@drincs/pixi-vn-json 1.13.8 → 1.13.9

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.
@@ -0,0 +1,36 @@
1
+ import { StorageElementType, StepLabelPropsType } from '@drincs/pixi-vn';
2
+
3
+ /**
4
+ * A middleware handler that can intercept and transform a logic value before it is
5
+ * returned by {@link VariableGetter.getLogichValue}.
6
+ *
7
+ * Handlers are called in registration order, each receiving the current value and a
8
+ * `next` function to invoke the rest of the chain (including the built-in resolver).
9
+ * Return `undefined` to fall through to `next`.
10
+ */
11
+ type VariableGetterHandler = <T = StorageElementType>(value: T, next: (value: T) => T | undefined) => T | undefined;
12
+
13
+ declare namespace VariableGetter {
14
+ /**
15
+ * Registers a new middleware handler into the resolution chain.
16
+ * Handlers are invoked in the order they were added.
17
+ *
18
+ * @param handler - The middleware handler to register.
19
+ */
20
+ function add(handler: VariableGetterHandler): void;
21
+ /**
22
+ * Removes all registered middleware handlers, restoring the default resolution behaviour.
23
+ */
24
+ function clear(): void;
25
+ /**
26
+ * Resolves a JSON logic value, running it through all registered middleware handlers
27
+ * before falling back to the built-in storage/arithmetic/condition evaluator.
28
+ *
29
+ * @param value - The value or logic expression to resolve.
30
+ * @param props - The current step label props passed to each handler.
31
+ * @returns The resolved value, or `undefined`.
32
+ */
33
+ function getLogichValue<T = StorageElementType>(value: any, props?: StepLabelPropsType): T | undefined;
34
+ }
35
+
36
+ export { VariableGetter as V, type VariableGetterHandler as a };
@@ -0,0 +1,36 @@
1
+ import { StorageElementType, StepLabelPropsType } from '@drincs/pixi-vn';
2
+
3
+ /**
4
+ * A middleware handler that can intercept and transform a logic value before it is
5
+ * returned by {@link VariableGetter.getLogichValue}.
6
+ *
7
+ * Handlers are called in registration order, each receiving the current value and a
8
+ * `next` function to invoke the rest of the chain (including the built-in resolver).
9
+ * Return `undefined` to fall through to `next`.
10
+ */
11
+ type VariableGetterHandler = <T = StorageElementType>(value: T, next: (value: T) => T | undefined) => T | undefined;
12
+
13
+ declare namespace VariableGetter {
14
+ /**
15
+ * Registers a new middleware handler into the resolution chain.
16
+ * Handlers are invoked in the order they were added.
17
+ *
18
+ * @param handler - The middleware handler to register.
19
+ */
20
+ function add(handler: VariableGetterHandler): void;
21
+ /**
22
+ * Removes all registered middleware handlers, restoring the default resolution behaviour.
23
+ */
24
+ function clear(): void;
25
+ /**
26
+ * Resolves a JSON logic value, running it through all registered middleware handlers
27
+ * before falling back to the built-in storage/arithmetic/condition evaluator.
28
+ *
29
+ * @param value - The value or logic expression to resolve.
30
+ * @param props - The current step label props passed to each handler.
31
+ * @returns The resolved value, or `undefined`.
32
+ */
33
+ function getLogichValue<T = StorageElementType>(value: any, props?: StepLabelPropsType): T | undefined;
34
+ }
35
+
36
+ export { VariableGetter as V, type VariableGetterHandler as a };
package/dist/actions.cjs CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var core=require('@drincs/pixi-vn-json/core'),canvas=require('@drincs/pixi-vn/canvas'),translator=require('@drincs/pixi-vn-json/translator'),narration=require('@drincs/pixi-vn/narration'),sound=require('@drincs/pixi-vn/sound'),pixiVn=require('@drincs/pixi-vn'),storage=require('@drincs/pixi-vn/storage');var q=Object.defineProperty;var W=(e,t,i)=>t in e?q(e,t,{enumerable:true,configurable:true,writable:true,value:i}):e[t]=i;var u=(e,t,i)=>W(e,typeof t!="symbol"?t+"":t,i);async function Te(e){let t=core.JsonUnifier.getLogichValue(e,{});if(t)switch(t.type){case "assets":switch(t.operationType){case "load":await canvas.Assets.load(t.aliases);break;case "lazyload":canvas.Assets.backgroundLoad(t.aliases);break}break;case "bundle":switch(t.operationType){case "load":await canvas.Assets.loadBundle(t.aliases);break;case "lazyload":canvas.Assets.backgroundLoadBundle(t.aliases);break}break}}var o;(s=>(s.log=(c,...p)=>console.log(`[Pixi\u2019VN Json] ${c}`,...p),s.warn=(c,...p)=>console.warn(`[Pixi\u2019VN Json] ${c}`,...p),s.error=(c,...p)=>console.error(`[Pixi\u2019VN Json] ${c}`,...p),s.info=(c,...p)=>console.info(`[Pixi\u2019VN Json] ${c}`,...p)))(o||(o={}));async function v(e,t,i){switch(i.type){case "fade":await canvas.showWithFade(t.alias,e,i.props,i.priority);break;case "dissolve":await canvas.showWithDissolve(t.alias,e,i.props,i.priority);break;case "movein":case "moveout":await canvas.moveIn(t.alias,e,i.props,i.priority);break;case "zoomin":case "zoomout":await canvas.zoomIn(t.alias,e,i.props,i.priority);break;case "pushin":case "pushout":await canvas.pushIn(t.alias,e,i.props,i.priority);break}}function P(e){if(e.transition)switch(e.transition.type){case "fade":canvas.removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":canvas.removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":canvas.moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":canvas.zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":canvas.pushOut(e.alias,e.transition.props,e.transition.priority);break}else canvas.canvas.remove(e.alias);}async function Le(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.ImageSprite(e.props,e.url||e.alias);await v(t,e,e.transition);}else await canvas.showImage(e.alias,e.url,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Image with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function Ie(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.VideoSprite(e.props,e.url||e.alias);await v(t,e,e.transition);}else await canvas.showVideo(e.alias,e.url,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Video with alias ${e.alias} not found.`);break}case "remove":P(e);break;case "pause":case "resume":{let t=canvas.canvas.find(e.alias);t?t.paused=e.operationType==="pause":o.error(`Video with alias ${e.alias} not found.`);break}}}async function Ee(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.ImageContainer(e.props,e.urls);await v(t,e,e.transition);}else await canvas.showImageContainer(e.alias,e.urls,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`ImageContainer with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function Re(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator.translator.t(e.text),e.transition){let t=new canvas.Text(e.props);await v(t,e,e.transition);}else canvas.showText(e.alias,e.text,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Text with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function ze(e){switch(e.operationType){case "edit":try{let t=canvas.canvas.find(e.alias);t?e.props&&t.setMemory({...t.memory,...e.props}):o.error(`Canvas Element with alias ${e.alias} not found.`);}catch(t){o.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,t);}break;case "remove":P(e);break}}async function Me(e){e.type==="shake"&&await canvas.shakeEffect(e.alias,e.props,e.priority);}function _e(e){switch(e.type){case "animate":canvas.canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function De(e){switch(e.type){case "input":narration.narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.narration.dialogue=void 0;break}}function We(e){switch(e.operationType){case "play":e.url?sound.sound.play(e.alias,e.url,e.props):sound.sound.play(e.alias,e.props);break;case "stop":switch(e.type){case "sound":sound.sound.stop(e.alias);break;case "all":sound.sound.stopAll();break}break;case "pause":switch(e.type){case "sound":sound.sound.pause(e.alias);break;case "channel":sound.sound.findChannel(e.alias).pauseAll();break;case "all":sound.sound.pauseAll();break}break;case "resume":switch(e.type){case "sound":sound.sound.resume(e.alias);break;case "channel":sound.sound.findChannel(e.alias).resumeAll();break;case "all":sound.sound.resumeAll();break}break;case "edit":Object.entries(e.props).forEach(([t,i])=>{let a=sound.sound.find(e.alias);a&&(t==="volume"?a.volume.value=i:a.paused=i);});break}}var J="___param___";var n=class n{static init(t){t.loadAssets&&(n._loadAssets=t.loadAssets),t.soundOperation&&(n._soundOperation=t.soundOperation),t.imageOperation&&(n._imageOperation=t.imageOperation),t.videoOperation&&(n._videoOperation=t.videoOperation),t.imageContainerOperation&&(n._imageContainerOperation=t.imageContainerOperation),t.textOperation&&(n._textOperation=t.textOperation),t.canvasElementOperation&&(n._canvasElementOperation=t.canvasElementOperation),t.setStorageValue&&(n._setStorageValue=t.setStorageValue),t.setInitialStorageValue&&(n._setInitialStorageValue=t.setInitialStorageValue),t.narrationOperation&&(n._narrationOperation=t.narrationOperation),t.effectOperation&&(n._effectOperation=t.effectOperation),t.animateOperation&&(n._animateOperation=t.animateOperation),t.getLogichValue&&(n._getLogichValue=t.getLogichValue),t.getConditionalStep&&(n._getConditionalStep=t.getConditionalStep);}static get loadAssets(){return n._loadAssets}static get soundOperation(){return n._soundOperation}static get imageOperation(){return n._imageOperation}static get videoOperation(){return n._videoOperation}static get imageContainerOperation(){return n._imageContainerOperation}static get textOperation(){return n._textOperation}static get canvasElementOperation(){return n._canvasElementOperation}static get setStorageValue(){return n._setStorageValue}static get setInitialStorageValue(){return n._setInitialStorageValue}static get narrationOperation(){return n._narrationOperation}static get effectOperation(){return n._effectOperation}static get animateOperation(){return n._animateOperation}static get getLogichValue(){return n._getLogichValue}static get getConditionalStep(){return n._getConditionalStep}};u(n,"_loadAssets",()=>{}),u(n,"_soundOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_imageOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_videoOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_imageContainerOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_textOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_canvasElementOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_setStorageValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_setInitialStorageValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_narrationOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_effectOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_animateOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_getLogichValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_getConditionalStep",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var h=n;function R(e,t){if(t&&typeof t=="object"&&typeof e.functionName=="string"&&e.functionName in t){let i=t[e.functionName];if(typeof i=="function"){let a=e.args.map(s=>h.getLogichValue(s,t));return i(...a)}else o.warn(`getLogichValue function ${e.functionName} not found in props`);}}function z(e,t){let i=core.JsonUnifier.getLogichValue(e,t);return i&&typeof i=="object"&&"type"in i?core.JsonUnifier.getLogichValue(i,t):i}function gi(e,t={}){let i=z(e.value,t);switch(e.storageType){case "flagStorage":storage.storage.setFlag(e.key,e.value);break;case "storage":storage.storage.set(e.key,i);break;case "tempstorage":storage.storage.setTempVariable(e.key,i);break;case "params":{let a=storage.storage.get(`${J}${narration.narration.openedLabels.length-1}`)||[];a.length>e.key&&(a[e.key]=i),storage.storage.setTempVariable(`${J}${narration.narration.openedLabels.length-1}`,a);break}}}function xi(e,t={}){let i=z(e.value,t);switch(e.storageType){case "storage":case "tempstorage":storage.storage.default={[e.key]:i};break}}function xe(e,t={}){let i=Ne(e,t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return fe(i,t);case "arithmetic":case "arithmeticsingle":return Ve(i,t);case "compare":case "union":return ye(i,t);case "function":return R(i,t)}return i}function Ve(e,t){let i=core.JsonUnifier.getLogichValue(e.leftValue,t);switch(e.type){case "arithmetic":{let a=core.JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "*":return i*a;case "/":return i/a;case "+":return typeof i=="string"||typeof a=="string"?`${i}${a}`:Array.isArray(i)&&Array.isArray(a)?[...i,...a]:Array.isArray(i)?[...i,a]:Array.isArray(a)?[i,...a]:i+a;case "-":if(Array.isArray(i)&&Array.isArray(a))return i.filter(s=>!a.includes(s));if(Array.isArray(i))return i.filter(s=>s!==a);if(Array.isArray(a)){o.warn("getValueFromArithmeticOperations cannot subtract array from non-array");return}return i-a;case "%":return i%a;case "POW":return i**a;case "RANDOM":return narration.narration.getRandomNumber(i,a);case "INTERSECTION":if(Array.isArray(i)&&Array.isArray(a))return i.filter(s=>a.includes(s));o.warn("getValueFromArithmeticOperations cannot intersect non-array values");return;default:o.warn("getValueFromArithmeticOperations unknown operator",e);return}}case "arithmeticsingle":switch(e.operator){case "INT":return Number(i);case "FLOOR":return Math.floor(i);}break}}function fe(e,t){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return e.key==="_input_value_"?narration.narration.inputValue:storage.storage.get(e.key);case "flagStorage":return storage.storage.getFlag(e.key);case "label":return narration.narration.getTimesLabelOpened(e.label);case "choice":return narration.narration.getTimesChoiceMade(e.index);case "logic":return core.JsonUnifier.getLogichValue(e.operation,t);case "params":{let i=storage.storage.get(`${J}${narration.narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];o.warn("getValue params not found");return}}return e}function ye(e,t){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":{let i=core.JsonUnifier.getLogichValue(e.leftValue,t),a=core.JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "==":return Array.isArray(i)&&Array.isArray(a)?i.length===a.length&&i.every(s=>a.includes(s)):i===a;case "!=":return Array.isArray(i)&&Array.isArray(a)?i.length!==a.length||!i.every(s=>a.includes(s)):i!==a;case "<":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)<0:Array.isArray(i)&&Array.isArray(a)?i.length<a.length:i<a;case "<=":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)<=0:Array.isArray(i)&&Array.isArray(a)?i.length<=a.length:i<=a;case ">":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)>0:Array.isArray(i)&&Array.isArray(a)?i.length>a.length:i>a;case ">=":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)>=0:Array.isArray(i)&&Array.isArray(a)?i.length>=a.length:i>=a;case "CONTAINS":return Array.isArray(i)&&Array.isArray(a)?a.every(s=>i.includes(s)):Array.isArray(i)?i.includes(a):i.toString().includes(a.toString())}break}case "value":{let i=core.JsonUnifier.getLogichValue(e,t);return Array.isArray(i)?i.length>0:i&&typeof i=="object"?Object.keys(i).length>0:!!i}case "union":return he(e,t)}return !!e}function he(e,t){if(e.unionType==="not"){let a=xe(e.condition,t);return Array.isArray(a)?a.length===0:a&&typeof a=="object"?Object.keys(a).length===0:!a}let i=a=>core.JsonUnifier.getLogichValue(a,t)||false;return e.unionType==="and"?e.conditions.every(i):e.conditions.some(i)}function Pe(e,t){return Math.floor(Math.random()*(t-e+1)+e)}function Ne(e,t={}){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return ve(e,t);case "ifelse":return core.JsonUnifier.getLogichValue(e.condition,t)?core.JsonUnifier.getLogichValue(e.then,t):core.JsonUnifier.getLogichValue(e.else,t);case "stepswitch":{let i=core.JsonUnifier.getLogichValue(e.elements,t)||[];if(i.length===0){o.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":{let a=Pe(0,i.length-1);return core.JsonUnifier.getLogichValue(i[a],t)}case "loop":{let a=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return a>i.length-1?(a=a%i.length,core.JsonUnifier.getLogichValue(i[a],t)):core.JsonUnifier.getLogichValue(i[a],t)}case "sequential":{let a,s=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end==="lastItem"&&(a=core.JsonUnifier.getLogichValue(i[i.length-1],t)),s>i.length-1?a:core.JsonUnifier.getLogichValue(i[s],t)}case "sequentialrandom":{let a=narration.NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:e.nestedId,onceOnly:true});if(a===void 0&&e.end==="lastItem"){let s=narration.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!s?.usedRandomNumbers){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let c=s.usedRandomNumbers[`0-${i.length-1}`];return core.JsonUnifier.getLogichValue(i[c[c.length-1]],t)}if(a===void 0){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return core.JsonUnifier.getLogichValue(i[a],t)}}}}return e}function M(e,t={}){if(e.conditionalStep){let i=pixiVn.createExportableElement(core.JsonUnifier.getLogichValue(e.conditionalStep,t));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operations===void 0&&delete i?.operations,i){let a={...e,conditionalStep:void 0,...i};return M(a,t)}else narration.narration.dialogGlue&&(narration.narration.dialogGlue=false);}return e}function ve(e,t){let i=e.firstItem,a=(e.secondConditionalItem??[]).flatMap(c=>Array.isArray(c)?c.map(p=>core.JsonUnifier.getLogichValue(p,t)):[core.JsonUnifier.getLogichValue(c,t)]),s=i?[i,...a]:a;if(s.length===0){o.warn("combinateResult toCheck.length === 0");return}if(typeof s[0]=="string")return translator.translator.t(s);if(typeof s[0]=="object"){let c=s,p,C=false,O=c.map((l,y)=>{l=M(l,t);let d=core.JsonUnifier.getLogichValue(l.dialogue,t)||"";return y===0?(p=core.JsonUnifier.getLogichValue(l.glueEnabled,t)||false,d):(typeof d=="object"&&"text"in d&&(d=`${d.character}: ${d.text}`),p===false&&C&&(d=`
1
+ 'use strict';var core=require('@drincs/pixi-vn-json/core'),canvas=require('@drincs/pixi-vn/canvas'),translator=require('@drincs/pixi-vn-json/translator'),narration=require('@drincs/pixi-vn/narration'),sound=require('@drincs/pixi-vn/sound'),pixiVn=require('@drincs/pixi-vn'),storage=require('@drincs/pixi-vn/storage');var X=Object.defineProperty;var B=(e,t,i)=>t in e?X(e,t,{enumerable:true,configurable:true,writable:true,value:i}):e[t]=i;var d=(e,t,i)=>B(e,typeof t!="symbol"?t+"":t,i);async function Ce(e){let t=core.JsonUnifier.getLogichValue(e,{});if(t)switch(t.type){case "assets":switch(t.operationType){case "load":await canvas.Assets.load(t.aliases);break;case "lazyload":canvas.Assets.backgroundLoad(t.aliases);break}break;case "bundle":switch(t.operationType){case "load":await canvas.Assets.loadBundle(t.aliases);break;case "lazyload":canvas.Assets.backgroundLoadBundle(t.aliases);break}break}}var o;(r=>(r.log=(s,...u)=>console.log(`[Pixi\u2019VN Json] ${s}`,...u),r.warn=(s,...u)=>console.warn(`[Pixi\u2019VN Json] ${s}`,...u),r.error=(s,...u)=>console.error(`[Pixi\u2019VN Json] ${s}`,...u),r.info=(s,...u)=>console.info(`[Pixi\u2019VN Json] ${s}`,...u)))(o||(o={}));async function w(e,t,i){switch(i.type){case "fade":await canvas.showWithFade(t.alias,e,i.props,i.priority);break;case "dissolve":await canvas.showWithDissolve(t.alias,e,i.props,i.priority);break;case "movein":case "moveout":await canvas.moveIn(t.alias,e,i.props,i.priority);break;case "zoomin":case "zoomout":await canvas.zoomIn(t.alias,e,i.props,i.priority);break;case "pushin":case "pushout":await canvas.pushIn(t.alias,e,i.props,i.priority);break}}function S(e){if(e.transition)switch(e.transition.type){case "fade":canvas.removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":canvas.removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":canvas.moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":canvas.zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":canvas.pushOut(e.alias,e.transition.props,e.transition.priority);break}else canvas.canvas.remove(e.alias);}async function Ie(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.ImageSprite(e.props,e.url||e.alias);await w(t,e,e.transition);}else await canvas.showImage(e.alias,e.url,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Image with alias ${e.alias} not found.`);break}case "remove":S(e);break}}async function Ee(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.VideoSprite(e.props,e.url||e.alias);await w(t,e,e.transition);}else await canvas.showVideo(e.alias,e.url,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Video with alias ${e.alias} not found.`);break}case "remove":S(e);break;case "pause":case "resume":{let t=canvas.canvas.find(e.alias);t?t.paused=e.operationType==="pause":o.error(`Video with alias ${e.alias} not found.`);break}}}async function Re(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.ImageContainer(e.props,e.urls);await w(t,e,e.transition);}else await canvas.showImageContainer(e.alias,e.urls,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`ImageContainer with alias ${e.alias} not found.`);break}case "remove":S(e);break}}async function ze(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator.translator.t(e.text),e.transition){let t=new canvas.Text(e.props);await w(t,e,e.transition);}else canvas.showText(e.alias,e.text,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Text with alias ${e.alias} not found.`);break}case "remove":S(e);break}}async function Me(e){switch(e.operationType){case "edit":try{let t=canvas.canvas.find(e.alias);t?e.props&&t.setMemory({...t.memory,...e.props}):o.error(`Canvas Element with alias ${e.alias} not found.`);}catch(t){o.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,t);}break;case "remove":S(e);break}}async function Ge(e){e.type==="shake"&&await canvas.shakeEffect(e.alias,e.props,e.priority);}function _e(e){switch(e.type){case "animate":canvas.canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function De(e){switch(e.type){case "input":narration.narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.narration.dialogue=void 0;break}}function He(e){switch(e.operationType){case "play":e.url?sound.sound.play(e.alias,e.url,e.props):sound.sound.play(e.alias,e.props);break;case "stop":switch(e.type){case "sound":sound.sound.stop(e.alias);break;case "all":sound.sound.stopAll();break}break;case "pause":switch(e.type){case "sound":sound.sound.pause(e.alias);break;case "channel":sound.sound.findChannel(e.alias).pauseAll();break;case "all":sound.sound.pauseAll();break}break;case "resume":switch(e.type){case "sound":sound.sound.resume(e.alias);break;case "channel":sound.sound.findChannel(e.alias).resumeAll();break;case "all":sound.sound.resumeAll();break}break;case "edit":Object.entries(e.props).forEach(([t,i])=>{let a=sound.sound.find(e.alias);a&&(t==="volume"?a.volume.value=i:a.paused=i);});break}}var C="___param___";var n=class n{static init(t){t.loadAssets&&(n._loadAssets=t.loadAssets),t.soundOperation&&(n._soundOperation=t.soundOperation),t.imageOperation&&(n._imageOperation=t.imageOperation),t.videoOperation&&(n._videoOperation=t.videoOperation),t.imageContainerOperation&&(n._imageContainerOperation=t.imageContainerOperation),t.textOperation&&(n._textOperation=t.textOperation),t.canvasElementOperation&&(n._canvasElementOperation=t.canvasElementOperation),t.setStorageValue&&(n._setStorageValue=t.setStorageValue),t.setInitialStorageValue&&(n._setInitialStorageValue=t.setInitialStorageValue),t.narrationOperation&&(n._narrationOperation=t.narrationOperation),t.effectOperation&&(n._effectOperation=t.effectOperation),t.animateOperation&&(n._animateOperation=t.animateOperation),t.getLogichValue&&(n._getLogichValue=t.getLogichValue),t.getConditionalStep&&(n._getConditionalStep=t.getConditionalStep);}static get loadAssets(){return n._loadAssets}static get soundOperation(){return n._soundOperation}static get imageOperation(){return n._imageOperation}static get videoOperation(){return n._videoOperation}static get imageContainerOperation(){return n._imageContainerOperation}static get textOperation(){return n._textOperation}static get canvasElementOperation(){return n._canvasElementOperation}static get setStorageValue(){return n._setStorageValue}static get setInitialStorageValue(){return n._setInitialStorageValue}static get narrationOperation(){return n._narrationOperation}static get effectOperation(){return n._effectOperation}static get animateOperation(){return n._animateOperation}static get getLogichValue(){return n._getLogichValue}static get getConditionalStep(){return n._getConditionalStep}};d(n,"_loadAssets",()=>{}),d(n,"_soundOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_imageOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_videoOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_imageContainerOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_textOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_canvasElementOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_setStorageValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_setInitialStorageValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_narrationOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_effectOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_animateOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_getLogichValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_getConditionalStep",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var N=n;function G(e,t){if(t&&typeof t=="object"&&typeof e.functionName=="string"&&e.functionName in t){let i=t[e.functionName];if(typeof i=="function"){let a=e.args.map(r=>N.getLogichValue(r,t));return i(...a)}else o.warn(`getLogichValue function ${e.functionName} not found in props`);}}function _(e,t){let i=core.JsonUnifier.getLogichValue(e,t);return i&&typeof i=="object"&&"type"in i?core.JsonUnifier.getLogichValue(i,t):i}function xi(e,t={}){let i=_(e.value,t);switch(e.storageType){case "flagStorage":storage.storage.setFlag(e.key,e.value);break;case "storage":storage.storage.set(e.key,i);break;case "tempstorage":storage.storage.setTempVariable(e.key,i);break;case "params":{let a=storage.storage.get(`${C}${narration.narration.openedLabels.length-1}`)||[];a.length>e.key&&(a[e.key]=i),storage.storage.setTempVariable(`${C}${narration.narration.openedLabels.length-1}`,a);break}}}function Vi(e,t={}){let i=_(e.value,t);switch(e.storageType){case "storage":case "tempstorage":storage.storage.default={[e.key]:i};break}}function j(e,t={}){let i=I(e,t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return he(i,t);case "arithmetic":case "arithmeticsingle":return ye(i,t);case "compare":case "union":return Pe(i,t);case "function":return G(i,t)}return i}function ye(e,t){let i=core.JsonUnifier.getLogichValue(e.leftValue,t);switch(e.type){case "arithmetic":{let a=core.JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "*":return i*a;case "/":return i/a;case "+":return typeof i=="string"||typeof a=="string"?`${i}${a}`:Array.isArray(i)&&Array.isArray(a)?[...i,...a]:Array.isArray(i)?[...i,a]:Array.isArray(a)?[i,...a]:i+a;case "-":if(Array.isArray(i)&&Array.isArray(a))return i.filter(r=>!a.includes(r));if(Array.isArray(i))return i.filter(r=>r!==a);if(Array.isArray(a)){o.warn("getValueFromArithmeticOperations cannot subtract array from non-array");return}return i-a;case "%":return i%a;case "POW":return i**a;case "RANDOM":return narration.narration.getRandomNumber(i,a);case "INTERSECTION":if(Array.isArray(i)&&Array.isArray(a))return i.filter(r=>a.includes(r));o.warn("getValueFromArithmeticOperations cannot intersect non-array values");return;default:o.warn("getValueFromArithmeticOperations unknown operator",e);return}}case "arithmeticsingle":switch(e.operator){case "INT":return Number(i);case "FLOOR":return Math.floor(i);}break}}function he(e,t){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return e.key==="_input_value_"?narration.narration.inputValue:storage.storage.get(e.key);case "flagStorage":return storage.storage.getFlag(e.key);case "label":return narration.narration.getTimesLabelOpened(e.label);case "choice":return narration.narration.getTimesChoiceMade(e.index);case "logic":return core.JsonUnifier.getLogichValue(e.operation,t);case "params":{let i=storage.storage.get(`${C}${narration.narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];o.warn("getValue params not found");return}}return e}function Pe(e,t){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":{let i=core.JsonUnifier.getLogichValue(e.leftValue,t),a=core.JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "==":return Array.isArray(i)&&Array.isArray(a)?i.length===a.length&&i.every(r=>a.includes(r)):i===a;case "!=":return Array.isArray(i)&&Array.isArray(a)?i.length!==a.length||!i.every(r=>a.includes(r)):i!==a;case "<":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)<0:Array.isArray(i)&&Array.isArray(a)?i.length<a.length:i<a;case "<=":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)<=0:Array.isArray(i)&&Array.isArray(a)?i.length<=a.length:i<=a;case ">":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)>0:Array.isArray(i)&&Array.isArray(a)?i.length>a.length:i>a;case ">=":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)>=0:Array.isArray(i)&&Array.isArray(a)?i.length>=a.length:i>=a;case "CONTAINS":return Array.isArray(i)&&Array.isArray(a)?a.every(r=>i.includes(r)):Array.isArray(i)?i.includes(a):i.toString().includes(a.toString())}break}case "value":{let i=core.JsonUnifier.getLogichValue(e,t);return Array.isArray(i)?i.length>0:i&&typeof i=="object"?Object.keys(i).length>0:!!i}case "union":return Ne(e,t)}return !!e}function Ne(e,t){if(e.unionType==="not"){let a=j(e.condition,t);return Array.isArray(a)?a.length===0:a&&typeof a=="object"?Object.keys(a).length===0:!a}let i=a=>core.JsonUnifier.getLogichValue(a,t)||false;return e.unionType==="and"?e.conditions.every(i):e.conditions.some(i)}function ve(e,t){return Math.floor(Math.random()*(t-e+1)+e)}function I(e,t={}){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return Je(e,t);case "ifelse":return core.JsonUnifier.getLogichValue(e.condition,t)?core.JsonUnifier.getLogichValue(e.then,t):core.JsonUnifier.getLogichValue(e.else,t);case "stepswitch":{let i=core.JsonUnifier.getLogichValue(e.elements,t)||[];if(i.length===0){o.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":{let a=ve(0,i.length-1);return core.JsonUnifier.getLogichValue(i[a],t)}case "loop":{let a=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return a>i.length-1?(a=a%i.length,core.JsonUnifier.getLogichValue(i[a],t)):core.JsonUnifier.getLogichValue(i[a],t)}case "sequential":{let a,r=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end==="lastItem"&&(a=core.JsonUnifier.getLogichValue(i[i.length-1],t)),r>i.length-1?a:core.JsonUnifier.getLogichValue(i[r],t)}case "sequentialrandom":{let a=narration.NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:e.nestedId,onceOnly:true});if(a===void 0&&e.end==="lastItem"){let r=narration.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!r?.usedRandomNumbers){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let s=r.usedRandomNumbers[`0-${i.length-1}`];return core.JsonUnifier.getLogichValue(i[s[s.length-1]],t)}if(a===void 0){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return core.JsonUnifier.getLogichValue(i[a],t)}}}}return e}function $(e,t={}){if(e.conditionalStep){let i=pixiVn.createExportableElement(core.JsonUnifier.getLogichValue(e.conditionalStep,t));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operations===void 0&&delete i?.operations,i){let a={...e,conditionalStep:void 0,...i};return $(a,t)}else narration.narration.dialogGlue&&(narration.narration.dialogGlue=false);}return e}function Je(e,t){let i=e.firstItem,a=(e.secondConditionalItem??[]).flatMap(s=>Array.isArray(s)?s.map(u=>core.JsonUnifier.getLogichValue(u,t)):[core.JsonUnifier.getLogichValue(s,t)]),r=i?[i,...a]:a;if(r.length===0){o.warn("combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return translator.translator.t(r);if(typeof r[0]=="object"){let s=r,u,v=false,J=s.map((l,h)=>{l=$(l,t);let p=core.JsonUnifier.getLogichValue(l.dialogue,t)||"";return h===0?(u=core.JsonUnifier.getLogichValue(l.glueEnabled,t)||false,p):(typeof p=="object"&&"text"in p&&(p=`${p.character}: ${p.text}`),u===false&&v&&(p=`
2
2
 
3
- ${d}`),d&&(C=true),p=core.JsonUnifier.getLogichValue(l.glueEnabled,t)||false,d)}),w=core.JsonUnifier.getLogichValue(O[0],t),A=typeof w=="object"&&"character"in w?w.character:void 0,k=O.flatMap(l=>{let y;l&&typeof l=="object"&&"text"in l?y=l.text:y=l;let d;return Array.isArray(y)?d=y.map(D=>{let F=core.JsonUnifier.getLogichValue(D,t);return translator.translator.t(`${F}`)}):d=core.JsonUnifier.getLogichValue(y,t)||"",translator.translator.t(d)}),_=c.find(l=>l.end),$=c.find(l=>l.choices),j=false,L=false;c.length>0&&(c[0].glueEnabled&&c[0].goNextStep&&c[0].dialogue===void 0&&(narration.narration.dialogGlue=true),j=c[c.length-1].glueEnabled,L=c.reverse().find(l=>!(l.operations&&(!l.dialogue||!l.choices)))?.goNextStep);let G=c.find(l=>l.labelToOpen),b=[];return c.forEach(l=>{l.operations&&(b=[...b,...l.operations]);}),{dialogue:A?{character:A,text:k}:k,end:_?.end,choices:$?.choices,glueEnabled:j,goNextStep:L,labelToOpen:G?.labelToOpen,operations:b}}}exports.animateOperation=_e;exports.canvasElementOperation=ze;exports.effectOperation=Me;exports.getConditionalStep=M;exports.getLogichValue=xe;exports.getValueFromConditionalStatements=Ne;exports.imageContainerOperation=Ee;exports.imageOperation=Le;exports.loadAssets=Te;exports.narrationOperation=De;exports.setInitialStorageValue=xi;exports.setStorageValue=gi;exports.soundOperation=We;exports.textOperation=Re;exports.videoOperation=Ie;
3
+ ${p}`),p&&(v=true),u=core.JsonUnifier.getLogichValue(l.glueEnabled,t)||false,p)}),y=core.JsonUnifier.getLogichValue(J[0],t),P=typeof y=="object"&&"character"in y?y.character:void 0,T=J.flatMap(l=>{let h;l&&typeof l=="object"&&"text"in l?h=l.text:h=l;let p;return Array.isArray(h)?p=h.map(W=>{let H=core.JsonUnifier.getLogichValue(W,t);return translator.translator.t(`${H}`)}):p=core.JsonUnifier.getLogichValue(h,t)||"",translator.translator.t(p)}),A=s.find(l=>l.end),D=s.find(l=>l.choices),E=false,R=false;s.length>0&&(s[0].glueEnabled&&s[0].goNextStep&&s[0].dialogue===void 0&&(narration.narration.dialogGlue=true),E=s[s.length-1].glueEnabled,R=s.reverse().find(l=>!(l.operations&&(!l.dialogue||!l.choices)))?.goNextStep);let q=s.find(l=>l.labelToOpen),k=[];return s.forEach(l=>{l.operations&&(k=[...k,...l.operations]);}),{dialogue:P?{character:P,text:T}:T,end:A?.end,choices:D?.choices,glueEnabled:E,goNextStep:R,labelToOpen:q?.labelToOpen,operations:k}}}exports.VariableGetter=void 0;(r=>{let e=new Set;function t(s){e.add(s);}r.add=t;function i(){e.clear();}r.clear=i;function a(s,u={}){let v=P=>j(P,u)??void 0,J=I(s,u);if(e.size===0)return v(J);let y=v;for(let P of e){let T=y;y=A=>P(A,T)??void 0;}return y(J)}r.getLogichValue=a;})(exports.VariableGetter||(exports.VariableGetter={}));exports.animateOperation=_e;exports.canvasElementOperation=Me;exports.effectOperation=Ge;exports.getConditionalStep=$;exports.getLogichValue=j;exports.getValueFromConditionalStatements=I;exports.imageContainerOperation=Re;exports.imageOperation=Ie;exports.loadAssets=Ce;exports.narrationOperation=De;exports.setInitialStorageValue=Vi;exports.setStorageValue=xi;exports.soundOperation=He;exports.textOperation=ze;exports.videoOperation=Ee;
@@ -2,6 +2,7 @@ import { L as PixiVNJsonOperation, A as PixiVNJsonIfElse, M as PixiVNJsonOperati
2
2
  import { ImageSpriteMemory, VideoSpriteMemory, ContainerMemory, ContainerChild } from '@drincs/pixi-vn/canvas';
3
3
  import { StepLabelPropsType } from '@drincs/pixi-vn/narration';
4
4
  import { StorageElementType } from '@drincs/pixi-vn/storage';
5
+ export { V as VariableGetter, a as VariableGetterHandler } from './VariableGetter-ZDA6kdah.cjs';
5
6
  import '@drincs/pixi-vn';
6
7
  import '@drincs/pixi-vn/motion';
7
8
  import 'pixi.js';
package/dist/actions.d.ts CHANGED
@@ -2,6 +2,7 @@ import { L as PixiVNJsonOperation, A as PixiVNJsonIfElse, M as PixiVNJsonOperati
2
2
  import { ImageSpriteMemory, VideoSpriteMemory, ContainerMemory, ContainerChild } from '@drincs/pixi-vn/canvas';
3
3
  import { StepLabelPropsType } from '@drincs/pixi-vn/narration';
4
4
  import { StorageElementType } from '@drincs/pixi-vn/storage';
5
+ export { V as VariableGetter, a as VariableGetterHandler } from './VariableGetter-ZDA6kdah.js';
5
6
  import '@drincs/pixi-vn';
6
7
  import '@drincs/pixi-vn/motion';
7
8
  import 'pixi.js';
package/dist/actions.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {Assets,canvas,ImageSprite,showImage,VideoSprite,showVideo,ImageContainer,showImageContainer,Text,showText,shakeEffect,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade}from'@drincs/pixi-vn/canvas';import {translator}from'@drincs/pixi-vn-json/translator';import {narration,NarrationManagerStatic}from'@drincs/pixi-vn/narration';import {sound}from'@drincs/pixi-vn/sound';import {PixiError,createExportableElement}from'@drincs/pixi-vn';import {storage}from'@drincs/pixi-vn/storage';var q=Object.defineProperty;var W=(e,t,i)=>t in e?q(e,t,{enumerable:true,configurable:true,writable:true,value:i}):e[t]=i;var u=(e,t,i)=>W(e,typeof t!="symbol"?t+"":t,i);async function Te(e){let t=JsonUnifier.getLogichValue(e,{});if(t)switch(t.type){case "assets":switch(t.operationType){case "load":await Assets.load(t.aliases);break;case "lazyload":Assets.backgroundLoad(t.aliases);break}break;case "bundle":switch(t.operationType){case "load":await Assets.loadBundle(t.aliases);break;case "lazyload":Assets.backgroundLoadBundle(t.aliases);break}break}}var o;(s=>(s.log=(c,...p)=>console.log(`[Pixi\u2019VN Json] ${c}`,...p),s.warn=(c,...p)=>console.warn(`[Pixi\u2019VN Json] ${c}`,...p),s.error=(c,...p)=>console.error(`[Pixi\u2019VN Json] ${c}`,...p),s.info=(c,...p)=>console.info(`[Pixi\u2019VN Json] ${c}`,...p)))(o||(o={}));async function v(e,t,i){switch(i.type){case "fade":await showWithFade(t.alias,e,i.props,i.priority);break;case "dissolve":await showWithDissolve(t.alias,e,i.props,i.priority);break;case "movein":case "moveout":await moveIn(t.alias,e,i.props,i.priority);break;case "zoomin":case "zoomout":await zoomIn(t.alias,e,i.props,i.priority);break;case "pushin":case "pushout":await pushIn(t.alias,e,i.props,i.priority);break}}function P(e){if(e.transition)switch(e.transition.type){case "fade":removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":pushOut(e.alias,e.transition.props,e.transition.priority);break}else canvas.remove(e.alias);}async function Le(e){switch(e.operationType){case "show":if(e.transition){let t=new ImageSprite(e.props,e.url||e.alias);await v(t,e,e.transition);}else await showImage(e.alias,e.url,e.props);break;case "edit":{let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Image with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function Ie(e){switch(e.operationType){case "show":if(e.transition){let t=new VideoSprite(e.props,e.url||e.alias);await v(t,e,e.transition);}else await showVideo(e.alias,e.url,e.props);break;case "edit":{let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Video with alias ${e.alias} not found.`);break}case "remove":P(e);break;case "pause":case "resume":{let t=canvas.find(e.alias);t?t.paused=e.operationType==="pause":o.error(`Video with alias ${e.alias} not found.`);break}}}async function Ee(e){switch(e.operationType){case "show":if(e.transition){let t=new ImageContainer(e.props,e.urls);await v(t,e,e.transition);}else await showImageContainer(e.alias,e.urls,e.props);break;case "edit":{let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`ImageContainer with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function Re(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator.t(e.text),e.transition){let t=new Text(e.props);await v(t,e,e.transition);}else showText(e.alias,e.text,e.props);break;case "edit":{let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Text with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function ze(e){switch(e.operationType){case "edit":try{let t=canvas.find(e.alias);t?e.props&&t.setMemory({...t.memory,...e.props}):o.error(`Canvas Element with alias ${e.alias} not found.`);}catch(t){o.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,t);}break;case "remove":P(e);break}}async function Me(e){e.type==="shake"&&await shakeEffect(e.alias,e.props,e.priority);}function _e(e){switch(e.type){case "animate":canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function De(e){switch(e.type){case "input":narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.dialogue=void 0;break}}function We(e){switch(e.operationType){case "play":e.url?sound.play(e.alias,e.url,e.props):sound.play(e.alias,e.props);break;case "stop":switch(e.type){case "sound":sound.stop(e.alias);break;case "all":sound.stopAll();break}break;case "pause":switch(e.type){case "sound":sound.pause(e.alias);break;case "channel":sound.findChannel(e.alias).pauseAll();break;case "all":sound.pauseAll();break}break;case "resume":switch(e.type){case "sound":sound.resume(e.alias);break;case "channel":sound.findChannel(e.alias).resumeAll();break;case "all":sound.resumeAll();break}break;case "edit":Object.entries(e.props).forEach(([t,i])=>{let a=sound.find(e.alias);a&&(t==="volume"?a.volume.value=i:a.paused=i);});break}}var J="___param___";var n=class n{static init(t){t.loadAssets&&(n._loadAssets=t.loadAssets),t.soundOperation&&(n._soundOperation=t.soundOperation),t.imageOperation&&(n._imageOperation=t.imageOperation),t.videoOperation&&(n._videoOperation=t.videoOperation),t.imageContainerOperation&&(n._imageContainerOperation=t.imageContainerOperation),t.textOperation&&(n._textOperation=t.textOperation),t.canvasElementOperation&&(n._canvasElementOperation=t.canvasElementOperation),t.setStorageValue&&(n._setStorageValue=t.setStorageValue),t.setInitialStorageValue&&(n._setInitialStorageValue=t.setInitialStorageValue),t.narrationOperation&&(n._narrationOperation=t.narrationOperation),t.effectOperation&&(n._effectOperation=t.effectOperation),t.animateOperation&&(n._animateOperation=t.animateOperation),t.getLogichValue&&(n._getLogichValue=t.getLogichValue),t.getConditionalStep&&(n._getConditionalStep=t.getConditionalStep);}static get loadAssets(){return n._loadAssets}static get soundOperation(){return n._soundOperation}static get imageOperation(){return n._imageOperation}static get videoOperation(){return n._videoOperation}static get imageContainerOperation(){return n._imageContainerOperation}static get textOperation(){return n._textOperation}static get canvasElementOperation(){return n._canvasElementOperation}static get setStorageValue(){return n._setStorageValue}static get setInitialStorageValue(){return n._setInitialStorageValue}static get narrationOperation(){return n._narrationOperation}static get effectOperation(){return n._effectOperation}static get animateOperation(){return n._animateOperation}static get getLogichValue(){return n._getLogichValue}static get getConditionalStep(){return n._getConditionalStep}};u(n,"_loadAssets",()=>{}),u(n,"_soundOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_imageOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_videoOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_imageContainerOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_textOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_canvasElementOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_setStorageValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_setInitialStorageValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_narrationOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_effectOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_animateOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_getLogichValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_getConditionalStep",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var h=n;function R(e,t){if(t&&typeof t=="object"&&typeof e.functionName=="string"&&e.functionName in t){let i=t[e.functionName];if(typeof i=="function"){let a=e.args.map(s=>h.getLogichValue(s,t));return i(...a)}else o.warn(`getLogichValue function ${e.functionName} not found in props`);}}function z(e,t){let i=JsonUnifier.getLogichValue(e,t);return i&&typeof i=="object"&&"type"in i?JsonUnifier.getLogichValue(i,t):i}function gi(e,t={}){let i=z(e.value,t);switch(e.storageType){case "flagStorage":storage.setFlag(e.key,e.value);break;case "storage":storage.set(e.key,i);break;case "tempstorage":storage.setTempVariable(e.key,i);break;case "params":{let a=storage.get(`${J}${narration.openedLabels.length-1}`)||[];a.length>e.key&&(a[e.key]=i),storage.setTempVariable(`${J}${narration.openedLabels.length-1}`,a);break}}}function xi(e,t={}){let i=z(e.value,t);switch(e.storageType){case "storage":case "tempstorage":storage.default={[e.key]:i};break}}function xe(e,t={}){let i=Ne(e,t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return fe(i,t);case "arithmetic":case "arithmeticsingle":return Ve(i,t);case "compare":case "union":return ye(i,t);case "function":return R(i,t)}return i}function Ve(e,t){let i=JsonUnifier.getLogichValue(e.leftValue,t);switch(e.type){case "arithmetic":{let a=JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "*":return i*a;case "/":return i/a;case "+":return typeof i=="string"||typeof a=="string"?`${i}${a}`:Array.isArray(i)&&Array.isArray(a)?[...i,...a]:Array.isArray(i)?[...i,a]:Array.isArray(a)?[i,...a]:i+a;case "-":if(Array.isArray(i)&&Array.isArray(a))return i.filter(s=>!a.includes(s));if(Array.isArray(i))return i.filter(s=>s!==a);if(Array.isArray(a)){o.warn("getValueFromArithmeticOperations cannot subtract array from non-array");return}return i-a;case "%":return i%a;case "POW":return i**a;case "RANDOM":return narration.getRandomNumber(i,a);case "INTERSECTION":if(Array.isArray(i)&&Array.isArray(a))return i.filter(s=>a.includes(s));o.warn("getValueFromArithmeticOperations cannot intersect non-array values");return;default:o.warn("getValueFromArithmeticOperations unknown operator",e);return}}case "arithmeticsingle":switch(e.operator){case "INT":return Number(i);case "FLOOR":return Math.floor(i);}break}}function fe(e,t){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return e.key==="_input_value_"?narration.inputValue:storage.get(e.key);case "flagStorage":return storage.getFlag(e.key);case "label":return narration.getTimesLabelOpened(e.label);case "choice":return narration.getTimesChoiceMade(e.index);case "logic":return JsonUnifier.getLogichValue(e.operation,t);case "params":{let i=storage.get(`${J}${narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];o.warn("getValue params not found");return}}return e}function ye(e,t){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":{let i=JsonUnifier.getLogichValue(e.leftValue,t),a=JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "==":return Array.isArray(i)&&Array.isArray(a)?i.length===a.length&&i.every(s=>a.includes(s)):i===a;case "!=":return Array.isArray(i)&&Array.isArray(a)?i.length!==a.length||!i.every(s=>a.includes(s)):i!==a;case "<":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)<0:Array.isArray(i)&&Array.isArray(a)?i.length<a.length:i<a;case "<=":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)<=0:Array.isArray(i)&&Array.isArray(a)?i.length<=a.length:i<=a;case ">":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)>0:Array.isArray(i)&&Array.isArray(a)?i.length>a.length:i>a;case ">=":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)>=0:Array.isArray(i)&&Array.isArray(a)?i.length>=a.length:i>=a;case "CONTAINS":return Array.isArray(i)&&Array.isArray(a)?a.every(s=>i.includes(s)):Array.isArray(i)?i.includes(a):i.toString().includes(a.toString())}break}case "value":{let i=JsonUnifier.getLogichValue(e,t);return Array.isArray(i)?i.length>0:i&&typeof i=="object"?Object.keys(i).length>0:!!i}case "union":return he(e,t)}return !!e}function he(e,t){if(e.unionType==="not"){let a=xe(e.condition,t);return Array.isArray(a)?a.length===0:a&&typeof a=="object"?Object.keys(a).length===0:!a}let i=a=>JsonUnifier.getLogichValue(a,t)||false;return e.unionType==="and"?e.conditions.every(i):e.conditions.some(i)}function Pe(e,t){return Math.floor(Math.random()*(t-e+1)+e)}function Ne(e,t={}){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return ve(e,t);case "ifelse":return JsonUnifier.getLogichValue(e.condition,t)?JsonUnifier.getLogichValue(e.then,t):JsonUnifier.getLogichValue(e.else,t);case "stepswitch":{let i=JsonUnifier.getLogichValue(e.elements,t)||[];if(i.length===0){o.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":{let a=Pe(0,i.length-1);return JsonUnifier.getLogichValue(i[a],t)}case "loop":{let a=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return a>i.length-1?(a=a%i.length,JsonUnifier.getLogichValue(i[a],t)):JsonUnifier.getLogichValue(i[a],t)}case "sequential":{let a,s=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end==="lastItem"&&(a=JsonUnifier.getLogichValue(i[i.length-1],t)),s>i.length-1?a:JsonUnifier.getLogichValue(i[s],t)}case "sequentialrandom":{let a=NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:e.nestedId,onceOnly:true});if(a===void 0&&e.end==="lastItem"){let s=NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!s?.usedRandomNumbers){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let c=s.usedRandomNumbers[`0-${i.length-1}`];return JsonUnifier.getLogichValue(i[c[c.length-1]],t)}if(a===void 0){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return JsonUnifier.getLogichValue(i[a],t)}}}}return e}function M(e,t={}){if(e.conditionalStep){let i=createExportableElement(JsonUnifier.getLogichValue(e.conditionalStep,t));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operations===void 0&&delete i?.operations,i){let a={...e,conditionalStep:void 0,...i};return M(a,t)}else narration.dialogGlue&&(narration.dialogGlue=false);}return e}function ve(e,t){let i=e.firstItem,a=(e.secondConditionalItem??[]).flatMap(c=>Array.isArray(c)?c.map(p=>JsonUnifier.getLogichValue(p,t)):[JsonUnifier.getLogichValue(c,t)]),s=i?[i,...a]:a;if(s.length===0){o.warn("combinateResult toCheck.length === 0");return}if(typeof s[0]=="string")return translator.t(s);if(typeof s[0]=="object"){let c=s,p,C=false,O=c.map((l,y)=>{l=M(l,t);let d=JsonUnifier.getLogichValue(l.dialogue,t)||"";return y===0?(p=JsonUnifier.getLogichValue(l.glueEnabled,t)||false,d):(typeof d=="object"&&"text"in d&&(d=`${d.character}: ${d.text}`),p===false&&C&&(d=`
1
+ import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {Assets,canvas,ImageSprite,showImage,VideoSprite,showVideo,ImageContainer,showImageContainer,Text,showText,shakeEffect,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade}from'@drincs/pixi-vn/canvas';import {translator}from'@drincs/pixi-vn-json/translator';import {NarrationManagerStatic,narration}from'@drincs/pixi-vn/narration';import {sound}from'@drincs/pixi-vn/sound';import {createExportableElement,PixiError}from'@drincs/pixi-vn';import {storage}from'@drincs/pixi-vn/storage';var X=Object.defineProperty;var B=(e,t,i)=>t in e?X(e,t,{enumerable:true,configurable:true,writable:true,value:i}):e[t]=i;var d=(e,t,i)=>B(e,typeof t!="symbol"?t+"":t,i);async function Ce(e){let t=JsonUnifier.getLogichValue(e,{});if(t)switch(t.type){case "assets":switch(t.operationType){case "load":await Assets.load(t.aliases);break;case "lazyload":Assets.backgroundLoad(t.aliases);break}break;case "bundle":switch(t.operationType){case "load":await Assets.loadBundle(t.aliases);break;case "lazyload":Assets.backgroundLoadBundle(t.aliases);break}break}}var o;(r=>(r.log=(s,...u)=>console.log(`[Pixi\u2019VN Json] ${s}`,...u),r.warn=(s,...u)=>console.warn(`[Pixi\u2019VN Json] ${s}`,...u),r.error=(s,...u)=>console.error(`[Pixi\u2019VN Json] ${s}`,...u),r.info=(s,...u)=>console.info(`[Pixi\u2019VN Json] ${s}`,...u)))(o||(o={}));async function w(e,t,i){switch(i.type){case "fade":await showWithFade(t.alias,e,i.props,i.priority);break;case "dissolve":await showWithDissolve(t.alias,e,i.props,i.priority);break;case "movein":case "moveout":await moveIn(t.alias,e,i.props,i.priority);break;case "zoomin":case "zoomout":await zoomIn(t.alias,e,i.props,i.priority);break;case "pushin":case "pushout":await pushIn(t.alias,e,i.props,i.priority);break}}function S(e){if(e.transition)switch(e.transition.type){case "fade":removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":pushOut(e.alias,e.transition.props,e.transition.priority);break}else canvas.remove(e.alias);}async function Ie(e){switch(e.operationType){case "show":if(e.transition){let t=new ImageSprite(e.props,e.url||e.alias);await w(t,e,e.transition);}else await showImage(e.alias,e.url,e.props);break;case "edit":{let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Image with alias ${e.alias} not found.`);break}case "remove":S(e);break}}async function Ee(e){switch(e.operationType){case "show":if(e.transition){let t=new VideoSprite(e.props,e.url||e.alias);await w(t,e,e.transition);}else await showVideo(e.alias,e.url,e.props);break;case "edit":{let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Video with alias ${e.alias} not found.`);break}case "remove":S(e);break;case "pause":case "resume":{let t=canvas.find(e.alias);t?t.paused=e.operationType==="pause":o.error(`Video with alias ${e.alias} not found.`);break}}}async function Re(e){switch(e.operationType){case "show":if(e.transition){let t=new ImageContainer(e.props,e.urls);await w(t,e,e.transition);}else await showImageContainer(e.alias,e.urls,e.props);break;case "edit":{let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`ImageContainer with alias ${e.alias} not found.`);break}case "remove":S(e);break}}async function ze(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator.t(e.text),e.transition){let t=new Text(e.props);await w(t,e,e.transition);}else showText(e.alias,e.text,e.props);break;case "edit":{let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Text with alias ${e.alias} not found.`);break}case "remove":S(e);break}}async function Me(e){switch(e.operationType){case "edit":try{let t=canvas.find(e.alias);t?e.props&&t.setMemory({...t.memory,...e.props}):o.error(`Canvas Element with alias ${e.alias} not found.`);}catch(t){o.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,t);}break;case "remove":S(e);break}}async function Ge(e){e.type==="shake"&&await shakeEffect(e.alias,e.props,e.priority);}function _e(e){switch(e.type){case "animate":canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function De(e){switch(e.type){case "input":narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.dialogue=void 0;break}}function He(e){switch(e.operationType){case "play":e.url?sound.play(e.alias,e.url,e.props):sound.play(e.alias,e.props);break;case "stop":switch(e.type){case "sound":sound.stop(e.alias);break;case "all":sound.stopAll();break}break;case "pause":switch(e.type){case "sound":sound.pause(e.alias);break;case "channel":sound.findChannel(e.alias).pauseAll();break;case "all":sound.pauseAll();break}break;case "resume":switch(e.type){case "sound":sound.resume(e.alias);break;case "channel":sound.findChannel(e.alias).resumeAll();break;case "all":sound.resumeAll();break}break;case "edit":Object.entries(e.props).forEach(([t,i])=>{let a=sound.find(e.alias);a&&(t==="volume"?a.volume.value=i:a.paused=i);});break}}var C="___param___";var n=class n{static init(t){t.loadAssets&&(n._loadAssets=t.loadAssets),t.soundOperation&&(n._soundOperation=t.soundOperation),t.imageOperation&&(n._imageOperation=t.imageOperation),t.videoOperation&&(n._videoOperation=t.videoOperation),t.imageContainerOperation&&(n._imageContainerOperation=t.imageContainerOperation),t.textOperation&&(n._textOperation=t.textOperation),t.canvasElementOperation&&(n._canvasElementOperation=t.canvasElementOperation),t.setStorageValue&&(n._setStorageValue=t.setStorageValue),t.setInitialStorageValue&&(n._setInitialStorageValue=t.setInitialStorageValue),t.narrationOperation&&(n._narrationOperation=t.narrationOperation),t.effectOperation&&(n._effectOperation=t.effectOperation),t.animateOperation&&(n._animateOperation=t.animateOperation),t.getLogichValue&&(n._getLogichValue=t.getLogichValue),t.getConditionalStep&&(n._getConditionalStep=t.getConditionalStep);}static get loadAssets(){return n._loadAssets}static get soundOperation(){return n._soundOperation}static get imageOperation(){return n._imageOperation}static get videoOperation(){return n._videoOperation}static get imageContainerOperation(){return n._imageContainerOperation}static get textOperation(){return n._textOperation}static get canvasElementOperation(){return n._canvasElementOperation}static get setStorageValue(){return n._setStorageValue}static get setInitialStorageValue(){return n._setInitialStorageValue}static get narrationOperation(){return n._narrationOperation}static get effectOperation(){return n._effectOperation}static get animateOperation(){return n._animateOperation}static get getLogichValue(){return n._getLogichValue}static get getConditionalStep(){return n._getConditionalStep}};d(n,"_loadAssets",()=>{}),d(n,"_soundOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_imageOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_videoOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_imageContainerOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_textOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_canvasElementOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_setStorageValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_setInitialStorageValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_narrationOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_effectOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_animateOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_getLogichValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),d(n,"_getConditionalStep",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var N=n;function G(e,t){if(t&&typeof t=="object"&&typeof e.functionName=="string"&&e.functionName in t){let i=t[e.functionName];if(typeof i=="function"){let a=e.args.map(r=>N.getLogichValue(r,t));return i(...a)}else o.warn(`getLogichValue function ${e.functionName} not found in props`);}}function _(e,t){let i=JsonUnifier.getLogichValue(e,t);return i&&typeof i=="object"&&"type"in i?JsonUnifier.getLogichValue(i,t):i}function xi(e,t={}){let i=_(e.value,t);switch(e.storageType){case "flagStorage":storage.setFlag(e.key,e.value);break;case "storage":storage.set(e.key,i);break;case "tempstorage":storage.setTempVariable(e.key,i);break;case "params":{let a=storage.get(`${C}${narration.openedLabels.length-1}`)||[];a.length>e.key&&(a[e.key]=i),storage.setTempVariable(`${C}${narration.openedLabels.length-1}`,a);break}}}function Vi(e,t={}){let i=_(e.value,t);switch(e.storageType){case "storage":case "tempstorage":storage.default={[e.key]:i};break}}function j(e,t={}){let i=I(e,t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return he(i,t);case "arithmetic":case "arithmeticsingle":return ye(i,t);case "compare":case "union":return Pe(i,t);case "function":return G(i,t)}return i}function ye(e,t){let i=JsonUnifier.getLogichValue(e.leftValue,t);switch(e.type){case "arithmetic":{let a=JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "*":return i*a;case "/":return i/a;case "+":return typeof i=="string"||typeof a=="string"?`${i}${a}`:Array.isArray(i)&&Array.isArray(a)?[...i,...a]:Array.isArray(i)?[...i,a]:Array.isArray(a)?[i,...a]:i+a;case "-":if(Array.isArray(i)&&Array.isArray(a))return i.filter(r=>!a.includes(r));if(Array.isArray(i))return i.filter(r=>r!==a);if(Array.isArray(a)){o.warn("getValueFromArithmeticOperations cannot subtract array from non-array");return}return i-a;case "%":return i%a;case "POW":return i**a;case "RANDOM":return narration.getRandomNumber(i,a);case "INTERSECTION":if(Array.isArray(i)&&Array.isArray(a))return i.filter(r=>a.includes(r));o.warn("getValueFromArithmeticOperations cannot intersect non-array values");return;default:o.warn("getValueFromArithmeticOperations unknown operator",e);return}}case "arithmeticsingle":switch(e.operator){case "INT":return Number(i);case "FLOOR":return Math.floor(i);}break}}function he(e,t){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return e.key==="_input_value_"?narration.inputValue:storage.get(e.key);case "flagStorage":return storage.getFlag(e.key);case "label":return narration.getTimesLabelOpened(e.label);case "choice":return narration.getTimesChoiceMade(e.index);case "logic":return JsonUnifier.getLogichValue(e.operation,t);case "params":{let i=storage.get(`${C}${narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];o.warn("getValue params not found");return}}return e}function Pe(e,t){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":{let i=JsonUnifier.getLogichValue(e.leftValue,t),a=JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "==":return Array.isArray(i)&&Array.isArray(a)?i.length===a.length&&i.every(r=>a.includes(r)):i===a;case "!=":return Array.isArray(i)&&Array.isArray(a)?i.length!==a.length||!i.every(r=>a.includes(r)):i!==a;case "<":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)<0:Array.isArray(i)&&Array.isArray(a)?i.length<a.length:i<a;case "<=":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)<=0:Array.isArray(i)&&Array.isArray(a)?i.length<=a.length:i<=a;case ">":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)>0:Array.isArray(i)&&Array.isArray(a)?i.length>a.length:i>a;case ">=":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)>=0:Array.isArray(i)&&Array.isArray(a)?i.length>=a.length:i>=a;case "CONTAINS":return Array.isArray(i)&&Array.isArray(a)?a.every(r=>i.includes(r)):Array.isArray(i)?i.includes(a):i.toString().includes(a.toString())}break}case "value":{let i=JsonUnifier.getLogichValue(e,t);return Array.isArray(i)?i.length>0:i&&typeof i=="object"?Object.keys(i).length>0:!!i}case "union":return Ne(e,t)}return !!e}function Ne(e,t){if(e.unionType==="not"){let a=j(e.condition,t);return Array.isArray(a)?a.length===0:a&&typeof a=="object"?Object.keys(a).length===0:!a}let i=a=>JsonUnifier.getLogichValue(a,t)||false;return e.unionType==="and"?e.conditions.every(i):e.conditions.some(i)}function ve(e,t){return Math.floor(Math.random()*(t-e+1)+e)}function I(e,t={}){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return Je(e,t);case "ifelse":return JsonUnifier.getLogichValue(e.condition,t)?JsonUnifier.getLogichValue(e.then,t):JsonUnifier.getLogichValue(e.else,t);case "stepswitch":{let i=JsonUnifier.getLogichValue(e.elements,t)||[];if(i.length===0){o.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":{let a=ve(0,i.length-1);return JsonUnifier.getLogichValue(i[a],t)}case "loop":{let a=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return a>i.length-1?(a=a%i.length,JsonUnifier.getLogichValue(i[a],t)):JsonUnifier.getLogichValue(i[a],t)}case "sequential":{let a,r=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end==="lastItem"&&(a=JsonUnifier.getLogichValue(i[i.length-1],t)),r>i.length-1?a:JsonUnifier.getLogichValue(i[r],t)}case "sequentialrandom":{let a=NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:e.nestedId,onceOnly:true});if(a===void 0&&e.end==="lastItem"){let r=NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!r?.usedRandomNumbers){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let s=r.usedRandomNumbers[`0-${i.length-1}`];return JsonUnifier.getLogichValue(i[s[s.length-1]],t)}if(a===void 0){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return JsonUnifier.getLogichValue(i[a],t)}}}}return e}function $(e,t={}){if(e.conditionalStep){let i=createExportableElement(JsonUnifier.getLogichValue(e.conditionalStep,t));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operations===void 0&&delete i?.operations,i){let a={...e,conditionalStep:void 0,...i};return $(a,t)}else narration.dialogGlue&&(narration.dialogGlue=false);}return e}function Je(e,t){let i=e.firstItem,a=(e.secondConditionalItem??[]).flatMap(s=>Array.isArray(s)?s.map(u=>JsonUnifier.getLogichValue(u,t)):[JsonUnifier.getLogichValue(s,t)]),r=i?[i,...a]:a;if(r.length===0){o.warn("combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return translator.t(r);if(typeof r[0]=="object"){let s=r,u,v=false,J=s.map((l,h)=>{l=$(l,t);let p=JsonUnifier.getLogichValue(l.dialogue,t)||"";return h===0?(u=JsonUnifier.getLogichValue(l.glueEnabled,t)||false,p):(typeof p=="object"&&"text"in p&&(p=`${p.character}: ${p.text}`),u===false&&v&&(p=`
2
2
 
3
- ${d}`),d&&(C=true),p=JsonUnifier.getLogichValue(l.glueEnabled,t)||false,d)}),w=JsonUnifier.getLogichValue(O[0],t),A=typeof w=="object"&&"character"in w?w.character:void 0,k=O.flatMap(l=>{let y;l&&typeof l=="object"&&"text"in l?y=l.text:y=l;let d;return Array.isArray(y)?d=y.map(D=>{let F=JsonUnifier.getLogichValue(D,t);return translator.t(`${F}`)}):d=JsonUnifier.getLogichValue(y,t)||"",translator.t(d)}),_=c.find(l=>l.end),$=c.find(l=>l.choices),j=false,L=false;c.length>0&&(c[0].glueEnabled&&c[0].goNextStep&&c[0].dialogue===void 0&&(narration.dialogGlue=true),j=c[c.length-1].glueEnabled,L=c.reverse().find(l=>!(l.operations&&(!l.dialogue||!l.choices)))?.goNextStep);let G=c.find(l=>l.labelToOpen),b=[];return c.forEach(l=>{l.operations&&(b=[...b,...l.operations]);}),{dialogue:A?{character:A,text:k}:k,end:_?.end,choices:$?.choices,glueEnabled:j,goNextStep:L,labelToOpen:G?.labelToOpen,operations:b}}}export{_e as animateOperation,ze as canvasElementOperation,Me as effectOperation,M as getConditionalStep,xe as getLogichValue,Ne as getValueFromConditionalStatements,Ee as imageContainerOperation,Le as imageOperation,Te as loadAssets,De as narrationOperation,xi as setInitialStorageValue,gi as setStorageValue,We as soundOperation,Re as textOperation,Ie as videoOperation};
3
+ ${p}`),p&&(v=true),u=JsonUnifier.getLogichValue(l.glueEnabled,t)||false,p)}),y=JsonUnifier.getLogichValue(J[0],t),P=typeof y=="object"&&"character"in y?y.character:void 0,T=J.flatMap(l=>{let h;l&&typeof l=="object"&&"text"in l?h=l.text:h=l;let p;return Array.isArray(h)?p=h.map(W=>{let H=JsonUnifier.getLogichValue(W,t);return translator.t(`${H}`)}):p=JsonUnifier.getLogichValue(h,t)||"",translator.t(p)}),A=s.find(l=>l.end),D=s.find(l=>l.choices),E=false,R=false;s.length>0&&(s[0].glueEnabled&&s[0].goNextStep&&s[0].dialogue===void 0&&(narration.dialogGlue=true),E=s[s.length-1].glueEnabled,R=s.reverse().find(l=>!(l.operations&&(!l.dialogue||!l.choices)))?.goNextStep);let q=s.find(l=>l.labelToOpen),k=[];return s.forEach(l=>{l.operations&&(k=[...k,...l.operations]);}),{dialogue:P?{character:P,text:T}:T,end:A?.end,choices:D?.choices,glueEnabled:E,goNextStep:R,labelToOpen:q?.labelToOpen,operations:k}}}var F;(r=>{let e=new Set;function t(s){e.add(s);}r.add=t;function i(){e.clear();}r.clear=i;function a(s,u={}){let v=P=>j(P,u)??void 0,J=I(s,u);if(e.size===0)return v(J);let y=v;for(let P of e){let T=y;y=A=>P(A,T)??void 0;}return y(J)}r.getLogichValue=a;})(F||(F={}));export{F as VariableGetter,_e as animateOperation,Me as canvasElementOperation,Ge as effectOperation,$ as getConditionalStep,j as getLogichValue,I as getValueFromConditionalStatements,Re as imageContainerOperation,Ie as imageOperation,Ce as loadAssets,De as narrationOperation,Vi as setInitialStorageValue,xi as setStorageValue,He as soundOperation,ze as textOperation,Ee as videoOperation};
package/dist/index.cjs CHANGED
@@ -1,2 +1,3 @@
1
- 'use strict';var actions=require('@drincs/pixi-vn-json/actions'),core=require('@drincs/pixi-vn-json/core'),translator=require('@drincs/pixi-vn-json/translator'),characters=require('@drincs/pixi-vn/characters'),zod=require('zod'),interpreter=require('@drincs/pixi-vn-json/interpreter');exports.VariableGetter=void 0;(v=>{let n=new Set;function o(m){n.add(m);}v.add=o;function h(){n.clear();}v.clear=h;function y(m,x={}){let p=a=>actions.getLogichValue(a,x)??void 0,u=actions.getValueFromConditionalStatements(m,x);if(n.size===0)return p(u);let c=p;for(let a of n){let e=c;c=i=>a(i,e)??void 0;}return c(u)}v.getLogichValue=y;})(exports.VariableGetter||(exports.VariableGetter={}));var b={version:"1.13.8"};var _="___param___",N=`https://pixi-vn.com/schemas/${b.version}/schema.json`,T=["==","!=","<","<=",">",">=","CONTAINS"];exports.TextReplaces=void 0;(a=>{a.options={replaceRegex:/\[([^\]]+)\]/};let o=[],h=false,y=false;function v(e,i){o.unshift({fn:e,opts:i});let t=i.type??"before-translation";t==="before-translation"&&!h?(translator.translator.beforeToTranslate=r=>p(r,{type:"before-translation"}),h=true):t==="after-translation"&&!y&&(translator.translator.afterToTranslate=r=>p(r,{type:"after-translation"}),y=true);}a.add=v;function m(e){let i=o.findIndex(t=>t.fn===e);i!==-1&&o.splice(i,1);}a.remove=m;function x(){return o.map(e=>e.opts)}a.info=x;function p(e,i){for(let r of o.filter(d=>d.opts.i18nInterpolation))e=u(e,r.fn,r.opts.validation);let t=o.filter(r=>(r.opts.type??"before-translation")===i.type);for(let r of t)e=c(e,r.fn,r.opts.validation);return e}a.replace=p;function u(e,i,t){let r=new RegExp(a.options.replaceRegex.source,"g"),d=[...e.matchAll(r)],l=new Set,f=[];for(let s of d)l.has(s[1])||(l.add(s[1]),f.push(s[1]));for(let s of f){if(t==="characterId"){if(!characters.RegisteredCharacters.has(s))continue}else if(t!=="all"){if(t instanceof RegExp){if(!t.test(s))continue}else if(t instanceof zod.ZodType&&!t.safeParse(s).success)continue}i(s)!==void 0&&(e=e.replace(`[${s}]`,`{{[${s}]}}`));}return e}function c(e,i,t){let r=new RegExp(a.options.replaceRegex.source,"g"),d=[...e.matchAll(r)],l=new Set,f=[];for(let s of d)l.has(s[1])||(l.add(s[1]),f.push(s[1]));for(let s of f){if(t==="characterId"){if(!characters.RegisteredCharacters.has(s))continue}else if(t!=="all"){if(t instanceof RegExp){if(!t.test(s))continue}else if(t instanceof zod.ZodType&&!t.safeParse(s).success)continue}let j=i(s);j!==void 0&&(e=e.replaceAll(`[${s}]`,j));}return e}})(exports.TextReplaces||(exports.TextReplaces={}));function pe(){core.JsonUnifier.init({animateOperation:actions.animateOperation,canvasElementOperation:actions.canvasElementOperation,effectOperation:actions.effectOperation,imageContainerOperation:actions.imageContainerOperation,imageOperation:actions.imageOperation,textOperation:actions.textOperation,narrationOperation:actions.narrationOperation,loadAssets:actions.loadAssets,soundOperation:actions.soundOperation,videoOperation:actions.videoOperation,setStorageValue:actions.setStorageValue,setInitialStorageValue:actions.setInitialStorageValue,getLogichValue:exports.VariableGetter.getLogichValue,getConditionalStep:actions.getConditionalStep});}
2
- exports.PIXIVNJSON_PARAM_ID=_;exports.PIXIVNJSON_SCHEMA_URL=N;exports.PixiVNJsonComparationOperators=T;exports.init=pe;Object.keys(translator).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return translator[k]}})});Object.keys(interpreter).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return interpreter[k]}})});
1
+ 'use strict';var actions=require('@drincs/pixi-vn-json/actions'),core=require('@drincs/pixi-vn-json/core'),pixiVn=require('@drincs/pixi-vn'),translator=require('@drincs/pixi-vn-json/translator'),narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage'),interpreter=require('@drincs/pixi-vn-json/interpreter');var M=Object.defineProperty;var D=(t,i,e)=>i in t?M(t,i,{enumerable:true,configurable:true,writable:true,value:e}):t[i]=e;var p=(t,i,e)=>D(t,typeof i!="symbol"?i+"":i,e);var j={version:"1.13.9"};var T="___param___",$=`https://pixi-vn.com/schemas/${j.version}/schema.json`,q=["==","!=","<","<=",">",">=","CONTAINS"];var s;(a=>(a.log=(r,...u)=>console.log(`[Pixi\u2019VN Json] ${r}`,...u),a.warn=(r,...u)=>console.warn(`[Pixi\u2019VN Json] ${r}`,...u),a.error=(r,...u)=>console.error(`[Pixi\u2019VN Json] ${r}`,...u),a.info=(r,...u)=>console.info(`[Pixi\u2019VN Json] ${r}`,...u)))(s||(s={}));var o=class o{static init(i){i.loadAssets&&(o._loadAssets=i.loadAssets),i.soundOperation&&(o._soundOperation=i.soundOperation),i.imageOperation&&(o._imageOperation=i.imageOperation),i.videoOperation&&(o._videoOperation=i.videoOperation),i.imageContainerOperation&&(o._imageContainerOperation=i.imageContainerOperation),i.textOperation&&(o._textOperation=i.textOperation),i.canvasElementOperation&&(o._canvasElementOperation=i.canvasElementOperation),i.setStorageValue&&(o._setStorageValue=i.setStorageValue),i.setInitialStorageValue&&(o._setInitialStorageValue=i.setInitialStorageValue),i.narrationOperation&&(o._narrationOperation=i.narrationOperation),i.effectOperation&&(o._effectOperation=i.effectOperation),i.animateOperation&&(o._animateOperation=i.animateOperation),i.getLogichValue&&(o._getLogichValue=i.getLogichValue),i.getConditionalStep&&(o._getConditionalStep=i.getConditionalStep);}static get loadAssets(){return o._loadAssets}static get soundOperation(){return o._soundOperation}static get imageOperation(){return o._imageOperation}static get videoOperation(){return o._videoOperation}static get imageContainerOperation(){return o._imageContainerOperation}static get textOperation(){return o._textOperation}static get canvasElementOperation(){return o._canvasElementOperation}static get setStorageValue(){return o._setStorageValue}static get setInitialStorageValue(){return o._setInitialStorageValue}static get narrationOperation(){return o._narrationOperation}static get effectOperation(){return o._effectOperation}static get animateOperation(){return o._animateOperation}static get getLogichValue(){return o._getLogichValue}static get getConditionalStep(){return o._getConditionalStep}};p(o,"_loadAssets",()=>{}),p(o,"_soundOperation",()=>{throw s.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),p(o,"_imageOperation",()=>{throw s.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),p(o,"_videoOperation",()=>{throw s.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),p(o,"_imageContainerOperation",()=>{throw s.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),p(o,"_textOperation",()=>{throw s.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),p(o,"_canvasElementOperation",()=>{throw s.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),p(o,"_setStorageValue",()=>{throw s.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),p(o,"_setInitialStorageValue",()=>{throw s.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),p(o,"_narrationOperation",()=>{throw s.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),p(o,"_effectOperation",()=>{throw s.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),p(o,"_animateOperation",()=>{throw s.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),p(o,"_getLogichValue",()=>{throw s.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),p(o,"_getConditionalStep",()=>{throw s.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var P=o;function E(t,i){if(i&&typeof i=="object"&&typeof t.functionName=="string"&&t.functionName in i){let e=i[t.functionName];if(typeof e=="function"){let n=t.args.map(a=>P.getLogichValue(a,i));return e(...n)}else s.warn(`getLogichValue function ${t.functionName} not found in props`);}}function A(t,i={}){let e=C(t,i);if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "value":return W(e,i);case "arithmetic":case "arithmeticsingle":return X(e,i);case "compare":case "union":return B(e,i);case "function":return E(e,i)}return e}function X(t,i){let e=core.JsonUnifier.getLogichValue(t.leftValue,i);switch(t.type){case "arithmetic":{let n=core.JsonUnifier.getLogichValue(t.rightValue,i);switch(t.operator){case "*":return e*n;case "/":return e/n;case "+":return typeof e=="string"||typeof n=="string"?`${e}${n}`:Array.isArray(e)&&Array.isArray(n)?[...e,...n]:Array.isArray(e)?[...e,n]:Array.isArray(n)?[e,...n]:e+n;case "-":if(Array.isArray(e)&&Array.isArray(n))return e.filter(a=>!n.includes(a));if(Array.isArray(e))return e.filter(a=>a!==n);if(Array.isArray(n)){s.warn("getValueFromArithmeticOperations cannot subtract array from non-array");return}return e-n;case "%":return e%n;case "POW":return e**n;case "RANDOM":return narration.narration.getRandomNumber(e,n);case "INTERSECTION":if(Array.isArray(e)&&Array.isArray(n))return e.filter(a=>n.includes(a));s.warn("getValueFromArithmeticOperations cannot intersect non-array values");return;default:s.warn("getValueFromArithmeticOperations unknown operator",t);return}}case "arithmeticsingle":switch(t.operator){case "INT":return Number(e);case "FLOOR":return Math.floor(e);}break}}function W(t,i){if(t&&typeof t=="object"&&"type"in t&&t.type==="value"&&t.storageOperationType==="get")switch(t.storageType){case "storage":case "tempstorage":return t.key==="_input_value_"?narration.narration.inputValue:storage.storage.get(t.key);case "flagStorage":return storage.storage.getFlag(t.key);case "label":return narration.narration.getTimesLabelOpened(t.label);case "choice":return narration.narration.getTimesChoiceMade(t.index);case "logic":return core.JsonUnifier.getLogichValue(t.operation,i);case "params":{let e=storage.storage.get(`${T}${narration.narration.openedLabels.length-1}`)||[];if(e&&e.length>t.key)return e[t.key];s.warn("getValue params not found");return}}return t}function B(t,i){if(!t)return false;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case "compare":{let e=core.JsonUnifier.getLogichValue(t.leftValue,i),n=core.JsonUnifier.getLogichValue(t.rightValue,i);switch(t.operator){case "==":return Array.isArray(e)&&Array.isArray(n)?e.length===n.length&&e.every(a=>n.includes(a)):e===n;case "!=":return Array.isArray(e)&&Array.isArray(n)?e.length!==n.length||!e.every(a=>n.includes(a)):e!==n;case "<":return typeof e=="string"&&typeof n=="string"?e.localeCompare(n)<0:Array.isArray(e)&&Array.isArray(n)?e.length<n.length:e<n;case "<=":return typeof e=="string"&&typeof n=="string"?e.localeCompare(n)<=0:Array.isArray(e)&&Array.isArray(n)?e.length<=n.length:e<=n;case ">":return typeof e=="string"&&typeof n=="string"?e.localeCompare(n)>0:Array.isArray(e)&&Array.isArray(n)?e.length>n.length:e>n;case ">=":return typeof e=="string"&&typeof n=="string"?e.localeCompare(n)>=0:Array.isArray(e)&&Array.isArray(n)?e.length>=n.length:e>=n;case "CONTAINS":return Array.isArray(e)&&Array.isArray(n)?n.every(a=>e.includes(a)):Array.isArray(e)?e.includes(n):e.toString().includes(n.toString())}break}case "value":{let e=core.JsonUnifier.getLogichValue(t,i);return Array.isArray(e)?e.length>0:e&&typeof e=="object"?Object.keys(e).length>0:!!e}case "union":return K(t,i)}return !!t}function K(t,i){if(t.unionType==="not"){let n=A(t.condition,i);return Array.isArray(n)?n.length===0:n&&typeof n=="object"?Object.keys(n).length===0:!n}let e=n=>core.JsonUnifier.getLogichValue(n,i)||false;return t.unionType==="and"?t.conditions.every(e):t.conditions.some(e)}function Q(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function C(t,i={}){if(Array.isArray(t)||!t)return t;if(t&&typeof t=="object"&&"type"in t)switch(t.type){case "resulttocombine":return Y(t,i);case "ifelse":return core.JsonUnifier.getLogichValue(t.condition,i)?core.JsonUnifier.getLogichValue(t.then,i):core.JsonUnifier.getLogichValue(t.else,i);case "stepswitch":{let e=core.JsonUnifier.getLogichValue(t.elements,i)||[];if(e.length===0){s.error("getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case "random":{let n=Q(0,e.length-1);return core.JsonUnifier.getLogichValue(e[n],i)}case "loop":{let n=narration.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return n>e.length-1?(n=n%e.length,core.JsonUnifier.getLogichValue(e[n],i)):core.JsonUnifier.getLogichValue(e[n],i)}case "sequential":{let n,a=narration.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end==="lastItem"&&(n=core.JsonUnifier.getLogichValue(e[e.length-1],i)),a>e.length-1?n:core.JsonUnifier.getLogichValue(e[a],i)}case "sequentialrandom":{let n=narration.NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:t.nestedId,onceOnly:true});if(n===void 0&&t.end==="lastItem"){let a=narration.NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!a?.usedRandomNumbers){s.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let r=a.usedRandomNumbers[`0-${e.length-1}`];return core.JsonUnifier.getLogichValue(e[r[r.length-1]],i)}if(n===void 0){s.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return core.JsonUnifier.getLogichValue(e[n],i)}}}}return t}function I(t,i={}){if(t.conditionalStep){let e=pixiVn.createExportableElement(core.JsonUnifier.getLogichValue(t.conditionalStep,i));if(e?.glueEnabled===void 0&&delete e?.glueEnabled,e?.goNextStep===void 0&&delete e?.goNextStep,e?.end===void 0&&delete e?.end,e?.choices===void 0&&delete e?.choices,e?.dialogue===void 0&&delete e?.dialogue,e?.labelToOpen===void 0&&delete e?.labelToOpen,e?.operations===void 0&&delete e?.operations,e){let n={...t,conditionalStep:void 0,...e};return I(n,i)}else narration.narration.dialogGlue&&(narration.narration.dialogGlue=false);}return t}function Y(t,i){let e=t.firstItem,n=(t.secondConditionalItem??[]).flatMap(r=>Array.isArray(r)?r.map(u=>core.JsonUnifier.getLogichValue(u,i)):[core.JsonUnifier.getLogichValue(r,i)]),a=e?[e,...n]:n;if(a.length===0){s.warn("combinateResult toCheck.length === 0");return}if(typeof a[0]=="string")return translator.translator.t(a);if(typeof a[0]=="object"){let r=a,u,y=false,h=r.map((c,x)=>{c=I(c,i);let d=core.JsonUnifier.getLogichValue(c.dialogue,i)||"";return x===0?(u=core.JsonUnifier.getLogichValue(c.glueEnabled,i)||false,d):(typeof d=="object"&&"text"in d&&(d=`${d.character}: ${d.text}`),u===false&&y&&(d=`
2
+
3
+ ${d}`),d&&(y=true),u=core.JsonUnifier.getLogichValue(c.glueEnabled,i)||false,d)}),V=core.JsonUnifier.getLogichValue(h[0],i),f=typeof V=="object"&&"character"in V?V.character:void 0,N=h.flatMap(c=>{let x;c&&typeof c=="object"&&"text"in c?x=c.text:x=c;let d;return Array.isArray(x)?d=x.map(G=>{let z=core.JsonUnifier.getLogichValue(G,i);return translator.translator.t(`${z}`)}):d=core.JsonUnifier.getLogichValue(x,i)||"",translator.translator.t(d)}),v=r.find(c=>c.end),R=r.find(c=>c.choices),w=false,L=false;r.length>0&&(r[0].glueEnabled&&r[0].goNextStep&&r[0].dialogue===void 0&&(narration.narration.dialogGlue=true),w=r[r.length-1].glueEnabled,L=r.reverse().find(c=>!(c.operations&&(!c.dialogue||!c.choices)))?.goNextStep);let _=r.find(c=>c.labelToOpen),J=[];return r.forEach(c=>{c.operations&&(J=[...J,...c.operations]);}),{dialogue:f?{character:f,text:N}:N,end:v?.end,choices:R?.choices,glueEnabled:w,goNextStep:L,labelToOpen:_?.labelToOpen,operations:J}}}exports.VariableGetter=void 0;(a=>{let t=new Set;function i(r){t.add(r);}a.add=i;function e(){t.clear();}a.clear=e;function n(r,u={}){let y=f=>A(f,u)??void 0,h=C(r,u);if(t.size===0)return y(h);let V=y;for(let f of t){let N=V;V=v=>f(v,N)??void 0;}return V(h)}a.getLogichValue=n;})(exports.VariableGetter||(exports.VariableGetter={}));function De(){core.JsonUnifier.init({animateOperation:actions.animateOperation,canvasElementOperation:actions.canvasElementOperation,effectOperation:actions.effectOperation,imageContainerOperation:actions.imageContainerOperation,imageOperation:actions.imageOperation,textOperation:actions.textOperation,narrationOperation:actions.narrationOperation,loadAssets:actions.loadAssets,soundOperation:actions.soundOperation,videoOperation:actions.videoOperation,setStorageValue:actions.setStorageValue,setInitialStorageValue:actions.setInitialStorageValue,getLogichValue:actions.VariableGetter.getLogichValue,getConditionalStep:actions.getConditionalStep});}exports.PIXIVNJSON_PARAM_ID=T;exports.PIXIVNJSON_SCHEMA_URL=$;exports.PixiVNJsonComparationOperators=q;exports.init=De;Object.keys(translator).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return translator[k]}})});Object.keys(interpreter).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return interpreter[k]}})});