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