@drincs/pixi-vn-json 1.3.0 → 1.3.1

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.
@@ -1,5 +1,5 @@
1
1
  import PixiVNJsonLabels from './PixiVNJsonLabels.js';
2
- import PixiVNJsonOperations from './PixiVNJsonOperations.js';
2
+ import PixiVNJsonConditionalOperation from './PixiVNJsonOperations.js';
3
3
  import '../PixiVNJsonConditionalStatements-CdkmXvpt.js';
4
4
  import './PixiVNJsonCanvas.js';
5
5
  import './PixiVNJsonCanvasEffect.js';
@@ -19,7 +19,7 @@ interface PixiVNJson {
19
19
  * For the set storage: They will be set only if there are no variables with the same key already.
20
20
  * For the det tempstorage: if there are variables with the same key already, they will be overwritten.
21
21
  */
22
- initialOperations?: PixiVNJsonOperations;
22
+ initialOperations?: PixiVNJsonConditionalOperation[];
23
23
  /**
24
24
  * The labels to be used in the narrative. They will be added to the system
25
25
  */
@@ -1,6 +1,6 @@
1
1
  import { LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
2
2
  import { q as PixiVNJsonValueGet, d as PixiVNJsonConditionalStatements } from '../PixiVNJsonConditionalStatements-CdkmXvpt.cjs';
3
- import PixiVNJsonOperations from './PixiVNJsonOperations.cjs';
3
+ import PixiVNJsonConditionalOperation from './PixiVNJsonOperations.cjs';
4
4
  import './PixiVNJsonCanvas.cjs';
5
5
  import './PixiVNJsonCanvasEffect.cjs';
6
6
  import './PixiVNJsonCanvasTicker.cjs';
@@ -70,7 +70,7 @@ type PixiVNJsonLabelToOpen<T extends {} = {}> = {
70
70
  params?: any[];
71
71
  };
72
72
  /**
73
- * Steps of a {@link PixiVNJsonLabel}.
73
+ * Steps of a label.
74
74
  * Order of operations:
75
75
  * 1. run all {@link PixiVNJsonLabelStep.operations}
76
76
  * 2. set {@link PixiVNJsonLabelStep.choices}, {@link PixiVNJsonLabelStep.dialogue}, {@link PixiVNJsonLabelStep.glueEnabled}
@@ -79,7 +79,7 @@ type PixiVNJsonLabelToOpen<T extends {} = {}> = {
79
79
  * 5. end the label if {@link PixiVNJsonLabelStep.end} is "label_end"
80
80
  */
81
81
  type PixiVNJsonLabelStep = {
82
- operations?: PixiVNJsonOperations;
82
+ operations?: PixiVNJsonConditionalOperation[];
83
83
  /**
84
84
  * Variable used to display a choice menu.
85
85
  */
@@ -1,6 +1,6 @@
1
1
  import { LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
2
2
  import { q as PixiVNJsonValueGet, d as PixiVNJsonConditionalStatements } from '../PixiVNJsonConditionalStatements-CdkmXvpt.js';
3
- import PixiVNJsonOperations from './PixiVNJsonOperations.js';
3
+ import PixiVNJsonConditionalOperation from './PixiVNJsonOperations.js';
4
4
  import './PixiVNJsonCanvas.js';
5
5
  import './PixiVNJsonCanvasEffect.js';
6
6
  import './PixiVNJsonCanvasTicker.js';
@@ -70,7 +70,7 @@ type PixiVNJsonLabelToOpen<T extends {} = {}> = {
70
70
  params?: any[];
71
71
  };
72
72
  /**
73
- * Steps of a {@link PixiVNJsonLabel}.
73
+ * Steps of a label.
74
74
  * Order of operations:
75
75
  * 1. run all {@link PixiVNJsonLabelStep.operations}
76
76
  * 2. set {@link PixiVNJsonLabelStep.choices}, {@link PixiVNJsonLabelStep.dialogue}, {@link PixiVNJsonLabelStep.glueEnabled}
@@ -79,7 +79,7 @@ type PixiVNJsonLabelToOpen<T extends {} = {}> = {
79
79
  * 5. end the label if {@link PixiVNJsonLabelStep.end} is "label_end"
80
80
  */
81
81
  type PixiVNJsonLabelStep = {
82
- operations?: PixiVNJsonOperations;
82
+ operations?: PixiVNJsonConditionalOperation[];
83
83
  /**
84
84
  * Variable used to display a choice menu.
85
85
  */
@@ -9,15 +9,11 @@ import './PixiVNJsonMediaTransiotions.cjs';
9
9
  import './PixiVNJsonInput.cjs';
10
10
  import './PixiVNJsonSound.cjs';
11
11
 
12
- /**
13
- * Label of the narrative.
14
- */
15
- type PixiVNJsonLabel = PixiVNJsonLabelStep[];
16
12
  /**
17
13
  * Collection of labels to be used in the narrative.
18
14
  */
19
15
  type PixiVNJsonLabels = {
20
- [labelId: string]: PixiVNJsonLabel;
16
+ [labelId: string]: PixiVNJsonLabelStep[];
21
17
  };
22
18
 
23
- export type { PixiVNJsonLabel, PixiVNJsonLabels as default };
19
+ export type { PixiVNJsonLabels, PixiVNJsonLabels as default };
@@ -9,15 +9,11 @@ import './PixiVNJsonMediaTransiotions.js';
9
9
  import './PixiVNJsonInput.js';
10
10
  import './PixiVNJsonSound.js';
11
11
 
12
- /**
13
- * Label of the narrative.
14
- */
15
- type PixiVNJsonLabel = PixiVNJsonLabelStep[];
16
12
  /**
17
13
  * Collection of labels to be used in the narrative.
18
14
  */
19
15
  type PixiVNJsonLabels = {
20
- [labelId: string]: PixiVNJsonLabel;
16
+ [labelId: string]: PixiVNJsonLabelStep[];
21
17
  };
22
18
 
23
- export type { PixiVNJsonLabel, PixiVNJsonLabels as default };
19
+ export type { PixiVNJsonLabels, PixiVNJsonLabels as default };
@@ -12,6 +12,6 @@ type PixiVNJsonOperationString = {
12
12
  values: (string | PixiVNJsonValueGet | PixiVNJsonConditionalStatements<string | PixiVNJsonValueGet>)[];
13
13
  };
14
14
  type PixiVNJsonOperation = PixiVNJsonValueSet | PixiVNJsonCanvas | PixiVNJsonSound | PixiVNJsonInput;
15
- type PixiVNJsonOperations = (PixiVNJsonOperation | PixiVNJsonIfElse<PixiVNJsonOperation> | PixiVNJsonOperationString)[];
15
+ type PixiVNJsonConditionalOperation = PixiVNJsonOperation | PixiVNJsonIfElse<PixiVNJsonOperation> | PixiVNJsonOperationString;
16
16
 
17
- export type { PixiVNJsonOperation, PixiVNJsonOperationString, PixiVNJsonOperations as default };
17
+ export type { PixiVNJsonOperation, PixiVNJsonOperationString, PixiVNJsonConditionalOperation as default };
@@ -12,6 +12,6 @@ type PixiVNJsonOperationString = {
12
12
  values: (string | PixiVNJsonValueGet | PixiVNJsonConditionalStatements<string | PixiVNJsonValueGet>)[];
13
13
  };
14
14
  type PixiVNJsonOperation = PixiVNJsonValueSet | PixiVNJsonCanvas | PixiVNJsonSound | PixiVNJsonInput;
15
- type PixiVNJsonOperations = (PixiVNJsonOperation | PixiVNJsonIfElse<PixiVNJsonOperation> | PixiVNJsonOperationString)[];
15
+ type PixiVNJsonConditionalOperation = PixiVNJsonOperation | PixiVNJsonIfElse<PixiVNJsonOperation> | PixiVNJsonOperationString;
16
16
 
17
- export type { PixiVNJsonOperation, PixiVNJsonOperationString, PixiVNJsonOperations as default };
17
+ export type { PixiVNJsonOperation, PixiVNJsonOperationString, PixiVNJsonConditionalOperation as default };
@@ -4,9 +4,9 @@ export { default as PixiVNJsonCanvas, PixiVNJsonCanvasEdit, PixiVNJsonCanvasRemo
4
4
  export { default as PixiVNJsonCanvasEffect } from './PixiVNJsonCanvasEffect.cjs';
5
5
  export { default as PixiVNJsonCanvasTicker } from './PixiVNJsonCanvasTicker.cjs';
6
6
  export { default as PixiVNJsonInput } from './PixiVNJsonInput.cjs';
7
- export { PixiVNJsonLabel, default as PixiVNJsonLabels } from './PixiVNJsonLabels.cjs';
7
+ export { default as PixiVNJsonLabels } from './PixiVNJsonLabels.cjs';
8
8
  export { PixiVNJsonChoice, PixiVNJsonChoices, PixiVNJsonDialog, PixiVNJsonDialogText, default as PixiVNJsonLabelStep, PixiVNJsonLabelToOpen } from './PixiVNJsonLabelStep.cjs';
9
9
  export { default as PixiVNJsonMediaTransiotions } from './PixiVNJsonMediaTransiotions.cjs';
10
- export { PixiVNJsonOperation, PixiVNJsonOperationString, default as PixiVNJsonOperations } from './PixiVNJsonOperations.cjs';
10
+ export { default as PixiVNJsonConditionalOperation, PixiVNJsonOperation, PixiVNJsonOperationString } from './PixiVNJsonOperations.cjs';
11
11
  export { default as PixiVNJsonSound } from './PixiVNJsonSound.cjs';
12
12
  import '@drincs/pixi-vn';
@@ -4,9 +4,9 @@ export { default as PixiVNJsonCanvas, PixiVNJsonCanvasEdit, PixiVNJsonCanvasRemo
4
4
  export { default as PixiVNJsonCanvasEffect } from './PixiVNJsonCanvasEffect.js';
5
5
  export { default as PixiVNJsonCanvasTicker } from './PixiVNJsonCanvasTicker.js';
6
6
  export { default as PixiVNJsonInput } from './PixiVNJsonInput.js';
7
- export { PixiVNJsonLabel, default as PixiVNJsonLabels } from './PixiVNJsonLabels.js';
7
+ export { default as PixiVNJsonLabels } from './PixiVNJsonLabels.js';
8
8
  export { PixiVNJsonChoice, PixiVNJsonChoices, PixiVNJsonDialog, PixiVNJsonDialogText, default as PixiVNJsonLabelStep, PixiVNJsonLabelToOpen } from './PixiVNJsonLabelStep.js';
9
9
  export { default as PixiVNJsonMediaTransiotions } from './PixiVNJsonMediaTransiotions.js';
10
- export { PixiVNJsonOperation, PixiVNJsonOperationString, default as PixiVNJsonOperations } from './PixiVNJsonOperations.js';
10
+ export { default as PixiVNJsonConditionalOperation, PixiVNJsonOperation, PixiVNJsonOperationString } from './PixiVNJsonOperations.js';
11
11
  export { default as PixiVNJsonSound } from './PixiVNJsonSound.js';
12
12
  import '@drincs/pixi-vn';
@@ -1 +1 @@
1
- 'use strict';var h=class t{static _beforeToTranslate=undefined;static _translate=e=>e;static _afterToTranslate=undefined;static t(e){return Array.isArray(e)?e.map(i=>t.translate(`${i}`)):t.translate(`${e}`)}static set beforeToTranslate(e){t._beforeToTranslate=e;}static set translate(e){t._translate=e;}static get translate(){return e=>{let i=e;return t._beforeToTranslate&&(i=t._beforeToTranslate(i)),i=t._translate(i),t._afterToTranslate&&(i=t._afterToTranslate(i)),i}}static set afterToTranslate(e){t._afterToTranslate=e;}static addKey(e,i,s){let n=s.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===undefined&&(n==="empty_string"?e[r]="":n==="copy_key"&&(t._beforeToTranslate?e[r]=t._beforeToTranslate(r):e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&t.getConditionalsThenElse(e.then,i),e.else&&t.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(s=>{t.getConditionalsThenElse(s,i);});else if(e.elements.type==="ifelse"){let s=[];t.getConditionalsThenElse(e.elements,s),s.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let s=[];t.getConditionalsThenElse(e.elements,s),s.forEach(n=>{i.push(...n);});}else t.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&t.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(s=>{t.getConditionalsThenElse(s,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},s={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=t.getConditionalsThenElse(n.choices),r.forEach(l=>l.forEach(o=>{if("type"in o){let g=[];o.type==="ifelse"||o.type==="stepswitch"?t.getConditionalsThenElse(o,g):g=[o],g.map(a=>t.getConditionalsThenElse(a.text)).forEach(a=>{Array.isArray(a)&&a.forEach(f=>{Array.isArray(f)?f.forEach(c=>{typeof c=="string"?t.addKey(i,c,s):t.getConditionalsThenElse(c).forEach(T=>{Array.isArray(T)?T.forEach(d=>{typeof d=="string"&&t.addKey(i,d,s);}):typeof T=="string"&&t.addKey(i,T,s);});}):typeof f=="string"&&t.addKey(i,f,s);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=t.getConditionalsThenElse(n.dialogue),r.forEach(l=>{typeof l=="string"?t.addKey(i,l,s):"text"in l&&Array.isArray(l.text)&&l.text.forEach(o=>{typeof o=="string"?t.addKey(i,o,s):t.getConditionalsThenElse(o).forEach(y=>{typeof y=="string"?t.addKey(i,y,s):Array.isArray(y)&&y.forEach(a=>{typeof a=="string"?t.addKey(i,a,s):t.getConditionalsThenElse(a).forEach(f=>{typeof f=="string"&&t.addKey(i,f,s);});});});});});}n.conditionalStep&&t.getConditionalsThenElse(n.conditionalStep).forEach(l=>{Array.isArray(l)?t.generateJsonTranslation(l,i,s):t.generateJsonTranslation([l],i,s);});}),i}};module.exports=h;
1
+ 'use strict';var h=class t{static _beforeToTranslate=void 0;static _translate=e=>e;static _afterToTranslate=void 0;static t(e){return Array.isArray(e)?e.map(i=>t.translate(`${i}`)):t.translate(`${e}`)}static set beforeToTranslate(e){t._beforeToTranslate=e;}static set translate(e){t._translate=e;}static get translate(){return e=>{let i=e;return t._beforeToTranslate&&(i=t._beforeToTranslate(i)),i=t._translate(i),t._afterToTranslate&&(i=t._afterToTranslate(i)),i}}static set afterToTranslate(e){t._afterToTranslate=e;}static addKey(e,i,s){let n=s.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===void 0&&(n==="empty_string"?e[r]="":n==="copy_key"&&(t._beforeToTranslate?e[r]=t._beforeToTranslate(r):e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&t.getConditionalsThenElse(e.then,i),e.else&&t.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(s=>{t.getConditionalsThenElse(s,i);});else if(e.elements.type==="ifelse"){let s=[];t.getConditionalsThenElse(e.elements,s),s.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let s=[];t.getConditionalsThenElse(e.elements,s),s.forEach(n=>{i.push(...n);});}else t.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&t.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(s=>{t.getConditionalsThenElse(s,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},s={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=t.getConditionalsThenElse(n.choices),r.forEach(l=>l.forEach(o=>{if("type"in o){let g=[];o.type==="ifelse"||o.type==="stepswitch"?t.getConditionalsThenElse(o,g):g=[o],g.map(a=>t.getConditionalsThenElse(a.text)).forEach(a=>{Array.isArray(a)&&a.forEach(f=>{Array.isArray(f)?f.forEach(c=>{typeof c=="string"?t.addKey(i,c,s):t.getConditionalsThenElse(c).forEach(T=>{Array.isArray(T)?T.forEach(d=>{typeof d=="string"&&t.addKey(i,d,s);}):typeof T=="string"&&t.addKey(i,T,s);});}):typeof f=="string"&&t.addKey(i,f,s);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=t.getConditionalsThenElse(n.dialogue),r.forEach(l=>{typeof l=="string"?t.addKey(i,l,s):"text"in l&&Array.isArray(l.text)&&l.text.forEach(o=>{typeof o=="string"?t.addKey(i,o,s):t.getConditionalsThenElse(o).forEach(y=>{typeof y=="string"?t.addKey(i,y,s):Array.isArray(y)&&y.forEach(a=>{typeof a=="string"?t.addKey(i,a,s):t.getConditionalsThenElse(a).forEach(f=>{typeof f=="string"&&t.addKey(i,f,s);});});});});});}n.conditionalStep&&t.getConditionalsThenElse(n.conditionalStep).forEach(l=>{Array.isArray(l)?t.generateJsonTranslation(l,i,s):t.generateJsonTranslation([l],i,s);});}),i}};module.exports=h;
@@ -1 +1 @@
1
- var h=class t{static _beforeToTranslate=undefined;static _translate=e=>e;static _afterToTranslate=undefined;static t(e){return Array.isArray(e)?e.map(i=>t.translate(`${i}`)):t.translate(`${e}`)}static set beforeToTranslate(e){t._beforeToTranslate=e;}static set translate(e){t._translate=e;}static get translate(){return e=>{let i=e;return t._beforeToTranslate&&(i=t._beforeToTranslate(i)),i=t._translate(i),t._afterToTranslate&&(i=t._afterToTranslate(i)),i}}static set afterToTranslate(e){t._afterToTranslate=e;}static addKey(e,i,s){let n=s.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===undefined&&(n==="empty_string"?e[r]="":n==="copy_key"&&(t._beforeToTranslate?e[r]=t._beforeToTranslate(r):e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&t.getConditionalsThenElse(e.then,i),e.else&&t.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(s=>{t.getConditionalsThenElse(s,i);});else if(e.elements.type==="ifelse"){let s=[];t.getConditionalsThenElse(e.elements,s),s.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let s=[];t.getConditionalsThenElse(e.elements,s),s.forEach(n=>{i.push(...n);});}else t.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&t.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(s=>{t.getConditionalsThenElse(s,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},s={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=t.getConditionalsThenElse(n.choices),r.forEach(l=>l.forEach(o=>{if("type"in o){let g=[];o.type==="ifelse"||o.type==="stepswitch"?t.getConditionalsThenElse(o,g):g=[o],g.map(a=>t.getConditionalsThenElse(a.text)).forEach(a=>{Array.isArray(a)&&a.forEach(f=>{Array.isArray(f)?f.forEach(c=>{typeof c=="string"?t.addKey(i,c,s):t.getConditionalsThenElse(c).forEach(T=>{Array.isArray(T)?T.forEach(d=>{typeof d=="string"&&t.addKey(i,d,s);}):typeof T=="string"&&t.addKey(i,T,s);});}):typeof f=="string"&&t.addKey(i,f,s);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=t.getConditionalsThenElse(n.dialogue),r.forEach(l=>{typeof l=="string"?t.addKey(i,l,s):"text"in l&&Array.isArray(l.text)&&l.text.forEach(o=>{typeof o=="string"?t.addKey(i,o,s):t.getConditionalsThenElse(o).forEach(y=>{typeof y=="string"?t.addKey(i,y,s):Array.isArray(y)&&y.forEach(a=>{typeof a=="string"?t.addKey(i,a,s):t.getConditionalsThenElse(a).forEach(f=>{typeof f=="string"&&t.addKey(i,f,s);});});});});});}n.conditionalStep&&t.getConditionalsThenElse(n.conditionalStep).forEach(l=>{Array.isArray(l)?t.generateJsonTranslation(l,i,s):t.generateJsonTranslation([l],i,s);});}),i}};export{h as default};
1
+ var h=class t{static _beforeToTranslate=void 0;static _translate=e=>e;static _afterToTranslate=void 0;static t(e){return Array.isArray(e)?e.map(i=>t.translate(`${i}`)):t.translate(`${e}`)}static set beforeToTranslate(e){t._beforeToTranslate=e;}static set translate(e){t._translate=e;}static get translate(){return e=>{let i=e;return t._beforeToTranslate&&(i=t._beforeToTranslate(i)),i=t._translate(i),t._afterToTranslate&&(i=t._afterToTranslate(i)),i}}static set afterToTranslate(e){t._afterToTranslate=e;}static addKey(e,i,s){let n=s.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===void 0&&(n==="empty_string"?e[r]="":n==="copy_key"&&(t._beforeToTranslate?e[r]=t._beforeToTranslate(r):e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&t.getConditionalsThenElse(e.then,i),e.else&&t.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(s=>{t.getConditionalsThenElse(s,i);});else if(e.elements.type==="ifelse"){let s=[];t.getConditionalsThenElse(e.elements,s),s.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let s=[];t.getConditionalsThenElse(e.elements,s),s.forEach(n=>{i.push(...n);});}else t.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&t.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(s=>{t.getConditionalsThenElse(s,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},s={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=t.getConditionalsThenElse(n.choices),r.forEach(l=>l.forEach(o=>{if("type"in o){let g=[];o.type==="ifelse"||o.type==="stepswitch"?t.getConditionalsThenElse(o,g):g=[o],g.map(a=>t.getConditionalsThenElse(a.text)).forEach(a=>{Array.isArray(a)&&a.forEach(f=>{Array.isArray(f)?f.forEach(c=>{typeof c=="string"?t.addKey(i,c,s):t.getConditionalsThenElse(c).forEach(T=>{Array.isArray(T)?T.forEach(d=>{typeof d=="string"&&t.addKey(i,d,s);}):typeof T=="string"&&t.addKey(i,T,s);});}):typeof f=="string"&&t.addKey(i,f,s);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=t.getConditionalsThenElse(n.dialogue),r.forEach(l=>{typeof l=="string"?t.addKey(i,l,s):"text"in l&&Array.isArray(l.text)&&l.text.forEach(o=>{typeof o=="string"?t.addKey(i,o,s):t.getConditionalsThenElse(o).forEach(y=>{typeof y=="string"?t.addKey(i,y,s):Array.isArray(y)&&y.forEach(a=>{typeof a=="string"?t.addKey(i,a,s):t.getConditionalsThenElse(a).forEach(f=>{typeof f=="string"&&t.addKey(i,f,s);});});});});});}n.conditionalStep&&t.getConditionalsThenElse(n.conditionalStep).forEach(l=>{Array.isArray(l)?t.generateJsonTranslation(l,i,s):t.generateJsonTranslation([l],i,s);});}),i}};export{h as default};
@@ -1 +1 @@
1
- 'use strict';var g=class t{static _beforeToTranslate=undefined;static _translate=e=>e;static _afterToTranslate=undefined;static t(e){return Array.isArray(e)?e.map(i=>t.translate(`${i}`)):t.translate(`${e}`)}static set beforeToTranslate(e){t._beforeToTranslate=e;}static set translate(e){t._translate=e;}static get translate(){return e=>{let i=e;return t._beforeToTranslate&&(i=t._beforeToTranslate(i)),i=t._translate(i),t._afterToTranslate&&(i=t._afterToTranslate(i)),i}}static set afterToTranslate(e){t._afterToTranslate=e;}static addKey(e,i,s){let n=s.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===undefined&&(n==="empty_string"?e[r]="":n==="copy_key"&&(t._beforeToTranslate?e[r]=t._beforeToTranslate(r):e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&t.getConditionalsThenElse(e.then,i),e.else&&t.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(s=>{t.getConditionalsThenElse(s,i);});else if(e.elements.type==="ifelse"){let s=[];t.getConditionalsThenElse(e.elements,s),s.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let s=[];t.getConditionalsThenElse(e.elements,s),s.forEach(n=>{i.push(...n);});}else t.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&t.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(s=>{t.getConditionalsThenElse(s,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},s={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=t.getConditionalsThenElse(n.choices),r.forEach(o=>o.forEach(a=>{if("type"in a){let T=[];a.type==="ifelse"||a.type==="stepswitch"?t.getConditionalsThenElse(a,T):T=[a],T.map(l=>t.getConditionalsThenElse(l.text)).forEach(l=>{Array.isArray(l)&&l.forEach(f=>{Array.isArray(f)?f.forEach(h=>{typeof h=="string"?t.addKey(i,h,s):t.getConditionalsThenElse(h).forEach(c=>{Array.isArray(c)?c.forEach(p=>{typeof p=="string"&&t.addKey(i,p,s);}):typeof c=="string"&&t.addKey(i,c,s);});}):typeof f=="string"&&t.addKey(i,f,s);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=t.getConditionalsThenElse(n.dialogue),r.forEach(o=>{typeof o=="string"?t.addKey(i,o,s):"text"in o&&Array.isArray(o.text)&&o.text.forEach(a=>{typeof a=="string"?t.addKey(i,a,s):t.getConditionalsThenElse(a).forEach(y=>{typeof y=="string"?t.addKey(i,y,s):Array.isArray(y)&&y.forEach(l=>{typeof l=="string"?t.addKey(i,l,s):t.getConditionalsThenElse(l).forEach(f=>{typeof f=="string"&&t.addKey(i,f,s);});});});});});}n.conditionalStep&&t.getConditionalsThenElse(n.conditionalStep).forEach(o=>{Array.isArray(o)?t.generateJsonTranslation(o,i,s):t.generateJsonTranslation([o],i,s);});}),i}};var u=g;exports.translator=u;
1
+ 'use strict';var g=class t{static _beforeToTranslate=void 0;static _translate=e=>e;static _afterToTranslate=void 0;static t(e){return Array.isArray(e)?e.map(i=>t.translate(`${i}`)):t.translate(`${e}`)}static set beforeToTranslate(e){t._beforeToTranslate=e;}static set translate(e){t._translate=e;}static get translate(){return e=>{let i=e;return t._beforeToTranslate&&(i=t._beforeToTranslate(i)),i=t._translate(i),t._afterToTranslate&&(i=t._afterToTranslate(i)),i}}static set afterToTranslate(e){t._afterToTranslate=e;}static addKey(e,i,s){let n=s.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===void 0&&(n==="empty_string"?e[r]="":n==="copy_key"&&(t._beforeToTranslate?e[r]=t._beforeToTranslate(r):e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&t.getConditionalsThenElse(e.then,i),e.else&&t.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(s=>{t.getConditionalsThenElse(s,i);});else if(e.elements.type==="ifelse"){let s=[];t.getConditionalsThenElse(e.elements,s),s.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let s=[];t.getConditionalsThenElse(e.elements,s),s.forEach(n=>{i.push(...n);});}else t.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&t.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(s=>{t.getConditionalsThenElse(s,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},s={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=t.getConditionalsThenElse(n.choices),r.forEach(o=>o.forEach(a=>{if("type"in a){let T=[];a.type==="ifelse"||a.type==="stepswitch"?t.getConditionalsThenElse(a,T):T=[a],T.map(l=>t.getConditionalsThenElse(l.text)).forEach(l=>{Array.isArray(l)&&l.forEach(f=>{Array.isArray(f)?f.forEach(h=>{typeof h=="string"?t.addKey(i,h,s):t.getConditionalsThenElse(h).forEach(c=>{Array.isArray(c)?c.forEach(p=>{typeof p=="string"&&t.addKey(i,p,s);}):typeof c=="string"&&t.addKey(i,c,s);});}):typeof f=="string"&&t.addKey(i,f,s);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=t.getConditionalsThenElse(n.dialogue),r.forEach(o=>{typeof o=="string"?t.addKey(i,o,s):"text"in o&&Array.isArray(o.text)&&o.text.forEach(a=>{typeof a=="string"?t.addKey(i,a,s):t.getConditionalsThenElse(a).forEach(y=>{typeof y=="string"?t.addKey(i,y,s):Array.isArray(y)&&y.forEach(l=>{typeof l=="string"?t.addKey(i,l,s):t.getConditionalsThenElse(l).forEach(f=>{typeof f=="string"&&t.addKey(i,f,s);});});});});});}n.conditionalStep&&t.getConditionalsThenElse(n.conditionalStep).forEach(o=>{Array.isArray(o)?t.generateJsonTranslation(o,i,s):t.generateJsonTranslation([o],i,s);});}),i}};var u=g;exports.translator=u;
@@ -1 +1 @@
1
- var g=class t{static _beforeToTranslate=undefined;static _translate=e=>e;static _afterToTranslate=undefined;static t(e){return Array.isArray(e)?e.map(i=>t.translate(`${i}`)):t.translate(`${e}`)}static set beforeToTranslate(e){t._beforeToTranslate=e;}static set translate(e){t._translate=e;}static get translate(){return e=>{let i=e;return t._beforeToTranslate&&(i=t._beforeToTranslate(i)),i=t._translate(i),t._afterToTranslate&&(i=t._afterToTranslate(i)),i}}static set afterToTranslate(e){t._afterToTranslate=e;}static addKey(e,i,s){let n=s.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===undefined&&(n==="empty_string"?e[r]="":n==="copy_key"&&(t._beforeToTranslate?e[r]=t._beforeToTranslate(r):e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&t.getConditionalsThenElse(e.then,i),e.else&&t.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(s=>{t.getConditionalsThenElse(s,i);});else if(e.elements.type==="ifelse"){let s=[];t.getConditionalsThenElse(e.elements,s),s.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let s=[];t.getConditionalsThenElse(e.elements,s),s.forEach(n=>{i.push(...n);});}else t.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&t.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(s=>{t.getConditionalsThenElse(s,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},s={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=t.getConditionalsThenElse(n.choices),r.forEach(o=>o.forEach(a=>{if("type"in a){let T=[];a.type==="ifelse"||a.type==="stepswitch"?t.getConditionalsThenElse(a,T):T=[a],T.map(l=>t.getConditionalsThenElse(l.text)).forEach(l=>{Array.isArray(l)&&l.forEach(f=>{Array.isArray(f)?f.forEach(h=>{typeof h=="string"?t.addKey(i,h,s):t.getConditionalsThenElse(h).forEach(c=>{Array.isArray(c)?c.forEach(p=>{typeof p=="string"&&t.addKey(i,p,s);}):typeof c=="string"&&t.addKey(i,c,s);});}):typeof f=="string"&&t.addKey(i,f,s);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=t.getConditionalsThenElse(n.dialogue),r.forEach(o=>{typeof o=="string"?t.addKey(i,o,s):"text"in o&&Array.isArray(o.text)&&o.text.forEach(a=>{typeof a=="string"?t.addKey(i,a,s):t.getConditionalsThenElse(a).forEach(y=>{typeof y=="string"?t.addKey(i,y,s):Array.isArray(y)&&y.forEach(l=>{typeof l=="string"?t.addKey(i,l,s):t.getConditionalsThenElse(l).forEach(f=>{typeof f=="string"&&t.addKey(i,f,s);});});});});});}n.conditionalStep&&t.getConditionalsThenElse(n.conditionalStep).forEach(o=>{Array.isArray(o)?t.generateJsonTranslation(o,i,s):t.generateJsonTranslation([o],i,s);});}),i}};var u=g;export{u as translator};
1
+ var g=class t{static _beforeToTranslate=void 0;static _translate=e=>e;static _afterToTranslate=void 0;static t(e){return Array.isArray(e)?e.map(i=>t.translate(`${i}`)):t.translate(`${e}`)}static set beforeToTranslate(e){t._beforeToTranslate=e;}static set translate(e){t._translate=e;}static get translate(){return e=>{let i=e;return t._beforeToTranslate&&(i=t._beforeToTranslate(i)),i=t._translate(i),t._afterToTranslate&&(i=t._afterToTranslate(i)),i}}static set afterToTranslate(e){t._afterToTranslate=e;}static addKey(e,i,s){let n=s.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(r=>{e[r]===void 0&&(n==="empty_string"?e[r]="":n==="copy_key"&&(t._beforeToTranslate?e[r]=t._beforeToTranslate(r):e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&t.getConditionalsThenElse(e.then,i),e.else&&t.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(s=>{t.getConditionalsThenElse(s,i);});else if(e.elements.type==="ifelse"){let s=[];t.getConditionalsThenElse(e.elements,s),s.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let s=[];t.getConditionalsThenElse(e.elements,s),s.forEach(n=>{i.push(...n);});}else t.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&t.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(s=>{t.getConditionalsThenElse(s,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},s={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=t.getConditionalsThenElse(n.choices),r.forEach(o=>o.forEach(a=>{if("type"in a){let T=[];a.type==="ifelse"||a.type==="stepswitch"?t.getConditionalsThenElse(a,T):T=[a],T.map(l=>t.getConditionalsThenElse(l.text)).forEach(l=>{Array.isArray(l)&&l.forEach(f=>{Array.isArray(f)?f.forEach(h=>{typeof h=="string"?t.addKey(i,h,s):t.getConditionalsThenElse(h).forEach(c=>{Array.isArray(c)?c.forEach(p=>{typeof p=="string"&&t.addKey(i,p,s);}):typeof c=="string"&&t.addKey(i,c,s);});}):typeof f=="string"&&t.addKey(i,f,s);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=t.getConditionalsThenElse(n.dialogue),r.forEach(o=>{typeof o=="string"?t.addKey(i,o,s):"text"in o&&Array.isArray(o.text)&&o.text.forEach(a=>{typeof a=="string"?t.addKey(i,a,s):t.getConditionalsThenElse(a).forEach(y=>{typeof y=="string"?t.addKey(i,y,s):Array.isArray(y)&&y.forEach(l=>{typeof l=="string"?t.addKey(i,l,s):t.getConditionalsThenElse(l).forEach(f=>{typeof f=="string"&&t.addKey(i,f,s);});});});});});}n.conditionalStep&&t.getConditionalsThenElse(n.conditionalStep).forEach(o=>{Array.isArray(o)?t.generateJsonTranslation(o,i,s):t.generateJsonTranslation([o],i,s);});}),i}};var u=g;export{u as translator};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drincs/pixi-vn-json",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "type": "module",
5
5
  "description": "Pixi'VN can be integrated with JSON files to create a visual novel.",
6
6
  "main": "./dist/index.cjs",
@@ -31,7 +31,7 @@
31
31
  "typescript": "^5.7.3"
32
32
  },
33
33
  "peerDependencies": {
34
- "@drincs/pixi-vn": ">=0.10.12"
34
+ "@drincs/pixi-vn": ">=0.10.22"
35
35
  },
36
36
  "keywords": [
37
37
  "game",