@drincs/pixi-vn-json 1.0.2 → 1.0.4
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/{PixiVNJsonConditionalStatements-BBopD3ft.d.cts → PixiVNJsonConditionalStatements-CVkQSKpq.d.cts} +15 -4
- package/dist/{PixiVNJsonConditionalStatements-CSzbVYiW.d.ts → PixiVNJsonConditionalStatements-CVkQSKpq.d.ts} +15 -4
- package/dist/classes/LabelJson.cjs +2 -6
- package/dist/classes/LabelJson.d.cts +14 -5
- package/dist/classes/LabelJson.d.ts +14 -5
- package/dist/classes/LabelJson.js +2 -4
- package/dist/classes/index.cjs +2 -6
- package/dist/classes/index.d.cts +1 -2
- package/dist/classes/index.d.ts +1 -2
- package/dist/classes/index.js +2 -4
- package/dist/constants.cjs +1 -5
- package/dist/constants.js +1 -3
- package/dist/functions/importer.cjs +2 -6
- package/dist/functions/importer.d.cts +6 -6
- package/dist/functions/importer.d.ts +6 -6
- package/dist/functions/importer.js +2 -4
- package/dist/functions/index.cjs +2 -10
- package/dist/functions/index.d.cts +6 -6
- package/dist/functions/index.d.ts +6 -6
- package/dist/functions/index.js +2 -4
- package/dist/functions/operation-utility.cjs +3 -0
- package/dist/functions/operation-utility.d.cts +11 -0
- package/dist/functions/operation-utility.d.ts +11 -0
- package/dist/functions/operation-utility.js +3 -0
- package/dist/functions/utility.cjs +2 -9
- package/dist/functions/utility.d.cts +11 -17
- package/dist/functions/utility.d.ts +11 -17
- package/dist/functions/utility.js +2 -4
- package/dist/index.cjs +2 -12
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -4
- package/dist/interface/PixiVNJson.cjs +1 -2
- package/dist/interface/PixiVNJson.d.cts +1 -2
- package/dist/interface/PixiVNJson.d.ts +1 -2
- package/dist/interface/PixiVNJson.js +0 -1
- package/dist/interface/PixiVNJsonArithmeticOperations.cjs +1 -2
- package/dist/interface/PixiVNJsonArithmeticOperations.d.cts +1 -2
- package/dist/interface/PixiVNJsonArithmeticOperations.d.ts +1 -2
- package/dist/interface/PixiVNJsonArithmeticOperations.js +0 -1
- package/dist/interface/PixiVNJsonConditionalResultToCombine.cjs +1 -2
- package/dist/interface/PixiVNJsonConditionalResultToCombine.d.cts +1 -2
- package/dist/interface/PixiVNJsonConditionalResultToCombine.d.ts +1 -2
- package/dist/interface/PixiVNJsonConditionalResultToCombine.js +0 -1
- package/dist/interface/PixiVNJsonConditionalStatements.cjs +1 -2
- package/dist/interface/PixiVNJsonConditionalStatements.d.cts +1 -2
- package/dist/interface/PixiVNJsonConditionalStatements.d.ts +1 -2
- package/dist/interface/PixiVNJsonConditionalStatements.js +0 -1
- package/dist/interface/PixiVNJsonConditions.cjs +1 -2
- package/dist/interface/PixiVNJsonConditions.d.cts +1 -2
- package/dist/interface/PixiVNJsonConditions.d.ts +1 -2
- package/dist/interface/PixiVNJsonConditions.js +0 -1
- package/dist/interface/PixiVNJsonIfElse.cjs +1 -2
- package/dist/interface/PixiVNJsonIfElse.d.cts +1 -2
- package/dist/interface/PixiVNJsonIfElse.d.ts +1 -2
- package/dist/interface/PixiVNJsonIfElse.js +0 -1
- package/dist/interface/PixiVNJsonInput.cjs +1 -2
- package/dist/interface/PixiVNJsonInput.js +0 -1
- package/dist/interface/PixiVNJsonLabelStep.cjs +1 -2
- package/dist/interface/PixiVNJsonLabelStep.d.cts +12 -5
- package/dist/interface/PixiVNJsonLabelStep.d.ts +12 -5
- package/dist/interface/PixiVNJsonLabelStep.js +0 -1
- package/dist/interface/PixiVNJsonLabels.cjs +1 -2
- package/dist/interface/PixiVNJsonLabels.d.cts +1 -2
- package/dist/interface/PixiVNJsonLabels.d.ts +1 -2
- package/dist/interface/PixiVNJsonLabels.js +0 -1
- package/dist/interface/PixiVNJsonMedia.cjs +1 -2
- package/dist/interface/PixiVNJsonMedia.js +0 -1
- package/dist/interface/PixiVNJsonMediaTransiotions.cjs +1 -2
- package/dist/interface/PixiVNJsonMediaTransiotions.js +0 -1
- package/dist/interface/PixiVNJsonOperations.cjs +1 -2
- package/dist/interface/PixiVNJsonOperations.d.cts +1 -2
- package/dist/interface/PixiVNJsonOperations.d.ts +1 -2
- package/dist/interface/PixiVNJsonOperations.js +0 -1
- package/dist/interface/PixiVNJsonStepSwitch.cjs +1 -2
- package/dist/interface/PixiVNJsonStepSwitch.d.cts +1 -2
- package/dist/interface/PixiVNJsonStepSwitch.d.ts +1 -2
- package/dist/interface/PixiVNJsonStepSwitch.js +0 -1
- package/dist/interface/PixiVNJsonUnionCondition.cjs +1 -2
- package/dist/interface/PixiVNJsonUnionCondition.d.cts +1 -2
- package/dist/interface/PixiVNJsonUnionCondition.d.ts +1 -2
- package/dist/interface/PixiVNJsonUnionCondition.js +0 -1
- package/dist/interface/PixiVNJsonValue.cjs +1 -2
- package/dist/interface/PixiVNJsonValue.d.cts +1 -2
- package/dist/interface/PixiVNJsonValue.d.ts +1 -2
- package/dist/interface/PixiVNJsonValue.js +0 -1
- package/dist/interface/index.cjs +1 -2
- package/dist/interface/index.d.cts +1 -2
- package/dist/interface/index.d.ts +1 -2
- package/dist/interface/index.js +0 -1
- package/dist/managers/TranslateManager.cjs +1 -0
- package/dist/managers/TranslateManager.d.cts +27 -0
- package/dist/managers/TranslateManager.d.ts +27 -0
- package/dist/managers/TranslateManager.js +1 -0
- package/dist/managers/index.cjs +1 -0
- package/dist/managers/index.d.cts +9 -0
- package/dist/managers/index.d.ts +9 -0
- package/dist/managers/index.js +1 -0
- package/package.json +2 -2
- package/dist/interface/PixiVNJsonLabelCondition.cjs +0 -2
- package/dist/interface/PixiVNJsonLabelCondition.d.cts +0 -16
- package/dist/interface/PixiVNJsonLabelCondition.d.ts +0 -16
- package/dist/interface/PixiVNJsonLabelCondition.js +0 -1
package/dist/functions/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { NarrationManagerStatic, narration, getFlag, StorageManagerStatic, storage, setFlag, saveLabel, LabelAbstract, ChoiceMenuOption, canvas, CanvasVideo, zoomIn, moveIn, showWithDissolveTransition, showWithFadeTransition, showVideo, showImage, sound } from '@drincs/pixi-vn';
|
|
1
|
+
import {storage,narration,setFlag,StorageManagerStatic,saveLabel,NarrationManagerStatic,getFlag,canvas,CanvasVideo,zoomIn,moveIn,showWithDissolveTransition,showWithFadeTransition,showVideo,showImage,sound,LabelAbstract,ChoiceMenuOption,createExportableElement}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],v=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)+v+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,v=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]+v|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 _="___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;}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));});}getConditionalsThenElse(i,e=[]){if(typeof i=="object"&&i&&"type"in i)if(i.type==="ifelse")i.then&&this.getConditionalsThenElse(i.then,e),i.else&&this.getConditionalsThenElse(i.else,e);else if(i.type==="stepswitch"){if(i.elements)if(Array.isArray(i.elements))i.elements.forEach(r=>{this.getConditionalsThenElse(r,e);});else if(i.elements.type==="ifelse"){let r=[];this.getConditionalsThenElse(i.elements,r),r.forEach(o=>{e.push(...o);});}else if(i.elements.type==="stepswitch"){let r=[];this.getConditionalsThenElse(i.elements,r),r.forEach(o=>{e.push(...o);});}else this.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&this.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(r=>{this.getConditionalsThenElse(r,e);})):e.push(i);else i&&e.push(i);return e}generateNewTranslateFile(i,e={},r={}){return i.forEach(o=>{if(o.choices){let s=[];Array.isArray(o.choices)?s=[o.choices]:s=this.getConditionalsThenElse(o.choices),s.forEach(c=>c.forEach(h=>{if("type"in h){let d=[];h.type==="ifelse"||h.type==="stepswitch"?this.getConditionalsThenElse(h,d):d=[h],d.map(l=>this.getConditionalsThenElse(l.text)).forEach(l=>{Array.isArray(l)&&l.forEach(g=>{Array.isArray(g)?g.forEach(y=>{typeof y=="string"?this.addKey(e,y,r):this.getConditionalsThenElse(y).forEach(b=>{Array.isArray(b)?b.forEach(x=>{typeof x=="string"&&this.addKey(e,x,r);}):typeof b=="string"&&this.addKey(e,b,r);});}):typeof g=="string"&&this.addKey(e,g,r);});});}}));}if(o.dialogue){let s=[];Array.isArray(o.dialogue)?s=[o.dialogue]:s=this.getConditionalsThenElse(o.dialogue),s.forEach(c=>{typeof c=="string"?this.addKey(e,c,r):"text"in c&&Array.isArray(c.text)&&c.text.forEach(h=>{typeof h=="string"?this.addKey(e,h,r):this.getConditionalsThenElse(h).forEach(p=>{typeof p=="string"?this.addKey(e,p,r):Array.isArray(p)&&p.forEach(l=>{typeof l=="string"?this.addKey(e,l,r):this.getConditionalsThenElse(l).forEach(g=>{typeof g=="string"&&this.addKey(e,g,r);});});});});});}o.conditionalStep&&this.getConditionalsThenElse(o.conditionalStep).forEach(c=>{Array.isArray(c)?this.generateNewTranslateFile(c,e,r):this.generateNewTranslateFile([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=`
|
|
2
2
|
|
|
3
|
-
var ne=Object.create;var G=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var ae=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var R=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(i,n)=>(typeof require<"u"?require:i)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var z=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var le=(t,i,n,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of oe(i))!se.call(t,o)&&o!==n&&G(t,o,{get:()=>i[o],enumerable:!(e=re(i,o))||e.enumerable});return t};var ue=(t,i,n)=>(n=t!=null?ne(ae(t)):{},le(G(n,"default",{value:t,enumerable:!0}),t));var W=z((L,M)=>{(function(t,i){typeof L=="object"?M.exports=L=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(L,function(){var t=t||function(i,n){var e;if(typeof window<"u"&&window.crypto&&(e=window.crypto),typeof self<"u"&&self.crypto&&(e=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(e=globalThis.crypto),!e&&typeof window<"u"&&window.msCrypto&&(e=window.msCrypto),!e&&typeof global<"u"&&global.crypto&&(e=global.crypto),!e&&typeof R=="function")try{e=R("crypto");}catch{}var o=function(){if(e){if(typeof e.getRandomValues=="function")try{return e.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof e.randomBytes=="function")try{return e.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},l=Object.create||function(){function r(){}return function(a){var g;return r.prototype=a,g=new r,r.prototype=null,g}}(),s={},d=s.lib={},x=d.Base=function(){return {extend:function(r){var a=l(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)}}}(),m=d.WordArray=x.extend({init:function(r,a){r=this.words=r||[],a!=n?this.sigBytes=a:this.sigBytes=r.length*4;},toString:function(r){return (r||f).stringify(this)},concat:function(r){var a=this.words,g=r.words,h=this.sigBytes,T=r.sigBytes;if(this.clamp(),h%4)for(var N=0;N<T;N++){var B=g[N>>>2]>>>24-N%4*8&255;a[h+N>>>2]|=B<<24-(h+N)%4*8;}else for(var J=0;J<T;J+=4)a[h+J>>>2]=g[J>>>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=i.ceil(a/4);},clone:function(){var r=x.clone.call(this);return r.words=this.words.slice(0),r},random:function(r){for(var a=[],g=0;g<r;g+=4)a.push(o());return new m.init(a,r)}}),u=s.enc={},f=u.Hex={stringify:function(r){for(var a=r.words,g=r.sigBytes,h=[],T=0;T<g;T++){var N=a[T>>>2]>>>24-T%4*8&255;h.push((N>>>4).toString(16)),h.push((N&15).toString(16));}return h.join("")},parse:function(r){for(var a=r.length,g=[],h=0;h<a;h+=2)g[h>>>3]|=parseInt(r.substr(h,2),16)<<24-h%8*4;return new m.init(g,a/2)}},y=u.Latin1={stringify:function(r){for(var a=r.words,g=r.sigBytes,h=[],T=0;T<g;T++){var N=a[T>>>2]>>>24-T%4*8&255;h.push(String.fromCharCode(N));}return h.join("")},parse:function(r){for(var a=r.length,g=[],h=0;h<a;h++)g[h>>>2]|=(r.charCodeAt(h)&255)<<24-h%4*8;return new m.init(g,a)}},b=u.Utf8={stringify:function(r){try{return decodeURIComponent(escape(y.stringify(r)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(r){return y.parse(unescape(encodeURIComponent(r)))}},c=d.BufferedBlockAlgorithm=x.extend({reset:function(){this._data=new m.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,g=this._data,h=g.words,T=g.sigBytes,N=this.blockSize,B=N*4,J=T/B;r?J=i.ceil(J):J=i.max((J|0)-this._minBufferSize,0);var A=J*N,F=i.min(A*4,T);if(A){for(var D=0;D<A;D+=N)this._doProcessBlock(h,D);a=h.splice(0,A),g.sigBytes-=F;}return new m.init(a,F)},clone:function(){var r=x.clone.call(this);return r._data=this._data.clone(),r},_minBufferSize:0});d.Hasher=c.extend({cfg:x.extend(),init:function(r){this.cfg=this.cfg.extend(r),this.reset();},reset:function(){c.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,g){return new r.init(g).finalize(a)}},_createHmacHelper:function(r){return function(a,g){return new V.HMAC.init(r,g).finalize(a)}}});var V=s.algo={};return s}(Math);return t});});var $=z((I,U)=>{(function(t,i){typeof I=="object"?U.exports=I=i(W()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(I,function(t){return function(){var i=t,n=i.lib,e=n.WordArray,o=n.Hasher,l=i.algo,s=[],d=l.SHA1=o.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(x,m){for(var u=this._hash.words,f=u[0],y=u[1],b=u[2],c=u[3],v=u[4],V=0;V<80;V++){if(V<16)s[V]=x[m+V]|0;else {var r=s[V-3]^s[V-8]^s[V-14]^s[V-16];s[V]=r<<1|r>>>31;}var a=(f<<5|f>>>27)+v+s[V];V<20?a+=(y&b|~y&c)+1518500249:V<40?a+=(y^b^c)+1859775393:V<60?a+=(y&b|y&c|b&c)-1894007588:a+=(y^b^c)-899497514,v=c,c=b,b=y<<30|y>>>2,y=f,f=a;}u[0]=u[0]+f|0,u[1]=u[1]+y|0,u[2]=u[2]+b|0,u[3]=u[3]+c|0,u[4]=u[4]+v|0;},_doFinalize:function(){var x=this._data,m=x.words,u=this._nDataBytes*8,f=x.sigBytes*8;return m[f>>>5]|=128<<24-f%32,m[(f+64>>>9<<4)+14]=Math.floor(u/4294967296),m[(f+64>>>9<<4)+15]=u,x.sigBytes=m.length*4,this._process(),this._hash},clone:function(){var x=o.clone.call(this);return x._hash=this._hash.clone(),x}});i.SHA1=o._createHelper(d),i.HmacSHA1=o._createHmacHelper(d);}(),t.SHA1});});var ie=ue($());var j="___param___";function de(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function p(t,i){if(!(Array.isArray(t)||!t)){if(t&&typeof t=="object"&&"type"in t)switch(t.type){case"resulttocombine":return pe(t,i);case"ifelse":return P(t.condition,i)?p(t.then,i):p(t.else,i);case"stepswitch":let e=p(t.elements,i)||[];if(e.length===0){console.error("[Pixi'VN] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let o=de(0,e.length);return p(e[o],i);case"loop":return narration.currentStepTimesCounter>e.length-1?(narration.currentStepTimesCounter=0,p(e[0],i)):p(e[NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)],i);case"sequential":let l;return t.end=="lastItem"&&(l=p(e[e.length-1],i)),narration.currentStepTimesCounter>e.length-1?l:p(e[NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)],i);case"sequentialrandom":let s=NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:t.nestedId,onceOnly:!0});if(s==null&&t.end=="lastItem"){let d=NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!d||!d?.usedRandomNumbers)return;let x=d.usedRandomNumbers[`0-${e.length-1}`];return p(e[x[x.length-1]],i)}return s==null?void 0:p(e[s],i)}}return t}}function pe(t,i){let n=t.firstItem,e=[];t.secondConditionalItem?.forEach(l=>{if(Array.isArray(l))l.forEach(s=>{let d=p(s,i);d&&e.push(d);});else {let s=p(l,i);s&&e.push(s);}});let o=n?[n,...e]:e;if(o.length!==0){if(typeof o[0]=="string")return o.join("");if(typeof o[0]=="object"){let l=o,s=l.map(c=>c.dialogue).join(""),d=l.find(c=>c.end),x=l.find(c=>c.choices),m=l.find(c=>c.glueEnabled),u=l.find(c=>c.goNextStep),f=l.find(c=>c.labelToOpen),y=l.find(c=>c.operation);return {dialogue:s,end:d?.end,choices:x?.choices,glueEnabled:m?.glueEnabled,goNextStep:u?.goNextStep,labelToOpen:f?.labelToOpen,operation:y?.operation}}}}function ge(t,i){if(!t)return !1;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case"compare":let n=w(t.leftValue,i),e=w(t.rightValue,i);switch(t.operator){case"==":return n===e;case"!=":return n!==e;case"<":return n<e;case"<=":return n<=e;case">":return n>e;case">=":return n>=e;case"CONTAINS":return n.toString().includes(e.toString())}break;case"valueCondition":return !!w(t.value,i);case"union":return he(t,i);case"labelcondition":if("operator"in t&&"label"in t)switch(t.operator){case"started":return narration.getTimesLabelOpened(t.label)>0;case"completed":return narration.isLabelAlreadyCompleted(t.label)}break}return !!t}function w(t,i){if(t&&typeof t=="object"&&"type"in t)if(t.type==="value"&&t.storageOperationType==="get")switch(t.storageType){case"storage":return storage.getVariable(t.key);case"tempstorage":return StorageManagerStatic.getTempVariable(t.key);case"flagStorage":return getFlag(t.key);case"label":return narration.getTimesLabelOpened(t.label);case"logic":return P(t.operation,i);case"params":return i&&i.length-1>=t.key?i[t.key]:void 0}else return P(t,i);return t}function he(t,i){if(t.unionType==="not")return !P(t.condition,i);let n=t.unionType==="and";for(let e=0;e<t.conditions.length;e++)if(n=P(t.conditions[e],i)||!1,t.unionType==="and"){if(!n)return !1}else if(n)return !0;return n}function H(t,i){let n=p(t.value,i),e;switch(n&&typeof n=="object"&&"type"in n?e=P(n,i):e=n,t.storageType){case"flagStorage":setFlag(t.key,t.value);break;case"storage":storage.setVariable(t.key,e);break;case"tempstorage":StorageManagerStatic.setTempVariable(t.key,e);break;case"params":i&&i.length-1>=t.key&&(i[t.key]=e);break}}function P(t,i){let n=p(t,i);if(n&&typeof n=="object"&&"type"in n)switch(n.type){case"value":return w(n,i);case"arithmetic":case"arithmeticsingle":return ye(n,i);case"compare":case"valueCondition":case"union":case"labelcondition":return ge(n,i)}return n}function ye(t,i){let n=P(t.leftValue,i);switch(t.type){case"arithmetic":let e=P(t.rightValue,i);switch(t.operator){case"*":return n*e;case"/":return n/e;case"+":return n+e;case"-":return n-e;case"%":return n%e;case"POW":return Math.pow(n,e);case"RANDOM":return Math.floor(Math.random()*(e-n+1))+n}case"arithmeticsingle":switch(t.operator){case"INT":return parseInt(n);case"FLOOR":return Math.floor(n);case"FLOAT":return parseFloat(n)}break}}var O=class extends LabelAbstract{constructor(i,n,e,o){super(i,e),this._steps=n,this.operationStringConvert=o;}_steps;get steps(){return this._steps.map(this.stepConverter)}operationStringConvert;getStepSha1(i){if(i<0||i>=this.steps.length)return;let n=this._steps[i];return (0, ie.default)(n.toString().toLocaleLowerCase()).toString()}getDialogueText(i,n){let e="";if(Array.isArray(i)){let o=[];i.forEach(l=>{if(typeof l=="string")o.push(l);else if(l&&typeof l=="object"){let s=p(l,n);s&&(s&&!Array.isArray(s)&&typeof s=="object"&&(s=w(s,n)||""),Array.isArray(s)?o=o.concat(s):o.push(s));}}),e=o;}else {let o=p(i,n)||"";o&&!Array.isArray(o)&&typeof o=="object"&&(o=w(o,n)||""),e=o;}return e}getDialogue(i,n){let e=p(i,n),o;return e&&(typeof e=="object"&&"character"in e&&"text"in e?o={character:e.character,text:this.getDialogueText(e.text,n)}:o=this.getDialogueText(e,n)),o}getChoices(i,n){let e=p(i,n);if(e)return e.map(l=>p(l,n)).filter(l=>l!==void 0)}stepConverter(i){return async n=>{let e=n[j];if(typeof i=="function"&&(i=i()),i.operation)for(let u of i.operation)await this.runOperation(u,e);let o=this.getChoices(i.choices,e),l=p(i.glueEnabled,e),s=this.getDialogue(i.dialogue,e),d=[];i.labelToOpen&&(Array.isArray(i.labelToOpen)||(i.labelToOpen=[i.labelToOpen]),i.labelToOpen.forEach(u=>{let f=p(u,e);f&&d.push(f);}));let x=p(i.goNextStep,e),m=p(i.end,e);if(o){let u=o.map(f=>{let y="";if(Array.isArray(f.text)){let b=[];f.text.forEach(c=>{if(typeof c=="string")b.push(c);else if(c&&typeof c=="object"){let v=p(c,e);v&&!Array.isArray(v)&&typeof v=="object"&&(v=w(v,e)||""),v&&(Array.isArray(v)?b=b.concat(v):b.push(v));}}),y=b.join();}else typeof f.text=="string"&&(y=f.text);return new ChoiceMenuOption(y,f.label,f.props,{type:f.type,oneTime:f.oneTime})});u=u.filter((f,y)=>{if(f.oneTime){let b=narration.alreadyCurrentStepMadeChoices;if(b&&b.includes(y))return !1}return !0}),narration.choiceMenuOptions=u;}else narration.choiceMenuOptions=void 0;l?setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):l===!1&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1),s&&(narration.dialogue=s),d.forEach(u=>{let f=u.label;typeof f=="object"&&(f=w(f,e)||"");let y=u.params?.map(b=>P(b,e));n={...n,...u.props,[j]:y},u.type==="jump"?narration.jumpLabel(f,n):narration.callLabel(f,n);}),x&&await narration.goNext(n),m==="game_end"?(narration.closeAllLabels(),await narration.goNext(n)):m==="label_end"&&narration.closeCurrentLabel();}}async runOperation(i,n){let e=p(i,n);if(e)switch(e.type){case"sound":switch(e.operationType){case"add":sound.add(e.alias,{...e.props,url:e.url});break;case"play":sound.play(e.alias,e.props);break;case"remove":sound.remove(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}break;case"image":switch(e.operationType){case"show":if(e.transition)switch(e.transition.type){case"fade":await showWithFadeTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"dissolve":await showWithDissolveTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await moveIn(e.alias,e.url,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(e.alias,e.url,e.transition.props,e.transition.priority);break}else await showImage(e.alias,e.url);break;case"edit":let o=canvas.find(e.alias);o?e.props&&(o.memory={...o.memory,...e.props}):console.error(`[Pixi'VN] Image with alias ${e.alias} not found.`);break;case"remove":canvas.remove(e.alias);break}break;case"video":switch(e.operationType){case"show":if(e.transition){let d=new CanvasVideo;switch(d.videoLink=e.url,e.transition.type){case"fade":await showWithFadeTransition(e.alias,d,e.transition.props,e.transition.priority);break;case"dissolve":await showWithDissolveTransition(e.alias,d,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await moveIn(e.alias,d,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(e.alias,d,e.transition.props,e.transition.priority);break}}else await showVideo(e.alias,e.url);break;case"edit":let o=canvas.find(e.alias);o?e.props&&(o.memory={...o.memory,...e.props}):console.error(`[Pixi'VN] Video with alias ${e.alias} not found.`);break;case"remove":canvas.remove(e.alias);break;case"pause":let l=canvas.find(e.alias);l?l.paused=!0:console.error(`[Pixi'VN] Video with alias ${e.alias} not found.`);break;case"resume":let s=canvas.find(e.alias);s?s.paused=!1:console.error(`[Pixi'VN] Video with alias ${e.alias} not found.`);break}break;case"value":H(e,n);break;case"oprationtoconvert":if(this.operationStringConvert){let o="";e.values.forEach(s=>{if(typeof s=="string")o+=s;else {let d=P(s,n);d&&(o+=`${d}`);}});let l=this.operationStringConvert(o);l&&await this.runOperation(l,n);}break;case"input":switch(e.operationType){case"request":narration.requestInput({type:e.valueType});break}break}}};function ve(t,i){try{typeof t=="string"&&(t=JSON.parse(t));}catch(n){console.error("[Pixi'VN] Error parsing imported Pixi'VN JSON",n);return}if(typeof t!="object"){console.error("[Pixi'VN] Error parsing imported Pixi'VN JSON: data is not an object");return}if(t.labels){let n=t.labels;for(let e in n)try{let o=n[e],l=new O(e,o,void 0,i);saveLabel(l);}catch(o){console.error(`[Pixi'VN] Error creating JSON label ${e}`,o);}}}
|
|
4
|
-
|
|
5
|
-
export { P as geLogichValue, w as getValue, p as getValueFromConditionalStatements, ve as importPixiVNJson, H as setStorageJson };
|
|
3
|
+
`+u),s=f(n.glueEnabled)||!1,u)}),h=f(c[0]),d=typeof h=="object"&&"character"in h?h.character:void 0,p=c.map(n=>{let a;n&&typeof n=="object"&&"text"in n?a=n.text:a=n;let u;return Array.isArray(a)?u=a.map(m=>{let T=f(m);return J.t(`${T}`)}).join(""):u=f(a)||"",J.t(u)}).join(""),l=o.find(n=>n.end),g=o.find(n=>n.choices),y=!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),y=o[o.length-1].glueEnabled,b=o.reverse().find(n=>!(n.operation&&(!n.dialogue||!n.choices)))?.goNextStep);let x=o.find(n=>n.labelToOpen),v=[];return o.forEach(n=>{n.operation&&v.forEach(a=>{v.push(a);});}),{dialogue:d?{character:d,text:p}:p,end:l?.end,choices:g?.choices,glueEnabled:y,goNextStep:b,labelToOpen:x?.labelToOpen,operation:v}}}function ye(t){if(!t)return !1;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case"compare":let i=f(t.leftValue),e=f(t.rightValue);switch(t.operator){case"==":return i===e;case"!=":return i!==e;case"<":return i<e;case"<=":return i<=e;case">":return i>e;case">=":return i>=e;case"CONTAINS":return i.toString().includes(e.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 i=storage.getVariable(`${_}${narration.openedLabels.length-1}`)||[];if(i&&i.length>t.key)return i[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 i=t.unionType==="and";for(let e=0;e<t.conditions.length;e++)if(i=f(t.conditions[e])||!1,t.unionType==="and"){if(!i)return !1}else if(i)return !0;return i}function M(t){let i=f(t.value),e;switch(i&&typeof i=="object"&&"type"in i?e=f(i):e=i,t.storageType){case"flagStorage":setFlag(t.key,t.value);break;case"storage":storage.setVariable(t.key,e);break;case"tempstorage":storage.setTempVariable(t.key,e);break;case"params":let r=storage.getVariable(`${_}${narration.openedLabels.length-1}`)||[];r&&r.length-1>=t.key&&(r[t.key]=e),storage.setTempVariable(`${_}${narration.openedLabels.length-1}`,r);break}}function f(t){let i=ge(t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return me(i);case"arithmetic":case"arithmeticsingle":return be(i);case"compare":case"valueCondition":case"union":return ye(i)}return i}function be(t){let i=f(t.leftValue);switch(t.type){case"arithmetic":let e=f(t.rightValue);switch(t.operator){case"*":return i*e;case"/":return i/e;case"+":return i+e;case"-":return i-e;case"%":return i%e;case"POW":return Math.pow(i,e);case"RANDOM":return narration.getRandomNumber(i,e)}case"arithmeticsingle":switch(t.operator){case"INT":return parseInt(i);case"FLOOR":return Math.floor(i);case"FLOAT":return parseFloat(i)}break}}async function L(t,i){let e=f(t);if(e)switch(e.type){case"sound":switch(e.operationType){case"add":sound.add(e.alias,{...e.props,url:e.url});break;case"play":sound.play(e.alias,e.props);break;case"remove":sound.remove(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}break;case"image":switch(e.operationType){case"show":if(e.transition)switch(e.transition.type){case"fade":await showWithFadeTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"dissolve":await showWithDissolveTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await moveIn(e.alias,e.url,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(e.alias,e.url,e.transition.props,e.transition.priority);break}else await showImage(e.alias,e.url);break;case"edit":let r=canvas.find(e.alias);r?e.props&&(r.memory={...r.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${e.alias} not found.`);break;case"remove":canvas.remove(e.alias);break}break;case"video":switch(e.operationType){case"show":if(e.transition){let c=new CanvasVideo;switch(c.videoLink=e.url,e.transition.type){case"fade":await showWithFadeTransition(e.alias,c,e.transition.props,e.transition.priority);break;case"dissolve":await showWithDissolveTransition(e.alias,c,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await moveIn(e.alias,c,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(e.alias,c,e.transition.props,e.transition.priority);break}}else await showVideo(e.alias,e.url);break;case"edit":let r=canvas.find(e.alias);r?e.props&&(r.memory={...r.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"remove":canvas.remove(e.alias);break;case"pause":let o=canvas.find(e.alias);o?o.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"resume":let s=canvas.find(e.alias);s?s.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break}break;case"value":M(e);break;case"oprationtoconvert":if(i){let r="";e.values.forEach(s=>{if(typeof s=="string")r+=s;else {let c=f(s);r+=`${c}`;}});let o=i(r);o&&await L(o);}break;case"input":switch(e.operationType){case"request":narration.requestInput({type:e.valueType});break}break}}var O=class extends LabelAbstract{constructor(i,e,r,o={}){super(i,r),this._steps=e,this.operationStringConvert=o.operationStringConvert,this.skipEmptyDialogs=o.skipEmptyDialogs||!1;}_steps;get steps(){return this._steps.map(i=>this.stepConverter(i))}operationStringConvert;skipEmptyDialogs=!1;getStepSha1(i){if(i<0||i>=this.steps.length)return;let e=this._steps[i];return (0, re.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(i){let e="";if(Array.isArray(i)){let r=[];i.forEach(o=>{if(typeof o=="string")r.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)?r=r.concat(s):r.push(`${s}`)):r.push(`${o}`);}}),e=r;}else {let r=f(i)||"";r&&!Array.isArray(r)&&typeof r=="object"&&(r=f(r)||""),e=r;}return `${e}`}getDialogue(i){let e=f(i);if(e)return typeof e=="object"&&"character"in e&&"text"in e?{character:e.character,text:J.t(this.getDialogueText(e.text))}:J.t(this.getDialogueText(e));if(e!=null)return `${e}`}getChoices(i){return f(i)?.map(o=>f(o)).filter(o=>o!==void 0)}stepConverter(i){return async e=>{if(typeof i=="function"&&(i=i()),i=B(i),i.operation)for(let p of i.operation)await L(p,this.operationStringConvert);let r=this.getChoices(i.choices),o=f(i.glueEnabled),s=this.getDialogue(i.dialogue),c=[];i.labelToOpen&&(Array.isArray(i.labelToOpen)||(i.labelToOpen=[i.labelToOpen]),i.labelToOpen.forEach(p=>{let l=f(p);l&&c.push(l);}));let h=f(i.goNextStep),d=f(i.end);if(r){let p=r.map(l=>{let g="";if(Array.isArray(l.text)){let y=[];l.text.forEach(b=>{if(typeof b=="string")y.push(J.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)?y=y.concat(J.t(x)):y.push(J.t(x)));}}),g=y.join();}else typeof l.text=="string"&&(g=J.t(l.text));return new ChoiceMenuOption(g,l.label,l.props,{type:l.type,oneTime:l.oneTime,onlyHaveNoChoice:l.onlyHaveNoChoice,autoSelect:l.autoSelect})});narration.choiceMenuOptions=p;}else narration.choiceMenuOptions=void 0;s!==void 0&&(narration.dialogue=s,this.skipEmptyDialogs&&typeof s=="string"&&(s===""||RegExp(/^\s+$/).test(s))&&(h=!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 p of c){let l=p.label;typeof l=="object"&&(l=f(l)||"");let g=p.params?.map(y=>f(y));e={...e,...p.props},p.type==="jump"?(narration.closeCurrentLabel(),storage.setTempVariable(`${_}${narration.openedLabels.length}`,g),await narration.callLabel(l,e)):(storage.setTempVariable(`${_}${narration.openedLabels.length}`,g),await narration.callLabel(l,e));}d==="game_end"?(narration.closeAllLabels(),await narration.goNext(e)):d==="label_end"&&narration.closeCurrentLabel(),h&&await narration.goNext(e);}}};function _e(t,i={}){let e=i?.operationStringConvert;try{typeof t=="string"&&(t=JSON.parse(t));}catch(r){console.error("[Pixi\u2019VN Json] Error parsing imported Pixi'VN JSON",r);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 r of t.initialOperations)L(r,e);StorageManagerStatic.saveStorageAsBasicStorage();}if(t.labels){let r=t.labels;for(let o in r)try{let s=r[o],c=new O(o,s,void 0,i);saveLabel(c);}catch(s){console.error(`[Pixi\u2019VN Json] Error creating JSON label ${o}`,s);}}}export{f as geLogichValue,_e as importPixiVNJson,M as setStorageJson};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var pixiVn=require('@drincs/pixi-vn');var J="___param___";var m=class n{static _translate=i=>i;static t(i){return Array.isArray(i)?i.map(e=>n._translate(`${e}`)):n._translate(`${i}`)}static set translate(i){n._translate=i;}addKey(i,e,t){let a=t.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(o=>{i[o]===void 0&&(a==="empty_string"?i[o]="":a==="copy_key"&&(i[o]=o));});}getConditionalsThenElse(i,e=[]){if(typeof i=="object"&&i&&"type"in i)if(i.type==="ifelse")i.then&&this.getConditionalsThenElse(i.then,e),i.else&&this.getConditionalsThenElse(i.else,e);else if(i.type==="stepswitch"){if(i.elements)if(Array.isArray(i.elements))i.elements.forEach(t=>{this.getConditionalsThenElse(t,e);});else if(i.elements.type==="ifelse"){let t=[];this.getConditionalsThenElse(i.elements,t),t.forEach(a=>{e.push(...a);});}else if(i.elements.type==="stepswitch"){let t=[];this.getConditionalsThenElse(i.elements,t),t.forEach(a=>{e.push(...a);});}else this.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&this.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(t=>{this.getConditionalsThenElse(t,e);})):e.push(i);else i&&e.push(i);return e}generateNewTranslateFile(i,e={},t={}){return i.forEach(a=>{if(a.choices){let o=[];Array.isArray(a.choices)?o=[a.choices]:o=this.getConditionalsThenElse(a.choices),o.forEach(r=>r.forEach(f=>{if("type"in f){let c=[];f.type==="ifelse"||f.type==="stepswitch"?this.getConditionalsThenElse(f,c):c=[f],c.map(p=>this.getConditionalsThenElse(p.text)).forEach(p=>{Array.isArray(p)&&p.forEach(h=>{Array.isArray(h)?h.forEach(V=>{typeof V=="string"?this.addKey(e,V,t):this.getConditionalsThenElse(V).forEach(T=>{Array.isArray(T)?T.forEach(P=>{typeof P=="string"&&this.addKey(e,P,t);}):typeof T=="string"&&this.addKey(e,T,t);});}):typeof h=="string"&&this.addKey(e,h,t);});});}}));}if(a.dialogue){let o=[];Array.isArray(a.dialogue)?o=[a.dialogue]:o=this.getConditionalsThenElse(a.dialogue),o.forEach(r=>{typeof r=="string"?this.addKey(e,r,t):"text"in r&&Array.isArray(r.text)&&r.text.forEach(f=>{typeof f=="string"?this.addKey(e,f,t):this.getConditionalsThenElse(f).forEach(d=>{typeof d=="string"?this.addKey(e,d,t):Array.isArray(d)&&d.forEach(p=>{typeof p=="string"?this.addKey(e,p,t):this.getConditionalsThenElse(p).forEach(h=>{typeof h=="string"&&this.addKey(e,h,t);});});});});});}a.conditionalStep&&this.getConditionalsThenElse(a.conditionalStep).forEach(r=>{Array.isArray(r)?this.generateNewTranslateFile(r,e,t):this.generateNewTranslateFile([r],e,t);});}),e}};function G(n,i){return Math.floor(Math.random()*(i-n+1)+n)}function F(n){if(Array.isArray(n)||!n)return n;if(n&&typeof n=="object"&&"type"in n)switch(n.type){case"resulttocombine":return $(n);case"ifelse":return s(n.condition)?s(n.then):s(n.else);case"stepswitch":let e=s(n.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(n.choiceType){case"random":let t=G(0,e.length-1);return s(e[t]);case"loop":let a=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(n.nestedId)-1;return a>e.length-1&&(a=a%e.length),s(e[a]);case"sequential":let o,r=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(n.nestedId)-1;return n.end=="lastItem"&&(o=s(e[e.length-1])),r>e.length-1?o:s(e[r]);case"sequentialrandom":let f=pixiVn.NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:n.nestedId,onceOnly:!0});if(f==null&&n.end=="lastItem"){let c=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(n.nestedId);if(!c||!c?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let d=c.usedRandomNumbers[`0-${e.length-1}`];return s(e[d[d.length-1]])}if(f==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return s(e[f])}}return n}function A(n){if(n.conditionalStep){let i=pixiVn.createExportableElement(s(n.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={...n,conditionalStep:void 0,...i};return A(e)}else pixiVn.getFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return n}function $(n){let i=n.firstItem,e=[];n.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(o=>{let r=s(o);e.push(r);});else {let o=s(a);e.push(o);}});let t=i?[i,...e]:e;if(t.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof t[0]=="string")return m.t(t).join("");if(typeof t[0]=="object"){let a=t,o,r=a.map((l,y)=>{l=A(l);let u=s(l.dialogue)||"";return y===0?(o=s(l.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),o===!1&&(u=`
|
|
2
|
+
|
|
3
|
+
`+u),o=s(l.glueEnabled)||!1,u)}),f=s(r[0]),c=typeof f=="object"&&"character"in f?f.character:void 0,d=r.map(l=>{let y;l&&typeof l=="object"&&"text"in l?y=l.text:y=l;let u;return Array.isArray(y)?u=y.map(L=>{let R=s(L);return m.t(`${R}`)}).join(""):u=s(y)||"",m.t(u)}).join(""),p=a.find(l=>l.end),h=a.find(l=>l.choices),V=!1,T=!1;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),V=a[a.length-1].glueEnabled,T=a.reverse().find(l=>!(l.operation&&(!l.dialogue||!l.choices)))?.goNextStep);let P=a.find(l=>l.labelToOpen),C=[];return a.forEach(l=>{l.operation&&C.forEach(y=>{C.push(y);});}),{dialogue:c?{character:c,text:d}:d,end:p?.end,choices:h?.choices,glueEnabled:V,goNextStep:T,labelToOpen:P?.labelToOpen,operation:C}}}function K(n){if(!n)return !1;if(typeof n!="object"||!("type"in n))return !!n;switch(n.type){case"compare":let i=s(n.leftValue),e=s(n.rightValue);switch(n.operator){case"==":return i===e;case"!=":return i!==e;case"<":return i<e;case"<=":return i<=e;case">":return i>e;case">=":return i>=e;case"CONTAINS":return i.toString().includes(e.toString())}break;case"valueCondition":return !!s(n.value);case"union":return X(n)}return !!n}function M(n){if(n&&typeof n=="object"&&"type"in n&&n.type==="value"&&n.storageOperationType==="get")switch(n.storageType){case"storage":case"tempstorage":return pixiVn.storage.getVariable(n.key);case"flagStorage":return pixiVn.getFlag(n.key);case"label":return pixiVn.narration.getTimesLabelOpened(n.label);case"choice":return pixiVn.narration.getTimesChoiceMade(n.index);case"logic":return s(n.operation);case"params":let i=pixiVn.storage.getVariable(`${J}${pixiVn.narration.openedLabels.length-1}`)||[];if(i&&i.length>n.key)return i[n.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return n}function X(n){if(n.unionType==="not")return !s(n.condition);let i=n.unionType==="and";for(let e=0;e<n.conditions.length;e++)if(i=s(n.conditions[e])||!1,n.unionType==="and"){if(!i)return !1}else if(i)return !0;return i}function k(n){let i=s(n.value),e;switch(i&&typeof i=="object"&&"type"in i?e=s(i):e=i,n.storageType){case"flagStorage":pixiVn.setFlag(n.key,n.value);break;case"storage":pixiVn.storage.setVariable(n.key,e);break;case"tempstorage":pixiVn.storage.setTempVariable(n.key,e);break;case"params":let t=pixiVn.storage.getVariable(`${J}${pixiVn.narration.openedLabels.length-1}`)||[];t&&t.length-1>=n.key&&(t[n.key]=e),pixiVn.storage.setTempVariable(`${J}${pixiVn.narration.openedLabels.length-1}`,t);break}}function s(n){let i=F(n);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return M(i);case"arithmetic":case"arithmeticsingle":return U(i);case"compare":case"valueCondition":case"union":return K(i)}return i}function U(n){let i=s(n.leftValue);switch(n.type){case"arithmetic":let e=s(n.rightValue);switch(n.operator){case"*":return i*e;case"/":return i/e;case"+":return i+e;case"-":return i-e;case"%":return i%e;case"POW":return Math.pow(i,e);case"RANDOM":return pixiVn.narration.getRandomNumber(i,e)}case"arithmeticsingle":switch(n.operator){case"INT":return parseInt(i);case"FLOOR":return Math.floor(i);case"FLOAT":return parseFloat(i)}break}}async function H(n,i){let e=s(n);if(e)switch(e.type){case"sound":switch(e.operationType){case"add":pixiVn.sound.add(e.alias,{...e.props,url:e.url});break;case"play":pixiVn.sound.play(e.alias,e.props);break;case"remove":pixiVn.sound.remove(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}break;case"image":switch(e.operationType){case"show":if(e.transition)switch(e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,e.url,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,e.url,e.transition.props,e.transition.priority);break}else await pixiVn.showImage(e.alias,e.url);break;case"edit":let t=pixiVn.canvas.find(e.alias);t?e.props&&(t.memory={...t.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${e.alias} not found.`);break;case"remove":pixiVn.canvas.remove(e.alias);break}break;case"video":switch(e.operationType){case"show":if(e.transition){let r=new pixiVn.CanvasVideo;switch(r.videoLink=e.url,e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,r,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,r,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,r,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,r,e.transition.props,e.transition.priority);break}}else await pixiVn.showVideo(e.alias,e.url);break;case"edit":let t=pixiVn.canvas.find(e.alias);t?e.props&&(t.memory={...t.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"remove":pixiVn.canvas.remove(e.alias);break;case"pause":let a=pixiVn.canvas.find(e.alias);a?a.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"resume":let o=pixiVn.canvas.find(e.alias);o?o.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break}break;case"value":k(e);break;case"oprationtoconvert":if(i){let t="";e.values.forEach(o=>{if(typeof o=="string")t+=o;else {let r=s(o);t+=`${r}`;}});let a=i(t);a&&await H(a);}break;case"input":switch(e.operationType){case"request":pixiVn.narration.requestInput({type:e.valueType});break}break}}exports.runOperation=H;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { e as PixiVNJsonIfElse } from '../PixiVNJsonConditionalStatements-CVkQSKpq.cjs';
|
|
2
|
+
import { PixiVNJsonOperation, PixiVNJsonOperationString } from '../interface/PixiVNJsonOperations.cjs';
|
|
3
|
+
import '@drincs/pixi-vn';
|
|
4
|
+
import '../interface/PixiVNJsonInput.cjs';
|
|
5
|
+
import '../interface/PixiVNJsonMedia.cjs';
|
|
6
|
+
import '../interface/PixiVNJsonMediaTransiotions.cjs';
|
|
7
|
+
import 'pixi.js';
|
|
8
|
+
|
|
9
|
+
declare function runOperation(origin: PixiVNJsonOperation | PixiVNJsonIfElse<PixiVNJsonOperation> | PixiVNJsonOperationString, operationStringConvert?: (value: string) => PixiVNJsonOperation | undefined): Promise<void>;
|
|
10
|
+
|
|
11
|
+
export { runOperation };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { e as PixiVNJsonIfElse } from '../PixiVNJsonConditionalStatements-CVkQSKpq.js';
|
|
2
|
+
import { PixiVNJsonOperation, PixiVNJsonOperationString } from '../interface/PixiVNJsonOperations.js';
|
|
3
|
+
import '@drincs/pixi-vn';
|
|
4
|
+
import '../interface/PixiVNJsonInput.js';
|
|
5
|
+
import '../interface/PixiVNJsonMedia.js';
|
|
6
|
+
import '../interface/PixiVNJsonMediaTransiotions.js';
|
|
7
|
+
import 'pixi.js';
|
|
8
|
+
|
|
9
|
+
declare function runOperation(origin: PixiVNJsonOperation | PixiVNJsonIfElse<PixiVNJsonOperation> | PixiVNJsonOperationString, operationStringConvert?: (value: string) => PixiVNJsonOperation | undefined): Promise<void>;
|
|
10
|
+
|
|
11
|
+
export { runOperation };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {narration,canvas,CanvasVideo,zoomIn,moveIn,showWithDissolveTransition,showWithFadeTransition,showVideo,showImage,sound,storage,setFlag,NarrationManagerStatic,getFlag,createExportableElement}from'@drincs/pixi-vn';var J="___param___";var m=class n{static _translate=i=>i;static t(i){return Array.isArray(i)?i.map(e=>n._translate(`${e}`)):n._translate(`${i}`)}static set translate(i){n._translate=i;}addKey(i,e,t){let a=t.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(o=>{i[o]===void 0&&(a==="empty_string"?i[o]="":a==="copy_key"&&(i[o]=o));});}getConditionalsThenElse(i,e=[]){if(typeof i=="object"&&i&&"type"in i)if(i.type==="ifelse")i.then&&this.getConditionalsThenElse(i.then,e),i.else&&this.getConditionalsThenElse(i.else,e);else if(i.type==="stepswitch"){if(i.elements)if(Array.isArray(i.elements))i.elements.forEach(t=>{this.getConditionalsThenElse(t,e);});else if(i.elements.type==="ifelse"){let t=[];this.getConditionalsThenElse(i.elements,t),t.forEach(a=>{e.push(...a);});}else if(i.elements.type==="stepswitch"){let t=[];this.getConditionalsThenElse(i.elements,t),t.forEach(a=>{e.push(...a);});}else this.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&this.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(t=>{this.getConditionalsThenElse(t,e);})):e.push(i);else i&&e.push(i);return e}generateNewTranslateFile(i,e={},t={}){return i.forEach(a=>{if(a.choices){let o=[];Array.isArray(a.choices)?o=[a.choices]:o=this.getConditionalsThenElse(a.choices),o.forEach(r=>r.forEach(f=>{if("type"in f){let c=[];f.type==="ifelse"||f.type==="stepswitch"?this.getConditionalsThenElse(f,c):c=[f],c.map(p=>this.getConditionalsThenElse(p.text)).forEach(p=>{Array.isArray(p)&&p.forEach(h=>{Array.isArray(h)?h.forEach(V=>{typeof V=="string"?this.addKey(e,V,t):this.getConditionalsThenElse(V).forEach(T=>{Array.isArray(T)?T.forEach(P=>{typeof P=="string"&&this.addKey(e,P,t);}):typeof T=="string"&&this.addKey(e,T,t);});}):typeof h=="string"&&this.addKey(e,h,t);});});}}));}if(a.dialogue){let o=[];Array.isArray(a.dialogue)?o=[a.dialogue]:o=this.getConditionalsThenElse(a.dialogue),o.forEach(r=>{typeof r=="string"?this.addKey(e,r,t):"text"in r&&Array.isArray(r.text)&&r.text.forEach(f=>{typeof f=="string"?this.addKey(e,f,t):this.getConditionalsThenElse(f).forEach(d=>{typeof d=="string"?this.addKey(e,d,t):Array.isArray(d)&&d.forEach(p=>{typeof p=="string"?this.addKey(e,p,t):this.getConditionalsThenElse(p).forEach(h=>{typeof h=="string"&&this.addKey(e,h,t);});});});});});}a.conditionalStep&&this.getConditionalsThenElse(a.conditionalStep).forEach(r=>{Array.isArray(r)?this.generateNewTranslateFile(r,e,t):this.generateNewTranslateFile([r],e,t);});}),e}};function G(n,i){return Math.floor(Math.random()*(i-n+1)+n)}function F(n){if(Array.isArray(n)||!n)return n;if(n&&typeof n=="object"&&"type"in n)switch(n.type){case"resulttocombine":return $(n);case"ifelse":return s(n.condition)?s(n.then):s(n.else);case"stepswitch":let e=s(n.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(n.choiceType){case"random":let t=G(0,e.length-1);return s(e[t]);case"loop":let a=NarrationManagerStatic.getCurrentStepTimesCounter(n.nestedId)-1;return a>e.length-1&&(a=a%e.length),s(e[a]);case"sequential":let o,r=NarrationManagerStatic.getCurrentStepTimesCounter(n.nestedId)-1;return n.end=="lastItem"&&(o=s(e[e.length-1])),r>e.length-1?o:s(e[r]);case"sequentialrandom":let f=NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:n.nestedId,onceOnly:!0});if(f==null&&n.end=="lastItem"){let c=NarrationManagerStatic.getCurrentStepTimesCounterData(n.nestedId);if(!c||!c?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let d=c.usedRandomNumbers[`0-${e.length-1}`];return s(e[d[d.length-1]])}if(f==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return s(e[f])}}return n}function A(n){if(n.conditionalStep){let i=createExportableElement(s(n.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={...n,conditionalStep:void 0,...i};return A(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 n}function $(n){let i=n.firstItem,e=[];n.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(o=>{let r=s(o);e.push(r);});else {let o=s(a);e.push(o);}});let t=i?[i,...e]:e;if(t.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof t[0]=="string")return m.t(t).join("");if(typeof t[0]=="object"){let a=t,o,r=a.map((l,y)=>{l=A(l);let u=s(l.dialogue)||"";return y===0?(o=s(l.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),o===!1&&(u=`
|
|
2
|
+
|
|
3
|
+
`+u),o=s(l.glueEnabled)||!1,u)}),f=s(r[0]),c=typeof f=="object"&&"character"in f?f.character:void 0,d=r.map(l=>{let y;l&&typeof l=="object"&&"text"in l?y=l.text:y=l;let u;return Array.isArray(y)?u=y.map(L=>{let R=s(L);return m.t(`${R}`)}).join(""):u=s(y)||"",m.t(u)}).join(""),p=a.find(l=>l.end),h=a.find(l=>l.choices),V=!1,T=!1;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),V=a[a.length-1].glueEnabled,T=a.reverse().find(l=>!(l.operation&&(!l.dialogue||!l.choices)))?.goNextStep);let P=a.find(l=>l.labelToOpen),C=[];return a.forEach(l=>{l.operation&&C.forEach(y=>{C.push(y);});}),{dialogue:c?{character:c,text:d}:d,end:p?.end,choices:h?.choices,glueEnabled:V,goNextStep:T,labelToOpen:P?.labelToOpen,operation:C}}}function K(n){if(!n)return !1;if(typeof n!="object"||!("type"in n))return !!n;switch(n.type){case"compare":let i=s(n.leftValue),e=s(n.rightValue);switch(n.operator){case"==":return i===e;case"!=":return i!==e;case"<":return i<e;case"<=":return i<=e;case">":return i>e;case">=":return i>=e;case"CONTAINS":return i.toString().includes(e.toString())}break;case"valueCondition":return !!s(n.value);case"union":return X(n)}return !!n}function M(n){if(n&&typeof n=="object"&&"type"in n&&n.type==="value"&&n.storageOperationType==="get")switch(n.storageType){case"storage":case"tempstorage":return storage.getVariable(n.key);case"flagStorage":return getFlag(n.key);case"label":return narration.getTimesLabelOpened(n.label);case"choice":return narration.getTimesChoiceMade(n.index);case"logic":return s(n.operation);case"params":let i=storage.getVariable(`${J}${narration.openedLabels.length-1}`)||[];if(i&&i.length>n.key)return i[n.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return n}function X(n){if(n.unionType==="not")return !s(n.condition);let i=n.unionType==="and";for(let e=0;e<n.conditions.length;e++)if(i=s(n.conditions[e])||!1,n.unionType==="and"){if(!i)return !1}else if(i)return !0;return i}function k(n){let i=s(n.value),e;switch(i&&typeof i=="object"&&"type"in i?e=s(i):e=i,n.storageType){case"flagStorage":setFlag(n.key,n.value);break;case"storage":storage.setVariable(n.key,e);break;case"tempstorage":storage.setTempVariable(n.key,e);break;case"params":let t=storage.getVariable(`${J}${narration.openedLabels.length-1}`)||[];t&&t.length-1>=n.key&&(t[n.key]=e),storage.setTempVariable(`${J}${narration.openedLabels.length-1}`,t);break}}function s(n){let i=F(n);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return M(i);case"arithmetic":case"arithmeticsingle":return U(i);case"compare":case"valueCondition":case"union":return K(i)}return i}function U(n){let i=s(n.leftValue);switch(n.type){case"arithmetic":let e=s(n.rightValue);switch(n.operator){case"*":return i*e;case"/":return i/e;case"+":return i+e;case"-":return i-e;case"%":return i%e;case"POW":return Math.pow(i,e);case"RANDOM":return narration.getRandomNumber(i,e)}case"arithmeticsingle":switch(n.operator){case"INT":return parseInt(i);case"FLOOR":return Math.floor(i);case"FLOAT":return parseFloat(i)}break}}async function H(n,i){let e=s(n);if(e)switch(e.type){case"sound":switch(e.operationType){case"add":sound.add(e.alias,{...e.props,url:e.url});break;case"play":sound.play(e.alias,e.props);break;case"remove":sound.remove(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}break;case"image":switch(e.operationType){case"show":if(e.transition)switch(e.transition.type){case"fade":await showWithFadeTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"dissolve":await showWithDissolveTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await moveIn(e.alias,e.url,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(e.alias,e.url,e.transition.props,e.transition.priority);break}else await showImage(e.alias,e.url);break;case"edit":let t=canvas.find(e.alias);t?e.props&&(t.memory={...t.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${e.alias} not found.`);break;case"remove":canvas.remove(e.alias);break}break;case"video":switch(e.operationType){case"show":if(e.transition){let r=new CanvasVideo;switch(r.videoLink=e.url,e.transition.type){case"fade":await showWithFadeTransition(e.alias,r,e.transition.props,e.transition.priority);break;case"dissolve":await showWithDissolveTransition(e.alias,r,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await moveIn(e.alias,r,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(e.alias,r,e.transition.props,e.transition.priority);break}}else await showVideo(e.alias,e.url);break;case"edit":let t=canvas.find(e.alias);t?e.props&&(t.memory={...t.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"remove":canvas.remove(e.alias);break;case"pause":let a=canvas.find(e.alias);a?a.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"resume":let o=canvas.find(e.alias);o?o.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break}break;case"value":k(e);break;case"oprationtoconvert":if(i){let t="";e.values.forEach(o=>{if(typeof o=="string")t+=o;else {let r=s(o);t+=`${r}`;}});let a=i(t);a&&await H(a);}break;case"input":switch(e.operationType){case"request":narration.requestInput({type:e.valueType});break}break}}export{H as runOperation};
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
'use strict';var pixiVn=require('@drincs/pixi-vn');var b="___param___";var p=class n{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(i=>n._translate(`${i}`)):n._translate(`${e}`)}static set translate(e){n._translate=e;}addKey(e,i,s){let t=s.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(o=>{e[o]===void 0&&(t==="empty_string"?e[o]="":t==="copy_key"&&(e[o]=o));});}getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&this.getConditionalsThenElse(e.then,i),e.else&&this.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(s=>{this.getConditionalsThenElse(s,i);});else if(e.elements.type==="ifelse"){let s=[];this.getConditionalsThenElse(e.elements,s),s.forEach(t=>{i.push(...t);});}else if(e.elements.type==="stepswitch"){let s=[];this.getConditionalsThenElse(e.elements,s),s.forEach(t=>{i.push(...t);});}else this.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&this.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(s=>{this.getConditionalsThenElse(s,i);})):i.push(e);else e&&i.push(e);return i}generateNewTranslateFile(e,i={},s={}){return e.forEach(t=>{if(t.choices){let o=[];Array.isArray(t.choices)?o=[t.choices]:o=this.getConditionalsThenElse(t.choices),o.forEach(l=>l.forEach(f=>{if("type"in f){let d=[];f.type==="ifelse"||f.type==="stepswitch"?this.getConditionalsThenElse(f,d):d=[f],d.map(g=>this.getConditionalsThenElse(g.text)).forEach(g=>{Array.isArray(g)&&g.forEach(h=>{Array.isArray(h)?h.forEach(x=>{typeof x=="string"?this.addKey(i,x,s):this.getConditionalsThenElse(x).forEach(m=>{Array.isArray(m)?m.forEach(N=>{typeof N=="string"&&this.addKey(i,N,s);}):typeof m=="string"&&this.addKey(i,m,s);});}):typeof h=="string"&&this.addKey(i,h,s);});});}}));}if(t.dialogue){let o=[];Array.isArray(t.dialogue)?o=[t.dialogue]:o=this.getConditionalsThenElse(t.dialogue),o.forEach(l=>{typeof l=="string"?this.addKey(i,l,s):"text"in l&&Array.isArray(l.text)&&l.text.forEach(f=>{typeof f=="string"?this.addKey(i,f,s):this.getConditionalsThenElse(f).forEach(c=>{typeof c=="string"?this.addKey(i,c,s):Array.isArray(c)&&c.forEach(g=>{typeof g=="string"?this.addKey(i,g,s):this.getConditionalsThenElse(g).forEach(h=>{typeof h=="string"&&this.addKey(i,h,s);});});});});});}t.conditionalStep&&this.getConditionalsThenElse(t.conditionalStep).forEach(l=>{Array.isArray(l)?this.generateNewTranslateFile(l,i,s):this.generateNewTranslateFile([l],i,s);});}),i}};function O(n,e){return Math.floor(Math.random()*(e-n+1)+n)}function w(n){if(Array.isArray(n)||!n)return n;if(n&&typeof n=="object"&&"type"in n)switch(n.type){case"resulttocombine":return D(n);case"ifelse":return a(n.condition)?a(n.then):a(n.else);case"stepswitch":let i=a(n.elements)||[];if(i.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(n.choiceType){case"random":let s=O(0,i.length-1);return a(i[s]);case"loop":let t=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(n.nestedId)-1;return t>i.length-1&&(t=t%i.length),a(i[t]);case"sequential":let o,l=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(n.nestedId)-1;return n.end=="lastItem"&&(o=a(i[i.length-1])),l>i.length-1?o:a(i[l]);case"sequentialrandom":let f=pixiVn.NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:n.nestedId,onceOnly:!0});if(f==null&&n.end=="lastItem"){let d=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(n.nestedId);if(!d||!d?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let c=d.usedRandomNumbers[`0-${i.length-1}`];return a(i[c[c.length-1]])}if(f==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return a(i[f])}}return n}function S(n){if(n.conditionalStep){let e=pixiVn.createExportableElement(a(n.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 i={...n,conditionalStep:void 0,...e};return S(i)}else pixiVn.getFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return n}function D(n){let e=n.firstItem,i=[];n.secondConditionalItem?.forEach(t=>{if(Array.isArray(t))t.forEach(o=>{let l=a(o);i.push(l);});else {let o=a(t);i.push(o);}});let s=e?[e,...i]:i;if(s.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof s[0]=="string")return p.t(s).join("");if(typeof s[0]=="object"){let t=s,o,l=t.map((r,y)=>{r=S(r);let u=a(r.dialogue)||"";return y===0?(o=a(r.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),o===!1&&(u=`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function m(e,n){return Math.floor(Math.random()*(n-e+1)+e)}function o(e,n){if(!(Array.isArray(e)||!e)){if(e&&typeof e=="object"&&"type"in e)switch(e.type){case"resulttocombine":return J(e,n);case"ifelse":return u(e.condition,n)?o(e.then,n):o(e.else,n);case"stepswitch":let t=o(e.elements,n)||[];if(t.length===0){console.error("[Pixi'VN] getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case"random":let c=m(0,t.length);return o(t[c],n);case"loop":return pixiVn.narration.currentStepTimesCounter>t.length-1?(pixiVn.narration.currentStepTimesCounter=0,o(t[0],n)):o(t[pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)],n);case"sequential":let r;return e.end=="lastItem"&&(r=o(t[t.length-1],n)),pixiVn.narration.currentStepTimesCounter>t.length-1?r:o(t[pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)],n);case"sequentialrandom":let s=pixiVn.NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:e.nestedId,onceOnly:!0});if(s==null&&e.end=="lastItem"){let l=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!l||!l?.usedRandomNumbers)return;let d=l.usedRandomNumbers[`0-${t.length-1}`];return o(t[d[d.length-1]],n)}return s==null?void 0:o(t[s],n)}}return e}}function J(e,n){let i=e.firstItem,t=[];e.secondConditionalItem?.forEach(r=>{if(Array.isArray(r))r.forEach(s=>{let l=o(s,n);l&&t.push(l);});else {let s=o(r,n);s&&t.push(s);}});let c=i?[i,...t]:t;if(c.length!==0){if(typeof c[0]=="string")return c.join("");if(typeof c[0]=="object"){let r=c,s=r.map(a=>a.dialogue).join(""),l=r.find(a=>a.end),d=r.find(a=>a.choices),V=r.find(a=>a.glueEnabled),b=r.find(a=>a.goNextStep),h=r.find(a=>a.labelToOpen),N=r.find(a=>a.operation);return {dialogue:s,end:l?.end,choices:d?.choices,glueEnabled:V?.glueEnabled,goNextStep:b?.goNextStep,labelToOpen:h?.labelToOpen,operation:N?.operation}}}}function S(e,n){if(!e)return !1;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case"compare":let i=T(e.leftValue,n),t=T(e.rightValue,n);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 !!T(e.value,n);case"union":return C(e,n);case"labelcondition":if("operator"in e&&"label"in e)switch(e.operator){case"started":return pixiVn.narration.getTimesLabelOpened(e.label)>0;case"completed":return pixiVn.narration.isLabelAlreadyCompleted(e.label)}break}return !!e}function T(e,n){if(e&&typeof e=="object"&&"type"in e)if(e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case"storage":return pixiVn.storage.getVariable(e.key);case"tempstorage":return pixiVn.StorageManagerStatic.getTempVariable(e.key);case"flagStorage":return pixiVn.getFlag(e.key);case"label":return pixiVn.narration.getTimesLabelOpened(e.label);case"logic":return u(e.operation,n);case"params":return n&&n.length-1>=e.key?n[e.key]:void 0}else return u(e,n);return e}function C(e,n){if(e.unionType==="not")return !u(e.condition,n);let i=e.unionType==="and";for(let t=0;t<e.conditions.length;t++)if(i=u(e.conditions[t],n)||!1,e.unionType==="and"){if(!i)return !1}else if(i)return !0;return i}function A(e,n){let i=o(e.value,n),t;switch(i&&typeof i=="object"&&"type"in i?t=u(i,n):t=i,e.storageType){case"flagStorage":pixiVn.setFlag(e.key,e.value);break;case"storage":pixiVn.storage.setVariable(e.key,t);break;case"tempstorage":pixiVn.StorageManagerStatic.setTempVariable(e.key,t);break;case"params":n&&n.length-1>=e.key&&(n[e.key]=t);break}}function u(e,n){let i=o(e,n);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return T(i,n);case"arithmetic":case"arithmeticsingle":return k(i,n);case"compare":case"valueCondition":case"union":case"labelcondition":return S(i,n)}return i}function k(e,n){let i=u(e.leftValue,n);switch(e.type){case"arithmetic":let t=u(e.rightValue,n);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 Math.floor(Math.random()*(t-i+1))+i}case"arithmeticsingle":switch(e.operator){case"INT":return parseInt(i);case"FLOOR":return Math.floor(i);case"FLOAT":return parseFloat(i)}break}}
|
|
6
|
-
|
|
7
|
-
exports.geLogichValue = u;
|
|
8
|
-
exports.getValue = T;
|
|
9
|
-
exports.getValueFromConditionalStatements = o;
|
|
10
|
-
exports.setStorageJson = A;
|
|
3
|
+
`+u),o=a(r.glueEnabled)||!1,u)}),f=a(l[0]),d=typeof f=="object"&&"character"in f?f.character:void 0,c=l.map(r=>{let y;r&&typeof r=="object"&&"text"in r?y=r.text:y=r;let u;return Array.isArray(y)?u=y.map(A=>{let _=a(A);return p.t(`${_}`)}).join(""):u=a(y)||"",p.t(u)}).join(""),g=t.find(r=>r.end),h=t.find(r=>r.choices),x=!1,m=!1;t.length>0&&(t[0].glueEnabled&&t[0].goNextStep&&t[0].dialogue===void 0&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),x=t[t.length-1].glueEnabled,m=t.reverse().find(r=>!(r.operation&&(!r.dialogue||!r.choices)))?.goNextStep);let N=t.find(r=>r.labelToOpen),E=[];return t.forEach(r=>{r.operation&&E.forEach(y=>{E.push(y);});}),{dialogue:d?{character:d,text:c}:c,end:g?.end,choices:h?.choices,glueEnabled:x,goNextStep:m,labelToOpen:N?.labelToOpen,operation:E}}}function L(n){if(!n)return !1;if(typeof n!="object"||!("type"in n))return !!n;switch(n.type){case"compare":let e=a(n.leftValue),i=a(n.rightValue);switch(n.operator){case"==":return e===i;case"!=":return e!==i;case"<":return e<i;case"<=":return e<=i;case">":return e>i;case">=":return e>=i;case"CONTAINS":return e.toString().includes(i.toString())}break;case"valueCondition":return !!a(n.value);case"union":return G(n)}return !!n}function R(n){if(n&&typeof n=="object"&&"type"in n&&n.type==="value"&&n.storageOperationType==="get")switch(n.storageType){case"storage":case"tempstorage":return pixiVn.storage.getVariable(n.key);case"flagStorage":return pixiVn.getFlag(n.key);case"label":return pixiVn.narration.getTimesLabelOpened(n.label);case"choice":return pixiVn.narration.getTimesChoiceMade(n.index);case"logic":return a(n.operation);case"params":let e=pixiVn.storage.getVariable(`${b}${pixiVn.narration.openedLabels.length-1}`)||[];if(e&&e.length>n.key)return e[n.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return n}function G(n){if(n.unionType==="not")return !a(n.condition);let e=n.unionType==="and";for(let i=0;i<n.conditions.length;i++)if(e=a(n.conditions[i])||!1,n.unionType==="and"){if(!e)return !1}else if(e)return !0;return e}function Y(n){let e=a(n.value),i;switch(e&&typeof e=="object"&&"type"in e?i=a(e):i=e,n.storageType){case"flagStorage":pixiVn.setFlag(n.key,n.value);break;case"storage":pixiVn.storage.setVariable(n.key,i);break;case"tempstorage":pixiVn.storage.setTempVariable(n.key,i);break;case"params":let s=pixiVn.storage.getVariable(`${b}${pixiVn.narration.openedLabels.length-1}`)||[];s&&s.length-1>=n.key&&(s[n.key]=i),pixiVn.storage.setTempVariable(`${b}${pixiVn.narration.openedLabels.length-1}`,s);break}}function a(n){let e=w(n);if(e&&typeof e=="object"&&"type"in e)switch(e.type){case"value":return R(e);case"arithmetic":case"arithmeticsingle":return k(e);case"compare":case"valueCondition":case"union":return L(e)}return e}function k(n){let e=a(n.leftValue);switch(n.type){case"arithmetic":let i=a(n.rightValue);switch(n.operator){case"*":return e*i;case"/":return e/i;case"+":return e+i;case"-":return e-i;case"%":return e%i;case"POW":return Math.pow(e,i);case"RANDOM":return pixiVn.narration.getRandomNumber(e,i)}case"arithmeticsingle":switch(n.operator){case"INT":return parseInt(e);case"FLOOR":return Math.floor(e);case"FLOAT":return parseFloat(e)}break}}exports.getConditionalStep=S;exports.getLogichValue=a;exports.setStorageJson=Y;
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import { StorageElementType } from '@drincs/pixi-vn';
|
|
2
|
-
import
|
|
3
|
-
import '../
|
|
2
|
+
import PixiVNJsonLabelStep from '../interface/PixiVNJsonLabelStep.cjs';
|
|
3
|
+
import { p as PixiVNJsonValueSet, o as PixiVNJsonValueGet, P as PixiVNJsonArithmeticOperations, d as PixiVNJsonConditions, b as PixiVNJsonConditionalStatements } from '../PixiVNJsonConditionalStatements-CVkQSKpq.cjs';
|
|
4
|
+
import '../interface/PixiVNJsonOperations.cjs';
|
|
5
|
+
import '../interface/PixiVNJsonInput.cjs';
|
|
6
|
+
import '../interface/PixiVNJsonMedia.cjs';
|
|
7
|
+
import '../interface/PixiVNJsonMediaTransiotions.cjs';
|
|
8
|
+
import 'pixi.js';
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* @returns the value from the conditional statements
|
|
9
|
-
*/
|
|
10
|
-
declare function getValueFromConditionalStatements<T>(statement: PixiVNJsonConditionalResultToCombine<T> | PixiVNJsonConditionalStatements<T> | T | undefined, params: any[]): T | undefined;
|
|
11
|
-
/**
|
|
12
|
-
* Get the value from the storage or the value.
|
|
13
|
-
* @param value is the value to get
|
|
14
|
-
* @returns the value from the storage or the value
|
|
15
|
-
*/
|
|
16
|
-
declare function getValue<T = any>(value: StorageElementType | PixiVNJsonValueGet | PixiVNJsonConditions, params: any[]): T | undefined;
|
|
17
|
-
declare function setStorageJson(value: PixiVNJsonValueSet, params: any[]): void;
|
|
18
|
-
declare function geLogichValue<T = StorageElementType>(value: T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions | PixiVNJsonConditionalStatements<T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions>, params: any[]): T | undefined;
|
|
10
|
+
declare function getConditionalStep(originalStep: PixiVNJsonLabelStep): PixiVNJsonLabelStep;
|
|
11
|
+
declare function setStorageJson(value: PixiVNJsonValueSet): void;
|
|
12
|
+
declare function getLogichValue<T = StorageElementType>(value: T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions | PixiVNJsonConditionalStatements<T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions>): T | undefined;
|
|
19
13
|
|
|
20
|
-
export {
|
|
14
|
+
export { getConditionalStep, getLogichValue, setStorageJson };
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import { StorageElementType } from '@drincs/pixi-vn';
|
|
2
|
-
import
|
|
3
|
-
import '../
|
|
2
|
+
import PixiVNJsonLabelStep from '../interface/PixiVNJsonLabelStep.js';
|
|
3
|
+
import { p as PixiVNJsonValueSet, o as PixiVNJsonValueGet, P as PixiVNJsonArithmeticOperations, d as PixiVNJsonConditions, b as PixiVNJsonConditionalStatements } from '../PixiVNJsonConditionalStatements-CVkQSKpq.js';
|
|
4
|
+
import '../interface/PixiVNJsonOperations.js';
|
|
5
|
+
import '../interface/PixiVNJsonInput.js';
|
|
6
|
+
import '../interface/PixiVNJsonMedia.js';
|
|
7
|
+
import '../interface/PixiVNJsonMediaTransiotions.js';
|
|
8
|
+
import 'pixi.js';
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* @returns the value from the conditional statements
|
|
9
|
-
*/
|
|
10
|
-
declare function getValueFromConditionalStatements<T>(statement: PixiVNJsonConditionalResultToCombine<T> | PixiVNJsonConditionalStatements<T> | T | undefined, params: any[]): T | undefined;
|
|
11
|
-
/**
|
|
12
|
-
* Get the value from the storage or the value.
|
|
13
|
-
* @param value is the value to get
|
|
14
|
-
* @returns the value from the storage or the value
|
|
15
|
-
*/
|
|
16
|
-
declare function getValue<T = any>(value: StorageElementType | PixiVNJsonValueGet | PixiVNJsonConditions, params: any[]): T | undefined;
|
|
17
|
-
declare function setStorageJson(value: PixiVNJsonValueSet, params: any[]): void;
|
|
18
|
-
declare function geLogichValue<T = StorageElementType>(value: T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions | PixiVNJsonConditionalStatements<T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions>, params: any[]): T | undefined;
|
|
10
|
+
declare function getConditionalStep(originalStep: PixiVNJsonLabelStep): PixiVNJsonLabelStep;
|
|
11
|
+
declare function setStorageJson(value: PixiVNJsonValueSet): void;
|
|
12
|
+
declare function getLogichValue<T = StorageElementType>(value: T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions | PixiVNJsonConditionalStatements<T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions>): T | undefined;
|
|
19
13
|
|
|
20
|
-
export {
|
|
14
|
+
export { getConditionalStep, getLogichValue, setStorageJson };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { NarrationManagerStatic,
|
|
1
|
+
import {createExportableElement,getFlag,storage,setFlag,narration,NarrationManagerStatic}from'@drincs/pixi-vn';var b="___param___";var p=class n{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(i=>n._translate(`${i}`)):n._translate(`${e}`)}static set translate(e){n._translate=e;}addKey(e,i,s){let t=s.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(o=>{e[o]===void 0&&(t==="empty_string"?e[o]="":t==="copy_key"&&(e[o]=o));});}getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&this.getConditionalsThenElse(e.then,i),e.else&&this.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(s=>{this.getConditionalsThenElse(s,i);});else if(e.elements.type==="ifelse"){let s=[];this.getConditionalsThenElse(e.elements,s),s.forEach(t=>{i.push(...t);});}else if(e.elements.type==="stepswitch"){let s=[];this.getConditionalsThenElse(e.elements,s),s.forEach(t=>{i.push(...t);});}else this.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&this.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(s=>{this.getConditionalsThenElse(s,i);})):i.push(e);else e&&i.push(e);return i}generateNewTranslateFile(e,i={},s={}){return e.forEach(t=>{if(t.choices){let o=[];Array.isArray(t.choices)?o=[t.choices]:o=this.getConditionalsThenElse(t.choices),o.forEach(l=>l.forEach(f=>{if("type"in f){let d=[];f.type==="ifelse"||f.type==="stepswitch"?this.getConditionalsThenElse(f,d):d=[f],d.map(g=>this.getConditionalsThenElse(g.text)).forEach(g=>{Array.isArray(g)&&g.forEach(h=>{Array.isArray(h)?h.forEach(x=>{typeof x=="string"?this.addKey(i,x,s):this.getConditionalsThenElse(x).forEach(m=>{Array.isArray(m)?m.forEach(N=>{typeof N=="string"&&this.addKey(i,N,s);}):typeof m=="string"&&this.addKey(i,m,s);});}):typeof h=="string"&&this.addKey(i,h,s);});});}}));}if(t.dialogue){let o=[];Array.isArray(t.dialogue)?o=[t.dialogue]:o=this.getConditionalsThenElse(t.dialogue),o.forEach(l=>{typeof l=="string"?this.addKey(i,l,s):"text"in l&&Array.isArray(l.text)&&l.text.forEach(f=>{typeof f=="string"?this.addKey(i,f,s):this.getConditionalsThenElse(f).forEach(c=>{typeof c=="string"?this.addKey(i,c,s):Array.isArray(c)&&c.forEach(g=>{typeof g=="string"?this.addKey(i,g,s):this.getConditionalsThenElse(g).forEach(h=>{typeof h=="string"&&this.addKey(i,h,s);});});});});});}t.conditionalStep&&this.getConditionalsThenElse(t.conditionalStep).forEach(l=>{Array.isArray(l)?this.generateNewTranslateFile(l,i,s):this.generateNewTranslateFile([l],i,s);});}),i}};function O(n,e){return Math.floor(Math.random()*(e-n+1)+n)}function w(n){if(Array.isArray(n)||!n)return n;if(n&&typeof n=="object"&&"type"in n)switch(n.type){case"resulttocombine":return D(n);case"ifelse":return a(n.condition)?a(n.then):a(n.else);case"stepswitch":let i=a(n.elements)||[];if(i.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(n.choiceType){case"random":let s=O(0,i.length-1);return a(i[s]);case"loop":let t=NarrationManagerStatic.getCurrentStepTimesCounter(n.nestedId)-1;return t>i.length-1&&(t=t%i.length),a(i[t]);case"sequential":let o,l=NarrationManagerStatic.getCurrentStepTimesCounter(n.nestedId)-1;return n.end=="lastItem"&&(o=a(i[i.length-1])),l>i.length-1?o:a(i[l]);case"sequentialrandom":let f=NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:n.nestedId,onceOnly:!0});if(f==null&&n.end=="lastItem"){let d=NarrationManagerStatic.getCurrentStepTimesCounterData(n.nestedId);if(!d||!d?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let c=d.usedRandomNumbers[`0-${i.length-1}`];return a(i[c[c.length-1]])}if(f==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return a(i[f])}}return n}function S(n){if(n.conditionalStep){let e=createExportableElement(a(n.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 i={...n,conditionalStep:void 0,...e};return S(i)}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 n}function D(n){let e=n.firstItem,i=[];n.secondConditionalItem?.forEach(t=>{if(Array.isArray(t))t.forEach(o=>{let l=a(o);i.push(l);});else {let o=a(t);i.push(o);}});let s=e?[e,...i]:i;if(s.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof s[0]=="string")return p.t(s).join("");if(typeof s[0]=="object"){let t=s,o,l=t.map((r,y)=>{r=S(r);let u=a(r.dialogue)||"";return y===0?(o=a(r.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),o===!1&&(u=`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { u as geLogichValue, T as getValue, o as getValueFromConditionalStatements, A as setStorageJson };
|
|
3
|
+
`+u),o=a(r.glueEnabled)||!1,u)}),f=a(l[0]),d=typeof f=="object"&&"character"in f?f.character:void 0,c=l.map(r=>{let y;r&&typeof r=="object"&&"text"in r?y=r.text:y=r;let u;return Array.isArray(y)?u=y.map(A=>{let _=a(A);return p.t(`${_}`)}).join(""):u=a(y)||"",p.t(u)}).join(""),g=t.find(r=>r.end),h=t.find(r=>r.choices),x=!1,m=!1;t.length>0&&(t[0].glueEnabled&&t[0].goNextStep&&t[0].dialogue===void 0&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),x=t[t.length-1].glueEnabled,m=t.reverse().find(r=>!(r.operation&&(!r.dialogue||!r.choices)))?.goNextStep);let N=t.find(r=>r.labelToOpen),E=[];return t.forEach(r=>{r.operation&&E.forEach(y=>{E.push(y);});}),{dialogue:d?{character:d,text:c}:c,end:g?.end,choices:h?.choices,glueEnabled:x,goNextStep:m,labelToOpen:N?.labelToOpen,operation:E}}}function L(n){if(!n)return !1;if(typeof n!="object"||!("type"in n))return !!n;switch(n.type){case"compare":let e=a(n.leftValue),i=a(n.rightValue);switch(n.operator){case"==":return e===i;case"!=":return e!==i;case"<":return e<i;case"<=":return e<=i;case">":return e>i;case">=":return e>=i;case"CONTAINS":return e.toString().includes(i.toString())}break;case"valueCondition":return !!a(n.value);case"union":return G(n)}return !!n}function R(n){if(n&&typeof n=="object"&&"type"in n&&n.type==="value"&&n.storageOperationType==="get")switch(n.storageType){case"storage":case"tempstorage":return storage.getVariable(n.key);case"flagStorage":return getFlag(n.key);case"label":return narration.getTimesLabelOpened(n.label);case"choice":return narration.getTimesChoiceMade(n.index);case"logic":return a(n.operation);case"params":let e=storage.getVariable(`${b}${narration.openedLabels.length-1}`)||[];if(e&&e.length>n.key)return e[n.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return n}function G(n){if(n.unionType==="not")return !a(n.condition);let e=n.unionType==="and";for(let i=0;i<n.conditions.length;i++)if(e=a(n.conditions[i])||!1,n.unionType==="and"){if(!e)return !1}else if(e)return !0;return e}function Y(n){let e=a(n.value),i;switch(e&&typeof e=="object"&&"type"in e?i=a(e):i=e,n.storageType){case"flagStorage":setFlag(n.key,n.value);break;case"storage":storage.setVariable(n.key,i);break;case"tempstorage":storage.setTempVariable(n.key,i);break;case"params":let s=storage.getVariable(`${b}${narration.openedLabels.length-1}`)||[];s&&s.length-1>=n.key&&(s[n.key]=i),storage.setTempVariable(`${b}${narration.openedLabels.length-1}`,s);break}}function a(n){let e=w(n);if(e&&typeof e=="object"&&"type"in e)switch(e.type){case"value":return R(e);case"arithmetic":case"arithmeticsingle":return k(e);case"compare":case"valueCondition":case"union":return L(e)}return e}function k(n){let e=a(n.leftValue);switch(n.type){case"arithmetic":let i=a(n.rightValue);switch(n.operator){case"*":return e*i;case"/":return e/i;case"+":return e+i;case"-":return e-i;case"%":return e%i;case"POW":return Math.pow(e,i);case"RANDOM":return narration.getRandomNumber(e,i)}case"arithmeticsingle":switch(n.operator){case"INT":return parseInt(e);case"FLOOR":return Math.floor(e);case"FLOAT":return parseFloat(e)}break}}export{S as getConditionalStep,a as getLogichValue,Y as setStorageJson};
|
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
'use strict';var pixiVn=require('@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],v=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)+v+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,v=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]+v|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 _="___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;}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));});}getConditionalsThenElse(i,e=[]){if(typeof i=="object"&&i&&"type"in i)if(i.type==="ifelse")i.then&&this.getConditionalsThenElse(i.then,e),i.else&&this.getConditionalsThenElse(i.else,e);else if(i.type==="stepswitch"){if(i.elements)if(Array.isArray(i.elements))i.elements.forEach(r=>{this.getConditionalsThenElse(r,e);});else if(i.elements.type==="ifelse"){let r=[];this.getConditionalsThenElse(i.elements,r),r.forEach(o=>{e.push(...o);});}else if(i.elements.type==="stepswitch"){let r=[];this.getConditionalsThenElse(i.elements,r),r.forEach(o=>{e.push(...o);});}else this.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&this.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(r=>{this.getConditionalsThenElse(r,e);})):e.push(i);else i&&e.push(i);return e}generateNewTranslateFile(i,e={},r={}){return i.forEach(o=>{if(o.choices){let s=[];Array.isArray(o.choices)?s=[o.choices]:s=this.getConditionalsThenElse(o.choices),s.forEach(c=>c.forEach(h=>{if("type"in h){let d=[];h.type==="ifelse"||h.type==="stepswitch"?this.getConditionalsThenElse(h,d):d=[h],d.map(l=>this.getConditionalsThenElse(l.text)).forEach(l=>{Array.isArray(l)&&l.forEach(g=>{Array.isArray(g)?g.forEach(y=>{typeof y=="string"?this.addKey(e,y,r):this.getConditionalsThenElse(y).forEach(b=>{Array.isArray(b)?b.forEach(x=>{typeof x=="string"&&this.addKey(e,x,r);}):typeof b=="string"&&this.addKey(e,b,r);});}):typeof g=="string"&&this.addKey(e,g,r);});});}}));}if(o.dialogue){let s=[];Array.isArray(o.dialogue)?s=[o.dialogue]:s=this.getConditionalsThenElse(o.dialogue),s.forEach(c=>{typeof c=="string"?this.addKey(e,c,r):"text"in c&&Array.isArray(c.text)&&c.text.forEach(h=>{typeof h=="string"?this.addKey(e,h,r):this.getConditionalsThenElse(h).forEach(p=>{typeof p=="string"?this.addKey(e,p,r):Array.isArray(p)&&p.forEach(l=>{typeof l=="string"?this.addKey(e,l,r):this.getConditionalsThenElse(l).forEach(g=>{typeof g=="string"&&this.addKey(e,g,r);});});});});});}o.conditionalStep&&this.getConditionalsThenElse(o.conditionalStep).forEach(c=>{Array.isArray(c)?this.generateNewTranslateFile(c,e,r):this.generateNewTranslateFile([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=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return o>e.length-1&&(o=o%e.length),f(e[o]);case"sequential":let s,c=pixiVn.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=pixiVn.NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:t.nestedId,onceOnly:!0});if(h==null&&t.end=="lastItem"){let d=pixiVn.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=pixiVn.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 pixiVn.getFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.setFlag(pixiVn.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=`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var ne=Object.create;var G=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var ae=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var j=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(i,n)=>(typeof require<"u"?require:i)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var M=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var le=(t,i,n,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of oe(i))!se.call(t,o)&&o!==n&&G(t,o,{get:()=>i[o],enumerable:!(e=re(i,o))||e.enumerable});return t};var ue=(t,i,n)=>(n=t!=null?ne(ae(t)):{},le(G(n,"default",{value:t,enumerable:!0}),t));var W=M((L,z)=>{(function(t,i){typeof L=="object"?z.exports=L=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(L,function(){var t=t||function(i,n){var e;if(typeof window<"u"&&window.crypto&&(e=window.crypto),typeof self<"u"&&self.crypto&&(e=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(e=globalThis.crypto),!e&&typeof window<"u"&&window.msCrypto&&(e=window.msCrypto),!e&&typeof global<"u"&&global.crypto&&(e=global.crypto),!e&&typeof j=="function")try{e=j("crypto");}catch{}var o=function(){if(e){if(typeof e.getRandomValues=="function")try{return e.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof e.randomBytes=="function")try{return e.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},l=Object.create||function(){function r(){}return function(a){var g;return r.prototype=a,g=new r,r.prototype=null,g}}(),s={},p=s.lib={},b=p.Base=function(){return {extend:function(r){var a=l(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)}}}(),m=p.WordArray=b.extend({init:function(r,a){r=this.words=r||[],a!=n?this.sigBytes=a:this.sigBytes=r.length*4;},toString:function(r){return (r||f).stringify(this)},concat:function(r){var a=this.words,g=r.words,h=this.sigBytes,N=r.sigBytes;if(this.clamp(),h%4)for(var T=0;T<N;T++){var D=g[T>>>2]>>>24-T%4*8&255;a[h+T>>>2]|=D<<24-(h+T)%4*8;}else for(var J=0;J<N;J+=4)a[h+J>>>2]=g[J>>>2];return this.sigBytes+=N,this},clamp:function(){var r=this.words,a=this.sigBytes;r[a>>>2]&=4294967295<<32-a%4*8,r.length=i.ceil(a/4);},clone:function(){var r=b.clone.call(this);return r.words=this.words.slice(0),r},random:function(r){for(var a=[],g=0;g<r;g+=4)a.push(o());return new m.init(a,r)}}),u=s.enc={},f=u.Hex={stringify:function(r){for(var a=r.words,g=r.sigBytes,h=[],N=0;N<g;N++){var T=a[N>>>2]>>>24-N%4*8&255;h.push((T>>>4).toString(16)),h.push((T&15).toString(16));}return h.join("")},parse:function(r){for(var a=r.length,g=[],h=0;h<a;h+=2)g[h>>>3]|=parseInt(r.substr(h,2),16)<<24-h%8*4;return new m.init(g,a/2)}},y=u.Latin1={stringify:function(r){for(var a=r.words,g=r.sigBytes,h=[],N=0;N<g;N++){var T=a[N>>>2]>>>24-N%4*8&255;h.push(String.fromCharCode(T));}return h.join("")},parse:function(r){for(var a=r.length,g=[],h=0;h<a;h++)g[h>>>2]|=(r.charCodeAt(h)&255)<<24-h%4*8;return new m.init(g,a)}},x=u.Utf8={stringify:function(r){try{return decodeURIComponent(escape(y.stringify(r)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(r){return y.parse(unescape(encodeURIComponent(r)))}},c=p.BufferedBlockAlgorithm=b.extend({reset:function(){this._data=new m.init,this._nDataBytes=0;},_append:function(r){typeof r=="string"&&(r=x.parse(r)),this._data.concat(r),this._nDataBytes+=r.sigBytes;},_process:function(r){var a,g=this._data,h=g.words,N=g.sigBytes,T=this.blockSize,D=T*4,J=N/D;r?J=i.ceil(J):J=i.max((J|0)-this._minBufferSize,0);var A=J*T,F=i.min(A*4,N);if(A){for(var R=0;R<A;R+=T)this._doProcessBlock(h,R);a=h.splice(0,A),g.sigBytes-=F;}return new m.init(a,F)},clone:function(){var r=b.clone.call(this);return r._data=this._data.clone(),r},_minBufferSize:0});p.Hasher=c.extend({cfg:b.extend(),init:function(r){this.cfg=this.cfg.extend(r),this.reset();},reset:function(){c.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,g){return new r.init(g).finalize(a)}},_createHmacHelper:function(r){return function(a,g){return new V.HMAC.init(r,g).finalize(a)}}});var V=s.algo={};return s}(Math);return t});});var $=M((I,U)=>{(function(t,i){typeof I=="object"?U.exports=I=i(W()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(I,function(t){return function(){var i=t,n=i.lib,e=n.WordArray,o=n.Hasher,l=i.algo,s=[],p=l.SHA1=o.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(b,m){for(var u=this._hash.words,f=u[0],y=u[1],x=u[2],c=u[3],v=u[4],V=0;V<80;V++){if(V<16)s[V]=b[m+V]|0;else {var r=s[V-3]^s[V-8]^s[V-14]^s[V-16];s[V]=r<<1|r>>>31;}var a=(f<<5|f>>>27)+v+s[V];V<20?a+=(y&x|~y&c)+1518500249:V<40?a+=(y^x^c)+1859775393:V<60?a+=(y&x|y&c|x&c)-1894007588:a+=(y^x^c)-899497514,v=c,c=x,x=y<<30|y>>>2,y=f,f=a;}u[0]=u[0]+f|0,u[1]=u[1]+y|0,u[2]=u[2]+x|0,u[3]=u[3]+c|0,u[4]=u[4]+v|0;},_doFinalize:function(){var b=this._data,m=b.words,u=this._nDataBytes*8,f=b.sigBytes*8;return m[f>>>5]|=128<<24-f%32,m[(f+64>>>9<<4)+14]=Math.floor(u/4294967296),m[(f+64>>>9<<4)+15]=u,b.sigBytes=m.length*4,this._process(),this._hash},clone:function(){var b=o.clone.call(this);return b._hash=this._hash.clone(),b}});i.SHA1=o._createHelper(p),i.HmacSHA1=o._createHmacHelper(p);}(),t.SHA1});});var ie=ue($());var E="___param___";function pe(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function d(t,i){if(!(Array.isArray(t)||!t)){if(t&&typeof t=="object"&&"type"in t)switch(t.type){case"resulttocombine":return de(t,i);case"ifelse":return P(t.condition,i)?d(t.then,i):d(t.else,i);case"stepswitch":let e=d(t.elements,i)||[];if(e.length===0){console.error("[Pixi'VN] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let o=pe(0,e.length);return d(e[o],i);case"loop":return pixiVn.narration.currentStepTimesCounter>e.length-1?(pixiVn.narration.currentStepTimesCounter=0,d(e[0],i)):d(e[pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)],i);case"sequential":let l;return t.end=="lastItem"&&(l=d(e[e.length-1],i)),pixiVn.narration.currentStepTimesCounter>e.length-1?l:d(e[pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)],i);case"sequentialrandom":let s=pixiVn.NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:t.nestedId,onceOnly:!0});if(s==null&&t.end=="lastItem"){let p=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!p||!p?.usedRandomNumbers)return;let b=p.usedRandomNumbers[`0-${e.length-1}`];return d(e[b[b.length-1]],i)}return s==null?void 0:d(e[s],i)}}return t}}function de(t,i){let n=t.firstItem,e=[];t.secondConditionalItem?.forEach(l=>{if(Array.isArray(l))l.forEach(s=>{let p=d(s,i);p&&e.push(p);});else {let s=d(l,i);s&&e.push(s);}});let o=n?[n,...e]:e;if(o.length!==0){if(typeof o[0]=="string")return o.join("");if(typeof o[0]=="object"){let l=o,s=l.map(c=>c.dialogue).join(""),p=l.find(c=>c.end),b=l.find(c=>c.choices),m=l.find(c=>c.glueEnabled),u=l.find(c=>c.goNextStep),f=l.find(c=>c.labelToOpen),y=l.find(c=>c.operation);return {dialogue:s,end:p?.end,choices:b?.choices,glueEnabled:m?.glueEnabled,goNextStep:u?.goNextStep,labelToOpen:f?.labelToOpen,operation:y?.operation}}}}function ge(t,i){if(!t)return !1;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case"compare":let n=w(t.leftValue,i),e=w(t.rightValue,i);switch(t.operator){case"==":return n===e;case"!=":return n!==e;case"<":return n<e;case"<=":return n<=e;case">":return n>e;case">=":return n>=e;case"CONTAINS":return n.toString().includes(e.toString())}break;case"valueCondition":return !!w(t.value,i);case"union":return he(t,i);case"labelcondition":if("operator"in t&&"label"in t)switch(t.operator){case"started":return pixiVn.narration.getTimesLabelOpened(t.label)>0;case"completed":return pixiVn.narration.isLabelAlreadyCompleted(t.label)}break}return !!t}function w(t,i){if(t&&typeof t=="object"&&"type"in t)if(t.type==="value"&&t.storageOperationType==="get")switch(t.storageType){case"storage":return pixiVn.storage.getVariable(t.key);case"tempstorage":return pixiVn.StorageManagerStatic.getTempVariable(t.key);case"flagStorage":return pixiVn.getFlag(t.key);case"label":return pixiVn.narration.getTimesLabelOpened(t.label);case"logic":return P(t.operation,i);case"params":return i&&i.length-1>=t.key?i[t.key]:void 0}else return P(t,i);return t}function he(t,i){if(t.unionType==="not")return !P(t.condition,i);let n=t.unionType==="and";for(let e=0;e<t.conditions.length;e++)if(n=P(t.conditions[e],i)||!1,t.unionType==="and"){if(!n)return !1}else if(n)return !0;return n}function H(t,i){let n=d(t.value,i),e;switch(n&&typeof n=="object"&&"type"in n?e=P(n,i):e=n,t.storageType){case"flagStorage":pixiVn.setFlag(t.key,t.value);break;case"storage":pixiVn.storage.setVariable(t.key,e);break;case"tempstorage":pixiVn.StorageManagerStatic.setTempVariable(t.key,e);break;case"params":i&&i.length-1>=t.key&&(i[t.key]=e);break}}function P(t,i){let n=d(t,i);if(n&&typeof n=="object"&&"type"in n)switch(n.type){case"value":return w(n,i);case"arithmetic":case"arithmeticsingle":return ye(n,i);case"compare":case"valueCondition":case"union":case"labelcondition":return ge(n,i)}return n}function ye(t,i){let n=P(t.leftValue,i);switch(t.type){case"arithmetic":let e=P(t.rightValue,i);switch(t.operator){case"*":return n*e;case"/":return n/e;case"+":return n+e;case"-":return n-e;case"%":return n%e;case"POW":return Math.pow(n,e);case"RANDOM":return Math.floor(Math.random()*(e-n+1))+n}case"arithmeticsingle":switch(t.operator){case"INT":return parseInt(n);case"FLOOR":return Math.floor(n);case"FLOAT":return parseFloat(n)}break}}var O=class extends pixiVn.LabelAbstract{constructor(i,n,e,o){super(i,e),this._steps=n,this.operationStringConvert=o;}_steps;get steps(){return this._steps.map(this.stepConverter)}operationStringConvert;getStepSha1(i){if(i<0||i>=this.steps.length)return;let n=this._steps[i];return (0, ie.default)(n.toString().toLocaleLowerCase()).toString()}getDialogueText(i,n){let e="";if(Array.isArray(i)){let o=[];i.forEach(l=>{if(typeof l=="string")o.push(l);else if(l&&typeof l=="object"){let s=d(l,n);s&&(s&&!Array.isArray(s)&&typeof s=="object"&&(s=w(s,n)||""),Array.isArray(s)?o=o.concat(s):o.push(s));}}),e=o;}else {let o=d(i,n)||"";o&&!Array.isArray(o)&&typeof o=="object"&&(o=w(o,n)||""),e=o;}return e}getDialogue(i,n){let e=d(i,n),o;return e&&(typeof e=="object"&&"character"in e&&"text"in e?o={character:e.character,text:this.getDialogueText(e.text,n)}:o=this.getDialogueText(e,n)),o}getChoices(i,n){let e=d(i,n);if(e)return e.map(l=>d(l,n)).filter(l=>l!==void 0)}stepConverter(i){return async n=>{let e=n[E];if(typeof i=="function"&&(i=i()),i.operation)for(let u of i.operation)await this.runOperation(u,e);let o=this.getChoices(i.choices,e),l=d(i.glueEnabled,e),s=this.getDialogue(i.dialogue,e),p=[];i.labelToOpen&&(Array.isArray(i.labelToOpen)||(i.labelToOpen=[i.labelToOpen]),i.labelToOpen.forEach(u=>{let f=d(u,e);f&&p.push(f);}));let b=d(i.goNextStep,e),m=d(i.end,e);if(o){let u=o.map(f=>{let y="";if(Array.isArray(f.text)){let x=[];f.text.forEach(c=>{if(typeof c=="string")x.push(c);else if(c&&typeof c=="object"){let v=d(c,e);v&&!Array.isArray(v)&&typeof v=="object"&&(v=w(v,e)||""),v&&(Array.isArray(v)?x=x.concat(v):x.push(v));}}),y=x.join();}else typeof f.text=="string"&&(y=f.text);return new pixiVn.ChoiceMenuOption(y,f.label,f.props,{type:f.type,oneTime:f.oneTime})});u=u.filter((f,y)=>{if(f.oneTime){let x=pixiVn.narration.alreadyCurrentStepMadeChoices;if(x&&x.includes(y))return !1}return !0}),pixiVn.narration.choiceMenuOptions=u;}else pixiVn.narration.choiceMenuOptions=void 0;l?pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):l===!1&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1),s&&(pixiVn.narration.dialogue=s),p.forEach(u=>{let f=u.label;typeof f=="object"&&(f=w(f,e)||"");let y=u.params?.map(x=>P(x,e));n={...n,...u.props,[E]:y},u.type==="jump"?pixiVn.narration.jumpLabel(f,n):pixiVn.narration.callLabel(f,n);}),b&&await pixiVn.narration.goNext(n),m==="game_end"?(pixiVn.narration.closeAllLabels(),await pixiVn.narration.goNext(n)):m==="label_end"&&pixiVn.narration.closeCurrentLabel();}}async runOperation(i,n){let e=d(i,n);if(e)switch(e.type){case"sound":switch(e.operationType){case"add":pixiVn.sound.add(e.alias,{...e.props,url:e.url});break;case"play":pixiVn.sound.play(e.alias,e.props);break;case"remove":pixiVn.sound.remove(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}break;case"image":switch(e.operationType){case"show":if(e.transition)switch(e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,e.url,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,e.url,e.transition.props,e.transition.priority);break}else await pixiVn.showImage(e.alias,e.url);break;case"edit":let o=pixiVn.canvas.find(e.alias);o?e.props&&(o.memory={...o.memory,...e.props}):console.error(`[Pixi'VN] Image with alias ${e.alias} not found.`);break;case"remove":pixiVn.canvas.remove(e.alias);break}break;case"video":switch(e.operationType){case"show":if(e.transition){let p=new pixiVn.CanvasVideo;switch(p.videoLink=e.url,e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,p,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,p,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,p,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,p,e.transition.props,e.transition.priority);break}}else await pixiVn.showVideo(e.alias,e.url);break;case"edit":let o=pixiVn.canvas.find(e.alias);o?e.props&&(o.memory={...o.memory,...e.props}):console.error(`[Pixi'VN] Video with alias ${e.alias} not found.`);break;case"remove":pixiVn.canvas.remove(e.alias);break;case"pause":let l=pixiVn.canvas.find(e.alias);l?l.paused=!0:console.error(`[Pixi'VN] Video with alias ${e.alias} not found.`);break;case"resume":let s=pixiVn.canvas.find(e.alias);s?s.paused=!1:console.error(`[Pixi'VN] Video with alias ${e.alias} not found.`);break}break;case"value":H(e,n);break;case"oprationtoconvert":if(this.operationStringConvert){let o="";e.values.forEach(s=>{if(typeof s=="string")o+=s;else {let p=P(s,n);p&&(o+=`${p}`);}});let l=this.operationStringConvert(o);l&&await this.runOperation(l,n);}break;case"input":switch(e.operationType){case"request":pixiVn.narration.requestInput({type:e.valueType});break}break}}};function ve(t,i){try{typeof t=="string"&&(t=JSON.parse(t));}catch(n){console.error("[Pixi'VN] Error parsing imported Pixi'VN JSON",n);return}if(typeof t!="object"){console.error("[Pixi'VN] Error parsing imported Pixi'VN JSON: data is not an object");return}if(t.labels){let n=t.labels;for(let e in n)try{let o=n[e],l=new O(e,o,void 0,i);pixiVn.saveLabel(l);}catch(o){console.error(`[Pixi'VN] Error creating JSON label ${e}`,o);}}}
|
|
6
|
-
|
|
7
|
-
exports.LabelJson = O;
|
|
8
|
-
exports.PIXIVNJSON_PARAM_ID = E;
|
|
9
|
-
exports.geLogichValue = P;
|
|
10
|
-
exports.getValue = w;
|
|
11
|
-
exports.getValueFromConditionalStatements = d;
|
|
12
|
-
exports.importPixiVNJson = ve;
|
|
13
|
-
exports.setStorageJson = H;
|
|
3
|
+
`+u),s=f(n.glueEnabled)||!1,u)}),h=f(c[0]),d=typeof h=="object"&&"character"in h?h.character:void 0,p=c.map(n=>{let a;n&&typeof n=="object"&&"text"in n?a=n.text:a=n;let u;return Array.isArray(a)?u=a.map(m=>{let T=f(m);return J.t(`${T}`)}).join(""):u=f(a)||"",J.t(u)}).join(""),l=o.find(n=>n.end),g=o.find(n=>n.choices),y=!1,b=!1;o.length>0&&(o[0].glueEnabled&&o[0].goNextStep&&o[0].dialogue===void 0&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),y=o[o.length-1].glueEnabled,b=o.reverse().find(n=>!(n.operation&&(!n.dialogue||!n.choices)))?.goNextStep);let x=o.find(n=>n.labelToOpen),v=[];return o.forEach(n=>{n.operation&&v.forEach(a=>{v.push(a);});}),{dialogue:d?{character:d,text:p}:p,end:l?.end,choices:g?.choices,glueEnabled:y,goNextStep:b,labelToOpen:x?.labelToOpen,operation:v}}}function ye(t){if(!t)return !1;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case"compare":let i=f(t.leftValue),e=f(t.rightValue);switch(t.operator){case"==":return i===e;case"!=":return i!==e;case"<":return i<e;case"<=":return i<=e;case">":return i>e;case">=":return i>=e;case"CONTAINS":return i.toString().includes(e.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 pixiVn.storage.getVariable(t.key);case"flagStorage":return pixiVn.getFlag(t.key);case"label":return pixiVn.narration.getTimesLabelOpened(t.label);case"choice":return pixiVn.narration.getTimesChoiceMade(t.index);case"logic":return f(t.operation);case"params":let i=pixiVn.storage.getVariable(`${_}${pixiVn.narration.openedLabels.length-1}`)||[];if(i&&i.length>t.key)return i[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 i=t.unionType==="and";for(let e=0;e<t.conditions.length;e++)if(i=f(t.conditions[e])||!1,t.unionType==="and"){if(!i)return !1}else if(i)return !0;return i}function j(t){let i=f(t.value),e;switch(i&&typeof i=="object"&&"type"in i?e=f(i):e=i,t.storageType){case"flagStorage":pixiVn.setFlag(t.key,t.value);break;case"storage":pixiVn.storage.setVariable(t.key,e);break;case"tempstorage":pixiVn.storage.setTempVariable(t.key,e);break;case"params":let r=pixiVn.storage.getVariable(`${_}${pixiVn.narration.openedLabels.length-1}`)||[];r&&r.length-1>=t.key&&(r[t.key]=e),pixiVn.storage.setTempVariable(`${_}${pixiVn.narration.openedLabels.length-1}`,r);break}}function f(t){let i=ge(t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return me(i);case"arithmetic":case"arithmeticsingle":return be(i);case"compare":case"valueCondition":case"union":return ye(i)}return i}function be(t){let i=f(t.leftValue);switch(t.type){case"arithmetic":let e=f(t.rightValue);switch(t.operator){case"*":return i*e;case"/":return i/e;case"+":return i+e;case"-":return i-e;case"%":return i%e;case"POW":return Math.pow(i,e);case"RANDOM":return pixiVn.narration.getRandomNumber(i,e)}case"arithmeticsingle":switch(t.operator){case"INT":return parseInt(i);case"FLOOR":return Math.floor(i);case"FLOAT":return parseFloat(i)}break}}async function L(t,i){let e=f(t);if(e)switch(e.type){case"sound":switch(e.operationType){case"add":pixiVn.sound.add(e.alias,{...e.props,url:e.url});break;case"play":pixiVn.sound.play(e.alias,e.props);break;case"remove":pixiVn.sound.remove(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}break;case"image":switch(e.operationType){case"show":if(e.transition)switch(e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,e.url,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,e.url,e.transition.props,e.transition.priority);break}else await pixiVn.showImage(e.alias,e.url);break;case"edit":let r=pixiVn.canvas.find(e.alias);r?e.props&&(r.memory={...r.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${e.alias} not found.`);break;case"remove":pixiVn.canvas.remove(e.alias);break}break;case"video":switch(e.operationType){case"show":if(e.transition){let c=new pixiVn.CanvasVideo;switch(c.videoLink=e.url,e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,c,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,c,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,c,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,c,e.transition.props,e.transition.priority);break}}else await pixiVn.showVideo(e.alias,e.url);break;case"edit":let r=pixiVn.canvas.find(e.alias);r?e.props&&(r.memory={...r.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"remove":pixiVn.canvas.remove(e.alias);break;case"pause":let o=pixiVn.canvas.find(e.alias);o?o.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"resume":let s=pixiVn.canvas.find(e.alias);s?s.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break}break;case"value":j(e);break;case"oprationtoconvert":if(i){let r="";e.values.forEach(s=>{if(typeof s=="string")r+=s;else {let c=f(s);r+=`${c}`;}});let o=i(r);o&&await L(o);}break;case"input":switch(e.operationType){case"request":pixiVn.narration.requestInput({type:e.valueType});break}break}}var O=class extends pixiVn.LabelAbstract{constructor(i,e,r,o={}){super(i,r),this._steps=e,this.operationStringConvert=o.operationStringConvert,this.skipEmptyDialogs=o.skipEmptyDialogs||!1;}_steps;get steps(){return this._steps.map(i=>this.stepConverter(i))}operationStringConvert;skipEmptyDialogs=!1;getStepSha1(i){if(i<0||i>=this.steps.length)return;let e=this._steps[i];return (0, re.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(i){let e="";if(Array.isArray(i)){let r=[];i.forEach(o=>{if(typeof o=="string")r.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)?r=r.concat(s):r.push(`${s}`)):r.push(`${o}`);}}),e=r;}else {let r=f(i)||"";r&&!Array.isArray(r)&&typeof r=="object"&&(r=f(r)||""),e=r;}return `${e}`}getDialogue(i){let e=f(i);if(e)return typeof e=="object"&&"character"in e&&"text"in e?{character:e.character,text:J.t(this.getDialogueText(e.text))}:J.t(this.getDialogueText(e));if(e!=null)return `${e}`}getChoices(i){return f(i)?.map(o=>f(o)).filter(o=>o!==void 0)}stepConverter(i){return async e=>{if(typeof i=="function"&&(i=i()),i=B(i),i.operation)for(let p of i.operation)await L(p,this.operationStringConvert);let r=this.getChoices(i.choices),o=f(i.glueEnabled),s=this.getDialogue(i.dialogue),c=[];i.labelToOpen&&(Array.isArray(i.labelToOpen)||(i.labelToOpen=[i.labelToOpen]),i.labelToOpen.forEach(p=>{let l=f(p);l&&c.push(l);}));let h=f(i.goNextStep),d=f(i.end);if(r){let p=r.map(l=>{let g="";if(Array.isArray(l.text)){let y=[];l.text.forEach(b=>{if(typeof b=="string")y.push(J.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)?y=y.concat(J.t(x)):y.push(J.t(x)));}}),g=y.join();}else typeof l.text=="string"&&(g=J.t(l.text));return new pixiVn.ChoiceMenuOption(g,l.label,l.props,{type:l.type,oneTime:l.oneTime,onlyHaveNoChoice:l.onlyHaveNoChoice,autoSelect:l.autoSelect})});pixiVn.narration.choiceMenuOptions=p;}else pixiVn.narration.choiceMenuOptions=void 0;s!==void 0&&(pixiVn.narration.dialogue=s,this.skipEmptyDialogs&&typeof s=="string"&&(s===""||RegExp(/^\s+$/).test(s))&&(h=!0)),o?pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):o===!1&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);for(let p of c){let l=p.label;typeof l=="object"&&(l=f(l)||"");let g=p.params?.map(y=>f(y));e={...e,...p.props},p.type==="jump"?(pixiVn.narration.closeCurrentLabel(),pixiVn.storage.setTempVariable(`${_}${pixiVn.narration.openedLabels.length}`,g),await pixiVn.narration.callLabel(l,e)):(pixiVn.storage.setTempVariable(`${_}${pixiVn.narration.openedLabels.length}`,g),await pixiVn.narration.callLabel(l,e));}d==="game_end"?(pixiVn.narration.closeAllLabels(),await pixiVn.narration.goNext(e)):d==="label_end"&&pixiVn.narration.closeCurrentLabel(),h&&await pixiVn.narration.goNext(e);}}};function _e(t,i={}){let e=i?.operationStringConvert;try{typeof t=="string"&&(t=JSON.parse(t));}catch(r){console.error("[Pixi\u2019VN Json] Error parsing imported Pixi'VN JSON",r);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 r of t.initialOperations)L(r,e);pixiVn.StorageManagerStatic.saveStorageAsBasicStorage();}if(t.labels){let r=t.labels;for(let o in r)try{let s=r[o],c=new O(o,s,void 0,i);pixiVn.saveLabel(c);}catch(s){console.error(`[Pixi\u2019VN Json] Error creating JSON label ${o}`,s);}}}exports.LabelJson=O;exports.PIXIVNJSON_PARAM_ID=_;exports.TranslateManager=J;exports.geLogichValue=f;exports.importPixiVNJson=_e;exports.setStorageJson=j;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export { default as LabelJson } from './classes/LabelJson.cjs';
|
|
2
2
|
export { PIXIVNJSON_PARAM_ID } from './constants.cjs';
|
|
3
3
|
export { importPixiVNJson } from './functions/importer.cjs';
|
|
4
|
-
export {
|
|
4
|
+
export { getLogichValue as geLogichValue, setStorageJson } from './functions/utility.cjs';
|
|
5
5
|
export { default as PixiVNJson } from './interface/PixiVNJson.cjs';
|
|
6
|
-
export { P as PixiVNJsonArithmeticOperations, c as PixiVNJsonComparation, a as PixiVNJsonConditionalResultToCombine, b as PixiVNJsonConditionalStatements, d as PixiVNJsonConditions, e as PixiVNJsonIfElse,
|
|
6
|
+
export { P as PixiVNJsonArithmeticOperations, j as PixiVNJsonChoiceGet, c as PixiVNJsonComparation, a as PixiVNJsonConditionalResultToCombine, b as PixiVNJsonConditionalStatements, d as PixiVNJsonConditions, e as PixiVNJsonIfElse, k as PixiVNJsonLabelGet, l as PixiVNJsonLogicGet, m as PixiVNJsonParamGet, f as PixiVNJsonStepSwitch, g as PixiVNJsonStepSwitchElementType, h as PixiVNJsonStepSwitchElementsType, n as PixiVNJsonStorageGet, i as PixiVNJsonUnionCondition, o as PixiVNJsonValueGet, p as PixiVNJsonValueSet } from './PixiVNJsonConditionalStatements-CVkQSKpq.cjs';
|
|
7
7
|
export { default as PixiVNJsonInput } from './interface/PixiVNJsonInput.cjs';
|
|
8
|
-
export { default as PixiVNJsonLabelCondition } from './interface/PixiVNJsonLabelCondition.cjs';
|
|
9
8
|
export { PixiVNJsonLabel, default as PixiVNJsonLabels } from './interface/PixiVNJsonLabels.cjs';
|
|
10
9
|
export { PixiVNJsonChoice, PixiVNJsonChoices, PixiVNJsonDialog, PixiVNJsonDialogText, default as PixiVNJsonLabelStep, PixiVNJsonLabelToOpen } from './interface/PixiVNJsonLabelStep.cjs';
|
|
11
10
|
export { PixiVNJsonCanvas, PixiVNJsonSound } from './interface/PixiVNJsonMedia.cjs';
|
|
12
11
|
export { default as PixiVNJsonMediaTransiotions } from './interface/PixiVNJsonMediaTransiotions.cjs';
|
|
13
12
|
export { PixiVNJsonOperation, PixiVNJsonOperationString, default as PixiVNJsonOperations } from './interface/PixiVNJsonOperations.cjs';
|
|
13
|
+
export { default as TranslateManager } from './managers/TranslateManager.cjs';
|
|
14
14
|
import '@drincs/pixi-vn';
|
|
15
15
|
import 'pixi.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export { default as LabelJson } from './classes/LabelJson.js';
|
|
2
2
|
export { PIXIVNJSON_PARAM_ID } from './constants.js';
|
|
3
3
|
export { importPixiVNJson } from './functions/importer.js';
|
|
4
|
-
export {
|
|
4
|
+
export { getLogichValue as geLogichValue, setStorageJson } from './functions/utility.js';
|
|
5
5
|
export { default as PixiVNJson } from './interface/PixiVNJson.js';
|
|
6
|
-
export { P as PixiVNJsonArithmeticOperations, c as PixiVNJsonComparation, a as PixiVNJsonConditionalResultToCombine, b as PixiVNJsonConditionalStatements, d as PixiVNJsonConditions, e as PixiVNJsonIfElse,
|
|
6
|
+
export { P as PixiVNJsonArithmeticOperations, j as PixiVNJsonChoiceGet, c as PixiVNJsonComparation, a as PixiVNJsonConditionalResultToCombine, b as PixiVNJsonConditionalStatements, d as PixiVNJsonConditions, e as PixiVNJsonIfElse, k as PixiVNJsonLabelGet, l as PixiVNJsonLogicGet, m as PixiVNJsonParamGet, f as PixiVNJsonStepSwitch, g as PixiVNJsonStepSwitchElementType, h as PixiVNJsonStepSwitchElementsType, n as PixiVNJsonStorageGet, i as PixiVNJsonUnionCondition, o as PixiVNJsonValueGet, p as PixiVNJsonValueSet } from './PixiVNJsonConditionalStatements-CVkQSKpq.js';
|
|
7
7
|
export { default as PixiVNJsonInput } from './interface/PixiVNJsonInput.js';
|
|
8
|
-
export { default as PixiVNJsonLabelCondition } from './interface/PixiVNJsonLabelCondition.js';
|
|
9
8
|
export { PixiVNJsonLabel, default as PixiVNJsonLabels } from './interface/PixiVNJsonLabels.js';
|
|
10
9
|
export { PixiVNJsonChoice, PixiVNJsonChoices, PixiVNJsonDialog, PixiVNJsonDialogText, default as PixiVNJsonLabelStep, PixiVNJsonLabelToOpen } from './interface/PixiVNJsonLabelStep.js';
|
|
11
10
|
export { PixiVNJsonCanvas, PixiVNJsonSound } from './interface/PixiVNJsonMedia.js';
|
|
12
11
|
export { default as PixiVNJsonMediaTransiotions } from './interface/PixiVNJsonMediaTransiotions.js';
|
|
13
12
|
export { PixiVNJsonOperation, PixiVNJsonOperationString, default as PixiVNJsonOperations } from './interface/PixiVNJsonOperations.js';
|
|
13
|
+
export { default as TranslateManager } from './managers/TranslateManager.js';
|
|
14
14
|
import '@drincs/pixi-vn';
|
|
15
15
|
import 'pixi.js';
|