@drincs/pixi-vn-json 1.13.9 → 1.13.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  Pixi’VN can be integrated with JSON files to create a visual novel. This method is useful for:
14
14
 
15
- - Add a new narrative to Pixi’VN (It was used to create the integration with <DynamicLink href="/ink">**_ink_**</DynamicLink> and <DynamicLink href="/renpy">Ren'Py</DynamicLink>)
15
+ - Add a new narrative to Pixi’VN (It was used to create the integration with **_ink_**
16
16
  - Create a external tool to create visual novels with Pixi’VN
17
17
 
18
18
  ( In both these cases it is advisable to notify the developers of Pixi’VN to add the new feature to be helped )
@@ -1,4 +1,4 @@
1
- import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory, SoundPlayOptionsWithChannel, MediaInterface, LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
1
+ import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ContainerOptions, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerMemory, SoundPlayOptionsWithChannel, MediaInterface, LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
2
2
  import { KeyframesType, AnimationOptions, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions } from '@drincs/pixi-vn/motion';
3
3
  import { UPDATE_PRIORITY } from 'pixi.js';
4
4
 
@@ -996,4 +996,4 @@ type PixiVNJsonLabelStep = {
996
996
  conditionalStep?: PixiVNJsonConditionalStatements<PixiVNJsonLabelStep | PixiVNJsonLabelStep[]>;
997
997
  };
998
998
 
999
- export type { PixiVNJsonValueGet as $, PixiVNJsonIfElse as A, PixiVNJsonImageContainerEdit as B, PixiVNJsonImageEdit as C, PixiVNJsonInputRequest as D, PixiVNJsonLabelGet as E, PixiVNJsonLabelStep as F, PixiVNJsonLabelToOpen as G, PixiVNJsonLogicGet as H, PixiVNJsonMediaTransiotions as I, PixiVNJsonNarration as J, PixiVNJsonOnlyStorageSet as K, PixiVNJsonOperation as L, PixiVNJsonOperationString as M, PixiVNJsonParamGet as N, PixiVNJsonSound as O, PixiVNJsonAnimateBase as P, PixiVNJsonSoundEdit as Q, PixiVNJsonSoundPauseResume as R, PixiVNJsonSoundPlay as S, PixiVNJsonSoundRemove as T, PixiVNJsonStepSwitch as U, PixiVNJsonStepSwitchElementType as V, PixiVNJsonStepSwitchElementsType as W, PixiVNJsonStorageGet as X, PixiVNJsonTextEdit as Y, PixiVNJsonUnionCondition as Z, PixiVNJsonUnknownEdit as _, PixiVNJsonAnimateSequence as a, PixiVNJsonValueSet as a0, PixiVNJsonVideoEdit as a1, PixiVNJsonVideoPauseResume as a2, PixiVNJsonArithmeticOperations as b, PixiVNJsonArithmeticOperationsArithmetic as c, PixiVNJsonArithmeticOperationsArithmeticSingle as d, PixiVNJsonCanvas as e, PixiVNJsonCanvasAnimate as f, PixiVNJsonCanvasEdit as g, PixiVNJsonCanvasEffect as h, PixiVNJsonCanvasImageContainerShow as i, PixiVNJsonCanvasImageVideoShow as j, PixiVNJsonCanvasRemove as k, PixiVNJsonCanvasShow as l, PixiVNJsonCanvasTextShow as m, PixiVNJsonChoice as n, PixiVNJsonChoiceGet as o, PixiVNJsonChoices as p, PixiVNJsonComparation as q, PixiVNJsonComparationOperatorsType as r, PixiVNJsonConditionalOperation as s, PixiVNJsonConditionalResultToCombine as t, PixiVNJsonConditionalStatements as u, PixiVNJsonConditions as v, PixiVNJsonDialog as w, PixiVNJsonDialogText as x, PixiVNJsonDialogue as y, PixiVNJsonFunction as z };
999
+ export type { PixiVNJsonStepSwitchElementType as $, PixiVNJsonArithmeticOperationsArithmetic as A, PixiVNJsonArithmeticOperationsArithmeticSingle as B, PixiVNJsonCanvas as C, PixiVNJsonCanvasEdit as D, PixiVNJsonCanvasShow as E, PixiVNJsonChoice as F, PixiVNJsonChoiceGet as G, PixiVNJsonChoices as H, PixiVNJsonComparation as I, PixiVNJsonConditionalOperation as J, PixiVNJsonConditionalResultToCombine as K, PixiVNJsonDialog as L, PixiVNJsonDialogText as M, PixiVNJsonDialogue as N, PixiVNJsonFunction as O, PixiVNJsonOperation as P, PixiVNJsonInputRequest as Q, PixiVNJsonLabelGet as R, PixiVNJsonLabelToOpen as S, PixiVNJsonLogicGet as T, PixiVNJsonMediaTransiotions as U, PixiVNJsonParamGet as V, PixiVNJsonSoundEdit as W, PixiVNJsonSoundPauseResume as X, PixiVNJsonSoundPlay as Y, PixiVNJsonSoundRemove as Z, PixiVNJsonStepSwitch as _, PixiVNJsonIfElse as a, PixiVNJsonStepSwitchElementsType as a0, PixiVNJsonStorageGet as a1, PixiVNJsonUnionCondition as a2, PixiVNJsonOperationString as b, PixiVNJsonSound as c, PixiVNJsonCanvasImageVideoShow as d, PixiVNJsonImageEdit as e, PixiVNJsonCanvasRemove as f, PixiVNJsonVideoEdit as g, PixiVNJsonVideoPauseResume as h, PixiVNJsonCanvasImageContainerShow as i, PixiVNJsonImageContainerEdit as j, PixiVNJsonCanvasTextShow as k, PixiVNJsonTextEdit as l, PixiVNJsonUnknownEdit as m, PixiVNJsonValueSet as n, PixiVNJsonOnlyStorageSet as o, PixiVNJsonNarration as p, PixiVNJsonCanvasEffect as q, PixiVNJsonCanvasAnimate as r, PixiVNJsonValueGet as s, PixiVNJsonArithmeticOperations as t, PixiVNJsonConditions as u, PixiVNJsonConditionalStatements as v, PixiVNJsonLabelStep as w, PixiVNJsonComparationOperatorsType as x, PixiVNJsonAnimateBase as y, PixiVNJsonAnimateSequence as z };
@@ -1,4 +1,4 @@
1
- import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory, SoundPlayOptionsWithChannel, MediaInterface, LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
1
+ import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ContainerOptions, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerMemory, SoundPlayOptionsWithChannel, MediaInterface, LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
2
2
  import { KeyframesType, AnimationOptions, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions } from '@drincs/pixi-vn/motion';
3
3
  import { UPDATE_PRIORITY } from 'pixi.js';
4
4
 
@@ -996,4 +996,4 @@ type PixiVNJsonLabelStep = {
996
996
  conditionalStep?: PixiVNJsonConditionalStatements<PixiVNJsonLabelStep | PixiVNJsonLabelStep[]>;
997
997
  };
998
998
 
999
- export type { PixiVNJsonValueGet as $, PixiVNJsonIfElse as A, PixiVNJsonImageContainerEdit as B, PixiVNJsonImageEdit as C, PixiVNJsonInputRequest as D, PixiVNJsonLabelGet as E, PixiVNJsonLabelStep as F, PixiVNJsonLabelToOpen as G, PixiVNJsonLogicGet as H, PixiVNJsonMediaTransiotions as I, PixiVNJsonNarration as J, PixiVNJsonOnlyStorageSet as K, PixiVNJsonOperation as L, PixiVNJsonOperationString as M, PixiVNJsonParamGet as N, PixiVNJsonSound as O, PixiVNJsonAnimateBase as P, PixiVNJsonSoundEdit as Q, PixiVNJsonSoundPauseResume as R, PixiVNJsonSoundPlay as S, PixiVNJsonSoundRemove as T, PixiVNJsonStepSwitch as U, PixiVNJsonStepSwitchElementType as V, PixiVNJsonStepSwitchElementsType as W, PixiVNJsonStorageGet as X, PixiVNJsonTextEdit as Y, PixiVNJsonUnionCondition as Z, PixiVNJsonUnknownEdit as _, PixiVNJsonAnimateSequence as a, PixiVNJsonValueSet as a0, PixiVNJsonVideoEdit as a1, PixiVNJsonVideoPauseResume as a2, PixiVNJsonArithmeticOperations as b, PixiVNJsonArithmeticOperationsArithmetic as c, PixiVNJsonArithmeticOperationsArithmeticSingle as d, PixiVNJsonCanvas as e, PixiVNJsonCanvasAnimate as f, PixiVNJsonCanvasEdit as g, PixiVNJsonCanvasEffect as h, PixiVNJsonCanvasImageContainerShow as i, PixiVNJsonCanvasImageVideoShow as j, PixiVNJsonCanvasRemove as k, PixiVNJsonCanvasShow as l, PixiVNJsonCanvasTextShow as m, PixiVNJsonChoice as n, PixiVNJsonChoiceGet as o, PixiVNJsonChoices as p, PixiVNJsonComparation as q, PixiVNJsonComparationOperatorsType as r, PixiVNJsonConditionalOperation as s, PixiVNJsonConditionalResultToCombine as t, PixiVNJsonConditionalStatements as u, PixiVNJsonConditions as v, PixiVNJsonDialog as w, PixiVNJsonDialogText as x, PixiVNJsonDialogue as y, PixiVNJsonFunction as z };
999
+ export type { PixiVNJsonStepSwitchElementType as $, PixiVNJsonArithmeticOperationsArithmetic as A, PixiVNJsonArithmeticOperationsArithmeticSingle as B, PixiVNJsonCanvas as C, PixiVNJsonCanvasEdit as D, PixiVNJsonCanvasShow as E, PixiVNJsonChoice as F, PixiVNJsonChoiceGet as G, PixiVNJsonChoices as H, PixiVNJsonComparation as I, PixiVNJsonConditionalOperation as J, PixiVNJsonConditionalResultToCombine as K, PixiVNJsonDialog as L, PixiVNJsonDialogText as M, PixiVNJsonDialogue as N, PixiVNJsonFunction as O, PixiVNJsonOperation as P, PixiVNJsonInputRequest as Q, PixiVNJsonLabelGet as R, PixiVNJsonLabelToOpen as S, PixiVNJsonLogicGet as T, PixiVNJsonMediaTransiotions as U, PixiVNJsonParamGet as V, PixiVNJsonSoundEdit as W, PixiVNJsonSoundPauseResume as X, PixiVNJsonSoundPlay as Y, PixiVNJsonSoundRemove as Z, PixiVNJsonStepSwitch as _, PixiVNJsonIfElse as a, PixiVNJsonStepSwitchElementsType as a0, PixiVNJsonStorageGet as a1, PixiVNJsonUnionCondition as a2, PixiVNJsonOperationString as b, PixiVNJsonSound as c, PixiVNJsonCanvasImageVideoShow as d, PixiVNJsonImageEdit as e, PixiVNJsonCanvasRemove as f, PixiVNJsonVideoEdit as g, PixiVNJsonVideoPauseResume as h, PixiVNJsonCanvasImageContainerShow as i, PixiVNJsonImageContainerEdit as j, PixiVNJsonCanvasTextShow as k, PixiVNJsonTextEdit as l, PixiVNJsonUnknownEdit as m, PixiVNJsonValueSet as n, PixiVNJsonOnlyStorageSet as o, PixiVNJsonNarration as p, PixiVNJsonCanvasEffect as q, PixiVNJsonCanvasAnimate as r, PixiVNJsonValueGet as s, PixiVNJsonArithmeticOperations as t, PixiVNJsonConditions as u, PixiVNJsonConditionalStatements as v, PixiVNJsonLabelStep as w, PixiVNJsonComparationOperatorsType as x, PixiVNJsonAnimateBase as y, PixiVNJsonAnimateSequence as z };
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 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=`
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');async function Je(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 a;(o=>(o.log=(r,...c)=>console.log(`[Pixi\u2019VN Json] ${r}`,...c),o.warn=(r,...c)=>console.warn(`[Pixi\u2019VN Json] ${r}`,...c),o.error=(r,...c)=>console.error(`[Pixi\u2019VN Json] ${r}`,...c),o.info=(r,...c)=>console.info(`[Pixi\u2019VN Json] ${r}`,...c)))(a||={});async function b(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 v(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 Oe(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.ImageSprite(e.props,e.url||e.alias);await b(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}):a.error(`Image with alias ${e.alias} not found.`);break}case "remove":v(e);break}}async function Ae(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.VideoSprite(e.props,e.url||e.alias);await b(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}):a.error(`Video with alias ${e.alias} not found.`);break}case "remove":v(e);break;case "pause":case "resume":{let t=canvas.canvas.find(e.alias);t?t.paused=e.operationType==="pause":a.error(`Video with alias ${e.alias} not found.`);break}}}async function ke(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.ImageContainer(e.props,e.urls);await b(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}):a.error(`ImageContainer with alias ${e.alias} not found.`);break}case "remove":v(e);break}}async function Le(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 b(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}):a.error(`Text with alias ${e.alias} not found.`);break}case "remove":v(e);break}}async function je(e){switch(e.operationType){case "edit":try{let t=canvas.canvas.find(e.alias);t?e.props&&t.setMemory({...t.memory,...e.props}):a.error(`Canvas Element with alias ${e.alias} not found.`);}catch(t){a.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,t);}break;case "remove":v(e);break}}async function Ie(e){e.type==="shake"&&await canvas.shakeEffect(e.alias,e.props,e.priority);}function Ee(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 ze(e){switch(e.type){case "input":narration.narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.narration.dialogue=void 0;break}}function $e(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 n=sound.sound.find(e.alias);n&&(t==="volume"?n.volume.value=i:n.paused=i);});break}}var T="___param___";var h=class e{static init(t){t.loadAssets&&(e._loadAssets=t.loadAssets),t.soundOperation&&(e._soundOperation=t.soundOperation),t.imageOperation&&(e._imageOperation=t.imageOperation),t.videoOperation&&(e._videoOperation=t.videoOperation),t.imageContainerOperation&&(e._imageContainerOperation=t.imageContainerOperation),t.textOperation&&(e._textOperation=t.textOperation),t.canvasElementOperation&&(e._canvasElementOperation=t.canvasElementOperation),t.setStorageValue&&(e._setStorageValue=t.setStorageValue),t.setInitialStorageValue&&(e._setInitialStorageValue=t.setInitialStorageValue),t.narrationOperation&&(e._narrationOperation=t.narrationOperation),t.effectOperation&&(e._effectOperation=t.effectOperation),t.animateOperation&&(e._animateOperation=t.animateOperation),t.getLogichValue&&(e._getLogichValue=t.getLogichValue),t.getConditionalStep&&(e._getConditionalStep=t.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return e._loadAssets}static _soundOperation=()=>{throw a.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.")};static get soundOperation(){return e._soundOperation}static _imageOperation=()=>{throw a.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.")};static get imageOperation(){return e._imageOperation}static _videoOperation=()=>{throw a.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.")};static get videoOperation(){return e._videoOperation}static _imageContainerOperation=()=>{throw a.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.")};static get imageContainerOperation(){return e._imageContainerOperation}static _textOperation=()=>{throw a.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.")};static get textOperation(){return e._textOperation}static _canvasElementOperation=()=>{throw a.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.")};static get canvasElementOperation(){return e._canvasElementOperation}static _setStorageValue=()=>{throw a.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.")};static get setStorageValue(){return e._setStorageValue}static _setInitialStorageValue=()=>{throw a.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.")};static get setInitialStorageValue(){return e._setInitialStorageValue}static _narrationOperation=()=>{throw a.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.")};static get narrationOperation(){return e._narrationOperation}static _effectOperation=()=>{throw a.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.")};static get effectOperation(){return e._effectOperation}static _animateOperation=()=>{throw a.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.")};static get animateOperation(){return e._animateOperation}static _getLogichValue=()=>{throw a.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.")};static get getLogichValue(){return e._getLogichValue}static _getConditionalStep=()=>{throw a.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.")};static get getConditionalStep(){return e._getConditionalStep}};function _(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 n=e.args.map(o=>h.getLogichValue(o,t));return i(...n)}else a.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 ci(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 n=storage.storage.get(`${T}${narration.narration.openedLabels.length-1}`)||[];n.length>e.key&&(n[e.key]=i),storage.storage.setTempVariable(`${T}${narration.narration.openedLabels.length-1}`,n);break}}}function ui(e,t={}){let i=z(e.value,t);switch(e.storageType){case "storage":case "tempstorage":storage.storage.default={[e.key]:i};break}}function k(e,t={}){let i=L(e,t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return ge(i,t);case "arithmetic":case "arithmeticsingle":return me(i,t);case "compare":case "union":return xe(i,t);case "function":return _(i,t)}return i}function me(e,t){let i=core.JsonUnifier.getLogichValue(e.leftValue,t);switch(e.type){case "arithmetic":{let n=core.JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "*":return i*n;case "/":return i/n;case "+":return typeof i=="string"||typeof n=="string"?`${i}${n}`:Array.isArray(i)&&Array.isArray(n)?[...i,...n]:Array.isArray(i)?[...i,n]:Array.isArray(n)?[i,...n]:i+n;case "-":if(Array.isArray(i)&&Array.isArray(n))return i.filter(o=>!n.includes(o));if(Array.isArray(i))return i.filter(o=>o!==n);if(Array.isArray(n)){a.warn("getValueFromArithmeticOperations cannot subtract array from non-array");return}return i-n;case "%":return i%n;case "POW":return i**n;case "RANDOM":return narration.narration.getRandomNumber(i,n);case "INTERSECTION":if(Array.isArray(i)&&Array.isArray(n))return i.filter(o=>n.includes(o));a.warn("getValueFromArithmeticOperations cannot intersect non-array values");return;default:a.warn("getValueFromArithmeticOperations unknown operator",e);return}}case "arithmeticsingle":switch(e.operator){case "INT":return Number(i);case "FLOOR":return Math.floor(i);}break}}function ge(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(`${T}${narration.narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];a.warn("getValue params not found");return}}return e}function xe(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),n=core.JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "==":return Array.isArray(i)&&Array.isArray(n)?i.length===n.length&&i.every(o=>n.includes(o)):i===n;case "!=":return Array.isArray(i)&&Array.isArray(n)?i.length!==n.length||!i.every(o=>n.includes(o)):i!==n;case "<":return typeof i=="string"&&typeof n=="string"?i.localeCompare(n)<0:Array.isArray(i)&&Array.isArray(n)?i.length<n.length:i<n;case "<=":return typeof i=="string"&&typeof n=="string"?i.localeCompare(n)<=0:Array.isArray(i)&&Array.isArray(n)?i.length<=n.length:i<=n;case ">":return typeof i=="string"&&typeof n=="string"?i.localeCompare(n)>0:Array.isArray(i)&&Array.isArray(n)?i.length>n.length:i>n;case ">=":return typeof i=="string"&&typeof n=="string"?i.localeCompare(n)>=0:Array.isArray(i)&&Array.isArray(n)?i.length>=n.length:i>=n;case "CONTAINS":return Array.isArray(i)&&Array.isArray(n)?n.every(o=>i.includes(o)):Array.isArray(i)?i.includes(n):i.toString().includes(n.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 Ve(e,t)}return !!e}function Ve(e,t){if(e.unionType==="not"){let n=k(e.condition,t);return Array.isArray(n)?n.length===0:n&&typeof n=="object"?Object.keys(n).length===0:!n}let i=n=>core.JsonUnifier.getLogichValue(n,t)||false;return e.unionType==="and"?e.conditions.every(i):e.conditions.some(i)}function fe(e,t){return Math.floor(Math.random()*(t-e+1)+e)}function L(e,t={}){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return ye(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){a.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":{let n=fe(0,i.length-1);return core.JsonUnifier.getLogichValue(i[n],t)}case "loop":{let n=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return n>i.length-1?(n=n%i.length,core.JsonUnifier.getLogichValue(i[n],t)):core.JsonUnifier.getLogichValue(i[n],t)}case "sequential":{let n,o=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end==="lastItem"&&(n=core.JsonUnifier.getLogichValue(i[i.length-1],t)),o>i.length-1?n:core.JsonUnifier.getLogichValue(i[o],t)}case "sequentialrandom":{let n=narration.NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:e.nestedId,onceOnly:true});if(n===void 0&&e.end==="lastItem"){let o=narration.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!o?.usedRandomNumbers){a.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let r=o.usedRandomNumbers[`0-${i.length-1}`];return core.JsonUnifier.getLogichValue(i[r[r.length-1]],t)}if(n===void 0){a.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return core.JsonUnifier.getLogichValue(i[n],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 n={...e,conditionalStep:void 0,...i};return M(n,t)}else narration.narration.dialogGlue&&(narration.narration.dialogGlue=false);}return e}function ye(e,t){let i=e.firstItem,n=(e.secondConditionalItem??[]).flatMap(r=>Array.isArray(r)?r.map(c=>core.JsonUnifier.getLogichValue(c,t)):[core.JsonUnifier.getLogichValue(r,t)]),o=i?[i,...n]:n;if(o.length===0){a.warn("combinateResult toCheck.length === 0");return}if(typeof o[0]=="string")return translator.translator.t(o);if(typeof o[0]=="object"){let r=o,c,P=false,N=r.map((l,f)=>{l=M(l,t);let u=core.JsonUnifier.getLogichValue(l.dialogue,t)||"";return f===0?(c=core.JsonUnifier.getLogichValue(l.glueEnabled,t)||false,u):(typeof u=="object"&&"text"in u&&(u=`${u.character}: ${u.text}`),c===false&&P&&(u=`
2
2
 
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;
3
+ ${u}`),u&&(P=true),c=core.JsonUnifier.getLogichValue(l.glueEnabled,t)||false,u)}),V=core.JsonUnifier.getLogichValue(N[0],t),y=typeof V=="object"&&"character"in V?V.character:void 0,J=N.flatMap(l=>{let f;l&&typeof l=="object"&&"text"in l?f=l.text:f=l;let u;return Array.isArray(f)?u=f.map(F=>{let D=core.JsonUnifier.getLogichValue(F,t);return translator.translator.t(`${D}`)}):u=core.JsonUnifier.getLogichValue(f,t)||"",translator.translator.t(u)}),C=r.find(l=>l.end),G=r.find(l=>l.choices),j=false,I=false;r.length>0&&(r[0].glueEnabled&&r[0].goNextStep&&r[0].dialogue===void 0&&(narration.narration.dialogGlue=true),j=r[r.length-1].glueEnabled,I=r.reverse().find(l=>!(l.operations&&(!l.dialogue||!l.choices)))?.goNextStep);let $=r.find(l=>l.labelToOpen),O=[];return r.forEach(l=>{l.operations&&(O=[...O,...l.operations]);}),{dialogue:y?{character:y,text:J}:J,end:C?.end,choices:G?.choices,glueEnabled:j,goNextStep:I,labelToOpen:$?.labelToOpen,operations:O}}}exports.VariableGetter=void 0;(o=>{let e=new Set;function t(r){e.add(r);}o.add=t;function i(){e.clear();}o.clear=i;function n(r,c={}){let P=y=>k(y,c)??void 0,N=L(r,c);if(e.size===0)return P(N);let V=P;for(let y of e){let J=V;V=C=>y(C,J)??void 0;}return V(N)}o.getLogichValue=n;})(exports.VariableGetter||={});exports.animateOperation=Ee;exports.canvasElementOperation=je;exports.effectOperation=Ie;exports.getConditionalStep=M;exports.getLogichValue=k;exports.getValueFromConditionalStatements=L;exports.imageContainerOperation=ke;exports.imageOperation=Oe;exports.loadAssets=Je;exports.narrationOperation=ze;exports.setInitialStorageValue=ui;exports.setStorageValue=ci;exports.soundOperation=$e;exports.textOperation=Le;exports.videoOperation=Ae;
@@ -1,4 +1,4 @@
1
- import { L as PixiVNJsonOperation, A as PixiVNJsonIfElse, M as PixiVNJsonOperationString, f as PixiVNJsonCanvasAnimate, _ as PixiVNJsonUnknownEdit, k as PixiVNJsonCanvasRemove, h as PixiVNJsonCanvasEffect, i as PixiVNJsonCanvasImageContainerShow, B as PixiVNJsonImageContainerEdit, j as PixiVNJsonCanvasImageVideoShow, C as PixiVNJsonImageEdit, m as PixiVNJsonCanvasTextShow, Y as PixiVNJsonTextEdit, a1 as PixiVNJsonVideoEdit, a2 as PixiVNJsonVideoPauseResume, J as PixiVNJsonNarration, O as PixiVNJsonSound, F as PixiVNJsonLabelStep, $ as PixiVNJsonValueGet, b as PixiVNJsonArithmeticOperations, v as PixiVNJsonConditions, z as PixiVNJsonFunction, u as PixiVNJsonConditionalStatements, t as PixiVNJsonConditionalResultToCombine, K as PixiVNJsonOnlyStorageSet, a0 as PixiVNJsonValueSet } from './PixiVNJsonLabelStep-DJgORyFd.cjs';
1
+ import { P as PixiVNJsonOperation, a as PixiVNJsonIfElse, b as PixiVNJsonOperationString, r as PixiVNJsonCanvasAnimate, m as PixiVNJsonUnknownEdit, f as PixiVNJsonCanvasRemove, q as PixiVNJsonCanvasEffect, i as PixiVNJsonCanvasImageContainerShow, j as PixiVNJsonImageContainerEdit, d as PixiVNJsonCanvasImageVideoShow, e as PixiVNJsonImageEdit, k as PixiVNJsonCanvasTextShow, l as PixiVNJsonTextEdit, g as PixiVNJsonVideoEdit, h as PixiVNJsonVideoPauseResume, p as PixiVNJsonNarration, c as PixiVNJsonSound, w as PixiVNJsonLabelStep, s as PixiVNJsonValueGet, t as PixiVNJsonArithmeticOperations, u as PixiVNJsonConditions, O as PixiVNJsonFunction, v as PixiVNJsonConditionalStatements, K as PixiVNJsonConditionalResultToCombine, o as PixiVNJsonOnlyStorageSet, n as PixiVNJsonValueSet } from './PixiVNJsonLabelStep-BsGHNfkq.cjs';
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';
package/dist/actions.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { L as PixiVNJsonOperation, A as PixiVNJsonIfElse, M as PixiVNJsonOperationString, f as PixiVNJsonCanvasAnimate, _ as PixiVNJsonUnknownEdit, k as PixiVNJsonCanvasRemove, h as PixiVNJsonCanvasEffect, i as PixiVNJsonCanvasImageContainerShow, B as PixiVNJsonImageContainerEdit, j as PixiVNJsonCanvasImageVideoShow, C as PixiVNJsonImageEdit, m as PixiVNJsonCanvasTextShow, Y as PixiVNJsonTextEdit, a1 as PixiVNJsonVideoEdit, a2 as PixiVNJsonVideoPauseResume, J as PixiVNJsonNarration, O as PixiVNJsonSound, F as PixiVNJsonLabelStep, $ as PixiVNJsonValueGet, b as PixiVNJsonArithmeticOperations, v as PixiVNJsonConditions, z as PixiVNJsonFunction, u as PixiVNJsonConditionalStatements, t as PixiVNJsonConditionalResultToCombine, K as PixiVNJsonOnlyStorageSet, a0 as PixiVNJsonValueSet } from './PixiVNJsonLabelStep-DJgORyFd.js';
1
+ import { P as PixiVNJsonOperation, a as PixiVNJsonIfElse, b as PixiVNJsonOperationString, r as PixiVNJsonCanvasAnimate, m as PixiVNJsonUnknownEdit, f as PixiVNJsonCanvasRemove, q as PixiVNJsonCanvasEffect, i as PixiVNJsonCanvasImageContainerShow, j as PixiVNJsonImageContainerEdit, d as PixiVNJsonCanvasImageVideoShow, e as PixiVNJsonImageEdit, k as PixiVNJsonCanvasTextShow, l as PixiVNJsonTextEdit, g as PixiVNJsonVideoEdit, h as PixiVNJsonVideoPauseResume, p as PixiVNJsonNarration, c as PixiVNJsonSound, w as PixiVNJsonLabelStep, s as PixiVNJsonValueGet, t as PixiVNJsonArithmeticOperations, u as PixiVNJsonConditions, O as PixiVNJsonFunction, v as PixiVNJsonConditionalStatements, K as PixiVNJsonConditionalResultToCombine, o as PixiVNJsonOnlyStorageSet, n as PixiVNJsonValueSet } from './PixiVNJsonLabelStep-BsGHNfkq.js';
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';
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 {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=`
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';async function Je(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 a;(o=>(o.log=(r,...c)=>console.log(`[Pixi\u2019VN Json] ${r}`,...c),o.warn=(r,...c)=>console.warn(`[Pixi\u2019VN Json] ${r}`,...c),o.error=(r,...c)=>console.error(`[Pixi\u2019VN Json] ${r}`,...c),o.info=(r,...c)=>console.info(`[Pixi\u2019VN Json] ${r}`,...c)))(a||={});async function b(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 v(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 Oe(e){switch(e.operationType){case "show":if(e.transition){let t=new ImageSprite(e.props,e.url||e.alias);await b(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}):a.error(`Image with alias ${e.alias} not found.`);break}case "remove":v(e);break}}async function Ae(e){switch(e.operationType){case "show":if(e.transition){let t=new VideoSprite(e.props,e.url||e.alias);await b(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}):a.error(`Video with alias ${e.alias} not found.`);break}case "remove":v(e);break;case "pause":case "resume":{let t=canvas.find(e.alias);t?t.paused=e.operationType==="pause":a.error(`Video with alias ${e.alias} not found.`);break}}}async function ke(e){switch(e.operationType){case "show":if(e.transition){let t=new ImageContainer(e.props,e.urls);await b(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}):a.error(`ImageContainer with alias ${e.alias} not found.`);break}case "remove":v(e);break}}async function Le(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 b(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}):a.error(`Text with alias ${e.alias} not found.`);break}case "remove":v(e);break}}async function je(e){switch(e.operationType){case "edit":try{let t=canvas.find(e.alias);t?e.props&&t.setMemory({...t.memory,...e.props}):a.error(`Canvas Element with alias ${e.alias} not found.`);}catch(t){a.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,t);}break;case "remove":v(e);break}}async function Ie(e){e.type==="shake"&&await shakeEffect(e.alias,e.props,e.priority);}function Ee(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 ze(e){switch(e.type){case "input":narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.dialogue=void 0;break}}function $e(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 n=sound.find(e.alias);n&&(t==="volume"?n.volume.value=i:n.paused=i);});break}}var T="___param___";var h=class e{static init(t){t.loadAssets&&(e._loadAssets=t.loadAssets),t.soundOperation&&(e._soundOperation=t.soundOperation),t.imageOperation&&(e._imageOperation=t.imageOperation),t.videoOperation&&(e._videoOperation=t.videoOperation),t.imageContainerOperation&&(e._imageContainerOperation=t.imageContainerOperation),t.textOperation&&(e._textOperation=t.textOperation),t.canvasElementOperation&&(e._canvasElementOperation=t.canvasElementOperation),t.setStorageValue&&(e._setStorageValue=t.setStorageValue),t.setInitialStorageValue&&(e._setInitialStorageValue=t.setInitialStorageValue),t.narrationOperation&&(e._narrationOperation=t.narrationOperation),t.effectOperation&&(e._effectOperation=t.effectOperation),t.animateOperation&&(e._animateOperation=t.animateOperation),t.getLogichValue&&(e._getLogichValue=t.getLogichValue),t.getConditionalStep&&(e._getConditionalStep=t.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return e._loadAssets}static _soundOperation=()=>{throw a.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.")};static get soundOperation(){return e._soundOperation}static _imageOperation=()=>{throw a.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.")};static get imageOperation(){return e._imageOperation}static _videoOperation=()=>{throw a.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.")};static get videoOperation(){return e._videoOperation}static _imageContainerOperation=()=>{throw a.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.")};static get imageContainerOperation(){return e._imageContainerOperation}static _textOperation=()=>{throw a.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.")};static get textOperation(){return e._textOperation}static _canvasElementOperation=()=>{throw a.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.")};static get canvasElementOperation(){return e._canvasElementOperation}static _setStorageValue=()=>{throw a.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.")};static get setStorageValue(){return e._setStorageValue}static _setInitialStorageValue=()=>{throw a.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.")};static get setInitialStorageValue(){return e._setInitialStorageValue}static _narrationOperation=()=>{throw a.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.")};static get narrationOperation(){return e._narrationOperation}static _effectOperation=()=>{throw a.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.")};static get effectOperation(){return e._effectOperation}static _animateOperation=()=>{throw a.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.")};static get animateOperation(){return e._animateOperation}static _getLogichValue=()=>{throw a.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.")};static get getLogichValue(){return e._getLogichValue}static _getConditionalStep=()=>{throw a.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.")};static get getConditionalStep(){return e._getConditionalStep}};function _(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 n=e.args.map(o=>h.getLogichValue(o,t));return i(...n)}else a.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 ci(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 n=storage.get(`${T}${narration.openedLabels.length-1}`)||[];n.length>e.key&&(n[e.key]=i),storage.setTempVariable(`${T}${narration.openedLabels.length-1}`,n);break}}}function ui(e,t={}){let i=z(e.value,t);switch(e.storageType){case "storage":case "tempstorage":storage.default={[e.key]:i};break}}function k(e,t={}){let i=L(e,t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return ge(i,t);case "arithmetic":case "arithmeticsingle":return me(i,t);case "compare":case "union":return xe(i,t);case "function":return _(i,t)}return i}function me(e,t){let i=JsonUnifier.getLogichValue(e.leftValue,t);switch(e.type){case "arithmetic":{let n=JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "*":return i*n;case "/":return i/n;case "+":return typeof i=="string"||typeof n=="string"?`${i}${n}`:Array.isArray(i)&&Array.isArray(n)?[...i,...n]:Array.isArray(i)?[...i,n]:Array.isArray(n)?[i,...n]:i+n;case "-":if(Array.isArray(i)&&Array.isArray(n))return i.filter(o=>!n.includes(o));if(Array.isArray(i))return i.filter(o=>o!==n);if(Array.isArray(n)){a.warn("getValueFromArithmeticOperations cannot subtract array from non-array");return}return i-n;case "%":return i%n;case "POW":return i**n;case "RANDOM":return narration.getRandomNumber(i,n);case "INTERSECTION":if(Array.isArray(i)&&Array.isArray(n))return i.filter(o=>n.includes(o));a.warn("getValueFromArithmeticOperations cannot intersect non-array values");return;default:a.warn("getValueFromArithmeticOperations unknown operator",e);return}}case "arithmeticsingle":switch(e.operator){case "INT":return Number(i);case "FLOOR":return Math.floor(i);}break}}function ge(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(`${T}${narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];a.warn("getValue params not found");return}}return e}function xe(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),n=JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "==":return Array.isArray(i)&&Array.isArray(n)?i.length===n.length&&i.every(o=>n.includes(o)):i===n;case "!=":return Array.isArray(i)&&Array.isArray(n)?i.length!==n.length||!i.every(o=>n.includes(o)):i!==n;case "<":return typeof i=="string"&&typeof n=="string"?i.localeCompare(n)<0:Array.isArray(i)&&Array.isArray(n)?i.length<n.length:i<n;case "<=":return typeof i=="string"&&typeof n=="string"?i.localeCompare(n)<=0:Array.isArray(i)&&Array.isArray(n)?i.length<=n.length:i<=n;case ">":return typeof i=="string"&&typeof n=="string"?i.localeCompare(n)>0:Array.isArray(i)&&Array.isArray(n)?i.length>n.length:i>n;case ">=":return typeof i=="string"&&typeof n=="string"?i.localeCompare(n)>=0:Array.isArray(i)&&Array.isArray(n)?i.length>=n.length:i>=n;case "CONTAINS":return Array.isArray(i)&&Array.isArray(n)?n.every(o=>i.includes(o)):Array.isArray(i)?i.includes(n):i.toString().includes(n.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 Ve(e,t)}return !!e}function Ve(e,t){if(e.unionType==="not"){let n=k(e.condition,t);return Array.isArray(n)?n.length===0:n&&typeof n=="object"?Object.keys(n).length===0:!n}let i=n=>JsonUnifier.getLogichValue(n,t)||false;return e.unionType==="and"?e.conditions.every(i):e.conditions.some(i)}function fe(e,t){return Math.floor(Math.random()*(t-e+1)+e)}function L(e,t={}){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return ye(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){a.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":{let n=fe(0,i.length-1);return JsonUnifier.getLogichValue(i[n],t)}case "loop":{let n=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return n>i.length-1?(n=n%i.length,JsonUnifier.getLogichValue(i[n],t)):JsonUnifier.getLogichValue(i[n],t)}case "sequential":{let n,o=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end==="lastItem"&&(n=JsonUnifier.getLogichValue(i[i.length-1],t)),o>i.length-1?n:JsonUnifier.getLogichValue(i[o],t)}case "sequentialrandom":{let n=NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:e.nestedId,onceOnly:true});if(n===void 0&&e.end==="lastItem"){let o=NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!o?.usedRandomNumbers){a.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let r=o.usedRandomNumbers[`0-${i.length-1}`];return JsonUnifier.getLogichValue(i[r[r.length-1]],t)}if(n===void 0){a.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return JsonUnifier.getLogichValue(i[n],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 n={...e,conditionalStep:void 0,...i};return M(n,t)}else narration.dialogGlue&&(narration.dialogGlue=false);}return e}function ye(e,t){let i=e.firstItem,n=(e.secondConditionalItem??[]).flatMap(r=>Array.isArray(r)?r.map(c=>JsonUnifier.getLogichValue(c,t)):[JsonUnifier.getLogichValue(r,t)]),o=i?[i,...n]:n;if(o.length===0){a.warn("combinateResult toCheck.length === 0");return}if(typeof o[0]=="string")return translator.t(o);if(typeof o[0]=="object"){let r=o,c,P=false,N=r.map((l,f)=>{l=M(l,t);let u=JsonUnifier.getLogichValue(l.dialogue,t)||"";return f===0?(c=JsonUnifier.getLogichValue(l.glueEnabled,t)||false,u):(typeof u=="object"&&"text"in u&&(u=`${u.character}: ${u.text}`),c===false&&P&&(u=`
2
2
 
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};
3
+ ${u}`),u&&(P=true),c=JsonUnifier.getLogichValue(l.glueEnabled,t)||false,u)}),V=JsonUnifier.getLogichValue(N[0],t),y=typeof V=="object"&&"character"in V?V.character:void 0,J=N.flatMap(l=>{let f;l&&typeof l=="object"&&"text"in l?f=l.text:f=l;let u;return Array.isArray(f)?u=f.map(F=>{let D=JsonUnifier.getLogichValue(F,t);return translator.t(`${D}`)}):u=JsonUnifier.getLogichValue(f,t)||"",translator.t(u)}),C=r.find(l=>l.end),G=r.find(l=>l.choices),j=false,I=false;r.length>0&&(r[0].glueEnabled&&r[0].goNextStep&&r[0].dialogue===void 0&&(narration.dialogGlue=true),j=r[r.length-1].glueEnabled,I=r.reverse().find(l=>!(l.operations&&(!l.dialogue||!l.choices)))?.goNextStep);let $=r.find(l=>l.labelToOpen),O=[];return r.forEach(l=>{l.operations&&(O=[...O,...l.operations]);}),{dialogue:y?{character:y,text:J}:J,end:C?.end,choices:G?.choices,glueEnabled:j,goNextStep:I,labelToOpen:$?.labelToOpen,operations:O}}}var he;(o=>{let e=new Set;function t(r){e.add(r);}o.add=t;function i(){e.clear();}o.clear=i;function n(r,c={}){let P=y=>k(y,c)??void 0,N=L(r,c);if(e.size===0)return P(N);let V=P;for(let y of e){let J=V;V=C=>y(C,J)??void 0;}return V(N)}o.getLogichValue=n;})(he||={});export{he as VariableGetter,Ee as animateOperation,je as canvasElementOperation,Ie as effectOperation,M as getConditionalStep,k as getLogichValue,L as getValueFromConditionalStatements,ke as imageContainerOperation,Oe as imageOperation,Je as loadAssets,ze as narrationOperation,ui as setInitialStorageValue,ci as setStorageValue,$e as soundOperation,Le as textOperation,Ae as videoOperation};
package/dist/core.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var pixiVn=require('@drincs/pixi-vn');var x=Object.defineProperty;var d=(s,i,p)=>i in s?x(s,i,{enumerable:true,configurable:true,writable:true,value:p}):s[i]=p;var o=(s,i,p)=>d(s,typeof i!="symbol"?i+"":i,p);var t;(P=>(P.log=(n,...r)=>console.log(`[Pixi\u2019VN Json] ${n}`,...r),P.warn=(n,...r)=>console.warn(`[Pixi\u2019VN Json] ${n}`,...r),P.error=(n,...r)=>console.error(`[Pixi\u2019VN Json] ${n}`,...r),P.info=(n,...r)=>console.info(`[Pixi\u2019VN Json] ${n}`,...r)))(t||(t={}));var e=class e{static init(i){i.loadAssets&&(e._loadAssets=i.loadAssets),i.soundOperation&&(e._soundOperation=i.soundOperation),i.imageOperation&&(e._imageOperation=i.imageOperation),i.videoOperation&&(e._videoOperation=i.videoOperation),i.imageContainerOperation&&(e._imageContainerOperation=i.imageContainerOperation),i.textOperation&&(e._textOperation=i.textOperation),i.canvasElementOperation&&(e._canvasElementOperation=i.canvasElementOperation),i.setStorageValue&&(e._setStorageValue=i.setStorageValue),i.setInitialStorageValue&&(e._setInitialStorageValue=i.setInitialStorageValue),i.narrationOperation&&(e._narrationOperation=i.narrationOperation),i.effectOperation&&(e._effectOperation=i.effectOperation),i.animateOperation&&(e._animateOperation=i.animateOperation),i.getLogichValue&&(e._getLogichValue=i.getLogichValue),i.getConditionalStep&&(e._getConditionalStep=i.getConditionalStep);}static get loadAssets(){return e._loadAssets}static get soundOperation(){return e._soundOperation}static get imageOperation(){return e._imageOperation}static get videoOperation(){return e._videoOperation}static get imageContainerOperation(){return e._imageContainerOperation}static get textOperation(){return e._textOperation}static get canvasElementOperation(){return e._canvasElementOperation}static get setStorageValue(){return e._setStorageValue}static get setInitialStorageValue(){return e._setInitialStorageValue}static get narrationOperation(){return e._narrationOperation}static get effectOperation(){return e._effectOperation}static get animateOperation(){return e._animateOperation}static get getLogichValue(){return e._getLogichValue}static get getConditionalStep(){return e._getConditionalStep}};o(e,"_loadAssets",()=>{}),o(e,"_soundOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_imageOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_videoOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_imageContainerOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_textOperation",()=>{throw t.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.")}),o(e,"_canvasElementOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_setStorageValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_setInitialStorageValue",()=>{throw t.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.")}),o(e,"_narrationOperation",()=>{throw t.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.")}),o(e,"_effectOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_animateOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_getLogichValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_getConditionalStep",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var c=e;exports.JsonUnifier=c;
1
+ 'use strict';var pixiVn=require('@drincs/pixi-vn');var t;(r=>(r.log=(a,...n)=>console.log(`[Pixi\u2019VN Json] ${a}`,...n),r.warn=(a,...n)=>console.warn(`[Pixi\u2019VN Json] ${a}`,...n),r.error=(a,...n)=>console.error(`[Pixi\u2019VN Json] ${a}`,...n),r.info=(a,...n)=>console.info(`[Pixi\u2019VN Json] ${a}`,...n)))(t||={});var s=class e{static init(i){i.loadAssets&&(e._loadAssets=i.loadAssets),i.soundOperation&&(e._soundOperation=i.soundOperation),i.imageOperation&&(e._imageOperation=i.imageOperation),i.videoOperation&&(e._videoOperation=i.videoOperation),i.imageContainerOperation&&(e._imageContainerOperation=i.imageContainerOperation),i.textOperation&&(e._textOperation=i.textOperation),i.canvasElementOperation&&(e._canvasElementOperation=i.canvasElementOperation),i.setStorageValue&&(e._setStorageValue=i.setStorageValue),i.setInitialStorageValue&&(e._setInitialStorageValue=i.setInitialStorageValue),i.narrationOperation&&(e._narrationOperation=i.narrationOperation),i.effectOperation&&(e._effectOperation=i.effectOperation),i.animateOperation&&(e._animateOperation=i.animateOperation),i.getLogichValue&&(e._getLogichValue=i.getLogichValue),i.getConditionalStep&&(e._getConditionalStep=i.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return e._loadAssets}static _soundOperation=()=>{throw t.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.")};static get soundOperation(){return e._soundOperation}static _imageOperation=()=>{throw t.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.")};static get imageOperation(){return e._imageOperation}static _videoOperation=()=>{throw t.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.")};static get videoOperation(){return e._videoOperation}static _imageContainerOperation=()=>{throw t.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.")};static get imageContainerOperation(){return e._imageContainerOperation}static _textOperation=()=>{throw t.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.")};static get textOperation(){return e._textOperation}static _canvasElementOperation=()=>{throw t.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.")};static get canvasElementOperation(){return e._canvasElementOperation}static _setStorageValue=()=>{throw t.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.")};static get setStorageValue(){return e._setStorageValue}static _setInitialStorageValue=()=>{throw t.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.")};static get setInitialStorageValue(){return e._setInitialStorageValue}static _narrationOperation=()=>{throw t.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.")};static get narrationOperation(){return e._narrationOperation}static _effectOperation=()=>{throw t.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.")};static get effectOperation(){return e._effectOperation}static _animateOperation=()=>{throw t.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.")};static get animateOperation(){return e._animateOperation}static _getLogichValue=()=>{throw t.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.")};static get getLogichValue(){return e._getLogichValue}static _getConditionalStep=()=>{throw t.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.")};static get getConditionalStep(){return e._getConditionalStep}};exports.JsonUnifier=s;
package/dist/core.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ImageSpriteMemory, VideoSpriteMemory, ContainerMemory, ContainerChild, StepLabelPropsType, StorageElementType } from '@drincs/pixi-vn';
2
- import { L as PixiVNJsonOperation, A as PixiVNJsonIfElse, M as PixiVNJsonOperationString, O as PixiVNJsonSound, j as PixiVNJsonCanvasImageVideoShow, C as PixiVNJsonImageEdit, k as PixiVNJsonCanvasRemove, a1 as PixiVNJsonVideoEdit, a2 as PixiVNJsonVideoPauseResume, i as PixiVNJsonCanvasImageContainerShow, B as PixiVNJsonImageContainerEdit, m as PixiVNJsonCanvasTextShow, Y as PixiVNJsonTextEdit, _ as PixiVNJsonUnknownEdit, a0 as PixiVNJsonValueSet, K as PixiVNJsonOnlyStorageSet, J as PixiVNJsonNarration, h as PixiVNJsonCanvasEffect, f as PixiVNJsonCanvasAnimate, $ as PixiVNJsonValueGet, b as PixiVNJsonArithmeticOperations, v as PixiVNJsonConditions, u as PixiVNJsonConditionalStatements, F as PixiVNJsonLabelStep } from './PixiVNJsonLabelStep-DJgORyFd.cjs';
2
+ import { P as PixiVNJsonOperation, a as PixiVNJsonIfElse, b as PixiVNJsonOperationString, c as PixiVNJsonSound, d as PixiVNJsonCanvasImageVideoShow, e as PixiVNJsonImageEdit, f as PixiVNJsonCanvasRemove, g as PixiVNJsonVideoEdit, h as PixiVNJsonVideoPauseResume, i as PixiVNJsonCanvasImageContainerShow, j as PixiVNJsonImageContainerEdit, k as PixiVNJsonCanvasTextShow, l as PixiVNJsonTextEdit, m as PixiVNJsonUnknownEdit, n as PixiVNJsonValueSet, o as PixiVNJsonOnlyStorageSet, p as PixiVNJsonNarration, q as PixiVNJsonCanvasEffect, r as PixiVNJsonCanvasAnimate, s as PixiVNJsonValueGet, t as PixiVNJsonArithmeticOperations, u as PixiVNJsonConditions, v as PixiVNJsonConditionalStatements, w as PixiVNJsonLabelStep } from './PixiVNJsonLabelStep-BsGHNfkq.cjs';
3
3
  import '@drincs/pixi-vn/motion';
4
4
  import 'pixi.js';
5
5
 
package/dist/core.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ImageSpriteMemory, VideoSpriteMemory, ContainerMemory, ContainerChild, StepLabelPropsType, StorageElementType } from '@drincs/pixi-vn';
2
- import { L as PixiVNJsonOperation, A as PixiVNJsonIfElse, M as PixiVNJsonOperationString, O as PixiVNJsonSound, j as PixiVNJsonCanvasImageVideoShow, C as PixiVNJsonImageEdit, k as PixiVNJsonCanvasRemove, a1 as PixiVNJsonVideoEdit, a2 as PixiVNJsonVideoPauseResume, i as PixiVNJsonCanvasImageContainerShow, B as PixiVNJsonImageContainerEdit, m as PixiVNJsonCanvasTextShow, Y as PixiVNJsonTextEdit, _ as PixiVNJsonUnknownEdit, a0 as PixiVNJsonValueSet, K as PixiVNJsonOnlyStorageSet, J as PixiVNJsonNarration, h as PixiVNJsonCanvasEffect, f as PixiVNJsonCanvasAnimate, $ as PixiVNJsonValueGet, b as PixiVNJsonArithmeticOperations, v as PixiVNJsonConditions, u as PixiVNJsonConditionalStatements, F as PixiVNJsonLabelStep } from './PixiVNJsonLabelStep-DJgORyFd.js';
2
+ import { P as PixiVNJsonOperation, a as PixiVNJsonIfElse, b as PixiVNJsonOperationString, c as PixiVNJsonSound, d as PixiVNJsonCanvasImageVideoShow, e as PixiVNJsonImageEdit, f as PixiVNJsonCanvasRemove, g as PixiVNJsonVideoEdit, h as PixiVNJsonVideoPauseResume, i as PixiVNJsonCanvasImageContainerShow, j as PixiVNJsonImageContainerEdit, k as PixiVNJsonCanvasTextShow, l as PixiVNJsonTextEdit, m as PixiVNJsonUnknownEdit, n as PixiVNJsonValueSet, o as PixiVNJsonOnlyStorageSet, p as PixiVNJsonNarration, q as PixiVNJsonCanvasEffect, r as PixiVNJsonCanvasAnimate, s as PixiVNJsonValueGet, t as PixiVNJsonArithmeticOperations, u as PixiVNJsonConditions, v as PixiVNJsonConditionalStatements, w as PixiVNJsonLabelStep } from './PixiVNJsonLabelStep-BsGHNfkq.js';
3
3
  import '@drincs/pixi-vn/motion';
4
4
  import 'pixi.js';
5
5
 
package/dist/core.mjs CHANGED
@@ -1 +1 @@
1
- import {PixiError}from'@drincs/pixi-vn';var x=Object.defineProperty;var d=(s,i,p)=>i in s?x(s,i,{enumerable:true,configurable:true,writable:true,value:p}):s[i]=p;var o=(s,i,p)=>d(s,typeof i!="symbol"?i+"":i,p);var t;(P=>(P.log=(n,...r)=>console.log(`[Pixi\u2019VN Json] ${n}`,...r),P.warn=(n,...r)=>console.warn(`[Pixi\u2019VN Json] ${n}`,...r),P.error=(n,...r)=>console.error(`[Pixi\u2019VN Json] ${n}`,...r),P.info=(n,...r)=>console.info(`[Pixi\u2019VN Json] ${n}`,...r)))(t||(t={}));var e=class e{static init(i){i.loadAssets&&(e._loadAssets=i.loadAssets),i.soundOperation&&(e._soundOperation=i.soundOperation),i.imageOperation&&(e._imageOperation=i.imageOperation),i.videoOperation&&(e._videoOperation=i.videoOperation),i.imageContainerOperation&&(e._imageContainerOperation=i.imageContainerOperation),i.textOperation&&(e._textOperation=i.textOperation),i.canvasElementOperation&&(e._canvasElementOperation=i.canvasElementOperation),i.setStorageValue&&(e._setStorageValue=i.setStorageValue),i.setInitialStorageValue&&(e._setInitialStorageValue=i.setInitialStorageValue),i.narrationOperation&&(e._narrationOperation=i.narrationOperation),i.effectOperation&&(e._effectOperation=i.effectOperation),i.animateOperation&&(e._animateOperation=i.animateOperation),i.getLogichValue&&(e._getLogichValue=i.getLogichValue),i.getConditionalStep&&(e._getConditionalStep=i.getConditionalStep);}static get loadAssets(){return e._loadAssets}static get soundOperation(){return e._soundOperation}static get imageOperation(){return e._imageOperation}static get videoOperation(){return e._videoOperation}static get imageContainerOperation(){return e._imageContainerOperation}static get textOperation(){return e._textOperation}static get canvasElementOperation(){return e._canvasElementOperation}static get setStorageValue(){return e._setStorageValue}static get setInitialStorageValue(){return e._setInitialStorageValue}static get narrationOperation(){return e._narrationOperation}static get effectOperation(){return e._effectOperation}static get animateOperation(){return e._animateOperation}static get getLogichValue(){return e._getLogichValue}static get getConditionalStep(){return e._getConditionalStep}};o(e,"_loadAssets",()=>{}),o(e,"_soundOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_imageOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_videoOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_imageContainerOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_textOperation",()=>{throw t.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.")}),o(e,"_canvasElementOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_setStorageValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_setInitialStorageValue",()=>{throw t.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.")}),o(e,"_narrationOperation",()=>{throw t.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.")}),o(e,"_effectOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_animateOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_getLogichValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_getConditionalStep",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var c=e;export{c as JsonUnifier};
1
+ import {PixiError}from'@drincs/pixi-vn';var t;(r=>(r.log=(a,...n)=>console.log(`[Pixi\u2019VN Json] ${a}`,...n),r.warn=(a,...n)=>console.warn(`[Pixi\u2019VN Json] ${a}`,...n),r.error=(a,...n)=>console.error(`[Pixi\u2019VN Json] ${a}`,...n),r.info=(a,...n)=>console.info(`[Pixi\u2019VN Json] ${a}`,...n)))(t||={});var s=class e{static init(i){i.loadAssets&&(e._loadAssets=i.loadAssets),i.soundOperation&&(e._soundOperation=i.soundOperation),i.imageOperation&&(e._imageOperation=i.imageOperation),i.videoOperation&&(e._videoOperation=i.videoOperation),i.imageContainerOperation&&(e._imageContainerOperation=i.imageContainerOperation),i.textOperation&&(e._textOperation=i.textOperation),i.canvasElementOperation&&(e._canvasElementOperation=i.canvasElementOperation),i.setStorageValue&&(e._setStorageValue=i.setStorageValue),i.setInitialStorageValue&&(e._setInitialStorageValue=i.setInitialStorageValue),i.narrationOperation&&(e._narrationOperation=i.narrationOperation),i.effectOperation&&(e._effectOperation=i.effectOperation),i.animateOperation&&(e._animateOperation=i.animateOperation),i.getLogichValue&&(e._getLogichValue=i.getLogichValue),i.getConditionalStep&&(e._getConditionalStep=i.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return e._loadAssets}static _soundOperation=()=>{throw t.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.")};static get soundOperation(){return e._soundOperation}static _imageOperation=()=>{throw t.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.")};static get imageOperation(){return e._imageOperation}static _videoOperation=()=>{throw t.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.")};static get videoOperation(){return e._videoOperation}static _imageContainerOperation=()=>{throw t.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.")};static get imageContainerOperation(){return e._imageContainerOperation}static _textOperation=()=>{throw t.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.")};static get textOperation(){return e._textOperation}static _canvasElementOperation=()=>{throw t.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.")};static get canvasElementOperation(){return e._canvasElementOperation}static _setStorageValue=()=>{throw t.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.")};static get setStorageValue(){return e._setStorageValue}static _setInitialStorageValue=()=>{throw t.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.")};static get setInitialStorageValue(){return e._setInitialStorageValue}static _narrationOperation=()=>{throw t.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.")};static get narrationOperation(){return e._narrationOperation}static _effectOperation=()=>{throw t.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.")};static get effectOperation(){return e._effectOperation}static _animateOperation=()=>{throw t.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.")};static get animateOperation(){return e._animateOperation}static _getLogichValue=()=>{throw t.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.")};static get getLogichValue(){return e._getLogichValue}static _getConditionalStep=()=>{throw t.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.")};static get getConditionalStep(){return e._getConditionalStep}};export{s as JsonUnifier};
package/dist/index.cjs CHANGED
@@ -1,3 +1,2 @@
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]}})});
1
+ 'use strict';var actions=require('@drincs/pixi-vn-json/actions'),core=require('@drincs/pixi-vn-json/core'),interpreter=require('@drincs/pixi-vn-json/interpreter'),translator=require('@drincs/pixi-vn-json/translator');var t={version:"1.13.10"};var i="___param___",s=`https://pixi-vn.com/schemas/${t.version}/schema.json`,r=["==","!=","<","<=",">",">=","CONTAINS"];function b(){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});}
2
+ Object.defineProperty(exports,"VariableGetter",{enumerable:true,get:function(){return actions.VariableGetter}});exports.PIXIVNJSON_PARAM_ID=i;exports.PIXIVNJSON_SCHEMA_URL=s;exports.PixiVNJsonComparationOperators=r;exports.init=b;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]}})});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]}})});
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { r as PixiVNJsonComparationOperatorsType } from './PixiVNJsonLabelStep-DJgORyFd.cjs';
2
- export { P as PixiVNJsonAnimateBase, a as PixiVNJsonAnimateSequence, b as PixiVNJsonArithmeticOperations, c as PixiVNJsonArithmeticOperationsArithmetic, d as PixiVNJsonArithmeticOperationsArithmeticSingle, e as PixiVNJsonCanvas, f as PixiVNJsonCanvasAnimate, g as PixiVNJsonCanvasEdit, h as PixiVNJsonCanvasEffect, i as PixiVNJsonCanvasImageContainerShow, j as PixiVNJsonCanvasImageVideoShow, k as PixiVNJsonCanvasRemove, l as PixiVNJsonCanvasShow, m as PixiVNJsonCanvasTextShow, n as PixiVNJsonChoice, o as PixiVNJsonChoiceGet, p as PixiVNJsonChoices, q as PixiVNJsonComparation, s as PixiVNJsonConditionalOperation, t as PixiVNJsonConditionalResultToCombine, u as PixiVNJsonConditionalStatements, v as PixiVNJsonConditions, w as PixiVNJsonDialog, x as PixiVNJsonDialogText, y as PixiVNJsonDialogue, z as PixiVNJsonFunction, A as PixiVNJsonIfElse, B as PixiVNJsonImageContainerEdit, C as PixiVNJsonImageEdit, D as PixiVNJsonInputRequest, E as PixiVNJsonLabelGet, F as PixiVNJsonLabelStep, G as PixiVNJsonLabelToOpen, H as PixiVNJsonLogicGet, I as PixiVNJsonMediaTransiotions, J as PixiVNJsonNarration, K as PixiVNJsonOnlyStorageSet, L as PixiVNJsonOperation, M as PixiVNJsonOperationString, N as PixiVNJsonParamGet, O as PixiVNJsonSound, Q as PixiVNJsonSoundEdit, R as PixiVNJsonSoundPauseResume, S as PixiVNJsonSoundPlay, T as PixiVNJsonSoundRemove, U as PixiVNJsonStepSwitch, V as PixiVNJsonStepSwitchElementType, W as PixiVNJsonStepSwitchElementsType, X as PixiVNJsonStorageGet, Y as PixiVNJsonTextEdit, Z as PixiVNJsonUnionCondition, _ as PixiVNJsonUnknownEdit, $ as PixiVNJsonValueGet, a0 as PixiVNJsonValueSet, a1 as PixiVNJsonVideoEdit, a2 as PixiVNJsonVideoPauseResume } from './PixiVNJsonLabelStep-DJgORyFd.cjs';
1
+ import { x as PixiVNJsonComparationOperatorsType } from './PixiVNJsonLabelStep-BsGHNfkq.cjs';
2
+ export { y as PixiVNJsonAnimateBase, z as PixiVNJsonAnimateSequence, t as PixiVNJsonArithmeticOperations, A as PixiVNJsonArithmeticOperationsArithmetic, B as PixiVNJsonArithmeticOperationsArithmeticSingle, C as PixiVNJsonCanvas, r as PixiVNJsonCanvasAnimate, D as PixiVNJsonCanvasEdit, q as PixiVNJsonCanvasEffect, i as PixiVNJsonCanvasImageContainerShow, d as PixiVNJsonCanvasImageVideoShow, f as PixiVNJsonCanvasRemove, E as PixiVNJsonCanvasShow, k as PixiVNJsonCanvasTextShow, F as PixiVNJsonChoice, G as PixiVNJsonChoiceGet, H as PixiVNJsonChoices, I as PixiVNJsonComparation, J as PixiVNJsonConditionalOperation, K as PixiVNJsonConditionalResultToCombine, v as PixiVNJsonConditionalStatements, u as PixiVNJsonConditions, L as PixiVNJsonDialog, M as PixiVNJsonDialogText, N as PixiVNJsonDialogue, O as PixiVNJsonFunction, a as PixiVNJsonIfElse, j as PixiVNJsonImageContainerEdit, e as PixiVNJsonImageEdit, Q as PixiVNJsonInputRequest, R as PixiVNJsonLabelGet, w as PixiVNJsonLabelStep, S as PixiVNJsonLabelToOpen, T as PixiVNJsonLogicGet, U as PixiVNJsonMediaTransiotions, p as PixiVNJsonNarration, o as PixiVNJsonOnlyStorageSet, P as PixiVNJsonOperation, b as PixiVNJsonOperationString, V as PixiVNJsonParamGet, c as PixiVNJsonSound, W as PixiVNJsonSoundEdit, X as PixiVNJsonSoundPauseResume, Y as PixiVNJsonSoundPlay, Z as PixiVNJsonSoundRemove, _ as PixiVNJsonStepSwitch, $ as PixiVNJsonStepSwitchElementType, a0 as PixiVNJsonStepSwitchElementsType, a1 as PixiVNJsonStorageGet, l as PixiVNJsonTextEdit, a2 as PixiVNJsonUnionCondition, m as PixiVNJsonUnknownEdit, s as PixiVNJsonValueGet, n as PixiVNJsonValueSet, g as PixiVNJsonVideoEdit, h as PixiVNJsonVideoPauseResume } from './PixiVNJsonLabelStep-BsGHNfkq.cjs';
3
+ export { PixiVNJson, PixiVNJsonLabels } from './schema.cjs';
3
4
  export { V as VariableGetter, a as VariableGetterHandler } from './VariableGetter-ZDA6kdah.cjs';
4
5
  export { LabelJson, importPixiVNJson } from './interpreter.cjs';
5
- export { PixiVNJson, PixiVNJsonLabels } from './schema.cjs';
6
6
  export { ReplaceHandler, ReplaceHandlerOptions, TextReplaces, translator } from './translator.cjs';
7
7
  import '@drincs/pixi-vn';
8
8
  import '@drincs/pixi-vn/motion';
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { r as PixiVNJsonComparationOperatorsType } from './PixiVNJsonLabelStep-DJgORyFd.js';
2
- export { P as PixiVNJsonAnimateBase, a as PixiVNJsonAnimateSequence, b as PixiVNJsonArithmeticOperations, c as PixiVNJsonArithmeticOperationsArithmetic, d as PixiVNJsonArithmeticOperationsArithmeticSingle, e as PixiVNJsonCanvas, f as PixiVNJsonCanvasAnimate, g as PixiVNJsonCanvasEdit, h as PixiVNJsonCanvasEffect, i as PixiVNJsonCanvasImageContainerShow, j as PixiVNJsonCanvasImageVideoShow, k as PixiVNJsonCanvasRemove, l as PixiVNJsonCanvasShow, m as PixiVNJsonCanvasTextShow, n as PixiVNJsonChoice, o as PixiVNJsonChoiceGet, p as PixiVNJsonChoices, q as PixiVNJsonComparation, s as PixiVNJsonConditionalOperation, t as PixiVNJsonConditionalResultToCombine, u as PixiVNJsonConditionalStatements, v as PixiVNJsonConditions, w as PixiVNJsonDialog, x as PixiVNJsonDialogText, y as PixiVNJsonDialogue, z as PixiVNJsonFunction, A as PixiVNJsonIfElse, B as PixiVNJsonImageContainerEdit, C as PixiVNJsonImageEdit, D as PixiVNJsonInputRequest, E as PixiVNJsonLabelGet, F as PixiVNJsonLabelStep, G as PixiVNJsonLabelToOpen, H as PixiVNJsonLogicGet, I as PixiVNJsonMediaTransiotions, J as PixiVNJsonNarration, K as PixiVNJsonOnlyStorageSet, L as PixiVNJsonOperation, M as PixiVNJsonOperationString, N as PixiVNJsonParamGet, O as PixiVNJsonSound, Q as PixiVNJsonSoundEdit, R as PixiVNJsonSoundPauseResume, S as PixiVNJsonSoundPlay, T as PixiVNJsonSoundRemove, U as PixiVNJsonStepSwitch, V as PixiVNJsonStepSwitchElementType, W as PixiVNJsonStepSwitchElementsType, X as PixiVNJsonStorageGet, Y as PixiVNJsonTextEdit, Z as PixiVNJsonUnionCondition, _ as PixiVNJsonUnknownEdit, $ as PixiVNJsonValueGet, a0 as PixiVNJsonValueSet, a1 as PixiVNJsonVideoEdit, a2 as PixiVNJsonVideoPauseResume } from './PixiVNJsonLabelStep-DJgORyFd.js';
1
+ import { x as PixiVNJsonComparationOperatorsType } from './PixiVNJsonLabelStep-BsGHNfkq.js';
2
+ export { y as PixiVNJsonAnimateBase, z as PixiVNJsonAnimateSequence, t as PixiVNJsonArithmeticOperations, A as PixiVNJsonArithmeticOperationsArithmetic, B as PixiVNJsonArithmeticOperationsArithmeticSingle, C as PixiVNJsonCanvas, r as PixiVNJsonCanvasAnimate, D as PixiVNJsonCanvasEdit, q as PixiVNJsonCanvasEffect, i as PixiVNJsonCanvasImageContainerShow, d as PixiVNJsonCanvasImageVideoShow, f as PixiVNJsonCanvasRemove, E as PixiVNJsonCanvasShow, k as PixiVNJsonCanvasTextShow, F as PixiVNJsonChoice, G as PixiVNJsonChoiceGet, H as PixiVNJsonChoices, I as PixiVNJsonComparation, J as PixiVNJsonConditionalOperation, K as PixiVNJsonConditionalResultToCombine, v as PixiVNJsonConditionalStatements, u as PixiVNJsonConditions, L as PixiVNJsonDialog, M as PixiVNJsonDialogText, N as PixiVNJsonDialogue, O as PixiVNJsonFunction, a as PixiVNJsonIfElse, j as PixiVNJsonImageContainerEdit, e as PixiVNJsonImageEdit, Q as PixiVNJsonInputRequest, R as PixiVNJsonLabelGet, w as PixiVNJsonLabelStep, S as PixiVNJsonLabelToOpen, T as PixiVNJsonLogicGet, U as PixiVNJsonMediaTransiotions, p as PixiVNJsonNarration, o as PixiVNJsonOnlyStorageSet, P as PixiVNJsonOperation, b as PixiVNJsonOperationString, V as PixiVNJsonParamGet, c as PixiVNJsonSound, W as PixiVNJsonSoundEdit, X as PixiVNJsonSoundPauseResume, Y as PixiVNJsonSoundPlay, Z as PixiVNJsonSoundRemove, _ as PixiVNJsonStepSwitch, $ as PixiVNJsonStepSwitchElementType, a0 as PixiVNJsonStepSwitchElementsType, a1 as PixiVNJsonStorageGet, l as PixiVNJsonTextEdit, a2 as PixiVNJsonUnionCondition, m as PixiVNJsonUnknownEdit, s as PixiVNJsonValueGet, n as PixiVNJsonValueSet, g as PixiVNJsonVideoEdit, h as PixiVNJsonVideoPauseResume } from './PixiVNJsonLabelStep-BsGHNfkq.js';
3
+ export { PixiVNJson, PixiVNJsonLabels } from './schema.js';
3
4
  export { V as VariableGetter, a as VariableGetterHandler } from './VariableGetter-ZDA6kdah.js';
4
5
  export { LabelJson, importPixiVNJson } from './interpreter.js';
5
- export { PixiVNJson, PixiVNJsonLabels } from './schema.js';
6
6
  export { ReplaceHandler, ReplaceHandlerOptions, TextReplaces, translator } from './translator.js';
7
7
  import '@drincs/pixi-vn';
8
8
  import '@drincs/pixi-vn/motion';
package/dist/index.mjs CHANGED
@@ -1,3 +1,2 @@
1
- import {getConditionalStep,VariableGetter,setInitialStorageValue,setStorageValue,videoOperation,soundOperation,loadAssets,narrationOperation,textOperation,imageOperation,imageContainerOperation,effectOperation,canvasElementOperation,animateOperation}from'@drincs/pixi-vn-json/actions';import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {createExportableElement,PixiError}from'@drincs/pixi-vn';import {translator as translator$1}from'@drincs/pixi-vn-json/translator';export*from'@drincs/pixi-vn-json/translator';import {NarrationManagerStatic,narration}from'@drincs/pixi-vn/narration';import {storage}from'@drincs/pixi-vn/storage';export*from'@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 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 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 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 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 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 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 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 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 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 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 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 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 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=JsonUnifier.getLogichValue(t.leftValue,i);switch(t.type){case "arithmetic":{let n=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.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.inputValue:storage.get(t.key);case "flagStorage":return storage.getFlag(t.key);case "label":return narration.getTimesLabelOpened(t.label);case "choice":return narration.getTimesChoiceMade(t.index);case "logic":return JsonUnifier.getLogichValue(t.operation,i);case "params":{let e=storage.get(`${T}${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=JsonUnifier.getLogichValue(t.leftValue,i),n=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=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=>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 JsonUnifier.getLogichValue(t.condition,i)?JsonUnifier.getLogichValue(t.then,i):JsonUnifier.getLogichValue(t.else,i);case "stepswitch":{let e=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 JsonUnifier.getLogichValue(e[n],i)}case "loop":{let n=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return n>e.length-1?(n=n%e.length,JsonUnifier.getLogichValue(e[n],i)):JsonUnifier.getLogichValue(e[n],i)}case "sequential":{let n,a=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end==="lastItem"&&(n=JsonUnifier.getLogichValue(e[e.length-1],i)),a>e.length-1?n:JsonUnifier.getLogichValue(e[a],i)}case "sequentialrandom":{let n=NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:t.nestedId,onceOnly:true});if(n===void 0&&t.end==="lastItem"){let a=NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!a?.usedRandomNumbers){s.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let r=a.usedRandomNumbers[`0-${e.length-1}`];return JsonUnifier.getLogichValue(e[r[r.length-1]],i)}if(n===void 0){s.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return JsonUnifier.getLogichValue(e[n],i)}}}}return t}function I(t,i={}){if(t.conditionalStep){let e=createExportableElement(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.dialogGlue&&(narration.dialogGlue=false);}return t}function Y(t,i){let e=t.firstItem,n=(t.secondConditionalItem??[]).flatMap(r=>Array.isArray(r)?r.map(u=>JsonUnifier.getLogichValue(u,i)):[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$1.t(a);if(typeof a[0]=="object"){let r=a,u,y=false,h=r.map((c,x)=>{c=I(c,i);let d=JsonUnifier.getLogichValue(c.dialogue,i)||"";return x===0?(u=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=JsonUnifier.getLogichValue(c.glueEnabled,i)||false,d)}),V=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=JsonUnifier.getLogichValue(G,i);return translator$1.t(`${z}`)}):d=JsonUnifier.getLogichValue(x,i)||"",translator$1.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.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}}}var k;(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;})(k||(k={}));function De(){JsonUnifier.init({animateOperation:animateOperation,canvasElementOperation:canvasElementOperation,effectOperation:effectOperation,imageContainerOperation:imageContainerOperation,imageOperation:imageOperation,textOperation:textOperation,narrationOperation:narrationOperation,loadAssets:loadAssets,soundOperation:soundOperation,videoOperation:videoOperation,setStorageValue:setStorageValue,setInitialStorageValue:setInitialStorageValue,getLogichValue:VariableGetter.getLogichValue,getConditionalStep:getConditionalStep});}export{T as PIXIVNJSON_PARAM_ID,$ as PIXIVNJSON_SCHEMA_URL,q as PixiVNJsonComparationOperators,k as VariableGetter,De as init};
1
+ import {getConditionalStep,VariableGetter,setInitialStorageValue,setStorageValue,videoOperation,soundOperation,loadAssets,narrationOperation,textOperation,imageOperation,imageContainerOperation,effectOperation,canvasElementOperation,animateOperation}from'@drincs/pixi-vn-json/actions';export{VariableGetter}from'@drincs/pixi-vn-json/actions';import {JsonUnifier}from'@drincs/pixi-vn-json/core';export*from'@drincs/pixi-vn-json/interpreter';export*from'@drincs/pixi-vn-json/translator';var t={version:"1.13.10"};var i="___param___",s=`https://pixi-vn.com/schemas/${t.version}/schema.json`,r=["==","!=","<","<=",">",">=","CONTAINS"];function b(){JsonUnifier.init({animateOperation:animateOperation,canvasElementOperation:canvasElementOperation,effectOperation:effectOperation,imageContainerOperation:imageContainerOperation,imageOperation:imageOperation,textOperation:textOperation,narrationOperation:narrationOperation,loadAssets:loadAssets,soundOperation:soundOperation,videoOperation:videoOperation,setStorageValue:setStorageValue,setInitialStorageValue:setInitialStorageValue,getLogichValue:VariableGetter.getLogichValue,getConditionalStep:getConditionalStep});}
2
+ export{i as PIXIVNJSON_PARAM_ID,s as PIXIVNJSON_SCHEMA_URL,r as PixiVNJsonComparationOperators,b as init};
@@ -1 +1 @@
1
- 'use strict';var pixiVn=require('@drincs/pixi-vn'),core=require('@drincs/pixi-vn-json/core'),translator=require('@drincs/pixi-vn-json/translator'),narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage');var te=Object.create;var R=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var ae=(s,e,r)=>e in s?R(s,e,{enumerable:true,configurable:true,writable:true,value:r}):s[e]=r;var D=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var W=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var se=(s,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ne(e))!re.call(s,n)&&n!==r&&R(s,n,{get:()=>e[n],enumerable:!(t=ie(e,n))||t.enumerable});return s};var pe=(s,e,r)=>(r=s!=null?te(oe(s)):{},se(R(r,"default",{value:s,enumerable:true}),s));var V=(s,e,r)=>ae(s,typeof e!="symbol"?e+"":e,r);var Q=W((I,K)=>{(function(s,e){typeof I=="object"?K.exports=I=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(I,function(){var s=s||(function(e,r){var t;if(typeof window<"u"&&window.crypto&&(t=window.crypto),typeof self<"u"&&self.crypto&&(t=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(t=globalThis.crypto),!t&&typeof window<"u"&&window.msCrypto&&(t=window.msCrypto),!t&&typeof global<"u"&&global.crypto&&(t=global.crypto),!t&&typeof D=="function")try{t=D("crypto");}catch{}var n=function(){if(t){if(typeof t.getRandomValues=="function")try{return t.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof t.randomBytes=="function")try{return t.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},p=Object.create||(function(){function i(){}return function(o){var u;return i.prototype=o,u=new i,i.prototype=null,u}})(),a={},d=a.lib={},m=d.Base=(function(){return {extend:function(i){var o=p(this);return i&&o.mixIn(i),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments);}),o.init.prototype=o,o.$super=this,o},create:function(){var i=this.extend();return i.init.apply(i,arguments),i},init:function(){},mixIn:function(i){for(var o in i)i.hasOwnProperty(o)&&(this[o]=i[o]);i.hasOwnProperty("toString")&&(this.toString=i.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),v=d.WordArray=m.extend({init:function(i,o){i=this.words=i||[],o!=r?this.sigBytes=o:this.sigBytes=i.length*4;},toString:function(i){return (i||J).stringify(this)},concat:function(i){var o=this.words,u=i.words,l=this.sigBytes,S=i.sigBytes;if(this.clamp(),l%4)for(var b=0;b<S;b++){var B=u[b>>>2]>>>24-b%4*8&255;o[l+b>>>2]|=B<<24-(l+b)%4*8;}else for(var j=0;j<S;j+=4)o[l+j>>>2]=u[j>>>2];return this.sigBytes+=S,this},clamp:function(){var i=this.words,o=this.sigBytes;i[o>>>2]&=4294967295<<32-o%4*8,i.length=e.ceil(o/4);},clone:function(){var i=m.clone.call(this);return i.words=this.words.slice(0),i},random:function(i){for(var o=[],u=0;u<i;u+=4)o.push(n());return new v.init(o,i)}}),f=a.enc={},J=f.Hex={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push((b>>>4).toString(16)),l.push((b&15).toString(16));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l+=2)u[l>>>3]|=parseInt(i.substr(l,2),16)<<24-l%8*4;return new v.init(u,o/2)}},N=f.Latin1={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push(String.fromCharCode(b));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l++)u[l>>>2]|=(i.charCodeAt(l)&255)<<24-l%4*8;return new v.init(u,o)}},C=f.Utf8={stringify:function(i){try{return decodeURIComponent(escape(N.stringify(i)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(i){return N.parse(unescape(encodeURIComponent(i)))}},g=d.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new v.init,this._nDataBytes=0;},_append:function(i){typeof i=="string"&&(i=C.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes;},_process:function(i){var o,u=this._data,l=u.words,S=u.sigBytes,b=this.blockSize,B=b*4,j=S/B;i?j=e.ceil(j):j=e.max((j|0)-this._minBufferSize,0);var E=j*b,q=e.min(E*4,S);if(E){for(var k=0;k<E;k+=b)this._doProcessBlock(l,k);o=l.splice(0,E),u.sigBytes-=q;}return new v.init(o,q)},clone:function(){var i=m.clone.call(this);return i._data=this._data.clone(),i},_minBufferSize:0});d.Hasher=g.extend({cfg:m.extend(),init:function(i){this.cfg=this.cfg.extend(i),this.reset();},reset:function(){g.reset.call(this),this._doReset();},update:function(i){return this._append(i),this._process(),this},finalize:function(i){i&&this._append(i);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(i){return function(o,u){return new i.init(u).finalize(o)}},_createHmacHelper:function(i){return function(o,u){return new P.HMAC.init(i,u).finalize(o)}}});var P=a.algo={};return a})(Math);return s});});var Z=W((z,Y)=>{(function(s,e){typeof z=="object"?Y.exports=z=e(Q()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(z,function(s){return (function(){var e=s,r=e.lib,t=r.WordArray,n=r.Hasher,p=e.algo,a=[],d=p.SHA1=n.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(m,v){for(var f=this._hash.words,J=f[0],N=f[1],C=f[2],g=f[3],x=f[4],P=0;P<80;P++){if(P<16)a[P]=m[v+P]|0;else {var i=a[P-3]^a[P-8]^a[P-14]^a[P-16];a[P]=i<<1|i>>>31;}var o=(J<<5|J>>>27)+x+a[P];P<20?o+=(N&C|~N&g)+1518500249:P<40?o+=(N^C^g)+1859775393:P<60?o+=(N&C|N&g|C&g)-1894007588:o+=(N^C^g)-899497514,x=g,g=C,C=N<<30|N>>>2,N=J,J=o;}f[0]=f[0]+J|0,f[1]=f[1]+N|0,f[2]=f[2]+C|0,f[3]=f[3]+g|0,f[4]=f[4]+x|0;},_doFinalize:function(){var m=this._data,v=m.words,f=this._nDataBytes*8,J=m.sigBytes*8;return v[J>>>5]|=128<<24-J%32,v[(J+64>>>9<<4)+14]=Math.floor(f/4294967296),v[(J+64>>>9<<4)+15]=f,m.sigBytes=v.length*4,this._process(),this._hash},clone:function(){var m=n.clone.call(this);return m._hash=this._hash.clone(),m}});e.SHA1=n._createHelper(d),e.HmacSHA1=n._createHmacHelper(d);})(),s.SHA1});});var H="___param___";var h;(n=>(n.log=(p,...a)=>console.log(`[Pixi\u2019VN Json] ${p}`,...a),n.warn=(p,...a)=>console.warn(`[Pixi\u2019VN Json] ${p}`,...a),n.error=(p,...a)=>console.error(`[Pixi\u2019VN Json] ${p}`,...a),n.info=(p,...a)=>console.info(`[Pixi\u2019VN Json] ${p}`,...a)))(h||(h={}));var c=class c{static init(e){e.loadAssets&&(c._loadAssets=e.loadAssets),e.soundOperation&&(c._soundOperation=e.soundOperation),e.imageOperation&&(c._imageOperation=e.imageOperation),e.videoOperation&&(c._videoOperation=e.videoOperation),e.imageContainerOperation&&(c._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(c._textOperation=e.textOperation),e.canvasElementOperation&&(c._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(c._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(c._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(c._narrationOperation=e.narrationOperation),e.effectOperation&&(c._effectOperation=e.effectOperation),e.animateOperation&&(c._animateOperation=e.animateOperation),e.getLogichValue&&(c._getLogichValue=e.getLogichValue),e.getConditionalStep&&(c._getConditionalStep=e.getConditionalStep);}static get loadAssets(){return c._loadAssets}static get soundOperation(){return c._soundOperation}static get imageOperation(){return c._imageOperation}static get videoOperation(){return c._videoOperation}static get imageContainerOperation(){return c._imageContainerOperation}static get textOperation(){return c._textOperation}static get canvasElementOperation(){return c._canvasElementOperation}static get setStorageValue(){return c._setStorageValue}static get setInitialStorageValue(){return c._setInitialStorageValue}static get narrationOperation(){return c._narrationOperation}static get effectOperation(){return c._effectOperation}static get animateOperation(){return c._animateOperation}static get getLogichValue(){return c._getLogichValue}static get getConditionalStep(){return c._getConditionalStep}};V(c,"_loadAssets",()=>{}),V(c,"_soundOperation",()=>{throw h.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.")}),V(c,"_imageOperation",()=>{throw h.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.")}),V(c,"_videoOperation",()=>{throw h.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.")}),V(c,"_imageContainerOperation",()=>{throw h.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.")}),V(c,"_textOperation",()=>{throw h.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.")}),V(c,"_canvasElementOperation",()=>{throw h.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.")}),V(c,"_setStorageValue",()=>{throw h.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.")}),V(c,"_setInitialStorageValue",()=>{throw h.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.")}),V(c,"_narrationOperation",()=>{throw h.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.")}),V(c,"_effectOperation",()=>{throw h.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.")}),V(c,"_animateOperation",()=>{throw h.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.")}),V(c,"_getLogichValue",()=>{throw h.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.")}),V(c,"_getConditionalStep",()=>{throw h.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 T=c;function F(s,e){if(e&&typeof e=="object"&&typeof s.functionName=="string"&&s.functionName in e){let r=e[s.functionName];if(typeof r=="function"){let t=s.args.map(n=>T.getLogichValue(n,e));return r(...t)}else h.warn(`getLogichValue function ${s.functionName} not found in props`);}}function X(s,e={}){let r="";return s.values.forEach(t=>{if(typeof t=="string")r+=t;else {let n=core.JsonUnifier.getLogichValue(t,e);r+=`${n}`;}}),r}async function $(s,e,r){let t=core.JsonUnifier.getLogichValue(s,e);if(t)switch(t.type){case "sound":core.JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await core.JsonUnifier.loadAssets(t);break;case "image":await core.JsonUnifier.imageOperation(t);break;case "video":await core.JsonUnifier.videoOperation(t);break;case "imagecontainer":await core.JsonUnifier.imageContainerOperation(t);break;case "text":await core.JsonUnifier.textOperation(t);break;case "canvaselement":await core.JsonUnifier.canvasElementOperation(t);break;case "value":core.JsonUnifier.setStorageValue(t,e);break;case "operationtoconvert":if(r){let n=X(t,e),p=await r(n);p&&await $(p,e,r);}break;case "input":case "dialogue":core.JsonUnifier.narrationOperation(t);break;case "shake":await core.JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":core.JsonUnifier.animateOperation(t);break;case "function":await F(t,e);break}}function M(s){let e=core.JsonUnifier.getLogichValue(s,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&core.JsonUnifier.setInitialStorageValue(e);}var ee=pe(Z());var _=class extends narration.LabelAbstract{constructor(r,t,n,p={}){n||(n={}),n.onLoadingLabel=async()=>{for(let a of t){let d;if(typeof a=="function"?d=a():d=a,d=core.JsonUnifier.getConditionalStep(d),d.operations)try{let m=d.operations.map(v=>core.JsonUnifier.loadAssets(v));await Promise.all(m);}catch(m){h.error("The operation in the onLoadingLabel function of the label has an error:",m);}}};super(r,n);V(this,"_steps");V(this,"operationStringConvert");V(this,"skipEmptyDialogs",false);this._steps=t,this.operationStringConvert=p.operationStringConvert,this.skipEmptyDialogs=p.skipEmptyDialogs||false;}get steps(){return this._steps.map(r=>this.stepConverter(r))}get stepCount(){return this._steps.length}getStepById(r){if(r<0||r>=this._steps.length)return;let t=this._steps[r];return this.stepConverter(t)}getStepSha(r){if(r<0||r>=this.steps.length)return;let t=this._steps[r];return (0, ee.default)(t.toString().toLocaleLowerCase()).toString()}getDialogueText(r,t){let n="";if(Array.isArray(r)){let p=[];r.forEach(a=>{if(typeof a=="string")p.push(a);else if(a&&typeof a=="object"){let d=core.JsonUnifier.getLogichValue(a,t);d?(d&&!Array.isArray(d)&&typeof d=="object"&&(d=core.JsonUnifier.getLogichValue(d,t)||""),Array.isArray(d)?p=p.map(m=>`${m}`).concat(d):p.push(`${d}`)):p.push(`${a}`);}else p.push(`${a}`);}),n=p;}else {let p=core.JsonUnifier.getLogichValue(r,t);p&&!Array.isArray(p)&&typeof p=="object"&&(p=core.JsonUnifier.getLogichValue(p,t)),p&&Array.isArray(p)?n=p.map(a=>`${a}`):n=`${p}`;}return n}getDialogue(r,t){if(r==null)return;let n=core.JsonUnifier.getLogichValue(r,t);return n==null?`${n}`:typeof n=="object"&&"character"in n&&"text"in n?{character:n.character,text:translator.translator.t(this.getDialogueText(n.text,t))}:translator.translator.t(this.getDialogueText(n,t))}getChoices(r,t){return core.JsonUnifier.getLogichValue(r,t)?.map(a=>core.JsonUnifier.getLogichValue(a,t)).filter(a=>a!==void 0)}stepConverter(r){return async t=>{let n=typeof r=="function"?r():r;n=pixiVn.createExportableElement(n),n=core.JsonUnifier.getConditionalStep(n,t);let p=this.operationStringConvert?g=>this.operationStringConvert(g,n,t):void 0,{operations:a=[]}=n;for(let g of a)await $(g,t,p);let{labelToOpen:d=[]}=n,m=this.getChoices(n.choices,t),v=core.JsonUnifier.getLogichValue(n.glueEnabled,t),f=this.getDialogue(n.dialogue,t),J=[];Array.isArray(d)||(d=[d]),d.forEach(g=>{let x=core.JsonUnifier.getLogichValue(g,t);x&&J.push(x);});let N=core.JsonUnifier.getLogichValue(n.goNextStep,t),C=core.JsonUnifier.getLogichValue(n.end,t);if(m){let g=m.map(x=>{let P="";if(Array.isArray(x.text)){let o=[];x.text.forEach(u=>{if(typeof u=="string")o.push(translator.translator.t(u));else if(u&&typeof u=="object"){let l=core.JsonUnifier.getLogichValue(u,t);l&&!Array.isArray(l)&&typeof l=="object"&&(l=core.JsonUnifier.getLogichValue(l,t)||""),l&&(Array.isArray(l)?o=o.concat(translator.translator.t(l)):o.push(translator.translator.t(l)));}}),P=o;}else typeof x.text=="string"&&(P=translator.translator.t(x.text));return {label:x.label,text:P,props:x.props,type:x.type,oneTime:x.oneTime,onlyHaveNoChoice:x.onlyHaveNoChoice,autoSelect:x.autoSelect}});narration.narration.choices=g;}else narration.narration.choices=void 0;f!==void 0&&(narration.narration.dialogue=f,this.skipEmptyDialogs&&typeof f=="string"&&(f===""||RegExp(/^\s+$/).test(f))&&(N=true)),v?narration.narration.dialogGlue=true:v===false&&(narration.narration.dialogGlue=false);for(let g of J){let x=g.label;typeof x=="object"&&(x=core.JsonUnifier.getLogichValue(x,t)||"");let P=g.params?.map(i=>core.JsonUnifier.getLogichValue(i,t));t={...t,...g.props},g.type==="jump"?(narration.narration.openedLabels.length>0&&narration.narration.closeCurrentLabel(),storage.storage.setTempVariable(`${H}${narration.narration.openedLabels.length}`,P),await narration.narration.call(x,t)):(storage.storage.setTempVariable(`${H}${narration.narration.openedLabels.length}`,P),await narration.narration.call(x,t));}C==="game_end"?(narration.narration.closeAllLabels(),await narration.narration.continue(t,{runNow:true})):C==="label_end"&&narration.narration.closeCurrentLabel(),N&&await narration.narration.continue(t,{runNow:true});}}};async function me(s,e={}){if(!Array.isArray(s))if(typeof s=="object"||typeof s=="string")s=[s];else {h.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let r=s.map(p=>{if(typeof p=="string")try{return JSON.parse(p)}catch(a){return h.error("Error parsing imported Pixi'VN JSON",a),{}}return p}),t=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)a.type==="value"&&(typeof a.value!="object"||!a.value||!("type"in a.value))&&M(a);return Promise.resolve()});await Promise.all(t);let n=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)(a.type!=="value"||a.type==="value"&&typeof a.value=="object"&&a.value&&"type"in a.value)&&M(a);if(p.labels){let a=p.labels;for(let d in a)try{let m=a[d],v=new _(d,m,void 0,e);narration.RegisteredLabels.add(v);}catch(m){h.error(`Error creating JSON label ${d}`,m);}}return Promise.resolve()});await Promise.all(n);}exports.LabelJson=_;exports.importPixiVNJson=me;
1
+ 'use strict';var pixiVn=require('@drincs/pixi-vn'),core=require('@drincs/pixi-vn-json/core'),translator=require('@drincs/pixi-vn-json/translator'),narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage');var Z=Object.create;var $=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var B=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,o)=>(typeof require<"u"?require:e)[o]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var M=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var oe=(n,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ie(e))!ne.call(n,s)&&s!==o&&$(n,s,{get:()=>e[s],enumerable:!(t=ee(e,s))||t.enumerable});return n};var re=(n,e,o)=>(o=n!=null?Z(te(n)):{},oe($(o,"default",{value:n,enumerable:true}),n));var F=M((A,G)=>{(function(n,e){typeof A=="object"?G.exports=A=e():typeof define=="function"&&define.amd?define([],e):n.CryptoJS=e();})(A,function(){var n=n||(function(e,o){var t;if(typeof window<"u"&&window.crypto&&(t=window.crypto),typeof self<"u"&&self.crypto&&(t=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(t=globalThis.crypto),!t&&typeof window<"u"&&window.msCrypto&&(t=window.msCrypto),!t&&typeof global<"u"&&global.crypto&&(t=global.crypto),!t&&typeof B=="function")try{t=B("crypto");}catch{}var s=function(){if(t){if(typeof t.getRandomValues=="function")try{return t.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof t.randomBytes=="function")try{return t.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},p=Object.create||(function(){function i(){}return function(a){var c;return i.prototype=a,c=new i,i.prototype=null,c}})(),r={},x=r.lib={},f=x.Base=(function(){return {extend:function(i){var a=p(this);return i&&a.mixIn(i),(!a.hasOwnProperty("init")||this.init===a.init)&&(a.init=function(){a.$super.init.apply(this,arguments);}),a.init.prototype=a,a.$super=this,a},create:function(){var i=this.extend();return i.init.apply(i,arguments),i},init:function(){},mixIn:function(i){for(var a in i)i.hasOwnProperty(a)&&(this[a]=i[a]);i.hasOwnProperty("toString")&&(this.toString=i.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),h=x.WordArray=f.extend({init:function(i,a){i=this.words=i||[],a!=o?this.sigBytes=a:this.sigBytes=i.length*4;},toString:function(i){return (i||N).stringify(this)},concat:function(i){var a=this.words,c=i.words,d=this.sigBytes,y=i.sigBytes;if(this.clamp(),d%4)for(var J=0;J<y;J++){var I=c[J>>>2]>>>24-J%4*8&255;a[d+J>>>2]|=I<<24-(d+J)%4*8;}else for(var C=0;C<y;C+=4)a[d+C>>>2]=c[C>>>2];return this.sigBytes+=y,this},clamp:function(){var i=this.words,a=this.sigBytes;i[a>>>2]&=4294967295<<32-a%4*8,i.length=e.ceil(a/4);},clone:function(){var i=f.clone.call(this);return i.words=this.words.slice(0),i},random:function(i){for(var a=[],c=0;c<i;c+=4)a.push(s());return new h.init(a,i)}}),u=r.enc={},N=u.Hex={stringify:function(i){for(var a=i.words,c=i.sigBytes,d=[],y=0;y<c;y++){var J=a[y>>>2]>>>24-y%4*8&255;d.push((J>>>4).toString(16)),d.push((J&15).toString(16));}return d.join("")},parse:function(i){for(var a=i.length,c=[],d=0;d<a;d+=2)c[d>>>3]|=parseInt(i.substr(d,2),16)<<24-d%8*4;return new h.init(c,a/2)}},V=u.Latin1={stringify:function(i){for(var a=i.words,c=i.sigBytes,d=[],y=0;y<c;y++){var J=a[y>>>2]>>>24-y%4*8&255;d.push(String.fromCharCode(J));}return d.join("")},parse:function(i){for(var a=i.length,c=[],d=0;d<a;d++)c[d>>>2]|=(i.charCodeAt(d)&255)<<24-d%4*8;return new h.init(c,a)}},m=u.Utf8={stringify:function(i){try{return decodeURIComponent(escape(V.stringify(i)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(i){return V.parse(unescape(encodeURIComponent(i)))}},l=x.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new h.init,this._nDataBytes=0;},_append:function(i){typeof i=="string"&&(i=m.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes;},_process:function(i){var a,c=this._data,d=c.words,y=c.sigBytes,J=this.blockSize,I=J*4,C=y/I;i?C=e.ceil(C):C=e.max((C|0)-this._minBufferSize,0);var T=C*J,H=e.min(T*4,y);if(T){for(var z=0;z<T;z+=J)this._doProcessBlock(d,z);a=d.splice(0,T),c.sigBytes-=H;}return new h.init(a,H)},clone:function(){var i=f.clone.call(this);return i._data=this._data.clone(),i},_minBufferSize:0});x.Hasher=l.extend({cfg:f.extend(),init:function(i){this.cfg=this.cfg.extend(i),this.reset();},reset:function(){l.reset.call(this),this._doReset();},update:function(i){return this._append(i),this._process(),this},finalize:function(i){i&&this._append(i);var a=this._doFinalize();return a},blockSize:512/32,_createHelper:function(i){return function(a,c){return new i.init(c).finalize(a)}},_createHmacHelper:function(i){return function(a,c){return new P.HMAC.init(i,c).finalize(a)}}});var P=r.algo={};return r})(Math);return n});});var K=M((E,X)=>{(function(n,e){typeof E=="object"?X.exports=E=e(F()):typeof define=="function"&&define.amd?define(["./core"],e):e(n.CryptoJS);})(E,function(n){return (function(){var e=n,o=e.lib,t=o.WordArray,s=o.Hasher,p=e.algo,r=[],x=p.SHA1=s.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(f,h){for(var u=this._hash.words,N=u[0],V=u[1],m=u[2],l=u[3],w=u[4],P=0;P<80;P++){if(P<16)r[P]=f[h+P]|0;else {var i=r[P-3]^r[P-8]^r[P-14]^r[P-16];r[P]=i<<1|i>>>31;}var a=(N<<5|N>>>27)+w+r[P];P<20?a+=(V&m|~V&l)+1518500249:P<40?a+=(V^m^l)+1859775393:P<60?a+=(V&m|V&l|m&l)-1894007588:a+=(V^m^l)-899497514,w=l,l=m,m=V<<30|V>>>2,V=N,N=a;}u[0]=u[0]+N|0,u[1]=u[1]+V|0,u[2]=u[2]+m|0,u[3]=u[3]+l|0,u[4]=u[4]+w|0;},_doFinalize:function(){var f=this._data,h=f.words,u=this._nDataBytes*8,N=f.sigBytes*8;return h[N>>>5]|=128<<24-N%32,h[(N+64>>>9<<4)+14]=Math.floor(u/4294967296),h[(N+64>>>9<<4)+15]=u,f.sigBytes=h.length*4,this._process(),this._hash},clone:function(){var f=s.clone.call(this);return f._hash=this._hash.clone(),f}});e.SHA1=s._createHelper(x),e.HmacSHA1=s._createHmacHelper(x);})(),n.SHA1});});var k="___param___";var g;(s=>(s.log=(p,...r)=>console.log(`[Pixi\u2019VN Json] ${p}`,...r),s.warn=(p,...r)=>console.warn(`[Pixi\u2019VN Json] ${p}`,...r),s.error=(p,...r)=>console.error(`[Pixi\u2019VN Json] ${p}`,...r),s.info=(p,...r)=>console.info(`[Pixi\u2019VN Json] ${p}`,...r)))(g||={});var L=class n{static init(e){e.loadAssets&&(n._loadAssets=e.loadAssets),e.soundOperation&&(n._soundOperation=e.soundOperation),e.imageOperation&&(n._imageOperation=e.imageOperation),e.videoOperation&&(n._videoOperation=e.videoOperation),e.imageContainerOperation&&(n._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(n._textOperation=e.textOperation),e.canvasElementOperation&&(n._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(n._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(n._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(n._narrationOperation=e.narrationOperation),e.effectOperation&&(n._effectOperation=e.effectOperation),e.animateOperation&&(n._animateOperation=e.animateOperation),e.getLogichValue&&(n._getLogichValue=e.getLogichValue),e.getConditionalStep&&(n._getConditionalStep=e.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return n._loadAssets}static _soundOperation=()=>{throw g.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.")};static get soundOperation(){return n._soundOperation}static _imageOperation=()=>{throw g.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.")};static get imageOperation(){return n._imageOperation}static _videoOperation=()=>{throw g.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.")};static get videoOperation(){return n._videoOperation}static _imageContainerOperation=()=>{throw g.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.")};static get imageContainerOperation(){return n._imageContainerOperation}static _textOperation=()=>{throw g.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.")};static get textOperation(){return n._textOperation}static _canvasElementOperation=()=>{throw g.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.")};static get canvasElementOperation(){return n._canvasElementOperation}static _setStorageValue=()=>{throw g.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.")};static get setStorageValue(){return n._setStorageValue}static _setInitialStorageValue=()=>{throw g.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.")};static get setInitialStorageValue(){return n._setInitialStorageValue}static _narrationOperation=()=>{throw g.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.")};static get narrationOperation(){return n._narrationOperation}static _effectOperation=()=>{throw g.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.")};static get effectOperation(){return n._effectOperation}static _animateOperation=()=>{throw g.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.")};static get animateOperation(){return n._animateOperation}static _getLogichValue=()=>{throw g.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.")};static get getLogichValue(){return n._getLogichValue}static _getConditionalStep=()=>{throw g.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.")};static get getConditionalStep(){return n._getConditionalStep}};function q(n,e){if(e&&typeof e=="object"&&typeof n.functionName=="string"&&n.functionName in e){let o=e[n.functionName];if(typeof o=="function"){let t=n.args.map(s=>L.getLogichValue(s,e));return o(...t)}else g.warn(`getLogichValue function ${n.functionName} not found in props`);}}function W(n,e={}){let o="";return n.values.forEach(t=>{if(typeof t=="string")o+=t;else {let s=core.JsonUnifier.getLogichValue(t,e);o+=`${s}`;}}),o}async function R(n,e,o){let t=core.JsonUnifier.getLogichValue(n,e);if(t)switch(t.type){case "sound":core.JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await core.JsonUnifier.loadAssets(t);break;case "image":await core.JsonUnifier.imageOperation(t);break;case "video":await core.JsonUnifier.videoOperation(t);break;case "imagecontainer":await core.JsonUnifier.imageContainerOperation(t);break;case "text":await core.JsonUnifier.textOperation(t);break;case "canvaselement":await core.JsonUnifier.canvasElementOperation(t);break;case "value":core.JsonUnifier.setStorageValue(t,e);break;case "operationtoconvert":if(o){let s=W(t,e),p=await o(s);p&&await R(p,e,o);}break;case "input":case "dialogue":core.JsonUnifier.narrationOperation(t);break;case "shake":await core.JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":core.JsonUnifier.animateOperation(t);break;case "function":await q(t,e);break}}function D(n){let e=core.JsonUnifier.getLogichValue(n,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&core.JsonUnifier.setInitialStorageValue(e);}var Y=re(K());var _=class extends narration.LabelAbstract{constructor(e,o,t,s={}){t||(t={}),t.onLoadingLabel=async()=>{for(let p of o){let r;if(typeof p=="function"?r=p():r=p,r=core.JsonUnifier.getConditionalStep(r),r.operations)try{let x=r.operations.map(f=>core.JsonUnifier.loadAssets(f));await Promise.all(x);}catch(x){g.error("The operation in the onLoadingLabel function of the label has an error:",x);}}},super(e,t),this._steps=o,this.operationStringConvert=s.operationStringConvert,this.skipEmptyDialogs=s.skipEmptyDialogs||false;}_steps;get steps(){return this._steps.map(e=>this.stepConverter(e))}get stepCount(){return this._steps.length}getStepById(e){if(e<0||e>=this._steps.length)return;let o=this._steps[e];return this.stepConverter(o)}operationStringConvert;skipEmptyDialogs=false;getStepSha(e){if(e<0||e>=this.steps.length)return;let o=this._steps[e];return (0, Y.default)(o.toString().toLocaleLowerCase()).toString()}getDialogueText(e,o){let t="";if(Array.isArray(e)){let s=[];e.forEach(p=>{if(typeof p=="string")s.push(p);else if(p&&typeof p=="object"){let r=core.JsonUnifier.getLogichValue(p,o);r?(r&&!Array.isArray(r)&&typeof r=="object"&&(r=core.JsonUnifier.getLogichValue(r,o)||""),Array.isArray(r)?s=s.map(x=>`${x}`).concat(r):s.push(`${r}`)):s.push(`${p}`);}else s.push(`${p}`);}),t=s;}else {let s=core.JsonUnifier.getLogichValue(e,o);s&&!Array.isArray(s)&&typeof s=="object"&&(s=core.JsonUnifier.getLogichValue(s,o)),s&&Array.isArray(s)?t=s.map(p=>`${p}`):t=`${s}`;}return t}getDialogue(e,o){if(e==null)return;let t=core.JsonUnifier.getLogichValue(e,o);return t==null?`${t}`:typeof t=="object"&&"character"in t&&"text"in t?{character:t.character,text:translator.translator.t(this.getDialogueText(t.text,o))}:translator.translator.t(this.getDialogueText(t,o))}getChoices(e,o){return core.JsonUnifier.getLogichValue(e,o)?.map(p=>core.JsonUnifier.getLogichValue(p,o)).filter(p=>p!==void 0)}stepConverter(e){return async o=>{let t=typeof e=="function"?e():e;t=pixiVn.createExportableElement(t),t=core.JsonUnifier.getConditionalStep(t,o);let s=this.operationStringConvert?m=>this.operationStringConvert(m,t,o):void 0,{operations:p=[]}=t;for(let m of p)await R(m,o,s);let{labelToOpen:r=[]}=t,x=this.getChoices(t.choices,o),f=core.JsonUnifier.getLogichValue(t.glueEnabled,o),h=this.getDialogue(t.dialogue,o),u=[];Array.isArray(r)||(r=[r]),r.forEach(m=>{let l=core.JsonUnifier.getLogichValue(m,o);l&&u.push(l);});let N=core.JsonUnifier.getLogichValue(t.goNextStep,o),V=core.JsonUnifier.getLogichValue(t.end,o);if(x){let m=x.map(l=>{let w="";if(Array.isArray(l.text)){let i=[];l.text.forEach(a=>{if(typeof a=="string")i.push(translator.translator.t(a));else if(a&&typeof a=="object"){let c=core.JsonUnifier.getLogichValue(a,o);c&&!Array.isArray(c)&&typeof c=="object"&&(c=core.JsonUnifier.getLogichValue(c,o)||""),c&&(Array.isArray(c)?i=i.concat(translator.translator.t(c)):i.push(translator.translator.t(c)));}}),w=i;}else typeof l.text=="string"&&(w=translator.translator.t(l.text));return {label:l.label,text:w,props:l.props,type:l.type,oneTime:l.oneTime,onlyHaveNoChoice:l.onlyHaveNoChoice,autoSelect:l.autoSelect}});narration.narration.choices=m;}else narration.narration.choices=void 0;h!==void 0&&(narration.narration.dialogue=h,this.skipEmptyDialogs&&typeof h=="string"&&(h===""||RegExp(/^\s+$/).test(h))&&(N=true)),f?narration.narration.dialogGlue=true:f===false&&(narration.narration.dialogGlue=false);for(let m of u){let l=m.label;typeof l=="object"&&(l=core.JsonUnifier.getLogichValue(l,o)||"");let w=m.params?.map(P=>core.JsonUnifier.getLogichValue(P,o));o={...o,...m.props},m.type==="jump"?(narration.narration.openedLabels.length>0&&narration.narration.closeCurrentLabel(),storage.storage.setTempVariable(`${k}${narration.narration.openedLabels.length}`,w),await narration.narration.call(l,o)):(storage.storage.setTempVariable(`${k}${narration.narration.openedLabels.length}`,w),await narration.narration.call(l,o));}V==="game_end"?(narration.narration.closeAllLabels(),await narration.narration.continue(o,{runNow:true})):V==="label_end"&&narration.narration.closeCurrentLabel(),N&&await narration.narration.continue(o,{runNow:true});}}};async function de(n,e={}){if(!Array.isArray(n))if(typeof n=="object"||typeof n=="string")n=[n];else {g.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let o=n.map(p=>{if(typeof p=="string")try{return JSON.parse(p)}catch(r){return g.error("Error parsing imported Pixi'VN JSON",r),{}}return p}),t=o.map(async p=>{if(p.initialOperations)for(let r of p.initialOperations)r.type==="value"&&(typeof r.value!="object"||!r.value||!("type"in r.value))&&D(r);return Promise.resolve()});await Promise.all(t);let s=o.map(async p=>{if(p.initialOperations)for(let r of p.initialOperations)(r.type!=="value"||r.type==="value"&&typeof r.value=="object"&&r.value&&"type"in r.value)&&D(r);if(p.labels){let r=p.labels;for(let x in r)try{let f=r[x],h=new _(x,f,void 0,e);narration.RegisteredLabels.add(h);}catch(f){g.error(`Error creating JSON label ${x}`,f);}}return Promise.resolve()});await Promise.all(s);}exports.LabelJson=_;exports.importPixiVNJson=de;
@@ -1,4 +1,4 @@
1
- import { F as PixiVNJsonLabelStep, L as PixiVNJsonOperation } from './PixiVNJsonLabelStep-DJgORyFd.cjs';
1
+ import { w as PixiVNJsonLabelStep, P as PixiVNJsonOperation } from './PixiVNJsonLabelStep-BsGHNfkq.cjs';
2
2
  import { LabelAbstract, LabelProps, StepLabelPropsType, StepLabelType } from '@drincs/pixi-vn/narration';
3
3
  import { PixiVNJson } from './schema.cjs';
4
4
  import '@drincs/pixi-vn';
@@ -1,4 +1,4 @@
1
- import { F as PixiVNJsonLabelStep, L as PixiVNJsonOperation } from './PixiVNJsonLabelStep-DJgORyFd.js';
1
+ import { w as PixiVNJsonLabelStep, P as PixiVNJsonOperation } from './PixiVNJsonLabelStep-BsGHNfkq.js';
2
2
  import { LabelAbstract, LabelProps, StepLabelPropsType, StepLabelType } from '@drincs/pixi-vn/narration';
3
3
  import { PixiVNJson } from './schema.js';
4
4
  import '@drincs/pixi-vn';
@@ -1 +1 @@
1
- import {PixiError,createExportableElement}from'@drincs/pixi-vn';import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {translator}from'@drincs/pixi-vn-json/translator';import {LabelAbstract,narration,RegisteredLabels}from'@drincs/pixi-vn/narration';import {storage}from'@drincs/pixi-vn/storage';var te=Object.create;var R=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var ae=(s,e,r)=>e in s?R(s,e,{enumerable:true,configurable:true,writable:true,value:r}):s[e]=r;var D=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var W=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var se=(s,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ne(e))!re.call(s,n)&&n!==r&&R(s,n,{get:()=>e[n],enumerable:!(t=ie(e,n))||t.enumerable});return s};var pe=(s,e,r)=>(r=s!=null?te(oe(s)):{},se(R(r,"default",{value:s,enumerable:true}),s));var V=(s,e,r)=>ae(s,typeof e!="symbol"?e+"":e,r);var Q=W((I,K)=>{(function(s,e){typeof I=="object"?K.exports=I=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(I,function(){var s=s||(function(e,r){var t;if(typeof window<"u"&&window.crypto&&(t=window.crypto),typeof self<"u"&&self.crypto&&(t=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(t=globalThis.crypto),!t&&typeof window<"u"&&window.msCrypto&&(t=window.msCrypto),!t&&typeof global<"u"&&global.crypto&&(t=global.crypto),!t&&typeof D=="function")try{t=D("crypto");}catch{}var n=function(){if(t){if(typeof t.getRandomValues=="function")try{return t.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof t.randomBytes=="function")try{return t.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},p=Object.create||(function(){function i(){}return function(o){var u;return i.prototype=o,u=new i,i.prototype=null,u}})(),a={},d=a.lib={},m=d.Base=(function(){return {extend:function(i){var o=p(this);return i&&o.mixIn(i),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments);}),o.init.prototype=o,o.$super=this,o},create:function(){var i=this.extend();return i.init.apply(i,arguments),i},init:function(){},mixIn:function(i){for(var o in i)i.hasOwnProperty(o)&&(this[o]=i[o]);i.hasOwnProperty("toString")&&(this.toString=i.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),v=d.WordArray=m.extend({init:function(i,o){i=this.words=i||[],o!=r?this.sigBytes=o:this.sigBytes=i.length*4;},toString:function(i){return (i||J).stringify(this)},concat:function(i){var o=this.words,u=i.words,l=this.sigBytes,S=i.sigBytes;if(this.clamp(),l%4)for(var b=0;b<S;b++){var B=u[b>>>2]>>>24-b%4*8&255;o[l+b>>>2]|=B<<24-(l+b)%4*8;}else for(var j=0;j<S;j+=4)o[l+j>>>2]=u[j>>>2];return this.sigBytes+=S,this},clamp:function(){var i=this.words,o=this.sigBytes;i[o>>>2]&=4294967295<<32-o%4*8,i.length=e.ceil(o/4);},clone:function(){var i=m.clone.call(this);return i.words=this.words.slice(0),i},random:function(i){for(var o=[],u=0;u<i;u+=4)o.push(n());return new v.init(o,i)}}),f=a.enc={},J=f.Hex={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push((b>>>4).toString(16)),l.push((b&15).toString(16));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l+=2)u[l>>>3]|=parseInt(i.substr(l,2),16)<<24-l%8*4;return new v.init(u,o/2)}},N=f.Latin1={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push(String.fromCharCode(b));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l++)u[l>>>2]|=(i.charCodeAt(l)&255)<<24-l%4*8;return new v.init(u,o)}},C=f.Utf8={stringify:function(i){try{return decodeURIComponent(escape(N.stringify(i)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(i){return N.parse(unescape(encodeURIComponent(i)))}},g=d.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new v.init,this._nDataBytes=0;},_append:function(i){typeof i=="string"&&(i=C.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes;},_process:function(i){var o,u=this._data,l=u.words,S=u.sigBytes,b=this.blockSize,B=b*4,j=S/B;i?j=e.ceil(j):j=e.max((j|0)-this._minBufferSize,0);var E=j*b,q=e.min(E*4,S);if(E){for(var k=0;k<E;k+=b)this._doProcessBlock(l,k);o=l.splice(0,E),u.sigBytes-=q;}return new v.init(o,q)},clone:function(){var i=m.clone.call(this);return i._data=this._data.clone(),i},_minBufferSize:0});d.Hasher=g.extend({cfg:m.extend(),init:function(i){this.cfg=this.cfg.extend(i),this.reset();},reset:function(){g.reset.call(this),this._doReset();},update:function(i){return this._append(i),this._process(),this},finalize:function(i){i&&this._append(i);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(i){return function(o,u){return new i.init(u).finalize(o)}},_createHmacHelper:function(i){return function(o,u){return new P.HMAC.init(i,u).finalize(o)}}});var P=a.algo={};return a})(Math);return s});});var Z=W((z,Y)=>{(function(s,e){typeof z=="object"?Y.exports=z=e(Q()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(z,function(s){return (function(){var e=s,r=e.lib,t=r.WordArray,n=r.Hasher,p=e.algo,a=[],d=p.SHA1=n.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(m,v){for(var f=this._hash.words,J=f[0],N=f[1],C=f[2],g=f[3],x=f[4],P=0;P<80;P++){if(P<16)a[P]=m[v+P]|0;else {var i=a[P-3]^a[P-8]^a[P-14]^a[P-16];a[P]=i<<1|i>>>31;}var o=(J<<5|J>>>27)+x+a[P];P<20?o+=(N&C|~N&g)+1518500249:P<40?o+=(N^C^g)+1859775393:P<60?o+=(N&C|N&g|C&g)-1894007588:o+=(N^C^g)-899497514,x=g,g=C,C=N<<30|N>>>2,N=J,J=o;}f[0]=f[0]+J|0,f[1]=f[1]+N|0,f[2]=f[2]+C|0,f[3]=f[3]+g|0,f[4]=f[4]+x|0;},_doFinalize:function(){var m=this._data,v=m.words,f=this._nDataBytes*8,J=m.sigBytes*8;return v[J>>>5]|=128<<24-J%32,v[(J+64>>>9<<4)+14]=Math.floor(f/4294967296),v[(J+64>>>9<<4)+15]=f,m.sigBytes=v.length*4,this._process(),this._hash},clone:function(){var m=n.clone.call(this);return m._hash=this._hash.clone(),m}});e.SHA1=n._createHelper(d),e.HmacSHA1=n._createHmacHelper(d);})(),s.SHA1});});var H="___param___";var h;(n=>(n.log=(p,...a)=>console.log(`[Pixi\u2019VN Json] ${p}`,...a),n.warn=(p,...a)=>console.warn(`[Pixi\u2019VN Json] ${p}`,...a),n.error=(p,...a)=>console.error(`[Pixi\u2019VN Json] ${p}`,...a),n.info=(p,...a)=>console.info(`[Pixi\u2019VN Json] ${p}`,...a)))(h||(h={}));var c=class c{static init(e){e.loadAssets&&(c._loadAssets=e.loadAssets),e.soundOperation&&(c._soundOperation=e.soundOperation),e.imageOperation&&(c._imageOperation=e.imageOperation),e.videoOperation&&(c._videoOperation=e.videoOperation),e.imageContainerOperation&&(c._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(c._textOperation=e.textOperation),e.canvasElementOperation&&(c._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(c._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(c._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(c._narrationOperation=e.narrationOperation),e.effectOperation&&(c._effectOperation=e.effectOperation),e.animateOperation&&(c._animateOperation=e.animateOperation),e.getLogichValue&&(c._getLogichValue=e.getLogichValue),e.getConditionalStep&&(c._getConditionalStep=e.getConditionalStep);}static get loadAssets(){return c._loadAssets}static get soundOperation(){return c._soundOperation}static get imageOperation(){return c._imageOperation}static get videoOperation(){return c._videoOperation}static get imageContainerOperation(){return c._imageContainerOperation}static get textOperation(){return c._textOperation}static get canvasElementOperation(){return c._canvasElementOperation}static get setStorageValue(){return c._setStorageValue}static get setInitialStorageValue(){return c._setInitialStorageValue}static get narrationOperation(){return c._narrationOperation}static get effectOperation(){return c._effectOperation}static get animateOperation(){return c._animateOperation}static get getLogichValue(){return c._getLogichValue}static get getConditionalStep(){return c._getConditionalStep}};V(c,"_loadAssets",()=>{}),V(c,"_soundOperation",()=>{throw h.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.")}),V(c,"_imageOperation",()=>{throw h.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.")}),V(c,"_videoOperation",()=>{throw h.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.")}),V(c,"_imageContainerOperation",()=>{throw h.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.")}),V(c,"_textOperation",()=>{throw h.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.")}),V(c,"_canvasElementOperation",()=>{throw h.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.")}),V(c,"_setStorageValue",()=>{throw h.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.")}),V(c,"_setInitialStorageValue",()=>{throw h.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.")}),V(c,"_narrationOperation",()=>{throw h.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.")}),V(c,"_effectOperation",()=>{throw h.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.")}),V(c,"_animateOperation",()=>{throw h.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.")}),V(c,"_getLogichValue",()=>{throw h.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.")}),V(c,"_getConditionalStep",()=>{throw h.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 T=c;function F(s,e){if(e&&typeof e=="object"&&typeof s.functionName=="string"&&s.functionName in e){let r=e[s.functionName];if(typeof r=="function"){let t=s.args.map(n=>T.getLogichValue(n,e));return r(...t)}else h.warn(`getLogichValue function ${s.functionName} not found in props`);}}function X(s,e={}){let r="";return s.values.forEach(t=>{if(typeof t=="string")r+=t;else {let n=JsonUnifier.getLogichValue(t,e);r+=`${n}`;}}),r}async function $(s,e,r){let t=JsonUnifier.getLogichValue(s,e);if(t)switch(t.type){case "sound":JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await JsonUnifier.loadAssets(t);break;case "image":await JsonUnifier.imageOperation(t);break;case "video":await JsonUnifier.videoOperation(t);break;case "imagecontainer":await JsonUnifier.imageContainerOperation(t);break;case "text":await JsonUnifier.textOperation(t);break;case "canvaselement":await JsonUnifier.canvasElementOperation(t);break;case "value":JsonUnifier.setStorageValue(t,e);break;case "operationtoconvert":if(r){let n=X(t,e),p=await r(n);p&&await $(p,e,r);}break;case "input":case "dialogue":JsonUnifier.narrationOperation(t);break;case "shake":await JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":JsonUnifier.animateOperation(t);break;case "function":await F(t,e);break}}function M(s){let e=JsonUnifier.getLogichValue(s,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&JsonUnifier.setInitialStorageValue(e);}var ee=pe(Z());var _=class extends LabelAbstract{constructor(r,t,n,p={}){n||(n={}),n.onLoadingLabel=async()=>{for(let a of t){let d;if(typeof a=="function"?d=a():d=a,d=JsonUnifier.getConditionalStep(d),d.operations)try{let m=d.operations.map(v=>JsonUnifier.loadAssets(v));await Promise.all(m);}catch(m){h.error("The operation in the onLoadingLabel function of the label has an error:",m);}}};super(r,n);V(this,"_steps");V(this,"operationStringConvert");V(this,"skipEmptyDialogs",false);this._steps=t,this.operationStringConvert=p.operationStringConvert,this.skipEmptyDialogs=p.skipEmptyDialogs||false;}get steps(){return this._steps.map(r=>this.stepConverter(r))}get stepCount(){return this._steps.length}getStepById(r){if(r<0||r>=this._steps.length)return;let t=this._steps[r];return this.stepConverter(t)}getStepSha(r){if(r<0||r>=this.steps.length)return;let t=this._steps[r];return (0, ee.default)(t.toString().toLocaleLowerCase()).toString()}getDialogueText(r,t){let n="";if(Array.isArray(r)){let p=[];r.forEach(a=>{if(typeof a=="string")p.push(a);else if(a&&typeof a=="object"){let d=JsonUnifier.getLogichValue(a,t);d?(d&&!Array.isArray(d)&&typeof d=="object"&&(d=JsonUnifier.getLogichValue(d,t)||""),Array.isArray(d)?p=p.map(m=>`${m}`).concat(d):p.push(`${d}`)):p.push(`${a}`);}else p.push(`${a}`);}),n=p;}else {let p=JsonUnifier.getLogichValue(r,t);p&&!Array.isArray(p)&&typeof p=="object"&&(p=JsonUnifier.getLogichValue(p,t)),p&&Array.isArray(p)?n=p.map(a=>`${a}`):n=`${p}`;}return n}getDialogue(r,t){if(r==null)return;let n=JsonUnifier.getLogichValue(r,t);return n==null?`${n}`:typeof n=="object"&&"character"in n&&"text"in n?{character:n.character,text:translator.t(this.getDialogueText(n.text,t))}:translator.t(this.getDialogueText(n,t))}getChoices(r,t){return JsonUnifier.getLogichValue(r,t)?.map(a=>JsonUnifier.getLogichValue(a,t)).filter(a=>a!==void 0)}stepConverter(r){return async t=>{let n=typeof r=="function"?r():r;n=createExportableElement(n),n=JsonUnifier.getConditionalStep(n,t);let p=this.operationStringConvert?g=>this.operationStringConvert(g,n,t):void 0,{operations:a=[]}=n;for(let g of a)await $(g,t,p);let{labelToOpen:d=[]}=n,m=this.getChoices(n.choices,t),v=JsonUnifier.getLogichValue(n.glueEnabled,t),f=this.getDialogue(n.dialogue,t),J=[];Array.isArray(d)||(d=[d]),d.forEach(g=>{let x=JsonUnifier.getLogichValue(g,t);x&&J.push(x);});let N=JsonUnifier.getLogichValue(n.goNextStep,t),C=JsonUnifier.getLogichValue(n.end,t);if(m){let g=m.map(x=>{let P="";if(Array.isArray(x.text)){let o=[];x.text.forEach(u=>{if(typeof u=="string")o.push(translator.t(u));else if(u&&typeof u=="object"){let l=JsonUnifier.getLogichValue(u,t);l&&!Array.isArray(l)&&typeof l=="object"&&(l=JsonUnifier.getLogichValue(l,t)||""),l&&(Array.isArray(l)?o=o.concat(translator.t(l)):o.push(translator.t(l)));}}),P=o;}else typeof x.text=="string"&&(P=translator.t(x.text));return {label:x.label,text:P,props:x.props,type:x.type,oneTime:x.oneTime,onlyHaveNoChoice:x.onlyHaveNoChoice,autoSelect:x.autoSelect}});narration.choices=g;}else narration.choices=void 0;f!==void 0&&(narration.dialogue=f,this.skipEmptyDialogs&&typeof f=="string"&&(f===""||RegExp(/^\s+$/).test(f))&&(N=true)),v?narration.dialogGlue=true:v===false&&(narration.dialogGlue=false);for(let g of J){let x=g.label;typeof x=="object"&&(x=JsonUnifier.getLogichValue(x,t)||"");let P=g.params?.map(i=>JsonUnifier.getLogichValue(i,t));t={...t,...g.props},g.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${H}${narration.openedLabels.length}`,P),await narration.call(x,t)):(storage.setTempVariable(`${H}${narration.openedLabels.length}`,P),await narration.call(x,t));}C==="game_end"?(narration.closeAllLabels(),await narration.continue(t,{runNow:true})):C==="label_end"&&narration.closeCurrentLabel(),N&&await narration.continue(t,{runNow:true});}}};async function me(s,e={}){if(!Array.isArray(s))if(typeof s=="object"||typeof s=="string")s=[s];else {h.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let r=s.map(p=>{if(typeof p=="string")try{return JSON.parse(p)}catch(a){return h.error("Error parsing imported Pixi'VN JSON",a),{}}return p}),t=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)a.type==="value"&&(typeof a.value!="object"||!a.value||!("type"in a.value))&&M(a);return Promise.resolve()});await Promise.all(t);let n=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)(a.type!=="value"||a.type==="value"&&typeof a.value=="object"&&a.value&&"type"in a.value)&&M(a);if(p.labels){let a=p.labels;for(let d in a)try{let m=a[d],v=new _(d,m,void 0,e);RegisteredLabels.add(v);}catch(m){h.error(`Error creating JSON label ${d}`,m);}}return Promise.resolve()});await Promise.all(n);}export{_ as LabelJson,me as importPixiVNJson};
1
+ import {createExportableElement,PixiError}from'@drincs/pixi-vn';import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {translator}from'@drincs/pixi-vn-json/translator';import {LabelAbstract,narration,RegisteredLabels}from'@drincs/pixi-vn/narration';import {storage}from'@drincs/pixi-vn/storage';var Z=Object.create;var $=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var B=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,o)=>(typeof require<"u"?require:e)[o]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var M=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var oe=(n,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ie(e))!ne.call(n,s)&&s!==o&&$(n,s,{get:()=>e[s],enumerable:!(t=ee(e,s))||t.enumerable});return n};var re=(n,e,o)=>(o=n!=null?Z(te(n)):{},oe($(o,"default",{value:n,enumerable:true}),n));var F=M((A,G)=>{(function(n,e){typeof A=="object"?G.exports=A=e():typeof define=="function"&&define.amd?define([],e):n.CryptoJS=e();})(A,function(){var n=n||(function(e,o){var t;if(typeof window<"u"&&window.crypto&&(t=window.crypto),typeof self<"u"&&self.crypto&&(t=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(t=globalThis.crypto),!t&&typeof window<"u"&&window.msCrypto&&(t=window.msCrypto),!t&&typeof global<"u"&&global.crypto&&(t=global.crypto),!t&&typeof B=="function")try{t=B("crypto");}catch{}var s=function(){if(t){if(typeof t.getRandomValues=="function")try{return t.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof t.randomBytes=="function")try{return t.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},p=Object.create||(function(){function i(){}return function(a){var c;return i.prototype=a,c=new i,i.prototype=null,c}})(),r={},x=r.lib={},f=x.Base=(function(){return {extend:function(i){var a=p(this);return i&&a.mixIn(i),(!a.hasOwnProperty("init")||this.init===a.init)&&(a.init=function(){a.$super.init.apply(this,arguments);}),a.init.prototype=a,a.$super=this,a},create:function(){var i=this.extend();return i.init.apply(i,arguments),i},init:function(){},mixIn:function(i){for(var a in i)i.hasOwnProperty(a)&&(this[a]=i[a]);i.hasOwnProperty("toString")&&(this.toString=i.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),h=x.WordArray=f.extend({init:function(i,a){i=this.words=i||[],a!=o?this.sigBytes=a:this.sigBytes=i.length*4;},toString:function(i){return (i||N).stringify(this)},concat:function(i){var a=this.words,c=i.words,d=this.sigBytes,y=i.sigBytes;if(this.clamp(),d%4)for(var J=0;J<y;J++){var I=c[J>>>2]>>>24-J%4*8&255;a[d+J>>>2]|=I<<24-(d+J)%4*8;}else for(var C=0;C<y;C+=4)a[d+C>>>2]=c[C>>>2];return this.sigBytes+=y,this},clamp:function(){var i=this.words,a=this.sigBytes;i[a>>>2]&=4294967295<<32-a%4*8,i.length=e.ceil(a/4);},clone:function(){var i=f.clone.call(this);return i.words=this.words.slice(0),i},random:function(i){for(var a=[],c=0;c<i;c+=4)a.push(s());return new h.init(a,i)}}),u=r.enc={},N=u.Hex={stringify:function(i){for(var a=i.words,c=i.sigBytes,d=[],y=0;y<c;y++){var J=a[y>>>2]>>>24-y%4*8&255;d.push((J>>>4).toString(16)),d.push((J&15).toString(16));}return d.join("")},parse:function(i){for(var a=i.length,c=[],d=0;d<a;d+=2)c[d>>>3]|=parseInt(i.substr(d,2),16)<<24-d%8*4;return new h.init(c,a/2)}},V=u.Latin1={stringify:function(i){for(var a=i.words,c=i.sigBytes,d=[],y=0;y<c;y++){var J=a[y>>>2]>>>24-y%4*8&255;d.push(String.fromCharCode(J));}return d.join("")},parse:function(i){for(var a=i.length,c=[],d=0;d<a;d++)c[d>>>2]|=(i.charCodeAt(d)&255)<<24-d%4*8;return new h.init(c,a)}},m=u.Utf8={stringify:function(i){try{return decodeURIComponent(escape(V.stringify(i)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(i){return V.parse(unescape(encodeURIComponent(i)))}},l=x.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new h.init,this._nDataBytes=0;},_append:function(i){typeof i=="string"&&(i=m.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes;},_process:function(i){var a,c=this._data,d=c.words,y=c.sigBytes,J=this.blockSize,I=J*4,C=y/I;i?C=e.ceil(C):C=e.max((C|0)-this._minBufferSize,0);var T=C*J,H=e.min(T*4,y);if(T){for(var z=0;z<T;z+=J)this._doProcessBlock(d,z);a=d.splice(0,T),c.sigBytes-=H;}return new h.init(a,H)},clone:function(){var i=f.clone.call(this);return i._data=this._data.clone(),i},_minBufferSize:0});x.Hasher=l.extend({cfg:f.extend(),init:function(i){this.cfg=this.cfg.extend(i),this.reset();},reset:function(){l.reset.call(this),this._doReset();},update:function(i){return this._append(i),this._process(),this},finalize:function(i){i&&this._append(i);var a=this._doFinalize();return a},blockSize:512/32,_createHelper:function(i){return function(a,c){return new i.init(c).finalize(a)}},_createHmacHelper:function(i){return function(a,c){return new P.HMAC.init(i,c).finalize(a)}}});var P=r.algo={};return r})(Math);return n});});var K=M((E,X)=>{(function(n,e){typeof E=="object"?X.exports=E=e(F()):typeof define=="function"&&define.amd?define(["./core"],e):e(n.CryptoJS);})(E,function(n){return (function(){var e=n,o=e.lib,t=o.WordArray,s=o.Hasher,p=e.algo,r=[],x=p.SHA1=s.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(f,h){for(var u=this._hash.words,N=u[0],V=u[1],m=u[2],l=u[3],w=u[4],P=0;P<80;P++){if(P<16)r[P]=f[h+P]|0;else {var i=r[P-3]^r[P-8]^r[P-14]^r[P-16];r[P]=i<<1|i>>>31;}var a=(N<<5|N>>>27)+w+r[P];P<20?a+=(V&m|~V&l)+1518500249:P<40?a+=(V^m^l)+1859775393:P<60?a+=(V&m|V&l|m&l)-1894007588:a+=(V^m^l)-899497514,w=l,l=m,m=V<<30|V>>>2,V=N,N=a;}u[0]=u[0]+N|0,u[1]=u[1]+V|0,u[2]=u[2]+m|0,u[3]=u[3]+l|0,u[4]=u[4]+w|0;},_doFinalize:function(){var f=this._data,h=f.words,u=this._nDataBytes*8,N=f.sigBytes*8;return h[N>>>5]|=128<<24-N%32,h[(N+64>>>9<<4)+14]=Math.floor(u/4294967296),h[(N+64>>>9<<4)+15]=u,f.sigBytes=h.length*4,this._process(),this._hash},clone:function(){var f=s.clone.call(this);return f._hash=this._hash.clone(),f}});e.SHA1=s._createHelper(x),e.HmacSHA1=s._createHmacHelper(x);})(),n.SHA1});});var k="___param___";var g;(s=>(s.log=(p,...r)=>console.log(`[Pixi\u2019VN Json] ${p}`,...r),s.warn=(p,...r)=>console.warn(`[Pixi\u2019VN Json] ${p}`,...r),s.error=(p,...r)=>console.error(`[Pixi\u2019VN Json] ${p}`,...r),s.info=(p,...r)=>console.info(`[Pixi\u2019VN Json] ${p}`,...r)))(g||={});var L=class n{static init(e){e.loadAssets&&(n._loadAssets=e.loadAssets),e.soundOperation&&(n._soundOperation=e.soundOperation),e.imageOperation&&(n._imageOperation=e.imageOperation),e.videoOperation&&(n._videoOperation=e.videoOperation),e.imageContainerOperation&&(n._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(n._textOperation=e.textOperation),e.canvasElementOperation&&(n._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(n._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(n._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(n._narrationOperation=e.narrationOperation),e.effectOperation&&(n._effectOperation=e.effectOperation),e.animateOperation&&(n._animateOperation=e.animateOperation),e.getLogichValue&&(n._getLogichValue=e.getLogichValue),e.getConditionalStep&&(n._getConditionalStep=e.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return n._loadAssets}static _soundOperation=()=>{throw g.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.")};static get soundOperation(){return n._soundOperation}static _imageOperation=()=>{throw g.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.")};static get imageOperation(){return n._imageOperation}static _videoOperation=()=>{throw g.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.")};static get videoOperation(){return n._videoOperation}static _imageContainerOperation=()=>{throw g.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.")};static get imageContainerOperation(){return n._imageContainerOperation}static _textOperation=()=>{throw g.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.")};static get textOperation(){return n._textOperation}static _canvasElementOperation=()=>{throw g.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.")};static get canvasElementOperation(){return n._canvasElementOperation}static _setStorageValue=()=>{throw g.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.")};static get setStorageValue(){return n._setStorageValue}static _setInitialStorageValue=()=>{throw g.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.")};static get setInitialStorageValue(){return n._setInitialStorageValue}static _narrationOperation=()=>{throw g.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.")};static get narrationOperation(){return n._narrationOperation}static _effectOperation=()=>{throw g.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.")};static get effectOperation(){return n._effectOperation}static _animateOperation=()=>{throw g.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.")};static get animateOperation(){return n._animateOperation}static _getLogichValue=()=>{throw g.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.")};static get getLogichValue(){return n._getLogichValue}static _getConditionalStep=()=>{throw g.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.")};static get getConditionalStep(){return n._getConditionalStep}};function q(n,e){if(e&&typeof e=="object"&&typeof n.functionName=="string"&&n.functionName in e){let o=e[n.functionName];if(typeof o=="function"){let t=n.args.map(s=>L.getLogichValue(s,e));return o(...t)}else g.warn(`getLogichValue function ${n.functionName} not found in props`);}}function W(n,e={}){let o="";return n.values.forEach(t=>{if(typeof t=="string")o+=t;else {let s=JsonUnifier.getLogichValue(t,e);o+=`${s}`;}}),o}async function R(n,e,o){let t=JsonUnifier.getLogichValue(n,e);if(t)switch(t.type){case "sound":JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await JsonUnifier.loadAssets(t);break;case "image":await JsonUnifier.imageOperation(t);break;case "video":await JsonUnifier.videoOperation(t);break;case "imagecontainer":await JsonUnifier.imageContainerOperation(t);break;case "text":await JsonUnifier.textOperation(t);break;case "canvaselement":await JsonUnifier.canvasElementOperation(t);break;case "value":JsonUnifier.setStorageValue(t,e);break;case "operationtoconvert":if(o){let s=W(t,e),p=await o(s);p&&await R(p,e,o);}break;case "input":case "dialogue":JsonUnifier.narrationOperation(t);break;case "shake":await JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":JsonUnifier.animateOperation(t);break;case "function":await q(t,e);break}}function D(n){let e=JsonUnifier.getLogichValue(n,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&JsonUnifier.setInitialStorageValue(e);}var Y=re(K());var _=class extends LabelAbstract{constructor(e,o,t,s={}){t||(t={}),t.onLoadingLabel=async()=>{for(let p of o){let r;if(typeof p=="function"?r=p():r=p,r=JsonUnifier.getConditionalStep(r),r.operations)try{let x=r.operations.map(f=>JsonUnifier.loadAssets(f));await Promise.all(x);}catch(x){g.error("The operation in the onLoadingLabel function of the label has an error:",x);}}},super(e,t),this._steps=o,this.operationStringConvert=s.operationStringConvert,this.skipEmptyDialogs=s.skipEmptyDialogs||false;}_steps;get steps(){return this._steps.map(e=>this.stepConverter(e))}get stepCount(){return this._steps.length}getStepById(e){if(e<0||e>=this._steps.length)return;let o=this._steps[e];return this.stepConverter(o)}operationStringConvert;skipEmptyDialogs=false;getStepSha(e){if(e<0||e>=this.steps.length)return;let o=this._steps[e];return (0, Y.default)(o.toString().toLocaleLowerCase()).toString()}getDialogueText(e,o){let t="";if(Array.isArray(e)){let s=[];e.forEach(p=>{if(typeof p=="string")s.push(p);else if(p&&typeof p=="object"){let r=JsonUnifier.getLogichValue(p,o);r?(r&&!Array.isArray(r)&&typeof r=="object"&&(r=JsonUnifier.getLogichValue(r,o)||""),Array.isArray(r)?s=s.map(x=>`${x}`).concat(r):s.push(`${r}`)):s.push(`${p}`);}else s.push(`${p}`);}),t=s;}else {let s=JsonUnifier.getLogichValue(e,o);s&&!Array.isArray(s)&&typeof s=="object"&&(s=JsonUnifier.getLogichValue(s,o)),s&&Array.isArray(s)?t=s.map(p=>`${p}`):t=`${s}`;}return t}getDialogue(e,o){if(e==null)return;let t=JsonUnifier.getLogichValue(e,o);return t==null?`${t}`:typeof t=="object"&&"character"in t&&"text"in t?{character:t.character,text:translator.t(this.getDialogueText(t.text,o))}:translator.t(this.getDialogueText(t,o))}getChoices(e,o){return JsonUnifier.getLogichValue(e,o)?.map(p=>JsonUnifier.getLogichValue(p,o)).filter(p=>p!==void 0)}stepConverter(e){return async o=>{let t=typeof e=="function"?e():e;t=createExportableElement(t),t=JsonUnifier.getConditionalStep(t,o);let s=this.operationStringConvert?m=>this.operationStringConvert(m,t,o):void 0,{operations:p=[]}=t;for(let m of p)await R(m,o,s);let{labelToOpen:r=[]}=t,x=this.getChoices(t.choices,o),f=JsonUnifier.getLogichValue(t.glueEnabled,o),h=this.getDialogue(t.dialogue,o),u=[];Array.isArray(r)||(r=[r]),r.forEach(m=>{let l=JsonUnifier.getLogichValue(m,o);l&&u.push(l);});let N=JsonUnifier.getLogichValue(t.goNextStep,o),V=JsonUnifier.getLogichValue(t.end,o);if(x){let m=x.map(l=>{let w="";if(Array.isArray(l.text)){let i=[];l.text.forEach(a=>{if(typeof a=="string")i.push(translator.t(a));else if(a&&typeof a=="object"){let c=JsonUnifier.getLogichValue(a,o);c&&!Array.isArray(c)&&typeof c=="object"&&(c=JsonUnifier.getLogichValue(c,o)||""),c&&(Array.isArray(c)?i=i.concat(translator.t(c)):i.push(translator.t(c)));}}),w=i;}else typeof l.text=="string"&&(w=translator.t(l.text));return {label:l.label,text:w,props:l.props,type:l.type,oneTime:l.oneTime,onlyHaveNoChoice:l.onlyHaveNoChoice,autoSelect:l.autoSelect}});narration.choices=m;}else narration.choices=void 0;h!==void 0&&(narration.dialogue=h,this.skipEmptyDialogs&&typeof h=="string"&&(h===""||RegExp(/^\s+$/).test(h))&&(N=true)),f?narration.dialogGlue=true:f===false&&(narration.dialogGlue=false);for(let m of u){let l=m.label;typeof l=="object"&&(l=JsonUnifier.getLogichValue(l,o)||"");let w=m.params?.map(P=>JsonUnifier.getLogichValue(P,o));o={...o,...m.props},m.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${k}${narration.openedLabels.length}`,w),await narration.call(l,o)):(storage.setTempVariable(`${k}${narration.openedLabels.length}`,w),await narration.call(l,o));}V==="game_end"?(narration.closeAllLabels(),await narration.continue(o,{runNow:true})):V==="label_end"&&narration.closeCurrentLabel(),N&&await narration.continue(o,{runNow:true});}}};async function de(n,e={}){if(!Array.isArray(n))if(typeof n=="object"||typeof n=="string")n=[n];else {g.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let o=n.map(p=>{if(typeof p=="string")try{return JSON.parse(p)}catch(r){return g.error("Error parsing imported Pixi'VN JSON",r),{}}return p}),t=o.map(async p=>{if(p.initialOperations)for(let r of p.initialOperations)r.type==="value"&&(typeof r.value!="object"||!r.value||!("type"in r.value))&&D(r);return Promise.resolve()});await Promise.all(t);let s=o.map(async p=>{if(p.initialOperations)for(let r of p.initialOperations)(r.type!=="value"||r.type==="value"&&typeof r.value=="object"&&r.value&&"type"in r.value)&&D(r);if(p.labels){let r=p.labels;for(let x in r)try{let f=r[x],h=new _(x,f,void 0,e);RegisteredLabels.add(h);}catch(f){g.error(`Error creating JSON label ${x}`,f);}}return Promise.resolve()});await Promise.all(s);}export{_ as LabelJson,de as importPixiVNJson};
package/dist/schema.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as PixiVNJsonLabelStep, a0 as PixiVNJsonValueSet, A as PixiVNJsonIfElse } from './PixiVNJsonLabelStep-DJgORyFd.cjs';
2
- export { P as PixiVNJsonAnimateBase, a as PixiVNJsonAnimateSequence, b as PixiVNJsonArithmeticOperations, c as PixiVNJsonArithmeticOperationsArithmetic, d as PixiVNJsonArithmeticOperationsArithmeticSingle, e as PixiVNJsonCanvas, f as PixiVNJsonCanvasAnimate, g as PixiVNJsonCanvasEdit, h as PixiVNJsonCanvasEffect, i as PixiVNJsonCanvasImageContainerShow, j as PixiVNJsonCanvasImageVideoShow, k as PixiVNJsonCanvasRemove, l as PixiVNJsonCanvasShow, m as PixiVNJsonCanvasTextShow, n as PixiVNJsonChoice, o as PixiVNJsonChoiceGet, p as PixiVNJsonChoices, q as PixiVNJsonComparation, r as PixiVNJsonComparationOperatorsType, s as PixiVNJsonConditionalOperation, t as PixiVNJsonConditionalResultToCombine, u as PixiVNJsonConditionalStatements, v as PixiVNJsonConditions, w as PixiVNJsonDialog, x as PixiVNJsonDialogText, y as PixiVNJsonDialogue, z as PixiVNJsonFunction, B as PixiVNJsonImageContainerEdit, C as PixiVNJsonImageEdit, D as PixiVNJsonInputRequest, E as PixiVNJsonLabelGet, G as PixiVNJsonLabelToOpen, H as PixiVNJsonLogicGet, I as PixiVNJsonMediaTransiotions, J as PixiVNJsonNarration, K as PixiVNJsonOnlyStorageSet, L as PixiVNJsonOperation, M as PixiVNJsonOperationString, N as PixiVNJsonParamGet, O as PixiVNJsonSound, Q as PixiVNJsonSoundEdit, R as PixiVNJsonSoundPauseResume, S as PixiVNJsonSoundPlay, T as PixiVNJsonSoundRemove, U as PixiVNJsonStepSwitch, V as PixiVNJsonStepSwitchElementType, W as PixiVNJsonStepSwitchElementsType, X as PixiVNJsonStorageGet, Y as PixiVNJsonTextEdit, Z as PixiVNJsonUnionCondition, _ as PixiVNJsonUnknownEdit, $ as PixiVNJsonValueGet, a1 as PixiVNJsonVideoEdit, a2 as PixiVNJsonVideoPauseResume } from './PixiVNJsonLabelStep-DJgORyFd.cjs';
1
+ import { w as PixiVNJsonLabelStep, n as PixiVNJsonValueSet, a as PixiVNJsonIfElse } from './PixiVNJsonLabelStep-BsGHNfkq.cjs';
2
+ export { y as PixiVNJsonAnimateBase, z as PixiVNJsonAnimateSequence, t as PixiVNJsonArithmeticOperations, A as PixiVNJsonArithmeticOperationsArithmetic, B as PixiVNJsonArithmeticOperationsArithmeticSingle, C as PixiVNJsonCanvas, r as PixiVNJsonCanvasAnimate, D as PixiVNJsonCanvasEdit, q as PixiVNJsonCanvasEffect, i as PixiVNJsonCanvasImageContainerShow, d as PixiVNJsonCanvasImageVideoShow, f as PixiVNJsonCanvasRemove, E as PixiVNJsonCanvasShow, k as PixiVNJsonCanvasTextShow, F as PixiVNJsonChoice, G as PixiVNJsonChoiceGet, H as PixiVNJsonChoices, I as PixiVNJsonComparation, x as PixiVNJsonComparationOperatorsType, J as PixiVNJsonConditionalOperation, K as PixiVNJsonConditionalResultToCombine, v as PixiVNJsonConditionalStatements, u as PixiVNJsonConditions, L as PixiVNJsonDialog, M as PixiVNJsonDialogText, N as PixiVNJsonDialogue, O as PixiVNJsonFunction, j as PixiVNJsonImageContainerEdit, e as PixiVNJsonImageEdit, Q as PixiVNJsonInputRequest, R as PixiVNJsonLabelGet, S as PixiVNJsonLabelToOpen, T as PixiVNJsonLogicGet, U as PixiVNJsonMediaTransiotions, p as PixiVNJsonNarration, o as PixiVNJsonOnlyStorageSet, P as PixiVNJsonOperation, b as PixiVNJsonOperationString, V as PixiVNJsonParamGet, c as PixiVNJsonSound, W as PixiVNJsonSoundEdit, X as PixiVNJsonSoundPauseResume, Y as PixiVNJsonSoundPlay, Z as PixiVNJsonSoundRemove, _ as PixiVNJsonStepSwitch, $ as PixiVNJsonStepSwitchElementType, a0 as PixiVNJsonStepSwitchElementsType, a1 as PixiVNJsonStorageGet, l as PixiVNJsonTextEdit, a2 as PixiVNJsonUnionCondition, m as PixiVNJsonUnknownEdit, s as PixiVNJsonValueGet, g as PixiVNJsonVideoEdit, h as PixiVNJsonVideoPauseResume } from './PixiVNJsonLabelStep-BsGHNfkq.cjs';
3
3
  import '@drincs/pixi-vn';
4
4
  import '@drincs/pixi-vn/motion';
5
5
  import 'pixi.js';
package/dist/schema.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as PixiVNJsonLabelStep, a0 as PixiVNJsonValueSet, A as PixiVNJsonIfElse } from './PixiVNJsonLabelStep-DJgORyFd.js';
2
- export { P as PixiVNJsonAnimateBase, a as PixiVNJsonAnimateSequence, b as PixiVNJsonArithmeticOperations, c as PixiVNJsonArithmeticOperationsArithmetic, d as PixiVNJsonArithmeticOperationsArithmeticSingle, e as PixiVNJsonCanvas, f as PixiVNJsonCanvasAnimate, g as PixiVNJsonCanvasEdit, h as PixiVNJsonCanvasEffect, i as PixiVNJsonCanvasImageContainerShow, j as PixiVNJsonCanvasImageVideoShow, k as PixiVNJsonCanvasRemove, l as PixiVNJsonCanvasShow, m as PixiVNJsonCanvasTextShow, n as PixiVNJsonChoice, o as PixiVNJsonChoiceGet, p as PixiVNJsonChoices, q as PixiVNJsonComparation, r as PixiVNJsonComparationOperatorsType, s as PixiVNJsonConditionalOperation, t as PixiVNJsonConditionalResultToCombine, u as PixiVNJsonConditionalStatements, v as PixiVNJsonConditions, w as PixiVNJsonDialog, x as PixiVNJsonDialogText, y as PixiVNJsonDialogue, z as PixiVNJsonFunction, B as PixiVNJsonImageContainerEdit, C as PixiVNJsonImageEdit, D as PixiVNJsonInputRequest, E as PixiVNJsonLabelGet, G as PixiVNJsonLabelToOpen, H as PixiVNJsonLogicGet, I as PixiVNJsonMediaTransiotions, J as PixiVNJsonNarration, K as PixiVNJsonOnlyStorageSet, L as PixiVNJsonOperation, M as PixiVNJsonOperationString, N as PixiVNJsonParamGet, O as PixiVNJsonSound, Q as PixiVNJsonSoundEdit, R as PixiVNJsonSoundPauseResume, S as PixiVNJsonSoundPlay, T as PixiVNJsonSoundRemove, U as PixiVNJsonStepSwitch, V as PixiVNJsonStepSwitchElementType, W as PixiVNJsonStepSwitchElementsType, X as PixiVNJsonStorageGet, Y as PixiVNJsonTextEdit, Z as PixiVNJsonUnionCondition, _ as PixiVNJsonUnknownEdit, $ as PixiVNJsonValueGet, a1 as PixiVNJsonVideoEdit, a2 as PixiVNJsonVideoPauseResume } from './PixiVNJsonLabelStep-DJgORyFd.js';
1
+ import { w as PixiVNJsonLabelStep, n as PixiVNJsonValueSet, a as PixiVNJsonIfElse } from './PixiVNJsonLabelStep-BsGHNfkq.js';
2
+ export { y as PixiVNJsonAnimateBase, z as PixiVNJsonAnimateSequence, t as PixiVNJsonArithmeticOperations, A as PixiVNJsonArithmeticOperationsArithmetic, B as PixiVNJsonArithmeticOperationsArithmeticSingle, C as PixiVNJsonCanvas, r as PixiVNJsonCanvasAnimate, D as PixiVNJsonCanvasEdit, q as PixiVNJsonCanvasEffect, i as PixiVNJsonCanvasImageContainerShow, d as PixiVNJsonCanvasImageVideoShow, f as PixiVNJsonCanvasRemove, E as PixiVNJsonCanvasShow, k as PixiVNJsonCanvasTextShow, F as PixiVNJsonChoice, G as PixiVNJsonChoiceGet, H as PixiVNJsonChoices, I as PixiVNJsonComparation, x as PixiVNJsonComparationOperatorsType, J as PixiVNJsonConditionalOperation, K as PixiVNJsonConditionalResultToCombine, v as PixiVNJsonConditionalStatements, u as PixiVNJsonConditions, L as PixiVNJsonDialog, M as PixiVNJsonDialogText, N as PixiVNJsonDialogue, O as PixiVNJsonFunction, j as PixiVNJsonImageContainerEdit, e as PixiVNJsonImageEdit, Q as PixiVNJsonInputRequest, R as PixiVNJsonLabelGet, S as PixiVNJsonLabelToOpen, T as PixiVNJsonLogicGet, U as PixiVNJsonMediaTransiotions, p as PixiVNJsonNarration, o as PixiVNJsonOnlyStorageSet, P as PixiVNJsonOperation, b as PixiVNJsonOperationString, V as PixiVNJsonParamGet, c as PixiVNJsonSound, W as PixiVNJsonSoundEdit, X as PixiVNJsonSoundPauseResume, Y as PixiVNJsonSoundPlay, Z as PixiVNJsonSoundRemove, _ as PixiVNJsonStepSwitch, $ as PixiVNJsonStepSwitchElementType, a0 as PixiVNJsonStepSwitchElementsType, a1 as PixiVNJsonStorageGet, l as PixiVNJsonTextEdit, a2 as PixiVNJsonUnionCondition, m as PixiVNJsonUnknownEdit, s as PixiVNJsonValueGet, g as PixiVNJsonVideoEdit, h as PixiVNJsonVideoPauseResume } from './PixiVNJsonLabelStep-BsGHNfkq.js';
3
3
  import '@drincs/pixi-vn';
4
4
  import '@drincs/pixi-vn/motion';
5
5
  import 'pixi.js';
@@ -1 +1 @@
1
- 'use strict';var characters=require('@drincs/pixi-vn/characters'),zod=require('zod'),core=require('@drincs/pixi-vn-json/core');exports.TextReplaces=void 0;(l=>{l.options={replaceRegex:/\[([^\]]+)\]/};let p=[];function x(e,i){p.unshift({fn:e,opts:i});}l.add=x;function R(e){let i=p.findIndex(t=>t.fn===e);i!==-1&&p.splice(i,1);}l.remove=R;function S(){return p.map(e=>e.opts)}l.info=S;function w(e,i){let t=p.filter(r=>(r.opts.type??"after-translation")===i.type);for(let r of t)e=V(e,r.fn,r.opts.validation);return e}l.replace=w;function y(e){let i=p.filter(t=>t.opts.i18nInterpolation);for(let t of i)e=f(e,t.fn,t.opts);return e}l.runI18nPreStep=y;function f(e,i,t){let{validation:r}=t,u=new RegExp(l.options.replaceRegex.source,"g"),a=[...e.matchAll(u)],s=new Set,n=[];for(let o of a)s.has(o[1])||(s.add(o[1]),n.push(o[1]));for(let o of n){if(r==="characterId"){if(!characters.RegisteredCharacters.has(o))continue}else if(r!=="all"){if(r instanceof RegExp){if(!r.test(o))continue}else if(r instanceof zod.ZodType&&!r.safeParse(o).success)continue}i(o)!==void 0&&(e.includes(`{{[${o}]}}`)||(e=e.replaceAll(`[${o}]`,`{{[${o}]}}`)));}return e}function V(e,i,t){let r=new RegExp(l.options.replaceRegex.source,"g"),u=[...e.matchAll(r)],a=new Set,s=[];for(let n of u)a.has(n[1])||(a.add(n[1]),s.push(n[1]));for(let n of s){if(t==="characterId"){if(!characters.RegisteredCharacters.has(n))continue}else if(t!=="all"){if(t instanceof RegExp){if(!t.test(n))continue}else if(t instanceof zod.ZodType&&!t.safeParse(n).success)continue}let o=i(n);o!==void 0&&(e=e.replaceAll(`[${n}]`,o));}return e}})(exports.TextReplaces||(exports.TextReplaces={}));function H(d,p={}){let x="";return d.values.forEach(R=>{if(typeof R=="string")x+=R;else {let S=core.JsonUnifier.getLogichValue(R,p);x+=`${S}`;}}),x}var J;(l=>{let d=e=>e;function R(e){return Array.isArray(e)?e.map(i=>S(`${i}`)):S(`${e}`)}l.t=R;function S(e){let i=e;return l.beforeToTranslate&&(i=(0, l.beforeToTranslate)(i)),i=exports.TextReplaces.replace(i,{type:"before-translation"}),i=d(i),l.afterToTranslate&&(i=(0, l.afterToTranslate)(i)),i=exports.TextReplaces.replace(i,{type:"after-translation"}),i}l.translate=S;function w(e){d=e;}l.setTranslate=w;function y(e,i,t){let{defaultValue:r="empty_string"}=t;typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(u=>{let a=u;if(l.beforeToTranslate&&(a=(0, l.beforeToTranslate)(a)),r==="empty_string")e[a]===void 0&&(e[a]="");else if(r==="copy_key"){let s=u;l.beforeToTranslate&&(s=(0, l.beforeToTranslate)(s));let n=exports.TextReplaces.runI18nPreStep(s);n=exports.TextReplaces.replace(n,{type:"before-translation"}),e[a]=n;}});}function f(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&f(e.then,i),e.else&&f(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(t=>{f(t,i);});else if(e.elements.type==="ifelse"){let t=[];f(e.elements,t),t.forEach(r=>{i.push(...r);});}else if(e.elements.type==="stepswitch"){let t=[];f(e.elements,t),t.forEach(r=>{i.push(...r);});}else f(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&f(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(t=>{f(t,i);})):i.push(e);else e&&i.push(e);return i}async function V(e,i={},t={}){let{defaultValue:r="copy_key",operationStringConvert:u}=t,a=e.map(async s=>{if(s.choices){let n=[];Array.isArray(s.choices)?n=[s.choices]:n=f(s.choices),n.forEach(o=>{o.forEach(c=>{if("type"in c){let m=[];c.type==="ifelse"||c.type==="stepswitch"?f(c,m):m=[c],m.map(g=>f(g.text)).forEach(g=>{Array.isArray(g)&&g.forEach(h=>{Array.isArray(h)?h.forEach(E=>{typeof E=="string"?y(i,E,{defaultValue:r}):f(E).forEach(A=>{Array.isArray(A)?A.forEach(T=>{typeof T=="string"&&y(i,T,{defaultValue:r});}):typeof A=="string"&&y(i,A,{defaultValue:r});});}):typeof h=="string"&&y(i,h,{defaultValue:r});});});}});});}if(s.dialogue){let n=[];Array.isArray(s.dialogue)?n=[s.dialogue]:n=f(s.dialogue),n.forEach(o=>{if(typeof o=="string")y(i,o,{defaultValue:r});else if("text"in o){let c=f(o.text);typeof c=="string"&&(c=[c]),c.forEach(m=>{typeof m=="string"?y(i,m,{defaultValue:r}):f(m).forEach(g=>{typeof g=="string"?y(i,g,{defaultValue:r}):Array.isArray(g)&&g.forEach(h=>{typeof h=="string"?y(i,h,{defaultValue:r}):f(h).forEach(E=>{typeof E=="string"&&y(i,E,{defaultValue:r});});});});});}});}if(s.operations)for(let n of s.operations){if(n.type==="operationtoconvert"&&u){let o=H(n),c=await u(o,s,{});if(!c)return;n=c;}n.type==="text"&&n.operationType==="show"&&y(i,n.text,{defaultValue:r});}s.conditionalStep&&f(s.conditionalStep).forEach(o=>{Array.isArray(o)?V(o,i,t):V([o],i,t);});});return await Promise.all(a),i}l.generateJsonTranslation=V;})(J||(J={}));var _=J;exports.translator=_;
1
+ 'use strict';var characters=require('@drincs/pixi-vn/characters'),zod=require('zod'),core=require('@drincs/pixi-vn-json/core');exports.TextReplaces=void 0;(l=>{l.options={replaceRegex:/\[([^\]]+)\]/};let p=[];function x(e,i){p.unshift({fn:e,opts:i});}l.add=x;function E(e){let i=p.findIndex(t=>t.fn===e);i!==-1&&p.splice(i,1);}l.remove=E;function S(){return p.map(e=>e.opts)}l.info=S;function w(e,i){let t=p.filter(r=>(r.opts.type??"after-translation")===i.type);for(let r of t)e=V(e,r.fn,r.opts.validation);return e}l.replace=w;function y(e){let i=p.filter(t=>t.opts.i18nInterpolation);for(let t of i)e=f(e,t.fn,t.opts);return e}l.runI18nPreStep=y;function f(e,i,t){let{validation:r}=t,u=new RegExp(l.options.replaceRegex.source,"g"),a=[...e.matchAll(u)],s=new Set,n=[];for(let o of a)s.has(o[1])||(s.add(o[1]),n.push(o[1]));for(let o of n){if(r==="characterId"){if(!characters.RegisteredCharacters.has(o))continue}else if(r!=="all"){if(r instanceof RegExp){if(!r.test(o))continue}else if(r instanceof zod.ZodType&&!r.safeParse(o).success)continue}i(o)!==void 0&&(e.includes(`{{[${o}]}}`)||(e=e.replaceAll(`[${o}]`,`{{[${o}]}}`)));}return e}function V(e,i,t){let r=new RegExp(l.options.replaceRegex.source,"g"),u=[...e.matchAll(r)],a=new Set,s=[];for(let n of u)a.has(n[1])||(a.add(n[1]),s.push(n[1]));for(let n of s){if(t==="characterId"){if(!characters.RegisteredCharacters.has(n))continue}else if(t!=="all"){if(t instanceof RegExp){if(!t.test(n))continue}else if(t instanceof zod.ZodType&&!t.safeParse(n).success)continue}let o=i(n);o!==void 0&&(e=e.replaceAll(`[${n}]`,o));}return e}})(exports.TextReplaces||={});function C(d,p={}){let x="";return d.values.forEach(E=>{if(typeof E=="string")x+=E;else {let S=core.JsonUnifier.getLogichValue(E,p);x+=`${S}`;}}),x}var H;(l=>{let d=e=>e;function E(e){return Array.isArray(e)?e.map(i=>S(`${i}`)):S(`${e}`)}l.t=E;function S(e){let i=e;return l.beforeToTranslate&&(i=(0, l.beforeToTranslate)(i)),i=exports.TextReplaces.replace(i,{type:"before-translation"}),i=d(i),l.afterToTranslate&&(i=(0, l.afterToTranslate)(i)),i=exports.TextReplaces.replace(i,{type:"after-translation"}),i}l.translate=S;function w(e){d=e;}l.setTranslate=w;function y(e,i,t){let{defaultValue:r="empty_string"}=t;typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(u=>{let a=u;if(l.beforeToTranslate&&(a=(0, l.beforeToTranslate)(a)),r==="empty_string")e[a]===void 0&&(e[a]="");else if(r==="copy_key"){let s=u;l.beforeToTranslate&&(s=(0, l.beforeToTranslate)(s));let n=exports.TextReplaces.runI18nPreStep(s);n=exports.TextReplaces.replace(n,{type:"before-translation"}),e[a]=n;}});}function f(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&f(e.then,i),e.else&&f(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(t=>{f(t,i);});else if(e.elements.type==="ifelse"){let t=[];f(e.elements,t),t.forEach(r=>{i.push(...r);});}else if(e.elements.type==="stepswitch"){let t=[];f(e.elements,t),t.forEach(r=>{i.push(...r);});}else f(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&f(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(t=>{f(t,i);})):i.push(e);else e&&i.push(e);return i}async function V(e,i={},t={}){let{defaultValue:r="copy_key",operationStringConvert:u}=t,a=e.map(async s=>{if(s.choices){let n=[];Array.isArray(s.choices)?n=[s.choices]:n=f(s.choices),n.forEach(o=>{o.forEach(c=>{if("type"in c){let m=[];c.type==="ifelse"||c.type==="stepswitch"?f(c,m):m=[c],m.map(g=>f(g.text)).forEach(g=>{Array.isArray(g)&&g.forEach(h=>{Array.isArray(h)?h.forEach(P=>{typeof P=="string"?y(i,P,{defaultValue:r}):f(P).forEach(A=>{Array.isArray(A)?A.forEach(T=>{typeof T=="string"&&y(i,T,{defaultValue:r});}):typeof A=="string"&&y(i,A,{defaultValue:r});});}):typeof h=="string"&&y(i,h,{defaultValue:r});});});}});});}if(s.dialogue){let n=[];Array.isArray(s.dialogue)?n=[s.dialogue]:n=f(s.dialogue),n.forEach(o=>{if(typeof o=="string")y(i,o,{defaultValue:r});else if("text"in o){let c=f(o.text);typeof c=="string"&&(c=[c]),c.forEach(m=>{typeof m=="string"?y(i,m,{defaultValue:r}):f(m).forEach(g=>{typeof g=="string"?y(i,g,{defaultValue:r}):Array.isArray(g)&&g.forEach(h=>{typeof h=="string"?y(i,h,{defaultValue:r}):f(h).forEach(P=>{typeof P=="string"&&y(i,P,{defaultValue:r});});});});});}});}if(s.operations)for(let n of s.operations){if(n.type==="operationtoconvert"&&u){let o=C(n),c=await u(o,s,{});if(!c)return;n=c;}n.type==="text"&&n.operationType==="show"&&y(i,n.text,{defaultValue:r});}s.conditionalStep&&f(s.conditionalStep).forEach(o=>{Array.isArray(o)?V(o,i,t):V([o],i,t);});});return await Promise.all(a),i}l.generateJsonTranslation=V;})(H||={});var _=H;exports.translator=_;
@@ -1,6 +1,6 @@
1
1
  import { ZodType } from 'zod';
2
2
  import { StepLabelPropsType } from '@drincs/pixi-vn';
3
- import { F as PixiVNJsonLabelStep, L as PixiVNJsonOperation } from './PixiVNJsonLabelStep-DJgORyFd.cjs';
3
+ import { w as PixiVNJsonLabelStep, P as PixiVNJsonOperation } from './PixiVNJsonLabelStep-BsGHNfkq.cjs';
4
4
  import '@drincs/pixi-vn/motion';
5
5
  import 'pixi.js';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { ZodType } from 'zod';
2
2
  import { StepLabelPropsType } from '@drincs/pixi-vn';
3
- import { F as PixiVNJsonLabelStep, L as PixiVNJsonOperation } from './PixiVNJsonLabelStep-DJgORyFd.js';
3
+ import { w as PixiVNJsonLabelStep, P as PixiVNJsonOperation } from './PixiVNJsonLabelStep-BsGHNfkq.js';
4
4
  import '@drincs/pixi-vn/motion';
5
5
  import 'pixi.js';
6
6
 
@@ -1 +1 @@
1
- import {RegisteredCharacters}from'@drincs/pixi-vn/characters';import {ZodType}from'zod';import {JsonUnifier}from'@drincs/pixi-vn-json/core';var P;(l=>{l.options={replaceRegex:/\[([^\]]+)\]/};let p=[];function x(e,i){p.unshift({fn:e,opts:i});}l.add=x;function R(e){let i=p.findIndex(t=>t.fn===e);i!==-1&&p.splice(i,1);}l.remove=R;function S(){return p.map(e=>e.opts)}l.info=S;function w(e,i){let t=p.filter(r=>(r.opts.type??"after-translation")===i.type);for(let r of t)e=V(e,r.fn,r.opts.validation);return e}l.replace=w;function y(e){let i=p.filter(t=>t.opts.i18nInterpolation);for(let t of i)e=f(e,t.fn,t.opts);return e}l.runI18nPreStep=y;function f(e,i,t){let{validation:r}=t,u=new RegExp(l.options.replaceRegex.source,"g"),a=[...e.matchAll(u)],s=new Set,n=[];for(let o of a)s.has(o[1])||(s.add(o[1]),n.push(o[1]));for(let o of n){if(r==="characterId"){if(!RegisteredCharacters.has(o))continue}else if(r!=="all"){if(r instanceof RegExp){if(!r.test(o))continue}else if(r instanceof ZodType&&!r.safeParse(o).success)continue}i(o)!==void 0&&(e.includes(`{{[${o}]}}`)||(e=e.replaceAll(`[${o}]`,`{{[${o}]}}`)));}return e}function V(e,i,t){let r=new RegExp(l.options.replaceRegex.source,"g"),u=[...e.matchAll(r)],a=new Set,s=[];for(let n of u)a.has(n[1])||(a.add(n[1]),s.push(n[1]));for(let n of s){if(t==="characterId"){if(!RegisteredCharacters.has(n))continue}else if(t!=="all"){if(t instanceof RegExp){if(!t.test(n))continue}else if(t instanceof ZodType&&!t.safeParse(n).success)continue}let o=i(n);o!==void 0&&(e=e.replaceAll(`[${n}]`,o));}return e}})(P||(P={}));function H(d,p={}){let x="";return d.values.forEach(R=>{if(typeof R=="string")x+=R;else {let S=JsonUnifier.getLogichValue(R,p);x+=`${S}`;}}),x}var J;(l=>{let d=e=>e;function R(e){return Array.isArray(e)?e.map(i=>S(`${i}`)):S(`${e}`)}l.t=R;function S(e){let i=e;return l.beforeToTranslate&&(i=(0, l.beforeToTranslate)(i)),i=P.replace(i,{type:"before-translation"}),i=d(i),l.afterToTranslate&&(i=(0, l.afterToTranslate)(i)),i=P.replace(i,{type:"after-translation"}),i}l.translate=S;function w(e){d=e;}l.setTranslate=w;function y(e,i,t){let{defaultValue:r="empty_string"}=t;typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(u=>{let a=u;if(l.beforeToTranslate&&(a=(0, l.beforeToTranslate)(a)),r==="empty_string")e[a]===void 0&&(e[a]="");else if(r==="copy_key"){let s=u;l.beforeToTranslate&&(s=(0, l.beforeToTranslate)(s));let n=P.runI18nPreStep(s);n=P.replace(n,{type:"before-translation"}),e[a]=n;}});}function f(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&f(e.then,i),e.else&&f(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(t=>{f(t,i);});else if(e.elements.type==="ifelse"){let t=[];f(e.elements,t),t.forEach(r=>{i.push(...r);});}else if(e.elements.type==="stepswitch"){let t=[];f(e.elements,t),t.forEach(r=>{i.push(...r);});}else f(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&f(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(t=>{f(t,i);})):i.push(e);else e&&i.push(e);return i}async function V(e,i={},t={}){let{defaultValue:r="copy_key",operationStringConvert:u}=t,a=e.map(async s=>{if(s.choices){let n=[];Array.isArray(s.choices)?n=[s.choices]:n=f(s.choices),n.forEach(o=>{o.forEach(c=>{if("type"in c){let m=[];c.type==="ifelse"||c.type==="stepswitch"?f(c,m):m=[c],m.map(g=>f(g.text)).forEach(g=>{Array.isArray(g)&&g.forEach(h=>{Array.isArray(h)?h.forEach(E=>{typeof E=="string"?y(i,E,{defaultValue:r}):f(E).forEach(A=>{Array.isArray(A)?A.forEach(T=>{typeof T=="string"&&y(i,T,{defaultValue:r});}):typeof A=="string"&&y(i,A,{defaultValue:r});});}):typeof h=="string"&&y(i,h,{defaultValue:r});});});}});});}if(s.dialogue){let n=[];Array.isArray(s.dialogue)?n=[s.dialogue]:n=f(s.dialogue),n.forEach(o=>{if(typeof o=="string")y(i,o,{defaultValue:r});else if("text"in o){let c=f(o.text);typeof c=="string"&&(c=[c]),c.forEach(m=>{typeof m=="string"?y(i,m,{defaultValue:r}):f(m).forEach(g=>{typeof g=="string"?y(i,g,{defaultValue:r}):Array.isArray(g)&&g.forEach(h=>{typeof h=="string"?y(i,h,{defaultValue:r}):f(h).forEach(E=>{typeof E=="string"&&y(i,E,{defaultValue:r});});});});});}});}if(s.operations)for(let n of s.operations){if(n.type==="operationtoconvert"&&u){let o=H(n),c=await u(o,s,{});if(!c)return;n=c;}n.type==="text"&&n.operationType==="show"&&y(i,n.text,{defaultValue:r});}s.conditionalStep&&f(s.conditionalStep).forEach(o=>{Array.isArray(o)?V(o,i,t):V([o],i,t);});});return await Promise.all(a),i}l.generateJsonTranslation=V;})(J||(J={}));var _=J;export{P as TextReplaces,_ as translator};
1
+ import {RegisteredCharacters}from'@drincs/pixi-vn/characters';import {ZodType}from'zod';import {JsonUnifier}from'@drincs/pixi-vn-json/core';var R;(l=>{l.options={replaceRegex:/\[([^\]]+)\]/};let p=[];function x(e,i){p.unshift({fn:e,opts:i});}l.add=x;function E(e){let i=p.findIndex(t=>t.fn===e);i!==-1&&p.splice(i,1);}l.remove=E;function S(){return p.map(e=>e.opts)}l.info=S;function w(e,i){let t=p.filter(r=>(r.opts.type??"after-translation")===i.type);for(let r of t)e=V(e,r.fn,r.opts.validation);return e}l.replace=w;function y(e){let i=p.filter(t=>t.opts.i18nInterpolation);for(let t of i)e=f(e,t.fn,t.opts);return e}l.runI18nPreStep=y;function f(e,i,t){let{validation:r}=t,u=new RegExp(l.options.replaceRegex.source,"g"),a=[...e.matchAll(u)],s=new Set,n=[];for(let o of a)s.has(o[1])||(s.add(o[1]),n.push(o[1]));for(let o of n){if(r==="characterId"){if(!RegisteredCharacters.has(o))continue}else if(r!=="all"){if(r instanceof RegExp){if(!r.test(o))continue}else if(r instanceof ZodType&&!r.safeParse(o).success)continue}i(o)!==void 0&&(e.includes(`{{[${o}]}}`)||(e=e.replaceAll(`[${o}]`,`{{[${o}]}}`)));}return e}function V(e,i,t){let r=new RegExp(l.options.replaceRegex.source,"g"),u=[...e.matchAll(r)],a=new Set,s=[];for(let n of u)a.has(n[1])||(a.add(n[1]),s.push(n[1]));for(let n of s){if(t==="characterId"){if(!RegisteredCharacters.has(n))continue}else if(t!=="all"){if(t instanceof RegExp){if(!t.test(n))continue}else if(t instanceof ZodType&&!t.safeParse(n).success)continue}let o=i(n);o!==void 0&&(e=e.replaceAll(`[${n}]`,o));}return e}})(R||={});function C(d,p={}){let x="";return d.values.forEach(E=>{if(typeof E=="string")x+=E;else {let S=JsonUnifier.getLogichValue(E,p);x+=`${S}`;}}),x}var H;(l=>{let d=e=>e;function E(e){return Array.isArray(e)?e.map(i=>S(`${i}`)):S(`${e}`)}l.t=E;function S(e){let i=e;return l.beforeToTranslate&&(i=(0, l.beforeToTranslate)(i)),i=R.replace(i,{type:"before-translation"}),i=d(i),l.afterToTranslate&&(i=(0, l.afterToTranslate)(i)),i=R.replace(i,{type:"after-translation"}),i}l.translate=S;function w(e){d=e;}l.setTranslate=w;function y(e,i,t){let{defaultValue:r="empty_string"}=t;typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(u=>{let a=u;if(l.beforeToTranslate&&(a=(0, l.beforeToTranslate)(a)),r==="empty_string")e[a]===void 0&&(e[a]="");else if(r==="copy_key"){let s=u;l.beforeToTranslate&&(s=(0, l.beforeToTranslate)(s));let n=R.runI18nPreStep(s);n=R.replace(n,{type:"before-translation"}),e[a]=n;}});}function f(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&f(e.then,i),e.else&&f(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(t=>{f(t,i);});else if(e.elements.type==="ifelse"){let t=[];f(e.elements,t),t.forEach(r=>{i.push(...r);});}else if(e.elements.type==="stepswitch"){let t=[];f(e.elements,t),t.forEach(r=>{i.push(...r);});}else f(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&f(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(t=>{f(t,i);})):i.push(e);else e&&i.push(e);return i}async function V(e,i={},t={}){let{defaultValue:r="copy_key",operationStringConvert:u}=t,a=e.map(async s=>{if(s.choices){let n=[];Array.isArray(s.choices)?n=[s.choices]:n=f(s.choices),n.forEach(o=>{o.forEach(c=>{if("type"in c){let m=[];c.type==="ifelse"||c.type==="stepswitch"?f(c,m):m=[c],m.map(g=>f(g.text)).forEach(g=>{Array.isArray(g)&&g.forEach(h=>{Array.isArray(h)?h.forEach(P=>{typeof P=="string"?y(i,P,{defaultValue:r}):f(P).forEach(A=>{Array.isArray(A)?A.forEach(T=>{typeof T=="string"&&y(i,T,{defaultValue:r});}):typeof A=="string"&&y(i,A,{defaultValue:r});});}):typeof h=="string"&&y(i,h,{defaultValue:r});});});}});});}if(s.dialogue){let n=[];Array.isArray(s.dialogue)?n=[s.dialogue]:n=f(s.dialogue),n.forEach(o=>{if(typeof o=="string")y(i,o,{defaultValue:r});else if("text"in o){let c=f(o.text);typeof c=="string"&&(c=[c]),c.forEach(m=>{typeof m=="string"?y(i,m,{defaultValue:r}):f(m).forEach(g=>{typeof g=="string"?y(i,g,{defaultValue:r}):Array.isArray(g)&&g.forEach(h=>{typeof h=="string"?y(i,h,{defaultValue:r}):f(h).forEach(P=>{typeof P=="string"&&y(i,P,{defaultValue:r});});});});});}});}if(s.operations)for(let n of s.operations){if(n.type==="operationtoconvert"&&u){let o=C(n),c=await u(o,s,{});if(!c)return;n=c;}n.type==="text"&&n.operationType==="show"&&y(i,n.text,{defaultValue:r});}s.conditionalStep&&f(s.conditionalStep).forEach(o=>{Array.isArray(o)?V(o,i,t):V([o],i,t);});});return await Promise.all(a),i}l.generateJsonTranslation=V;})(H||={});var _=H;export{R as TextReplaces,_ as translator};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drincs/pixi-vn-json",
3
- "version": "1.13.9",
3
+ "version": "1.13.10",
4
4
  "type": "module",
5
5
  "description": "Pixi'VN can be integrated with JSON files to create a visual novel.",
6
6
  "main": "./dist/index.cjs",