@drincs/pixi-vn-json 1.13.0 → 1.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PixiVNJsonLabelStep-dVwPLFMT.d.cts → PixiVNJsonLabelStep-B335RwgE.d.cts} +13 -5
- package/dist/{PixiVNJsonLabelStep-dVwPLFMT.d.ts → PixiVNJsonLabelStep-B335RwgE.d.ts} +13 -5
- package/dist/{PixiVNJsonLabelStep-DgN7qF7j.d.cts → PixiVNJsonLabelStep-C-9WKwTo.d.cts} +12 -4
- package/dist/{PixiVNJsonLabelStep-DgN7qF7j.d.ts → PixiVNJsonLabelStep-C-9WKwTo.d.ts} +12 -4
- package/dist/actions.cjs +2 -2
- package/dist/actions.d.cts +1 -1
- package/dist/actions.d.ts +1 -1
- package/dist/actions.mjs +2 -2
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +226 -38
- package/dist/index.d.ts +226 -38
- package/dist/index.mjs +2 -2
- package/dist/interpreter.cjs +1 -1
- package/dist/interpreter.d.cts +1 -1
- package/dist/interpreter.d.ts +1 -1
- package/dist/interpreter.mjs +1 -1
- package/dist/schema.d.cts +2 -2
- package/dist/schema.d.ts +2 -2
- package/dist/translator.d.cts +12 -4
- package/dist/translator.d.ts +12 -4
- package/package.json +6 -4
|
@@ -277,13 +277,14 @@ interface PixiVNJsonArithmeticOperationsArithmetic {
|
|
|
277
277
|
* Operator of the arithmetic operation:
|
|
278
278
|
* - `"*"` multiplication
|
|
279
279
|
* - `"/"` division
|
|
280
|
-
* - `"+"` addition
|
|
281
|
-
* - `"-"` subtraction
|
|
280
|
+
* - `"+"` addition (concatenation for strings and arrays)
|
|
281
|
+
* - `"-"` subtraction (removal of elements for arrays)
|
|
282
282
|
* - `"%"` modulo
|
|
283
283
|
* - `"POW"` exponentiation
|
|
284
284
|
* - `"RANDOM"` random integer between leftValue and rightValue (inclusive)
|
|
285
|
+
* - `"INTERSECTION"` intersection of two arrays (only elements present in both arrays are included in the result)
|
|
285
286
|
*/
|
|
286
|
-
operator: "*" | "/" | "+" | "-" | "%" | "POW" | "RANDOM";
|
|
287
|
+
operator: "*" | "/" | "+" | "-" | "%" | "POW" | "RANDOM" | "INTERSECTION";
|
|
287
288
|
}
|
|
288
289
|
/**
|
|
289
290
|
* Unary arithmetic operation applied to a single value (e.g. INT, FLOOR, FLOAT).
|
|
@@ -346,7 +347,7 @@ type PixiVNJsonUnionCondition = PixiVNJsonUnionConditionAndOr | PixiVNJsonUnionC
|
|
|
346
347
|
* - `"<="` less than or equal
|
|
347
348
|
* - `">"` greater than
|
|
348
349
|
* - `">="` greater than or equal
|
|
349
|
-
* - `"CONTAINS"` checks whether the left string/array contains the right value
|
|
350
|
+
* - `"CONTAINS"` checks whether the left string/array contains the right value, if left and right are arrays, checks if all items in right are included in left
|
|
350
351
|
*/
|
|
351
352
|
type PixiVNJsonComparationOperatorsType = "==" | "!=" | "<" | "<=" | ">" | ">=" | "CONTAINS";
|
|
352
353
|
/**
|
|
@@ -388,6 +389,13 @@ interface PixiVNJsonIfElse<Then> {
|
|
|
388
389
|
type: "ifelse";
|
|
389
390
|
/**
|
|
390
391
|
* The list of conditions to be checked.
|
|
392
|
+
*
|
|
393
|
+
* if is a {@link StorageElementType} or a {@link PixiVNJsonValueGet}:
|
|
394
|
+
* - if is a array or object, the condition is true if not empty
|
|
395
|
+
* - if is a string, the condition is true if not empty
|
|
396
|
+
* - if is a number, the condition is true if not zero
|
|
397
|
+
* - if is a boolean, the condition is true if true
|
|
398
|
+
* - if is null or undefined, the condition is false
|
|
391
399
|
*/
|
|
392
400
|
condition: PixiVNJsonConditions;
|
|
393
401
|
/**
|
|
@@ -988,4 +996,4 @@ type PixiVNJsonLabelStep = {
|
|
|
988
996
|
conditionalStep?: PixiVNJsonConditionalStatements<PixiVNJsonLabelStep | PixiVNJsonLabelStep[]>;
|
|
989
997
|
};
|
|
990
998
|
|
|
991
|
-
export type { PixiVNJsonArithmeticOperationsArithmeticSingle as A, PixiVNJsonCanvas as B, PixiVNJsonCanvasEdit as C, PixiVNJsonCanvasShow as D, PixiVNJsonChoice as E, PixiVNJsonChoiceGet as F, PixiVNJsonChoices as G, PixiVNJsonComparation as H, PixiVNJsonComparationOperatorsType as I, PixiVNJsonConditionalOperation as J, PixiVNJsonConditionalResultToCombine as K, PixiVNJsonDialog as L, PixiVNJsonDialogText as M,
|
|
999
|
+
export type { PixiVNJsonStepSwitchElementType as $, PixiVNJsonArithmeticOperationsArithmeticSingle as A, PixiVNJsonCanvas as B, PixiVNJsonCanvasEdit as C, PixiVNJsonCanvasShow as D, PixiVNJsonChoice as E, PixiVNJsonChoiceGet as F, PixiVNJsonChoices as G, PixiVNJsonComparation as H, PixiVNJsonComparationOperatorsType 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, PixiVNJsonAnimateBase as x, PixiVNJsonAnimateSequence as y, PixiVNJsonArithmeticOperationsArithmetic as z };
|
|
@@ -277,13 +277,14 @@ interface PixiVNJsonArithmeticOperationsArithmetic {
|
|
|
277
277
|
* Operator of the arithmetic operation:
|
|
278
278
|
* - `"*"` multiplication
|
|
279
279
|
* - `"/"` division
|
|
280
|
-
* - `"+"` addition
|
|
281
|
-
* - `"-"` subtraction
|
|
280
|
+
* - `"+"` addition (concatenation for strings and arrays)
|
|
281
|
+
* - `"-"` subtraction (removal of elements for arrays)
|
|
282
282
|
* - `"%"` modulo
|
|
283
283
|
* - `"POW"` exponentiation
|
|
284
284
|
* - `"RANDOM"` random integer between leftValue and rightValue (inclusive)
|
|
285
|
+
* - `"INTERSECTION"` intersection of two arrays (only elements present in both arrays are included in the result)
|
|
285
286
|
*/
|
|
286
|
-
operator: "*" | "/" | "+" | "-" | "%" | "POW" | "RANDOM";
|
|
287
|
+
operator: "*" | "/" | "+" | "-" | "%" | "POW" | "RANDOM" | "INTERSECTION";
|
|
287
288
|
}
|
|
288
289
|
/**
|
|
289
290
|
* Unary arithmetic operation applied to a single value (e.g. INT, FLOOR, FLOAT).
|
|
@@ -346,7 +347,7 @@ type PixiVNJsonUnionCondition = PixiVNJsonUnionConditionAndOr | PixiVNJsonUnionC
|
|
|
346
347
|
* - `"<="` less than or equal
|
|
347
348
|
* - `">"` greater than
|
|
348
349
|
* - `">="` greater than or equal
|
|
349
|
-
* - `"CONTAINS"` checks whether the left string/array contains the right value
|
|
350
|
+
* - `"CONTAINS"` checks whether the left string/array contains the right value, if left and right are arrays, checks if all items in right are included in left
|
|
350
351
|
*/
|
|
351
352
|
type PixiVNJsonComparationOperatorsType = "==" | "!=" | "<" | "<=" | ">" | ">=" | "CONTAINS";
|
|
352
353
|
/**
|
|
@@ -388,6 +389,13 @@ interface PixiVNJsonIfElse<Then> {
|
|
|
388
389
|
type: "ifelse";
|
|
389
390
|
/**
|
|
390
391
|
* The list of conditions to be checked.
|
|
392
|
+
*
|
|
393
|
+
* if is a {@link StorageElementType} or a {@link PixiVNJsonValueGet}:
|
|
394
|
+
* - if is a array or object, the condition is true if not empty
|
|
395
|
+
* - if is a string, the condition is true if not empty
|
|
396
|
+
* - if is a number, the condition is true if not zero
|
|
397
|
+
* - if is a boolean, the condition is true if true
|
|
398
|
+
* - if is null or undefined, the condition is false
|
|
391
399
|
*/
|
|
392
400
|
condition: PixiVNJsonConditions;
|
|
393
401
|
/**
|
|
@@ -988,4 +996,4 @@ type PixiVNJsonLabelStep = {
|
|
|
988
996
|
conditionalStep?: PixiVNJsonConditionalStatements<PixiVNJsonLabelStep | PixiVNJsonLabelStep[]>;
|
|
989
997
|
};
|
|
990
998
|
|
|
991
|
-
export type { PixiVNJsonArithmeticOperationsArithmeticSingle as A, PixiVNJsonCanvas as B, PixiVNJsonCanvasEdit as C, PixiVNJsonCanvasShow as D, PixiVNJsonChoice as E, PixiVNJsonChoiceGet as F, PixiVNJsonChoices as G, PixiVNJsonComparation as H, PixiVNJsonComparationOperatorsType as I, PixiVNJsonConditionalOperation as J, PixiVNJsonConditionalResultToCombine as K, PixiVNJsonDialog as L, PixiVNJsonDialogText as M,
|
|
999
|
+
export type { PixiVNJsonStepSwitchElementType as $, PixiVNJsonArithmeticOperationsArithmeticSingle as A, PixiVNJsonCanvas as B, PixiVNJsonCanvasEdit as C, PixiVNJsonCanvasShow as D, PixiVNJsonChoice as E, PixiVNJsonChoiceGet as F, PixiVNJsonChoices as G, PixiVNJsonComparation as H, PixiVNJsonComparationOperatorsType 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, PixiVNJsonAnimateBase as x, PixiVNJsonAnimateSequence as y, PixiVNJsonArithmeticOperationsArithmetic as z };
|
|
@@ -277,13 +277,14 @@ interface PixiVNJsonArithmeticOperationsArithmetic {
|
|
|
277
277
|
* Operator of the arithmetic operation:
|
|
278
278
|
* - `"*"` multiplication
|
|
279
279
|
* - `"/"` division
|
|
280
|
-
* - `"+"` addition
|
|
281
|
-
* - `"-"` subtraction
|
|
280
|
+
* - `"+"` addition (concatenation for strings and arrays)
|
|
281
|
+
* - `"-"` subtraction (removal of elements for arrays)
|
|
282
282
|
* - `"%"` modulo
|
|
283
283
|
* - `"POW"` exponentiation
|
|
284
284
|
* - `"RANDOM"` random integer between leftValue and rightValue (inclusive)
|
|
285
|
+
* - `"INTERSECTION"` intersection of two arrays (only elements present in both arrays are included in the result)
|
|
285
286
|
*/
|
|
286
|
-
operator: "*" | "/" | "+" | "-" | "%" | "POW" | "RANDOM";
|
|
287
|
+
operator: "*" | "/" | "+" | "-" | "%" | "POW" | "RANDOM" | "INTERSECTION";
|
|
287
288
|
}
|
|
288
289
|
/**
|
|
289
290
|
* Unary arithmetic operation applied to a single value (e.g. INT, FLOOR, FLOAT).
|
|
@@ -346,7 +347,7 @@ type PixiVNJsonUnionCondition = PixiVNJsonUnionConditionAndOr | PixiVNJsonUnionC
|
|
|
346
347
|
* - `"<="` less than or equal
|
|
347
348
|
* - `">"` greater than
|
|
348
349
|
* - `">="` greater than or equal
|
|
349
|
-
* - `"CONTAINS"` checks whether the left string/array contains the right value
|
|
350
|
+
* - `"CONTAINS"` checks whether the left string/array contains the right value, if left and right are arrays, checks if all items in right are included in left
|
|
350
351
|
*/
|
|
351
352
|
type PixiVNJsonComparationOperatorsType = "==" | "!=" | "<" | "<=" | ">" | ">=" | "CONTAINS";
|
|
352
353
|
/**
|
|
@@ -388,6 +389,13 @@ interface PixiVNJsonIfElse<Then> {
|
|
|
388
389
|
type: "ifelse";
|
|
389
390
|
/**
|
|
390
391
|
* The list of conditions to be checked.
|
|
392
|
+
*
|
|
393
|
+
* if is a {@link StorageElementType} or a {@link PixiVNJsonValueGet}:
|
|
394
|
+
* - if is a array or object, the condition is true if not empty
|
|
395
|
+
* - if is a string, the condition is true if not empty
|
|
396
|
+
* - if is a number, the condition is true if not zero
|
|
397
|
+
* - if is a boolean, the condition is true if true
|
|
398
|
+
* - if is null or undefined, the condition is false
|
|
391
399
|
*/
|
|
392
400
|
condition: PixiVNJsonConditions;
|
|
393
401
|
/**
|
|
@@ -277,13 +277,14 @@ interface PixiVNJsonArithmeticOperationsArithmetic {
|
|
|
277
277
|
* Operator of the arithmetic operation:
|
|
278
278
|
* - `"*"` multiplication
|
|
279
279
|
* - `"/"` division
|
|
280
|
-
* - `"+"` addition
|
|
281
|
-
* - `"-"` subtraction
|
|
280
|
+
* - `"+"` addition (concatenation for strings and arrays)
|
|
281
|
+
* - `"-"` subtraction (removal of elements for arrays)
|
|
282
282
|
* - `"%"` modulo
|
|
283
283
|
* - `"POW"` exponentiation
|
|
284
284
|
* - `"RANDOM"` random integer between leftValue and rightValue (inclusive)
|
|
285
|
+
* - `"INTERSECTION"` intersection of two arrays (only elements present in both arrays are included in the result)
|
|
285
286
|
*/
|
|
286
|
-
operator: "*" | "/" | "+" | "-" | "%" | "POW" | "RANDOM";
|
|
287
|
+
operator: "*" | "/" | "+" | "-" | "%" | "POW" | "RANDOM" | "INTERSECTION";
|
|
287
288
|
}
|
|
288
289
|
/**
|
|
289
290
|
* Unary arithmetic operation applied to a single value (e.g. INT, FLOOR, FLOAT).
|
|
@@ -346,7 +347,7 @@ type PixiVNJsonUnionCondition = PixiVNJsonUnionConditionAndOr | PixiVNJsonUnionC
|
|
|
346
347
|
* - `"<="` less than or equal
|
|
347
348
|
* - `">"` greater than
|
|
348
349
|
* - `">="` greater than or equal
|
|
349
|
-
* - `"CONTAINS"` checks whether the left string/array contains the right value
|
|
350
|
+
* - `"CONTAINS"` checks whether the left string/array contains the right value, if left and right are arrays, checks if all items in right are included in left
|
|
350
351
|
*/
|
|
351
352
|
type PixiVNJsonComparationOperatorsType = "==" | "!=" | "<" | "<=" | ">" | ">=" | "CONTAINS";
|
|
352
353
|
/**
|
|
@@ -388,6 +389,13 @@ interface PixiVNJsonIfElse<Then> {
|
|
|
388
389
|
type: "ifelse";
|
|
389
390
|
/**
|
|
390
391
|
* The list of conditions to be checked.
|
|
392
|
+
*
|
|
393
|
+
* if is a {@link StorageElementType} or a {@link PixiVNJsonValueGet}:
|
|
394
|
+
* - if is a array or object, the condition is true if not empty
|
|
395
|
+
* - if is a string, the condition is true if not empty
|
|
396
|
+
* - if is a number, the condition is true if not zero
|
|
397
|
+
* - if is a boolean, the condition is true if true
|
|
398
|
+
* - if is null or undefined, the condition is false
|
|
391
399
|
*/
|
|
392
400
|
condition: PixiVNJsonConditions;
|
|
393
401
|
/**
|
package/dist/actions.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';var core=require('@drincs/pixi-vn-json/core'),canvas=require('@drincs/pixi-vn/canvas'),translator=require('@drincs/pixi-vn-json/translator'),narration=require('@drincs/pixi-vn/narration'),sound=require('@drincs/pixi-vn/sound'),pixiVn=require('@drincs/pixi-vn'),storage=require('@drincs/pixi-vn/storage');var q=Object.defineProperty;var W=(e,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=`
|
|
1
|
+
'use strict';var core=require('@drincs/pixi-vn-json/core'),canvas=require('@drincs/pixi-vn/canvas'),translator=require('@drincs/pixi-vn-json/translator'),narration=require('@drincs/pixi-vn/narration'),sound=require('@drincs/pixi-vn/sound'),pixiVn=require('@drincs/pixi-vn'),storage=require('@drincs/pixi-vn/storage');var q=Object.defineProperty;var W=(e,t,i)=>t in e?q(e,t,{enumerable:true,configurable:true,writable:true,value:i}):e[t]=i;var u=(e,t,i)=>W(e,typeof t!="symbol"?t+"":t,i);async function Te(e){let t=core.JsonUnifier.getLogichValue(e,{});if(t)switch(t.type){case "assets":switch(t.operationType){case "load":await canvas.Assets.load(t.aliases);break;case "lazyload":canvas.Assets.backgroundLoad(t.aliases);break}break;case "bundle":switch(t.operationType){case "load":await canvas.Assets.loadBundle(t.aliases);break;case "lazyload":canvas.Assets.backgroundLoadBundle(t.aliases);break}break}}var o;(s=>(s.log=(c,...p)=>console.log(`[Pixi\u2019VN Json] ${c}`,...p),s.warn=(c,...p)=>console.warn(`[Pixi\u2019VN Json] ${c}`,...p),s.error=(c,...p)=>console.error(`[Pixi\u2019VN Json] ${c}`,...p),s.info=(c,...p)=>console.info(`[Pixi\u2019VN Json] ${c}`,...p)))(o||(o={}));async function v(e,t,i){switch(i.type){case "fade":await canvas.showWithFade(t.alias,e,i.props,i.priority);break;case "dissolve":await canvas.showWithDissolve(t.alias,e,i.props,i.priority);break;case "movein":case "moveout":await canvas.moveIn(t.alias,e,i.props,i.priority);break;case "zoomin":case "zoomout":await canvas.zoomIn(t.alias,e,i.props,i.priority);break;case "pushin":case "pushout":await canvas.pushIn(t.alias,e,i.props,i.priority);break}}function P(e){if(e.transition)switch(e.transition.type){case "fade":canvas.removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":canvas.removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":canvas.moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":canvas.zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":canvas.pushOut(e.alias,e.transition.props,e.transition.priority);break}else canvas.canvas.remove(e.alias);}async function Le(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.ImageSprite(e.props,e.url||e.alias);await v(t,e,e.transition);}else await canvas.showImage(e.alias,e.url,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Image with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function Ie(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.VideoSprite(e.props,e.url||e.alias);await v(t,e,e.transition);}else await canvas.showVideo(e.alias,e.url,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Video with alias ${e.alias} not found.`);break}case "remove":P(e);break;case "pause":case "resume":{let t=canvas.canvas.find(e.alias);t?t.paused=e.operationType==="pause":o.error(`Video with alias ${e.alias} not found.`);break}}}async function Ee(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.ImageContainer(e.props,e.urls);await v(t,e,e.transition);}else await canvas.showImageContainer(e.alias,e.urls,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`ImageContainer with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function Re(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator.translator.t(e.text),e.transition){let t=new canvas.Text(e.props);await v(t,e,e.transition);}else canvas.showText(e.alias,e.text,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Text with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function ze(e){switch(e.operationType){case "edit":try{let t=canvas.canvas.find(e.alias);t?e.props&&t.setMemory({...t.memory,...e.props}):o.error(`Canvas Element with alias ${e.alias} not found.`);}catch(t){o.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,t);}break;case "remove":P(e);break}}async function Me(e){e.type==="shake"&&await canvas.shakeEffect(e.alias,e.props,e.priority);}function _e(e){switch(e.type){case "animate":canvas.canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function De(e){switch(e.type){case "input":narration.narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.narration.dialogue=void 0;break}}function We(e){switch(e.operationType){case "play":e.url?sound.sound.play(e.alias,e.url,e.props):sound.sound.play(e.alias,e.props);break;case "stop":switch(e.type){case "sound":sound.sound.stop(e.alias);break;case "all":sound.sound.stopAll();break}break;case "pause":switch(e.type){case "sound":sound.sound.pause(e.alias);break;case "channel":sound.sound.findChannel(e.alias).pauseAll();break;case "all":sound.sound.pauseAll();break}break;case "resume":switch(e.type){case "sound":sound.sound.resume(e.alias);break;case "channel":sound.sound.findChannel(e.alias).resumeAll();break;case "all":sound.sound.resumeAll();break}break;case "edit":Object.entries(e.props).forEach(([t,i])=>{let a=sound.sound.find(e.alias);a&&(t==="volume"?a.volume.value=i:a.paused=i);});break}}var J="___param___";var n=class n{static init(t){t.loadAssets&&(n._loadAssets=t.loadAssets),t.soundOperation&&(n._soundOperation=t.soundOperation),t.imageOperation&&(n._imageOperation=t.imageOperation),t.videoOperation&&(n._videoOperation=t.videoOperation),t.imageContainerOperation&&(n._imageContainerOperation=t.imageContainerOperation),t.textOperation&&(n._textOperation=t.textOperation),t.canvasElementOperation&&(n._canvasElementOperation=t.canvasElementOperation),t.setStorageValue&&(n._setStorageValue=t.setStorageValue),t.setInitialStorageValue&&(n._setInitialStorageValue=t.setInitialStorageValue),t.narrationOperation&&(n._narrationOperation=t.narrationOperation),t.effectOperation&&(n._effectOperation=t.effectOperation),t.animateOperation&&(n._animateOperation=t.animateOperation),t.getLogichValue&&(n._getLogichValue=t.getLogichValue),t.getConditionalStep&&(n._getConditionalStep=t.getConditionalStep);}static get loadAssets(){return n._loadAssets}static get soundOperation(){return n._soundOperation}static get imageOperation(){return n._imageOperation}static get videoOperation(){return n._videoOperation}static get imageContainerOperation(){return n._imageContainerOperation}static get textOperation(){return n._textOperation}static get canvasElementOperation(){return n._canvasElementOperation}static get setStorageValue(){return n._setStorageValue}static get setInitialStorageValue(){return n._setInitialStorageValue}static get narrationOperation(){return n._narrationOperation}static get effectOperation(){return n._effectOperation}static get animateOperation(){return n._animateOperation}static get getLogichValue(){return n._getLogichValue}static get getConditionalStep(){return n._getConditionalStep}};u(n,"_loadAssets",()=>{}),u(n,"_soundOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_imageOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_videoOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_imageContainerOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_textOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_canvasElementOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_setStorageValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_setInitialStorageValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_narrationOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_effectOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_animateOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_getLogichValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_getConditionalStep",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var h=n;function R(e,t){if(t&&typeof t=="object"&&typeof e.functionName=="string"&&e.functionName in t){let i=t[e.functionName];if(typeof i=="function"){let a=e.args.map(s=>h.getLogichValue(s,t));return i(...a)}else o.warn(`getLogichValue function ${e.functionName} not found in props`);}}function z(e,t){let i=core.JsonUnifier.getLogichValue(e,t);return i&&typeof i=="object"&&"type"in i?core.JsonUnifier.getLogichValue(i,t):i}function gi(e,t={}){let i=z(e.value,t);switch(e.storageType){case "flagStorage":storage.storage.setFlag(e.key,e.value);break;case "storage":storage.storage.set(e.key,i);break;case "tempstorage":storage.storage.setTempVariable(e.key,i);break;case "params":{let a=storage.storage.get(`${J}${narration.narration.openedLabels.length-1}`)||[];a.length>e.key&&(a[e.key]=i),storage.storage.setTempVariable(`${J}${narration.narration.openedLabels.length-1}`,a);break}}}function xi(e,t={}){let i=z(e.value,t);switch(e.storageType){case "storage":case "tempstorage":storage.storage.default={[e.key]:i};break}}function xe(e,t={}){let i=Ne(e,t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return fe(i,t);case "arithmetic":case "arithmeticsingle":return Ve(i,t);case "compare":case "union":return ye(i,t);case "function":return R(i,t)}return i}function Ve(e,t){let i=core.JsonUnifier.getLogichValue(e.leftValue,t);switch(e.type){case "arithmetic":{let a=core.JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "*":return i*a;case "/":return i/a;case "+":return typeof i=="string"||typeof a=="string"?`${i}${a}`:Array.isArray(i)&&Array.isArray(a)?[...i,...a]:Array.isArray(i)?[...i,a]:Array.isArray(a)?[i,...a]:i+a;case "-":if(Array.isArray(i)&&Array.isArray(a))return i.filter(s=>!a.includes(s));if(Array.isArray(i))return i.filter(s=>s!==a);if(Array.isArray(a)){o.warn("getValueFromArithmeticOperations cannot subtract array from non-array");return}return i-a;case "%":return i%a;case "POW":return i**a;case "RANDOM":return narration.narration.getRandomNumber(i,a);case "INTERSECTION":if(Array.isArray(i)&&Array.isArray(a))return i.filter(s=>a.includes(s));o.warn("getValueFromArithmeticOperations cannot intersect non-array values");return;default:o.warn("getValueFromArithmeticOperations unknown operator",e);return}}case "arithmeticsingle":switch(e.operator){case "INT":return Number(i);case "FLOOR":return Math.floor(i);}break}}function fe(e,t){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return e.key==="_input_value_"?narration.narration.inputValue:storage.storage.get(e.key);case "flagStorage":return storage.storage.getFlag(e.key);case "label":return narration.narration.getTimesLabelOpened(e.label);case "choice":return narration.narration.getTimesChoiceMade(e.index);case "logic":return core.JsonUnifier.getLogichValue(e.operation,t);case "params":{let i=storage.storage.get(`${J}${narration.narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];o.warn("getValue params not found");return}}return e}function ye(e,t){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":{let i=core.JsonUnifier.getLogichValue(e.leftValue,t),a=core.JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "==":return Array.isArray(i)&&Array.isArray(a)?i.length===a.length&&i.every(s=>a.includes(s)):i===a;case "!=":return Array.isArray(i)&&Array.isArray(a)?i.length!==a.length||!i.every(s=>a.includes(s)):i!==a;case "<":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)<0:Array.isArray(i)&&Array.isArray(a)?i.length<a.length:i<a;case "<=":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)<=0:Array.isArray(i)&&Array.isArray(a)?i.length<=a.length:i<=a;case ">":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)>0:Array.isArray(i)&&Array.isArray(a)?i.length>a.length:i>a;case ">=":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)>=0:Array.isArray(i)&&Array.isArray(a)?i.length>=a.length:i>=a;case "CONTAINS":return Array.isArray(i)&&Array.isArray(a)?a.every(s=>i.includes(s)):Array.isArray(i)?i.includes(a):i.toString().includes(a.toString())}break}case "value":{let i=core.JsonUnifier.getLogichValue(e,t);return Array.isArray(i)?i.length>0:i&&typeof i=="object"?Object.keys(i).length>0:!!i}case "union":return he(e,t)}return !!e}function he(e,t){if(e.unionType==="not"){let a=xe(e.condition,t);return Array.isArray(a)?a.length===0:a&&typeof a=="object"?Object.keys(a).length===0:!a}let i=a=>core.JsonUnifier.getLogichValue(a,t)||false;return e.unionType==="and"?e.conditions.every(i):e.conditions.some(i)}function Pe(e,t){return Math.floor(Math.random()*(t-e+1)+e)}function Ne(e,t={}){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return ve(e,t);case "ifelse":return core.JsonUnifier.getLogichValue(e.condition,t)?core.JsonUnifier.getLogichValue(e.then,t):core.JsonUnifier.getLogichValue(e.else,t);case "stepswitch":{let i=core.JsonUnifier.getLogichValue(e.elements,t)||[];if(i.length===0){o.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":{let a=Pe(0,i.length-1);return core.JsonUnifier.getLogichValue(i[a],t)}case "loop":{let a=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return a>i.length-1?(a=a%i.length,core.JsonUnifier.getLogichValue(i[a],t)):core.JsonUnifier.getLogichValue(i[a],t)}case "sequential":{let a,s=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end==="lastItem"&&(a=core.JsonUnifier.getLogichValue(i[i.length-1],t)),s>i.length-1?a:core.JsonUnifier.getLogichValue(i[s],t)}case "sequentialrandom":{let a=narration.NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:e.nestedId,onceOnly:true});if(a===void 0&&e.end==="lastItem"){let s=narration.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!s?.usedRandomNumbers){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let c=s.usedRandomNumbers[`0-${i.length-1}`];return core.JsonUnifier.getLogichValue(i[c[c.length-1]],t)}if(a===void 0){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return core.JsonUnifier.getLogichValue(i[a],t)}}}}return e}function M(e,t={}){if(e.conditionalStep){let i=pixiVn.createExportableElement(core.JsonUnifier.getLogichValue(e.conditionalStep,t));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operations===void 0&&delete i?.operations,i){let a={...e,conditionalStep:void 0,...i};return M(a,t)}else narration.narration.dialogGlue&&(narration.narration.dialogGlue=false);}return e}function ve(e,t){let i=e.firstItem,a=(e.secondConditionalItem??[]).flatMap(c=>Array.isArray(c)?c.map(p=>core.JsonUnifier.getLogichValue(p,t)):[core.JsonUnifier.getLogichValue(c,t)]),s=i?[i,...a]:a;if(s.length===0){o.warn("combinateResult toCheck.length === 0");return}if(typeof s[0]=="string")return translator.translator.t(s);if(typeof s[0]=="object"){let c=s,p,C=false,O=c.map((l,y)=>{l=M(l,t);let d=core.JsonUnifier.getLogichValue(l.dialogue,t)||"";return y===0?(p=core.JsonUnifier.getLogichValue(l.glueEnabled,t)||false,d):(typeof d=="object"&&"text"in d&&(d=`${d.character}: ${d.text}`),p===false&&C&&(d=`
|
|
2
2
|
|
|
3
|
-
${
|
|
3
|
+
${d}`),d&&(C=true),p=core.JsonUnifier.getLogichValue(l.glueEnabled,t)||false,d)}),S=core.JsonUnifier.getLogichValue(O[0],t),A=typeof S=="object"&&"character"in S?S.character:void 0,k=O.flatMap(l=>{let y;l&&typeof l=="object"&&"text"in l?y=l.text:y=l;let d;return Array.isArray(y)?d=y.map(D=>{let F=core.JsonUnifier.getLogichValue(D,t);return translator.translator.t(`${F}`)}):d=core.JsonUnifier.getLogichValue(y,t)||"",translator.translator.t(d)}),_=c.find(l=>l.end),$=c.find(l=>l.choices),j=false,L=false;c.length>0&&(c[0].glueEnabled&&c[0].goNextStep&&c[0].dialogue===void 0&&(narration.narration.dialogGlue=true),j=c[c.length-1].glueEnabled,L=c.reverse().find(l=>!(l.operations&&(!l.dialogue||!l.choices)))?.goNextStep);let G=c.find(l=>l.labelToOpen),b=[];return c.forEach(l=>{l.operations&&(b=[...b,...l.operations]);}),{dialogue:A?{character:A,text:k}:k,end:_?.end,choices:$?.choices,glueEnabled:j,goNextStep:L,labelToOpen:G?.labelToOpen,operations:b}}}exports.animateOperation=_e;exports.canvasElementOperation=ze;exports.effectOperation=Me;exports.getConditionalStep=M;exports.getLogichValue=xe;exports.getValueFromConditionalStatements=Ne;exports.imageContainerOperation=Ee;exports.imageOperation=Le;exports.loadAssets=Te;exports.narrationOperation=De;exports.setInitialStorageValue=xi;exports.setStorageValue=gi;exports.soundOperation=We;exports.textOperation=Re;exports.videoOperation=Ie;
|
package/dist/actions.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-C-9WKwTo.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 { 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-
|
|
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-C-9WKwTo.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 {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=`
|
|
1
|
+
import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {Assets,canvas,ImageSprite,showImage,VideoSprite,showVideo,ImageContainer,showImageContainer,Text,showText,shakeEffect,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade}from'@drincs/pixi-vn/canvas';import {translator}from'@drincs/pixi-vn-json/translator';import {narration,NarrationManagerStatic}from'@drincs/pixi-vn/narration';import {sound}from'@drincs/pixi-vn/sound';import {PixiError,createExportableElement}from'@drincs/pixi-vn';import {storage}from'@drincs/pixi-vn/storage';var q=Object.defineProperty;var W=(e,t,i)=>t in e?q(e,t,{enumerable:true,configurable:true,writable:true,value:i}):e[t]=i;var u=(e,t,i)=>W(e,typeof t!="symbol"?t+"":t,i);async function Te(e){let t=JsonUnifier.getLogichValue(e,{});if(t)switch(t.type){case "assets":switch(t.operationType){case "load":await Assets.load(t.aliases);break;case "lazyload":Assets.backgroundLoad(t.aliases);break}break;case "bundle":switch(t.operationType){case "load":await Assets.loadBundle(t.aliases);break;case "lazyload":Assets.backgroundLoadBundle(t.aliases);break}break}}var o;(s=>(s.log=(c,...p)=>console.log(`[Pixi\u2019VN Json] ${c}`,...p),s.warn=(c,...p)=>console.warn(`[Pixi\u2019VN Json] ${c}`,...p),s.error=(c,...p)=>console.error(`[Pixi\u2019VN Json] ${c}`,...p),s.info=(c,...p)=>console.info(`[Pixi\u2019VN Json] ${c}`,...p)))(o||(o={}));async function v(e,t,i){switch(i.type){case "fade":await showWithFade(t.alias,e,i.props,i.priority);break;case "dissolve":await showWithDissolve(t.alias,e,i.props,i.priority);break;case "movein":case "moveout":await moveIn(t.alias,e,i.props,i.priority);break;case "zoomin":case "zoomout":await zoomIn(t.alias,e,i.props,i.priority);break;case "pushin":case "pushout":await pushIn(t.alias,e,i.props,i.priority);break}}function P(e){if(e.transition)switch(e.transition.type){case "fade":removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":pushOut(e.alias,e.transition.props,e.transition.priority);break}else canvas.remove(e.alias);}async function Le(e){switch(e.operationType){case "show":if(e.transition){let t=new ImageSprite(e.props,e.url||e.alias);await v(t,e,e.transition);}else await showImage(e.alias,e.url,e.props);break;case "edit":{let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Image with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function Ie(e){switch(e.operationType){case "show":if(e.transition){let t=new VideoSprite(e.props,e.url||e.alias);await v(t,e,e.transition);}else await showVideo(e.alias,e.url,e.props);break;case "edit":{let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Video with alias ${e.alias} not found.`);break}case "remove":P(e);break;case "pause":case "resume":{let t=canvas.find(e.alias);t?t.paused=e.operationType==="pause":o.error(`Video with alias ${e.alias} not found.`);break}}}async function Ee(e){switch(e.operationType){case "show":if(e.transition){let t=new ImageContainer(e.props,e.urls);await v(t,e,e.transition);}else await showImageContainer(e.alias,e.urls,e.props);break;case "edit":{let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`ImageContainer with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function Re(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator.t(e.text),e.transition){let t=new Text(e.props);await v(t,e,e.transition);}else showText(e.alias,e.text,e.props);break;case "edit":{let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Text with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function ze(e){switch(e.operationType){case "edit":try{let t=canvas.find(e.alias);t?e.props&&t.setMemory({...t.memory,...e.props}):o.error(`Canvas Element with alias ${e.alias} not found.`);}catch(t){o.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,t);}break;case "remove":P(e);break}}async function Me(e){e.type==="shake"&&await shakeEffect(e.alias,e.props,e.priority);}function _e(e){switch(e.type){case "animate":canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function De(e){switch(e.type){case "input":narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.dialogue=void 0;break}}function We(e){switch(e.operationType){case "play":e.url?sound.play(e.alias,e.url,e.props):sound.play(e.alias,e.props);break;case "stop":switch(e.type){case "sound":sound.stop(e.alias);break;case "all":sound.stopAll();break}break;case "pause":switch(e.type){case "sound":sound.pause(e.alias);break;case "channel":sound.findChannel(e.alias).pauseAll();break;case "all":sound.pauseAll();break}break;case "resume":switch(e.type){case "sound":sound.resume(e.alias);break;case "channel":sound.findChannel(e.alias).resumeAll();break;case "all":sound.resumeAll();break}break;case "edit":Object.entries(e.props).forEach(([t,i])=>{let a=sound.find(e.alias);a&&(t==="volume"?a.volume.value=i:a.paused=i);});break}}var J="___param___";var n=class n{static init(t){t.loadAssets&&(n._loadAssets=t.loadAssets),t.soundOperation&&(n._soundOperation=t.soundOperation),t.imageOperation&&(n._imageOperation=t.imageOperation),t.videoOperation&&(n._videoOperation=t.videoOperation),t.imageContainerOperation&&(n._imageContainerOperation=t.imageContainerOperation),t.textOperation&&(n._textOperation=t.textOperation),t.canvasElementOperation&&(n._canvasElementOperation=t.canvasElementOperation),t.setStorageValue&&(n._setStorageValue=t.setStorageValue),t.setInitialStorageValue&&(n._setInitialStorageValue=t.setInitialStorageValue),t.narrationOperation&&(n._narrationOperation=t.narrationOperation),t.effectOperation&&(n._effectOperation=t.effectOperation),t.animateOperation&&(n._animateOperation=t.animateOperation),t.getLogichValue&&(n._getLogichValue=t.getLogichValue),t.getConditionalStep&&(n._getConditionalStep=t.getConditionalStep);}static get loadAssets(){return n._loadAssets}static get soundOperation(){return n._soundOperation}static get imageOperation(){return n._imageOperation}static get videoOperation(){return n._videoOperation}static get imageContainerOperation(){return n._imageContainerOperation}static get textOperation(){return n._textOperation}static get canvasElementOperation(){return n._canvasElementOperation}static get setStorageValue(){return n._setStorageValue}static get setInitialStorageValue(){return n._setInitialStorageValue}static get narrationOperation(){return n._narrationOperation}static get effectOperation(){return n._effectOperation}static get animateOperation(){return n._animateOperation}static get getLogichValue(){return n._getLogichValue}static get getConditionalStep(){return n._getConditionalStep}};u(n,"_loadAssets",()=>{}),u(n,"_soundOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_imageOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_videoOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_imageContainerOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_textOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_canvasElementOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_setStorageValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_setInitialStorageValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_narrationOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_effectOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_animateOperation",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_getLogichValue",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),u(n,"_getConditionalStep",()=>{throw o.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var h=n;function R(e,t){if(t&&typeof t=="object"&&typeof e.functionName=="string"&&e.functionName in t){let i=t[e.functionName];if(typeof i=="function"){let a=e.args.map(s=>h.getLogichValue(s,t));return i(...a)}else o.warn(`getLogichValue function ${e.functionName} not found in props`);}}function z(e,t){let i=JsonUnifier.getLogichValue(e,t);return i&&typeof i=="object"&&"type"in i?JsonUnifier.getLogichValue(i,t):i}function gi(e,t={}){let i=z(e.value,t);switch(e.storageType){case "flagStorage":storage.setFlag(e.key,e.value);break;case "storage":storage.set(e.key,i);break;case "tempstorage":storage.setTempVariable(e.key,i);break;case "params":{let a=storage.get(`${J}${narration.openedLabels.length-1}`)||[];a.length>e.key&&(a[e.key]=i),storage.setTempVariable(`${J}${narration.openedLabels.length-1}`,a);break}}}function xi(e,t={}){let i=z(e.value,t);switch(e.storageType){case "storage":case "tempstorage":storage.default={[e.key]:i};break}}function xe(e,t={}){let i=Ne(e,t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return fe(i,t);case "arithmetic":case "arithmeticsingle":return Ve(i,t);case "compare":case "union":return ye(i,t);case "function":return R(i,t)}return i}function Ve(e,t){let i=JsonUnifier.getLogichValue(e.leftValue,t);switch(e.type){case "arithmetic":{let a=JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "*":return i*a;case "/":return i/a;case "+":return typeof i=="string"||typeof a=="string"?`${i}${a}`:Array.isArray(i)&&Array.isArray(a)?[...i,...a]:Array.isArray(i)?[...i,a]:Array.isArray(a)?[i,...a]:i+a;case "-":if(Array.isArray(i)&&Array.isArray(a))return i.filter(s=>!a.includes(s));if(Array.isArray(i))return i.filter(s=>s!==a);if(Array.isArray(a)){o.warn("getValueFromArithmeticOperations cannot subtract array from non-array");return}return i-a;case "%":return i%a;case "POW":return i**a;case "RANDOM":return narration.getRandomNumber(i,a);case "INTERSECTION":if(Array.isArray(i)&&Array.isArray(a))return i.filter(s=>a.includes(s));o.warn("getValueFromArithmeticOperations cannot intersect non-array values");return;default:o.warn("getValueFromArithmeticOperations unknown operator",e);return}}case "arithmeticsingle":switch(e.operator){case "INT":return Number(i);case "FLOOR":return Math.floor(i);}break}}function fe(e,t){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return e.key==="_input_value_"?narration.inputValue:storage.get(e.key);case "flagStorage":return storage.getFlag(e.key);case "label":return narration.getTimesLabelOpened(e.label);case "choice":return narration.getTimesChoiceMade(e.index);case "logic":return JsonUnifier.getLogichValue(e.operation,t);case "params":{let i=storage.get(`${J}${narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];o.warn("getValue params not found");return}}return e}function ye(e,t){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":{let i=JsonUnifier.getLogichValue(e.leftValue,t),a=JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "==":return Array.isArray(i)&&Array.isArray(a)?i.length===a.length&&i.every(s=>a.includes(s)):i===a;case "!=":return Array.isArray(i)&&Array.isArray(a)?i.length!==a.length||!i.every(s=>a.includes(s)):i!==a;case "<":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)<0:Array.isArray(i)&&Array.isArray(a)?i.length<a.length:i<a;case "<=":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)<=0:Array.isArray(i)&&Array.isArray(a)?i.length<=a.length:i<=a;case ">":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)>0:Array.isArray(i)&&Array.isArray(a)?i.length>a.length:i>a;case ">=":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)>=0:Array.isArray(i)&&Array.isArray(a)?i.length>=a.length:i>=a;case "CONTAINS":return Array.isArray(i)&&Array.isArray(a)?a.every(s=>i.includes(s)):Array.isArray(i)?i.includes(a):i.toString().includes(a.toString())}break}case "value":{let i=JsonUnifier.getLogichValue(e,t);return Array.isArray(i)?i.length>0:i&&typeof i=="object"?Object.keys(i).length>0:!!i}case "union":return he(e,t)}return !!e}function he(e,t){if(e.unionType==="not"){let a=xe(e.condition,t);return Array.isArray(a)?a.length===0:a&&typeof a=="object"?Object.keys(a).length===0:!a}let i=a=>JsonUnifier.getLogichValue(a,t)||false;return e.unionType==="and"?e.conditions.every(i):e.conditions.some(i)}function Pe(e,t){return Math.floor(Math.random()*(t-e+1)+e)}function Ne(e,t={}){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return ve(e,t);case "ifelse":return JsonUnifier.getLogichValue(e.condition,t)?JsonUnifier.getLogichValue(e.then,t):JsonUnifier.getLogichValue(e.else,t);case "stepswitch":{let i=JsonUnifier.getLogichValue(e.elements,t)||[];if(i.length===0){o.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":{let a=Pe(0,i.length-1);return JsonUnifier.getLogichValue(i[a],t)}case "loop":{let a=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return a>i.length-1?(a=a%i.length,JsonUnifier.getLogichValue(i[a],t)):JsonUnifier.getLogichValue(i[a],t)}case "sequential":{let a,s=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end==="lastItem"&&(a=JsonUnifier.getLogichValue(i[i.length-1],t)),s>i.length-1?a:JsonUnifier.getLogichValue(i[s],t)}case "sequentialrandom":{let a=NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:e.nestedId,onceOnly:true});if(a===void 0&&e.end==="lastItem"){let s=NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!s?.usedRandomNumbers){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let c=s.usedRandomNumbers[`0-${i.length-1}`];return JsonUnifier.getLogichValue(i[c[c.length-1]],t)}if(a===void 0){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return JsonUnifier.getLogichValue(i[a],t)}}}}return e}function M(e,t={}){if(e.conditionalStep){let i=createExportableElement(JsonUnifier.getLogichValue(e.conditionalStep,t));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operations===void 0&&delete i?.operations,i){let a={...e,conditionalStep:void 0,...i};return M(a,t)}else narration.dialogGlue&&(narration.dialogGlue=false);}return e}function ve(e,t){let i=e.firstItem,a=(e.secondConditionalItem??[]).flatMap(c=>Array.isArray(c)?c.map(p=>JsonUnifier.getLogichValue(p,t)):[JsonUnifier.getLogichValue(c,t)]),s=i?[i,...a]:a;if(s.length===0){o.warn("combinateResult toCheck.length === 0");return}if(typeof s[0]=="string")return translator.t(s);if(typeof s[0]=="object"){let c=s,p,C=false,O=c.map((l,y)=>{l=M(l,t);let d=JsonUnifier.getLogichValue(l.dialogue,t)||"";return y===0?(p=JsonUnifier.getLogichValue(l.glueEnabled,t)||false,d):(typeof d=="object"&&"text"in d&&(d=`${d.character}: ${d.text}`),p===false&&C&&(d=`
|
|
2
2
|
|
|
3
|
-
${
|
|
3
|
+
${d}`),d&&(C=true),p=JsonUnifier.getLogichValue(l.glueEnabled,t)||false,d)}),S=JsonUnifier.getLogichValue(O[0],t),A=typeof S=="object"&&"character"in S?S.character:void 0,k=O.flatMap(l=>{let y;l&&typeof l=="object"&&"text"in l?y=l.text:y=l;let d;return Array.isArray(y)?d=y.map(D=>{let F=JsonUnifier.getLogichValue(D,t);return translator.t(`${F}`)}):d=JsonUnifier.getLogichValue(y,t)||"",translator.t(d)}),_=c.find(l=>l.end),$=c.find(l=>l.choices),j=false,L=false;c.length>0&&(c[0].glueEnabled&&c[0].goNextStep&&c[0].dialogue===void 0&&(narration.dialogGlue=true),j=c[c.length-1].glueEnabled,L=c.reverse().find(l=>!(l.operations&&(!l.dialogue||!l.choices)))?.goNextStep);let G=c.find(l=>l.labelToOpen),b=[];return c.forEach(l=>{l.operations&&(b=[...b,...l.operations]);}),{dialogue:A?{character:A,text:k}:k,end:_?.end,choices:$?.choices,glueEnabled:j,goNextStep:L,labelToOpen:G?.labelToOpen,operations:b}}}export{_e as animateOperation,ze as canvasElementOperation,Me as effectOperation,M as getConditionalStep,xe as getLogichValue,Ne as getValueFromConditionalStatements,Ee as imageContainerOperation,Le as imageOperation,Te as loadAssets,De as narrationOperation,xi as setInitialStorageValue,gi as setStorageValue,We as soundOperation,Re as textOperation,Ie as videoOperation};
|
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 { 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-
|
|
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-B335RwgE.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 { 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-
|
|
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-B335RwgE.js';
|
|
3
3
|
import '@drincs/pixi-vn/motion';
|
|
4
4
|
import 'pixi.js';
|
|
5
5
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var actions=require('@drincs/pixi-vn-json/actions'),core=require('@drincs/pixi-vn-json/core'),
|
|
2
|
-
exports.PIXIVNJSON_PARAM_ID=
|
|
1
|
+
'use strict';var actions=require('@drincs/pixi-vn-json/actions'),core=require('@drincs/pixi-vn-json/core'),translator=require('@drincs/pixi-vn-json/translator'),characters=require('@drincs/pixi-vn/characters'),zod=require('zod'),interpreter=require('@drincs/pixi-vn-json/interpreter');exports.VariableGetter=void 0;(v=>{let o=new Set;function n(d){o.add(d);}v.add=n;function m(){o.clear();}v.clear=m;function f(d,u={}){let p=e=>actions.getLogichValue(e,u)??void 0,c=actions.getValueFromConditionalStatements(d,u);if(o.size===0)return p(c);let a=p;for(let e of o){let r=a;a=t=>e(t,r)??void 0;}return a(c)}v.getLogichValue=f;})(exports.VariableGetter||(exports.VariableGetter={}));var y={version:"1.13.2"};var P="___param___",S=`https://pixi-vn.web.app/schemas/${y.version}/schema.json`,_=["==","!=","<","<=",">",">=","CONTAINS"];exports.TextReplaces=void 0;(a=>{a.options={replaceRegex:/\[([^\]]+)\]/};let n=[],m=false,f=false;function v(e,r){n.push({fn:e,opts:r});let t=r.type??"before-translation";t==="before-translation"&&!m?(translator.translator.beforeToTranslate=s=>p(s,{type:"before-translation"}),m=true):t==="after-translation"&&!f&&(translator.translator.afterToTranslate=s=>p(s,{type:"after-translation"}),f=true);}a.add=v;function d(e){let r=n.findIndex(t=>t.fn===e);r!==-1&&n.splice(r,1);}a.remove=d;function u(){return n.map(e=>e.opts)}a.info=u;function p(e,r){let t=n.filter(s=>(s.opts.type??"before-translation")===r.type);for(let s of t)e=c(e,s.fn,s.opts.validation);return e}a.replace=p;function c(e,r,t){let s=new RegExp(a.options.replaceRegex.source,"g"),V=[...e.matchAll(s)],h=new Set,g=[];for(let i of V)h.has(i[1])||(h.add(i[1]),g.push(i[1]));for(let i of g){if(t==="characterId"){if(!characters.RegisteredCharacters.has(i))continue}else if(t!=="all"){if(t instanceof RegExp){if(!t.test(i))continue}else if(t instanceof zod.ZodType&&!t.safeParse(i).success)continue}let x=r(i);x!==void 0&&(e=e.replaceAll(`[${i}]`,x));}return e}})(exports.TextReplaces||(exports.TextReplaces={}));function ae(){core.JsonUnifier.init({animateOperation:actions.animateOperation,canvasElementOperation:actions.canvasElementOperation,effectOperation:actions.effectOperation,imageContainerOperation:actions.imageContainerOperation,imageOperation:actions.imageOperation,textOperation:actions.textOperation,narrationOperation:actions.narrationOperation,loadAssets:actions.loadAssets,soundOperation:actions.soundOperation,videoOperation:actions.videoOperation,setStorageValue:actions.setStorageValue,setInitialStorageValue:actions.setInitialStorageValue,getLogichValue:exports.VariableGetter.getLogichValue,getConditionalStep:actions.getConditionalStep});}
|
|
2
|
+
exports.PIXIVNJSON_PARAM_ID=P;exports.PIXIVNJSON_SCHEMA_URL=S;exports.PixiVNJsonComparationOperators=_;exports.init=ae;Object.keys(core).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return core[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]}})});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]}})});
|