@drincs/pixi-vn-json 1.0.9 → 1.0.11

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 +1 @@
1
- var p=class s{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(i=>s._translate(`${i}`)):s._translate(`${e}`)}static set translate(e){s._translate=e;}static addKey(e,i,t){let n=t.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"&&(e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&s.getConditionalsThenElse(e.then,i),e.else&&s.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(t=>{s.getConditionalsThenElse(t,i);});else if(e.elements.type==="ifelse"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else s.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&s.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(t=>{s.getConditionalsThenElse(t,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},t={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=s.getConditionalsThenElse(n.choices),r.forEach(l=>l.forEach(o=>{if("type"in o){let h=[];o.type==="ifelse"||o.type==="stepswitch"?s.getConditionalsThenElse(o,h):h=[o],h.map(f=>s.getConditionalsThenElse(f.text)).forEach(f=>{Array.isArray(f)&&f.forEach(a=>{Array.isArray(a)?a.forEach(c=>{typeof c=="string"?s.addKey(i,c,t):s.getConditionalsThenElse(c).forEach(g=>{Array.isArray(g)?g.forEach(E=>{typeof E=="string"&&s.addKey(i,E,t);}):typeof g=="string"&&s.addKey(i,g,t);});}):typeof a=="string"&&s.addKey(i,a,t);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=s.getConditionalsThenElse(n.dialogue),r.forEach(l=>{typeof l=="string"?s.addKey(i,l,t):"text"in l&&Array.isArray(l.text)&&l.text.forEach(o=>{typeof o=="string"?s.addKey(i,o,t):s.getConditionalsThenElse(o).forEach(y=>{typeof y=="string"?s.addKey(i,y,t):Array.isArray(y)&&y.forEach(f=>{typeof f=="string"?s.addKey(i,f,t):s.getConditionalsThenElse(f).forEach(a=>{typeof a=="string"&&s.addKey(i,a,t);});});});});});}n.conditionalStep&&s.getConditionalsThenElse(n.conditionalStep).forEach(l=>{Array.isArray(l)?s.generateJsonTranslation(l,i,t):s.generateJsonTranslation([l],i,t);});}),i}};export{p as default};
1
+ var h=class i{static _beforeToTranslate=void 0;static _translate=e=>e;static _afterToTranslate=void 0;static t(e){return Array.isArray(e)?e.map(t=>i.translate(`${t}`)):i.translate(`${e}`)}static set beforeToTranslate(e){i._beforeToTranslate=e;}static set translate(e){i._translate=e;}static get translate(){return e=>{let t="";return i._beforeToTranslate&&(t=i._beforeToTranslate(e)),t=i._translate(t),i._afterToTranslate&&(t=i._afterToTranslate(t)),t}}static set afterToTranslate(e){i._afterToTranslate=e;}static addKey(e,t,s){let n=s.defaultValue||"empty_string";typeof t=="string"&&(t=[t]),Array.isArray(t)&&t.forEach(r=>{e[r]===void 0&&(n==="empty_string"?e[r]="":n==="copy_key"&&(i._beforeToTranslate?e[r]=i._beforeToTranslate(r):e[r]=r));});}static getConditionalsThenElse(e,t=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&i.getConditionalsThenElse(e.then,t),e.else&&i.getConditionalsThenElse(e.else,t);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(s=>{i.getConditionalsThenElse(s,t);});else if(e.elements.type==="ifelse"){let s=[];i.getConditionalsThenElse(e.elements,s),s.forEach(n=>{t.push(...n);});}else if(e.elements.type==="stepswitch"){let s=[];i.getConditionalsThenElse(e.elements,s),s.forEach(n=>{t.push(...n);});}else i.getConditionalsThenElse(e.elements,t);}else e.type==="resulttocombine"?(e.firstItem&&i.getConditionalsThenElse(e.firstItem,t),e.secondConditionalItem&&e.secondConditionalItem.forEach(s=>{i.getConditionalsThenElse(s,t);})):t.push(e);else e&&t.push(e);return t}static generateJsonTranslation(e,t={},s={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=i.getConditionalsThenElse(n.choices),r.forEach(l=>l.forEach(o=>{if("type"in o){let g=[];o.type==="ifelse"||o.type==="stepswitch"?i.getConditionalsThenElse(o,g):g=[o],g.map(a=>i.getConditionalsThenElse(a.text)).forEach(a=>{Array.isArray(a)&&a.forEach(f=>{Array.isArray(f)?f.forEach(c=>{typeof c=="string"?i.addKey(t,c,s):i.getConditionalsThenElse(c).forEach(T=>{Array.isArray(T)?T.forEach(d=>{typeof d=="string"&&i.addKey(t,d,s);}):typeof T=="string"&&i.addKey(t,T,s);});}):typeof f=="string"&&i.addKey(t,f,s);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=i.getConditionalsThenElse(n.dialogue),r.forEach(l=>{typeof l=="string"?i.addKey(t,l,s):"text"in l&&Array.isArray(l.text)&&l.text.forEach(o=>{typeof o=="string"?i.addKey(t,o,s):i.getConditionalsThenElse(o).forEach(y=>{typeof y=="string"?i.addKey(t,y,s):Array.isArray(y)&&y.forEach(a=>{typeof a=="string"?i.addKey(t,a,s):i.getConditionalsThenElse(a).forEach(f=>{typeof f=="string"&&i.addKey(t,f,s);});});});});});}n.conditionalStep&&i.getConditionalsThenElse(n.conditionalStep).forEach(l=>{Array.isArray(l)?i.generateJsonTranslation(l,t,s):i.generateJsonTranslation([l],t,s);});}),t}};export{h as default};
@@ -1 +1 @@
1
- 'use strict';var h=class s{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(i=>s._translate(`${i}`)):s._translate(`${e}`)}static set translate(e){s._translate=e;}static addKey(e,i,t){let n=t.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"&&(e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&s.getConditionalsThenElse(e.then,i),e.else&&s.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(t=>{s.getConditionalsThenElse(t,i);});else if(e.elements.type==="ifelse"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else s.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&s.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(t=>{s.getConditionalsThenElse(t,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},t={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=s.getConditionalsThenElse(n.choices),r.forEach(l=>l.forEach(o=>{if("type"in o){let g=[];o.type==="ifelse"||o.type==="stepswitch"?s.getConditionalsThenElse(o,g):g=[o],g.map(f=>s.getConditionalsThenElse(f.text)).forEach(f=>{Array.isArray(f)&&f.forEach(a=>{Array.isArray(a)?a.forEach(p=>{typeof p=="string"?s.addKey(i,p,t):s.getConditionalsThenElse(p).forEach(c=>{Array.isArray(c)?c.forEach(T=>{typeof T=="string"&&s.addKey(i,T,t);}):typeof c=="string"&&s.addKey(i,c,t);});}):typeof a=="string"&&s.addKey(i,a,t);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=s.getConditionalsThenElse(n.dialogue),r.forEach(l=>{typeof l=="string"?s.addKey(i,l,t):"text"in l&&Array.isArray(l.text)&&l.text.forEach(o=>{typeof o=="string"?s.addKey(i,o,t):s.getConditionalsThenElse(o).forEach(y=>{typeof y=="string"?s.addKey(i,y,t):Array.isArray(y)&&y.forEach(f=>{typeof f=="string"?s.addKey(i,f,t):s.getConditionalsThenElse(f).forEach(a=>{typeof a=="string"&&s.addKey(i,a,t);});});});});});}n.conditionalStep&&s.getConditionalsThenElse(n.conditionalStep).forEach(l=>{Array.isArray(l)?s.generateJsonTranslation(l,i,t):s.generateJsonTranslation([l],i,t);});}),i}};var C=h;exports.translator=C;
1
+ 'use strict';var g=class i{static _beforeToTranslate=void 0;static _translate=e=>e;static _afterToTranslate=void 0;static t(e){return Array.isArray(e)?e.map(t=>i.translate(`${t}`)):i.translate(`${e}`)}static set beforeToTranslate(e){i._beforeToTranslate=e;}static set translate(e){i._translate=e;}static get translate(){return e=>{let t="";return i._beforeToTranslate&&(t=i._beforeToTranslate(e)),t=i._translate(t),i._afterToTranslate&&(t=i._afterToTranslate(t)),t}}static set afterToTranslate(e){i._afterToTranslate=e;}static addKey(e,t,s){let n=s.defaultValue||"empty_string";typeof t=="string"&&(t=[t]),Array.isArray(t)&&t.forEach(r=>{e[r]===void 0&&(n==="empty_string"?e[r]="":n==="copy_key"&&(i._beforeToTranslate?e[r]=i._beforeToTranslate(r):e[r]=r));});}static getConditionalsThenElse(e,t=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&i.getConditionalsThenElse(e.then,t),e.else&&i.getConditionalsThenElse(e.else,t);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(s=>{i.getConditionalsThenElse(s,t);});else if(e.elements.type==="ifelse"){let s=[];i.getConditionalsThenElse(e.elements,s),s.forEach(n=>{t.push(...n);});}else if(e.elements.type==="stepswitch"){let s=[];i.getConditionalsThenElse(e.elements,s),s.forEach(n=>{t.push(...n);});}else i.getConditionalsThenElse(e.elements,t);}else e.type==="resulttocombine"?(e.firstItem&&i.getConditionalsThenElse(e.firstItem,t),e.secondConditionalItem&&e.secondConditionalItem.forEach(s=>{i.getConditionalsThenElse(s,t);})):t.push(e);else e&&t.push(e);return t}static generateJsonTranslation(e,t={},s={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=i.getConditionalsThenElse(n.choices),r.forEach(o=>o.forEach(a=>{if("type"in a){let T=[];a.type==="ifelse"||a.type==="stepswitch"?i.getConditionalsThenElse(a,T):T=[a],T.map(l=>i.getConditionalsThenElse(l.text)).forEach(l=>{Array.isArray(l)&&l.forEach(f=>{Array.isArray(f)?f.forEach(h=>{typeof h=="string"?i.addKey(t,h,s):i.getConditionalsThenElse(h).forEach(c=>{Array.isArray(c)?c.forEach(p=>{typeof p=="string"&&i.addKey(t,p,s);}):typeof c=="string"&&i.addKey(t,c,s);});}):typeof f=="string"&&i.addKey(t,f,s);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=i.getConditionalsThenElse(n.dialogue),r.forEach(o=>{typeof o=="string"?i.addKey(t,o,s):"text"in o&&Array.isArray(o.text)&&o.text.forEach(a=>{typeof a=="string"?i.addKey(t,a,s):i.getConditionalsThenElse(a).forEach(y=>{typeof y=="string"?i.addKey(t,y,s):Array.isArray(y)&&y.forEach(l=>{typeof l=="string"?i.addKey(t,l,s):i.getConditionalsThenElse(l).forEach(f=>{typeof f=="string"&&i.addKey(t,f,s);});});});});});}n.conditionalStep&&i.getConditionalsThenElse(n.conditionalStep).forEach(o=>{Array.isArray(o)?i.generateJsonTranslation(o,t,s):i.generateJsonTranslation([o],t,s);});}),t}};var u=g;exports.translator=u;
@@ -1 +1 @@
1
- var h=class s{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(i=>s._translate(`${i}`)):s._translate(`${e}`)}static set translate(e){s._translate=e;}static addKey(e,i,t){let n=t.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"&&(e[r]=r));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&s.getConditionalsThenElse(e.then,i),e.else&&s.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(t=>{s.getConditionalsThenElse(t,i);});else if(e.elements.type==="ifelse"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else if(e.elements.type==="stepswitch"){let t=[];s.getConditionalsThenElse(e.elements,t),t.forEach(n=>{i.push(...n);});}else s.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&s.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(t=>{s.getConditionalsThenElse(t,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},t={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=s.getConditionalsThenElse(n.choices),r.forEach(l=>l.forEach(o=>{if("type"in o){let g=[];o.type==="ifelse"||o.type==="stepswitch"?s.getConditionalsThenElse(o,g):g=[o],g.map(f=>s.getConditionalsThenElse(f.text)).forEach(f=>{Array.isArray(f)&&f.forEach(a=>{Array.isArray(a)?a.forEach(p=>{typeof p=="string"?s.addKey(i,p,t):s.getConditionalsThenElse(p).forEach(c=>{Array.isArray(c)?c.forEach(T=>{typeof T=="string"&&s.addKey(i,T,t);}):typeof c=="string"&&s.addKey(i,c,t);});}):typeof a=="string"&&s.addKey(i,a,t);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=s.getConditionalsThenElse(n.dialogue),r.forEach(l=>{typeof l=="string"?s.addKey(i,l,t):"text"in l&&Array.isArray(l.text)&&l.text.forEach(o=>{typeof o=="string"?s.addKey(i,o,t):s.getConditionalsThenElse(o).forEach(y=>{typeof y=="string"?s.addKey(i,y,t):Array.isArray(y)&&y.forEach(f=>{typeof f=="string"?s.addKey(i,f,t):s.getConditionalsThenElse(f).forEach(a=>{typeof a=="string"&&s.addKey(i,a,t);});});});});});}n.conditionalStep&&s.getConditionalsThenElse(n.conditionalStep).forEach(l=>{Array.isArray(l)?s.generateJsonTranslation(l,i,t):s.generateJsonTranslation([l],i,t);});}),i}};var C=h;export{C as translator};
1
+ var g=class i{static _beforeToTranslate=void 0;static _translate=e=>e;static _afterToTranslate=void 0;static t(e){return Array.isArray(e)?e.map(t=>i.translate(`${t}`)):i.translate(`${e}`)}static set beforeToTranslate(e){i._beforeToTranslate=e;}static set translate(e){i._translate=e;}static get translate(){return e=>{let t="";return i._beforeToTranslate&&(t=i._beforeToTranslate(e)),t=i._translate(t),i._afterToTranslate&&(t=i._afterToTranslate(t)),t}}static set afterToTranslate(e){i._afterToTranslate=e;}static addKey(e,t,s){let n=s.defaultValue||"empty_string";typeof t=="string"&&(t=[t]),Array.isArray(t)&&t.forEach(r=>{e[r]===void 0&&(n==="empty_string"?e[r]="":n==="copy_key"&&(i._beforeToTranslate?e[r]=i._beforeToTranslate(r):e[r]=r));});}static getConditionalsThenElse(e,t=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&i.getConditionalsThenElse(e.then,t),e.else&&i.getConditionalsThenElse(e.else,t);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(s=>{i.getConditionalsThenElse(s,t);});else if(e.elements.type==="ifelse"){let s=[];i.getConditionalsThenElse(e.elements,s),s.forEach(n=>{t.push(...n);});}else if(e.elements.type==="stepswitch"){let s=[];i.getConditionalsThenElse(e.elements,s),s.forEach(n=>{t.push(...n);});}else i.getConditionalsThenElse(e.elements,t);}else e.type==="resulttocombine"?(e.firstItem&&i.getConditionalsThenElse(e.firstItem,t),e.secondConditionalItem&&e.secondConditionalItem.forEach(s=>{i.getConditionalsThenElse(s,t);})):t.push(e);else e&&t.push(e);return t}static generateJsonTranslation(e,t={},s={}){return e.forEach(n=>{if(n.choices){let r=[];Array.isArray(n.choices)?r=[n.choices]:r=i.getConditionalsThenElse(n.choices),r.forEach(o=>o.forEach(a=>{if("type"in a){let T=[];a.type==="ifelse"||a.type==="stepswitch"?i.getConditionalsThenElse(a,T):T=[a],T.map(l=>i.getConditionalsThenElse(l.text)).forEach(l=>{Array.isArray(l)&&l.forEach(f=>{Array.isArray(f)?f.forEach(h=>{typeof h=="string"?i.addKey(t,h,s):i.getConditionalsThenElse(h).forEach(c=>{Array.isArray(c)?c.forEach(p=>{typeof p=="string"&&i.addKey(t,p,s);}):typeof c=="string"&&i.addKey(t,c,s);});}):typeof f=="string"&&i.addKey(t,f,s);});});}}));}if(n.dialogue){let r=[];Array.isArray(n.dialogue)?r=[n.dialogue]:r=i.getConditionalsThenElse(n.dialogue),r.forEach(o=>{typeof o=="string"?i.addKey(t,o,s):"text"in o&&Array.isArray(o.text)&&o.text.forEach(a=>{typeof a=="string"?i.addKey(t,a,s):i.getConditionalsThenElse(a).forEach(y=>{typeof y=="string"?i.addKey(t,y,s):Array.isArray(y)&&y.forEach(l=>{typeof l=="string"?i.addKey(t,l,s):i.getConditionalsThenElse(l).forEach(f=>{typeof f=="string"&&i.addKey(t,f,s);});});});});});}n.conditionalStep&&i.getConditionalsThenElse(n.conditionalStep).forEach(o=>{Array.isArray(o)?i.generateJsonTranslation(o,t,s):i.generateJsonTranslation([o],t,s);});}),t}};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.0.9",
3
+ "version": "1.0.11",
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",