@drincs/pixi-vn-json 1.7.1 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/importer.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage');var Y=Object.create;var z=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty;var ie=(s,e,i)=>e in s?z(s,e,{enumerable:true,configurable:true,writable:true,value:i}):s[e]=i;var B=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var $=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var te=(s,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Q(e))!ee.call(s,n)&&n!==i&&z(s,n,{get:()=>e[n],enumerable:!(o=j(e,n))||o.enumerable});return s};var ne=(s,e,i)=>(i=s!=null?Y(Z(s)):{},te(z(i,"default",{value:s,enumerable:true}),s));var v=(s,e,i)=>ie(s,typeof e!="symbol"?e+"":e,i);var G=$((A,K)=>{(function(s,e){typeof A=="object"?K.exports=A=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(A,function(){var s=s||(function(e,i){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 B=="function")try{o=B("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.")},a=Object.create||(function(){function t(){}return function(r){var m;return t.prototype=r,m=new t,t.prototype=null,m}})(),p={},c=p.lib={},h=c.Base=(function(){return {extend:function(t){var r=a(this);return t&&r.mixIn(t),(!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 t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var r in t)t.hasOwnProperty(r)&&(this[r]=t[r]);t.hasOwnProperty("toString")&&(this.toString=t.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),y=c.WordArray=h.extend({init:function(t,r){t=this.words=t||[],r!=i?this.sigBytes=r:this.sigBytes=t.length*4;},toString:function(t){return (t||g).stringify(this)},concat:function(t){var r=this.words,m=t.words,u=this.sigBytes,C=t.sigBytes;if(this.clamp(),u%4)for(var b=0;b<C;b++){var k=m[b>>>2]>>>24-b%4*8&255;r[u+b>>>2]|=k<<24-(u+b)%4*8;}else for(var E=0;E<C;E+=4)r[u+E>>>2]=m[E>>>2];return this.sigBytes+=C,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4);},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var r=[],m=0;m<t;m+=4)r.push(n());return new y.init(r,t)}}),d=p.enc={},g=d.Hex={stringify:function(t){for(var r=t.words,m=t.sigBytes,u=[],C=0;C<m;C++){var b=r[C>>>2]>>>24-C%4*8&255;u.push((b>>>4).toString(16)),u.push((b&15).toString(16));}return u.join("")},parse:function(t){for(var r=t.length,m=[],u=0;u<r;u+=2)m[u>>>3]|=parseInt(t.substr(u,2),16)<<24-u%8*4;return new y.init(m,r/2)}},x=d.Latin1={stringify:function(t){for(var r=t.words,m=t.sigBytes,u=[],C=0;C<m;C++){var b=r[C>>>2]>>>24-C%4*8&255;u.push(String.fromCharCode(b));}return u.join("")},parse:function(t){for(var r=t.length,m=[],u=0;u<r;u++)m[u>>>2]|=(t.charCodeAt(u)&255)<<24-u%4*8;return new y.init(m,r)}},S=d.Utf8={stringify:function(t){try{return decodeURIComponent(escape(x.stringify(t)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(t){return x.parse(unescape(encodeURIComponent(t)))}},V=c.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new y.init,this._nDataBytes=0;},_append:function(t){typeof t=="string"&&(t=S.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes;},_process:function(t){var r,m=this._data,u=m.words,C=m.sigBytes,b=this.blockSize,k=b*4,E=C/k;t?E=e.ceil(E):E=e.max((E|0)-this._minBufferSize,0);var L=E*b,H=e.min(L*4,C);if(L){for(var D=0;D<L;D+=b)this._doProcessBlock(u,D);r=u.splice(0,L),m.sigBytes-=H;}return new y.init(r,H)},clone:function(){var t=h.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});c.Hasher=V.extend({cfg:h.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset();},reset:function(){V.reset.call(this),this._doReset();},update:function(t){return this._append(t),this._process(),this},finalize:function(t){t&&this._append(t);var r=this._doFinalize();return r},blockSize:512/32,_createHelper:function(t){return function(r,m){return new t.init(m).finalize(r)}},_createHmacHelper:function(t){return function(r,m){return new P.HMAC.init(t,m).finalize(r)}}});var P=p.algo={};return p})(Math);return s});});var F=$((I,W)=>{(function(s,e){typeof I=="object"?W.exports=I=e(G()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(I,function(s){return (function(){var e=s,i=e.lib,o=i.WordArray,n=i.Hasher,a=e.algo,p=[],c=a.SHA1=n.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(h,y){for(var d=this._hash.words,g=d[0],x=d[1],S=d[2],V=d[3],J=d[4],P=0;P<80;P++){if(P<16)p[P]=h[y+P]|0;else {var t=p[P-3]^p[P-8]^p[P-14]^p[P-16];p[P]=t<<1|t>>>31;}var r=(g<<5|g>>>27)+J+p[P];P<20?r+=(x&S|~x&V)+1518500249:P<40?r+=(x^S^V)+1859775393:P<60?r+=(x&S|x&V|S&V)-1894007588:r+=(x^S^V)-899497514,J=V,V=S,S=x<<30|x>>>2,x=g,g=r;}d[0]=d[0]+g|0,d[1]=d[1]+x|0,d[2]=d[2]+S|0,d[3]=d[3]+V|0,d[4]=d[4]+J|0;},_doFinalize:function(){var h=this._data,y=h.words,d=this._nDataBytes*8,g=h.sigBytes*8;return y[g>>>5]|=128<<24-g%32,y[(g+64>>>9<<4)+14]=Math.floor(d/4294967296),y[(g+64>>>9<<4)+15]=d,h.sigBytes=y.length*4,this._process(),this._hash},clone:function(){var h=n.clone.call(this);return h._hash=this._hash.clone(),h}});e.SHA1=n._createHelper(c),e.HmacSHA1=n._createHmacHelper(c);})(),s.SHA1});});var N;(n=>(n.log=(a,...p)=>console.log(`[Pixi\u2019VN Json] ${a}`,...p),n.warn=(a,...p)=>console.warn(`[Pixi\u2019VN Json] ${a}`,...p),n.error=(a,...p)=>console.error(`[Pixi\u2019VN Json] ${a}`,...p),n.info=(a,...p)=>console.info(`[Pixi\u2019VN Json] ${a}`,...p)))(N||(N={}));var l=class{static init(e){this._loadAssets=e.loadAssets,this._soundOperation=e.soundOperation,this._imageOperation=e.imageOperation,this._videoOperation=e.videoOperation,this._imageContainerOperation=e.imageContainerOperation,this._canvasElementOperation=e.canvasElementOperation,this._setStorageValue=e.setStorageValue,this._inputOperation=e.inputOperation,this._tickerOperation=e.tickerOperation,this._effectOperation=e.effectOperation,this._animateOperation=e.animateOperation,this._getLogichValue=e.getLogichValue,this._getConditionalStep=e.getConditionalStep;}static get loadAssets(){return this._loadAssets}static get soundOperation(){return this._soundOperation}static get imageOperation(){return this._imageOperation}static get videoOperation(){return this._videoOperation}static get imageContainerOperation(){return this._imageContainerOperation}static get canvasElementOperation(){return this._canvasElementOperation}static get setStorageValue(){return this._setStorageValue}static get inputOperation(){return this._inputOperation}static get tickerOperation(){return this._tickerOperation}static get effectOperation(){return this._effectOperation}static get animateOperation(){return this._animateOperation}static get getLogichValue(){return this._getLogichValue}static get getConditionalStep(){return this._getConditionalStep}};v(l,"_loadAssets",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_soundOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_imageOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_videoOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_imageContainerOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_canvasElementOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_setStorageValue",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_inputOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_tickerOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_effectOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_animateOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_getLogichValue",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_getConditionalStep",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")});async function _(s,e){let i=l.getLogichValue(s);if(i)switch(i.type){case "sound":l.soundOperation(i);break;case "assets":case "bundle":await l.loadAssets(i);break;case "image":await l.imageOperation(i);break;case "video":await l.videoOperation(i);break;case "imagecontainer":await l.imageContainerOperation(i);break;case "canvaselement":await l.canvasElementOperation(i);break;case "value":l.setStorageValue(i);break;case "operationtoconvert":if(e){let o="";i.values.forEach(a=>{if(typeof a=="string")o+=a;else {let p=l.getLogichValue(a);o+=`${p}`;}});let n=await e(o);n&&await _(n,e);}break;case "input":l.inputOperation(i);break;case "fade":case "move":case "rotate":case "zoom":l.tickerOperation(i);break;case "shake":await l.effectOperation(i);break;case "animate":case "animate-sequence":l.animateOperation(i);break}}async function re(s,e={}){let{operationStringConvert:i,skipEmptyDialogs:o}=e;if(!Array.isArray(s))if(typeof s=="object"||typeof s=="string")s=[s];else {N.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let n=s.map(async c=>{if(typeof c=="string")try{c=JSON.parse(c);}catch(h){N.error("Error parsing imported Pixi'VN JSON",h),c={};}return c}),p=(await Promise.all(n)).map(async c=>{let h=[];if(c.initialOperations){c.initialOperations.forEach(d=>{let g=_(d,i?x=>i(x,{},{}):void 0);h.push(g);});let y={};[...storage.storage.storage.keys()].forEach((d,g)=>{y[d]=storage.storage.storage.get(d);}),storage.storage.startingStorage=y;}if(c.labels){let y=c.labels;for(let d in y)try{let g=y[d],x=new w(d,g,void 0,e);narration.RegisteredLabels.add(x);}catch(g){N.error(`Error creating JSON label ${d}`,g);}}return Promise.all(h)});await Promise.all(p);}var q=ne(F());var R="___param___";var f=class f{static t(e){return Array.isArray(e)?e.map(i=>f.translate(`${i}`)):f.translate(`${e}`)}static set beforeToTranslate(e){f._beforeToTranslate=e;}static set translate(e){f._translate=e;}static get translate(){return e=>{let i=e;return f._beforeToTranslate&&(i=f._beforeToTranslate(i)),i=f._translate(i),f._afterToTranslate&&(i=f._afterToTranslate(i)),i}}static set afterToTranslate(e){f._afterToTranslate=e;}static addKey(e,i,o){let n=o.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(a=>{e[a]===void 0&&(n==="empty_string"?e[a]="":n==="copy_key"&&(f._beforeToTranslate?e[a]=f._beforeToTranslate(a):e[a]=a));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&f.getConditionalsThenElse(e.then,i),e.else&&f.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(o=>{f.getConditionalsThenElse(o,i);});else if(e.elements.type==="ifelse"){let o=[];f.getConditionalsThenElse(e.elements,o),o.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let o=[];f.getConditionalsThenElse(e.elements,o),o.forEach(n=>{i.push(...n);});}else f.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&f.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(o=>{f.getConditionalsThenElse(o,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},o={}){let{defaultValue:n="copy_key"}=o;return e.forEach(a=>{if(a.choices){let p=[];Array.isArray(a.choices)?p=[a.choices]:p=f.getConditionalsThenElse(a.choices),p.forEach(c=>c.forEach(h=>{if("type"in h){let y=[];h.type==="ifelse"||h.type==="stepswitch"?f.getConditionalsThenElse(h,y):y=[h],y.map(g=>f.getConditionalsThenElse(g.text)).forEach(g=>{Array.isArray(g)&&g.forEach(x=>{Array.isArray(x)?x.forEach(S=>{typeof S=="string"?f.addKey(i,S,{defaultValue:n}):f.getConditionalsThenElse(S).forEach(V=>{Array.isArray(V)?V.forEach(J=>{typeof J=="string"&&f.addKey(i,J,{defaultValue:n});}):typeof V=="string"&&f.addKey(i,V,{defaultValue:n});});}):typeof x=="string"&&f.addKey(i,x,{defaultValue:n});});});}}));}if(a.dialogue){let p=[];Array.isArray(a.dialogue)?p=[a.dialogue]:p=f.getConditionalsThenElse(a.dialogue),p.forEach(c=>{if(typeof c=="string")f.addKey(i,c,{defaultValue:n});else if("text"in c){let h=f.getConditionalsThenElse(c.text);typeof h=="string"&&(h=[h]),h.forEach(y=>{typeof y=="string"?f.addKey(i,y,{defaultValue:n}):f.getConditionalsThenElse(y).forEach(g=>{typeof g=="string"?f.addKey(i,g,{defaultValue:n}):Array.isArray(g)&&g.forEach(x=>{typeof x=="string"?f.addKey(i,x,{defaultValue:n}):f.getConditionalsThenElse(x).forEach(S=>{typeof S=="string"&&f.addKey(i,S,{defaultValue:n});});});});});}});}a.conditionalStep&&f.getConditionalsThenElse(a.conditionalStep).forEach(c=>{Array.isArray(c)?f.generateJsonTranslation(c,i,o):f.generateJsonTranslation([c],i,o);});}),i}};v(f,"_beforeToTranslate"),v(f,"_translate",e=>e),v(f,"_afterToTranslate");var O=f;function ae(s){try{if(typeof s>"u")return s;let e=JSON.stringify(s);return JSON.parse(e)}catch(e){throw N.error("Error creating exportable element",s,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}var w=class extends narration.LabelAbstract{constructor(i,o,n,a={}){n||(n={}),n.onLoadingLabel=async()=>{for(let p of o){let c;if(typeof p=="function"?c=p():c=p,c=l.getConditionalStep(c),c.operations){let h=c.operations.map(y=>l.loadAssets(y));await Promise.all(h);}}};super(i,n);v(this,"_steps");v(this,"operationStringConvert");v(this,"skipEmptyDialogs",false);this._steps=o,this.operationStringConvert=a.operationStringConvert,this.skipEmptyDialogs=a.skipEmptyDialogs||false;}get steps(){return this._steps.map(i=>this.stepConverter(i))}get stepCount(){return this._steps.length}getStepById(i){if(i<0||i>=this._steps.length)return;let o=this._steps[i];return this.stepConverter(o)}getStepSha(i){if(i<0||i>=this.steps.length)return;let o=this._steps[i];return (0, q.default)(o.toString().toLocaleLowerCase()).toString()}getDialogueText(i){let o="";if(Array.isArray(i)){let n=[];i.forEach(a=>{if(typeof a=="string")n.push(a);else if(a&&typeof a=="object"){let p=l.getLogichValue(a);p?(p&&!Array.isArray(p)&&typeof p=="object"&&(p=l.getLogichValue(p)||""),Array.isArray(p)?n=n.concat(p):n.push(`${p}`)):n.push(`${a}`);}}),o=n;}else {let n=l.getLogichValue(i)||"";n&&!Array.isArray(n)&&typeof n=="object"&&(n=l.getLogichValue(n)||""),o=n;}return `${o}`}getDialogue(i){if(i==null)return;let o=l.getLogichValue(i);return o==null?"":typeof o=="object"&&"character"in o&&"text"in o?{character:o.character,text:O.t(this.getDialogueText(o.text))}:O.t(this.getDialogueText(o))}getChoices(i){return l.getLogichValue(i)?.map(a=>l.getLogichValue(a)).filter(a=>a!==void 0)}stepConverter(i){return async o=>{let n=typeof i=="function"?i():i;n=ae(n),n=l.getConditionalStep(n);let a=this.operationStringConvert?V=>this.operationStringConvert(V,n,o):void 0,{operations:p=[]}=n;for(let V of p)await _(V,a);let{labelToOpen:c=[]}=n,h=this.getChoices(n.choices),y=l.getLogichValue(n.glueEnabled),d=this.getDialogue(n.dialogue),g=[];Array.isArray(c)||(c=[c]),c.forEach(V=>{let J=l.getLogichValue(V);J&&g.push(J);});let x=l.getLogichValue(n.goNextStep),S=l.getLogichValue(n.end);if(h){let V=h.map(J=>{let P="";if(Array.isArray(J.text)){let r=[];J.text.forEach(m=>{if(typeof m=="string")r.push(O.t(m));else if(m&&typeof m=="object"){let u=l.getLogichValue(m);u&&!Array.isArray(u)&&typeof u=="object"&&(u=l.getLogichValue(u)||""),u&&(Array.isArray(u)?r=r.concat(O.t(u)):r.push(O.t(u)));}}),P=r;}else typeof J.text=="string"&&(P=O.t(J.text));return {label:J.label,text:P,props:J.props,type:J.type,oneTime:J.oneTime,onlyHaveNoChoice:J.onlyHaveNoChoice,autoSelect:J.autoSelect}});narration.narration.choiceMenuOptions=V;}else narration.narration.choiceMenuOptions=void 0;d!==void 0&&(narration.narration.dialogue=d,this.skipEmptyDialogs&&typeof d=="string"&&(d===""||RegExp(/^\s+$/).test(d))&&(x=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 V of g){let J=V.label;typeof J=="object"&&(J=l.getLogichValue(J)||"");let P=V.params?.map(t=>l.getLogichValue(t));o={...o,...V.props},V.type==="jump"?(narration.narration.openedLabels.length>0&&narration.narration.closeCurrentLabel(),storage.storage.setTempVariable(`${R}${narration.narration.openedLabels.length}`,P),await narration.narration.callLabel(J,o)):(storage.storage.setTempVariable(`${R}${narration.narration.openedLabels.length}`,P),await narration.narration.callLabel(J,o));}S==="game_end"?(narration.narration.closeAllLabels(),await narration.narration.goNext(o,{runNow:true})):S==="label_end"&&narration.narration.closeCurrentLabel(),x&&await narration.narration.goNext(o,{runNow:true});}}};exports.LabelJson=w;exports.importPixiVNJson=re;
1
+ 'use strict';var narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage');var Y=Object.create;var B=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty;var ie=(a,e,i)=>e in a?B(a,e,{enumerable:true,configurable:true,writable:true,value:i}):a[e]=i;var R=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var K=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var te=(a,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Z(e))!ee.call(a,n)&&n!==i&&B(a,n,{get:()=>e[n],enumerable:!(o=Q(e,n))||o.enumerable});return a};var ne=(a,e,i)=>(i=a!=null?Y(U(a)):{},te(B(i,"default",{value:a,enumerable:true}),a));var N=(a,e,i)=>ie(a,typeof e!="symbol"?e+"":e,i);var M=K((L,G)=>{(function(a,e){typeof L=="object"?G.exports=L=e():typeof define=="function"&&define.amd?define([],e):a.CryptoJS=e();})(L,function(){var a=a||(function(e,i){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 R=="function")try{o=R("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.")},s=Object.create||(function(){function t(){}return function(r){var x;return t.prototype=r,x=new t,t.prototype=null,x}})(),c={},f=c.lib={},g=f.Base=(function(){return {extend:function(t){var r=s(this);return t&&r.mixIn(t),(!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 t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var r in t)t.hasOwnProperty(r)&&(this[r]=t[r]);t.hasOwnProperty("toString")&&(this.toString=t.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),m=f.WordArray=g.extend({init:function(t,r){t=this.words=t||[],r!=i?this.sigBytes=r:this.sigBytes=t.length*4;},toString:function(t){return (t||h).stringify(this)},concat:function(t){var r=this.words,x=t.words,d=this.sigBytes,C=t.sigBytes;if(this.clamp(),d%4)for(var b=0;b<C;b++){var D=x[b>>>2]>>>24-b%4*8&255;r[d+b>>>2]|=D<<24-(d+b)%4*8;}else for(var T=0;T<C;T+=4)r[d+T>>>2]=x[T>>>2];return this.sigBytes+=C,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4);},clone:function(){var t=g.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var r=[],x=0;x<t;x+=4)r.push(n());return new m.init(r,t)}}),u=c.enc={},h=u.Hex={stringify:function(t){for(var r=t.words,x=t.sigBytes,d=[],C=0;C<x;C++){var b=r[C>>>2]>>>24-C%4*8&255;d.push((b>>>4).toString(16)),d.push((b&15).toString(16));}return d.join("")},parse:function(t){for(var r=t.length,x=[],d=0;d<r;d+=2)x[d>>>3]|=parseInt(t.substr(d,2),16)<<24-d%8*4;return new m.init(x,r/2)}},P=u.Latin1={stringify:function(t){for(var r=t.words,x=t.sigBytes,d=[],C=0;C<x;C++){var b=r[C>>>2]>>>24-C%4*8&255;d.push(String.fromCharCode(b));}return d.join("")},parse:function(t){for(var r=t.length,x=[],d=0;d<r;d++)x[d>>>2]|=(t.charCodeAt(d)&255)<<24-d%4*8;return new m.init(x,r)}},S=u.Utf8={stringify:function(t){try{return decodeURIComponent(escape(P.stringify(t)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(t){return P.parse(unescape(encodeURIComponent(t)))}},V=f.BufferedBlockAlgorithm=g.extend({reset:function(){this._data=new m.init,this._nDataBytes=0;},_append:function(t){typeof t=="string"&&(t=S.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes;},_process:function(t){var r,x=this._data,d=x.words,C=x.sigBytes,b=this.blockSize,D=b*4,T=C/D;t?T=e.ceil(T):T=e.max((T|0)-this._minBufferSize,0);var _=T*b,$=e.min(_*4,C);if(_){for(var z=0;z<_;z+=b)this._doProcessBlock(d,z);r=d.splice(0,_),x.sigBytes-=$;}return new m.init(r,$)},clone:function(){var t=g.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});f.Hasher=V.extend({cfg:g.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset();},reset:function(){V.reset.call(this),this._doReset();},update:function(t){return this._append(t),this._process(),this},finalize:function(t){t&&this._append(t);var r=this._doFinalize();return r},blockSize:512/32,_createHelper:function(t){return function(r,x){return new t.init(x).finalize(r)}},_createHmacHelper:function(t){return function(r,x){return new v.HMAC.init(t,x).finalize(r)}}});var v=c.algo={};return c})(Math);return a});});var F=K((I,W)=>{(function(a,e){typeof I=="object"?W.exports=I=e(M()):typeof define=="function"&&define.amd?define(["./core"],e):e(a.CryptoJS);})(I,function(a){return (function(){var e=a,i=e.lib,o=i.WordArray,n=i.Hasher,s=e.algo,c=[],f=s.SHA1=n.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(g,m){for(var u=this._hash.words,h=u[0],P=u[1],S=u[2],V=u[3],y=u[4],v=0;v<80;v++){if(v<16)c[v]=g[m+v]|0;else {var t=c[v-3]^c[v-8]^c[v-14]^c[v-16];c[v]=t<<1|t>>>31;}var r=(h<<5|h>>>27)+y+c[v];v<20?r+=(P&S|~P&V)+1518500249:v<40?r+=(P^S^V)+1859775393:v<60?r+=(P&S|P&V|S&V)-1894007588:r+=(P^S^V)-899497514,y=V,V=S,S=P<<30|P>>>2,P=h,h=r;}u[0]=u[0]+h|0,u[1]=u[1]+P|0,u[2]=u[2]+S|0,u[3]=u[3]+V|0,u[4]=u[4]+y|0;},_doFinalize:function(){var g=this._data,m=g.words,u=this._nDataBytes*8,h=g.sigBytes*8;return m[h>>>5]|=128<<24-h%32,m[(h+64>>>9<<4)+14]=Math.floor(u/4294967296),m[(h+64>>>9<<4)+15]=u,g.sigBytes=m.length*4,this._process(),this._hash},clone:function(){var g=n.clone.call(this);return g._hash=this._hash.clone(),g}});e.SHA1=n._createHelper(f),e.HmacSHA1=n._createHmacHelper(f);})(),a.SHA1});});var J;(n=>(n.log=(s,...c)=>console.log(`[Pixi\u2019VN Json] ${s}`,...c),n.warn=(s,...c)=>console.warn(`[Pixi\u2019VN Json] ${s}`,...c),n.error=(s,...c)=>console.error(`[Pixi\u2019VN Json] ${s}`,...c),n.info=(s,...c)=>console.info(`[Pixi\u2019VN Json] ${s}`,...c)))(J||(J={}));var l=class{static init(e){this._loadAssets=e.loadAssets,this._soundOperation=e.soundOperation,this._imageOperation=e.imageOperation,this._videoOperation=e.videoOperation,this._imageContainerOperation=e.imageContainerOperation,this._canvasElementOperation=e.canvasElementOperation,this._setStorageValue=e.setStorageValue,this._inputOperation=e.inputOperation,this._tickerOperation=e.tickerOperation,this._effectOperation=e.effectOperation,this._animateOperation=e.animateOperation,this._getLogichValue=e.getLogichValue,this._getConditionalStep=e.getConditionalStep;}static get loadAssets(){return this._loadAssets}static get soundOperation(){return this._soundOperation}static get imageOperation(){return this._imageOperation}static get videoOperation(){return this._videoOperation}static get imageContainerOperation(){return this._imageContainerOperation}static get canvasElementOperation(){return this._canvasElementOperation}static get setStorageValue(){return this._setStorageValue}static get inputOperation(){return this._inputOperation}static get tickerOperation(){return this._tickerOperation}static get effectOperation(){return this._effectOperation}static get animateOperation(){return this._animateOperation}static get getLogichValue(){return this._getLogichValue}static get getConditionalStep(){return this._getConditionalStep}};N(l,"_loadAssets",()=>{throw J.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.")}),N(l,"_soundOperation",()=>{throw J.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.")}),N(l,"_imageOperation",()=>{throw J.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.")}),N(l,"_videoOperation",()=>{throw J.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.")}),N(l,"_imageContainerOperation",()=>{throw J.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.")}),N(l,"_canvasElementOperation",()=>{throw J.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.")}),N(l,"_setStorageValue",()=>{throw J.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.")}),N(l,"_inputOperation",()=>{throw J.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.")}),N(l,"_tickerOperation",()=>{throw J.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.")}),N(l,"_effectOperation",()=>{throw J.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.")}),N(l,"_animateOperation",()=>{throw J.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.")}),N(l,"_getLogichValue",()=>{throw J.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.")}),N(l,"_getConditionalStep",()=>{throw J.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.")});async function A(a,e){let i=l.getLogichValue(a);if(i)switch(i.type){case "sound":l.soundOperation(i);break;case "assets":case "bundle":await l.loadAssets(i);break;case "image":await l.imageOperation(i);break;case "video":await l.videoOperation(i);break;case "imagecontainer":await l.imageContainerOperation(i);break;case "canvaselement":await l.canvasElementOperation(i);break;case "value":l.setStorageValue(i);break;case "operationtoconvert":if(e){let o="";i.values.forEach(s=>{if(typeof s=="string")o+=s;else {let c=l.getLogichValue(s);o+=`${c}`;}});let n=await e(o);n&&await A(n,e);}break;case "input":l.inputOperation(i);break;case "fade":case "move":case "rotate":case "zoom":l.tickerOperation(i);break;case "shake":await l.effectOperation(i);break;case "animate":case "animate-sequence":l.animateOperation(i);break}}async function re(a,e={}){let{operationStringConvert:i,skipEmptyDialogs:o}=e;if(!Array.isArray(a))if(typeof a=="object"||typeof a=="string")a=[a];else {J.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let n=a.map(async f=>{if(typeof f=="string")try{f=JSON.parse(f);}catch(g){J.error("Error parsing imported Pixi'VN JSON",g),f={};}return f}),c=(await Promise.all(n)).map(async f=>{let g=[];if(f.initialOperations){f.initialOperations.forEach(u=>{let h=A(u,i?P=>i(P,{},{}):void 0);g.push(h);});let m={};[...storage.storage.storage.keys()].forEach((u,h)=>{m[u]=storage.storage.storage.get(u);}),storage.storage.startingStorage=m;}if(f.labels){let m=f.labels;for(let u in m)try{let h=m[u],P=new O(u,h,void 0,e);narration.RegisteredLabels.add(P);}catch(h){J.error(`Error creating JSON label ${u}`,h);}}return Promise.all(g)});await Promise.all(c);}var q=ne(F());var H="___param___";var p=class p{static t(e){return Array.isArray(e)?e.map(i=>p.translate(`${i}`)):p.translate(`${e}`)}static set beforeToTranslate(e){p._beforeToTranslate=e;}static set translate(e){p._translate=e;}static get translate(){return e=>{let i=e;return p._beforeToTranslate&&(i=p._beforeToTranslate(i)),i=p._translate(i),p._afterToTranslate&&(i=p._afterToTranslate(i)),i}}static set afterToTranslate(e){p._afterToTranslate=e;}static addKey(e,i,o){let n=o.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(s=>{e[s]===void 0&&(n==="empty_string"?e[s]="":n==="copy_key"&&(p._beforeToTranslate?e[s]=p._beforeToTranslate(s):e[s]=s));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&p.getConditionalsThenElse(e.then,i),e.else&&p.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(o=>{p.getConditionalsThenElse(o,i);});else if(e.elements.type==="ifelse"){let o=[];p.getConditionalsThenElse(e.elements,o),o.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let o=[];p.getConditionalsThenElse(e.elements,o),o.forEach(n=>{i.push(...n);});}else p.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&p.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(o=>{p.getConditionalsThenElse(o,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},o={}){let{defaultValue:n="copy_key"}=o;return e.forEach(s=>{if(s.choices){let c=[];Array.isArray(s.choices)?c=[s.choices]:c=p.getConditionalsThenElse(s.choices),c.forEach(f=>f.forEach(g=>{if("type"in g){let m=[];g.type==="ifelse"||g.type==="stepswitch"?p.getConditionalsThenElse(g,m):m=[g],m.map(h=>p.getConditionalsThenElse(h.text)).forEach(h=>{Array.isArray(h)&&h.forEach(P=>{Array.isArray(P)?P.forEach(S=>{typeof S=="string"?p.addKey(i,S,{defaultValue:n}):p.getConditionalsThenElse(S).forEach(V=>{Array.isArray(V)?V.forEach(y=>{typeof y=="string"&&p.addKey(i,y,{defaultValue:n});}):typeof V=="string"&&p.addKey(i,V,{defaultValue:n});});}):typeof P=="string"&&p.addKey(i,P,{defaultValue:n});});});}}));}if(s.dialogue){let c=[];Array.isArray(s.dialogue)?c=[s.dialogue]:c=p.getConditionalsThenElse(s.dialogue),c.forEach(f=>{if(typeof f=="string")p.addKey(i,f,{defaultValue:n});else if("text"in f){let g=p.getConditionalsThenElse(f.text);typeof g=="string"&&(g=[g]),g.forEach(m=>{typeof m=="string"?p.addKey(i,m,{defaultValue:n}):p.getConditionalsThenElse(m).forEach(h=>{typeof h=="string"?p.addKey(i,h,{defaultValue:n}):Array.isArray(h)&&h.forEach(P=>{typeof P=="string"?p.addKey(i,P,{defaultValue:n}):p.getConditionalsThenElse(P).forEach(S=>{typeof S=="string"&&p.addKey(i,S,{defaultValue:n});});});});});}});}s.conditionalStep&&p.getConditionalsThenElse(s.conditionalStep).forEach(f=>{Array.isArray(f)?p.generateJsonTranslation(f,i,o):p.generateJsonTranslation([f],i,o);});}),i}};N(p,"_beforeToTranslate"),N(p,"_translate",e=>e),N(p,"_afterToTranslate");var E=p;function se(a){try{if(typeof a>"u")return a;let e=JSON.stringify(a);return JSON.parse(e)}catch(e){throw J.error("Error creating exportable element",a,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}var O=class extends narration.LabelAbstract{constructor(i,o,n,s={}){n||(n={}),n.onLoadingLabel=async()=>{for(let c of o){let f;if(typeof c=="function"?f=c():f=c,f=l.getConditionalStep(f),f.operations){let g=f.operations.map(m=>l.loadAssets(m));await Promise.all(g);}}};super(i,n);N(this,"_steps");N(this,"operationStringConvert");N(this,"skipEmptyDialogs",false);this._steps=o,this.operationStringConvert=s.operationStringConvert,this.skipEmptyDialogs=s.skipEmptyDialogs||false;}get steps(){return this._steps.map(i=>this.stepConverter(i))}get stepCount(){return this._steps.length}getStepById(i){if(i<0||i>=this._steps.length)return;let o=this._steps[i];return this.stepConverter(o)}getStepSha(i){if(i<0||i>=this.steps.length)return;let o=this._steps[i];return (0, q.default)(o.toString().toLocaleLowerCase()).toString()}getDialogueText(i){let o="";if(Array.isArray(i)){let n=[];i.forEach(s=>{if(typeof s=="string")n.push(s);else if(s&&typeof s=="object"){let c=l.getLogichValue(s);c?(c&&!Array.isArray(c)&&typeof c=="object"&&(c=l.getLogichValue(c)||""),Array.isArray(c)?n=n.concat(c):n.push(`${c}`)):n.push(`${s}`);}}),o=n;}else {let n=l.getLogichValue(i)||"";n&&!Array.isArray(n)&&typeof n=="object"&&(n=l.getLogichValue(n)||""),o=n;}return `${o}`}getDialogue(i){if(i==null)return;let o=l.getLogichValue(i);return o==null?"":typeof o=="object"&&"character"in o&&"text"in o?{character:o.character,text:E.t(this.getDialogueText(o.text))}:E.t(this.getDialogueText(o))}getChoices(i){return l.getLogichValue(i)?.map(s=>l.getLogichValue(s)).filter(s=>s!==void 0)}stepConverter(i){return async o=>{let n=typeof i=="function"?i():i;n=se(n),n=l.getConditionalStep(n);let s=this.operationStringConvert?V=>this.operationStringConvert(V,n,o):void 0,{operations:c=[]}=n;for(let V of c)await A(V,s);let{labelToOpen:f=[]}=n,g=this.getChoices(n.choices),m=l.getLogichValue(n.glueEnabled),u=this.getDialogue(n.dialogue),h=[];Array.isArray(f)||(f=[f]),f.forEach(V=>{let y=l.getLogichValue(V);y&&h.push(y);});let P=l.getLogichValue(n.goNextStep),S=l.getLogichValue(n.end);if(g){let V=g.map(y=>{let v="";if(Array.isArray(y.text)){let r=[];y.text.forEach(x=>{if(typeof x=="string")r.push(E.t(x));else if(x&&typeof x=="object"){let d=l.getLogichValue(x);d&&!Array.isArray(d)&&typeof d=="object"&&(d=l.getLogichValue(d)||""),d&&(Array.isArray(d)?r=r.concat(E.t(d)):r.push(E.t(d)));}}),v=r;}else typeof y.text=="string"&&(v=E.t(y.text));return {label:y.label,text:v,props:y.props,type:y.type,oneTime:y.oneTime,onlyHaveNoChoice:y.onlyHaveNoChoice,autoSelect:y.autoSelect}});narration.narration.choiceMenuOptions=V;}else narration.narration.choiceMenuOptions=void 0;u!==void 0&&(narration.narration.dialogue=u,this.skipEmptyDialogs&&typeof u=="string"&&(u===""||RegExp(/^\s+$/).test(u))&&(P=true)),m?storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):m===false&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let V of h){let y=V.label;typeof y=="object"&&(y=l.getLogichValue(y)||"");let v=V.params?.map(t=>l.getLogichValue(t));o={...o,...V.props},V.type==="jump"?(narration.narration.openedLabels.length>0&&narration.narration.closeCurrentLabel(),storage.storage.setTempVariable(`${H}${narration.narration.openedLabels.length}`,v),await narration.narration.callLabel(y,o)):(storage.storage.setTempVariable(`${H}${narration.narration.openedLabels.length}`,v),await narration.narration.callLabel(y,o));}S==="game_end"?(narration.narration.closeAllLabels(),await narration.narration.goNext(o,{runNow:true})):S==="label_end"&&narration.narration.closeCurrentLabel(),P&&await narration.narration.goNext(o,{runNow:true});}}};exports.LabelJson=O;exports.importPixiVNJson=re;
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';var Y=Object.create;var z=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty;var ie=(s,e,i)=>e in s?z(s,e,{enumerable:true,configurable:true,writable:true,value:i}):s[e]=i;var B=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var $=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var te=(s,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Q(e))!ee.call(s,n)&&n!==i&&z(s,n,{get:()=>e[n],enumerable:!(o=j(e,n))||o.enumerable});return s};var ne=(s,e,i)=>(i=s!=null?Y(Z(s)):{},te(z(i,"default",{value:s,enumerable:true}),s));var v=(s,e,i)=>ie(s,typeof e!="symbol"?e+"":e,i);var G=$((A,K)=>{(function(s,e){typeof A=="object"?K.exports=A=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(A,function(){var s=s||(function(e,i){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 B=="function")try{o=B("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.")},a=Object.create||(function(){function t(){}return function(r){var m;return t.prototype=r,m=new t,t.prototype=null,m}})(),p={},c=p.lib={},h=c.Base=(function(){return {extend:function(t){var r=a(this);return t&&r.mixIn(t),(!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 t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var r in t)t.hasOwnProperty(r)&&(this[r]=t[r]);t.hasOwnProperty("toString")&&(this.toString=t.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),y=c.WordArray=h.extend({init:function(t,r){t=this.words=t||[],r!=i?this.sigBytes=r:this.sigBytes=t.length*4;},toString:function(t){return (t||g).stringify(this)},concat:function(t){var r=this.words,m=t.words,u=this.sigBytes,C=t.sigBytes;if(this.clamp(),u%4)for(var b=0;b<C;b++){var k=m[b>>>2]>>>24-b%4*8&255;r[u+b>>>2]|=k<<24-(u+b)%4*8;}else for(var E=0;E<C;E+=4)r[u+E>>>2]=m[E>>>2];return this.sigBytes+=C,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4);},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var r=[],m=0;m<t;m+=4)r.push(n());return new y.init(r,t)}}),d=p.enc={},g=d.Hex={stringify:function(t){for(var r=t.words,m=t.sigBytes,u=[],C=0;C<m;C++){var b=r[C>>>2]>>>24-C%4*8&255;u.push((b>>>4).toString(16)),u.push((b&15).toString(16));}return u.join("")},parse:function(t){for(var r=t.length,m=[],u=0;u<r;u+=2)m[u>>>3]|=parseInt(t.substr(u,2),16)<<24-u%8*4;return new y.init(m,r/2)}},x=d.Latin1={stringify:function(t){for(var r=t.words,m=t.sigBytes,u=[],C=0;C<m;C++){var b=r[C>>>2]>>>24-C%4*8&255;u.push(String.fromCharCode(b));}return u.join("")},parse:function(t){for(var r=t.length,m=[],u=0;u<r;u++)m[u>>>2]|=(t.charCodeAt(u)&255)<<24-u%4*8;return new y.init(m,r)}},S=d.Utf8={stringify:function(t){try{return decodeURIComponent(escape(x.stringify(t)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(t){return x.parse(unescape(encodeURIComponent(t)))}},V=c.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new y.init,this._nDataBytes=0;},_append:function(t){typeof t=="string"&&(t=S.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes;},_process:function(t){var r,m=this._data,u=m.words,C=m.sigBytes,b=this.blockSize,k=b*4,E=C/k;t?E=e.ceil(E):E=e.max((E|0)-this._minBufferSize,0);var L=E*b,H=e.min(L*4,C);if(L){for(var D=0;D<L;D+=b)this._doProcessBlock(u,D);r=u.splice(0,L),m.sigBytes-=H;}return new y.init(r,H)},clone:function(){var t=h.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});c.Hasher=V.extend({cfg:h.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset();},reset:function(){V.reset.call(this),this._doReset();},update:function(t){return this._append(t),this._process(),this},finalize:function(t){t&&this._append(t);var r=this._doFinalize();return r},blockSize:512/32,_createHelper:function(t){return function(r,m){return new t.init(m).finalize(r)}},_createHmacHelper:function(t){return function(r,m){return new P.HMAC.init(t,m).finalize(r)}}});var P=p.algo={};return p})(Math);return s});});var F=$((I,W)=>{(function(s,e){typeof I=="object"?W.exports=I=e(G()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(I,function(s){return (function(){var e=s,i=e.lib,o=i.WordArray,n=i.Hasher,a=e.algo,p=[],c=a.SHA1=n.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(h,y){for(var d=this._hash.words,g=d[0],x=d[1],S=d[2],V=d[3],J=d[4],P=0;P<80;P++){if(P<16)p[P]=h[y+P]|0;else {var t=p[P-3]^p[P-8]^p[P-14]^p[P-16];p[P]=t<<1|t>>>31;}var r=(g<<5|g>>>27)+J+p[P];P<20?r+=(x&S|~x&V)+1518500249:P<40?r+=(x^S^V)+1859775393:P<60?r+=(x&S|x&V|S&V)-1894007588:r+=(x^S^V)-899497514,J=V,V=S,S=x<<30|x>>>2,x=g,g=r;}d[0]=d[0]+g|0,d[1]=d[1]+x|0,d[2]=d[2]+S|0,d[3]=d[3]+V|0,d[4]=d[4]+J|0;},_doFinalize:function(){var h=this._data,y=h.words,d=this._nDataBytes*8,g=h.sigBytes*8;return y[g>>>5]|=128<<24-g%32,y[(g+64>>>9<<4)+14]=Math.floor(d/4294967296),y[(g+64>>>9<<4)+15]=d,h.sigBytes=y.length*4,this._process(),this._hash},clone:function(){var h=n.clone.call(this);return h._hash=this._hash.clone(),h}});e.SHA1=n._createHelper(c),e.HmacSHA1=n._createHmacHelper(c);})(),s.SHA1});});var N;(n=>(n.log=(a,...p)=>console.log(`[Pixi\u2019VN Json] ${a}`,...p),n.warn=(a,...p)=>console.warn(`[Pixi\u2019VN Json] ${a}`,...p),n.error=(a,...p)=>console.error(`[Pixi\u2019VN Json] ${a}`,...p),n.info=(a,...p)=>console.info(`[Pixi\u2019VN Json] ${a}`,...p)))(N||(N={}));var l=class{static init(e){this._loadAssets=e.loadAssets,this._soundOperation=e.soundOperation,this._imageOperation=e.imageOperation,this._videoOperation=e.videoOperation,this._imageContainerOperation=e.imageContainerOperation,this._canvasElementOperation=e.canvasElementOperation,this._setStorageValue=e.setStorageValue,this._inputOperation=e.inputOperation,this._tickerOperation=e.tickerOperation,this._effectOperation=e.effectOperation,this._animateOperation=e.animateOperation,this._getLogichValue=e.getLogichValue,this._getConditionalStep=e.getConditionalStep;}static get loadAssets(){return this._loadAssets}static get soundOperation(){return this._soundOperation}static get imageOperation(){return this._imageOperation}static get videoOperation(){return this._videoOperation}static get imageContainerOperation(){return this._imageContainerOperation}static get canvasElementOperation(){return this._canvasElementOperation}static get setStorageValue(){return this._setStorageValue}static get inputOperation(){return this._inputOperation}static get tickerOperation(){return this._tickerOperation}static get effectOperation(){return this._effectOperation}static get animateOperation(){return this._animateOperation}static get getLogichValue(){return this._getLogichValue}static get getConditionalStep(){return this._getConditionalStep}};v(l,"_loadAssets",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_soundOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_imageOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_videoOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_imageContainerOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_canvasElementOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_setStorageValue",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_inputOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_tickerOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_effectOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_animateOperation",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_getLogichValue",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),v(l,"_getConditionalStep",()=>{throw N.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")});async function _(s,e){let i=l.getLogichValue(s);if(i)switch(i.type){case "sound":l.soundOperation(i);break;case "assets":case "bundle":await l.loadAssets(i);break;case "image":await l.imageOperation(i);break;case "video":await l.videoOperation(i);break;case "imagecontainer":await l.imageContainerOperation(i);break;case "canvaselement":await l.canvasElementOperation(i);break;case "value":l.setStorageValue(i);break;case "operationtoconvert":if(e){let o="";i.values.forEach(a=>{if(typeof a=="string")o+=a;else {let p=l.getLogichValue(a);o+=`${p}`;}});let n=await e(o);n&&await _(n,e);}break;case "input":l.inputOperation(i);break;case "fade":case "move":case "rotate":case "zoom":l.tickerOperation(i);break;case "shake":await l.effectOperation(i);break;case "animate":case "animate-sequence":l.animateOperation(i);break}}async function re(s,e={}){let{operationStringConvert:i,skipEmptyDialogs:o}=e;if(!Array.isArray(s))if(typeof s=="object"||typeof s=="string")s=[s];else {N.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let n=s.map(async c=>{if(typeof c=="string")try{c=JSON.parse(c);}catch(h){N.error("Error parsing imported Pixi'VN JSON",h),c={};}return c}),p=(await Promise.all(n)).map(async c=>{let h=[];if(c.initialOperations){c.initialOperations.forEach(d=>{let g=_(d,i?x=>i(x,{},{}):void 0);h.push(g);});let y={};[...storage.storage.keys()].forEach((d,g)=>{y[d]=storage.storage.get(d);}),storage.startingStorage=y;}if(c.labels){let y=c.labels;for(let d in y)try{let g=y[d],x=new w(d,g,void 0,e);RegisteredLabels.add(x);}catch(g){N.error(`Error creating JSON label ${d}`,g);}}return Promise.all(h)});await Promise.all(p);}var q=ne(F());var R="___param___";var f=class f{static t(e){return Array.isArray(e)?e.map(i=>f.translate(`${i}`)):f.translate(`${e}`)}static set beforeToTranslate(e){f._beforeToTranslate=e;}static set translate(e){f._translate=e;}static get translate(){return e=>{let i=e;return f._beforeToTranslate&&(i=f._beforeToTranslate(i)),i=f._translate(i),f._afterToTranslate&&(i=f._afterToTranslate(i)),i}}static set afterToTranslate(e){f._afterToTranslate=e;}static addKey(e,i,o){let n=o.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(a=>{e[a]===void 0&&(n==="empty_string"?e[a]="":n==="copy_key"&&(f._beforeToTranslate?e[a]=f._beforeToTranslate(a):e[a]=a));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&f.getConditionalsThenElse(e.then,i),e.else&&f.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(o=>{f.getConditionalsThenElse(o,i);});else if(e.elements.type==="ifelse"){let o=[];f.getConditionalsThenElse(e.elements,o),o.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let o=[];f.getConditionalsThenElse(e.elements,o),o.forEach(n=>{i.push(...n);});}else f.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&f.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(o=>{f.getConditionalsThenElse(o,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},o={}){let{defaultValue:n="copy_key"}=o;return e.forEach(a=>{if(a.choices){let p=[];Array.isArray(a.choices)?p=[a.choices]:p=f.getConditionalsThenElse(a.choices),p.forEach(c=>c.forEach(h=>{if("type"in h){let y=[];h.type==="ifelse"||h.type==="stepswitch"?f.getConditionalsThenElse(h,y):y=[h],y.map(g=>f.getConditionalsThenElse(g.text)).forEach(g=>{Array.isArray(g)&&g.forEach(x=>{Array.isArray(x)?x.forEach(S=>{typeof S=="string"?f.addKey(i,S,{defaultValue:n}):f.getConditionalsThenElse(S).forEach(V=>{Array.isArray(V)?V.forEach(J=>{typeof J=="string"&&f.addKey(i,J,{defaultValue:n});}):typeof V=="string"&&f.addKey(i,V,{defaultValue:n});});}):typeof x=="string"&&f.addKey(i,x,{defaultValue:n});});});}}));}if(a.dialogue){let p=[];Array.isArray(a.dialogue)?p=[a.dialogue]:p=f.getConditionalsThenElse(a.dialogue),p.forEach(c=>{if(typeof c=="string")f.addKey(i,c,{defaultValue:n});else if("text"in c){let h=f.getConditionalsThenElse(c.text);typeof h=="string"&&(h=[h]),h.forEach(y=>{typeof y=="string"?f.addKey(i,y,{defaultValue:n}):f.getConditionalsThenElse(y).forEach(g=>{typeof g=="string"?f.addKey(i,g,{defaultValue:n}):Array.isArray(g)&&g.forEach(x=>{typeof x=="string"?f.addKey(i,x,{defaultValue:n}):f.getConditionalsThenElse(x).forEach(S=>{typeof S=="string"&&f.addKey(i,S,{defaultValue:n});});});});});}});}a.conditionalStep&&f.getConditionalsThenElse(a.conditionalStep).forEach(c=>{Array.isArray(c)?f.generateJsonTranslation(c,i,o):f.generateJsonTranslation([c],i,o);});}),i}};v(f,"_beforeToTranslate"),v(f,"_translate",e=>e),v(f,"_afterToTranslate");var O=f;function ae(s){try{if(typeof s>"u")return s;let e=JSON.stringify(s);return JSON.parse(e)}catch(e){throw N.error("Error creating exportable element",s,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}var w=class extends LabelAbstract{constructor(i,o,n,a={}){n||(n={}),n.onLoadingLabel=async()=>{for(let p of o){let c;if(typeof p=="function"?c=p():c=p,c=l.getConditionalStep(c),c.operations){let h=c.operations.map(y=>l.loadAssets(y));await Promise.all(h);}}};super(i,n);v(this,"_steps");v(this,"operationStringConvert");v(this,"skipEmptyDialogs",false);this._steps=o,this.operationStringConvert=a.operationStringConvert,this.skipEmptyDialogs=a.skipEmptyDialogs||false;}get steps(){return this._steps.map(i=>this.stepConverter(i))}get stepCount(){return this._steps.length}getStepById(i){if(i<0||i>=this._steps.length)return;let o=this._steps[i];return this.stepConverter(o)}getStepSha(i){if(i<0||i>=this.steps.length)return;let o=this._steps[i];return (0, q.default)(o.toString().toLocaleLowerCase()).toString()}getDialogueText(i){let o="";if(Array.isArray(i)){let n=[];i.forEach(a=>{if(typeof a=="string")n.push(a);else if(a&&typeof a=="object"){let p=l.getLogichValue(a);p?(p&&!Array.isArray(p)&&typeof p=="object"&&(p=l.getLogichValue(p)||""),Array.isArray(p)?n=n.concat(p):n.push(`${p}`)):n.push(`${a}`);}}),o=n;}else {let n=l.getLogichValue(i)||"";n&&!Array.isArray(n)&&typeof n=="object"&&(n=l.getLogichValue(n)||""),o=n;}return `${o}`}getDialogue(i){if(i==null)return;let o=l.getLogichValue(i);return o==null?"":typeof o=="object"&&"character"in o&&"text"in o?{character:o.character,text:O.t(this.getDialogueText(o.text))}:O.t(this.getDialogueText(o))}getChoices(i){return l.getLogichValue(i)?.map(a=>l.getLogichValue(a)).filter(a=>a!==void 0)}stepConverter(i){return async o=>{let n=typeof i=="function"?i():i;n=ae(n),n=l.getConditionalStep(n);let a=this.operationStringConvert?V=>this.operationStringConvert(V,n,o):void 0,{operations:p=[]}=n;for(let V of p)await _(V,a);let{labelToOpen:c=[]}=n,h=this.getChoices(n.choices),y=l.getLogichValue(n.glueEnabled),d=this.getDialogue(n.dialogue),g=[];Array.isArray(c)||(c=[c]),c.forEach(V=>{let J=l.getLogichValue(V);J&&g.push(J);});let x=l.getLogichValue(n.goNextStep),S=l.getLogichValue(n.end);if(h){let V=h.map(J=>{let P="";if(Array.isArray(J.text)){let r=[];J.text.forEach(m=>{if(typeof m=="string")r.push(O.t(m));else if(m&&typeof m=="object"){let u=l.getLogichValue(m);u&&!Array.isArray(u)&&typeof u=="object"&&(u=l.getLogichValue(u)||""),u&&(Array.isArray(u)?r=r.concat(O.t(u)):r.push(O.t(u)));}}),P=r;}else typeof J.text=="string"&&(P=O.t(J.text));return {label:J.label,text:P,props:J.props,type:J.type,oneTime:J.oneTime,onlyHaveNoChoice:J.onlyHaveNoChoice,autoSelect:J.autoSelect}});narration.choiceMenuOptions=V;}else narration.choiceMenuOptions=void 0;d!==void 0&&(narration.dialogue=d,this.skipEmptyDialogs&&typeof d=="string"&&(d===""||RegExp(/^\s+$/).test(d))&&(x=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 V of g){let J=V.label;typeof J=="object"&&(J=l.getLogichValue(J)||"");let P=V.params?.map(t=>l.getLogichValue(t));o={...o,...V.props},V.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${R}${narration.openedLabels.length}`,P),await narration.callLabel(J,o)):(storage.setTempVariable(`${R}${narration.openedLabels.length}`,P),await narration.callLabel(J,o));}S==="game_end"?(narration.closeAllLabels(),await narration.goNext(o,{runNow:true})):S==="label_end"&&narration.closeCurrentLabel(),x&&await narration.goNext(o,{runNow:true});}}};export{w as LabelJson,re as importPixiVNJson};
1
+ import {RegisteredLabels,LabelAbstract,narration}from'@drincs/pixi-vn/narration';import {storage,SYSTEM_RESERVED_STORAGE_KEYS}from'@drincs/pixi-vn/storage';var Y=Object.create;var B=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty;var ie=(a,e,i)=>e in a?B(a,e,{enumerable:true,configurable:true,writable:true,value:i}):a[e]=i;var R=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var K=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var te=(a,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Z(e))!ee.call(a,n)&&n!==i&&B(a,n,{get:()=>e[n],enumerable:!(o=Q(e,n))||o.enumerable});return a};var ne=(a,e,i)=>(i=a!=null?Y(U(a)):{},te(B(i,"default",{value:a,enumerable:true}),a));var N=(a,e,i)=>ie(a,typeof e!="symbol"?e+"":e,i);var M=K((L,G)=>{(function(a,e){typeof L=="object"?G.exports=L=e():typeof define=="function"&&define.amd?define([],e):a.CryptoJS=e();})(L,function(){var a=a||(function(e,i){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 R=="function")try{o=R("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.")},s=Object.create||(function(){function t(){}return function(r){var x;return t.prototype=r,x=new t,t.prototype=null,x}})(),c={},f=c.lib={},g=f.Base=(function(){return {extend:function(t){var r=s(this);return t&&r.mixIn(t),(!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 t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var r in t)t.hasOwnProperty(r)&&(this[r]=t[r]);t.hasOwnProperty("toString")&&(this.toString=t.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),m=f.WordArray=g.extend({init:function(t,r){t=this.words=t||[],r!=i?this.sigBytes=r:this.sigBytes=t.length*4;},toString:function(t){return (t||h).stringify(this)},concat:function(t){var r=this.words,x=t.words,d=this.sigBytes,C=t.sigBytes;if(this.clamp(),d%4)for(var b=0;b<C;b++){var D=x[b>>>2]>>>24-b%4*8&255;r[d+b>>>2]|=D<<24-(d+b)%4*8;}else for(var T=0;T<C;T+=4)r[d+T>>>2]=x[T>>>2];return this.sigBytes+=C,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4);},clone:function(){var t=g.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var r=[],x=0;x<t;x+=4)r.push(n());return new m.init(r,t)}}),u=c.enc={},h=u.Hex={stringify:function(t){for(var r=t.words,x=t.sigBytes,d=[],C=0;C<x;C++){var b=r[C>>>2]>>>24-C%4*8&255;d.push((b>>>4).toString(16)),d.push((b&15).toString(16));}return d.join("")},parse:function(t){for(var r=t.length,x=[],d=0;d<r;d+=2)x[d>>>3]|=parseInt(t.substr(d,2),16)<<24-d%8*4;return new m.init(x,r/2)}},P=u.Latin1={stringify:function(t){for(var r=t.words,x=t.sigBytes,d=[],C=0;C<x;C++){var b=r[C>>>2]>>>24-C%4*8&255;d.push(String.fromCharCode(b));}return d.join("")},parse:function(t){for(var r=t.length,x=[],d=0;d<r;d++)x[d>>>2]|=(t.charCodeAt(d)&255)<<24-d%4*8;return new m.init(x,r)}},S=u.Utf8={stringify:function(t){try{return decodeURIComponent(escape(P.stringify(t)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(t){return P.parse(unescape(encodeURIComponent(t)))}},V=f.BufferedBlockAlgorithm=g.extend({reset:function(){this._data=new m.init,this._nDataBytes=0;},_append:function(t){typeof t=="string"&&(t=S.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes;},_process:function(t){var r,x=this._data,d=x.words,C=x.sigBytes,b=this.blockSize,D=b*4,T=C/D;t?T=e.ceil(T):T=e.max((T|0)-this._minBufferSize,0);var _=T*b,$=e.min(_*4,C);if(_){for(var z=0;z<_;z+=b)this._doProcessBlock(d,z);r=d.splice(0,_),x.sigBytes-=$;}return new m.init(r,$)},clone:function(){var t=g.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});f.Hasher=V.extend({cfg:g.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset();},reset:function(){V.reset.call(this),this._doReset();},update:function(t){return this._append(t),this._process(),this},finalize:function(t){t&&this._append(t);var r=this._doFinalize();return r},blockSize:512/32,_createHelper:function(t){return function(r,x){return new t.init(x).finalize(r)}},_createHmacHelper:function(t){return function(r,x){return new v.HMAC.init(t,x).finalize(r)}}});var v=c.algo={};return c})(Math);return a});});var F=K((I,W)=>{(function(a,e){typeof I=="object"?W.exports=I=e(M()):typeof define=="function"&&define.amd?define(["./core"],e):e(a.CryptoJS);})(I,function(a){return (function(){var e=a,i=e.lib,o=i.WordArray,n=i.Hasher,s=e.algo,c=[],f=s.SHA1=n.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(g,m){for(var u=this._hash.words,h=u[0],P=u[1],S=u[2],V=u[3],y=u[4],v=0;v<80;v++){if(v<16)c[v]=g[m+v]|0;else {var t=c[v-3]^c[v-8]^c[v-14]^c[v-16];c[v]=t<<1|t>>>31;}var r=(h<<5|h>>>27)+y+c[v];v<20?r+=(P&S|~P&V)+1518500249:v<40?r+=(P^S^V)+1859775393:v<60?r+=(P&S|P&V|S&V)-1894007588:r+=(P^S^V)-899497514,y=V,V=S,S=P<<30|P>>>2,P=h,h=r;}u[0]=u[0]+h|0,u[1]=u[1]+P|0,u[2]=u[2]+S|0,u[3]=u[3]+V|0,u[4]=u[4]+y|0;},_doFinalize:function(){var g=this._data,m=g.words,u=this._nDataBytes*8,h=g.sigBytes*8;return m[h>>>5]|=128<<24-h%32,m[(h+64>>>9<<4)+14]=Math.floor(u/4294967296),m[(h+64>>>9<<4)+15]=u,g.sigBytes=m.length*4,this._process(),this._hash},clone:function(){var g=n.clone.call(this);return g._hash=this._hash.clone(),g}});e.SHA1=n._createHelper(f),e.HmacSHA1=n._createHmacHelper(f);})(),a.SHA1});});var J;(n=>(n.log=(s,...c)=>console.log(`[Pixi\u2019VN Json] ${s}`,...c),n.warn=(s,...c)=>console.warn(`[Pixi\u2019VN Json] ${s}`,...c),n.error=(s,...c)=>console.error(`[Pixi\u2019VN Json] ${s}`,...c),n.info=(s,...c)=>console.info(`[Pixi\u2019VN Json] ${s}`,...c)))(J||(J={}));var l=class{static init(e){this._loadAssets=e.loadAssets,this._soundOperation=e.soundOperation,this._imageOperation=e.imageOperation,this._videoOperation=e.videoOperation,this._imageContainerOperation=e.imageContainerOperation,this._canvasElementOperation=e.canvasElementOperation,this._setStorageValue=e.setStorageValue,this._inputOperation=e.inputOperation,this._tickerOperation=e.tickerOperation,this._effectOperation=e.effectOperation,this._animateOperation=e.animateOperation,this._getLogichValue=e.getLogichValue,this._getConditionalStep=e.getConditionalStep;}static get loadAssets(){return this._loadAssets}static get soundOperation(){return this._soundOperation}static get imageOperation(){return this._imageOperation}static get videoOperation(){return this._videoOperation}static get imageContainerOperation(){return this._imageContainerOperation}static get canvasElementOperation(){return this._canvasElementOperation}static get setStorageValue(){return this._setStorageValue}static get inputOperation(){return this._inputOperation}static get tickerOperation(){return this._tickerOperation}static get effectOperation(){return this._effectOperation}static get animateOperation(){return this._animateOperation}static get getLogichValue(){return this._getLogichValue}static get getConditionalStep(){return this._getConditionalStep}};N(l,"_loadAssets",()=>{throw J.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.")}),N(l,"_soundOperation",()=>{throw J.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.")}),N(l,"_imageOperation",()=>{throw J.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.")}),N(l,"_videoOperation",()=>{throw J.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.")}),N(l,"_imageContainerOperation",()=>{throw J.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.")}),N(l,"_canvasElementOperation",()=>{throw J.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.")}),N(l,"_setStorageValue",()=>{throw J.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.")}),N(l,"_inputOperation",()=>{throw J.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.")}),N(l,"_tickerOperation",()=>{throw J.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.")}),N(l,"_effectOperation",()=>{throw J.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.")}),N(l,"_animateOperation",()=>{throw J.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.")}),N(l,"_getLogichValue",()=>{throw J.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.")}),N(l,"_getConditionalStep",()=>{throw J.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.")});async function A(a,e){let i=l.getLogichValue(a);if(i)switch(i.type){case "sound":l.soundOperation(i);break;case "assets":case "bundle":await l.loadAssets(i);break;case "image":await l.imageOperation(i);break;case "video":await l.videoOperation(i);break;case "imagecontainer":await l.imageContainerOperation(i);break;case "canvaselement":await l.canvasElementOperation(i);break;case "value":l.setStorageValue(i);break;case "operationtoconvert":if(e){let o="";i.values.forEach(s=>{if(typeof s=="string")o+=s;else {let c=l.getLogichValue(s);o+=`${c}`;}});let n=await e(o);n&&await A(n,e);}break;case "input":l.inputOperation(i);break;case "fade":case "move":case "rotate":case "zoom":l.tickerOperation(i);break;case "shake":await l.effectOperation(i);break;case "animate":case "animate-sequence":l.animateOperation(i);break}}async function re(a,e={}){let{operationStringConvert:i,skipEmptyDialogs:o}=e;if(!Array.isArray(a))if(typeof a=="object"||typeof a=="string")a=[a];else {J.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let n=a.map(async f=>{if(typeof f=="string")try{f=JSON.parse(f);}catch(g){J.error("Error parsing imported Pixi'VN JSON",g),f={};}return f}),c=(await Promise.all(n)).map(async f=>{let g=[];if(f.initialOperations){f.initialOperations.forEach(u=>{let h=A(u,i?P=>i(P,{},{}):void 0);g.push(h);});let m={};[...storage.storage.keys()].forEach((u,h)=>{m[u]=storage.storage.get(u);}),storage.startingStorage=m;}if(f.labels){let m=f.labels;for(let u in m)try{let h=m[u],P=new O(u,h,void 0,e);RegisteredLabels.add(P);}catch(h){J.error(`Error creating JSON label ${u}`,h);}}return Promise.all(g)});await Promise.all(c);}var q=ne(F());var H="___param___";var p=class p{static t(e){return Array.isArray(e)?e.map(i=>p.translate(`${i}`)):p.translate(`${e}`)}static set beforeToTranslate(e){p._beforeToTranslate=e;}static set translate(e){p._translate=e;}static get translate(){return e=>{let i=e;return p._beforeToTranslate&&(i=p._beforeToTranslate(i)),i=p._translate(i),p._afterToTranslate&&(i=p._afterToTranslate(i)),i}}static set afterToTranslate(e){p._afterToTranslate=e;}static addKey(e,i,o){let n=o.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(s=>{e[s]===void 0&&(n==="empty_string"?e[s]="":n==="copy_key"&&(p._beforeToTranslate?e[s]=p._beforeToTranslate(s):e[s]=s));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&p.getConditionalsThenElse(e.then,i),e.else&&p.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(o=>{p.getConditionalsThenElse(o,i);});else if(e.elements.type==="ifelse"){let o=[];p.getConditionalsThenElse(e.elements,o),o.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let o=[];p.getConditionalsThenElse(e.elements,o),o.forEach(n=>{i.push(...n);});}else p.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&p.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(o=>{p.getConditionalsThenElse(o,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},o={}){let{defaultValue:n="copy_key"}=o;return e.forEach(s=>{if(s.choices){let c=[];Array.isArray(s.choices)?c=[s.choices]:c=p.getConditionalsThenElse(s.choices),c.forEach(f=>f.forEach(g=>{if("type"in g){let m=[];g.type==="ifelse"||g.type==="stepswitch"?p.getConditionalsThenElse(g,m):m=[g],m.map(h=>p.getConditionalsThenElse(h.text)).forEach(h=>{Array.isArray(h)&&h.forEach(P=>{Array.isArray(P)?P.forEach(S=>{typeof S=="string"?p.addKey(i,S,{defaultValue:n}):p.getConditionalsThenElse(S).forEach(V=>{Array.isArray(V)?V.forEach(y=>{typeof y=="string"&&p.addKey(i,y,{defaultValue:n});}):typeof V=="string"&&p.addKey(i,V,{defaultValue:n});});}):typeof P=="string"&&p.addKey(i,P,{defaultValue:n});});});}}));}if(s.dialogue){let c=[];Array.isArray(s.dialogue)?c=[s.dialogue]:c=p.getConditionalsThenElse(s.dialogue),c.forEach(f=>{if(typeof f=="string")p.addKey(i,f,{defaultValue:n});else if("text"in f){let g=p.getConditionalsThenElse(f.text);typeof g=="string"&&(g=[g]),g.forEach(m=>{typeof m=="string"?p.addKey(i,m,{defaultValue:n}):p.getConditionalsThenElse(m).forEach(h=>{typeof h=="string"?p.addKey(i,h,{defaultValue:n}):Array.isArray(h)&&h.forEach(P=>{typeof P=="string"?p.addKey(i,P,{defaultValue:n}):p.getConditionalsThenElse(P).forEach(S=>{typeof S=="string"&&p.addKey(i,S,{defaultValue:n});});});});});}});}s.conditionalStep&&p.getConditionalsThenElse(s.conditionalStep).forEach(f=>{Array.isArray(f)?p.generateJsonTranslation(f,i,o):p.generateJsonTranslation([f],i,o);});}),i}};N(p,"_beforeToTranslate"),N(p,"_translate",e=>e),N(p,"_afterToTranslate");var E=p;function se(a){try{if(typeof a>"u")return a;let e=JSON.stringify(a);return JSON.parse(e)}catch(e){throw J.error("Error creating exportable element",a,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}var O=class extends LabelAbstract{constructor(i,o,n,s={}){n||(n={}),n.onLoadingLabel=async()=>{for(let c of o){let f;if(typeof c=="function"?f=c():f=c,f=l.getConditionalStep(f),f.operations){let g=f.operations.map(m=>l.loadAssets(m));await Promise.all(g);}}};super(i,n);N(this,"_steps");N(this,"operationStringConvert");N(this,"skipEmptyDialogs",false);this._steps=o,this.operationStringConvert=s.operationStringConvert,this.skipEmptyDialogs=s.skipEmptyDialogs||false;}get steps(){return this._steps.map(i=>this.stepConverter(i))}get stepCount(){return this._steps.length}getStepById(i){if(i<0||i>=this._steps.length)return;let o=this._steps[i];return this.stepConverter(o)}getStepSha(i){if(i<0||i>=this.steps.length)return;let o=this._steps[i];return (0, q.default)(o.toString().toLocaleLowerCase()).toString()}getDialogueText(i){let o="";if(Array.isArray(i)){let n=[];i.forEach(s=>{if(typeof s=="string")n.push(s);else if(s&&typeof s=="object"){let c=l.getLogichValue(s);c?(c&&!Array.isArray(c)&&typeof c=="object"&&(c=l.getLogichValue(c)||""),Array.isArray(c)?n=n.concat(c):n.push(`${c}`)):n.push(`${s}`);}}),o=n;}else {let n=l.getLogichValue(i)||"";n&&!Array.isArray(n)&&typeof n=="object"&&(n=l.getLogichValue(n)||""),o=n;}return `${o}`}getDialogue(i){if(i==null)return;let o=l.getLogichValue(i);return o==null?"":typeof o=="object"&&"character"in o&&"text"in o?{character:o.character,text:E.t(this.getDialogueText(o.text))}:E.t(this.getDialogueText(o))}getChoices(i){return l.getLogichValue(i)?.map(s=>l.getLogichValue(s)).filter(s=>s!==void 0)}stepConverter(i){return async o=>{let n=typeof i=="function"?i():i;n=se(n),n=l.getConditionalStep(n);let s=this.operationStringConvert?V=>this.operationStringConvert(V,n,o):void 0,{operations:c=[]}=n;for(let V of c)await A(V,s);let{labelToOpen:f=[]}=n,g=this.getChoices(n.choices),m=l.getLogichValue(n.glueEnabled),u=this.getDialogue(n.dialogue),h=[];Array.isArray(f)||(f=[f]),f.forEach(V=>{let y=l.getLogichValue(V);y&&h.push(y);});let P=l.getLogichValue(n.goNextStep),S=l.getLogichValue(n.end);if(g){let V=g.map(y=>{let v="";if(Array.isArray(y.text)){let r=[];y.text.forEach(x=>{if(typeof x=="string")r.push(E.t(x));else if(x&&typeof x=="object"){let d=l.getLogichValue(x);d&&!Array.isArray(d)&&typeof d=="object"&&(d=l.getLogichValue(d)||""),d&&(Array.isArray(d)?r=r.concat(E.t(d)):r.push(E.t(d)));}}),v=r;}else typeof y.text=="string"&&(v=E.t(y.text));return {label:y.label,text:v,props:y.props,type:y.type,oneTime:y.oneTime,onlyHaveNoChoice:y.onlyHaveNoChoice,autoSelect:y.autoSelect}});narration.choiceMenuOptions=V;}else narration.choiceMenuOptions=void 0;u!==void 0&&(narration.dialogue=u,this.skipEmptyDialogs&&typeof u=="string"&&(u===""||RegExp(/^\s+$/).test(u))&&(P=true)),m?storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):m===false&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let V of h){let y=V.label;typeof y=="object"&&(y=l.getLogichValue(y)||"");let v=V.params?.map(t=>l.getLogichValue(t));o={...o,...V.props},V.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${H}${narration.openedLabels.length}`,v),await narration.callLabel(y,o)):(storage.setTempVariable(`${H}${narration.openedLabels.length}`,v),await narration.callLabel(y,o));}S==="game_end"?(narration.closeAllLabels(),await narration.goNext(o,{runNow:true})):S==="label_end"&&narration.closeCurrentLabel(),P&&await narration.goNext(o,{runNow:true});}}};export{O as LabelJson,re as importPixiVNJson};
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
1
  'use strict';var importer=require('@drincs/pixi-vn-json/importer'),unifier=require('@drincs/pixi-vn-json/unifier'),pixiVn=require('@drincs/pixi-vn');var H=Object.defineProperty;var B=(e,i,t)=>i in e?H(e,i,{enumerable:true,configurable:true,writable:true,value:t}):e[i]=t;var w=(e,i,t)=>B(e,typeof i!="symbol"?i+"":i,t);var J="___param___";var n=class n{static t(i){return Array.isArray(i)?i.map(t=>n.translate(`${t}`)):n.translate(`${i}`)}static set beforeToTranslate(i){n._beforeToTranslate=i;}static set translate(i){n._translate=i;}static get translate(){return i=>{let t=i;return n._beforeToTranslate&&(t=n._beforeToTranslate(t)),t=n._translate(t),n._afterToTranslate&&(t=n._afterToTranslate(t)),t}}static set afterToTranslate(i){n._afterToTranslate=i;}static addKey(i,t,r){let a=r.defaultValue||"empty_string";typeof t=="string"&&(t=[t]),Array.isArray(t)&&t.forEach(s=>{i[s]===void 0&&(a==="empty_string"?i[s]="":a==="copy_key"&&(n._beforeToTranslate?i[s]=n._beforeToTranslate(s):i[s]=s));});}static getConditionalsThenElse(i,t=[]){if(typeof i=="object"&&i&&"type"in i)if(i.type==="ifelse")i.then&&n.getConditionalsThenElse(i.then,t),i.else&&n.getConditionalsThenElse(i.else,t);else if(i.type==="stepswitch"){if(i.elements)if(Array.isArray(i.elements))i.elements.forEach(r=>{n.getConditionalsThenElse(r,t);});else if(i.elements.type==="ifelse"){let r=[];n.getConditionalsThenElse(i.elements,r),r.forEach(a=>{t.push(...a);});}else if(i.elements.type==="stepswitch"){let r=[];n.getConditionalsThenElse(i.elements,r),r.forEach(a=>{t.push(...a);});}else n.getConditionalsThenElse(i.elements,t);}else i.type==="resulttocombine"?(i.firstItem&&n.getConditionalsThenElse(i.firstItem,t),i.secondConditionalItem&&i.secondConditionalItem.forEach(r=>{n.getConditionalsThenElse(r,t);})):t.push(i);else i&&t.push(i);return t}static generateJsonTranslation(i,t={},r={}){let{defaultValue:a="copy_key"}=r;return i.forEach(s=>{if(s.choices){let l=[];Array.isArray(s.choices)?l=[s.choices]:l=n.getConditionalsThenElse(s.choices),l.forEach(c=>c.forEach(u=>{if("type"in u){let p=[];u.type==="ifelse"||u.type==="stepswitch"?n.getConditionalsThenElse(u,p):p=[u],p.map(g=>n.getConditionalsThenElse(g.text)).forEach(g=>{Array.isArray(g)&&g.forEach(T=>{Array.isArray(T)?T.forEach(V=>{typeof V=="string"?n.addKey(t,V,{defaultValue:a}):n.getConditionalsThenElse(V).forEach(N=>{Array.isArray(N)?N.forEach(b=>{typeof b=="string"&&n.addKey(t,b,{defaultValue:a});}):typeof N=="string"&&n.addKey(t,N,{defaultValue:a});});}):typeof T=="string"&&n.addKey(t,T,{defaultValue:a});});});}}));}if(s.dialogue){let l=[];Array.isArray(s.dialogue)?l=[s.dialogue]:l=n.getConditionalsThenElse(s.dialogue),l.forEach(c=>{if(typeof c=="string")n.addKey(t,c,{defaultValue:a});else if("text"in c){let u=n.getConditionalsThenElse(c.text);typeof u=="string"&&(u=[u]),u.forEach(p=>{typeof p=="string"?n.addKey(t,p,{defaultValue:a}):n.getConditionalsThenElse(p).forEach(g=>{typeof g=="string"?n.addKey(t,g,{defaultValue:a}):Array.isArray(g)&&g.forEach(T=>{typeof T=="string"?n.addKey(t,T,{defaultValue:a}):n.getConditionalsThenElse(T).forEach(V=>{typeof V=="string"&&n.addKey(t,V,{defaultValue:a});});});});});}});}s.conditionalStep&&n.getConditionalsThenElse(s.conditionalStep).forEach(c=>{Array.isArray(c)?n.generateJsonTranslation(c,t,r):n.generateJsonTranslation([c],t,r);});}),t}};w(n,"_beforeToTranslate"),w(n,"_translate",i=>i),w(n,"_afterToTranslate");var C=n;var S=C;async function L(e){let i=unifier.JsonUnifier.getLogichValue(e);if(i)switch(i.type){case "assets":switch(i.operationType){case "load":await pixiVn.Assets.load(i.aliases);break;case "lazyload":pixiVn.Assets.backgroundLoad(i.aliases);break}break;case "bundle":switch(i.operationType){case "load":await pixiVn.Assets.loadBundle(i.aliases);break;case "lazyload":pixiVn.Assets.backgroundLoadBundle(i.aliases);break}break}}var d;(a=>(a.log=(s,...l)=>console.log(`[Pixi\u2019VN Json] ${s}`,...l),a.warn=(s,...l)=>console.warn(`[Pixi\u2019VN Json] ${s}`,...l),a.error=(s,...l)=>console.error(`[Pixi\u2019VN Json] ${s}`,...l),a.info=(s,...l)=>console.info(`[Pixi\u2019VN Json] ${s}`,...l)))(d||(d={}));async function R(e,i,t){switch(t.type){case "fade":await pixiVn.showWithFade(i.alias,e,t.props,t.priority);break;case "dissolve":await pixiVn.showWithDissolve(i.alias,e,t.props,t.priority);break;case "movein":case "moveout":await pixiVn.moveIn(i.alias,e,t.props,t.priority);break;case "zoomin":case "zoomout":await pixiVn.zoomIn(i.alias,e,t.props,t.priority);break;case "pushin":case "pushout":await pixiVn.pushIn(i.alias,e,t.props,t.priority);break}}function O(e){if(e.transition)switch(e.transition.type){case "fade":pixiVn.removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":pixiVn.removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":pixiVn.moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":pixiVn.zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":pixiVn.pushOut(e.alias,e.transition.props,e.transition.priority);break}else pixiVn.canvas.remove(e.alias);}async function G(e){switch(e.operationType){case "show":if(e.transition){let t=new pixiVn.ImageSprite(e.props,e.url||e.alias);await R(t,e,e.transition);}else await pixiVn.showImage(e.alias,e.url,e.props);break;case "edit":let i=pixiVn.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):d.error(`Image with alias ${e.alias} not found.`);break;case "remove":O(e);break}}async function M(e){switch(e.operationType){case "show":if(e.transition){let a=new pixiVn.VideoSprite(e.props,e.url||e.alias);await R(a,e,e.transition);}else await pixiVn.showVideo(e.alias,e.url,e.props);break;case "edit":let i=pixiVn.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):d.error(`Video with alias ${e.alias} not found.`);break;case "remove":O(e);break;case "pause":let t=pixiVn.canvas.find(e.alias);t?t.paused=true:d.error(`Video with alias ${e.alias} not found.`);break;case "resume":let r=pixiVn.canvas.find(e.alias);r?r.paused=false:d.error(`Video with alias ${e.alias} not found.`);break}}async function $(e){switch(e.operationType){case "show":if(e.transition){let t=new pixiVn.ImageContainer(e.props,e.urls);await R(t,e,e.transition);}else await pixiVn.showImageContainer(e.alias,e.urls,e.props);break;case "edit":let i=pixiVn.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):d.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":O(e);break}}async function F(e){switch(e.operationType){case "edit":try{let i=pixiVn.canvas.find(e.alias);i?e.props&&(i.memory={...i.memory,...e.props}):d.error(`Canvas Element with alias ${e.alias} not found.`);}catch(i){d.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,i);}break;case "remove":O(e);break}}function _(e){switch(e.type){case "fade":let i=new pixiVn.FadeAlphaTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,i);break;case "move":let t=new pixiVn.MoveTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,t);break;case "rotate":let r=new pixiVn.RotateTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,r);break;case "zoom":let a=new pixiVn.ZoomTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,a);break}}async function K(e){switch(e.type){case "shake":await pixiVn.shakeEffect(e.alias,e.props,e.priority);break}}function U(e){switch(e.type){case "animate":pixiVn.canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":pixiVn.canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function z(e){switch(e.operationType){case "request":pixiVn.narration.requestInput({type:e.valueType},e.defaultValue);break}}function X(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 W(e){let i=o(e.value),t;switch(i&&typeof i=="object"&&"type"in i?t=o(i):t=i,e.storageType){case "flagStorage":pixiVn.storage.setFlag(e.key,e.value);break;case "storage":pixiVn.storage.setVariable(e.key,t);break;case "tempstorage":pixiVn.storage.setTempVariable(e.key,t);break;case "params":let r=pixiVn.storage.getVariable(`${J}${pixiVn.narration.openedLabels.length-1}`)||[];r&&r.length-1>=e.key&&(r[e.key]=t),pixiVn.storage.setTempVariable(`${J}${pixiVn.narration.openedLabels.length-1}`,r);break}}function o(e){let i=Ee(e);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return be(i);case "arithmetic":case "arithmeticsingle":return Ne(i);case "compare":case "valueCondition":case "union":return Pe(i)}return i}function Ne(e){let i=o(e.leftValue);switch(e.type){case "arithmetic":let t=o(e.rightValue);switch(e.operator){case "*":return i*t;case "/":return i/t;case "+":return i+t;case "-":return i-t;case "%":return i%t;case "POW":return Math.pow(i,t);case "RANDOM":return pixiVn.narration.getRandomNumber(i,t)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(i);case "FLOOR":return Math.floor(i);case "FLOAT":return parseFloat(i)}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 pixiVn.storage.getVariable(e.key);case "flagStorage":return pixiVn.storage.getFlag(e.key);case "label":return pixiVn.narration.getTimesLabelOpened(e.label);case "choice":return pixiVn.narration.getTimesChoiceMade(e.index);case "logic":return o(e.operation);case "params":let i=pixiVn.storage.getVariable(`${J}${pixiVn.narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];d.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 i=o(e.leftValue),t=o(e.rightValue);switch(e.operator){case "==":return i===t;case "!=":return i!==t;case "<":return i<t;case "<=":return i<=t;case ">":return i>t;case ">=":return i>=t;case "CONTAINS":return i.toString().includes(t.toString())}break;case "valueCondition":return !!o(e.value);case "union":return Je(e)}return !!e}function Je(e){if(e.unionType==="not")return !o(e.condition);let i=e.unionType==="and";for(let t=0;t<e.conditions.length;t++)if(i=o(e.conditions[t])||false,e.unionType==="and"){if(!i)return false}else if(i)return true;return i}function Ce(e,i){return Math.floor(Math.random()*(i-e+1)+e)}function Ee(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return we(e);case "ifelse":return o(e.condition)?o(e.then):o(e.else);case "stepswitch":let t=o(e.elements)||[];if(t.length===0){d.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let r=Ce(0,t.length-1);return o(t[r]);case "loop":let a=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return a>t.length-1&&(a=a%t.length),o(t[a]);case "sequential":let s,l=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(s=o(t[t.length-1])),l>t.length-1?s:o(t[l]);case "sequentialrandom":let c=pixiVn.NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:e.nestedId,onceOnly:true});if(c==null&&e.end=="lastItem"){let u=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!u||!u?.usedRandomNumbers){d.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let p=u.usedRandomNumbers[`0-${t.length-1}`];return o(t[p[p.length-1]])}if(c==null){d.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return o(t[c])}}return e}function v(e){if(e.conditionalStep){let i=pixiVn.createExportableElement(o(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 t={...e,conditionalStep:void 0,...i};return v(t)}else pixiVn.storage.getFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return e}function we(e){let i=e.firstItem,t=[];e.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(s=>{let l=o(s);t.push(l);});else {let s=o(a);t.push(s);}});let r=i?[i,...t]:t;if(r.length===0){d.warn("combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return S.t(r);if(typeof r[0]=="object"){let a=r,s,l=a.map((f,x)=>{f=v(f);let m=o(f.dialogue)||"";return x===0?(s=o(f.glueEnabled)||false,m):(typeof m=="object"&&"text"in m&&(m=m.character+": "+m.text),s===false&&(m=`
2
2
 
3
- `+m),s=o(f.glueEnabled)||false,m)}),c=o(l[0]),u=typeof c=="object"&&"character"in c?c.character:void 0,p=l.flatMap(f=>{let x;f&&typeof f=="object"&&"text"in f?x=f.text:x=f;let m;return Array.isArray(x)?m=x.map(q=>{let Y=o(q);return S.t(`${Y}`)}):m=o(x)||"",S.t(m)}),A=a.find(f=>f.end),g=a.find(f=>f.choices),T=false,V=false;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),T=a[a.length-1].glueEnabled,V=a.reverse().find(f=>!(f.operations&&(!f.dialogue||!f.choices)))?.goNextStep);let N=a.find(f=>f.labelToOpen),b=[];return a.forEach(f=>{f.operations&&b.forEach(x=>{b.push(x);});}),{dialogue:u?{character:u,text:p}:p,end:A?.end,choices:g?.choices,glueEnabled:T,goNextStep:V,labelToOpen:N?.labelToOpen,operations:b}}}unifier.JsonUnifier.init({animateOperation:U,canvasElementOperation:F,effectOperation:K,imageContainerOperation:$,imageOperation:G,inputOperation:z,loadAssets:L,soundOperation:X,tickerOperation:_,videoOperation:M,setStorageValue:W,getLogichValue:o,getConditionalStep:v});exports.PIXIVNJSON_PARAM_ID=J;exports.translator=S;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(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
+ `+m),s=o(f.glueEnabled)||false,m)}),c=o(l[0]),u=typeof c=="object"&&"character"in c?c.character:void 0,p=l.flatMap(f=>{let x;f&&typeof f=="object"&&"text"in f?x=f.text:x=f;let m;return Array.isArray(x)?m=x.map(q=>{let Y=o(q);return S.t(`${Y}`)}):m=o(x)||"",S.t(m)}),A=a.find(f=>f.end),g=a.find(f=>f.choices),T=false,V=false;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),T=a[a.length-1].glueEnabled,V=a.reverse().find(f=>!(f.operations&&(!f.dialogue||!f.choices)))?.goNextStep);let N=a.find(f=>f.labelToOpen),b=[];return a.forEach(f=>{f.operations&&b.forEach(x=>{b.push(x);});}),{dialogue:u?{character:u,text:p}:p,end:A?.end,choices:g?.choices,glueEnabled:T,goNextStep:V,labelToOpen:N?.labelToOpen,operations:b}}}function fi(){unifier.JsonUnifier.init({animateOperation:U,canvasElementOperation:F,effectOperation:K,imageContainerOperation:$,imageOperation:G,inputOperation:z,loadAssets:L,soundOperation:X,tickerOperation:_,videoOperation:M,setStorageValue:W,getLogichValue:o,getConditionalStep:v});}exports.PIXIVNJSON_PARAM_ID=J;exports.init=fi;exports.translator=S;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(unifier).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return unifier[k]}})});
package/dist/index.d.cts CHANGED
@@ -605,4 +605,6 @@ declare class TranslatorManager {
605
605
 
606
606
  declare const translator: typeof TranslatorManager;
607
607
 
608
- export { PIXIVNJSON_PARAM_ID, type PixiVNJson, type PixiVNJsonAnimateBase, type PixiVNJsonAnimateSequence, type PixiVNJsonArithmeticOperations, type PixiVNJsonArithmeticOperationsArithmetic, type PixiVNJsonArithmeticOperationsArithmeticSingle, type PixiVNJsonCanvas, type PixiVNJsonCanvasAnimate, type PixiVNJsonCanvasEdit, type PixiVNJsonCanvasEffect, type PixiVNJsonCanvasRemove, type PixiVNJsonCanvasShow, type PixiVNJsonCanvasTicker, type PixiVNJsonChoice, type PixiVNJsonChoiceGet, type PixiVNJsonChoices, type PixiVNJsonComparation, type PixiVNJsonConditionalOperation, type PixiVNJsonConditionalResultToCombine, type PixiVNJsonConditionalStatements, type PixiVNJsonConditions, type PixiVNJsonDialog, type PixiVNJsonDialogText, type PixiVNJsonIfElse, type PixiVNJsonInput, type PixiVNJsonLabelGet, type PixiVNJsonLabelStep, type PixiVNJsonLabelToOpen, type PixiVNJsonLabels, type PixiVNJsonLogicGet, type PixiVNJsonMediaTransiotions, type PixiVNJsonOperation, type PixiVNJsonOperationString, type PixiVNJsonParamGet, type PixiVNJsonSound, type PixiVNJsonStepSwitch, type PixiVNJsonStepSwitchElementType, type PixiVNJsonStepSwitchElementsType, type PixiVNJsonStorageGet, type PixiVNJsonUnionCondition, type PixiVNJsonValueGet, type PixiVNJsonValueSet, translator };
608
+ declare function init(): void;
609
+
610
+ export { PIXIVNJSON_PARAM_ID, type PixiVNJson, type PixiVNJsonAnimateBase, type PixiVNJsonAnimateSequence, type PixiVNJsonArithmeticOperations, type PixiVNJsonArithmeticOperationsArithmetic, type PixiVNJsonArithmeticOperationsArithmeticSingle, type PixiVNJsonCanvas, type PixiVNJsonCanvasAnimate, type PixiVNJsonCanvasEdit, type PixiVNJsonCanvasEffect, type PixiVNJsonCanvasRemove, type PixiVNJsonCanvasShow, type PixiVNJsonCanvasTicker, type PixiVNJsonChoice, type PixiVNJsonChoiceGet, type PixiVNJsonChoices, type PixiVNJsonComparation, type PixiVNJsonConditionalOperation, type PixiVNJsonConditionalResultToCombine, type PixiVNJsonConditionalStatements, type PixiVNJsonConditions, type PixiVNJsonDialog, type PixiVNJsonDialogText, type PixiVNJsonIfElse, type PixiVNJsonInput, type PixiVNJsonLabelGet, type PixiVNJsonLabelStep, type PixiVNJsonLabelToOpen, type PixiVNJsonLabels, type PixiVNJsonLogicGet, type PixiVNJsonMediaTransiotions, type PixiVNJsonOperation, type PixiVNJsonOperationString, type PixiVNJsonParamGet, type PixiVNJsonSound, type PixiVNJsonStepSwitch, type PixiVNJsonStepSwitchElementType, type PixiVNJsonStepSwitchElementsType, type PixiVNJsonStorageGet, type PixiVNJsonUnionCondition, type PixiVNJsonValueGet, type PixiVNJsonValueSet, init, translator };
package/dist/index.d.ts CHANGED
@@ -605,4 +605,6 @@ declare class TranslatorManager {
605
605
 
606
606
  declare const translator: typeof TranslatorManager;
607
607
 
608
- export { PIXIVNJSON_PARAM_ID, type PixiVNJson, type PixiVNJsonAnimateBase, type PixiVNJsonAnimateSequence, type PixiVNJsonArithmeticOperations, type PixiVNJsonArithmeticOperationsArithmetic, type PixiVNJsonArithmeticOperationsArithmeticSingle, type PixiVNJsonCanvas, type PixiVNJsonCanvasAnimate, type PixiVNJsonCanvasEdit, type PixiVNJsonCanvasEffect, type PixiVNJsonCanvasRemove, type PixiVNJsonCanvasShow, type PixiVNJsonCanvasTicker, type PixiVNJsonChoice, type PixiVNJsonChoiceGet, type PixiVNJsonChoices, type PixiVNJsonComparation, type PixiVNJsonConditionalOperation, type PixiVNJsonConditionalResultToCombine, type PixiVNJsonConditionalStatements, type PixiVNJsonConditions, type PixiVNJsonDialog, type PixiVNJsonDialogText, type PixiVNJsonIfElse, type PixiVNJsonInput, type PixiVNJsonLabelGet, type PixiVNJsonLabelStep, type PixiVNJsonLabelToOpen, type PixiVNJsonLabels, type PixiVNJsonLogicGet, type PixiVNJsonMediaTransiotions, type PixiVNJsonOperation, type PixiVNJsonOperationString, type PixiVNJsonParamGet, type PixiVNJsonSound, type PixiVNJsonStepSwitch, type PixiVNJsonStepSwitchElementType, type PixiVNJsonStepSwitchElementsType, type PixiVNJsonStorageGet, type PixiVNJsonUnionCondition, type PixiVNJsonValueGet, type PixiVNJsonValueSet, translator };
608
+ declare function init(): void;
609
+
610
+ export { PIXIVNJSON_PARAM_ID, type PixiVNJson, type PixiVNJsonAnimateBase, type PixiVNJsonAnimateSequence, type PixiVNJsonArithmeticOperations, type PixiVNJsonArithmeticOperationsArithmetic, type PixiVNJsonArithmeticOperationsArithmeticSingle, type PixiVNJsonCanvas, type PixiVNJsonCanvasAnimate, type PixiVNJsonCanvasEdit, type PixiVNJsonCanvasEffect, type PixiVNJsonCanvasRemove, type PixiVNJsonCanvasShow, type PixiVNJsonCanvasTicker, type PixiVNJsonChoice, type PixiVNJsonChoiceGet, type PixiVNJsonChoices, type PixiVNJsonComparation, type PixiVNJsonConditionalOperation, type PixiVNJsonConditionalResultToCombine, type PixiVNJsonConditionalStatements, type PixiVNJsonConditions, type PixiVNJsonDialog, type PixiVNJsonDialogText, type PixiVNJsonIfElse, type PixiVNJsonInput, type PixiVNJsonLabelGet, type PixiVNJsonLabelStep, type PixiVNJsonLabelToOpen, type PixiVNJsonLabels, type PixiVNJsonLogicGet, type PixiVNJsonMediaTransiotions, type PixiVNJsonOperation, type PixiVNJsonOperationString, type PixiVNJsonParamGet, type PixiVNJsonSound, type PixiVNJsonStepSwitch, type PixiVNJsonStepSwitchElementType, type PixiVNJsonStepSwitchElementsType, type PixiVNJsonStorageGet, type PixiVNJsonUnionCondition, type PixiVNJsonValueGet, type PixiVNJsonValueSet, init, translator };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  export*from'@drincs/pixi-vn-json/importer';import {JsonUnifier}from'@drincs/pixi-vn-json/unifier';export*from'@drincs/pixi-vn-json/unifier';import {createExportableElement,storage,SYSTEM_RESERVED_STORAGE_KEYS,narration,canvas,VideoSprite,showVideo,ZoomTicker,RotateTicker,MoveTicker,FadeAlphaTicker,sound,Assets,ImageSprite,showImage,ImageContainer,showImageContainer,shakeEffect,NarrationManagerStatic,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade}from'@drincs/pixi-vn';var H=Object.defineProperty;var B=(e,i,t)=>i in e?H(e,i,{enumerable:true,configurable:true,writable:true,value:t}):e[i]=t;var w=(e,i,t)=>B(e,typeof i!="symbol"?i+"":i,t);var J="___param___";var n=class n{static t(i){return Array.isArray(i)?i.map(t=>n.translate(`${t}`)):n.translate(`${i}`)}static set beforeToTranslate(i){n._beforeToTranslate=i;}static set translate(i){n._translate=i;}static get translate(){return i=>{let t=i;return n._beforeToTranslate&&(t=n._beforeToTranslate(t)),t=n._translate(t),n._afterToTranslate&&(t=n._afterToTranslate(t)),t}}static set afterToTranslate(i){n._afterToTranslate=i;}static addKey(i,t,r){let a=r.defaultValue||"empty_string";typeof t=="string"&&(t=[t]),Array.isArray(t)&&t.forEach(s=>{i[s]===void 0&&(a==="empty_string"?i[s]="":a==="copy_key"&&(n._beforeToTranslate?i[s]=n._beforeToTranslate(s):i[s]=s));});}static getConditionalsThenElse(i,t=[]){if(typeof i=="object"&&i&&"type"in i)if(i.type==="ifelse")i.then&&n.getConditionalsThenElse(i.then,t),i.else&&n.getConditionalsThenElse(i.else,t);else if(i.type==="stepswitch"){if(i.elements)if(Array.isArray(i.elements))i.elements.forEach(r=>{n.getConditionalsThenElse(r,t);});else if(i.elements.type==="ifelse"){let r=[];n.getConditionalsThenElse(i.elements,r),r.forEach(a=>{t.push(...a);});}else if(i.elements.type==="stepswitch"){let r=[];n.getConditionalsThenElse(i.elements,r),r.forEach(a=>{t.push(...a);});}else n.getConditionalsThenElse(i.elements,t);}else i.type==="resulttocombine"?(i.firstItem&&n.getConditionalsThenElse(i.firstItem,t),i.secondConditionalItem&&i.secondConditionalItem.forEach(r=>{n.getConditionalsThenElse(r,t);})):t.push(i);else i&&t.push(i);return t}static generateJsonTranslation(i,t={},r={}){let{defaultValue:a="copy_key"}=r;return i.forEach(s=>{if(s.choices){let l=[];Array.isArray(s.choices)?l=[s.choices]:l=n.getConditionalsThenElse(s.choices),l.forEach(c=>c.forEach(u=>{if("type"in u){let p=[];u.type==="ifelse"||u.type==="stepswitch"?n.getConditionalsThenElse(u,p):p=[u],p.map(g=>n.getConditionalsThenElse(g.text)).forEach(g=>{Array.isArray(g)&&g.forEach(T=>{Array.isArray(T)?T.forEach(V=>{typeof V=="string"?n.addKey(t,V,{defaultValue:a}):n.getConditionalsThenElse(V).forEach(N=>{Array.isArray(N)?N.forEach(b=>{typeof b=="string"&&n.addKey(t,b,{defaultValue:a});}):typeof N=="string"&&n.addKey(t,N,{defaultValue:a});});}):typeof T=="string"&&n.addKey(t,T,{defaultValue:a});});});}}));}if(s.dialogue){let l=[];Array.isArray(s.dialogue)?l=[s.dialogue]:l=n.getConditionalsThenElse(s.dialogue),l.forEach(c=>{if(typeof c=="string")n.addKey(t,c,{defaultValue:a});else if("text"in c){let u=n.getConditionalsThenElse(c.text);typeof u=="string"&&(u=[u]),u.forEach(p=>{typeof p=="string"?n.addKey(t,p,{defaultValue:a}):n.getConditionalsThenElse(p).forEach(g=>{typeof g=="string"?n.addKey(t,g,{defaultValue:a}):Array.isArray(g)&&g.forEach(T=>{typeof T=="string"?n.addKey(t,T,{defaultValue:a}):n.getConditionalsThenElse(T).forEach(V=>{typeof V=="string"&&n.addKey(t,V,{defaultValue:a});});});});});}});}s.conditionalStep&&n.getConditionalsThenElse(s.conditionalStep).forEach(c=>{Array.isArray(c)?n.generateJsonTranslation(c,t,r):n.generateJsonTranslation([c],t,r);});}),t}};w(n,"_beforeToTranslate"),w(n,"_translate",i=>i),w(n,"_afterToTranslate");var C=n;var S=C;async function L(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 d;(a=>(a.log=(s,...l)=>console.log(`[Pixi\u2019VN Json] ${s}`,...l),a.warn=(s,...l)=>console.warn(`[Pixi\u2019VN Json] ${s}`,...l),a.error=(s,...l)=>console.error(`[Pixi\u2019VN Json] ${s}`,...l),a.info=(s,...l)=>console.info(`[Pixi\u2019VN Json] ${s}`,...l)))(d||(d={}));async function R(e,i,t){switch(t.type){case "fade":await showWithFade(i.alias,e,t.props,t.priority);break;case "dissolve":await showWithDissolve(i.alias,e,t.props,t.priority);break;case "movein":case "moveout":await moveIn(i.alias,e,t.props,t.priority);break;case "zoomin":case "zoomout":await zoomIn(i.alias,e,t.props,t.priority);break;case "pushin":case "pushout":await pushIn(i.alias,e,t.props,t.priority);break}}function O(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 G(e){switch(e.operationType){case "show":if(e.transition){let t=new ImageSprite(e.props,e.url||e.alias);await R(t,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}):d.error(`Image with alias ${e.alias} not found.`);break;case "remove":O(e);break}}async function M(e){switch(e.operationType){case "show":if(e.transition){let a=new VideoSprite(e.props,e.url||e.alias);await R(a,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}):d.error(`Video with alias ${e.alias} not found.`);break;case "remove":O(e);break;case "pause":let t=canvas.find(e.alias);t?t.paused=true:d.error(`Video with alias ${e.alias} not found.`);break;case "resume":let r=canvas.find(e.alias);r?r.paused=false:d.error(`Video with alias ${e.alias} not found.`);break}}async function $(e){switch(e.operationType){case "show":if(e.transition){let t=new ImageContainer(e.props,e.urls);await R(t,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}):d.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":O(e);break}}async function F(e){switch(e.operationType){case "edit":try{let i=canvas.find(e.alias);i?e.props&&(i.memory={...i.memory,...e.props}):d.error(`Canvas Element with alias ${e.alias} not found.`);}catch(i){d.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,i);}break;case "remove":O(e);break}}function _(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 t=new MoveTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,t);break;case "rotate":let r=new RotateTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,r);break;case "zoom":let a=new ZoomTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,a);break}}async function K(e){switch(e.type){case "shake":await shakeEffect(e.alias,e.props,e.priority);break}}function U(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 z(e){switch(e.operationType){case "request":narration.requestInput({type:e.valueType},e.defaultValue);break}}function X(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 W(e){let i=o(e.value),t;switch(i&&typeof i=="object"&&"type"in i?t=o(i):t=i,e.storageType){case "flagStorage":storage.setFlag(e.key,e.value);break;case "storage":storage.setVariable(e.key,t);break;case "tempstorage":storage.setTempVariable(e.key,t);break;case "params":let r=storage.getVariable(`${J}${narration.openedLabels.length-1}`)||[];r&&r.length-1>=e.key&&(r[e.key]=t),storage.setTempVariable(`${J}${narration.openedLabels.length-1}`,r);break}}function o(e){let i=Ee(e);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return be(i);case "arithmetic":case "arithmeticsingle":return Ne(i);case "compare":case "valueCondition":case "union":return Pe(i)}return i}function Ne(e){let i=o(e.leftValue);switch(e.type){case "arithmetic":let t=o(e.rightValue);switch(e.operator){case "*":return i*t;case "/":return i/t;case "+":return i+t;case "-":return i-t;case "%":return i%t;case "POW":return Math.pow(i,t);case "RANDOM":return narration.getRandomNumber(i,t)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(i);case "FLOOR":return Math.floor(i);case "FLOAT":return parseFloat(i)}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 o(e.operation);case "params":let i=storage.getVariable(`${J}${narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];d.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 i=o(e.leftValue),t=o(e.rightValue);switch(e.operator){case "==":return i===t;case "!=":return i!==t;case "<":return i<t;case "<=":return i<=t;case ">":return i>t;case ">=":return i>=t;case "CONTAINS":return i.toString().includes(t.toString())}break;case "valueCondition":return !!o(e.value);case "union":return Je(e)}return !!e}function Je(e){if(e.unionType==="not")return !o(e.condition);let i=e.unionType==="and";for(let t=0;t<e.conditions.length;t++)if(i=o(e.conditions[t])||false,e.unionType==="and"){if(!i)return false}else if(i)return true;return i}function Ce(e,i){return Math.floor(Math.random()*(i-e+1)+e)}function Ee(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return we(e);case "ifelse":return o(e.condition)?o(e.then):o(e.else);case "stepswitch":let t=o(e.elements)||[];if(t.length===0){d.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let r=Ce(0,t.length-1);return o(t[r]);case "loop":let a=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return a>t.length-1&&(a=a%t.length),o(t[a]);case "sequential":let s,l=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(s=o(t[t.length-1])),l>t.length-1?s:o(t[l]);case "sequentialrandom":let c=NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:e.nestedId,onceOnly:true});if(c==null&&e.end=="lastItem"){let u=NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!u||!u?.usedRandomNumbers){d.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let p=u.usedRandomNumbers[`0-${t.length-1}`];return o(t[p[p.length-1]])}if(c==null){d.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return o(t[c])}}return e}function v(e){if(e.conditionalStep){let i=createExportableElement(o(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 t={...e,conditionalStep:void 0,...i};return v(t)}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 we(e){let i=e.firstItem,t=[];e.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(s=>{let l=o(s);t.push(l);});else {let s=o(a);t.push(s);}});let r=i?[i,...t]:t;if(r.length===0){d.warn("combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return S.t(r);if(typeof r[0]=="object"){let a=r,s,l=a.map((f,x)=>{f=v(f);let m=o(f.dialogue)||"";return x===0?(s=o(f.glueEnabled)||false,m):(typeof m=="object"&&"text"in m&&(m=m.character+": "+m.text),s===false&&(m=`
2
2
 
3
- `+m),s=o(f.glueEnabled)||false,m)}),c=o(l[0]),u=typeof c=="object"&&"character"in c?c.character:void 0,p=l.flatMap(f=>{let x;f&&typeof f=="object"&&"text"in f?x=f.text:x=f;let m;return Array.isArray(x)?m=x.map(q=>{let Y=o(q);return S.t(`${Y}`)}):m=o(x)||"",S.t(m)}),A=a.find(f=>f.end),g=a.find(f=>f.choices),T=false,V=false;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),T=a[a.length-1].glueEnabled,V=a.reverse().find(f=>!(f.operations&&(!f.dialogue||!f.choices)))?.goNextStep);let N=a.find(f=>f.labelToOpen),b=[];return a.forEach(f=>{f.operations&&b.forEach(x=>{b.push(x);});}),{dialogue:u?{character:u,text:p}:p,end:A?.end,choices:g?.choices,glueEnabled:T,goNextStep:V,labelToOpen:N?.labelToOpen,operations:b}}}JsonUnifier.init({animateOperation:U,canvasElementOperation:F,effectOperation:K,imageContainerOperation:$,imageOperation:G,inputOperation:z,loadAssets:L,soundOperation:X,tickerOperation:_,videoOperation:M,setStorageValue:W,getLogichValue:o,getConditionalStep:v});export{J as PIXIVNJSON_PARAM_ID,S as translator};
3
+ `+m),s=o(f.glueEnabled)||false,m)}),c=o(l[0]),u=typeof c=="object"&&"character"in c?c.character:void 0,p=l.flatMap(f=>{let x;f&&typeof f=="object"&&"text"in f?x=f.text:x=f;let m;return Array.isArray(x)?m=x.map(q=>{let Y=o(q);return S.t(`${Y}`)}):m=o(x)||"",S.t(m)}),A=a.find(f=>f.end),g=a.find(f=>f.choices),T=false,V=false;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),T=a[a.length-1].glueEnabled,V=a.reverse().find(f=>!(f.operations&&(!f.dialogue||!f.choices)))?.goNextStep);let N=a.find(f=>f.labelToOpen),b=[];return a.forEach(f=>{f.operations&&b.forEach(x=>{b.push(x);});}),{dialogue:u?{character:u,text:p}:p,end:A?.end,choices:g?.choices,glueEnabled:T,goNextStep:V,labelToOpen:N?.labelToOpen,operations:b}}}function fi(){JsonUnifier.init({animateOperation:U,canvasElementOperation:F,effectOperation:K,imageContainerOperation:$,imageOperation:G,inputOperation:z,loadAssets:L,soundOperation:X,tickerOperation:_,videoOperation:M,setStorageValue:W,getLogichValue:o,getConditionalStep:v});}export{J as PIXIVNJSON_PARAM_ID,fi as init,S as translator};
package/dist/unifier.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var p=Object.defineProperty;var m=(o,i,s)=>i in o?p(o,i,{enumerable:true,configurable:true,writable:true,value:s}):o[i]=s;var n=(o,i,s)=>m(o,typeof i!="symbol"?i+"":i,s);var t;(d=>(d.log=(a,...r)=>console.log(`[Pixi\u2019VN Json] ${a}`,...r),d.warn=(a,...r)=>console.warn(`[Pixi\u2019VN Json] ${a}`,...r),d.error=(a,...r)=>console.error(`[Pixi\u2019VN Json] ${a}`,...r),d.info=(a,...r)=>console.info(`[Pixi\u2019VN Json] ${a}`,...r)))(t||(t={}));var e=class{static init(i){this._loadAssets=i.loadAssets,this._soundOperation=i.soundOperation,this._imageOperation=i.imageOperation,this._videoOperation=i.videoOperation,this._imageContainerOperation=i.imageContainerOperation,this._canvasElementOperation=i.canvasElementOperation,this._setStorageValue=i.setStorageValue,this._inputOperation=i.inputOperation,this._tickerOperation=i.tickerOperation,this._effectOperation=i.effectOperation,this._animateOperation=i.animateOperation,this._getLogichValue=i.getLogichValue,this._getConditionalStep=i.getConditionalStep;}static get loadAssets(){return this._loadAssets}static get soundOperation(){return this._soundOperation}static get imageOperation(){return this._imageOperation}static get videoOperation(){return this._videoOperation}static get imageContainerOperation(){return this._imageContainerOperation}static get canvasElementOperation(){return this._canvasElementOperation}static get setStorageValue(){return this._setStorageValue}static get inputOperation(){return this._inputOperation}static get tickerOperation(){return this._tickerOperation}static get effectOperation(){return this._effectOperation}static get animateOperation(){return this._animateOperation}static get getLogichValue(){return this._getLogichValue}static get getConditionalStep(){return this._getConditionalStep}};n(e,"_loadAssets",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_soundOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_imageOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_videoOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_imageContainerOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_canvasElementOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_setStorageValue",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_inputOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_tickerOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_effectOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_animateOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_getLogichValue",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_getConditionalStep",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")});exports.JsonUnifier=e;
1
+ 'use strict';var c=Object.defineProperty;var P=(n,i,s)=>i in n?c(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;(p=>(p.log=(r,...a)=>console.log(`[Pixi\u2019VN Json] ${r}`,...a),p.warn=(r,...a)=>console.warn(`[Pixi\u2019VN Json] ${r}`,...a),p.error=(r,...a)=>console.error(`[Pixi\u2019VN Json] ${r}`,...a),p.info=(r,...a)=>console.info(`[Pixi\u2019VN Json] ${r}`,...a)))(t||(t={}));var e=class{static init(i){this._loadAssets=i.loadAssets,this._soundOperation=i.soundOperation,this._imageOperation=i.imageOperation,this._videoOperation=i.videoOperation,this._imageContainerOperation=i.imageContainerOperation,this._canvasElementOperation=i.canvasElementOperation,this._setStorageValue=i.setStorageValue,this._inputOperation=i.inputOperation,this._tickerOperation=i.tickerOperation,this._effectOperation=i.effectOperation,this._animateOperation=i.animateOperation,this._getLogichValue=i.getLogichValue,this._getConditionalStep=i.getConditionalStep;}static get loadAssets(){return this._loadAssets}static get soundOperation(){return this._soundOperation}static get imageOperation(){return this._imageOperation}static get videoOperation(){return this._videoOperation}static get imageContainerOperation(){return this._imageContainerOperation}static get canvasElementOperation(){return this._canvasElementOperation}static get setStorageValue(){return this._setStorageValue}static get inputOperation(){return this._inputOperation}static get tickerOperation(){return this._tickerOperation}static get effectOperation(){return this._effectOperation}static get animateOperation(){return this._animateOperation}static get getLogichValue(){return this._getLogichValue}static get getConditionalStep(){return this._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,"_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,"_inputOperation",()=>{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.")});exports.JsonUnifier=e;
package/dist/unifier.mjs CHANGED
@@ -1 +1 @@
1
- var p=Object.defineProperty;var m=(o,i,s)=>i in o?p(o,i,{enumerable:true,configurable:true,writable:true,value:s}):o[i]=s;var n=(o,i,s)=>m(o,typeof i!="symbol"?i+"":i,s);var t;(d=>(d.log=(a,...r)=>console.log(`[Pixi\u2019VN Json] ${a}`,...r),d.warn=(a,...r)=>console.warn(`[Pixi\u2019VN Json] ${a}`,...r),d.error=(a,...r)=>console.error(`[Pixi\u2019VN Json] ${a}`,...r),d.info=(a,...r)=>console.info(`[Pixi\u2019VN Json] ${a}`,...r)))(t||(t={}));var e=class{static init(i){this._loadAssets=i.loadAssets,this._soundOperation=i.soundOperation,this._imageOperation=i.imageOperation,this._videoOperation=i.videoOperation,this._imageContainerOperation=i.imageContainerOperation,this._canvasElementOperation=i.canvasElementOperation,this._setStorageValue=i.setStorageValue,this._inputOperation=i.inputOperation,this._tickerOperation=i.tickerOperation,this._effectOperation=i.effectOperation,this._animateOperation=i.animateOperation,this._getLogichValue=i.getLogichValue,this._getConditionalStep=i.getConditionalStep;}static get loadAssets(){return this._loadAssets}static get soundOperation(){return this._soundOperation}static get imageOperation(){return this._imageOperation}static get videoOperation(){return this._videoOperation}static get imageContainerOperation(){return this._imageContainerOperation}static get canvasElementOperation(){return this._canvasElementOperation}static get setStorageValue(){return this._setStorageValue}static get inputOperation(){return this._inputOperation}static get tickerOperation(){return this._tickerOperation}static get effectOperation(){return this._effectOperation}static get animateOperation(){return this._animateOperation}static get getLogichValue(){return this._getLogichValue}static get getConditionalStep(){return this._getConditionalStep}};n(e,"_loadAssets",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_soundOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_imageOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_videoOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_imageContainerOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_canvasElementOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_setStorageValue",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_inputOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_tickerOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_effectOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_animateOperation",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_getLogichValue",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")}),n(e,"_getConditionalStep",()=>{throw t.error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()"),new Error("Method not implemented, you should initialize the JsonUnifier: JsonUnifier.init()")});export{e as JsonUnifier};
1
+ var c=Object.defineProperty;var P=(n,i,s)=>i in n?c(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;(p=>(p.log=(r,...a)=>console.log(`[Pixi\u2019VN Json] ${r}`,...a),p.warn=(r,...a)=>console.warn(`[Pixi\u2019VN Json] ${r}`,...a),p.error=(r,...a)=>console.error(`[Pixi\u2019VN Json] ${r}`,...a),p.info=(r,...a)=>console.info(`[Pixi\u2019VN Json] ${r}`,...a)))(t||(t={}));var e=class{static init(i){this._loadAssets=i.loadAssets,this._soundOperation=i.soundOperation,this._imageOperation=i.imageOperation,this._videoOperation=i.videoOperation,this._imageContainerOperation=i.imageContainerOperation,this._canvasElementOperation=i.canvasElementOperation,this._setStorageValue=i.setStorageValue,this._inputOperation=i.inputOperation,this._tickerOperation=i.tickerOperation,this._effectOperation=i.effectOperation,this._animateOperation=i.animateOperation,this._getLogichValue=i.getLogichValue,this._getConditionalStep=i.getConditionalStep;}static get loadAssets(){return this._loadAssets}static get soundOperation(){return this._soundOperation}static get imageOperation(){return this._imageOperation}static get videoOperation(){return this._videoOperation}static get imageContainerOperation(){return this._imageContainerOperation}static get canvasElementOperation(){return this._canvasElementOperation}static get setStorageValue(){return this._setStorageValue}static get inputOperation(){return this._inputOperation}static get tickerOperation(){return this._tickerOperation}static get effectOperation(){return this._effectOperation}static get animateOperation(){return this._animateOperation}static get getLogichValue(){return this._getLogichValue}static get getConditionalStep(){return this._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,"_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,"_inputOperation",()=>{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.")});export{e as JsonUnifier};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drincs/pixi-vn-json",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
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",