@drincs/pixi-vn-json 1.7.2 → 1.7.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/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var importer=require('@drincs/pixi-vn-json/importer'),unifier=require('@drincs/pixi-vn-json/unifier'),pixiVn=require('@drincs/pixi-vn');var H=Object.defineProperty;var B=(e,i,t)=>i in e?H(e,i,{enumerable:true,configurable:true,writable:true,value:t}):e[i]=t;var w=(e,i,t)=>B(e,typeof i!="symbol"?i+"":i,t);var J="___param___";var n=class n{static t(i){return Array.isArray(i)?i.map(t=>n.translate(`${t}`)):n.translate(`${i}`)}static set beforeToTranslate(i){n._beforeToTranslate=i;}static set translate(i){n._translate=i;}static get translate(){return i=>{let t=i;return n._beforeToTranslate&&(t=n._beforeToTranslate(t)),t=n._translate(t),n._afterToTranslate&&(t=n._afterToTranslate(t)),t}}static set afterToTranslate(i){n._afterToTranslate=i;}static addKey(i,t,r){let a=r.defaultValue||"empty_string";typeof t=="string"&&(t=[t]),Array.isArray(t)&&t.forEach(s=>{i[s]===void 0&&(a==="empty_string"?i[s]="":a==="copy_key"&&(n._beforeToTranslate?i[s]=n._beforeToTranslate(s):i[s]=s));});}static getConditionalsThenElse(i,t=[]){if(typeof i=="object"&&i&&"type"in i)if(i.type==="ifelse")i.then&&n.getConditionalsThenElse(i.then,t),i.else&&n.getConditionalsThenElse(i.else,t);else if(i.type==="stepswitch"){if(i.elements)if(Array.isArray(i.elements))i.elements.forEach(r=>{n.getConditionalsThenElse(r,t);});else if(i.elements.type==="ifelse"){let r=[];n.getConditionalsThenElse(i.elements,r),r.forEach(a=>{t.push(...a);});}else if(i.elements.type==="stepswitch"){let r=[];n.getConditionalsThenElse(i.elements,r),r.forEach(a=>{t.push(...a);});}else n.getConditionalsThenElse(i.elements,t);}else i.type==="resulttocombine"?(i.firstItem&&n.getConditionalsThenElse(i.firstItem,t),i.secondConditionalItem&&i.secondConditionalItem.forEach(r=>{n.getConditionalsThenElse(r,t);})):t.push(i);else i&&t.push(i);return t}static generateJsonTranslation(i,t={},r={}){let{defaultValue:a="copy_key"}=r;return i.forEach(s=>{if(s.choices){let l=[];Array.isArray(s.choices)?l=[s.choices]:l=n.getConditionalsThenElse(s.choices),l.forEach(c=>c.forEach(u=>{if("type"in u){let p=[];u.type==="ifelse"||u.type==="stepswitch"?n.getConditionalsThenElse(u,p):p=[u],p.map(g=>n.getConditionalsThenElse(g.text)).forEach(g=>{Array.isArray(g)&&g.forEach(T=>{Array.isArray(T)?T.forEach(V=>{typeof V=="string"?n.addKey(t,V,{defaultValue:a}):n.getConditionalsThenElse(V).forEach(N=>{Array.isArray(N)?N.forEach(b=>{typeof b=="string"&&n.addKey(t,b,{defaultValue:a});}):typeof N=="string"&&n.addKey(t,N,{defaultValue:a});});}):typeof T=="string"&&n.addKey(t,T,{defaultValue:a});});});}}));}if(s.dialogue){let l=[];Array.isArray(s.dialogue)?l=[s.dialogue]:l=n.getConditionalsThenElse(s.dialogue),l.forEach(c=>{if(typeof c=="string")n.addKey(t,c,{defaultValue:a});else if("text"in c){let u=n.getConditionalsThenElse(c.text);typeof u=="string"&&(u=[u]),u.forEach(p=>{typeof p=="string"?n.addKey(t,p,{defaultValue:a}):n.getConditionalsThenElse(p).forEach(g=>{typeof g=="string"?n.addKey(t,g,{defaultValue:a}):Array.isArray(g)&&g.forEach(T=>{typeof T=="string"?n.addKey(t,T,{defaultValue:a}):n.getConditionalsThenElse(T).forEach(V=>{typeof V=="string"&&n.addKey(t,V,{defaultValue:a});});});});});}});}s.conditionalStep&&n.getConditionalsThenElse(s.conditionalStep).forEach(c=>{Array.isArray(c)?n.generateJsonTranslation(c,t,r):n.generateJsonTranslation([c],t,r);});}),t}};w(n,"_beforeToTranslate"),w(n,"_translate",i=>i),w(n,"_afterToTranslate");var C=n;var S=C;async function L(e){let i=unifier.JsonUnifier.getLogichValue(e);if(i)switch(i.type){case "assets":switch(i.operationType){case "load":await pixiVn.Assets.load(i.aliases);break;case "lazyload":pixiVn.Assets.backgroundLoad(i.aliases);break}break;case "bundle":switch(i.operationType){case "load":await pixiVn.Assets.loadBundle(i.aliases);break;case "lazyload":pixiVn.Assets.backgroundLoadBundle(i.aliases);break}break}}var d;(a=>(a.log=(s,...l)=>console.log(`[Pixi\u2019VN Json] ${s}`,...l),a.warn=(s,...l)=>console.warn(`[Pixi\u2019VN Json] ${s}`,...l),a.error=(s,...l)=>console.error(`[Pixi\u2019VN Json] ${s}`,...l),a.info=(s,...l)=>console.info(`[Pixi\u2019VN Json] ${s}`,...l)))(d||(d={}));async function R(e,i,t){switch(t.type){case "fade":await pixiVn.showWithFade(i.alias,e,t.props,t.priority);break;case "dissolve":await pixiVn.showWithDissolve(i.alias,e,t.props,t.priority);break;case "movein":case "moveout":await pixiVn.moveIn(i.alias,e,t.props,t.priority);break;case "zoomin":case "zoomout":await pixiVn.zoomIn(i.alias,e,t.props,t.priority);break;case "pushin":case "pushout":await pixiVn.pushIn(i.alias,e,t.props,t.priority);break}}function O(e){if(e.transition)switch(e.transition.type){case "fade":pixiVn.removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":pixiVn.removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":pixiVn.moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":pixiVn.zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":pixiVn.pushOut(e.alias,e.transition.props,e.transition.priority);break}else pixiVn.canvas.remove(e.alias);}async function G(e){switch(e.operationType){case "show":if(e.transition){let t=new pixiVn.ImageSprite(e.props,e.url||e.alias);await R(t,e,e.transition);}else await pixiVn.showImage(e.alias,e.url,e.props);break;case "edit":let i=pixiVn.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):d.error(`Image with alias ${e.alias} not found.`);break;case "remove":O(e);break}}async function M(e){switch(e.operationType){case "show":if(e.transition){let a=new pixiVn.VideoSprite(e.props,e.url||e.alias);await R(a,e,e.transition);}else await pixiVn.showVideo(e.alias,e.url,e.props);break;case "edit":let i=pixiVn.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):d.error(`Video with alias ${e.alias} not found.`);break;case "remove":O(e);break;case "pause":let t=pixiVn.canvas.find(e.alias);t?t.paused=true:d.error(`Video with alias ${e.alias} not found.`);break;case "resume":let r=pixiVn.canvas.find(e.alias);r?r.paused=false:d.error(`Video with alias ${e.alias} not found.`);break}}async function $(e){switch(e.operationType){case "show":if(e.transition){let t=new pixiVn.ImageContainer(e.props,e.urls);await R(t,e,e.transition);}else await pixiVn.showImageContainer(e.alias,e.urls,e.props);break;case "edit":let i=pixiVn.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):d.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":O(e);break}}async function F(e){switch(e.operationType){case "edit":try{let i=pixiVn.canvas.find(e.alias);i?e.props&&(i.memory={...i.memory,...e.props}):d.error(`Canvas Element with alias ${e.alias} not found.`);}catch(i){d.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,i);}break;case "remove":O(e);break}}function _(e){switch(e.type){case "fade":let i=new pixiVn.FadeAlphaTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,i);break;case "move":let t=new pixiVn.MoveTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,t);break;case "rotate":let r=new pixiVn.RotateTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,r);break;case "zoom":let a=new pixiVn.ZoomTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,a);break}}async function K(e){switch(e.type){case "shake":await pixiVn.shakeEffect(e.alias,e.props,e.priority);break}}function U(e){switch(e.type){case "animate":pixiVn.canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":pixiVn.canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function z(e){switch(e.operationType){case "request":pixiVn.narration.requestInput({type:e.valueType},e.defaultValue);break}}function X(e){switch(e.operationType){case "play":pixiVn.sound.play(e.alias,e.props);break;case "stop":pixiVn.sound.stop(e.alias);break;case "pause":pixiVn.sound.pause(e.alias);break;case "resume":pixiVn.sound.resume(e.alias);break;case "volume":pixiVn.sound.volume(e.alias,e.value);break}}function W(e){let i=o(e.value),t;switch(i&&typeof i=="object"&&"type"in i?t=o(i):t=i,e.storageType){case "flagStorage":pixiVn.storage.setFlag(e.key,e.value);break;case "storage":pixiVn.storage.setVariable(e.key,t);break;case "tempstorage":pixiVn.storage.setTempVariable(e.key,t);break;case "params":let r=pixiVn.storage.getVariable(`${J}${pixiVn.narration.openedLabels.length-1}`)||[];r&&r.length-1>=e.key&&(r[e.key]=t),pixiVn.storage.setTempVariable(`${J}${pixiVn.narration.openedLabels.length-1}`,r);break}}function o(e){let i=Ee(e);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return be(i);case "arithmetic":case "arithmeticsingle":return Ne(i);case "compare":case "valueCondition":case "union":return Pe(i)}return i}function Ne(e){let i=o(e.leftValue);switch(e.type){case "arithmetic":let t=o(e.rightValue);switch(e.operator){case "*":return i*t;case "/":return i/t;case "+":return i+t;case "-":return i-t;case "%":return i%t;case "POW":return Math.pow(i,t);case "RANDOM":return pixiVn.narration.getRandomNumber(i,t)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(i);case "FLOOR":return Math.floor(i);case "FLOAT":return parseFloat(i)}break}}function be(e){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return pixiVn.storage.getVariable(e.key);case "flagStorage":return pixiVn.storage.getFlag(e.key);case "label":return pixiVn.narration.getTimesLabelOpened(e.label);case "choice":return pixiVn.narration.getTimesChoiceMade(e.index);case "logic":return o(e.operation);case "params":let i=pixiVn.storage.getVariable(`${J}${pixiVn.narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];d.warn("getValue params not found");return}return e}function Pe(e){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":let i=o(e.leftValue),t=o(e.rightValue);switch(e.operator){case "==":return i===t;case "!=":return i!==t;case "<":return i<t;case "<=":return i<=t;case ">":return i>t;case ">=":return i>=t;case "CONTAINS":return i.toString().includes(t.toString())}break;case "valueCondition":return !!o(e.value);case "union":return Je(e)}return !!e}function Je(e){if(e.unionType==="not")return !o(e.condition);let i=e.unionType==="and";for(let t=0;t<e.conditions.length;t++)if(i=o(e.conditions[t])||false,e.unionType==="and"){if(!i)return false}else if(i)return true;return i}function Ce(e,i){return Math.floor(Math.random()*(i-e+1)+e)}function Ee(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return we(e);case "ifelse":return o(e.condition)?o(e.then):o(e.else);case "stepswitch":let t=o(e.elements)||[];if(t.length===0){d.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let r=Ce(0,t.length-1);return o(t[r]);case "loop":let a=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return a>t.length-1&&(a=a%t.length),o(t[a]);case "sequential":let s,l=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(s=o(t[t.length-1])),l>t.length-1?s:o(t[l]);case "sequentialrandom":let c=pixiVn.NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:e.nestedId,onceOnly:true});if(c==null&&e.end=="lastItem"){let u=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!u||!u?.usedRandomNumbers){d.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let p=u.usedRandomNumbers[`0-${t.length-1}`];return o(t[p[p.length-1]])}if(c==null){d.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return o(t[c])}}return e}function v(e){if(e.conditionalStep){let i=pixiVn.createExportableElement(o(e.conditionalStep));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operations===void 0&&delete i?.operations,i){let t={...e,conditionalStep:void 0,...i};return v(t)}else pixiVn.storage.getFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return e}function we(e){let i=e.firstItem,t=[];e.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(s=>{let l=o(s);t.push(l);});else {let s=o(a);t.push(s);}});let r=i?[i,...t]:t;if(r.length===0){d.warn("combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return S.t(r);if(typeof r[0]=="object"){let a=r,s,l=a.map((f,x)=>{f=v(f);let m=o(f.dialogue)||"";return x===0?(s=o(f.glueEnabled)||false,m):(typeof m=="object"&&"text"in m&&(m=m.character+": "+m.text),s===false&&(m=`
1
+ 'use strict';var importer=require('@drincs/pixi-vn-json/importer'),translator=require('@drincs/pixi-vn-json/translator'),unifier=require('@drincs/pixi-vn-json/unifier'),pixiVn=require('@drincs/pixi-vn'),narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage');var y="___param___";async function E(e){let i=unifier.JsonUnifier.getLogichValue(e);if(i)switch(i.type){case "assets":switch(i.operationType){case "load":await pixiVn.Assets.load(i.aliases);break;case "lazyload":pixiVn.Assets.backgroundLoad(i.aliases);break}break;case "bundle":switch(i.operationType){case "load":await pixiVn.Assets.loadBundle(i.aliases);break;case "lazyload":pixiVn.Assets.backgroundLoadBundle(i.aliases);break}break}}var l;(t=>(t.log=(o,...u)=>console.log(`[Pixi\u2019VN Json] ${o}`,...u),t.warn=(o,...u)=>console.warn(`[Pixi\u2019VN Json] ${o}`,...u),t.error=(o,...u)=>console.error(`[Pixi\u2019VN Json] ${o}`,...u),t.info=(o,...u)=>console.info(`[Pixi\u2019VN Json] ${o}`,...u)))(l||(l={}));async function w(e,i,a){switch(a.type){case "fade":await pixiVn.showWithFade(i.alias,e,a.props,a.priority);break;case "dissolve":await pixiVn.showWithDissolve(i.alias,e,a.props,a.priority);break;case "movein":case "moveout":await pixiVn.moveIn(i.alias,e,a.props,a.priority);break;case "zoomin":case "zoomout":await pixiVn.zoomIn(i.alias,e,a.props,a.priority);break;case "pushin":case "pushout":await pixiVn.pushIn(i.alias,e,a.props,a.priority);break}}function N(e){if(e.transition)switch(e.transition.type){case "fade":pixiVn.removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":pixiVn.removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":pixiVn.moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":pixiVn.zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":pixiVn.pushOut(e.alias,e.transition.props,e.transition.priority);break}else pixiVn.canvas.remove(e.alias);}async function I(e){switch(e.operationType){case "show":if(e.transition){let a=new pixiVn.ImageSprite(e.props,e.url||e.alias);await w(a,e,e.transition);}else await pixiVn.showImage(e.alias,e.url,e.props);break;case "edit":let i=pixiVn.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):l.error(`Image with alias ${e.alias} not found.`);break;case "remove":N(e);break}}async function v(e){switch(e.operationType){case "show":if(e.transition){let t=new pixiVn.VideoSprite(e.props,e.url||e.alias);await w(t,e,e.transition);}else await pixiVn.showVideo(e.alias,e.url,e.props);break;case "edit":let i=pixiVn.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):l.error(`Video with alias ${e.alias} not found.`);break;case "remove":N(e);break;case "pause":let a=pixiVn.canvas.find(e.alias);a?a.paused=true:l.error(`Video with alias ${e.alias} not found.`);break;case "resume":let r=pixiVn.canvas.find(e.alias);r?r.paused=false:l.error(`Video with alias ${e.alias} not found.`);break}}async function A(e){switch(e.operationType){case "show":if(e.transition){let a=new pixiVn.ImageContainer(e.props,e.urls);await w(a,e,e.transition);}else await pixiVn.showImageContainer(e.alias,e.urls,e.props);break;case "edit":let i=pixiVn.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):l.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":N(e);break}}async function _(e){switch(e.operationType){case "edit":try{let i=pixiVn.canvas.find(e.alias);i?e.props&&(i.memory={...i.memory,...e.props}):l.error(`Canvas Element with alias ${e.alias} not found.`);}catch(i){l.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,i);}break;case "remove":N(e);break}}function R(e){switch(e.type){case "fade":let i=new pixiVn.FadeAlphaTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,i);break;case "move":let a=new pixiVn.MoveTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,a);break;case "rotate":let r=new pixiVn.RotateTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,r);break;case "zoom":let t=new pixiVn.ZoomTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,t);break}}async function L(e){switch(e.type){case "shake":await pixiVn.shakeEffect(e.alias,e.props,e.priority);break}}function D(e){switch(e.type){case "animate":pixiVn.canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":pixiVn.canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function G(e){switch(e.operationType){case "request":pixiVn.narration.requestInput({type:e.valueType},e.defaultValue);break}}function M(e){switch(e.operationType){case "play":pixiVn.sound.play(e.alias,e.props);break;case "stop":pixiVn.sound.stop(e.alias);break;case "pause":pixiVn.sound.pause(e.alias);break;case "resume":pixiVn.sound.resume(e.alias);break;case "volume":pixiVn.sound.volume(e.alias,e.value);break}}function F(e){try{if(typeof e>"u")return e;let i=JSON.stringify(e);return JSON.parse(i)}catch(i){throw l.error("Error creating exportable element",e,i),new Error("[Pixi\u2019VN] Error creating exportable element")}}function $(e){let i=n(e.value),a;switch(i&&typeof i=="object"&&"type"in i?a=n(i):a=i,e.storageType){case "flagStorage":storage.storage.setFlag(e.key,e.value);break;case "storage":storage.storage.setVariable(e.key,a);break;case "tempstorage":storage.storage.setTempVariable(e.key,a);break;case "params":let r=storage.storage.getVariable(`${y}${narration.narration.openedLabels.length-1}`)||[];r&&r.length-1>=e.key&&(r[e.key]=a),storage.storage.setTempVariable(`${y}${narration.narration.openedLabels.length-1}`,r);break}}function n(e){let i=Ne(e);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return xe(i);case "arithmetic":case "arithmeticsingle":return Ve(i);case "compare":case "valueCondition":case "union":return ye(i)}return i}function Ve(e){let i=n(e.leftValue);switch(e.type){case "arithmetic":let a=n(e.rightValue);switch(e.operator){case "*":return i*a;case "/":return i/a;case "+":return i+a;case "-":return i-a;case "%":return i%a;case "POW":return Math.pow(i,a);case "RANDOM":return narration.narration.getRandomNumber(i,a)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(i);case "FLOOR":return Math.floor(i);case "FLOAT":return parseFloat(i)}break}}function xe(e){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return storage.storage.getVariable(e.key);case "flagStorage":return storage.storage.getFlag(e.key);case "label":return narration.narration.getTimesLabelOpened(e.label);case "choice":return narration.narration.getTimesChoiceMade(e.index);case "logic":return n(e.operation);case "params":let i=storage.storage.getVariable(`${y}${narration.narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];l.warn("getValue params not found");return}return e}function ye(e){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":let i=n(e.leftValue),a=n(e.rightValue);switch(e.operator){case "==":return i===a;case "!=":return i!==a;case "<":return i<a;case "<=":return i<=a;case ">":return i>a;case ">=":return i>=a;case "CONTAINS":return i.toString().includes(a.toString())}break;case "valueCondition":return !!n(e.value);case "union":return he(e)}return !!e}function he(e){if(e.unionType==="not")return !n(e.condition);let i=e.unionType==="and";for(let a=0;a<e.conditions.length;a++)if(i=n(e.conditions[a])||false,e.unionType==="and"){if(!i)return false}else if(i)return true;return i}function Te(e,i){return Math.floor(Math.random()*(i-e+1)+e)}function Ne(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return be(e);case "ifelse":return n(e.condition)?n(e.then):n(e.else);case "stepswitch":let a=n(e.elements)||[];if(a.length===0){l.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let r=Te(0,a.length-1);return n(a[r]);case "loop":let t=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return t>a.length-1&&(t=t%a.length),n(a[t]);case "sequential":let o,u=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(o=n(a[a.length-1])),u>a.length-1?o:n(a[u]);case "sequentialrandom":let p=narration.NarrationManagerStatic.getRandomNumber(0,a.length-1,{nestedId:e.nestedId,onceOnly:true});if(p==null&&e.end=="lastItem"){let g=narration.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!g||!g?.usedRandomNumbers){l.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let x=g.usedRandomNumbers[`0-${a.length-1}`];return n(a[x[x.length-1]])}if(p==null){l.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return n(a[p])}}return e}function P(e){if(e.conditionalStep){let i=F(n(e.conditionalStep));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operations===void 0&&delete i?.operations,i){let a={...e,conditionalStep:void 0,...i};return P(a)}else storage.storage.getFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return e}function be(e){let i=e.firstItem,a=[];e.secondConditionalItem?.forEach(t=>{if(Array.isArray(t))t.forEach(o=>{let u=n(o);a.push(u);});else {let o=n(t);a.push(o);}});let r=i?[i,...a]:a;if(r.length===0){l.warn("combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return translator.translator.t(r);if(typeof r[0]=="object"){let t=r,o,u=t.map((s,m)=>{s=P(s);let c=n(s.dialogue)||"";return m===0?(o=n(s.glueEnabled)||false,c):(typeof c=="object"&&"text"in c&&(c=c.character+": "+c.text),o===false&&(c=`
2
2
 
3
- `+m),s=o(f.glueEnabled)||false,m)}),c=o(l[0]),u=typeof c=="object"&&"character"in c?c.character:void 0,p=l.flatMap(f=>{let x;f&&typeof f=="object"&&"text"in f?x=f.text:x=f;let m;return Array.isArray(x)?m=x.map(q=>{let Y=o(q);return S.t(`${Y}`)}):m=o(x)||"",S.t(m)}),A=a.find(f=>f.end),g=a.find(f=>f.choices),T=false,V=false;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),T=a[a.length-1].glueEnabled,V=a.reverse().find(f=>!(f.operations&&(!f.dialogue||!f.choices)))?.goNextStep);let N=a.find(f=>f.labelToOpen),b=[];return a.forEach(f=>{f.operations&&b.forEach(x=>{b.push(x);});}),{dialogue:u?{character:u,text:p}:p,end:A?.end,choices:g?.choices,glueEnabled:T,goNextStep:V,labelToOpen:N?.labelToOpen,operations:b}}}function fi(){unifier.JsonUnifier.init({animateOperation:U,canvasElementOperation:F,effectOperation:K,imageContainerOperation:$,imageOperation:G,inputOperation:z,loadAssets:L,soundOperation:X,tickerOperation:_,videoOperation:M,setStorageValue:W,getLogichValue:o,getConditionalStep:v});}exports.PIXIVNJSON_PARAM_ID=J;exports.init=fi;exports.translator=S;Object.keys(importer).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return importer[k]}})});Object.keys(unifier).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return unifier[k]}})});
3
+ `+c),o=n(s.glueEnabled)||false,c)}),p=n(u[0]),g=typeof p=="object"&&"character"in p?p.character:void 0,x=u.flatMap(s=>{let m;s&&typeof s=="object"&&"text"in s?m=s.text:m=s;let c;return Array.isArray(m)?c=m.map(X=>{let W=n(X);return translator.translator.t(`${W}`)}):c=n(m)||"",translator.translator.t(c)}),j=t.find(s=>s.end),U=t.find(s=>s.choices),C=false,O=false;t.length>0&&(t[0].glueEnabled&&t[0].goNextStep&&t[0].dialogue===void 0&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),C=t[t.length-1].glueEnabled,O=t.reverse().find(s=>!(s.operations&&(!s.dialogue||!s.choices)))?.goNextStep);let z=t.find(s=>s.labelToOpen),J=[];return t.forEach(s=>{s.operations&&J.forEach(m=>{J.push(m);});}),{dialogue:g?{character:g,text:x}:x,end:j?.end,choices:U?.choices,glueEnabled:C,goNextStep:O,labelToOpen:z?.labelToOpen,operations:J}}}function ni(){unifier.JsonUnifier.init({animateOperation:D,canvasElementOperation:_,effectOperation:L,imageContainerOperation:A,imageOperation:I,inputOperation:G,loadAssets:E,soundOperation:M,tickerOperation:R,videoOperation:v,setStorageValue:$,getLogichValue:n,getConditionalStep:P});}exports.PIXIVNJSON_PARAM_ID=y;exports.init=ni;Object.keys(importer).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return importer[k]}})});Object.keys(translator).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return translator[k]}})});Object.keys(unifier).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return unifier[k]}})});
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from '@drincs/pixi-vn-json/importer';
2
+ export * from '@drincs/pixi-vn-json/translator';
2
3
  export * from '@drincs/pixi-vn-json/unifier';
3
4
  import { StorageElementType, CanvasBaseInterface, ImageSprite, KeyframesType, AnimationOptions, UPDATE_PRIORITY, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions, ShakeEffectProps, FadeAlphaTickerProps, MoveTickerProps, RotateTickerProps, ZoomTickerProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, ContainerOptions, ContainerMemory, SoundPlayOptions, LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
4
5
 
@@ -574,37 +575,6 @@ interface PixiVNJson {
574
575
  labels?: PixiVNJsonLabels;
575
576
  }
576
577
 
577
- declare class TranslatorManager {
578
- private static _beforeToTranslate;
579
- private static _translate;
580
- private static _afterToTranslate;
581
- static t<T = string | string[]>(key: T): T;
582
- static set beforeToTranslate(value: (key: string) => string);
583
- static set translate(value: (key: string) => string);
584
- static get translate(): (key: string) => string;
585
- static set afterToTranslate(value: (key: string) => string);
586
- private static addKey;
587
- private static getConditionalsThenElse;
588
- /**
589
- * Generates a JSON translation object from the provided labels.
590
- * @param labels The labels to translate.
591
- * @param json The JSON object to populate with translations.
592
- * @param options Options for translation, including default value handling.
593
- * @returns The populated JSON object with translations.
594
- */
595
- static generateJsonTranslation(labels: PixiVNJsonLabelStep[], json?: object, options?: {
596
- /**
597
- * Default value to use when a key is not found.
598
- * - "empty_string": Use an empty string as the default value.
599
- * - "copy_key": Use the key itself as the default value.
600
- * @default "copy_key"
601
- */
602
- defaultValue?: "empty_string" | "copy_key";
603
- }): object;
604
- }
605
-
606
- declare const translator: typeof TranslatorManager;
607
-
608
578
  declare function init(): void;
609
579
 
610
- export { PIXIVNJSON_PARAM_ID, type PixiVNJson, type PixiVNJsonAnimateBase, type PixiVNJsonAnimateSequence, type PixiVNJsonArithmeticOperations, type PixiVNJsonArithmeticOperationsArithmetic, type PixiVNJsonArithmeticOperationsArithmeticSingle, type PixiVNJsonCanvas, type PixiVNJsonCanvasAnimate, type PixiVNJsonCanvasEdit, type PixiVNJsonCanvasEffect, type PixiVNJsonCanvasRemove, type PixiVNJsonCanvasShow, type PixiVNJsonCanvasTicker, type PixiVNJsonChoice, type PixiVNJsonChoiceGet, type PixiVNJsonChoices, type PixiVNJsonComparation, type PixiVNJsonConditionalOperation, type PixiVNJsonConditionalResultToCombine, type PixiVNJsonConditionalStatements, type PixiVNJsonConditions, type PixiVNJsonDialog, type PixiVNJsonDialogText, type PixiVNJsonIfElse, type PixiVNJsonInput, type PixiVNJsonLabelGet, type PixiVNJsonLabelStep, type PixiVNJsonLabelToOpen, type PixiVNJsonLabels, type PixiVNJsonLogicGet, type PixiVNJsonMediaTransiotions, type PixiVNJsonOperation, type PixiVNJsonOperationString, type PixiVNJsonParamGet, type PixiVNJsonSound, type PixiVNJsonStepSwitch, type PixiVNJsonStepSwitchElementType, type PixiVNJsonStepSwitchElementsType, type PixiVNJsonStorageGet, type PixiVNJsonUnionCondition, type PixiVNJsonValueGet, type PixiVNJsonValueSet, init, translator };
580
+ export { PIXIVNJSON_PARAM_ID, type PixiVNJson, type PixiVNJsonAnimateBase, type PixiVNJsonAnimateSequence, type PixiVNJsonArithmeticOperations, type PixiVNJsonArithmeticOperationsArithmetic, type PixiVNJsonArithmeticOperationsArithmeticSingle, type PixiVNJsonCanvas, type PixiVNJsonCanvasAnimate, type PixiVNJsonCanvasEdit, type PixiVNJsonCanvasEffect, type PixiVNJsonCanvasRemove, type PixiVNJsonCanvasShow, type PixiVNJsonCanvasTicker, type PixiVNJsonChoice, type PixiVNJsonChoiceGet, type PixiVNJsonChoices, type PixiVNJsonComparation, type PixiVNJsonConditionalOperation, type PixiVNJsonConditionalResultToCombine, type PixiVNJsonConditionalStatements, type PixiVNJsonConditions, type PixiVNJsonDialog, type PixiVNJsonDialogText, type PixiVNJsonIfElse, type PixiVNJsonInput, type PixiVNJsonLabelGet, type PixiVNJsonLabelStep, type PixiVNJsonLabelToOpen, type PixiVNJsonLabels, type PixiVNJsonLogicGet, type PixiVNJsonMediaTransiotions, type PixiVNJsonOperation, type PixiVNJsonOperationString, type PixiVNJsonParamGet, type PixiVNJsonSound, type PixiVNJsonStepSwitch, type PixiVNJsonStepSwitchElementType, type PixiVNJsonStepSwitchElementsType, type PixiVNJsonStorageGet, type PixiVNJsonUnionCondition, type PixiVNJsonValueGet, type PixiVNJsonValueSet, init };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from '@drincs/pixi-vn-json/importer';
2
+ export * from '@drincs/pixi-vn-json/translator';
2
3
  export * from '@drincs/pixi-vn-json/unifier';
3
4
  import { StorageElementType, CanvasBaseInterface, ImageSprite, KeyframesType, AnimationOptions, UPDATE_PRIORITY, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions, ShakeEffectProps, FadeAlphaTickerProps, MoveTickerProps, RotateTickerProps, ZoomTickerProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, ContainerOptions, ContainerMemory, SoundPlayOptions, LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
4
5
 
@@ -574,37 +575,6 @@ interface PixiVNJson {
574
575
  labels?: PixiVNJsonLabels;
575
576
  }
576
577
 
577
- declare class TranslatorManager {
578
- private static _beforeToTranslate;
579
- private static _translate;
580
- private static _afterToTranslate;
581
- static t<T = string | string[]>(key: T): T;
582
- static set beforeToTranslate(value: (key: string) => string);
583
- static set translate(value: (key: string) => string);
584
- static get translate(): (key: string) => string;
585
- static set afterToTranslate(value: (key: string) => string);
586
- private static addKey;
587
- private static getConditionalsThenElse;
588
- /**
589
- * Generates a JSON translation object from the provided labels.
590
- * @param labels The labels to translate.
591
- * @param json The JSON object to populate with translations.
592
- * @param options Options for translation, including default value handling.
593
- * @returns The populated JSON object with translations.
594
- */
595
- static generateJsonTranslation(labels: PixiVNJsonLabelStep[], json?: object, options?: {
596
- /**
597
- * Default value to use when a key is not found.
598
- * - "empty_string": Use an empty string as the default value.
599
- * - "copy_key": Use the key itself as the default value.
600
- * @default "copy_key"
601
- */
602
- defaultValue?: "empty_string" | "copy_key";
603
- }): object;
604
- }
605
-
606
- declare const translator: typeof TranslatorManager;
607
-
608
578
  declare function init(): void;
609
579
 
610
- export { PIXIVNJSON_PARAM_ID, type PixiVNJson, type PixiVNJsonAnimateBase, type PixiVNJsonAnimateSequence, type PixiVNJsonArithmeticOperations, type PixiVNJsonArithmeticOperationsArithmetic, type PixiVNJsonArithmeticOperationsArithmeticSingle, type PixiVNJsonCanvas, type PixiVNJsonCanvasAnimate, type PixiVNJsonCanvasEdit, type PixiVNJsonCanvasEffect, type PixiVNJsonCanvasRemove, type PixiVNJsonCanvasShow, type PixiVNJsonCanvasTicker, type PixiVNJsonChoice, type PixiVNJsonChoiceGet, type PixiVNJsonChoices, type PixiVNJsonComparation, type PixiVNJsonConditionalOperation, type PixiVNJsonConditionalResultToCombine, type PixiVNJsonConditionalStatements, type PixiVNJsonConditions, type PixiVNJsonDialog, type PixiVNJsonDialogText, type PixiVNJsonIfElse, type PixiVNJsonInput, type PixiVNJsonLabelGet, type PixiVNJsonLabelStep, type PixiVNJsonLabelToOpen, type PixiVNJsonLabels, type PixiVNJsonLogicGet, type PixiVNJsonMediaTransiotions, type PixiVNJsonOperation, type PixiVNJsonOperationString, type PixiVNJsonParamGet, type PixiVNJsonSound, type PixiVNJsonStepSwitch, type PixiVNJsonStepSwitchElementType, type PixiVNJsonStepSwitchElementsType, type PixiVNJsonStorageGet, type PixiVNJsonUnionCondition, type PixiVNJsonValueGet, type PixiVNJsonValueSet, init, translator };
580
+ export { PIXIVNJSON_PARAM_ID, type PixiVNJson, type PixiVNJsonAnimateBase, type PixiVNJsonAnimateSequence, type PixiVNJsonArithmeticOperations, type PixiVNJsonArithmeticOperationsArithmetic, type PixiVNJsonArithmeticOperationsArithmeticSingle, type PixiVNJsonCanvas, type PixiVNJsonCanvasAnimate, type PixiVNJsonCanvasEdit, type PixiVNJsonCanvasEffect, type PixiVNJsonCanvasRemove, type PixiVNJsonCanvasShow, type PixiVNJsonCanvasTicker, type PixiVNJsonChoice, type PixiVNJsonChoiceGet, type PixiVNJsonChoices, type PixiVNJsonComparation, type PixiVNJsonConditionalOperation, type PixiVNJsonConditionalResultToCombine, type PixiVNJsonConditionalStatements, type PixiVNJsonConditions, type PixiVNJsonDialog, type PixiVNJsonDialogText, type PixiVNJsonIfElse, type PixiVNJsonInput, type PixiVNJsonLabelGet, type PixiVNJsonLabelStep, type PixiVNJsonLabelToOpen, type PixiVNJsonLabels, type PixiVNJsonLogicGet, type PixiVNJsonMediaTransiotions, type PixiVNJsonOperation, type PixiVNJsonOperationString, type PixiVNJsonParamGet, type PixiVNJsonSound, type PixiVNJsonStepSwitch, type PixiVNJsonStepSwitchElementType, type PixiVNJsonStepSwitchElementsType, type PixiVNJsonStorageGet, type PixiVNJsonUnionCondition, type PixiVNJsonValueGet, type PixiVNJsonValueSet, init };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- export*from'@drincs/pixi-vn-json/importer';import {JsonUnifier}from'@drincs/pixi-vn-json/unifier';export*from'@drincs/pixi-vn-json/unifier';import {createExportableElement,storage,SYSTEM_RESERVED_STORAGE_KEYS,narration,canvas,VideoSprite,showVideo,ZoomTicker,RotateTicker,MoveTicker,FadeAlphaTicker,sound,Assets,ImageSprite,showImage,ImageContainer,showImageContainer,shakeEffect,NarrationManagerStatic,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade}from'@drincs/pixi-vn';var H=Object.defineProperty;var B=(e,i,t)=>i in e?H(e,i,{enumerable:true,configurable:true,writable:true,value:t}):e[i]=t;var w=(e,i,t)=>B(e,typeof i!="symbol"?i+"":i,t);var J="___param___";var n=class n{static t(i){return Array.isArray(i)?i.map(t=>n.translate(`${t}`)):n.translate(`${i}`)}static set beforeToTranslate(i){n._beforeToTranslate=i;}static set translate(i){n._translate=i;}static get translate(){return i=>{let t=i;return n._beforeToTranslate&&(t=n._beforeToTranslate(t)),t=n._translate(t),n._afterToTranslate&&(t=n._afterToTranslate(t)),t}}static set afterToTranslate(i){n._afterToTranslate=i;}static addKey(i,t,r){let a=r.defaultValue||"empty_string";typeof t=="string"&&(t=[t]),Array.isArray(t)&&t.forEach(s=>{i[s]===void 0&&(a==="empty_string"?i[s]="":a==="copy_key"&&(n._beforeToTranslate?i[s]=n._beforeToTranslate(s):i[s]=s));});}static getConditionalsThenElse(i,t=[]){if(typeof i=="object"&&i&&"type"in i)if(i.type==="ifelse")i.then&&n.getConditionalsThenElse(i.then,t),i.else&&n.getConditionalsThenElse(i.else,t);else if(i.type==="stepswitch"){if(i.elements)if(Array.isArray(i.elements))i.elements.forEach(r=>{n.getConditionalsThenElse(r,t);});else if(i.elements.type==="ifelse"){let r=[];n.getConditionalsThenElse(i.elements,r),r.forEach(a=>{t.push(...a);});}else if(i.elements.type==="stepswitch"){let r=[];n.getConditionalsThenElse(i.elements,r),r.forEach(a=>{t.push(...a);});}else n.getConditionalsThenElse(i.elements,t);}else i.type==="resulttocombine"?(i.firstItem&&n.getConditionalsThenElse(i.firstItem,t),i.secondConditionalItem&&i.secondConditionalItem.forEach(r=>{n.getConditionalsThenElse(r,t);})):t.push(i);else i&&t.push(i);return t}static generateJsonTranslation(i,t={},r={}){let{defaultValue:a="copy_key"}=r;return i.forEach(s=>{if(s.choices){let l=[];Array.isArray(s.choices)?l=[s.choices]:l=n.getConditionalsThenElse(s.choices),l.forEach(c=>c.forEach(u=>{if("type"in u){let p=[];u.type==="ifelse"||u.type==="stepswitch"?n.getConditionalsThenElse(u,p):p=[u],p.map(g=>n.getConditionalsThenElse(g.text)).forEach(g=>{Array.isArray(g)&&g.forEach(T=>{Array.isArray(T)?T.forEach(V=>{typeof V=="string"?n.addKey(t,V,{defaultValue:a}):n.getConditionalsThenElse(V).forEach(N=>{Array.isArray(N)?N.forEach(b=>{typeof b=="string"&&n.addKey(t,b,{defaultValue:a});}):typeof N=="string"&&n.addKey(t,N,{defaultValue:a});});}):typeof T=="string"&&n.addKey(t,T,{defaultValue:a});});});}}));}if(s.dialogue){let l=[];Array.isArray(s.dialogue)?l=[s.dialogue]:l=n.getConditionalsThenElse(s.dialogue),l.forEach(c=>{if(typeof c=="string")n.addKey(t,c,{defaultValue:a});else if("text"in c){let u=n.getConditionalsThenElse(c.text);typeof u=="string"&&(u=[u]),u.forEach(p=>{typeof p=="string"?n.addKey(t,p,{defaultValue:a}):n.getConditionalsThenElse(p).forEach(g=>{typeof g=="string"?n.addKey(t,g,{defaultValue:a}):Array.isArray(g)&&g.forEach(T=>{typeof T=="string"?n.addKey(t,T,{defaultValue:a}):n.getConditionalsThenElse(T).forEach(V=>{typeof V=="string"&&n.addKey(t,V,{defaultValue:a});});});});});}});}s.conditionalStep&&n.getConditionalsThenElse(s.conditionalStep).forEach(c=>{Array.isArray(c)?n.generateJsonTranslation(c,t,r):n.generateJsonTranslation([c],t,r);});}),t}};w(n,"_beforeToTranslate"),w(n,"_translate",i=>i),w(n,"_afterToTranslate");var C=n;var S=C;async function L(e){let i=JsonUnifier.getLogichValue(e);if(i)switch(i.type){case "assets":switch(i.operationType){case "load":await Assets.load(i.aliases);break;case "lazyload":Assets.backgroundLoad(i.aliases);break}break;case "bundle":switch(i.operationType){case "load":await Assets.loadBundle(i.aliases);break;case "lazyload":Assets.backgroundLoadBundle(i.aliases);break}break}}var d;(a=>(a.log=(s,...l)=>console.log(`[Pixi\u2019VN Json] ${s}`,...l),a.warn=(s,...l)=>console.warn(`[Pixi\u2019VN Json] ${s}`,...l),a.error=(s,...l)=>console.error(`[Pixi\u2019VN Json] ${s}`,...l),a.info=(s,...l)=>console.info(`[Pixi\u2019VN Json] ${s}`,...l)))(d||(d={}));async function R(e,i,t){switch(t.type){case "fade":await showWithFade(i.alias,e,t.props,t.priority);break;case "dissolve":await showWithDissolve(i.alias,e,t.props,t.priority);break;case "movein":case "moveout":await moveIn(i.alias,e,t.props,t.priority);break;case "zoomin":case "zoomout":await zoomIn(i.alias,e,t.props,t.priority);break;case "pushin":case "pushout":await pushIn(i.alias,e,t.props,t.priority);break}}function O(e){if(e.transition)switch(e.transition.type){case "fade":removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":pushOut(e.alias,e.transition.props,e.transition.priority);break}else canvas.remove(e.alias);}async function G(e){switch(e.operationType){case "show":if(e.transition){let t=new ImageSprite(e.props,e.url||e.alias);await R(t,e,e.transition);}else await showImage(e.alias,e.url,e.props);break;case "edit":let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):d.error(`Image with alias ${e.alias} not found.`);break;case "remove":O(e);break}}async function M(e){switch(e.operationType){case "show":if(e.transition){let a=new VideoSprite(e.props,e.url||e.alias);await R(a,e,e.transition);}else await showVideo(e.alias,e.url,e.props);break;case "edit":let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):d.error(`Video with alias ${e.alias} not found.`);break;case "remove":O(e);break;case "pause":let t=canvas.find(e.alias);t?t.paused=true:d.error(`Video with alias ${e.alias} not found.`);break;case "resume":let r=canvas.find(e.alias);r?r.paused=false:d.error(`Video with alias ${e.alias} not found.`);break}}async function $(e){switch(e.operationType){case "show":if(e.transition){let t=new ImageContainer(e.props,e.urls);await R(t,e,e.transition);}else await showImageContainer(e.alias,e.urls,e.props);break;case "edit":let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):d.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":O(e);break}}async function F(e){switch(e.operationType){case "edit":try{let i=canvas.find(e.alias);i?e.props&&(i.memory={...i.memory,...e.props}):d.error(`Canvas Element with alias ${e.alias} not found.`);}catch(i){d.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,i);}break;case "remove":O(e);break}}function _(e){switch(e.type){case "fade":let i=new FadeAlphaTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,i);break;case "move":let t=new MoveTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,t);break;case "rotate":let r=new RotateTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,r);break;case "zoom":let a=new ZoomTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,a);break}}async function K(e){switch(e.type){case "shake":await shakeEffect(e.alias,e.props,e.priority);break}}function U(e){switch(e.type){case "animate":canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function z(e){switch(e.operationType){case "request":narration.requestInput({type:e.valueType},e.defaultValue);break}}function X(e){switch(e.operationType){case "play":sound.play(e.alias,e.props);break;case "stop":sound.stop(e.alias);break;case "pause":sound.pause(e.alias);break;case "resume":sound.resume(e.alias);break;case "volume":sound.volume(e.alias,e.value);break}}function W(e){let i=o(e.value),t;switch(i&&typeof i=="object"&&"type"in i?t=o(i):t=i,e.storageType){case "flagStorage":storage.setFlag(e.key,e.value);break;case "storage":storage.setVariable(e.key,t);break;case "tempstorage":storage.setTempVariable(e.key,t);break;case "params":let r=storage.getVariable(`${J}${narration.openedLabels.length-1}`)||[];r&&r.length-1>=e.key&&(r[e.key]=t),storage.setTempVariable(`${J}${narration.openedLabels.length-1}`,r);break}}function o(e){let i=Ee(e);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return be(i);case "arithmetic":case "arithmeticsingle":return Ne(i);case "compare":case "valueCondition":case "union":return Pe(i)}return i}function Ne(e){let i=o(e.leftValue);switch(e.type){case "arithmetic":let t=o(e.rightValue);switch(e.operator){case "*":return i*t;case "/":return i/t;case "+":return i+t;case "-":return i-t;case "%":return i%t;case "POW":return Math.pow(i,t);case "RANDOM":return narration.getRandomNumber(i,t)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(i);case "FLOOR":return Math.floor(i);case "FLOAT":return parseFloat(i)}break}}function be(e){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return storage.getVariable(e.key);case "flagStorage":return storage.getFlag(e.key);case "label":return narration.getTimesLabelOpened(e.label);case "choice":return narration.getTimesChoiceMade(e.index);case "logic":return o(e.operation);case "params":let i=storage.getVariable(`${J}${narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];d.warn("getValue params not found");return}return e}function Pe(e){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":let i=o(e.leftValue),t=o(e.rightValue);switch(e.operator){case "==":return i===t;case "!=":return i!==t;case "<":return i<t;case "<=":return i<=t;case ">":return i>t;case ">=":return i>=t;case "CONTAINS":return i.toString().includes(t.toString())}break;case "valueCondition":return !!o(e.value);case "union":return Je(e)}return !!e}function Je(e){if(e.unionType==="not")return !o(e.condition);let i=e.unionType==="and";for(let t=0;t<e.conditions.length;t++)if(i=o(e.conditions[t])||false,e.unionType==="and"){if(!i)return false}else if(i)return true;return i}function Ce(e,i){return Math.floor(Math.random()*(i-e+1)+e)}function Ee(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return we(e);case "ifelse":return o(e.condition)?o(e.then):o(e.else);case "stepswitch":let t=o(e.elements)||[];if(t.length===0){d.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let r=Ce(0,t.length-1);return o(t[r]);case "loop":let a=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return a>t.length-1&&(a=a%t.length),o(t[a]);case "sequential":let s,l=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(s=o(t[t.length-1])),l>t.length-1?s:o(t[l]);case "sequentialrandom":let c=NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:e.nestedId,onceOnly:true});if(c==null&&e.end=="lastItem"){let u=NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!u||!u?.usedRandomNumbers){d.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let p=u.usedRandomNumbers[`0-${t.length-1}`];return o(t[p[p.length-1]])}if(c==null){d.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return o(t[c])}}return e}function v(e){if(e.conditionalStep){let i=createExportableElement(o(e.conditionalStep));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operations===void 0&&delete i?.operations,i){let t={...e,conditionalStep:void 0,...i};return v(t)}else storage.getFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return e}function we(e){let i=e.firstItem,t=[];e.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(s=>{let l=o(s);t.push(l);});else {let s=o(a);t.push(s);}});let r=i?[i,...t]:t;if(r.length===0){d.warn("combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return S.t(r);if(typeof r[0]=="object"){let a=r,s,l=a.map((f,x)=>{f=v(f);let m=o(f.dialogue)||"";return x===0?(s=o(f.glueEnabled)||false,m):(typeof m=="object"&&"text"in m&&(m=m.character+": "+m.text),s===false&&(m=`
1
+ export*from'@drincs/pixi-vn-json/importer';import {translator as translator$1}from'@drincs/pixi-vn-json/translator';export*from'@drincs/pixi-vn-json/translator';import {JsonUnifier}from'@drincs/pixi-vn-json/unifier';export*from'@drincs/pixi-vn-json/unifier';import {canvas,VideoSprite,showVideo,ZoomTicker,RotateTicker,MoveTicker,FadeAlphaTicker,sound,Assets,narration as narration$1,ImageSprite,showImage,ImageContainer,showImageContainer,shakeEffect,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade}from'@drincs/pixi-vn';import {narration,NarrationManagerStatic}from'@drincs/pixi-vn/narration';import {storage,SYSTEM_RESERVED_STORAGE_KEYS}from'@drincs/pixi-vn/storage';var y="___param___";async function E(e){let i=JsonUnifier.getLogichValue(e);if(i)switch(i.type){case "assets":switch(i.operationType){case "load":await Assets.load(i.aliases);break;case "lazyload":Assets.backgroundLoad(i.aliases);break}break;case "bundle":switch(i.operationType){case "load":await Assets.loadBundle(i.aliases);break;case "lazyload":Assets.backgroundLoadBundle(i.aliases);break}break}}var l;(t=>(t.log=(o,...u)=>console.log(`[Pixi\u2019VN Json] ${o}`,...u),t.warn=(o,...u)=>console.warn(`[Pixi\u2019VN Json] ${o}`,...u),t.error=(o,...u)=>console.error(`[Pixi\u2019VN Json] ${o}`,...u),t.info=(o,...u)=>console.info(`[Pixi\u2019VN Json] ${o}`,...u)))(l||(l={}));async function w(e,i,a){switch(a.type){case "fade":await showWithFade(i.alias,e,a.props,a.priority);break;case "dissolve":await showWithDissolve(i.alias,e,a.props,a.priority);break;case "movein":case "moveout":await moveIn(i.alias,e,a.props,a.priority);break;case "zoomin":case "zoomout":await zoomIn(i.alias,e,a.props,a.priority);break;case "pushin":case "pushout":await pushIn(i.alias,e,a.props,a.priority);break}}function N(e){if(e.transition)switch(e.transition.type){case "fade":removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":pushOut(e.alias,e.transition.props,e.transition.priority);break}else canvas.remove(e.alias);}async function I(e){switch(e.operationType){case "show":if(e.transition){let a=new ImageSprite(e.props,e.url||e.alias);await w(a,e,e.transition);}else await showImage(e.alias,e.url,e.props);break;case "edit":let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):l.error(`Image with alias ${e.alias} not found.`);break;case "remove":N(e);break}}async function v(e){switch(e.operationType){case "show":if(e.transition){let t=new VideoSprite(e.props,e.url||e.alias);await w(t,e,e.transition);}else await showVideo(e.alias,e.url,e.props);break;case "edit":let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):l.error(`Video with alias ${e.alias} not found.`);break;case "remove":N(e);break;case "pause":let a=canvas.find(e.alias);a?a.paused=true:l.error(`Video with alias ${e.alias} not found.`);break;case "resume":let r=canvas.find(e.alias);r?r.paused=false:l.error(`Video with alias ${e.alias} not found.`);break}}async function A(e){switch(e.operationType){case "show":if(e.transition){let a=new ImageContainer(e.props,e.urls);await w(a,e,e.transition);}else await showImageContainer(e.alias,e.urls,e.props);break;case "edit":let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):l.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":N(e);break}}async function _(e){switch(e.operationType){case "edit":try{let i=canvas.find(e.alias);i?e.props&&(i.memory={...i.memory,...e.props}):l.error(`Canvas Element with alias ${e.alias} not found.`);}catch(i){l.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,i);}break;case "remove":N(e);break}}function R(e){switch(e.type){case "fade":let i=new FadeAlphaTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,i);break;case "move":let a=new MoveTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,a);break;case "rotate":let r=new RotateTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,r);break;case "zoom":let t=new ZoomTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,t);break}}async function L(e){switch(e.type){case "shake":await shakeEffect(e.alias,e.props,e.priority);break}}function D(e){switch(e.type){case "animate":canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function G(e){switch(e.operationType){case "request":narration$1.requestInput({type:e.valueType},e.defaultValue);break}}function M(e){switch(e.operationType){case "play":sound.play(e.alias,e.props);break;case "stop":sound.stop(e.alias);break;case "pause":sound.pause(e.alias);break;case "resume":sound.resume(e.alias);break;case "volume":sound.volume(e.alias,e.value);break}}function F(e){try{if(typeof e>"u")return e;let i=JSON.stringify(e);return JSON.parse(i)}catch(i){throw l.error("Error creating exportable element",e,i),new Error("[Pixi\u2019VN] Error creating exportable element")}}function $(e){let i=n(e.value),a;switch(i&&typeof i=="object"&&"type"in i?a=n(i):a=i,e.storageType){case "flagStorage":storage.setFlag(e.key,e.value);break;case "storage":storage.setVariable(e.key,a);break;case "tempstorage":storage.setTempVariable(e.key,a);break;case "params":let r=storage.getVariable(`${y}${narration.openedLabels.length-1}`)||[];r&&r.length-1>=e.key&&(r[e.key]=a),storage.setTempVariable(`${y}${narration.openedLabels.length-1}`,r);break}}function n(e){let i=Ne(e);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return xe(i);case "arithmetic":case "arithmeticsingle":return Ve(i);case "compare":case "valueCondition":case "union":return ye(i)}return i}function Ve(e){let i=n(e.leftValue);switch(e.type){case "arithmetic":let a=n(e.rightValue);switch(e.operator){case "*":return i*a;case "/":return i/a;case "+":return i+a;case "-":return i-a;case "%":return i%a;case "POW":return Math.pow(i,a);case "RANDOM":return narration.getRandomNumber(i,a)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(i);case "FLOOR":return Math.floor(i);case "FLOAT":return parseFloat(i)}break}}function xe(e){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return storage.getVariable(e.key);case "flagStorage":return storage.getFlag(e.key);case "label":return narration.getTimesLabelOpened(e.label);case "choice":return narration.getTimesChoiceMade(e.index);case "logic":return n(e.operation);case "params":let i=storage.getVariable(`${y}${narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];l.warn("getValue params not found");return}return e}function ye(e){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":let i=n(e.leftValue),a=n(e.rightValue);switch(e.operator){case "==":return i===a;case "!=":return i!==a;case "<":return i<a;case "<=":return i<=a;case ">":return i>a;case ">=":return i>=a;case "CONTAINS":return i.toString().includes(a.toString())}break;case "valueCondition":return !!n(e.value);case "union":return he(e)}return !!e}function he(e){if(e.unionType==="not")return !n(e.condition);let i=e.unionType==="and";for(let a=0;a<e.conditions.length;a++)if(i=n(e.conditions[a])||false,e.unionType==="and"){if(!i)return false}else if(i)return true;return i}function Te(e,i){return Math.floor(Math.random()*(i-e+1)+e)}function Ne(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return be(e);case "ifelse":return n(e.condition)?n(e.then):n(e.else);case "stepswitch":let a=n(e.elements)||[];if(a.length===0){l.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let r=Te(0,a.length-1);return n(a[r]);case "loop":let t=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return t>a.length-1&&(t=t%a.length),n(a[t]);case "sequential":let o,u=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(o=n(a[a.length-1])),u>a.length-1?o:n(a[u]);case "sequentialrandom":let p=NarrationManagerStatic.getRandomNumber(0,a.length-1,{nestedId:e.nestedId,onceOnly:true});if(p==null&&e.end=="lastItem"){let g=NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!g||!g?.usedRandomNumbers){l.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let x=g.usedRandomNumbers[`0-${a.length-1}`];return n(a[x[x.length-1]])}if(p==null){l.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return n(a[p])}}return e}function P(e){if(e.conditionalStep){let i=F(n(e.conditionalStep));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operations===void 0&&delete i?.operations,i){let a={...e,conditionalStep:void 0,...i};return P(a)}else storage.getFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return e}function be(e){let i=e.firstItem,a=[];e.secondConditionalItem?.forEach(t=>{if(Array.isArray(t))t.forEach(o=>{let u=n(o);a.push(u);});else {let o=n(t);a.push(o);}});let r=i?[i,...a]:a;if(r.length===0){l.warn("combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return translator$1.t(r);if(typeof r[0]=="object"){let t=r,o,u=t.map((s,m)=>{s=P(s);let c=n(s.dialogue)||"";return m===0?(o=n(s.glueEnabled)||false,c):(typeof c=="object"&&"text"in c&&(c=c.character+": "+c.text),o===false&&(c=`
2
2
 
3
- `+m),s=o(f.glueEnabled)||false,m)}),c=o(l[0]),u=typeof c=="object"&&"character"in c?c.character:void 0,p=l.flatMap(f=>{let x;f&&typeof f=="object"&&"text"in f?x=f.text:x=f;let m;return Array.isArray(x)?m=x.map(q=>{let Y=o(q);return S.t(`${Y}`)}):m=o(x)||"",S.t(m)}),A=a.find(f=>f.end),g=a.find(f=>f.choices),T=false,V=false;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),T=a[a.length-1].glueEnabled,V=a.reverse().find(f=>!(f.operations&&(!f.dialogue||!f.choices)))?.goNextStep);let N=a.find(f=>f.labelToOpen),b=[];return a.forEach(f=>{f.operations&&b.forEach(x=>{b.push(x);});}),{dialogue:u?{character:u,text:p}:p,end:A?.end,choices:g?.choices,glueEnabled:T,goNextStep:V,labelToOpen:N?.labelToOpen,operations:b}}}function fi(){JsonUnifier.init({animateOperation:U,canvasElementOperation:F,effectOperation:K,imageContainerOperation:$,imageOperation:G,inputOperation:z,loadAssets:L,soundOperation:X,tickerOperation:_,videoOperation:M,setStorageValue:W,getLogichValue:o,getConditionalStep:v});}export{J as PIXIVNJSON_PARAM_ID,fi as init,S as translator};
3
+ `+c),o=n(s.glueEnabled)||false,c)}),p=n(u[0]),g=typeof p=="object"&&"character"in p?p.character:void 0,x=u.flatMap(s=>{let m;s&&typeof s=="object"&&"text"in s?m=s.text:m=s;let c;return Array.isArray(m)?c=m.map(X=>{let W=n(X);return translator$1.t(`${W}`)}):c=n(m)||"",translator$1.t(c)}),j=t.find(s=>s.end),U=t.find(s=>s.choices),C=false,O=false;t.length>0&&(t[0].glueEnabled&&t[0].goNextStep&&t[0].dialogue===void 0&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),C=t[t.length-1].glueEnabled,O=t.reverse().find(s=>!(s.operations&&(!s.dialogue||!s.choices)))?.goNextStep);let z=t.find(s=>s.labelToOpen),J=[];return t.forEach(s=>{s.operations&&J.forEach(m=>{J.push(m);});}),{dialogue:g?{character:g,text:x}:x,end:j?.end,choices:U?.choices,glueEnabled:C,goNextStep:O,labelToOpen:z?.labelToOpen,operations:J}}}function ni(){JsonUnifier.init({animateOperation:D,canvasElementOperation:_,effectOperation:L,imageContainerOperation:A,imageOperation:I,inputOperation:G,loadAssets:E,soundOperation:M,tickerOperation:R,videoOperation:v,setStorageValue:$,getLogichValue:n,getConditionalStep:P});}export{y as PIXIVNJSON_PARAM_ID,ni as init};
@@ -0,0 +1 @@
1
+ 'use strict';var C=Object.defineProperty;var m=(c,e,i)=>e in c?C(c,e,{enumerable:true,configurable:true,writable:true,value:i}):c[e]=i;var d=(c,e,i)=>m(c,typeof e!="symbol"?e+"":e,i);var t=class t{static t(e){return Array.isArray(e)?e.map(i=>t.translate(`${i}`)):t.translate(`${e}`)}static set beforeToTranslate(e){t._beforeToTranslate=e;}static set translate(e){t._translate=e;}static get translate(){return e=>{let i=e;return t._beforeToTranslate&&(i=t._beforeToTranslate(i)),i=t._translate(i),t._afterToTranslate&&(i=t._afterToTranslate(i)),i}}static set afterToTranslate(e){t._afterToTranslate=e;}static addKey(e,i,r){let n=r.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(s=>{e[s]===void 0&&(n==="empty_string"?e[s]="":n==="copy_key"&&(t._beforeToTranslate?e[s]=t._beforeToTranslate(s):e[s]=s));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&t.getConditionalsThenElse(e.then,i),e.else&&t.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(r=>{t.getConditionalsThenElse(r,i);});else if(e.elements.type==="ifelse"){let r=[];t.getConditionalsThenElse(e.elements,r),r.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let r=[];t.getConditionalsThenElse(e.elements,r),r.forEach(n=>{i.push(...n);});}else t.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&t.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(r=>{t.getConditionalsThenElse(r,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},r={}){let{defaultValue:n="copy_key"}=r;return e.forEach(s=>{if(s.choices){let a=[];Array.isArray(s.choices)?a=[s.choices]:a=t.getConditionalsThenElse(s.choices),a.forEach(o=>o.forEach(l=>{if("type"in l){let g=[];l.type==="ifelse"||l.type==="stepswitch"?t.getConditionalsThenElse(l,g):g=[l],g.map(f=>t.getConditionalsThenElse(f.text)).forEach(f=>{Array.isArray(f)&&f.forEach(y=>{Array.isArray(y)?y.forEach(T=>{typeof T=="string"?t.addKey(i,T,{defaultValue:n}):t.getConditionalsThenElse(T).forEach(p=>{Array.isArray(p)?p.forEach(E=>{typeof E=="string"&&t.addKey(i,E,{defaultValue:n});}):typeof p=="string"&&t.addKey(i,p,{defaultValue:n});});}):typeof y=="string"&&t.addKey(i,y,{defaultValue:n});});});}}));}if(s.dialogue){let a=[];Array.isArray(s.dialogue)?a=[s.dialogue]:a=t.getConditionalsThenElse(s.dialogue),a.forEach(o=>{if(typeof o=="string")t.addKey(i,o,{defaultValue:n});else if("text"in o){let l=t.getConditionalsThenElse(o.text);typeof l=="string"&&(l=[l]),l.forEach(g=>{typeof g=="string"?t.addKey(i,g,{defaultValue:n}):t.getConditionalsThenElse(g).forEach(f=>{typeof f=="string"?t.addKey(i,f,{defaultValue:n}):Array.isArray(f)&&f.forEach(y=>{typeof y=="string"?t.addKey(i,y,{defaultValue:n}):t.getConditionalsThenElse(y).forEach(T=>{typeof T=="string"&&t.addKey(i,T,{defaultValue:n});});});});});}});}s.conditionalStep&&t.getConditionalsThenElse(s.conditionalStep).forEach(o=>{Array.isArray(o)?t.generateJsonTranslation(o,i,r):t.generateJsonTranslation([o],i,r);});}),i}};d(t,"_beforeToTranslate"),d(t,"_translate",e=>e),d(t,"_afterToTranslate");var h=t;var N=h;exports.translator=N;
@@ -0,0 +1,35 @@
1
+ import { P as PixiVNJsonLabelStep } from './PixiVNJsonLabelStep-CNFnTNr1.cjs';
2
+ import '@drincs/pixi-vn';
3
+
4
+ declare class TranslatorManager {
5
+ private static _beforeToTranslate;
6
+ private static _translate;
7
+ private static _afterToTranslate;
8
+ static t<T = string | string[]>(key: T): T;
9
+ static set beforeToTranslate(value: (key: string) => string);
10
+ static set translate(value: (key: string) => string);
11
+ static get translate(): (key: string) => string;
12
+ static set afterToTranslate(value: (key: string) => string);
13
+ private static addKey;
14
+ private static getConditionalsThenElse;
15
+ /**
16
+ * Generates a JSON translation object from the provided labels.
17
+ * @param labels The labels to translate.
18
+ * @param json The JSON object to populate with translations.
19
+ * @param options Options for translation, including default value handling.
20
+ * @returns The populated JSON object with translations.
21
+ */
22
+ static generateJsonTranslation(labels: PixiVNJsonLabelStep[], json?: object, options?: {
23
+ /**
24
+ * Default value to use when a key is not found.
25
+ * - "empty_string": Use an empty string as the default value.
26
+ * - "copy_key": Use the key itself as the default value.
27
+ * @default "copy_key"
28
+ */
29
+ defaultValue?: "empty_string" | "copy_key";
30
+ }): object;
31
+ }
32
+
33
+ declare const translator: typeof TranslatorManager;
34
+
35
+ export { translator };
@@ -0,0 +1,35 @@
1
+ import { P as PixiVNJsonLabelStep } from './PixiVNJsonLabelStep-CNFnTNr1.js';
2
+ import '@drincs/pixi-vn';
3
+
4
+ declare class TranslatorManager {
5
+ private static _beforeToTranslate;
6
+ private static _translate;
7
+ private static _afterToTranslate;
8
+ static t<T = string | string[]>(key: T): T;
9
+ static set beforeToTranslate(value: (key: string) => string);
10
+ static set translate(value: (key: string) => string);
11
+ static get translate(): (key: string) => string;
12
+ static set afterToTranslate(value: (key: string) => string);
13
+ private static addKey;
14
+ private static getConditionalsThenElse;
15
+ /**
16
+ * Generates a JSON translation object from the provided labels.
17
+ * @param labels The labels to translate.
18
+ * @param json The JSON object to populate with translations.
19
+ * @param options Options for translation, including default value handling.
20
+ * @returns The populated JSON object with translations.
21
+ */
22
+ static generateJsonTranslation(labels: PixiVNJsonLabelStep[], json?: object, options?: {
23
+ /**
24
+ * Default value to use when a key is not found.
25
+ * - "empty_string": Use an empty string as the default value.
26
+ * - "copy_key": Use the key itself as the default value.
27
+ * @default "copy_key"
28
+ */
29
+ defaultValue?: "empty_string" | "copy_key";
30
+ }): object;
31
+ }
32
+
33
+ declare const translator: typeof TranslatorManager;
34
+
35
+ export { translator };
@@ -0,0 +1 @@
1
+ var C=Object.defineProperty;var m=(c,e,i)=>e in c?C(c,e,{enumerable:true,configurable:true,writable:true,value:i}):c[e]=i;var d=(c,e,i)=>m(c,typeof e!="symbol"?e+"":e,i);var t=class t{static t(e){return Array.isArray(e)?e.map(i=>t.translate(`${i}`)):t.translate(`${e}`)}static set beforeToTranslate(e){t._beforeToTranslate=e;}static set translate(e){t._translate=e;}static get translate(){return e=>{let i=e;return t._beforeToTranslate&&(i=t._beforeToTranslate(i)),i=t._translate(i),t._afterToTranslate&&(i=t._afterToTranslate(i)),i}}static set afterToTranslate(e){t._afterToTranslate=e;}static addKey(e,i,r){let n=r.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(s=>{e[s]===void 0&&(n==="empty_string"?e[s]="":n==="copy_key"&&(t._beforeToTranslate?e[s]=t._beforeToTranslate(s):e[s]=s));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&t.getConditionalsThenElse(e.then,i),e.else&&t.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(r=>{t.getConditionalsThenElse(r,i);});else if(e.elements.type==="ifelse"){let r=[];t.getConditionalsThenElse(e.elements,r),r.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let r=[];t.getConditionalsThenElse(e.elements,r),r.forEach(n=>{i.push(...n);});}else t.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&t.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(r=>{t.getConditionalsThenElse(r,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},r={}){let{defaultValue:n="copy_key"}=r;return e.forEach(s=>{if(s.choices){let a=[];Array.isArray(s.choices)?a=[s.choices]:a=t.getConditionalsThenElse(s.choices),a.forEach(o=>o.forEach(l=>{if("type"in l){let g=[];l.type==="ifelse"||l.type==="stepswitch"?t.getConditionalsThenElse(l,g):g=[l],g.map(f=>t.getConditionalsThenElse(f.text)).forEach(f=>{Array.isArray(f)&&f.forEach(y=>{Array.isArray(y)?y.forEach(T=>{typeof T=="string"?t.addKey(i,T,{defaultValue:n}):t.getConditionalsThenElse(T).forEach(p=>{Array.isArray(p)?p.forEach(E=>{typeof E=="string"&&t.addKey(i,E,{defaultValue:n});}):typeof p=="string"&&t.addKey(i,p,{defaultValue:n});});}):typeof y=="string"&&t.addKey(i,y,{defaultValue:n});});});}}));}if(s.dialogue){let a=[];Array.isArray(s.dialogue)?a=[s.dialogue]:a=t.getConditionalsThenElse(s.dialogue),a.forEach(o=>{if(typeof o=="string")t.addKey(i,o,{defaultValue:n});else if("text"in o){let l=t.getConditionalsThenElse(o.text);typeof l=="string"&&(l=[l]),l.forEach(g=>{typeof g=="string"?t.addKey(i,g,{defaultValue:n}):t.getConditionalsThenElse(g).forEach(f=>{typeof f=="string"?t.addKey(i,f,{defaultValue:n}):Array.isArray(f)&&f.forEach(y=>{typeof y=="string"?t.addKey(i,y,{defaultValue:n}):t.getConditionalsThenElse(y).forEach(T=>{typeof T=="string"&&t.addKey(i,T,{defaultValue:n});});});});});}});}s.conditionalStep&&t.getConditionalsThenElse(s.conditionalStep).forEach(o=>{Array.isArray(o)?t.generateJsonTranslation(o,i,r):t.generateJsonTranslation([o],i,r);});}),i}};d(t,"_beforeToTranslate"),d(t,"_translate",e=>e),d(t,"_afterToTranslate");var h=t;var N=h;export{N as translator};
package/dist/unifier.cjs CHANGED
@@ -1 +1,3 @@
1
- 'use strict';var c=Object.defineProperty;var P=(n,i,s)=>i in n?c(n,i,{enumerable:true,configurable:true,writable:true,value:s}):n[i]=s;var o=(n,i,s)=>P(n,typeof i!="symbol"?i+"":i,s);var t;(p=>(p.log=(r,...a)=>console.log(`[Pixi\u2019VN Json] ${r}`,...a),p.warn=(r,...a)=>console.warn(`[Pixi\u2019VN Json] ${r}`,...a),p.error=(r,...a)=>console.error(`[Pixi\u2019VN Json] ${r}`,...a),p.info=(r,...a)=>console.info(`[Pixi\u2019VN Json] ${r}`,...a)))(t||(t={}));var e=class{static init(i){this._loadAssets=i.loadAssets,this._soundOperation=i.soundOperation,this._imageOperation=i.imageOperation,this._videoOperation=i.videoOperation,this._imageContainerOperation=i.imageContainerOperation,this._canvasElementOperation=i.canvasElementOperation,this._setStorageValue=i.setStorageValue,this._inputOperation=i.inputOperation,this._tickerOperation=i.tickerOperation,this._effectOperation=i.effectOperation,this._animateOperation=i.animateOperation,this._getLogichValue=i.getLogichValue,this._getConditionalStep=i.getConditionalStep;}static get loadAssets(){return this._loadAssets}static get soundOperation(){return this._soundOperation}static get imageOperation(){return this._imageOperation}static get videoOperation(){return this._videoOperation}static get imageContainerOperation(){return this._imageContainerOperation}static get canvasElementOperation(){return this._canvasElementOperation}static get setStorageValue(){return this._setStorageValue}static get inputOperation(){return this._inputOperation}static get tickerOperation(){return this._tickerOperation}static get effectOperation(){return this._effectOperation}static get animateOperation(){return this._animateOperation}static get getLogichValue(){return this._getLogichValue}static get getConditionalStep(){return this._getConditionalStep}};o(e,"_loadAssets",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_soundOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_imageOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_videoOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_imageContainerOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_canvasElementOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_setStorageValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_inputOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_tickerOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_effectOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_animateOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_getLogichValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_getConditionalStep",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});exports.JsonUnifier=e;
1
+ 'use strict';var narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage');var G=Object.defineProperty;var j=(t,e,i)=>e in t?G(t,e,{enumerable:true,configurable:true,writable:true,value:i}):t[e]=i;var f=(t,e,i)=>j(t,typeof e!="symbol"?e+"":e,i);var n=class n{static t(e){return Array.isArray(e)?e.map(i=>n.translate(`${i}`)):n.translate(`${e}`)}static set beforeToTranslate(e){n._beforeToTranslate=e;}static set translate(e){n._translate=e;}static get translate(){return e=>{let i=e;return n._beforeToTranslate&&(i=n._beforeToTranslate(i)),i=n._translate(i),n._afterToTranslate&&(i=n._afterToTranslate(i)),i}}static set afterToTranslate(e){n._afterToTranslate=e;}static addKey(e,i,l){let o=l.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===void 0&&(o==="empty_string"?e[r]="":o==="copy_key"&&(n._beforeToTranslate?e[r]=n._beforeToTranslate(r):e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&n.getConditionalsThenElse(e.then,i),e.else&&n.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(l=>{n.getConditionalsThenElse(l,i);});else if(e.elements.type==="ifelse"){let l=[];n.getConditionalsThenElse(e.elements,l),l.forEach(o=>{i.push(...o);});}else if(e.elements.type==="stepswitch"){let l=[];n.getConditionalsThenElse(e.elements,l),l.forEach(o=>{i.push(...o);});}else n.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&n.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(l=>{n.getConditionalsThenElse(l,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},l={}){let{defaultValue:o="copy_key"}=l;return e.forEach(r=>{if(r.choices){let c=[];Array.isArray(r.choices)?c=[r.choices]:c=n.getConditionalsThenElse(r.choices),c.forEach(d=>d.forEach(g=>{if("type"in g){let V=[];g.type==="ifelse"||g.type==="stepswitch"?n.getConditionalsThenElse(g,V):V=[g],V.map(m=>n.getConditionalsThenElse(m.text)).forEach(m=>{Array.isArray(m)&&m.forEach(P=>{Array.isArray(P)?P.forEach(h=>{typeof h=="string"?n.addKey(i,h,{defaultValue:o}):n.getConditionalsThenElse(h).forEach(y=>{Array.isArray(y)?y.forEach(J=>{typeof J=="string"&&n.addKey(i,J,{defaultValue:o});}):typeof y=="string"&&n.addKey(i,y,{defaultValue:o});});}):typeof P=="string"&&n.addKey(i,P,{defaultValue:o});});});}}));}if(r.dialogue){let c=[];Array.isArray(r.dialogue)?c=[r.dialogue]:c=n.getConditionalsThenElse(r.dialogue),c.forEach(d=>{if(typeof d=="string")n.addKey(i,d,{defaultValue:o});else if("text"in d){let g=n.getConditionalsThenElse(d.text);typeof g=="string"&&(g=[g]),g.forEach(V=>{typeof V=="string"?n.addKey(i,V,{defaultValue:o}):n.getConditionalsThenElse(V).forEach(m=>{typeof m=="string"?n.addKey(i,m,{defaultValue:o}):Array.isArray(m)&&m.forEach(P=>{typeof P=="string"?n.addKey(i,P,{defaultValue:o}):n.getConditionalsThenElse(P).forEach(h=>{typeof h=="string"&&n.addKey(i,h,{defaultValue:o});});});});});}});}r.conditionalStep&&n.getConditionalsThenElse(r.conditionalStep).forEach(d=>{Array.isArray(d)?n.generateJsonTranslation(d,i,l):n.generateJsonTranslation([d],i,l);});}),i}};f(n,"_beforeToTranslate"),f(n,"_translate",e=>e),f(n,"_afterToTranslate");var E=n;var S=E;var O="___param___";var u;(o=>(o.log=(r,...c)=>console.log(`[Pixi\u2019VN Json] ${r}`,...c),o.warn=(r,...c)=>console.warn(`[Pixi\u2019VN Json] ${r}`,...c),o.error=(r,...c)=>console.error(`[Pixi\u2019VN Json] ${r}`,...c),o.info=(r,...c)=>console.info(`[Pixi\u2019VN Json] ${r}`,...c)))(u||(u={}));function R(t){try{if(typeof t>"u")return t;let e=JSON.stringify(t);return JSON.parse(e)}catch(e){throw u.error("Error creating exportable element",t,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}function L(t){let e=s(t.value),i;switch(e&&typeof e=="object"&&"type"in e?i=s(e):i=e,t.storageType){case "flagStorage":storage.storage.setFlag(t.key,t.value);break;case "storage":storage.storage.setVariable(t.key,i);break;case "tempstorage":storage.storage.setTempVariable(t.key,i);break;case "params":let l=storage.storage.getVariable(`${O}${narration.narration.openedLabels.length-1}`)||[];l&&l.length-1>=t.key&&(l[t.key]=i),storage.storage.setTempVariable(`${O}${narration.narration.openedLabels.length-1}`,l);break}}function s(t){let e=K(t);if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "value":return _(e);case "arithmetic":case "arithmeticsingle":return z(e);case "compare":case "valueCondition":case "union":return F(e)}return e}function z(t){let e=s(t.leftValue);switch(t.type){case "arithmetic":let i=s(t.rightValue);switch(t.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.narration.getRandomNumber(e,i)}case "arithmeticsingle":switch(t.operator){case "INT":return parseInt(e);case "FLOOR":return Math.floor(e);case "FLOAT":return parseFloat(e)}break}}function _(t){if(t&&typeof t=="object"&&"type"in t&&t.type==="value"&&t.storageOperationType==="get")switch(t.storageType){case "storage":case "tempstorage":return storage.storage.getVariable(t.key);case "flagStorage":return storage.storage.getFlag(t.key);case "label":return narration.narration.getTimesLabelOpened(t.label);case "choice":return narration.narration.getTimesChoiceMade(t.index);case "logic":return s(t.operation);case "params":let e=storage.storage.getVariable(`${O}${narration.narration.openedLabels.length-1}`)||[];if(e&&e.length>t.key)return e[t.key];u.warn("getValue params not found");return}return t}function F(t){if(!t)return false;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case "compare":let e=s(t.leftValue),i=s(t.rightValue);switch(t.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 !!s(t.value);case "union":return M(t)}return !!t}function M(t){if(t.unionType==="not")return !s(t.condition);let e=t.unionType==="and";for(let i=0;i<t.conditions.length;i++)if(e=s(t.conditions[i])||false,t.unionType==="and"){if(!e)return false}else if(e)return true;return e}function $(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function K(t){if(Array.isArray(t)||!t)return t;if(t&&typeof t=="object"&&"type"in t)switch(t.type){case "resulttocombine":return X(t);case "ifelse":return s(t.condition)?s(t.then):s(t.else);case "stepswitch":let i=s(t.elements)||[];if(i.length===0){u.error("getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case "random":let l=$(0,i.length-1);return s(i[l]);case "loop":let o=narration.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return o>i.length-1&&(o=o%i.length),s(i[o]);case "sequential":let r,c=narration.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end=="lastItem"&&(r=s(i[i.length-1])),c>i.length-1?r:s(i[c]);case "sequentialrandom":let d=narration.NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:t.nestedId,onceOnly:true});if(d==null&&t.end=="lastItem"){let g=narration.NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!g||!g?.usedRandomNumbers){u.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let V=g.usedRandomNumbers[`0-${i.length-1}`];return s(i[V[V.length-1]])}if(d==null){u.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return s(i[d])}}return t}function b(t){if(t.conditionalStep){let e=R(s(t.conditionalStep));if(e?.glueEnabled===void 0&&delete e?.glueEnabled,e?.goNextStep===void 0&&delete e?.goNextStep,e?.end===void 0&&delete e?.end,e?.choices===void 0&&delete e?.choices,e?.dialogue===void 0&&delete e?.dialogue,e?.labelToOpen===void 0&&delete e?.labelToOpen,e?.operations===void 0&&delete e?.operations,e){let i={...t,conditionalStep:void 0,...e};return b(i)}else storage.storage.getFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return t}function X(t){let e=t.firstItem,i=[];t.secondConditionalItem?.forEach(o=>{if(Array.isArray(o))o.forEach(r=>{let c=s(r);i.push(c);});else {let r=s(o);i.push(r);}});let l=e?[e,...i]:i;if(l.length===0){u.warn("combinateResult toCheck.length === 0");return}if(typeof l[0]=="string")return S.t(l);if(typeof l[0]=="object"){let o=l,r,c=o.map((p,T)=>{p=b(p);let x=s(p.dialogue)||"";return T===0?(r=s(p.glueEnabled)||false,x):(typeof x=="object"&&"text"in x&&(x=x.character+": "+x.text),r===false&&(x=`
2
+
3
+ `+x),r=s(p.glueEnabled)||false,x)}),d=s(c[0]),g=typeof d=="object"&&"character"in d?d.character:void 0,V=c.flatMap(p=>{let T;p&&typeof p=="object"&&"text"in p?T=p.text:T=p;let x;return Array.isArray(T)?x=T.map(k=>{let D=s(k);return S.t(`${D}`)}):x=s(T)||"",S.t(x)}),w=o.find(p=>p.end),m=o.find(p=>p.choices),P=false,h=false;o.length>0&&(o[0].glueEnabled&&o[0].goNextStep&&o[0].dialogue===void 0&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),P=o[o.length-1].glueEnabled,h=o.reverse().find(p=>!(p.operations&&(!p.dialogue||!p.choices)))?.goNextStep);let y=o.find(p=>p.labelToOpen),J=[];return o.forEach(p=>{p.operations&&J.forEach(T=>{J.push(T);});}),{dialogue:g?{character:g,text:V}:V,end:w?.end,choices:m?.choices,glueEnabled:P,goNextStep:h,labelToOpen:y?.labelToOpen,operations:J}}}var a=class a{static init(e){a._loadAssets=e.loadAssets,a._soundOperation=e.soundOperation,a._imageOperation=e.imageOperation,a._videoOperation=e.videoOperation,a._imageContainerOperation=e.imageContainerOperation,a._canvasElementOperation=e.canvasElementOperation,a._setStorageValue=e.setStorageValue,a._inputOperation=e.inputOperation,a._tickerOperation=e.tickerOperation,a._effectOperation=e.effectOperation,a._animateOperation=e.animateOperation,a._getLogichValue=e.getLogichValue,a._getConditionalStep=e.getConditionalStep;}static get loadAssets(){return a._loadAssets}static get soundOperation(){return a._soundOperation}static get imageOperation(){return a._imageOperation}static get videoOperation(){return a._videoOperation}static get imageContainerOperation(){return a._imageContainerOperation}static get canvasElementOperation(){return a._canvasElementOperation}static get setStorageValue(){return a._setStorageValue}static get inputOperation(){return a._inputOperation}static get tickerOperation(){return a._tickerOperation}static get effectOperation(){return a._effectOperation}static get animateOperation(){return a._animateOperation}static get getLogichValue(){return a._getLogichValue}static get getConditionalStep(){return a._getConditionalStep}};f(a,"_loadAssets",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_soundOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_imageOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_videoOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_imageContainerOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_canvasElementOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_setStorageValue",L),f(a,"_inputOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_tickerOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_effectOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_animateOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_getLogichValue",s),f(a,"_getConditionalStep",b);var A=a;exports.JsonUnifier=A;
package/dist/unifier.mjs CHANGED
@@ -1 +1,3 @@
1
- var c=Object.defineProperty;var P=(n,i,s)=>i in n?c(n,i,{enumerable:true,configurable:true,writable:true,value:s}):n[i]=s;var o=(n,i,s)=>P(n,typeof i!="symbol"?i+"":i,s);var t;(p=>(p.log=(r,...a)=>console.log(`[Pixi\u2019VN Json] ${r}`,...a),p.warn=(r,...a)=>console.warn(`[Pixi\u2019VN Json] ${r}`,...a),p.error=(r,...a)=>console.error(`[Pixi\u2019VN Json] ${r}`,...a),p.info=(r,...a)=>console.info(`[Pixi\u2019VN Json] ${r}`,...a)))(t||(t={}));var e=class{static init(i){this._loadAssets=i.loadAssets,this._soundOperation=i.soundOperation,this._imageOperation=i.imageOperation,this._videoOperation=i.videoOperation,this._imageContainerOperation=i.imageContainerOperation,this._canvasElementOperation=i.canvasElementOperation,this._setStorageValue=i.setStorageValue,this._inputOperation=i.inputOperation,this._tickerOperation=i.tickerOperation,this._effectOperation=i.effectOperation,this._animateOperation=i.animateOperation,this._getLogichValue=i.getLogichValue,this._getConditionalStep=i.getConditionalStep;}static get loadAssets(){return this._loadAssets}static get soundOperation(){return this._soundOperation}static get imageOperation(){return this._imageOperation}static get videoOperation(){return this._videoOperation}static get imageContainerOperation(){return this._imageContainerOperation}static get canvasElementOperation(){return this._canvasElementOperation}static get setStorageValue(){return this._setStorageValue}static get inputOperation(){return this._inputOperation}static get tickerOperation(){return this._tickerOperation}static get effectOperation(){return this._effectOperation}static get animateOperation(){return this._animateOperation}static get getLogichValue(){return this._getLogichValue}static get getConditionalStep(){return this._getConditionalStep}};o(e,"_loadAssets",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_soundOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_imageOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_videoOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_imageContainerOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_canvasElementOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_setStorageValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_inputOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_tickerOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_effectOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_animateOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_getLogichValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_getConditionalStep",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});export{e as JsonUnifier};
1
+ import {narration,NarrationManagerStatic}from'@drincs/pixi-vn/narration';import {storage,SYSTEM_RESERVED_STORAGE_KEYS}from'@drincs/pixi-vn/storage';var G=Object.defineProperty;var j=(t,e,i)=>e in t?G(t,e,{enumerable:true,configurable:true,writable:true,value:i}):t[e]=i;var f=(t,e,i)=>j(t,typeof e!="symbol"?e+"":e,i);var n=class n{static t(e){return Array.isArray(e)?e.map(i=>n.translate(`${i}`)):n.translate(`${e}`)}static set beforeToTranslate(e){n._beforeToTranslate=e;}static set translate(e){n._translate=e;}static get translate(){return e=>{let i=e;return n._beforeToTranslate&&(i=n._beforeToTranslate(i)),i=n._translate(i),n._afterToTranslate&&(i=n._afterToTranslate(i)),i}}static set afterToTranslate(e){n._afterToTranslate=e;}static addKey(e,i,l){let o=l.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===void 0&&(o==="empty_string"?e[r]="":o==="copy_key"&&(n._beforeToTranslate?e[r]=n._beforeToTranslate(r):e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&n.getConditionalsThenElse(e.then,i),e.else&&n.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(l=>{n.getConditionalsThenElse(l,i);});else if(e.elements.type==="ifelse"){let l=[];n.getConditionalsThenElse(e.elements,l),l.forEach(o=>{i.push(...o);});}else if(e.elements.type==="stepswitch"){let l=[];n.getConditionalsThenElse(e.elements,l),l.forEach(o=>{i.push(...o);});}else n.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&n.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(l=>{n.getConditionalsThenElse(l,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},l={}){let{defaultValue:o="copy_key"}=l;return e.forEach(r=>{if(r.choices){let c=[];Array.isArray(r.choices)?c=[r.choices]:c=n.getConditionalsThenElse(r.choices),c.forEach(d=>d.forEach(g=>{if("type"in g){let V=[];g.type==="ifelse"||g.type==="stepswitch"?n.getConditionalsThenElse(g,V):V=[g],V.map(m=>n.getConditionalsThenElse(m.text)).forEach(m=>{Array.isArray(m)&&m.forEach(P=>{Array.isArray(P)?P.forEach(h=>{typeof h=="string"?n.addKey(i,h,{defaultValue:o}):n.getConditionalsThenElse(h).forEach(y=>{Array.isArray(y)?y.forEach(J=>{typeof J=="string"&&n.addKey(i,J,{defaultValue:o});}):typeof y=="string"&&n.addKey(i,y,{defaultValue:o});});}):typeof P=="string"&&n.addKey(i,P,{defaultValue:o});});});}}));}if(r.dialogue){let c=[];Array.isArray(r.dialogue)?c=[r.dialogue]:c=n.getConditionalsThenElse(r.dialogue),c.forEach(d=>{if(typeof d=="string")n.addKey(i,d,{defaultValue:o});else if("text"in d){let g=n.getConditionalsThenElse(d.text);typeof g=="string"&&(g=[g]),g.forEach(V=>{typeof V=="string"?n.addKey(i,V,{defaultValue:o}):n.getConditionalsThenElse(V).forEach(m=>{typeof m=="string"?n.addKey(i,m,{defaultValue:o}):Array.isArray(m)&&m.forEach(P=>{typeof P=="string"?n.addKey(i,P,{defaultValue:o}):n.getConditionalsThenElse(P).forEach(h=>{typeof h=="string"&&n.addKey(i,h,{defaultValue:o});});});});});}});}r.conditionalStep&&n.getConditionalsThenElse(r.conditionalStep).forEach(d=>{Array.isArray(d)?n.generateJsonTranslation(d,i,l):n.generateJsonTranslation([d],i,l);});}),i}};f(n,"_beforeToTranslate"),f(n,"_translate",e=>e),f(n,"_afterToTranslate");var E=n;var S=E;var O="___param___";var u;(o=>(o.log=(r,...c)=>console.log(`[Pixi\u2019VN Json] ${r}`,...c),o.warn=(r,...c)=>console.warn(`[Pixi\u2019VN Json] ${r}`,...c),o.error=(r,...c)=>console.error(`[Pixi\u2019VN Json] ${r}`,...c),o.info=(r,...c)=>console.info(`[Pixi\u2019VN Json] ${r}`,...c)))(u||(u={}));function R(t){try{if(typeof t>"u")return t;let e=JSON.stringify(t);return JSON.parse(e)}catch(e){throw u.error("Error creating exportable element",t,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}function L(t){let e=s(t.value),i;switch(e&&typeof e=="object"&&"type"in e?i=s(e):i=e,t.storageType){case "flagStorage":storage.setFlag(t.key,t.value);break;case "storage":storage.setVariable(t.key,i);break;case "tempstorage":storage.setTempVariable(t.key,i);break;case "params":let l=storage.getVariable(`${O}${narration.openedLabels.length-1}`)||[];l&&l.length-1>=t.key&&(l[t.key]=i),storage.setTempVariable(`${O}${narration.openedLabels.length-1}`,l);break}}function s(t){let e=K(t);if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "value":return _(e);case "arithmetic":case "arithmeticsingle":return z(e);case "compare":case "valueCondition":case "union":return F(e)}return e}function z(t){let e=s(t.leftValue);switch(t.type){case "arithmetic":let i=s(t.rightValue);switch(t.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(t.operator){case "INT":return parseInt(e);case "FLOOR":return Math.floor(e);case "FLOAT":return parseFloat(e)}break}}function _(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 storage.getFlag(t.key);case "label":return narration.getTimesLabelOpened(t.label);case "choice":return narration.getTimesChoiceMade(t.index);case "logic":return s(t.operation);case "params":let e=storage.getVariable(`${O}${narration.openedLabels.length-1}`)||[];if(e&&e.length>t.key)return e[t.key];u.warn("getValue params not found");return}return t}function F(t){if(!t)return false;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case "compare":let e=s(t.leftValue),i=s(t.rightValue);switch(t.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 !!s(t.value);case "union":return M(t)}return !!t}function M(t){if(t.unionType==="not")return !s(t.condition);let e=t.unionType==="and";for(let i=0;i<t.conditions.length;i++)if(e=s(t.conditions[i])||false,t.unionType==="and"){if(!e)return false}else if(e)return true;return e}function $(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function K(t){if(Array.isArray(t)||!t)return t;if(t&&typeof t=="object"&&"type"in t)switch(t.type){case "resulttocombine":return X(t);case "ifelse":return s(t.condition)?s(t.then):s(t.else);case "stepswitch":let i=s(t.elements)||[];if(i.length===0){u.error("getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case "random":let l=$(0,i.length-1);return s(i[l]);case "loop":let o=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return o>i.length-1&&(o=o%i.length),s(i[o]);case "sequential":let r,c=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end=="lastItem"&&(r=s(i[i.length-1])),c>i.length-1?r:s(i[c]);case "sequentialrandom":let d=NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:t.nestedId,onceOnly:true});if(d==null&&t.end=="lastItem"){let g=NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!g||!g?.usedRandomNumbers){u.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let V=g.usedRandomNumbers[`0-${i.length-1}`];return s(i[V[V.length-1]])}if(d==null){u.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return s(i[d])}}return t}function b(t){if(t.conditionalStep){let e=R(s(t.conditionalStep));if(e?.glueEnabled===void 0&&delete e?.glueEnabled,e?.goNextStep===void 0&&delete e?.goNextStep,e?.end===void 0&&delete e?.end,e?.choices===void 0&&delete e?.choices,e?.dialogue===void 0&&delete e?.dialogue,e?.labelToOpen===void 0&&delete e?.labelToOpen,e?.operations===void 0&&delete e?.operations,e){let i={...t,conditionalStep:void 0,...e};return b(i)}else storage.getFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return t}function X(t){let e=t.firstItem,i=[];t.secondConditionalItem?.forEach(o=>{if(Array.isArray(o))o.forEach(r=>{let c=s(r);i.push(c);});else {let r=s(o);i.push(r);}});let l=e?[e,...i]:i;if(l.length===0){u.warn("combinateResult toCheck.length === 0");return}if(typeof l[0]=="string")return S.t(l);if(typeof l[0]=="object"){let o=l,r,c=o.map((p,T)=>{p=b(p);let x=s(p.dialogue)||"";return T===0?(r=s(p.glueEnabled)||false,x):(typeof x=="object"&&"text"in x&&(x=x.character+": "+x.text),r===false&&(x=`
2
+
3
+ `+x),r=s(p.glueEnabled)||false,x)}),d=s(c[0]),g=typeof d=="object"&&"character"in d?d.character:void 0,V=c.flatMap(p=>{let T;p&&typeof p=="object"&&"text"in p?T=p.text:T=p;let x;return Array.isArray(T)?x=T.map(k=>{let D=s(k);return S.t(`${D}`)}):x=s(T)||"",S.t(x)}),w=o.find(p=>p.end),m=o.find(p=>p.choices),P=false,h=false;o.length>0&&(o[0].glueEnabled&&o[0].goNextStep&&o[0].dialogue===void 0&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),P=o[o.length-1].glueEnabled,h=o.reverse().find(p=>!(p.operations&&(!p.dialogue||!p.choices)))?.goNextStep);let y=o.find(p=>p.labelToOpen),J=[];return o.forEach(p=>{p.operations&&J.forEach(T=>{J.push(T);});}),{dialogue:g?{character:g,text:V}:V,end:w?.end,choices:m?.choices,glueEnabled:P,goNextStep:h,labelToOpen:y?.labelToOpen,operations:J}}}var a=class a{static init(e){a._loadAssets=e.loadAssets,a._soundOperation=e.soundOperation,a._imageOperation=e.imageOperation,a._videoOperation=e.videoOperation,a._imageContainerOperation=e.imageContainerOperation,a._canvasElementOperation=e.canvasElementOperation,a._setStorageValue=e.setStorageValue,a._inputOperation=e.inputOperation,a._tickerOperation=e.tickerOperation,a._effectOperation=e.effectOperation,a._animateOperation=e.animateOperation,a._getLogichValue=e.getLogichValue,a._getConditionalStep=e.getConditionalStep;}static get loadAssets(){return a._loadAssets}static get soundOperation(){return a._soundOperation}static get imageOperation(){return a._imageOperation}static get videoOperation(){return a._videoOperation}static get imageContainerOperation(){return a._imageContainerOperation}static get canvasElementOperation(){return a._canvasElementOperation}static get setStorageValue(){return a._setStorageValue}static get inputOperation(){return a._inputOperation}static get tickerOperation(){return a._tickerOperation}static get effectOperation(){return a._effectOperation}static get animateOperation(){return a._animateOperation}static get getLogichValue(){return a._getLogichValue}static get getConditionalStep(){return a._getConditionalStep}};f(a,"_loadAssets",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_soundOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_imageOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_videoOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_imageContainerOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_canvasElementOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_setStorageValue",L),f(a,"_inputOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_tickerOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_effectOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_animateOperation",()=>{throw u.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),f(a,"_getLogichValue",s),f(a,"_getConditionalStep",b);var A=a;export{A as JsonUnifier};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drincs/pixi-vn-json",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "type": "module",
5
5
  "description": "Pixi'VN can be integrated with JSON files to create a visual novel.",
6
6
  "main": "./dist/index.cjs",
@@ -11,9 +11,9 @@
11
11
  ],
12
12
  "scripts": {
13
13
  "build:unifier": "tsup --config tsup.unifier.config.ts",
14
- "build:importer": "tsup --config tsup.importer.config.ts",
14
+ "build:submodules": "tsup --config tsup.submodules.config.ts",
15
15
  "build:index": "tsup --config tsup.config.ts",
16
- "build": "npm run build:unifier && npm run build:importer && npm run build:index",
16
+ "build": "npm run build:unifier && npm run build:submodules && npm run build:index",
17
17
  "test": "vitest"
18
18
  },
19
19
  "exports": {
@@ -34,12 +34,19 @@
34
34
  "import": "./dist/importer.mjs",
35
35
  "require": "./dist/importer.cjs",
36
36
  "default": "./dist/importer.mjs"
37
+ },
38
+ "./translator": {
39
+ "types": "./dist/translator.d.ts",
40
+ "import": "./dist/translator.mjs",
41
+ "require": "./dist/translator.cjs",
42
+ "default": "./dist/translator.mjs"
37
43
  }
38
44
  },
39
45
  "typesVersions": {
40
46
  "*": {
41
47
  "unifier": ["./dist/unifier.d.ts"],
42
- "importer": ["./dist/importer.d.ts"]
48
+ "importer": ["./dist/importer.d.ts"],
49
+ "translator": ["./dist/translator.d.ts"]
43
50
  }
44
51
  },
45
52
  "repository": {