@drincs/pixi-vn-json 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/LabelJson.cjs +2 -2
- package/dist/classes/LabelJson.d.cts +2 -2
- package/dist/classes/LabelJson.d.ts +2 -2
- package/dist/classes/LabelJson.js +2 -2
- package/dist/classes/index.cjs +2 -2
- package/dist/classes/index.js +2 -2
- package/dist/functions/importer.cjs +2 -2
- package/dist/functions/importer.js +2 -2
- package/dist/functions/index.cjs +2 -2
- package/dist/functions/index.js +2 -2
- package/dist/functions/operation-utility.cjs +2 -2
- package/dist/functions/operation-utility.d.cts +2 -2
- package/dist/functions/operation-utility.d.ts +2 -2
- package/dist/functions/operation-utility.js +2 -2
- package/dist/functions/utility.cjs +2 -2
- package/dist/functions/utility.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/managers/TranslateManager.cjs +1 -1
- package/dist/managers/TranslateManager.d.cts +1 -1
- package/dist/managers/TranslateManager.d.ts +1 -1
- package/dist/managers/TranslateManager.js +1 -1
- package/dist/managers/index.cjs +1 -1
- package/dist/managers/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {storage,narration,setFlag,LabelAbstract,ChoiceMenuOption,StorageManagerStatic,saveLabel,NarrationManagerStatic,createExportableElement,getFlag,canvas,CanvasVideo,zoomIn,moveIn,showWithDissolveTransition,showWithFadeTransition,showVideo,showImage,sound}from'@drincs/pixi-vn';var oe=Object.create;var z=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var F=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(i,e)=>(typeof require<"u"?require:i)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var K=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var ce=(t,i,e,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of se(i))!fe.call(t,o)&&o!==e&&z(t,o,{get:()=>i[o],enumerable:!(r=ae(i,o))||r.enumerable});return t};var ue=(t,i,e)=>(e=t!=null?oe(le(t)):{},ce(z(e,"default",{value:t,enumerable:!0}),t));var X=K((I,U)=>{(function(t,i){typeof I=="object"?U.exports=I=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(I,function(){var t=t||function(i,e){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof F=="function")try{r=F("crypto");}catch{}var o=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||function(){function n(){}return function(a){var u;return n.prototype=a,u=new n,n.prototype=null,u}}(),c={},h=c.lib={},d=h.Base=function(){return {extend:function(n){var a=s(this);return n&&a.mixIn(n),(!a.hasOwnProperty("init")||this.init===a.init)&&(a.init=function(){a.$super.init.apply(this,arguments);}),a.init.prototype=a,a.$super=this,a},create:function(){var n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var a in n)n.hasOwnProperty(a)&&(this[a]=n[a]);n.hasOwnProperty("toString")&&(this.toString=n.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),p=h.WordArray=d.extend({init:function(n,a){n=this.words=n||[],a!=e?this.sigBytes=a:this.sigBytes=n.length*4;},toString:function(n){return (n||g).stringify(this)},concat:function(n){var a=this.words,u=n.words,m=this.sigBytes,T=n.sigBytes;if(this.clamp(),m%4)for(var N=0;N<T;N++){var $=u[N>>>2]>>>24-N%4*8&255;a[m+N>>>2]|=$<<24-(m+N)%4*8;}else for(var S=0;S<T;S+=4)a[m+S>>>2]=u[S>>>2];return this.sigBytes+=T,this},clamp:function(){var n=this.words,a=this.sigBytes;n[a>>>2]&=4294967295<<32-a%4*8,n.length=i.ceil(a/4);},clone:function(){var n=d.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var a=[],u=0;u<n;u+=4)a.push(o());return new p.init(a,n)}}),l=c.enc={},g=l.Hex={stringify:function(n){for(var a=n.words,u=n.sigBytes,m=[],T=0;T<u;T++){var N=a[T>>>2]>>>24-T%4*8&255;m.push((N>>>4).toString(16)),m.push((N&15).toString(16));}return m.join("")},parse:function(n){for(var a=n.length,u=[],m=0;m<a;m+=2)u[m>>>3]|=parseInt(n.substr(m,2),16)<<24-m%8*4;return new p.init(u,a/2)}},y=l.Latin1={stringify:function(n){for(var a=n.words,u=n.sigBytes,m=[],T=0;T<u;T++){var N=a[T>>>2]>>>24-T%4*8&255;m.push(String.fromCharCode(N));}return m.join("")},parse:function(n){for(var a=n.length,u=[],m=0;m<a;m++)u[m>>>2]|=(n.charCodeAt(m)&255)<<24-m%4*8;return new p.init(u,a)}},b=l.Utf8={stringify:function(n){try{return decodeURIComponent(escape(y.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return y.parse(unescape(encodeURIComponent(n)))}},x=h.BufferedBlockAlgorithm=d.extend({reset:function(){this._data=new p.init,this._nDataBytes=0;},_append:function(n){typeof n=="string"&&(n=b.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes;},_process:function(n){var a,u=this._data,m=u.words,T=u.sigBytes,N=this.blockSize,$=N*4,S=T/$;n?S=i.ceil(S):S=i.max((S|0)-this._minBufferSize,0);var k=S*N,W=i.min(k*4,T);if(k){for(var H=0;H<k;H+=N)this._doProcessBlock(m,H);a=m.splice(0,k),u.sigBytes-=W;}return new p.init(a,W)},clone:function(){var n=d.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});h.Hasher=x.extend({cfg:d.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset();},reset:function(){x.reset.call(this),this._doReset();},update:function(n){return this._append(n),this._process(),this},finalize:function(n){n&&this._append(n);var a=this._doFinalize();return a},blockSize:512/32,_createHelper:function(n){return function(a,u){return new n.init(u).finalize(a)}},_createHmacHelper:function(n){return function(a,u){return new V.HMAC.init(n,u).finalize(a)}}});var V=c.algo={};return c}(Math);return t});});var Y=K((D,q)=>{(function(t,i){typeof D=="object"?q.exports=D=i(X()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(D,function(t){return function(){var i=t,e=i.lib,r=e.WordArray,o=e.Hasher,s=i.algo,c=[],h=s.SHA1=o.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(d,p){for(var l=this._hash.words,g=l[0],y=l[1],b=l[2],x=l[3],C=l[4],V=0;V<80;V++){if(V<16)c[V]=d[p+V]|0;else {var n=c[V-3]^c[V-8]^c[V-14]^c[V-16];c[V]=n<<1|n>>>31;}var a=(g<<5|g>>>27)+C+c[V];V<20?a+=(y&b|~y&x)+1518500249:V<40?a+=(y^b^x)+1859775393:V<60?a+=(y&b|y&x|b&x)-1894007588:a+=(y^b^x)-899497514,C=x,x=b,b=y<<30|y>>>2,y=g,g=a;}l[0]=l[0]+g|0,l[1]=l[1]+y|0,l[2]=l[2]+b|0,l[3]=l[3]+x|0,l[4]=l[4]+C|0;},_doFinalize:function(){var d=this._data,p=d.words,l=this._nDataBytes*8,g=d.sigBytes*8;return p[g>>>5]|=128<<24-g%32,p[(g+64>>>9<<4)+14]=Math.floor(l/4294967296),p[(g+64>>>9<<4)+15]=l,d.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var d=o.clone.call(this);return d._hash=this._hash.clone(),d}});i.SHA1=o._createHelper(h),i.HmacSHA1=o._createHmacHelper(h);}(),t.SHA1});});var re=ue(Y());var E="___param___";var J=class t{static _translate=i=>i;static t(i){return Array.isArray(i)?i.map(e=>t._translate(`${e}`)):t._translate(`${i}`)}static set translate(i){t._translate=i;}static addKey(i,e,r){let o=r.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(s=>{i[s]===void 0&&(o==="empty_string"?i[s]="":o==="copy_key"&&(i[s]=s));});}static getConditionalsThenElse(i,e=[]){if(typeof i=="object"&&i&&"type"in i)if(i.type==="ifelse")i.then&&t.getConditionalsThenElse(i.then,e),i.else&&t.getConditionalsThenElse(i.else,e);else if(i.type==="stepswitch"){if(i.elements)if(Array.isArray(i.elements))i.elements.forEach(r=>{t.getConditionalsThenElse(r,e);});else if(i.elements.type==="ifelse"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(o=>{e.push(...o);});}else if(i.elements.type==="stepswitch"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(o=>{e.push(...o);});}else t.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&t.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(r=>{t.getConditionalsThenElse(r,e);})):e.push(i);else i&&e.push(i);return e}static generateTranslateJson(i,e={},r={}){return i.forEach(o=>{if(o.choices){let s=[];Array.isArray(o.choices)?s=[o.choices]:s=t.getConditionalsThenElse(o.choices),s.forEach(c=>c.forEach(h=>{if("type"in h){let d=[];h.type==="ifelse"||h.type==="stepswitch"?t.getConditionalsThenElse(h,d):d=[h],d.map(l=>t.getConditionalsThenElse(l.text)).forEach(l=>{Array.isArray(l)&&l.forEach(g=>{Array.isArray(g)?g.forEach(y=>{typeof y=="string"?t.addKey(e,y,r):t.getConditionalsThenElse(y).forEach(b=>{Array.isArray(b)?b.forEach(x=>{typeof x=="string"&&t.addKey(e,x,r);}):typeof b=="string"&&t.addKey(e,b,r);});}):typeof g=="string"&&t.addKey(e,g,r);});});}}));}if(o.dialogue){let s=[];Array.isArray(o.dialogue)?s=[o.dialogue]:s=t.getConditionalsThenElse(o.dialogue),s.forEach(c=>{typeof c=="string"?t.addKey(e,c,r):"text"in c&&Array.isArray(c.text)&&c.text.forEach(h=>{typeof h=="string"?t.addKey(e,h,r):t.getConditionalsThenElse(h).forEach(p=>{typeof p=="string"?t.addKey(e,p,r):Array.isArray(p)&&p.forEach(l=>{typeof l=="string"?t.addKey(e,l,r):t.getConditionalsThenElse(l).forEach(g=>{typeof g=="string"&&t.addKey(e,g,r);});});});});});}o.conditionalStep&&t.getConditionalsThenElse(o.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateTranslateJson(c,e,r):t.generateTranslateJson([c],e,r);});}),e}};function de(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function ge(t){if(Array.isArray(t)||!t)return t;if(t&&typeof t=="object"&&"type"in t)switch(t.type){case"resulttocombine":return he(t);case"ifelse":return f(t.condition)?f(t.then):f(t.else);case"stepswitch":let e=f(t.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let r=de(0,e.length-1);return f(e[r]);case"loop":let o=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return o>e.length-1&&(o=o%e.length),f(e[o]);case"sequential":let s,c=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end=="lastItem"&&(s=f(e[e.length-1])),c>e.length-1?s:f(e[c]);case"sequentialrandom":let h=NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:t.nestedId,onceOnly:!0});if(h==null&&t.end=="lastItem"){let d=NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!d||!d?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let p=d.usedRandomNumbers[`0-${e.length-1}`];return f(e[p[p.length-1]])}if(h==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return f(e[h])}}return t}function B(t){if(t.conditionalStep){let i=createExportableElement(f(t.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?.operation===void 0&&delete i?.operation,i){let e={...t,conditionalStep:void 0,...i};return B(e)}else getFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return t}function he(t){let i=t.firstItem,e=[];t.secondConditionalItem?.forEach(o=>{if(Array.isArray(o))o.forEach(s=>{let c=f(s);e.push(c);});else {let s=f(o);e.push(s);}});let r=i?[i,...e]:e;if(r.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return J.t(r).join("");if(typeof r[0]=="object"){let o=r,s,c=o.map((n,a)=>{n=B(n);let u=f(n.dialogue)||"";return a===0?(s=f(n.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),s===!1&&(u=`
|
|
1
|
+
import {storage,narration,setFlag,LabelAbstract,ChoiceMenuOption,StorageManagerStatic,saveLabel,NarrationManagerStatic,createExportableElement,getFlag,canvas,CanvasVideo,zoomIn,moveIn,showWithDissolveTransition,showWithFadeTransition,showVideo,showImage,sound}from'@drincs/pixi-vn';var oe=Object.create;var z=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var F=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var K=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ce=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of se(e))!fe.call(t,o)&&o!==n&&z(t,o,{get:()=>e[o],enumerable:!(i=ae(e,o))||i.enumerable});return t};var ue=(t,e,n)=>(n=t!=null?oe(le(t)):{},ce(z(n,"default",{value:t,enumerable:!0}),t));var X=K((I,U)=>{(function(t,e){typeof I=="object"?U.exports=I=e():typeof define=="function"&&define.amd?define([],e):t.CryptoJS=e();})(I,function(){var t=t||function(e,n){var i;if(typeof window<"u"&&window.crypto&&(i=window.crypto),typeof self<"u"&&self.crypto&&(i=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(i=globalThis.crypto),!i&&typeof window<"u"&&window.msCrypto&&(i=window.msCrypto),!i&&typeof global<"u"&&global.crypto&&(i=global.crypto),!i&&typeof F=="function")try{i=F("crypto");}catch{}var o=function(){if(i){if(typeof i.getRandomValues=="function")try{return i.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof i.randomBytes=="function")try{return i.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||function(){function r(){}return function(a){var u;return r.prototype=a,u=new r,r.prototype=null,u}}(),c={},p=c.lib={},g=p.Base=function(){return {extend:function(r){var a=s(this);return r&&a.mixIn(r),(!a.hasOwnProperty("init")||this.init===a.init)&&(a.init=function(){a.$super.init.apply(this,arguments);}),a.init.prototype=a,a.$super=this,a},create:function(){var r=this.extend();return r.init.apply(r,arguments),r},init:function(){},mixIn:function(r){for(var a in r)r.hasOwnProperty(a)&&(this[a]=r[a]);r.hasOwnProperty("toString")&&(this.toString=r.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),d=p.WordArray=g.extend({init:function(r,a){r=this.words=r||[],a!=n?this.sigBytes=a:this.sigBytes=r.length*4;},toString:function(r){return (r||y).stringify(this)},concat:function(r){var a=this.words,u=r.words,m=this.sigBytes,T=r.sigBytes;if(this.clamp(),m%4)for(var N=0;N<T;N++){var $=u[N>>>2]>>>24-N%4*8&255;a[m+N>>>2]|=$<<24-(m+N)%4*8;}else for(var S=0;S<T;S+=4)a[m+S>>>2]=u[S>>>2];return this.sigBytes+=T,this},clamp:function(){var r=this.words,a=this.sigBytes;r[a>>>2]&=4294967295<<32-a%4*8,r.length=e.ceil(a/4);},clone:function(){var r=g.clone.call(this);return r.words=this.words.slice(0),r},random:function(r){for(var a=[],u=0;u<r;u+=4)a.push(o());return new d.init(a,r)}}),l=c.enc={},y=l.Hex={stringify:function(r){for(var a=r.words,u=r.sigBytes,m=[],T=0;T<u;T++){var N=a[T>>>2]>>>24-T%4*8&255;m.push((N>>>4).toString(16)),m.push((N&15).toString(16));}return m.join("")},parse:function(r){for(var a=r.length,u=[],m=0;m<a;m+=2)u[m>>>3]|=parseInt(r.substr(m,2),16)<<24-m%8*4;return new d.init(u,a/2)}},h=l.Latin1={stringify:function(r){for(var a=r.words,u=r.sigBytes,m=[],T=0;T<u;T++){var N=a[T>>>2]>>>24-T%4*8&255;m.push(String.fromCharCode(N));}return m.join("")},parse:function(r){for(var a=r.length,u=[],m=0;m<a;m++)u[m>>>2]|=(r.charCodeAt(m)&255)<<24-m%4*8;return new d.init(u,a)}},b=l.Utf8={stringify:function(r){try{return decodeURIComponent(escape(h.stringify(r)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(r){return h.parse(unescape(encodeURIComponent(r)))}},x=p.BufferedBlockAlgorithm=g.extend({reset:function(){this._data=new d.init,this._nDataBytes=0;},_append:function(r){typeof r=="string"&&(r=b.parse(r)),this._data.concat(r),this._nDataBytes+=r.sigBytes;},_process:function(r){var a,u=this._data,m=u.words,T=u.sigBytes,N=this.blockSize,$=N*4,S=T/$;r?S=e.ceil(S):S=e.max((S|0)-this._minBufferSize,0);var k=S*N,W=e.min(k*4,T);if(k){for(var H=0;H<k;H+=N)this._doProcessBlock(m,H);a=m.splice(0,k),u.sigBytes-=W;}return new d.init(a,W)},clone:function(){var r=g.clone.call(this);return r._data=this._data.clone(),r},_minBufferSize:0});p.Hasher=x.extend({cfg:g.extend(),init:function(r){this.cfg=this.cfg.extend(r),this.reset();},reset:function(){x.reset.call(this),this._doReset();},update:function(r){return this._append(r),this._process(),this},finalize:function(r){r&&this._append(r);var a=this._doFinalize();return a},blockSize:512/32,_createHelper:function(r){return function(a,u){return new r.init(u).finalize(a)}},_createHmacHelper:function(r){return function(a,u){return new V.HMAC.init(r,u).finalize(a)}}});var V=c.algo={};return c}(Math);return t});});var Y=K((D,q)=>{(function(t,e){typeof D=="object"?q.exports=D=e(X()):typeof define=="function"&&define.amd?define(["./core"],e):e(t.CryptoJS);})(D,function(t){return function(){var e=t,n=e.lib,i=n.WordArray,o=n.Hasher,s=e.algo,c=[],p=s.SHA1=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(g,d){for(var l=this._hash.words,y=l[0],h=l[1],b=l[2],x=l[3],C=l[4],V=0;V<80;V++){if(V<16)c[V]=g[d+V]|0;else {var r=c[V-3]^c[V-8]^c[V-14]^c[V-16];c[V]=r<<1|r>>>31;}var a=(y<<5|y>>>27)+C+c[V];V<20?a+=(h&b|~h&x)+1518500249:V<40?a+=(h^b^x)+1859775393:V<60?a+=(h&b|h&x|b&x)-1894007588:a+=(h^b^x)-899497514,C=x,x=b,b=h<<30|h>>>2,h=y,y=a;}l[0]=l[0]+y|0,l[1]=l[1]+h|0,l[2]=l[2]+b|0,l[3]=l[3]+x|0,l[4]=l[4]+C|0;},_doFinalize:function(){var g=this._data,d=g.words,l=this._nDataBytes*8,y=g.sigBytes*8;return d[y>>>5]|=128<<24-y%32,d[(y+64>>>9<<4)+14]=Math.floor(l/4294967296),d[(y+64>>>9<<4)+15]=l,g.sigBytes=d.length*4,this._process(),this._hash},clone:function(){var g=o.clone.call(this);return g._hash=this._hash.clone(),g}});e.SHA1=o._createHelper(p),e.HmacSHA1=o._createHmacHelper(p);}(),t.SHA1});});var re=ue(Y());var E="___param___";var P=class t{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(n=>t._translate(`${n}`)):t._translate(`${e}`)}static set translate(e){t._translate=e;}static addKey(e,n,i){let o=i.defaultValue||"empty_string";typeof n=="string"&&(n=[n]),Array.isArray(n)&&n.forEach(s=>{e[s]===void 0&&(o==="empty_string"?e[s]="":o==="copy_key"&&(e[s]=s));});}static getConditionalsThenElse(e,n=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&t.getConditionalsThenElse(e.then,n),e.else&&t.getConditionalsThenElse(e.else,n);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(i=>{t.getConditionalsThenElse(i,n);});else if(e.elements.type==="ifelse"){let i=[];t.getConditionalsThenElse(e.elements,i),i.forEach(o=>{n.push(...o);});}else if(e.elements.type==="stepswitch"){let i=[];t.getConditionalsThenElse(e.elements,i),i.forEach(o=>{n.push(...o);});}else t.getConditionalsThenElse(e.elements,n);}else e.type==="resulttocombine"?(e.firstItem&&t.getConditionalsThenElse(e.firstItem,n),e.secondConditionalItem&&e.secondConditionalItem.forEach(i=>{t.getConditionalsThenElse(i,n);})):n.push(e);else e&&n.push(e);return n}static generateJsonTranslation(e,n={},i={}){return e.forEach(o=>{if(o.choices){let s=[];Array.isArray(o.choices)?s=[o.choices]:s=t.getConditionalsThenElse(o.choices),s.forEach(c=>c.forEach(p=>{if("type"in p){let g=[];p.type==="ifelse"||p.type==="stepswitch"?t.getConditionalsThenElse(p,g):g=[p],g.map(l=>t.getConditionalsThenElse(l.text)).forEach(l=>{Array.isArray(l)&&l.forEach(y=>{Array.isArray(y)?y.forEach(h=>{typeof h=="string"?t.addKey(n,h,i):t.getConditionalsThenElse(h).forEach(b=>{Array.isArray(b)?b.forEach(x=>{typeof x=="string"&&t.addKey(n,x,i);}):typeof b=="string"&&t.addKey(n,b,i);});}):typeof y=="string"&&t.addKey(n,y,i);});});}}));}if(o.dialogue){let s=[];Array.isArray(o.dialogue)?s=[o.dialogue]:s=t.getConditionalsThenElse(o.dialogue),s.forEach(c=>{typeof c=="string"?t.addKey(n,c,i):"text"in c&&Array.isArray(c.text)&&c.text.forEach(p=>{typeof p=="string"?t.addKey(n,p,i):t.getConditionalsThenElse(p).forEach(d=>{typeof d=="string"?t.addKey(n,d,i):Array.isArray(d)&&d.forEach(l=>{typeof l=="string"?t.addKey(n,l,i):t.getConditionalsThenElse(l).forEach(y=>{typeof y=="string"&&t.addKey(n,y,i);});});});});});}o.conditionalStep&&t.getConditionalsThenElse(o.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateJsonTranslation(c,n,i):t.generateJsonTranslation([c],n,i);});}),n}};function de(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function ge(t){if(Array.isArray(t)||!t)return t;if(t&&typeof t=="object"&&"type"in t)switch(t.type){case"resulttocombine":return ye(t);case"ifelse":return f(t.condition)?f(t.then):f(t.else);case"stepswitch":let n=f(t.elements)||[];if(n.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let i=de(0,n.length-1);return f(n[i]);case"loop":let o=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return o>n.length-1&&(o=o%n.length),f(n[o]);case"sequential":let s,c=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end=="lastItem"&&(s=f(n[n.length-1])),c>n.length-1?s:f(n[c]);case"sequentialrandom":let p=NarrationManagerStatic.getRandomNumber(0,n.length-1,{nestedId:t.nestedId,onceOnly:!0});if(p==null&&t.end=="lastItem"){let g=NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!g||!g?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let d=g.usedRandomNumbers[`0-${n.length-1}`];return f(n[d[d.length-1]])}if(p==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return f(n[p])}}return t}function B(t){if(t.conditionalStep){let e=createExportableElement(f(t.conditionalStep));if(e?.glueEnabled===void 0&&delete e?.glueEnabled,e?.goNextStep===void 0&&delete e?.goNextStep,e?.end===void 0&&delete e?.end,e?.choices===void 0&&delete e?.choices,e?.dialogue===void 0&&delete e?.dialogue,e?.labelToOpen===void 0&&delete e?.labelToOpen,e?.operation===void 0&&delete e?.operation,e){let n={...t,conditionalStep:void 0,...e};return B(n)}else getFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return t}function ye(t){let e=t.firstItem,n=[];t.secondConditionalItem?.forEach(o=>{if(Array.isArray(o))o.forEach(s=>{let c=f(s);n.push(c);});else {let s=f(o);n.push(s);}});let i=e?[e,...n]:n;if(i.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof i[0]=="string")return P.t(i).join("");if(typeof i[0]=="object"){let o=i,s,c=o.map((r,a)=>{r=B(r);let u=f(r.dialogue)||"";return a===0?(s=f(r.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),s===!1&&(u=`
|
|
2
2
|
|
|
3
|
-
`+u),s=f(
|
|
3
|
+
`+u),s=f(r.glueEnabled)||!1,u)}),p=f(c[0]),g=typeof p=="object"&&"character"in p?p.character:void 0,d=c.map(r=>{let a;r&&typeof r=="object"&&"text"in r?a=r.text:a=r;let u;return Array.isArray(a)?u=a.map(m=>{let T=f(m);return P.t(`${T}`)}).join(""):u=f(a)||"",P.t(u)}).join(""),l=o.find(r=>r.end),y=o.find(r=>r.choices),h=!1,b=!1;o.length>0&&(o[0].glueEnabled&&o[0].goNextStep&&o[0].dialogue===void 0&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),h=o[o.length-1].glueEnabled,b=o.reverse().find(r=>!(r.operation&&(!r.dialogue||!r.choices)))?.goNextStep);let x=o.find(r=>r.labelToOpen),C=[];return o.forEach(r=>{r.operation&&C.forEach(a=>{C.push(a);});}),{dialogue:g?{character:g,text:d}:d,end:l?.end,choices:y?.choices,glueEnabled:h,goNextStep:b,labelToOpen:x?.labelToOpen,operation:C}}}function he(t){if(!t)return !1;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case"compare":let e=f(t.leftValue),n=f(t.rightValue);switch(t.operator){case"==":return e===n;case"!=":return e!==n;case"<":return e<n;case"<=":return e<=n;case">":return e>n;case">=":return e>=n;case"CONTAINS":return e.toString().includes(n.toString())}break;case"valueCondition":return !!f(t.value);case"union":return xe(t)}return !!t}function me(t){if(t&&typeof t=="object"&&"type"in t&&t.type==="value"&&t.storageOperationType==="get")switch(t.storageType){case"storage":case"tempstorage":return storage.getVariable(t.key);case"flagStorage":return getFlag(t.key);case"label":return narration.getTimesLabelOpened(t.label);case"choice":return narration.getTimesChoiceMade(t.index);case"logic":return f(t.operation);case"params":let e=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];if(e&&e.length>t.key)return e[t.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return t}function xe(t){if(t.unionType==="not")return !f(t.condition);let e=t.unionType==="and";for(let n=0;n<t.conditions.length;n++)if(e=f(t.conditions[n])||!1,t.unionType==="and"){if(!e)return !1}else if(e)return !0;return e}function j(t){let e=f(t.value),n;switch(e&&typeof e=="object"&&"type"in e?n=f(e):n=e,t.storageType){case"flagStorage":setFlag(t.key,t.value);break;case"storage":storage.setVariable(t.key,n);break;case"tempstorage":storage.setTempVariable(t.key,n);break;case"params":let i=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];i&&i.length-1>=t.key&&(i[t.key]=n),storage.setTempVariable(`${E}${narration.openedLabels.length-1}`,i);break}}function f(t){let e=ge(t);if(e&&typeof e=="object"&&"type"in e)switch(e.type){case"value":return me(e);case"arithmetic":case"arithmeticsingle":return be(e);case"compare":case"valueCondition":case"union":return he(e)}return e}function be(t){let e=f(t.leftValue);switch(t.type){case"arithmetic":let n=f(t.rightValue);switch(t.operator){case"*":return e*n;case"/":return e/n;case"+":return e+n;case"-":return e-n;case"%":return e%n;case"POW":return Math.pow(e,n);case"RANDOM":return narration.getRandomNumber(e,n)}case"arithmeticsingle":switch(t.operator){case"INT":return parseInt(e);case"FLOOR":return Math.floor(e);case"FLOAT":return parseFloat(e)}break}}async function O(t,e,n){let i=f(t);if(i)switch(i.type){case"sound":switch(i.operationType){case"add":sound.add(i.alias,{...i.props,url:i.url});break;case"play":sound.play(i.alias,i.props);break;case"remove":sound.remove(i.alias);break;case"pause":sound.pause(i.alias);break;case"resume":sound.resume(i.alias);break;case"volume":sound.volume(i.alias,i.value);break}break;case"image":switch(i.operationType){case"show":if(i.transition)switch(i.transition.type){case"fade":await showWithFadeTransition(i.alias,i.url,i.transition.props,i.transition.priority);break;case"dissolve":await showWithDissolveTransition(i.alias,i.url,i.transition.props,i.transition.priority);break;case"movein":case"moveout":await moveIn(i.alias,i.url,i.transition.props,i.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(i.alias,i.url,i.transition.props,i.transition.priority);break}else await showImage(i.alias,i.url);break;case"edit":let o=canvas.find(i.alias);o?i.props&&(o.memory={...o.memory,...i.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${i.alias} not found.`);break;case"remove":canvas.remove(i.alias);break}break;case"video":switch(i.operationType){case"show":if(i.transition){let p=new CanvasVideo;switch(p.videoLink=i.url,i.transition.type){case"fade":await showWithFadeTransition(i.alias,p,i.transition.props,i.transition.priority);break;case"dissolve":await showWithDissolveTransition(i.alias,p,i.transition.props,i.transition.priority);break;case"movein":case"moveout":await moveIn(i.alias,p,i.transition.props,i.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(i.alias,p,i.transition.props,i.transition.priority);break}}else await showVideo(i.alias,i.url);break;case"edit":let o=canvas.find(i.alias);o?i.props&&(o.memory={...o.memory,...i.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${i.alias} not found.`);break;case"remove":canvas.remove(i.alias);break;case"pause":let s=canvas.find(i.alias);s?s.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${i.alias} not found.`);break;case"resume":let c=canvas.find(i.alias);c?c.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${i.alias} not found.`);break}break;case"value":j(i);break;case"oprationtoconvert":if(n){let o="";i.values.forEach(c=>{if(typeof c=="string")o+=c;else {let p=f(c);o+=`${p}`;}});let s=n(o,e);s&&await O(s,e,n);}break;case"input":switch(i.operationType){case"request":narration.requestInput({type:i.valueType});break}break}}var _=class extends LabelAbstract{constructor(e,n,i,o={}){super(e,i),this._steps=n,this.operationStringConvert=o.operationStringConvert,this.skipEmptyDialogs=o.skipEmptyDialogs||!1;}_steps;get steps(){return this._steps.map(e=>this.stepConverter(e))}operationStringConvert;skipEmptyDialogs=!1;getStepSha1(e){if(e<0||e>=this.steps.length)return;let n=this._steps[e];return (0, re.default)(n.toString().toLocaleLowerCase()).toString()}getDialogueText(e){let n="";if(Array.isArray(e)){let i=[];e.forEach(o=>{if(typeof o=="string")i.push(o);else if(o&&typeof o=="object"){let s=f(o);s?(s&&!Array.isArray(s)&&typeof s=="object"&&(s=f(s)||""),Array.isArray(s)?i=i.concat(s):i.push(`${s}`)):i.push(`${o}`);}}),n=i;}else {let i=f(e)||"";i&&!Array.isArray(i)&&typeof i=="object"&&(i=f(i)||""),n=i;}return `${n}`}getDialogue(e){let n=f(e);if(n)return typeof n=="object"&&"character"in n&&"text"in n?{character:n.character,text:P.t(this.getDialogueText(n.text))}:P.t(this.getDialogueText(n));if(n!=null)return `${n}`}getChoices(e){return f(e)?.map(o=>f(o)).filter(o=>o!==void 0)}stepConverter(e){return async n=>{if(typeof e=="function"&&(e=e()),e=B(e),e.operation)for(let d of e.operation)await O(d,n,this.operationStringConvert);let i=this.getChoices(e.choices),o=f(e.glueEnabled),s=this.getDialogue(e.dialogue),c=[];e.labelToOpen&&(Array.isArray(e.labelToOpen)||(e.labelToOpen=[e.labelToOpen]),e.labelToOpen.forEach(d=>{let l=f(d);l&&c.push(l);}));let p=f(e.goNextStep),g=f(e.end);if(i){let d=i.map(l=>{let y="";if(Array.isArray(l.text)){let h=[];l.text.forEach(b=>{if(typeof b=="string")h.push(P.t(b));else if(b&&typeof b=="object"){let x=f(b);x&&!Array.isArray(x)&&typeof x=="object"&&(x=f(x)||""),x&&(Array.isArray(x)?h=h.concat(P.t(x)):h.push(P.t(x)));}}),y=h.join();}else typeof l.text=="string"&&(y=P.t(l.text));return new ChoiceMenuOption(y,l.label,l.props,{type:l.type,oneTime:l.oneTime,onlyHaveNoChoice:l.onlyHaveNoChoice,autoSelect:l.autoSelect})});narration.choiceMenuOptions=d;}else narration.choiceMenuOptions=void 0;s!==void 0&&(narration.dialogue=s,this.skipEmptyDialogs&&typeof s=="string"&&(s===""||RegExp(/^\s+$/).test(s))&&(p=!0)),o?setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):o===!1&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);for(let d of c){let l=d.label;typeof l=="object"&&(l=f(l)||"");let y=d.params?.map(h=>f(h));n={...n,...d.props},d.type==="jump"?(narration.closeCurrentLabel(),storage.setTempVariable(`${E}${narration.openedLabels.length}`,y),await narration.callLabel(l,n)):(storage.setTempVariable(`${E}${narration.openedLabels.length}`,y),await narration.callLabel(l,n));}g==="game_end"?(narration.closeAllLabels(),await narration.goNext(n)):g==="label_end"&&narration.closeCurrentLabel(),p&&await narration.goNext(n);}}};function Ee(t,e={}){let n=e?.operationStringConvert;try{typeof t=="string"&&(t=JSON.parse(t));}catch(i){console.error("[Pixi\u2019VN Json] Error parsing imported Pixi'VN JSON",i);return}if(typeof t!="object"){console.error("[Pixi\u2019VN Json] Error parsing imported Pixi'VN JSON: data is not an object");return}if(t.initialOperations){for(let i of t.initialOperations)O(i,{},n);StorageManagerStatic.saveStorageAsBasicStorage();}if(t.labels){let i=t.labels;for(let o in i)try{let s=i[o],c=new _(o,s,void 0,e);saveLabel(c);}catch(s){console.error(`[Pixi\u2019VN Json] Error creating JSON label ${o}`,s);}}}export{_ as LabelJson,E as PIXIVNJSON_PARAM_ID,P as TranslateManager,f as geLogichValue,Ee as importPixiVNJson,j as setStorageJson};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var p=class s{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(i=>s._translate(`${i}`)):s._translate(`${e}`)}static set translate(e){s._translate=e;}static addKey(e,i,t){let n=t.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===void 0&&(n==="empty_string"?e[r]="":n==="copy_key"&&(e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&s.getConditionalsThenElse(e.then,i),e.else&&s.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(t=>{s.getConditionalsThenElse(t,i);});else if(e.elements.type==="ifelse"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else s.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&s.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(t=>{s.getConditionalsThenElse(t,i);})):i.push(e);else e&&i.push(e);return i}static
|
|
1
|
+
'use strict';var p=class s{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(i=>s._translate(`${i}`)):s._translate(`${e}`)}static set translate(e){s._translate=e;}static addKey(e,i,t){let n=t.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===void 0&&(n==="empty_string"?e[r]="":n==="copy_key"&&(e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&s.getConditionalsThenElse(e.then,i),e.else&&s.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(t=>{s.getConditionalsThenElse(t,i);});else if(e.elements.type==="ifelse"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else s.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&s.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(t=>{s.getConditionalsThenElse(t,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},t={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=s.getConditionalsThenElse(n.choices),r.forEach(l=>l.forEach(o=>{if("type"in o){let h=[];o.type==="ifelse"||o.type==="stepswitch"?s.getConditionalsThenElse(o,h):h=[o],h.map(f=>s.getConditionalsThenElse(f.text)).forEach(f=>{Array.isArray(f)&&f.forEach(a=>{Array.isArray(a)?a.forEach(c=>{typeof c=="string"?s.addKey(i,c,t):s.getConditionalsThenElse(c).forEach(g=>{Array.isArray(g)?g.forEach(E=>{typeof E=="string"&&s.addKey(i,E,t);}):typeof g=="string"&&s.addKey(i,g,t);});}):typeof a=="string"&&s.addKey(i,a,t);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=s.getConditionalsThenElse(n.dialogue),r.forEach(l=>{typeof l=="string"?s.addKey(i,l,t):"text"in l&&Array.isArray(l.text)&&l.text.forEach(o=>{typeof o=="string"?s.addKey(i,o,t):s.getConditionalsThenElse(o).forEach(y=>{typeof y=="string"?s.addKey(i,y,t):Array.isArray(y)&&y.forEach(f=>{typeof f=="string"?s.addKey(i,f,t):s.getConditionalsThenElse(f).forEach(a=>{typeof a=="string"&&s.addKey(i,a,t);});});});});});}n.conditionalStep&&s.getConditionalsThenElse(n.conditionalStep).forEach(l=>{Array.isArray(l)?s.generateJsonTranslation(l,i,t):s.generateJsonTranslation([l],i,t);});}),i}};module.exports=p;
|
|
@@ -13,7 +13,7 @@ declare class TranslatorManager {
|
|
|
13
13
|
static set translate(value: (key: string) => string);
|
|
14
14
|
private static addKey;
|
|
15
15
|
private static getConditionalsThenElse;
|
|
16
|
-
static
|
|
16
|
+
static generateJsonTranslation(labels: PixiVNJsonLabelStep[], json?: object, options?: {
|
|
17
17
|
defaultValue?: "empty_string" | "copy_key";
|
|
18
18
|
}): object;
|
|
19
19
|
}
|
|
@@ -13,7 +13,7 @@ declare class TranslatorManager {
|
|
|
13
13
|
static set translate(value: (key: string) => string);
|
|
14
14
|
private static addKey;
|
|
15
15
|
private static getConditionalsThenElse;
|
|
16
|
-
static
|
|
16
|
+
static generateJsonTranslation(labels: PixiVNJsonLabelStep[], json?: object, options?: {
|
|
17
17
|
defaultValue?: "empty_string" | "copy_key";
|
|
18
18
|
}): object;
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var p=class s{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(i=>s._translate(`${i}`)):s._translate(`${e}`)}static set translate(e){s._translate=e;}static addKey(e,i,t){let n=t.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===void 0&&(n==="empty_string"?e[r]="":n==="copy_key"&&(e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&s.getConditionalsThenElse(e.then,i),e.else&&s.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(t=>{s.getConditionalsThenElse(t,i);});else if(e.elements.type==="ifelse"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else s.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&s.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(t=>{s.getConditionalsThenElse(t,i);})):i.push(e);else e&&i.push(e);return i}static
|
|
1
|
+
var p=class s{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(i=>s._translate(`${i}`)):s._translate(`${e}`)}static set translate(e){s._translate=e;}static addKey(e,i,t){let n=t.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===void 0&&(n==="empty_string"?e[r]="":n==="copy_key"&&(e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&s.getConditionalsThenElse(e.then,i),e.else&&s.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(t=>{s.getConditionalsThenElse(t,i);});else if(e.elements.type==="ifelse"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else s.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&s.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(t=>{s.getConditionalsThenElse(t,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},t={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=s.getConditionalsThenElse(n.choices),r.forEach(l=>l.forEach(o=>{if("type"in o){let h=[];o.type==="ifelse"||o.type==="stepswitch"?s.getConditionalsThenElse(o,h):h=[o],h.map(f=>s.getConditionalsThenElse(f.text)).forEach(f=>{Array.isArray(f)&&f.forEach(a=>{Array.isArray(a)?a.forEach(c=>{typeof c=="string"?s.addKey(i,c,t):s.getConditionalsThenElse(c).forEach(g=>{Array.isArray(g)?g.forEach(E=>{typeof E=="string"&&s.addKey(i,E,t);}):typeof g=="string"&&s.addKey(i,g,t);});}):typeof a=="string"&&s.addKey(i,a,t);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=s.getConditionalsThenElse(n.dialogue),r.forEach(l=>{typeof l=="string"?s.addKey(i,l,t):"text"in l&&Array.isArray(l.text)&&l.text.forEach(o=>{typeof o=="string"?s.addKey(i,o,t):s.getConditionalsThenElse(o).forEach(y=>{typeof y=="string"?s.addKey(i,y,t):Array.isArray(y)&&y.forEach(f=>{typeof f=="string"?s.addKey(i,f,t):s.getConditionalsThenElse(f).forEach(a=>{typeof a=="string"&&s.addKey(i,a,t);});});});});});}n.conditionalStep&&s.getConditionalsThenElse(n.conditionalStep).forEach(l=>{Array.isArray(l)?s.generateJsonTranslation(l,i,t):s.generateJsonTranslation([l],i,t);});}),i}};export{p as default};
|
package/dist/managers/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var c=class s{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(i=>s._translate(`${i}`)):s._translate(`${e}`)}static set translate(e){s._translate=e;}static addKey(e,i,t){let n=t.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===void 0&&(n==="empty_string"?e[r]="":n==="copy_key"&&(e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&s.getConditionalsThenElse(e.then,i),e.else&&s.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(t=>{s.getConditionalsThenElse(t,i);});else if(e.elements.type==="ifelse"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else s.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&s.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(t=>{s.getConditionalsThenElse(t,i);})):i.push(e);else e&&i.push(e);return i}static
|
|
1
|
+
'use strict';var c=class s{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(i=>s._translate(`${i}`)):s._translate(`${e}`)}static set translate(e){s._translate=e;}static addKey(e,i,t){let n=t.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===void 0&&(n==="empty_string"?e[r]="":n==="copy_key"&&(e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&s.getConditionalsThenElse(e.then,i),e.else&&s.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(t=>{s.getConditionalsThenElse(t,i);});else if(e.elements.type==="ifelse"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else s.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&s.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(t=>{s.getConditionalsThenElse(t,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},t={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=s.getConditionalsThenElse(n.choices),r.forEach(l=>l.forEach(o=>{if("type"in o){let h=[];o.type==="ifelse"||o.type==="stepswitch"?s.getConditionalsThenElse(o,h):h=[o],h.map(f=>s.getConditionalsThenElse(f.text)).forEach(f=>{Array.isArray(f)&&f.forEach(a=>{Array.isArray(a)?a.forEach(p=>{typeof p=="string"?s.addKey(i,p,t):s.getConditionalsThenElse(p).forEach(g=>{Array.isArray(g)?g.forEach(T=>{typeof T=="string"&&s.addKey(i,T,t);}):typeof g=="string"&&s.addKey(i,g,t);});}):typeof a=="string"&&s.addKey(i,a,t);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=s.getConditionalsThenElse(n.dialogue),r.forEach(l=>{typeof l=="string"?s.addKey(i,l,t):"text"in l&&Array.isArray(l.text)&&l.text.forEach(o=>{typeof o=="string"?s.addKey(i,o,t):s.getConditionalsThenElse(o).forEach(y=>{typeof y=="string"?s.addKey(i,y,t):Array.isArray(y)&&y.forEach(f=>{typeof f=="string"?s.addKey(i,f,t):s.getConditionalsThenElse(f).forEach(a=>{typeof a=="string"&&s.addKey(i,a,t);});});});});});}n.conditionalStep&&s.getConditionalsThenElse(n.conditionalStep).forEach(l=>{Array.isArray(l)?s.generateJsonTranslation(l,i,t):s.generateJsonTranslation([l],i,t);});}),i}};exports.TranslateManager=c;
|
package/dist/managers/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=class s{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(i=>s._translate(`${i}`)):s._translate(`${e}`)}static set translate(e){s._translate=e;}static addKey(e,i,t){let n=t.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===void 0&&(n==="empty_string"?e[r]="":n==="copy_key"&&(e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&s.getConditionalsThenElse(e.then,i),e.else&&s.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(t=>{s.getConditionalsThenElse(t,i);});else if(e.elements.type==="ifelse"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else s.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&s.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(t=>{s.getConditionalsThenElse(t,i);})):i.push(e);else e&&i.push(e);return i}static
|
|
1
|
+
var c=class s{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(i=>s._translate(`${i}`)):s._translate(`${e}`)}static set translate(e){s._translate=e;}static addKey(e,i,t){let n=t.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===void 0&&(n==="empty_string"?e[r]="":n==="copy_key"&&(e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&s.getConditionalsThenElse(e.then,i),e.else&&s.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(t=>{s.getConditionalsThenElse(t,i);});else if(e.elements.type==="ifelse"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else s.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&s.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(t=>{s.getConditionalsThenElse(t,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},t={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=s.getConditionalsThenElse(n.choices),r.forEach(l=>l.forEach(o=>{if("type"in o){let h=[];o.type==="ifelse"||o.type==="stepswitch"?s.getConditionalsThenElse(o,h):h=[o],h.map(f=>s.getConditionalsThenElse(f.text)).forEach(f=>{Array.isArray(f)&&f.forEach(a=>{Array.isArray(a)?a.forEach(p=>{typeof p=="string"?s.addKey(i,p,t):s.getConditionalsThenElse(p).forEach(g=>{Array.isArray(g)?g.forEach(T=>{typeof T=="string"&&s.addKey(i,T,t);}):typeof g=="string"&&s.addKey(i,g,t);});}):typeof a=="string"&&s.addKey(i,a,t);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=s.getConditionalsThenElse(n.dialogue),r.forEach(l=>{typeof l=="string"?s.addKey(i,l,t):"text"in l&&Array.isArray(l.text)&&l.text.forEach(o=>{typeof o=="string"?s.addKey(i,o,t):s.getConditionalsThenElse(o).forEach(y=>{typeof y=="string"?s.addKey(i,y,t):Array.isArray(y)&&y.forEach(f=>{typeof f=="string"?s.addKey(i,f,t):s.getConditionalsThenElse(f).forEach(a=>{typeof a=="string"&&s.addKey(i,a,t);});});});});});}n.conditionalStep&&s.getConditionalsThenElse(n.conditionalStep).forEach(l=>{Array.isArray(l)?s.generateJsonTranslation(l,i,t):s.generateJsonTranslation([l],i,t);});}),i}};export{c as TranslateManager};
|