@drincs/pixi-vn-json 1.12.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ 'use strict';var core=require('@drincs/pixi-vn-json/core'),canvas=require('@drincs/pixi-vn/canvas'),translator=require('@drincs/pixi-vn-json/translator'),narration=require('@drincs/pixi-vn/narration'),sound=require('@drincs/pixi-vn/sound'),pixiVn=require('@drincs/pixi-vn'),storage=require('@drincs/pixi-vn/storage');var q=Object.defineProperty;var W=(e,i,t)=>i in e?q(e,i,{enumerable:true,configurable:true,writable:true,value:t}):e[i]=t;var d=(e,i,t)=>W(e,typeof i!="symbol"?i+"":i,t);async function Te(e){let i=core.JsonUnifier.getLogichValue(e,{});if(i)switch(i.type){case "assets":switch(i.operationType){case "load":await canvas.Assets.load(i.aliases);break;case "lazyload":canvas.Assets.backgroundLoad(i.aliases);break}break;case "bundle":switch(i.operationType){case "load":await canvas.Assets.loadBundle(i.aliases);break;case "lazyload":canvas.Assets.backgroundLoadBundle(i.aliases);break}break}}var o;(l=>(l.log=(r,...u)=>console.log(`[Pixi\u2019VN Json] ${r}`,...u),l.warn=(r,...u)=>console.warn(`[Pixi\u2019VN Json] ${r}`,...u),l.error=(r,...u)=>console.error(`[Pixi\u2019VN Json] ${r}`,...u),l.info=(r,...u)=>console.info(`[Pixi\u2019VN Json] ${r}`,...u)))(o||(o={}));async function v(e,i,t){switch(t.type){case "fade":await canvas.showWithFade(i.alias,e,t.props,t.priority);break;case "dissolve":await canvas.showWithDissolve(i.alias,e,t.props,t.priority);break;case "movein":case "moveout":await canvas.moveIn(i.alias,e,t.props,t.priority);break;case "zoomin":case "zoomout":await canvas.zoomIn(i.alias,e,t.props,t.priority);break;case "pushin":case "pushout":await canvas.pushIn(i.alias,e,t.props,t.priority);break}}function N(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 i=new canvas.ImageSprite(e.props,e.url||e.alias);await v(i,e,e.transition);}else await canvas.showImage(e.alias,e.url,e.props);break;case "edit":{let i=canvas.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):o.error(`Image with alias ${e.alias} not found.`);break}case "remove":N(e);break}}async function Ee(e){switch(e.operationType){case "show":if(e.transition){let i=new canvas.VideoSprite(e.props,e.url||e.alias);await v(i,e,e.transition);}else await canvas.showVideo(e.alias,e.url,e.props);break;case "edit":{let i=canvas.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):o.error(`Video with alias ${e.alias} not found.`);break}case "remove":N(e);break;case "pause":case "resume":{let i=canvas.canvas.find(e.alias);i?i.paused=e.operationType==="pause":o.error(`Video with alias ${e.alias} not found.`);break}}}async function Ae(e){switch(e.operationType){case "show":if(e.transition){let i=new canvas.ImageContainer(e.props,e.urls);await v(i,e,e.transition);}else await canvas.showImageContainer(e.alias,e.urls,e.props);break;case "edit":{let i=canvas.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):o.error(`ImageContainer with alias ${e.alias} not found.`);break}case "remove":N(e);break}}async function Re(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator.translator.t(e.text),e.transition){let i=new canvas.Text(e.props);await v(i,e,e.transition);}else canvas.showText(e.alias,e.text,e.props);break;case "edit":{let i=canvas.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):o.error(`Text with alias ${e.alias} not found.`);break}case "remove":N(e);break}}async function ze(e){switch(e.operationType){case "edit":try{let i=canvas.canvas.find(e.alias);i?e.props&&i.setMemory({...i.memory,...e.props}):o.error(`Canvas Element with alias ${e.alias} not found.`);}catch(i){o.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,i);}break;case "remove":N(e);break}}async function Me(e){e.type==="shake"&&await canvas.shakeEffect(e.alias,e.props,e.priority);}function _e(e){switch(e.type){case "animate":canvas.canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function De(e){switch(e.type){case "input":narration.narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.narration.dialogue=void 0;break}}function We(e){switch(e.operationType){case "play":e.url?sound.sound.play(e.alias,e.url,e.props):sound.sound.play(e.alias,e.props);break;case "stop":switch(e.type){case "sound":sound.sound.stop(e.alias);break;case "all":sound.sound.stopAll();break}break;case "pause":switch(e.type){case "sound":sound.sound.pause(e.alias);break;case "channel":sound.sound.findChannel(e.alias).pauseAll();break;case "all":sound.sound.pauseAll();break}break;case "resume":switch(e.type){case "sound":sound.sound.resume(e.alias);break;case "channel":sound.sound.findChannel(e.alias).resumeAll();break;case "all":sound.sound.resumeAll();break}break;case "edit":Object.entries(e.props).forEach(([i,t])=>{let a=sound.sound.find(e.alias);a&&(i==="volume"?a.volume.value=t:a.paused=t);});break}}var J="___param___";var n=class n{static init(i){i.loadAssets&&(n._loadAssets=i.loadAssets),i.soundOperation&&(n._soundOperation=i.soundOperation),i.imageOperation&&(n._imageOperation=i.imageOperation),i.videoOperation&&(n._videoOperation=i.videoOperation),i.imageContainerOperation&&(n._imageContainerOperation=i.imageContainerOperation),i.textOperation&&(n._textOperation=i.textOperation),i.canvasElementOperation&&(n._canvasElementOperation=i.canvasElementOperation),i.setStorageValue&&(n._setStorageValue=i.setStorageValue),i.setInitialStorageValue&&(n._setInitialStorageValue=i.setInitialStorageValue),i.narrationOperation&&(n._narrationOperation=i.narrationOperation),i.effectOperation&&(n._effectOperation=i.effectOperation),i.animateOperation&&(n._animateOperation=i.animateOperation),i.getLogichValue&&(n._getLogichValue=i.getLogichValue),i.getConditionalStep&&(n._getConditionalStep=i.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 f=n;function R(e,i){if(i&&typeof i=="object"&&typeof e.functionName=="string"&&e.functionName in i){let t=i[e.functionName];if(typeof t=="function"){let a=e.args.map(l=>f.getLogichValue(l,i));return t(...a)}else o.warn(`getLogichValue function ${e.functionName} not found in props`);}}function z(e,i){let t=core.JsonUnifier.getLogichValue(e,i);return t&&typeof t=="object"&&"type"in t?core.JsonUnifier.getLogichValue(t,i):t}function xi(e,i={}){let t=z(e.value,i);switch(e.storageType){case "flagStorage":storage.storage.setFlag(e.key,e.value);break;case "storage":storage.storage.set(e.key,t);break;case "tempstorage":storage.storage.setTempVariable(e.key,t);break;case "params":{let a=storage.storage.get(`${J}${narration.narration.openedLabels.length-1}`)||[];a.length>e.key&&(a[e.key]=t),storage.storage.setTempVariable(`${J}${narration.narration.openedLabels.length-1}`,a);break}}}function Vi(e,i={}){let t=z(e.value,i);switch(e.storageType){case "storage":case "tempstorage":storage.storage.default={[e.key]:t};break}}function Ve(e,i={}){let t=ye(e,i);if(t&&typeof t=="object"&&"type"in t)switch(t.type){case "value":return Pe(t,i);case "arithmetic":case "arithmeticsingle":return ge(t,i);case "compare":case "valueCondition":case "union":return he(t,i);case "function":return R(t,i)}return t}function ge(e,i){let t=core.JsonUnifier.getLogichValue(e.leftValue,i);switch(e.type){case "arithmetic":{let a=core.JsonUnifier.getLogichValue(e.rightValue,i);switch(e.operator){case "*":return t*a;case "/":return t/a;case "+":return t+a;case "-":return t-a;case "%":return t%a;case "POW":return t**a;case "RANDOM":return narration.narration.getRandomNumber(t,a)}}case "arithmeticsingle":switch(e.operator){case "INT":return Number(t);case "FLOOR":return Math.floor(t);}break}}function Pe(e,i){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,i);case "params":{let t=storage.storage.get(`${J}${narration.narration.openedLabels.length-1}`)||[];if(t&&t.length>e.key)return t[e.key];o.warn("getValue params not found");return}}return e}function he(e,i){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":{let t=core.JsonUnifier.getLogichValue(e.leftValue,i),a=core.JsonUnifier.getLogichValue(e.rightValue,i);switch(e.operator){case "==":return t===a;case "!=":return t!==a;case "<":return t<a;case "<=":return t<=a;case ">":return t>a;case ">=":return t>=a;case "CONTAINS":return t.toString().includes(a.toString())}break}case "valueCondition":return !!core.JsonUnifier.getLogichValue(e.value,i);case "union":return fe(e,i)}return !!e}function fe(e,i){if(e.unionType==="not")return !Ve(e.condition,i);let t=a=>core.JsonUnifier.getLogichValue(a,i)||false;return e.unionType==="and"?e.conditions.every(t):e.conditions.some(t)}function Ne(e,i){return Math.floor(Math.random()*(i-e+1)+e)}function ye(e,i={}){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return ve(e,i);case "ifelse":return core.JsonUnifier.getLogichValue(e.condition,i)?core.JsonUnifier.getLogichValue(e.then,i):core.JsonUnifier.getLogichValue(e.else,i);case "stepswitch":{let t=core.JsonUnifier.getLogichValue(e.elements,i)||[];if(t.length===0){o.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":{let a=Ne(0,t.length-1);return core.JsonUnifier.getLogichValue(t[a],i)}case "loop":{let a=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return a>t.length-1?(a=a%t.length,core.JsonUnifier.getLogichValue(t[a],i)):core.JsonUnifier.getLogichValue(t[a],i)}case "sequential":{let a,l=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end==="lastItem"&&(a=core.JsonUnifier.getLogichValue(t[t.length-1],i)),l>t.length-1?a:core.JsonUnifier.getLogichValue(t[l],i)}case "sequentialrandom":{let a=narration.NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:e.nestedId,onceOnly:true});if(a===void 0&&e.end==="lastItem"){let l=narration.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!l?.usedRandomNumbers){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let r=l.usedRandomNumbers[`0-${t.length-1}`];return core.JsonUnifier.getLogichValue(t[r[r.length-1]],i)}if(a===void 0){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return core.JsonUnifier.getLogichValue(t[a],i)}}}}return e}function M(e,i={}){if(e.conditionalStep){let t=pixiVn.createExportableElement(core.JsonUnifier.getLogichValue(e.conditionalStep,i));if(t?.glueEnabled===void 0&&delete t?.glueEnabled,t?.goNextStep===void 0&&delete t?.goNextStep,t?.end===void 0&&delete t?.end,t?.choices===void 0&&delete t?.choices,t?.dialogue===void 0&&delete t?.dialogue,t?.labelToOpen===void 0&&delete t?.labelToOpen,t?.operations===void 0&&delete t?.operations,t){let a={...e,conditionalStep:void 0,...t};return M(a,i)}else narration.narration.dialogGlue&&(narration.narration.dialogGlue=false);}return e}function ve(e,i){let t=e.firstItem,a=(e.secondConditionalItem??[]).flatMap(r=>Array.isArray(r)?r.map(u=>core.JsonUnifier.getLogichValue(u,i)):[core.JsonUnifier.getLogichValue(r,i)]),l=t?[t,...a]:a;if(l.length===0){o.warn("combinateResult toCheck.length === 0");return}if(typeof l[0]=="string")return translator.translator.t(l);if(typeof l[0]=="object"){let r=l,u,C=false,O=r.map((c,h)=>{c=M(c,i);let p=core.JsonUnifier.getLogichValue(c.dialogue,i)||"";return h===0?(u=core.JsonUnifier.getLogichValue(c.glueEnabled,i)||false,p):(typeof p=="object"&&"text"in p&&(p=`${p.character}: ${p.text}`),u===false&&C&&(p=`
2
+
3
+ ${p}`),p&&(C=true),u=core.JsonUnifier.getLogichValue(c.glueEnabled,i)||false,p)}),b=core.JsonUnifier.getLogichValue(O[0],i),k=typeof b=="object"&&"character"in b?b.character:void 0,L=O.flatMap(c=>{let h;c&&typeof c=="object"&&"text"in c?h=c.text:h=c;let p;return Array.isArray(h)?p=h.map(D=>{let F=core.JsonUnifier.getLogichValue(D,i);return translator.translator.t(`${F}`)}):p=core.JsonUnifier.getLogichValue(h,i)||"",translator.translator.t(p)}),_=r.find(c=>c.end),$=r.find(c=>c.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(c=>!(c.operations&&(!c.dialogue||!c.choices)))?.goNextStep);let G=r.find(c=>c.labelToOpen),w=[];return r.forEach(c=>{c.operations&&(w=[...w,...c.operations]);}),{dialogue:k?{character:k,text:L}:L,end:_?.end,choices:$?.choices,glueEnabled:j,goNextStep:I,labelToOpen:G?.labelToOpen,operations:w}}}exports.animateOperation=_e;exports.canvasElementOperation=ze;exports.effectOperation=Me;exports.getConditionalStep=M;exports.getLogichValue=Ve;exports.getValueFromConditionalStatements=ye;exports.imageContainerOperation=Ae;exports.imageOperation=Ie;exports.loadAssets=Te;exports.narrationOperation=De;exports.setInitialStorageValue=Vi;exports.setStorageValue=xi;exports.soundOperation=We;exports.textOperation=Re;exports.videoOperation=Ee;
@@ -0,0 +1,127 @@
1
+ import { c as PixiVNJsonOperation, b as PixiVNJsonIfElse, d as PixiVNJsonOperationString, e as PixiVNJsonCanvasAnimate, f as PixiVNJsonUnknownEdit, g as PixiVNJsonCanvasRemove, h as PixiVNJsonCanvasEffect, i as PixiVNJsonCanvasImageContainerShow, j as PixiVNJsonImageContainerEdit, k as PixiVNJsonCanvasImageVideoShow, l as PixiVNJsonImageEdit, m as PixiVNJsonCanvasTextShow, n as PixiVNJsonTextEdit, o as PixiVNJsonVideoEdit, p as PixiVNJsonVideoPauseResume, q as PixiVNJsonNarration, r as PixiVNJsonSound, P as PixiVNJsonLabelStep, s as PixiVNJsonValueGet, t as PixiVNJsonArithmeticOperations, u as PixiVNJsonConditions, v as PixiVNJsonFunction, w as PixiVNJsonConditionalStatements, x as PixiVNJsonConditionalResultToCombine, y as PixiVNJsonOnlyStorageSet, a as PixiVNJsonValueSet } from './PixiVNJsonLabelStep-DgN7qF7j.cjs';
2
+ import { ImageSpriteMemory, VideoSpriteMemory, ContainerMemory, ContainerChild } from '@drincs/pixi-vn/canvas';
3
+ import { StepLabelPropsType } from '@drincs/pixi-vn/narration';
4
+ import { StorageElementType } from '@drincs/pixi-vn/storage';
5
+ import '@drincs/pixi-vn';
6
+ import '@drincs/pixi-vn/motion';
7
+ import 'pixi.js';
8
+
9
+ /**
10
+ * Loads or lazily-loads asset bundles/aliases described by a JSON operation.
11
+ * Supports both individual asset aliases (`type: "assets"`) and named bundles
12
+ * (`type: "bundle"`), each with `"load"` (blocking) or `"lazyload"` (background) variants.
13
+ *
14
+ * @param origin - The operation or conditional expression that describes what to load.
15
+ */
16
+ declare function loadAssets(origin: PixiVNJsonOperation | PixiVNJsonIfElse<PixiVNJsonOperation> | PixiVNJsonOperationString): Promise<void>;
17
+
18
+ /**
19
+ * Handles show, edit, and remove operations for {@link ImageSprite} canvas elements.
20
+ *
21
+ * @param operation - The image operation descriptor.
22
+ */
23
+ declare function imageOperation(operation: PixiVNJsonCanvasImageVideoShow | PixiVNJsonImageEdit | PixiVNJsonCanvasRemove): Promise<void>;
24
+ /**
25
+ * Handles show, edit, remove, pause, and resume operations for {@link VideoSprite} canvas elements.
26
+ *
27
+ * @param operation - The video operation descriptor.
28
+ */
29
+ declare function videoOperation(operation: PixiVNJsonCanvasRemove | PixiVNJsonCanvasImageVideoShow | PixiVNJsonVideoEdit | PixiVNJsonVideoPauseResume): Promise<void>;
30
+ /**
31
+ * Handles show, edit, and remove operations for {@link ImageContainer} canvas elements.
32
+ *
33
+ * @param operation - The image-container operation descriptor.
34
+ */
35
+ declare function imageContainerOperation(operation: PixiVNJsonCanvasRemove | PixiVNJsonCanvasImageContainerShow | PixiVNJsonImageContainerEdit): Promise<void>;
36
+ /**
37
+ * Handles show, edit, and remove operations for {@link Text} canvas elements.
38
+ * On show, the text content is run through the active {@link translator} before display.
39
+ *
40
+ * @param operation - The text operation descriptor.
41
+ */
42
+ declare function textOperation(operation: PixiVNJsonCanvasRemove | PixiVNJsonCanvasTextShow | PixiVNJsonTextEdit): Promise<void>;
43
+ /**
44
+ * Handles edit and remove operations for any canvas element whose specific type is unknown.
45
+ * Useful as a generic fallback when the element type is not determined at the call site.
46
+ *
47
+ * @param operation - The generic canvas-element operation descriptor.
48
+ */
49
+ declare function canvasElementOperation(operation: PixiVNJsonUnknownEdit<ImageSpriteMemory | VideoSpriteMemory | ContainerMemory<ContainerChild>> | PixiVNJsonCanvasRemove): Promise<void>;
50
+ /**
51
+ * Applies a visual effect (e.g. shake) to a canvas element.
52
+ *
53
+ * @param operation - The canvas effect descriptor.
54
+ */
55
+ declare function effectOperation(operation: PixiVNJsonCanvasEffect): Promise<void>;
56
+ /**
57
+ * Starts a keyframe animation or animation sequence on a canvas element.
58
+ *
59
+ * @param operation - The animate operation descriptor.
60
+ */
61
+ declare function animateOperation(operation: PixiVNJsonCanvasAnimate): void;
62
+
63
+ /**
64
+ * Handles narration-related operations such as requesting player input or
65
+ * clearing the current dialogue line.
66
+ *
67
+ * @param operation - The narration operation descriptor.
68
+ */
69
+ declare function narrationOperation(operation: PixiVNJsonNarration): void;
70
+
71
+ /**
72
+ * Handles all sound operations: play, stop, pause, resume, and property editing.
73
+ * Supports targeting individual sounds, channels, or all sounds at once.
74
+ *
75
+ * @param operation - The sound operation descriptor.
76
+ */
77
+ declare function soundOperation(operation: PixiVNJsonSound): void;
78
+
79
+ /**
80
+ * Sets a value in the appropriate storage layer (flag storage, persistent storage,
81
+ * temporary storage, or label parameters) as described by the operation.
82
+ *
83
+ * @param value - The storage-set operation descriptor.
84
+ * @param props - The current step label props (used to resolve dynamic values).
85
+ */
86
+ declare function setStorageValue(value: PixiVNJsonValueSet, props?: StepLabelPropsType): void;
87
+ /**
88
+ * Sets a default (initial) value in persistent or temporary storage.
89
+ * Unlike {@link setStorageValue}, this only applies to `"storage"` and `"tempstorage"` types
90
+ * and writes to `storage.default` so the value is used as a fallback.
91
+ *
92
+ * @param value - The initial storage-set operation descriptor.
93
+ * @param props - The current step label props (used to resolve dynamic values).
94
+ */
95
+ declare function setInitialStorageValue(value: PixiVNJsonOnlyStorageSet, props?: StepLabelPropsType): void;
96
+ /**
97
+ * Resolves a JSON logic value (storage get, arithmetic, condition, function, conditional statement)
98
+ * down to a plain TypeScript value of type `T`.
99
+ *
100
+ * This is the main evaluation entry-point: conditional statements are unwrapped first,
101
+ * then the remaining expression type is dispatched to the appropriate handler.
102
+ *
103
+ * @param value - The value or expression to resolve.
104
+ * @param props - The current step label props passed down through the call chain.
105
+ * @returns The resolved value, or `undefined` if the expression cannot be evaluated.
106
+ */
107
+ declare function getLogichValue<T = StorageElementType>(value: T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions | PixiVNJsonFunction | PixiVNJsonConditionalStatements<T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions>, props?: StepLabelPropsType): T | undefined;
108
+ /**
109
+ * Get the value from the conditional statements.
110
+ * @param statement is the conditional statements object
111
+ * @returns the value from the conditional statements
112
+ */
113
+ declare function getValueFromConditionalStatements<T>(statement: PixiVNJsonConditionalResultToCombine<T> | PixiVNJsonConditionalStatements<T> | T | undefined, props?: StepLabelPropsType): T | undefined;
114
+ /**
115
+ * Resolves the `conditionalStep` field of a label step and merges the result back
116
+ * into the step, recursively, until no more conditional overrides remain.
117
+ *
118
+ * Undefined properties on the resolved conditional step are deleted so they do not
119
+ * overwrite existing values on the base step.
120
+ *
121
+ * @param originalStep - The label step that may contain a `conditionalStep` expression.
122
+ * @param props - The current step label props used to evaluate the condition.
123
+ * @returns The fully resolved label step.
124
+ */
125
+ declare function getConditionalStep(originalStep: PixiVNJsonLabelStep, props?: StepLabelPropsType): PixiVNJsonLabelStep;
126
+
127
+ export { animateOperation, canvasElementOperation, effectOperation, getConditionalStep, getLogichValue, getValueFromConditionalStatements, imageContainerOperation, imageOperation, loadAssets, narrationOperation, setInitialStorageValue, setStorageValue, soundOperation, textOperation, videoOperation };
@@ -0,0 +1,127 @@
1
+ import { c as PixiVNJsonOperation, b as PixiVNJsonIfElse, d as PixiVNJsonOperationString, e as PixiVNJsonCanvasAnimate, f as PixiVNJsonUnknownEdit, g as PixiVNJsonCanvasRemove, h as PixiVNJsonCanvasEffect, i as PixiVNJsonCanvasImageContainerShow, j as PixiVNJsonImageContainerEdit, k as PixiVNJsonCanvasImageVideoShow, l as PixiVNJsonImageEdit, m as PixiVNJsonCanvasTextShow, n as PixiVNJsonTextEdit, o as PixiVNJsonVideoEdit, p as PixiVNJsonVideoPauseResume, q as PixiVNJsonNarration, r as PixiVNJsonSound, P as PixiVNJsonLabelStep, s as PixiVNJsonValueGet, t as PixiVNJsonArithmeticOperations, u as PixiVNJsonConditions, v as PixiVNJsonFunction, w as PixiVNJsonConditionalStatements, x as PixiVNJsonConditionalResultToCombine, y as PixiVNJsonOnlyStorageSet, a as PixiVNJsonValueSet } from './PixiVNJsonLabelStep-DgN7qF7j.js';
2
+ import { ImageSpriteMemory, VideoSpriteMemory, ContainerMemory, ContainerChild } from '@drincs/pixi-vn/canvas';
3
+ import { StepLabelPropsType } from '@drincs/pixi-vn/narration';
4
+ import { StorageElementType } from '@drincs/pixi-vn/storage';
5
+ import '@drincs/pixi-vn';
6
+ import '@drincs/pixi-vn/motion';
7
+ import 'pixi.js';
8
+
9
+ /**
10
+ * Loads or lazily-loads asset bundles/aliases described by a JSON operation.
11
+ * Supports both individual asset aliases (`type: "assets"`) and named bundles
12
+ * (`type: "bundle"`), each with `"load"` (blocking) or `"lazyload"` (background) variants.
13
+ *
14
+ * @param origin - The operation or conditional expression that describes what to load.
15
+ */
16
+ declare function loadAssets(origin: PixiVNJsonOperation | PixiVNJsonIfElse<PixiVNJsonOperation> | PixiVNJsonOperationString): Promise<void>;
17
+
18
+ /**
19
+ * Handles show, edit, and remove operations for {@link ImageSprite} canvas elements.
20
+ *
21
+ * @param operation - The image operation descriptor.
22
+ */
23
+ declare function imageOperation(operation: PixiVNJsonCanvasImageVideoShow | PixiVNJsonImageEdit | PixiVNJsonCanvasRemove): Promise<void>;
24
+ /**
25
+ * Handles show, edit, remove, pause, and resume operations for {@link VideoSprite} canvas elements.
26
+ *
27
+ * @param operation - The video operation descriptor.
28
+ */
29
+ declare function videoOperation(operation: PixiVNJsonCanvasRemove | PixiVNJsonCanvasImageVideoShow | PixiVNJsonVideoEdit | PixiVNJsonVideoPauseResume): Promise<void>;
30
+ /**
31
+ * Handles show, edit, and remove operations for {@link ImageContainer} canvas elements.
32
+ *
33
+ * @param operation - The image-container operation descriptor.
34
+ */
35
+ declare function imageContainerOperation(operation: PixiVNJsonCanvasRemove | PixiVNJsonCanvasImageContainerShow | PixiVNJsonImageContainerEdit): Promise<void>;
36
+ /**
37
+ * Handles show, edit, and remove operations for {@link Text} canvas elements.
38
+ * On show, the text content is run through the active {@link translator} before display.
39
+ *
40
+ * @param operation - The text operation descriptor.
41
+ */
42
+ declare function textOperation(operation: PixiVNJsonCanvasRemove | PixiVNJsonCanvasTextShow | PixiVNJsonTextEdit): Promise<void>;
43
+ /**
44
+ * Handles edit and remove operations for any canvas element whose specific type is unknown.
45
+ * Useful as a generic fallback when the element type is not determined at the call site.
46
+ *
47
+ * @param operation - The generic canvas-element operation descriptor.
48
+ */
49
+ declare function canvasElementOperation(operation: PixiVNJsonUnknownEdit<ImageSpriteMemory | VideoSpriteMemory | ContainerMemory<ContainerChild>> | PixiVNJsonCanvasRemove): Promise<void>;
50
+ /**
51
+ * Applies a visual effect (e.g. shake) to a canvas element.
52
+ *
53
+ * @param operation - The canvas effect descriptor.
54
+ */
55
+ declare function effectOperation(operation: PixiVNJsonCanvasEffect): Promise<void>;
56
+ /**
57
+ * Starts a keyframe animation or animation sequence on a canvas element.
58
+ *
59
+ * @param operation - The animate operation descriptor.
60
+ */
61
+ declare function animateOperation(operation: PixiVNJsonCanvasAnimate): void;
62
+
63
+ /**
64
+ * Handles narration-related operations such as requesting player input or
65
+ * clearing the current dialogue line.
66
+ *
67
+ * @param operation - The narration operation descriptor.
68
+ */
69
+ declare function narrationOperation(operation: PixiVNJsonNarration): void;
70
+
71
+ /**
72
+ * Handles all sound operations: play, stop, pause, resume, and property editing.
73
+ * Supports targeting individual sounds, channels, or all sounds at once.
74
+ *
75
+ * @param operation - The sound operation descriptor.
76
+ */
77
+ declare function soundOperation(operation: PixiVNJsonSound): void;
78
+
79
+ /**
80
+ * Sets a value in the appropriate storage layer (flag storage, persistent storage,
81
+ * temporary storage, or label parameters) as described by the operation.
82
+ *
83
+ * @param value - The storage-set operation descriptor.
84
+ * @param props - The current step label props (used to resolve dynamic values).
85
+ */
86
+ declare function setStorageValue(value: PixiVNJsonValueSet, props?: StepLabelPropsType): void;
87
+ /**
88
+ * Sets a default (initial) value in persistent or temporary storage.
89
+ * Unlike {@link setStorageValue}, this only applies to `"storage"` and `"tempstorage"` types
90
+ * and writes to `storage.default` so the value is used as a fallback.
91
+ *
92
+ * @param value - The initial storage-set operation descriptor.
93
+ * @param props - The current step label props (used to resolve dynamic values).
94
+ */
95
+ declare function setInitialStorageValue(value: PixiVNJsonOnlyStorageSet, props?: StepLabelPropsType): void;
96
+ /**
97
+ * Resolves a JSON logic value (storage get, arithmetic, condition, function, conditional statement)
98
+ * down to a plain TypeScript value of type `T`.
99
+ *
100
+ * This is the main evaluation entry-point: conditional statements are unwrapped first,
101
+ * then the remaining expression type is dispatched to the appropriate handler.
102
+ *
103
+ * @param value - The value or expression to resolve.
104
+ * @param props - The current step label props passed down through the call chain.
105
+ * @returns The resolved value, or `undefined` if the expression cannot be evaluated.
106
+ */
107
+ declare function getLogichValue<T = StorageElementType>(value: T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions | PixiVNJsonFunction | PixiVNJsonConditionalStatements<T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions>, props?: StepLabelPropsType): T | undefined;
108
+ /**
109
+ * Get the value from the conditional statements.
110
+ * @param statement is the conditional statements object
111
+ * @returns the value from the conditional statements
112
+ */
113
+ declare function getValueFromConditionalStatements<T>(statement: PixiVNJsonConditionalResultToCombine<T> | PixiVNJsonConditionalStatements<T> | T | undefined, props?: StepLabelPropsType): T | undefined;
114
+ /**
115
+ * Resolves the `conditionalStep` field of a label step and merges the result back
116
+ * into the step, recursively, until no more conditional overrides remain.
117
+ *
118
+ * Undefined properties on the resolved conditional step are deleted so they do not
119
+ * overwrite existing values on the base step.
120
+ *
121
+ * @param originalStep - The label step that may contain a `conditionalStep` expression.
122
+ * @param props - The current step label props used to evaluate the condition.
123
+ * @returns The fully resolved label step.
124
+ */
125
+ declare function getConditionalStep(originalStep: PixiVNJsonLabelStep, props?: StepLabelPropsType): PixiVNJsonLabelStep;
126
+
127
+ export { animateOperation, canvasElementOperation, effectOperation, getConditionalStep, getLogichValue, getValueFromConditionalStatements, imageContainerOperation, imageOperation, loadAssets, narrationOperation, setInitialStorageValue, setStorageValue, soundOperation, textOperation, videoOperation };
@@ -0,0 +1,3 @@
1
+ import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {Assets,canvas,ImageSprite,showImage,VideoSprite,showVideo,ImageContainer,showImageContainer,Text,showText,shakeEffect,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade}from'@drincs/pixi-vn/canvas';import {translator}from'@drincs/pixi-vn-json/translator';import {narration,NarrationManagerStatic}from'@drincs/pixi-vn/narration';import {sound}from'@drincs/pixi-vn/sound';import {PixiError,createExportableElement}from'@drincs/pixi-vn';import {storage}from'@drincs/pixi-vn/storage';var q=Object.defineProperty;var W=(e,i,t)=>i in e?q(e,i,{enumerable:true,configurable:true,writable:true,value:t}):e[i]=t;var d=(e,i,t)=>W(e,typeof i!="symbol"?i+"":i,t);async function Te(e){let i=JsonUnifier.getLogichValue(e,{});if(i)switch(i.type){case "assets":switch(i.operationType){case "load":await Assets.load(i.aliases);break;case "lazyload":Assets.backgroundLoad(i.aliases);break}break;case "bundle":switch(i.operationType){case "load":await Assets.loadBundle(i.aliases);break;case "lazyload":Assets.backgroundLoadBundle(i.aliases);break}break}}var o;(l=>(l.log=(r,...u)=>console.log(`[Pixi\u2019VN Json] ${r}`,...u),l.warn=(r,...u)=>console.warn(`[Pixi\u2019VN Json] ${r}`,...u),l.error=(r,...u)=>console.error(`[Pixi\u2019VN Json] ${r}`,...u),l.info=(r,...u)=>console.info(`[Pixi\u2019VN Json] ${r}`,...u)))(o||(o={}));async function v(e,i,t){switch(t.type){case "fade":await showWithFade(i.alias,e,t.props,t.priority);break;case "dissolve":await showWithDissolve(i.alias,e,t.props,t.priority);break;case "movein":case "moveout":await moveIn(i.alias,e,t.props,t.priority);break;case "zoomin":case "zoomout":await zoomIn(i.alias,e,t.props,t.priority);break;case "pushin":case "pushout":await pushIn(i.alias,e,t.props,t.priority);break}}function N(e){if(e.transition)switch(e.transition.type){case "fade":removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":pushOut(e.alias,e.transition.props,e.transition.priority);break}else canvas.remove(e.alias);}async function Ie(e){switch(e.operationType){case "show":if(e.transition){let i=new ImageSprite(e.props,e.url||e.alias);await v(i,e,e.transition);}else await showImage(e.alias,e.url,e.props);break;case "edit":{let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):o.error(`Image with alias ${e.alias} not found.`);break}case "remove":N(e);break}}async function Ee(e){switch(e.operationType){case "show":if(e.transition){let i=new VideoSprite(e.props,e.url||e.alias);await v(i,e,e.transition);}else await showVideo(e.alias,e.url,e.props);break;case "edit":{let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):o.error(`Video with alias ${e.alias} not found.`);break}case "remove":N(e);break;case "pause":case "resume":{let i=canvas.find(e.alias);i?i.paused=e.operationType==="pause":o.error(`Video with alias ${e.alias} not found.`);break}}}async function Ae(e){switch(e.operationType){case "show":if(e.transition){let i=new ImageContainer(e.props,e.urls);await v(i,e,e.transition);}else await showImageContainer(e.alias,e.urls,e.props);break;case "edit":{let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):o.error(`ImageContainer with alias ${e.alias} not found.`);break}case "remove":N(e);break}}async function Re(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator.t(e.text),e.transition){let i=new Text(e.props);await v(i,e,e.transition);}else showText(e.alias,e.text,e.props);break;case "edit":{let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):o.error(`Text with alias ${e.alias} not found.`);break}case "remove":N(e);break}}async function ze(e){switch(e.operationType){case "edit":try{let i=canvas.find(e.alias);i?e.props&&i.setMemory({...i.memory,...e.props}):o.error(`Canvas Element with alias ${e.alias} not found.`);}catch(i){o.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,i);}break;case "remove":N(e);break}}async function Me(e){e.type==="shake"&&await shakeEffect(e.alias,e.props,e.priority);}function _e(e){switch(e.type){case "animate":canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function De(e){switch(e.type){case "input":narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.dialogue=void 0;break}}function We(e){switch(e.operationType){case "play":e.url?sound.play(e.alias,e.url,e.props):sound.play(e.alias,e.props);break;case "stop":switch(e.type){case "sound":sound.stop(e.alias);break;case "all":sound.stopAll();break}break;case "pause":switch(e.type){case "sound":sound.pause(e.alias);break;case "channel":sound.findChannel(e.alias).pauseAll();break;case "all":sound.pauseAll();break}break;case "resume":switch(e.type){case "sound":sound.resume(e.alias);break;case "channel":sound.findChannel(e.alias).resumeAll();break;case "all":sound.resumeAll();break}break;case "edit":Object.entries(e.props).forEach(([i,t])=>{let a=sound.find(e.alias);a&&(i==="volume"?a.volume.value=t:a.paused=t);});break}}var J="___param___";var n=class n{static init(i){i.loadAssets&&(n._loadAssets=i.loadAssets),i.soundOperation&&(n._soundOperation=i.soundOperation),i.imageOperation&&(n._imageOperation=i.imageOperation),i.videoOperation&&(n._videoOperation=i.videoOperation),i.imageContainerOperation&&(n._imageContainerOperation=i.imageContainerOperation),i.textOperation&&(n._textOperation=i.textOperation),i.canvasElementOperation&&(n._canvasElementOperation=i.canvasElementOperation),i.setStorageValue&&(n._setStorageValue=i.setStorageValue),i.setInitialStorageValue&&(n._setInitialStorageValue=i.setInitialStorageValue),i.narrationOperation&&(n._narrationOperation=i.narrationOperation),i.effectOperation&&(n._effectOperation=i.effectOperation),i.animateOperation&&(n._animateOperation=i.animateOperation),i.getLogichValue&&(n._getLogichValue=i.getLogichValue),i.getConditionalStep&&(n._getConditionalStep=i.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 f=n;function R(e,i){if(i&&typeof i=="object"&&typeof e.functionName=="string"&&e.functionName in i){let t=i[e.functionName];if(typeof t=="function"){let a=e.args.map(l=>f.getLogichValue(l,i));return t(...a)}else o.warn(`getLogichValue function ${e.functionName} not found in props`);}}function z(e,i){let t=JsonUnifier.getLogichValue(e,i);return t&&typeof t=="object"&&"type"in t?JsonUnifier.getLogichValue(t,i):t}function xi(e,i={}){let t=z(e.value,i);switch(e.storageType){case "flagStorage":storage.setFlag(e.key,e.value);break;case "storage":storage.set(e.key,t);break;case "tempstorage":storage.setTempVariable(e.key,t);break;case "params":{let a=storage.get(`${J}${narration.openedLabels.length-1}`)||[];a.length>e.key&&(a[e.key]=t),storage.setTempVariable(`${J}${narration.openedLabels.length-1}`,a);break}}}function Vi(e,i={}){let t=z(e.value,i);switch(e.storageType){case "storage":case "tempstorage":storage.default={[e.key]:t};break}}function Ve(e,i={}){let t=ye(e,i);if(t&&typeof t=="object"&&"type"in t)switch(t.type){case "value":return Pe(t,i);case "arithmetic":case "arithmeticsingle":return ge(t,i);case "compare":case "valueCondition":case "union":return he(t,i);case "function":return R(t,i)}return t}function ge(e,i){let t=JsonUnifier.getLogichValue(e.leftValue,i);switch(e.type){case "arithmetic":{let a=JsonUnifier.getLogichValue(e.rightValue,i);switch(e.operator){case "*":return t*a;case "/":return t/a;case "+":return t+a;case "-":return t-a;case "%":return t%a;case "POW":return t**a;case "RANDOM":return narration.getRandomNumber(t,a)}}case "arithmeticsingle":switch(e.operator){case "INT":return Number(t);case "FLOOR":return Math.floor(t);}break}}function Pe(e,i){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,i);case "params":{let t=storage.get(`${J}${narration.openedLabels.length-1}`)||[];if(t&&t.length>e.key)return t[e.key];o.warn("getValue params not found");return}}return e}function he(e,i){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":{let t=JsonUnifier.getLogichValue(e.leftValue,i),a=JsonUnifier.getLogichValue(e.rightValue,i);switch(e.operator){case "==":return t===a;case "!=":return t!==a;case "<":return t<a;case "<=":return t<=a;case ">":return t>a;case ">=":return t>=a;case "CONTAINS":return t.toString().includes(a.toString())}break}case "valueCondition":return !!JsonUnifier.getLogichValue(e.value,i);case "union":return fe(e,i)}return !!e}function fe(e,i){if(e.unionType==="not")return !Ve(e.condition,i);let t=a=>JsonUnifier.getLogichValue(a,i)||false;return e.unionType==="and"?e.conditions.every(t):e.conditions.some(t)}function Ne(e,i){return Math.floor(Math.random()*(i-e+1)+e)}function ye(e,i={}){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return ve(e,i);case "ifelse":return JsonUnifier.getLogichValue(e.condition,i)?JsonUnifier.getLogichValue(e.then,i):JsonUnifier.getLogichValue(e.else,i);case "stepswitch":{let t=JsonUnifier.getLogichValue(e.elements,i)||[];if(t.length===0){o.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":{let a=Ne(0,t.length-1);return JsonUnifier.getLogichValue(t[a],i)}case "loop":{let a=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return a>t.length-1?(a=a%t.length,JsonUnifier.getLogichValue(t[a],i)):JsonUnifier.getLogichValue(t[a],i)}case "sequential":{let a,l=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end==="lastItem"&&(a=JsonUnifier.getLogichValue(t[t.length-1],i)),l>t.length-1?a:JsonUnifier.getLogichValue(t[l],i)}case "sequentialrandom":{let a=NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:e.nestedId,onceOnly:true});if(a===void 0&&e.end==="lastItem"){let l=NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!l?.usedRandomNumbers){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let r=l.usedRandomNumbers[`0-${t.length-1}`];return JsonUnifier.getLogichValue(t[r[r.length-1]],i)}if(a===void 0){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return JsonUnifier.getLogichValue(t[a],i)}}}}return e}function M(e,i={}){if(e.conditionalStep){let t=createExportableElement(JsonUnifier.getLogichValue(e.conditionalStep,i));if(t?.glueEnabled===void 0&&delete t?.glueEnabled,t?.goNextStep===void 0&&delete t?.goNextStep,t?.end===void 0&&delete t?.end,t?.choices===void 0&&delete t?.choices,t?.dialogue===void 0&&delete t?.dialogue,t?.labelToOpen===void 0&&delete t?.labelToOpen,t?.operations===void 0&&delete t?.operations,t){let a={...e,conditionalStep:void 0,...t};return M(a,i)}else narration.dialogGlue&&(narration.dialogGlue=false);}return e}function ve(e,i){let t=e.firstItem,a=(e.secondConditionalItem??[]).flatMap(r=>Array.isArray(r)?r.map(u=>JsonUnifier.getLogichValue(u,i)):[JsonUnifier.getLogichValue(r,i)]),l=t?[t,...a]:a;if(l.length===0){o.warn("combinateResult toCheck.length === 0");return}if(typeof l[0]=="string")return translator.t(l);if(typeof l[0]=="object"){let r=l,u,C=false,O=r.map((c,h)=>{c=M(c,i);let p=JsonUnifier.getLogichValue(c.dialogue,i)||"";return h===0?(u=JsonUnifier.getLogichValue(c.glueEnabled,i)||false,p):(typeof p=="object"&&"text"in p&&(p=`${p.character}: ${p.text}`),u===false&&C&&(p=`
2
+
3
+ ${p}`),p&&(C=true),u=JsonUnifier.getLogichValue(c.glueEnabled,i)||false,p)}),b=JsonUnifier.getLogichValue(O[0],i),k=typeof b=="object"&&"character"in b?b.character:void 0,L=O.flatMap(c=>{let h;c&&typeof c=="object"&&"text"in c?h=c.text:h=c;let p;return Array.isArray(h)?p=h.map(D=>{let F=JsonUnifier.getLogichValue(D,i);return translator.t(`${F}`)}):p=JsonUnifier.getLogichValue(h,i)||"",translator.t(p)}),_=r.find(c=>c.end),$=r.find(c=>c.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(c=>!(c.operations&&(!c.dialogue||!c.choices)))?.goNextStep);let G=r.find(c=>c.labelToOpen),w=[];return r.forEach(c=>{c.operations&&(w=[...w,...c.operations]);}),{dialogue:k?{character:k,text:L}:L,end:_?.end,choices:$?.choices,glueEnabled:j,goNextStep:I,labelToOpen:G?.labelToOpen,operations:w}}}export{_e as animateOperation,ze as canvasElementOperation,Me as effectOperation,M as getConditionalStep,Ve as getLogichValue,ye as getValueFromConditionalStatements,Ae as imageContainerOperation,Ie as imageOperation,Te as loadAssets,De as narrationOperation,Vi as setInitialStorageValue,xi as setStorageValue,We as soundOperation,Re as textOperation,Ee as videoOperation};
package/dist/core.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var pixiVn=require('@drincs/pixi-vn');var d=Object.defineProperty;var P=(s,i,p)=>i in s?d(s,i,{enumerable:true,configurable:true,writable:true,value:p}):s[i]=p;var o=(s,i,p)=>P(s,typeof i!="symbol"?i+"":i,p);var t;(c=>(c.log=(n,...r)=>console.log(`[Pixi\u2019VN Json] ${n}`,...r),c.warn=(n,...r)=>console.warn(`[Pixi\u2019VN Json] ${n}`,...r),c.error=(n,...r)=>console.error(`[Pixi\u2019VN Json] ${n}`,...r),c.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 textOperation(){return e._textOperation}static get imageContainerOperation(){return e._imageContainerOperation}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 x=e;exports.JsonUnifier=x;
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;