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