@drincs/pixi-vn-ink 0.13.0 → 0.13.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.
@@ -13,6 +13,6 @@ import {a,c,b as b$1,e,d,f as f$1}from'./chunk-M7O5Q75X.mjs';import {PixiError,c
13
13
  `+B+"}";}}return i.pop(),s=B,r}function m(A){if(A.length===0)return F(A);let B=String.fromCodePoint(A.codePointAt(0));if(!R.isIdStartChar(B))return F(A);for(let a=B.length;a<A.length;a++)if(!R.isIdContinueChar(String.fromCodePoint(A.codePointAt(a))))return F(A);return A}function y(A){if(i.indexOf(A)>=0)throw TypeError("Converting circular structure to JSON5");i.push(A);let B=s;s=s+c;let a=[];for(let r=0;r<A.length;r++){let l=D(String(r),A);a.push(l!==void 0?l:"null");}let o;if(a.length===0)o="[]";else if(c==="")o="["+a.join(",")+"]";else {let r=`,
14
14
  `+s,l=a.join(r);o=`[
15
15
  `+s+l+`,
16
- `+B+"]";}return i.pop(),s=B,o}},pn={parse:un,stringify:ln},cn=pn,Je=cn;var Bt="\xA7SPACE\xA7",bt="\xA7DOUBLE_QUOTES\xA7",Tt="\xA7QUOTES\xA7",Vt="SPECIAL_\xA7QUOTES\xA7",St="\xA7CURLY_BRACKETS1\xA7",vt="\xA7CURLY_BRACKETS2\xA7",ge=class{};c(ge,"handlers",[t=>false]);var ke;(B=>{async function e(a,o){let r=ge.handlers;for(let l=0;l<r.length;l++)try{let p=await r[l](a,o,F);if(p===!0||typeof p=="string")return p}catch{}return false}function t(a){ge.handlers.push(a);}B.add=t;function u(){ge.handlers=[];}B.clear=u;async function n(a,o,r){try{a=a.replaceAll('\\"',bt),a=a.replaceAll("\\'",Tt),a=a.replaceAll("\\`",Vt),a=a.replaceAll("\\{",St),a=a.replaceAll("\\}",vt),a=a.replaceAll("{"," { "),a=a.replaceAll("}"," } "),a=a.replaceAll(St,"{"),a=a.replaceAll(vt,"}");let l=[],p,E="";for(let J=0;J<a.length;J++){let j=a[J];j==='"'||j==="'"||j==="`"?p===void 0?(l.push(E),E="",p=j,E+=j):p===j?(p=void 0,E+=j,l.push(E),E=""):E+=j:E+=j;}E!==""&&l.push(E),l.forEach((J,j)=>{j%2===1&&(l[j]=J.replaceAll(" ",Bt));}),a=l.join(""),l=a.split(" ").filter(J=>J!==""),l=l.map(J=>J.replaceAll(Bt," ").replaceAll(bt,'"').replaceAll(Tt,"'").replaceAll(Vt,"`"));let T=await e(l,r);if(T===!0)return;if(typeof T=="string")return T.startsWith("#")&&(T=T.substring(1)),B.run(T,o,r);let _=l.length>1?y(l[1]):"",w=l.length>0?y(l[0]):"";switch(_){case "image":case "imagecontainer":case "canvaselement":case "video":case "text":return _==="video"&&(w==="pause"||w==="resume")?{type:"video",operationType:w,alias:y(l[2])}:i(l,_);case "sound":case "allsound":case "channel":return c(l,_);case "input":if(w==="request"){let J={type:"input",operationType:"request"};if(l.length>2)try{let j=l.slice(2),q=F(j);"type"in q&&typeof q.type=="string"&&(J.valueType=q.type),"default"in q&&(J.defaultValue=q.default);}catch{}return J}break;case "assets":case "bundle":switch(w){case "load":case "lazyload":return {type:_,operationType:w,aliases:l.slice(2)}}break;default:if(_)switch(w){case "call":case "jump":o.labelToOpen={label:_,type:w},o.goNextStep=void 0;return;case "shake":let J={};if(l.length>2)try{J=F(l.slice(2));}catch{}return {alias:_,type:w,props:J};case "animate":let q={},$e={};if(l.length>2){let se=l.slice(2),ze=[];if(se.includes("options")){let Be=se.indexOf("options");ze=se.slice(Be+1),se=se.slice(0,Be);}try{q=F(se);}catch{}if(ze.length>0)try{$e=F(ze);}catch{}}return {alias:_,type:w,keyframes:q,options:$e}}else switch(w){case "pause":return "dialogue"in o&&delete o.dialogue,"goNextStep"in o&&delete o.goNextStep,{type:"dialogue",operationType:"clean"};case "continue":o.goNextStep=!0,o.glueEnabled=!1;return}}}catch(l){throw d.error("Error parsing ink hashtag-command",a),l}d.error("The operation is not valid",a);}B.run=n;function i(a,o){let r=y(a[0]),l=y(a[2]),p=h(a.slice(3));switch(r){case "show":switch(o){case "image":case "video":return s(o,l,p);case "imagecontainer":return C(o,l,p);case "text":return d$1(o,l,p);default:d.error("This show operation is not valid for this type of element",o);}case "edit":return {type:o,operationType:"edit",alias:l,props:m(p)};case "remove":let T={type:o,operationType:"remove",alias:l};if(p.length>1&&p[0]==="with"){let _=a[a.indexOf("with")+1],w=a.slice(a.indexOf("with")+2),J=D(_,w);J!==void 0&&(T.transition=J);}return T;default:d.error("The operation type is not valid",r);}}function s(a,o,r){let l,p;return r.length%2===0?(l=o,p=r):(l=y(r[0]),p=r.slice(1)),g({type:a,operationType:"show",alias:o,url:l},p)}function d$1(a,o,r){let l,p;return r.length%2===0?(l=o,p=r):(l=y(r[0]),p=r.slice(1)),g({type:a,operationType:"show",alias:o,text:l},p)}function C(a,o,r){let l=[],p=r.findIndex(w=>w.startsWith("[")),E=r.findIndex(w=>w.endsWith("]"));if(p===-1||E===-1){d.error("Show imagecontainer must have a list of image ulrs",r);return}if(l=r.slice(p,E+1),l.length<2){d.error("Show imagecontainer must have a list of image ulrs",r);return}l[0]==="["?l.shift():l[0]=l[0].substring(1),l[l.length-1]==="]"?l.pop():l[l.length-1]=l[l.length-1].substring(0,l[l.length-1].length-1);let T={type:a,operationType:"show",alias:o,urls:l.map(w=>y(w))},_=r.slice(E+1);return g(T,_)}function c(a,o){let r=y(a[0]),l=y(a[2]);switch(r){case "play":let p=h(a.slice(3)),E,T;p.length%2===0?(E=l,T=p):(E=y(p[0]),T=p.slice(1));let _={type:"sound",operationType:"play",alias:l};if(E&&(_.url=E),a.length>3){let He=F(T);He!==void 0&&(_.props=He);}return _;case "pause":case "resume":return {type:o==="allsound"?"all":o,operationType:r,alias:l};case "stop":case "remove":return {type:"sound",operationType:"stop",alias:l};case "edit":return {type:"sound",operationType:"edit",alias:l,props:F(a.slice(3))};case "volume":let q=parseFloat(a[3]);return {type:"sound",operationType:"edit",alias:l,props:{volume:q}}}}function g(a,o){if(o.length>0){if(o.includes("with")&&o.length>o.indexOf("with")+1){let r=o[o.indexOf("with")+1],l=o.slice(o.indexOf("with")+2);o=o.slice(0,o.indexOf("with"));let p=D(r,l);p!==void 0&&(a.transition=p);}if(o.length>0){let r=m(o);a.props=r;}}return a}function D(a,o){switch(a){case "dissolve":case "fade":case "movein":case "moveout":case "zoomin":case "zoomout":case "pushin":case "pushout":break;default:return}let r={type:a};if(o.length>0)try{let l=m(o);r.props=l;}catch{}return r}function F(a){let o=h(a);return m(o)}function h(a){let o=[],r=0,l="";for(let p=0;p<a.length;p++){let E=a[p];E.startsWith("{")?(r++,l+=E):E.endsWith("}")&&r>0?(r--,l+=E,r===0&&(o.push(l),l="")):r>0?l+=E:o.push(E);}return o}function m(a){if(a.length===0)return {};if(a.length%2!==0)throw d.error("The props list must have a pair number of elements",a),new Error("The props list must have a pair number of elements");let o="{";a.forEach((r,l)=>{if(l%2===0)o+=`"${r}": `;else {switch(r){case "null":case "undefined":case "true":case "false":o+=`${r}`;break;default:A(r)?(r=y(r),o+=`"${r}"`):r.startsWith("{")&&r.endsWith("}")?o+=`${r}`:r.startsWith('"')&&r.endsWith('"')?o+=`${r}`:isNaN(parseFloat(r))?o+=`"${r}"`:o+=`${r}`;}l<a.length-1&&(o+=", ");}}),o+="}";try{return Je.parse(o)}catch(r){throw d.error("Error parsing ink json",o),r}}function y(a){return a.startsWith('"')&&a.endsWith('"')||a.startsWith("'")&&a.endsWith("'")||a.startsWith("`")&&a.endsWith("`")?a.substring(1,a.length-1):a}function A(a){return !!(a.startsWith('"')&&a.endsWith('"')||a.startsWith("'")&&a.endsWith("'")||a.startsWith("`")&&a.endsWith("`"))}})(ke||(ke={}));var he=ke;function Dn(e){ke.add(e);}var De=class{};c(De,"handlers",[]);var nt;(n=>{function e(i){De.handlers.push(i);}n.add=e;function t(){De.handlers=[];}n.clear=t;function u(i,s,d=0){if(d>=De.handlers.length)return s(i);let C=De.handlers[d];return C(i,c=>u(c,s,d+1))}n.getLogichValue=u;})(nt||(nt={}));var Le=nt;var Dt=b$1(e(),1);var _e="global decl",oe="___external_value___";function xe(e,t){if(e.endsWith(".s"))return;if(new RegExp(/.*\.[0-9]+\..*$/).test(e)&&(e=e.split(".").filter(i=>!i.match(/^[0-9]+$/)).join("."),!e.startsWith(".")))return e.replaceAll(".","_|_");if(!new RegExp(/^\.\^.*$/).test(e)&&e.includes("g-")){let n=e.split("g-");return rt(t)+"_|_"+"g-"+n[n.length-1]}let u=0;for(;new RegExp(/^\.\^.*$/).test(e);)u++,e=e.substring(2);if(u=u-1,new RegExp(/^\..*$/).test(e)&&t){let n=e.substring(1);return rt(t,u)+"_|_"+n.replaceAll(".","_|_")}return e.replaceAll(".","_|_")||rt(t,u).replaceAll(".","_|_")}function rt(e,t=0){let u=e.split("_|_");for(;u.length>1&&t>0;)u.pop()?.includes("g-")&&t--,t--;return u.join("_|_")}var wt="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function ee(e){return e.startsWith("^")&&(e=e.substring(1)),e=e.replaceAll("\\\\",wt),e=e.replaceAll("\\n",`
16
+ `+B+"]";}return i.pop(),s=B,o}},pn={parse:un,stringify:ln},cn=pn,Je=cn;var Bt="\xA7SPACE\xA7",bt="\xA7DOUBLE_QUOTES\xA7",Tt="\xA7QUOTES\xA7",Vt="SPECIAL_\xA7QUOTES\xA7",St="\xA7CURLY_BRACKETS1\xA7",vt="\xA7CURLY_BRACKETS2\xA7",ge=class{};c(ge,"handlers",[t=>false]);var ke;(B=>{async function e(a,o){let r=ge.handlers;for(let l=0;l<r.length;l++)try{let p=await r[l](a,o,F);if(p===!0||typeof p=="string")return p}catch{}return false}function t(a){ge.handlers.push(a);}B.add=t;function u(){ge.handlers=[];}B.clear=u;async function n(a,o,r){try{a=a.replaceAll('\\"',bt),a=a.replaceAll("\\'",Tt),a=a.replaceAll("\\`",Vt),a=a.replaceAll("\\{",St),a=a.replaceAll("\\}",vt),a=a.replaceAll("{"," { "),a=a.replaceAll("}"," } "),a=a.replaceAll(St,"{"),a=a.replaceAll(vt,"}");let l=[],p,E="";for(let J=0;J<a.length;J++){let j=a[J];j==='"'||j==="'"||j==="`"?p===void 0?(l.push(E),E="",p=j,E+=j):p===j?(p=void 0,E+=j,l.push(E),E=""):E+=j:E+=j;}E!==""&&l.push(E),l.forEach((J,j)=>{j%2===1&&(l[j]=J.replaceAll(" ",Bt));}),a=l.join(""),l=a.split(" ").filter(J=>J!==""),l=l.map(J=>J.replaceAll(Bt," ").replaceAll(bt,'"').replaceAll(Tt,"'").replaceAll(Vt,"`"));let T=await e(l,r);if(T===!0)return;if(typeof T=="string")return T.startsWith("#")&&(T=T.substring(1)),B.run(T,o,r);let _=l.length>1?y(l[1]):"",w=l.length>0?y(l[0]):"";switch(_){case "image":case "imagecontainer":case "canvaselement":case "video":case "text":return _==="video"&&(w==="pause"||w==="resume")?{type:"video",operationType:w,alias:y(l[2])}:i(l,_);case "sound":case "allsounds":case "channel":return c(l,_);case "input":if(w==="request"){let J={type:"input",operationType:"request"};if(l.length>2)try{let j=l.slice(2),q=F(j);"type"in q&&typeof q.type=="string"&&(J.valueType=q.type),"default"in q&&(J.defaultValue=q.default);}catch{}return J}break;case "assets":case "bundle":switch(w){case "load":case "lazyload":return {type:_,operationType:w,aliases:l.slice(2)}}break;default:if(_)switch(w){case "call":case "jump":o.labelToOpen={label:_,type:w},o.goNextStep=void 0;return;case "shake":let J={};if(l.length>2)try{J=F(l.slice(2));}catch{}return {alias:_,type:w,props:J};case "animate":let q={},$e={};if(l.length>2){let se=l.slice(2),ze=[];if(se.includes("options")){let Be=se.indexOf("options");ze=se.slice(Be+1),se=se.slice(0,Be);}try{q=F(se);}catch{}if(ze.length>0)try{$e=F(ze);}catch{}}return {alias:_,type:w,keyframes:q,options:$e}}else switch(w){case "pause":return "dialogue"in o&&delete o.dialogue,"goNextStep"in o&&delete o.goNextStep,{type:"dialogue",operationType:"clean"};case "continue":o.goNextStep=!0,o.glueEnabled=!1;return}}}catch(l){throw d.error("Error parsing ink hashtag-command",a),l}d.error("The operation is not valid",a);}B.run=n;function i(a,o){let r=y(a[0]),l=y(a[2]),p=h(a.slice(3));switch(r){case "show":switch(o){case "image":case "video":return s(o,l,p);case "imagecontainer":return C(o,l,p);case "text":return d$1(o,l,p);default:d.error("This show operation is not valid for this type of element",o);}case "edit":return {type:o,operationType:"edit",alias:l,props:m(p)};case "remove":let T={type:o,operationType:"remove",alias:l};if(p.length>1&&p[0]==="with"){let _=a[a.indexOf("with")+1],w=a.slice(a.indexOf("with")+2),J=D(_,w);J!==void 0&&(T.transition=J);}return T;default:d.error("The operation type is not valid",r);}}function s(a,o,r){let l,p;return r.length%2===0?(l=o,p=r):(l=y(r[0]),p=r.slice(1)),g({type:a,operationType:"show",alias:o,url:l},p)}function d$1(a,o,r){let l,p;return r.length%2===0?(l=o,p=r):(l=y(r[0]),p=r.slice(1)),g({type:a,operationType:"show",alias:o,text:l},p)}function C(a,o,r){let l=[],p=r.findIndex(w=>w.startsWith("[")),E=r.findIndex(w=>w.endsWith("]"));if(p===-1||E===-1){d.error("Show imagecontainer must have a list of image ulrs",r);return}if(l=r.slice(p,E+1),l.length<2){d.error("Show imagecontainer must have a list of image ulrs",r);return}l[0]==="["?l.shift():l[0]=l[0].substring(1),l[l.length-1]==="]"?l.pop():l[l.length-1]=l[l.length-1].substring(0,l[l.length-1].length-1);let T={type:a,operationType:"show",alias:o,urls:l.map(w=>y(w))},_=r.slice(E+1);return g(T,_)}function c(a,o){let r=y(a[0]),l=y(a[2]);switch(r){case "play":let p=h(a.slice(3)),E,T;p.length%2===0?(E=l,T=p):(E=y(p[0]),T=p.slice(1));let _={type:"sound",operationType:"play",alias:l};if(E&&(_.url=E),a.length>3){let He=F(T);He!==void 0&&(_.props=He);}return _;case "pause":case "resume":return {type:o==="allsounds"?"all":o,operationType:r,alias:l};case "stop":case "remove":return {type:"sound",operationType:"stop",alias:l};case "edit":return {type:"sound",operationType:"edit",alias:l,props:F(a.slice(3))};case "volume":let q=parseFloat(a[3]);return {type:"sound",operationType:"edit",alias:l,props:{volume:q}}}}function g(a,o){if(o.length>0){if(o.includes("with")&&o.length>o.indexOf("with")+1){let r=o[o.indexOf("with")+1],l=o.slice(o.indexOf("with")+2);o=o.slice(0,o.indexOf("with"));let p=D(r,l);p!==void 0&&(a.transition=p);}if(o.length>0){let r=m(o);a.props=r;}}return a}function D(a,o){switch(a){case "dissolve":case "fade":case "movein":case "moveout":case "zoomin":case "zoomout":case "pushin":case "pushout":break;default:return}let r={type:a};if(o.length>0)try{let l=m(o);r.props=l;}catch{}return r}function F(a){let o=h(a);return m(o)}function h(a){let o=[],r=0,l="";for(let p=0;p<a.length;p++){let E=a[p];E.startsWith("{")?(r++,l+=E):E.endsWith("}")&&r>0?(r--,l+=E,r===0&&(o.push(l),l="")):r>0?l+=E:o.push(E);}return o}function m(a){if(a.length===0)return {};if(a.length%2!==0)throw d.error("The props list must have a pair number of elements",a),new Error("The props list must have a pair number of elements");let o="{";a.forEach((r,l)=>{if(l%2===0)o+=`"${r}": `;else {switch(r){case "null":case "undefined":case "true":case "false":o+=`${r}`;break;default:A(r)?(r=y(r),o+=`"${r}"`):r.startsWith("{")&&r.endsWith("}")?o+=`${r}`:r.startsWith('"')&&r.endsWith('"')?o+=`${r}`:isNaN(parseFloat(r))?o+=`"${r}"`:o+=`${r}`;}l<a.length-1&&(o+=", ");}}),o+="}";try{return Je.parse(o)}catch(r){throw d.error("Error parsing ink json",o),r}}function y(a){return a.startsWith('"')&&a.endsWith('"')||a.startsWith("'")&&a.endsWith("'")||a.startsWith("`")&&a.endsWith("`")?a.substring(1,a.length-1):a}function A(a){return !!(a.startsWith('"')&&a.endsWith('"')||a.startsWith("'")&&a.endsWith("'")||a.startsWith("`")&&a.endsWith("`"))}})(ke||(ke={}));var he=ke;function Dn(e){ke.add(e);}var De=class{};c(De,"handlers",[]);var nt;(n=>{function e(i){De.handlers.push(i);}n.add=e;function t(){De.handlers=[];}n.clear=t;function u(i,s,d=0){if(d>=De.handlers.length)return s(i);let C=De.handlers[d];return C(i,c=>u(c,s,d+1))}n.getLogichValue=u;})(nt||(nt={}));var Le=nt;var Dt=b$1(e(),1);var _e="global decl",oe="___external_value___";function xe(e,t){if(e.endsWith(".s"))return;if(new RegExp(/.*\.[0-9]+\..*$/).test(e)&&(e=e.split(".").filter(i=>!i.match(/^[0-9]+$/)).join("."),!e.startsWith(".")))return e.replaceAll(".","_|_");if(!new RegExp(/^\.\^.*$/).test(e)&&e.includes("g-")){let n=e.split("g-");return rt(t)+"_|_"+"g-"+n[n.length-1]}let u=0;for(;new RegExp(/^\.\^.*$/).test(e);)u++,e=e.substring(2);if(u=u-1,new RegExp(/^\..*$/).test(e)&&t){let n=e.substring(1);return rt(t,u)+"_|_"+n.replaceAll(".","_|_")}return e.replaceAll(".","_|_")||rt(t,u).replaceAll(".","_|_")}function rt(e,t=0){let u=e.split("_|_");for(;u.length>1&&t>0;)u.pop()?.includes("g-")&&t--,t--;return u.join("_|_")}var wt="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function ee(e){return e.startsWith("^")&&(e=e.substring(1)),e=e.replaceAll("\\\\",wt),e=e.replaceAll("\\n",`
17
17
  `),e=e.replaceAll("\\t"," "),e=e.replaceAll(" "," "),e=e.replaceAll(wt,"\\\\"),e}var Pt=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],Ot=["+","-","/","*","%","POW","RANDOM"],Nt=["INT","FLOOR","FLOAT"],Jt=["==",">","<",">=","<=","!=","CONTAINS"];function de(e,t,u){e=e.map(i=>{if(typeof i=="string"){if(i==="rnd")return "RANDOM";if(i==="?")return "CONTAINS"}return i});let n=[];return e.forEach(i=>{if(typeof i=="object"&&"CNT?"in i)if(new RegExp(/.*\.[0-9]\..*/).test(i["CNT?"])){let s=i["CNT?"].split("."),d$1=s.pop(),C=s.pop();if(C===void 0||d$1===void 0){d.error("Error parsing ink file: Conditional statement is not valid",e);return}let c=parseInt(C),g=s.join(".");if(g.includes("^.")){let F=g.split("."),h=F[F.length-1].replaceAll(".","_|_");F.pop(),g=F.join(".")+"."+h,d$1.includes("c-")&&(g=g+"_|_"+d$1);}else g=g.replaceAll(".","_|_");let D=xe(g,t);if(!D)return;n.push({type:"compare",leftValue:kt(D),operator:">=",rightValue:{type:"value",value:c}});}else {let s=xe(i["CNT?"],t);if(!s)return;n.push(kt(s));}else if(typeof i=="object"&&"VAR?"in i)n.push(Ce(i["VAR?"],u));else if(i==="&&"||i==="||"){if(n.length>=2){let s={type:"union",unionType:i==="&&"?"and":"or",conditions:[n[n.length-2],n[n.length-1]]};n.pop(),n.pop(),n.push(s);}}else if(i==="!")if(n.length===0)d.error("Error parsing ink file: Conditional statement is not valid",e);else {let s={type:"union",unionType:"not",condition:n[n.length-1]};n[n.length-1]=s;}else if(i&&typeof i=="string"&&Jt.includes(i))if(n.length<2)d.error("Error parsing ink file: Conditional statement is not valid",e);else {let s={type:"compare",operator:i,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(s);}else if(i&&typeof i=="string"&&Ot.includes(i))if(n.length<2)d.error("Error parsing ink file: Conditional statement is not valid",e);else {let s={type:"arithmetic",operator:i,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(s);}else if(i&&typeof i=="string"&&Nt.includes(i)){let s={type:"arithmeticsingle",operator:i,leftValue:n[n.length-1]};n.pop(),n.push(s);}else i&&typeof i=="string"?i.startsWith("^")&&n.push(ee(i)):typeof i=="object"&&"^->"in i?i["^->"].includes("$r")||n.push(i["^->"]):n.push(i);}),n}function kt(e){return {type:"value",storageType:"label",storageOperationType:"get",label:e}}function Lt(e,t,u){return de(e,t,u)}function Ce(e,t,u="storage"){let n=t.indexOf(e);return n>=0?{type:"value",storageType:"params",storageOperationType:"get",key:n}:{type:"value",storageOperationType:"get",storageType:u,key:e}}function it(e,t,u,n="storage"){let i=t.indexOf(e);return i>=0?{type:"value",storageType:"params",storageOperationType:"set",key:i,value:u}:{type:"value",storageOperationType:"set",storageType:n,key:e,value:u}}function ot(e,t){return t||new RegExp(`${"_|_".replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c-\\d+$`).test(e)?"call":"jump"}function Re(e,t){t&&(typeof t=="string"?t.startsWith("^")&&e.push(ee(t)):typeof t=="object"&&"type"in t&&t.type!=="value"&&e.push(t));}function at(e,t,u,n,i={}){let{isNewLine:s=true,isHashtagScript:d=false,isThreads:C=false}=i;return gn(e,t,u,n,{isNewLine:s,isHashtagScript:d,isThreads:C})}function gn(e,t,u,n,i){if(!t)return;let{isNewLine:s,isHashtagScript:d=false,isThreads:C}=i;if(d)Array.isArray(t)&&t.length>0&&e.push({operations:[{type:"operationtoconvert",values:t}],goNextStep:true});else if(typeof t=="string"&&t.startsWith("^")||t&&typeof t=="object"&&"type"in t&&t.type=="value"&&t.storageOperationType==="get"){if(!s&&e.length>0){let c=e[e.length-1];!c.glueEnabled&&!c.operations&&(c.glueEnabled=true,c.labelToOpen||(c.goNextStep=true)),e[e.length-1]=c;}typeof t=="string"?e.push(hn(ee(t))):e.push({dialogue:t});}else if(typeof t=="string"){if(t==="end")e.push({end:"game_end"});else if(t==="done")e.push({end:"label_end",goNextStep:true});else if(t=="<>")if(e.length>0){let c=e[e.length-1];c.glueEnabled=true,c.labelToOpen||(c.goNextStep=true),e[e.length-1]=c;}else e.push({glueEnabled:true,goNextStep:false});}else if(typeof t=="object"){if("type"in t&&t.type!=="value"){if(!s&&e.length>0){let c=e[e.length-1];!c.glueEnabled&&!c.operations&&(c.glueEnabled=true,c.labelToOpen||(c.goNextStep=true)),e[e.length-1]=c;}e.push({conditionalStep:t});}else if("->"in t){let c=s?void 0:true;if(c&&u.includes("c-")&&e.length>0&&e[e.length-1]?.dialogue===void 0&&(c=void 0),!s&&e.length>0){let g=e[e.length-1];g.labelToOpen||(g.goNextStep=true),e[e.length-1]=g;}if(t.params&&t.params.length===0&&delete t.params,t.var)e.push({labelToOpen:{label:Ce(t["->"],n),type:C?"call":"jump",params:t.params},glueEnabled:c});else {let g=xe(t["->"],u);if(!g)return;e.push({labelToOpen:{label:g,type:ot(g,C),params:t.params},glueEnabled:c});}}"type"in t&&t.type=="value"&&t.storageOperationType==="set"&&(typeof t.value=="string"&&t.value.startsWith("^")&&(t.value=ee(t.value)),e.push({goNextStep:true,operations:[t]}));}}function hn(e){let t;if(e.includes(": ")){let u=e.split(": "),n=u[0],i=u.slice(1).join(": ");RegisteredCharacters.get(n)&&(t=n,e=i);}return t?{dialogue:{character:t,text:e}}:{dialogue:e}}function st(e,t,u,n=true,i=false){return dn(e,t,u,n,i)}function dn(e,t,u,n,i=false){t&&(typeof t=="string"&&t.startsWith("^")||t&&typeof t=="object"&&"type"in t&&t.type=="value"&&t.storageOperationType==="get"?typeof t=="string"?e.push(ee(t)):e.push(t):typeof t=="object"&&"type"in t&&e.push(t));}function je(e,t,u){if(e.length===0){d.error("Error parsing ink file: Arithmetic statement is not valid",e);return}let n=de(e,t,u);if(n.length===1){let i=n[0];return i&&typeof i=="object"&&"type"in i?{type:"value",storageType:"logic",storageOperationType:"get",operation:i}:i}}function Ae(e,t,u,n="",i,s,d=void 0){let C=[],c="sequential",g=false,D=true;e.forEach(m=>{m==="%"&&(c="loop"),m==="seq"&&(c="random"),m==="MIN"&&(g=true);});let F=e[e.length-1];return Object.keys(F).forEach(m=>{let y=F[m];if(Array.isArray(y)&&y.length>3){y=y.slice(1,y.length-2);let A=[];ae(y,n,i,A,t,t,u,Ee,d,true,s),A.length===1?C.push(A[0]):C.push({type:"resulttocombine",combine:"cross",secondConditionalItem:A});}else Array.isArray(y)&&y.length===3&&(D=false);}),c==="sequential"?{type:"stepswitch",elements:C,choiceType:c,end:D?"lastItem":void 0,nestedId:d}:g&&c==="random"?{type:"stepswitch",elements:C,choiceType:"sequentialrandom",end:D?"lastItem":void 0,nestedId:d}:{type:"stepswitch",elements:C,choiceType:c}}function lt(e="",t=""){let u=Array.isArray(e)?e:[e],n=Array.isArray(t)?t:[t];return [...new Set([...u,...n])]}function Ee(e,t,u,n,i){if(e.length>0){let s={};_t(e,s,i);for(let[d$1,C]of Object.entries(s)){let c=u+"_|_"+d$1,g={text:C.text.length===1?C.text[0]:C.text,label:c,props:{},type:ot(c,false),oneTime:C.onetime};C.text.length===0&&(g.onlyHaveNoChoice=true,g.autoSelect=true),g.oneTime===false&&delete g.oneTime;let D=pt(g,C.conditions,i,u)||g,F=t[t.length-1];if(typeof F=="object"&&F&&"type"in F&&(F={conditionalStep:F}),t.length>0&&typeof F=="object"&&F&&"choices"in F&&F.choices){let h=F.choices;h&&Array.isArray(h)?h.push(D):d.error("Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",C,h),F.choices=h.sort((m,y)=>{try{let A=m.label.split("."),B=A[A.length-1].replaceAll(".","_|_"),a=y.label.split("."),o=a[a.length-1].replaceAll(".","_|_");if(B.includes("c-")&&o.includes("c-")){let r=B.split("c-")[1],l=parseInt(r),p=o.split("c-")[1],E=parseInt(p);return l-E}}catch{}return 0});}else t.push({choices:[D]});C.preDialog&&(n.preDialog[c]={...C.preDialog});}}}function _t(e,t,u,n){let i=[],s="",d="",C=false,c=[];for(let g=0;g<e.length;g++){let D=e[g];if(typeof D=="string")D.startsWith("^")?i.push(ee(D)):Pt.includes(D)&&c.push(D);else if(Array.isArray(D)&&D.includes("visit")){let F=Ae(D,Re,(h,m,y)=>{},n,{preDialog:{}},u);i.push(F);}else if(D&&typeof D=="object")if("*"in D&&typeof D["*"]&&typeof D["*"]=="string")D["*"].includes("c")&&(s="c"+D["*"].split("c")[1],D.flg&16&&(C=true));else if("s"in D&&D.s instanceof Array){let F=Rt(D.s),h=D.s.includes("<>");F&&(n&&t[n]?(t[n].preDialog={text:F,glue:h},t[n].text=lt(F,t[n].text)):(i.push(F),d=F));}else "CNT?"in D&&c.push(D);else c.push(D);if(s){t[s]?t[s].text=lt(i,t[s].text):t[s]={text:i,onetime:C,conditions:c},d&&(t[s].preDialog={text:d,glue:false});let F=e.slice(g+1);_t(F,t,u,s);return}}}function Rt(e){for(let t of e)if(typeof t=="string"){if(t.startsWith("^"))return ee(t)}else if(t instanceof Array){let u=Rt(t);if(u)return u}}function pt(e,t,u,n,i){if(t.length===0)return;let s=de(t,n,u);if(s.length===1){let d={type:"ifelse",condition:s[0],then:e,else:i};return d.else||delete d.else,d}else if(s.length>1){let d={type:"ifelse",condition:{type:"union",unionType:"and",conditions:s},then:e,else:i};return d.else||delete d.else,d}}function jt(e,t,u,n,i,s,d$1=void 0){if(e.length===0){d.error("Error parsing ink file: Conditional statement is not valid",e);return}let C=[],c=[];if(e.forEach(F=>{Array.isArray(F)?c.push(F):typeof F=="string"&&F==="du"?i.du?C.push(i.du):i.du=C[C.length-1]:(typeof F!="string"||F!=="/ev")&&C.push(F);}),c.length===0){d.error("Error parsing ink file: Conditional statement is not valid",c);return}let g=ct(c[0],t,u,n+"_|_"+"then",i,s,`${d$1||""}then`),D;return c.length===2?D=ct(c[1],t,u,n+"_|_"+"else",i,s,`${d$1||""}else`):c.length>2&&(c.shift(),c.push("nop"),c=[{b:c}],D=ct(c,t,u,n+"_|_"+"else",i,s,`${d$1||""}else`)),i.du=void 0,pt(g,C,s,n,D)}function ct(e,t,u,n,i,s,d=void 0){let C=[];for(let g of e)typeof g=="object"&&"b"in g&&(g.b=g.b.filter(D=>D!==null&&!(typeof D=="object"&&"->"in D&&new RegExp(/.*\.[0-9]/).test(D["->"]))),ae(g.b,n,i,C,t,t,u,Ee,d,true,s));return C.length===1?C[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:C}}function ae(e,t,u,n=[],i,s,d$1,C,c=void 0,g=true,D=[]){let F=false,h=[],m=false,y=false,A=false,B=[],a=[];if(u.preDialog[t]&&(g=false,i(n,"^"+u.preDialog[t].text,t,D,{isNewLine:g,isHashtagScript:y,isThreads:A}),u.preDialog[t].glue&&i(n,"<>",t,D,{isNewLine:g,isHashtagScript:y,isThreads:A}),delete u.preDialog[t]),e.includes("visit")){let r=Ae(e,s,d$1,t,u,D,c);r&&(!g&&n.length>0&&i(n,"<>",t,D,{isNewLine:g,isHashtagScript:y,isThreads:A}),i(n,r,t,D,{isNewLine:g,isHashtagScript:y,isThreads:A}));return}let o=e[0];if(o&&typeof o=="object"&&"temp="in o){for(;e[0]&&typeof e[0]=="object"&&"temp="in e[0];)D.push(e[0]["temp="]),e.shift();D=D.reverse();}if(e.forEach((r,l)=>{if(y){if(typeof r=="string"&&r=="/#"){let p=[];ae(a,t,u,p,st,st,d$1,C,c,g),i(n,p,t,D,{isNewLine:g,isHashtagScript:y,isThreads:A}),y=false,a=[];}else a.push(r);return}else if(F)if(Array.isArray(r))h.push(r);else if(r&&typeof r=="object")if("CNT?"in r)l>0&&e[l-1]=="ev"?(m=true,B.push(r)):m?B.push(r):(h.push(r),g=false);else if("VAR="in r||"temp="in r){let p=it("VAR="in r?r["VAR="]:r["temp="],D,e[l-1],"VAR="in r?"storage":"tempstorage");if(p.value&&typeof p.value=="string"&&p.value=="/str"&&(p.value=e[l-2]),p.value&&typeof p.value=="object"&&"^->"in p.value&&(p.value=p.value["^->"]),h.length>1){let E=je(h,t,D);h=[],E&&typeof E=="object"&&"type"in E&&E.type=="value"&&"storageType"in E&&E.storageType=="logic"&&(p.value=E.operation);}(typeof p.key!="string"||!p.key.includes("$r"))&&(i(n,p,t,D,{isNewLine:g,isHashtagScript:y,isThreads:A}),g=true);}else "VAR?"in r?h.push(r):"^->"in r&&(r["^->"].includes("$r")||h.push(r));else if(typeof r=="string"&&r=="/ev")m&&B.push(r),F=false,h.push(r);else if(typeof r=="string"&&r=="out"){if(h.length>0){let p=h[h.length-1];if(p&&typeof p=="object"&&"VAR?"in p){h.pop();let E=Ce(p["VAR?"],D,"storage");i(n,E,t,D,{isNewLine:g,isHashtagScript:y,isThreads:A});}else {let E=[];for(;h.length>0&&h[h.length-1]!="/ev";)E.push(h.pop());E=E.reverse();let T=je(E,t,D);h=[],T&&typeof T=="object"&&"type"in T&&T.type=="value"&&"storageType"in T&&T.storageType=="logic"?i(n,{storageOperationType:"get",storageType:"logic",operation:T.operation,type:"value"},t,D,{isNewLine:g,isHashtagScript:y,isThreads:A}):(i(n,"<>",t,D,{isNewLine:g,isHashtagScript:y,isThreads:A}),T=`^${T}`,i(n,T,t,D,{isNewLine:g,isHashtagScript:y,isThreads:A}));}g=false;}}else h.push(r);else if(typeof r=="string")if(r.startsWith("^"))i(n,r,t,D,{isNewLine:g,isHashtagScript:y,isThreads:A}),g=false;else if(r=="ev")F=true;else if(r==`
18
18
  `)g=true;else if(r=="done"||r=="end")i(n,r,t,D,{isNewLine:g,isHashtagScript:y,isThreads:A}),g=false;else if(r=="<>")i(n,r,t,D,{isNewLine:g,isHashtagScript:y,isThreads:A}),g=false;else if(r=="nop"&&m){let p=jt(B,s,d$1,t,u,D,c);p&&i(n,p,t,D,{isNewLine:g,isHashtagScript:y,isThreads:A}),m=false,B=[];}else r=="#"?y=true:r=="thread"&&(A=true);else if(r instanceof Array)if(m)B.push(r);else if(r.length>1&&typeof r[r.length-2]=="object"&&r[r.length-2]&&"c"in r[r.length-2]&&typeof r[r.length-1]=="object"&&r[r.length-1]&&"b"in r[r.length-1]){h.pop();let p=[],E=[];for(;h.length>0&&h[h.length-1]!="/ev";)p.push(h.pop());B=[...B,...p.reverse()],m=true,E.push(r.pop()),E.push(r.pop()),B=[...B,...r],B.push(E);}else if(r.length>1&&typeof r[r.length-1]=="object"&&r[r.length-1]&&"#n"in r[r.length-1]){let p=r.pop();if(!p){d.error("Error parsing ink file: el is undefined");return}let E=p["#n"];delete p["#n"],r.push(p),i(n,{"->":t?t+"_|_"+E:E},t,D,{isNewLine:g,isHashtagScript:y,isThreads:A}),d$1({[E]:r},t,u);}else ae(r,t,u,n,i,s,d$1,C,c,g,D);else if(r&&typeof r=="object")if("->"in r&&typeof r["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(r["->"])){let p=[];h.length>0&&(p=Lt(["ev",...h],t,D)),r.params=p,i(n,r,t,D,{isNewLine:g,isHashtagScript:y,isThreads:A}),g=false;}else if("*"in r&&typeof r["*"]=="string")r["*"].includes("c")&&(h.push(r),g=false);else if("s"in r&&r.s instanceof Array)h.push(r),g=false;else if("CNT?"in r)h.push(r),g=false;else if("VAR="in r||"temp="in r){let p=[],E=it("VAR="in r?r["VAR="]:r["temp="],D,void 0,"VAR="in r?"storage":"tempstorage");if(E.key!=="$r"){for(h.pop(),h[h.length-1]=="/ev"&&h.pop();h.length>0&&h[h.length-1]!="/ev";)p.push(h.pop());p=p.reverse(),E.value=je(p,t,D),h=[],(E.value!==void 0||E.value!==null)&&i(n,E,t,D,{isNewLine:g,isHashtagScript:y,isThreads:A}),g=false;}}else d$1(r,t,u);}),C(h,n,t,u,D),t.includes("_|_")&&n.length==2){let r=n[0],l=n[1];r&&l&&typeof r=="object"&&"dialogue"in r&&typeof l=="object"&&"labelToOpen"in l&&r.dialogue==" "&&l.labelToOpen&&(n.shift(),delete l.glueEnabled,n[0]=l);}}function It(e){try{let t={};return $t(e,t),t}catch(t){d.error("Error parsing ink file",t);}}function $t(e,t,u={externalSwitch:void 0}){for(let n of e)if(n)if(n instanceof Array)if(n.includes("visit")){let i=Ae(n,Re,(s,d,C)=>{},"",{preDialog:{}},[]);i&&(u.externalSwitch=i);}else $t(n,t,u);else typeof n=="object"&&(n&&"VAR="in n&&u.externalSwitch&&(t[oe]||(t[oe]=[]),t[oe].push({operations:[{type:"value",value:u.externalSwitch,key:n["VAR="],storageType:"storage",storageOperationType:"set"}]})),Ht(n,t));}function Ht(e,t,u="",n={preDialog:{}}){if(e!==null){for(let[i,s]of Object.entries(e))if(s instanceof Array){let d=[],C={},c=(u?u+"_|_":"")+i;ae(s,c,n,d,at,at,(g,D,F)=>{Ht(g,C,D,F);},Ee);for(let[g,D]of Object.entries(C))t[g]=D;d.length>0&&(t[c]=d);}}}function Ie(e){let{json:t,labelToRemove:u,issues:n,initialVarsToRemove:i}=f$1(e);if(n.forEach(({message:d$1,type:C})=>{C===Dt.ErrorType.Error?d.error("Ink compilation error: "+d$1):C===Dt.ErrorType.Warning?d.warn("Ink compilation warning: "+d$1):d.info("Ink compilation info: "+d$1);}),!t){d.error("No JSON generated from ink file");return}let s;try{s=Je.parse(t);}catch{d.error("Error parsing ink file");return}return zt(s,{labelToRemove:u,initialVarsToRemove:i})}function zt(e,t={}){let{labelToRemove:u=[],initialVarsToRemove:n=[]}=t,i={};if(i.labels=It(e.root),i.labels&&_e in i.labels){let s=i.labels[_e];delete i.labels[_e],s.forEach(d=>{d.operations&&(i.initialOperations=i.initialOperations?[...i.initialOperations,...d.operations]:[...d.operations]);});}if(i.labels&&oe in i.labels){let s=i.labels[oe];delete i.labels[oe],s.forEach(d=>{d.operations&&(i.initialOperations=i.initialOperations?[...i.initialOperations,...d.operations]:[...d.operations]);});}return u.forEach(s=>{i.labels&&s in i.labels&&delete i.labels[s];}),n.forEach(s=>{i.initialOperations&&(i.initialOperations=i.initialOperations.filter(d=>!(d.type==="value"&&d.key===s)));}),i}async function Cn(e){Array.isArray(e)||(e=[e]),Qe({getLogichValue:(u,n)=>Le.getLogichValue(u,n)});let t=e.map(async u=>{let n=Ie(u);return n&&await qe(n,{operationStringConvert:he.run,skipEmptyDialogs:true}),u});return await Promise.all(t)}async function An(e){return Qe({getLogichValue:(t,u)=>Le.getLogichValue(t,u)}),await qe(e,{operationStringConvert:he.run,skipEmptyDialogs:true})}function En(e){I.afterToTranslate=t=>ft(t,e);}function Fn(e){I.beforeToTranslate=t=>ft(t,e);}function ft(e,t){let u=e.match(/\[([^\]]+)\]/);if(u){let n=u[1],i=t(n);return i&&(e=e.replaceAll(u[0],i)),ft(e,t)}return e}function yn(e){I.translate=e;}async function mn(e,t={},u={}){let n=[];return e.labels&&Object.values(e.labels).forEach(i=>{n=n.concat(i);}),await I.generateJsonTranslation(n,t,{...u,operationStringConvert:he.run})}export{he as a,Dn as b,Le as c,Ie as d,zt as e,Cn as f,An as g,En as h,Fn as i,yn as j,mn as k};
package/dist/index.cjs CHANGED
@@ -56,7 +56,7 @@ Error:${h}`);}return u!=null&&(l=new r(u,s,this._externalErrorHandler,this._root
56
56
  `+A+"}";}}return i.pop(),a=A,c}function y(E){if(E.length===0)return d(E);let A=String.fromCodePoint(E.codePointAt(0));if(!Z.isIdStartChar(A))return d(E);for(let f=A.length;f<E.length;f++)if(!Z.isIdContinueChar(String.fromCodePoint(E.codePointAt(f))))return d(E);return E}function v(E){if(i.indexOf(E)>=0)throw TypeError("Converting circular structure to JSON5");i.push(E);let A=a;a=a+l;let f=[];for(let c=0;c<E.length;c++){let C=h(String(c),E);f.push(C!==void 0?C:"null");}let p;if(f.length===0)p="[]";else if(l==="")p="["+f.join(",")+"]";else {let c=`,
57
57
  `+a,C=f.join(c);p=`[
58
58
  `+a+C+`,
59
- `+A+"]";}return i.pop(),a=A,p}},Ld={parse:Td,stringify:Rd},Bd=Ld,Ei=Bd;var L;(i=>(i.log=(a,...s)=>console.log(`[Pixi\u2019VN Ink] ${a}`,...s),i.warn=(a,...s)=>console.warn(`[Pixi\u2019VN Ink] ${a}`,...s),i.error=(a,...s)=>console.error(`[Pixi\u2019VN Ink] ${a}`,...s),i.info=(a,...s)=>console.info(`[Pixi\u2019VN Ink] ${a}`,...s)))(L||(L={}));var Ql="\xA7SPACE\xA7",Zl="\xA7DOUBLE_QUOTES\xA7",eu="\xA7QUOTES\xA7",tu="SPECIAL_\xA7QUOTES\xA7",nu="\xA7CURLY_BRACKETS1\xA7",iu="\xA7CURLY_BRACKETS2\xA7",Gt=class{};ci(Gt,"handlers",[e=>false]);var Di;(A=>{async function r(f,p){let c=Gt.handlers;for(let C=0;C<c.length;C++)try{let m=await c[C](f,p,d);if(m===!0||typeof m=="string")return m}catch{}return false}function e(f){Gt.handlers.push(f);}A.add=e;function t(){Gt.handlers=[];}A.clear=t;async function n(f,p,c){try{f=f.replaceAll('\\"',Zl),f=f.replaceAll("\\'",eu),f=f.replaceAll("\\`",tu),f=f.replaceAll("\\{",nu),f=f.replaceAll("\\}",iu),f=f.replaceAll("{"," { "),f=f.replaceAll("}"," } "),f=f.replaceAll(nu,"{"),f=f.replaceAll(iu,"}");let C=[],m,D="";for(let O=0;O<f.length;O++){let q=f[O];q==='"'||q==="'"||q==="`"?m===void 0?(C.push(D),D="",m=q,D+=q):m===q?(m=void 0,D+=q,C.push(D),D=""):D+=q:D+=q;}D!==""&&C.push(D),C.forEach((O,q)=>{q%2===1&&(C[q]=O.replaceAll(" ",Ql));}),f=C.join(""),C=f.split(" ").filter(O=>O!==""),C=C.map(O=>O.replaceAll(Ql," ").replaceAll(Zl,'"').replaceAll(eu,"'").replaceAll(tu,"`"));let w=await r(C,c);if(w===!0)return;if(typeof w=="string")return w.startsWith("#")&&(w=w.substring(1)),A.run(w,p,c);let j=C.length>1?v(C[1]):"",P=C.length>0?v(C[0]):"";switch(j){case "image":case "imagecontainer":case "canvaselement":case "video":case "text":return j==="video"&&(P==="pause"||P==="resume")?{type:"video",operationType:P,alias:v(C[2])}:i(C,j);case "sound":case "allsound":case "channel":return l(C,j);case "input":if(P==="request"){let O={type:"input",operationType:"request"};if(C.length>2)try{let q=C.slice(2),ue=d(q);"type"in ue&&typeof ue.type=="string"&&(O.valueType=ue.type),"default"in ue&&(O.defaultValue=ue.default);}catch{}return O}break;case "assets":case "bundle":switch(P){case "load":case "lazyload":return {type:j,operationType:P,aliases:C.slice(2)}}break;default:if(j)switch(P){case "call":case "jump":p.labelToOpen={label:j,type:P},p.goNextStep=void 0;return;case "shake":let O={};if(C.length>2)try{O=d(C.slice(2));}catch{}return {alias:j,type:P,props:O};case "animate":let ue={},qt={};if(C.length>2){let Ge=C.slice(2),zs=[];if(Ge.includes("options")){let hi=Ge.indexOf("options");zs=Ge.slice(hi+1),Ge=Ge.slice(0,hi);}try{ue=d(Ge);}catch{}if(zs.length>0)try{qt=d(zs);}catch{}}return {alias:j,type:P,keyframes:ue,options:qt}}else switch(P){case "pause":return "dialogue"in p&&delete p.dialogue,"goNextStep"in p&&delete p.goNextStep,{type:"dialogue",operationType:"clean"};case "continue":p.goNextStep=!0,p.glueEnabled=!1;return}}}catch(C){throw L.error("Error parsing ink hashtag-command",f),C}L.error("The operation is not valid",f);}A.run=n;function i(f,p){let c=v(f[0]),C=v(f[2]),m=g(f.slice(3));switch(c){case "show":switch(p){case "image":case "video":return a(p,C,m);case "imagecontainer":return o(p,C,m);case "text":return s(p,C,m);default:L.error("This show operation is not valid for this type of element",p);}case "edit":return {type:p,operationType:"edit",alias:C,props:y(m)};case "remove":let w={type:p,operationType:"remove",alias:C};if(m.length>1&&m[0]==="with"){let j=f[f.indexOf("with")+1],P=f.slice(f.indexOf("with")+2),O=h(j,P);O!==void 0&&(w.transition=O);}return w;default:L.error("The operation type is not valid",c);}}function a(f,p,c){let C,m;return c.length%2===0?(C=p,m=c):(C=v(c[0]),m=c.slice(1)),u({type:f,operationType:"show",alias:p,url:C},m)}function s(f,p,c){let C,m;return c.length%2===0?(C=p,m=c):(C=v(c[0]),m=c.slice(1)),u({type:f,operationType:"show",alias:p,text:C},m)}function o(f,p,c){let C=[],m=c.findIndex(P=>P.startsWith("[")),D=c.findIndex(P=>P.endsWith("]"));if(m===-1||D===-1){L.error("Show imagecontainer must have a list of image ulrs",c);return}if(C=c.slice(m,D+1),C.length<2){L.error("Show imagecontainer must have a list of image ulrs",c);return}C[0]==="["?C.shift():C[0]=C[0].substring(1),C[C.length-1]==="]"?C.pop():C[C.length-1]=C[C.length-1].substring(0,C[C.length-1].length-1);let w={type:f,operationType:"show",alias:p,urls:C.map(P=>v(P))},j=c.slice(D+1);return u(w,j)}function l(f,p){let c=v(f[0]),C=v(f[2]);switch(c){case "play":let m=g(f.slice(3)),D,w;m.length%2===0?(D=C,w=m):(D=v(m[0]),w=m.slice(1));let j={type:"sound",operationType:"play",alias:C};if(D&&(j.url=D),f.length>3){let ct=d(w);ct!==void 0&&(j.props=ct);}return j;case "pause":case "resume":return {type:p==="allsound"?"all":p,operationType:c,alias:C};case "stop":case "remove":return {type:"sound",operationType:"stop",alias:C};case "edit":return {type:"sound",operationType:"edit",alias:C,props:d(f.slice(3))};case "volume":let ue=parseFloat(f[3]);return {type:"sound",operationType:"edit",alias:C,props:{volume:ue}}}}function u(f,p){if(p.length>0){if(p.includes("with")&&p.length>p.indexOf("with")+1){let c=p[p.indexOf("with")+1],C=p.slice(p.indexOf("with")+2);p=p.slice(0,p.indexOf("with"));let m=h(c,C);m!==void 0&&(f.transition=m);}if(p.length>0){let c=y(p);f.props=c;}}return f}function h(f,p){switch(f){case "dissolve":case "fade":case "movein":case "moveout":case "zoomin":case "zoomout":case "pushin":case "pushout":break;default:return}let c={type:f};if(p.length>0)try{let C=y(p);c.props=C;}catch{}return c}function d(f){let p=g(f);return y(p)}function g(f){let p=[],c=0,C="";for(let m=0;m<f.length;m++){let D=f[m];D.startsWith("{")?(c++,C+=D):D.endsWith("}")&&c>0?(c--,C+=D,c===0&&(p.push(C),C="")):c>0?C+=D:p.push(D);}return p}function y(f){if(f.length===0)return {};if(f.length%2!==0)throw L.error("The props list must have a pair number of elements",f),new Error("The props list must have a pair number of elements");let p="{";f.forEach((c,C)=>{if(C%2===0)p+=`"${c}": `;else {switch(c){case "null":case "undefined":case "true":case "false":p+=`${c}`;break;default:E(c)?(c=v(c),p+=`"${c}"`):c.startsWith("{")&&c.endsWith("}")?p+=`${c}`:c.startsWith('"')&&c.endsWith('"')?p+=`${c}`:isNaN(parseFloat(c))?p+=`"${c}"`:p+=`${c}`;}C<f.length-1&&(p+=", ");}}),p+="}";try{return Ei.parse(p)}catch(c){throw L.error("Error parsing ink json",p),c}}function v(f){return f.startsWith('"')&&f.endsWith('"')||f.startsWith("'")&&f.endsWith("'")||f.startsWith("`")&&f.endsWith("`")?f.substring(1,f.length-1):f}function E(f){return !!(f.startsWith('"')&&f.endsWith('"')||f.startsWith("'")&&f.endsWith("'")||f.startsWith("`")&&f.endsWith("`"))}})(Di||(Di={}));var $t=Di;function Wd(r){Di.add(r);}var Ft=class{};ci(Ft,"handlers",[]);var ca;(n=>{function r(i){Ft.handlers.push(i);}n.add=r;function e(){Ft.handlers=[];}n.clear=e;function t(i,a,s=0){if(s>=Ft.handlers.length)return a(i);let o=Ft.handlers[s];return o(i,l=>t(l,a,s+1))}n.getLogichValue=t;})(ca||(ca={}));var Si=ca;var ql=Ys(Jt());var Ai="global decl",ft="___external_value___";var Yh=Ys(Xh()),Qh=Ys(Jt());function li(r,e=[],t=[]){let n=[];try{return {json:new Yh.Compiler(r,{errorHandler:(o,l)=>{n.push({message:o,type:l});},countAllVisits:!0,fileHandler:{ResolveInkFilename:o=>o,LoadInkFileContents:()=>""},pluginNames:[],sourceFilename:null}).Compile().ToJson()||"",issues:n,labelToRemove:e,initialVarsToRemove:t}}catch(i){let a=n.find(s=>s.type===Qh.ErrorType.Error);if(a){if(a.message.includes("Divert target not found")){let s=a.message.match(/Divert target not found: '-> (\w+)'/);if(s&&s[1]){let o=s[1],l=`
59
+ `+A+"]";}return i.pop(),a=A,p}},Ld={parse:Td,stringify:Rd},Bd=Ld,Ei=Bd;var L;(i=>(i.log=(a,...s)=>console.log(`[Pixi\u2019VN Ink] ${a}`,...s),i.warn=(a,...s)=>console.warn(`[Pixi\u2019VN Ink] ${a}`,...s),i.error=(a,...s)=>console.error(`[Pixi\u2019VN Ink] ${a}`,...s),i.info=(a,...s)=>console.info(`[Pixi\u2019VN Ink] ${a}`,...s)))(L||(L={}));var Ql="\xA7SPACE\xA7",Zl="\xA7DOUBLE_QUOTES\xA7",eu="\xA7QUOTES\xA7",tu="SPECIAL_\xA7QUOTES\xA7",nu="\xA7CURLY_BRACKETS1\xA7",iu="\xA7CURLY_BRACKETS2\xA7",Gt=class{};ci(Gt,"handlers",[e=>false]);var Di;(A=>{async function r(f,p){let c=Gt.handlers;for(let C=0;C<c.length;C++)try{let m=await c[C](f,p,d);if(m===!0||typeof m=="string")return m}catch{}return false}function e(f){Gt.handlers.push(f);}A.add=e;function t(){Gt.handlers=[];}A.clear=t;async function n(f,p,c){try{f=f.replaceAll('\\"',Zl),f=f.replaceAll("\\'",eu),f=f.replaceAll("\\`",tu),f=f.replaceAll("\\{",nu),f=f.replaceAll("\\}",iu),f=f.replaceAll("{"," { "),f=f.replaceAll("}"," } "),f=f.replaceAll(nu,"{"),f=f.replaceAll(iu,"}");let C=[],m,D="";for(let O=0;O<f.length;O++){let q=f[O];q==='"'||q==="'"||q==="`"?m===void 0?(C.push(D),D="",m=q,D+=q):m===q?(m=void 0,D+=q,C.push(D),D=""):D+=q:D+=q;}D!==""&&C.push(D),C.forEach((O,q)=>{q%2===1&&(C[q]=O.replaceAll(" ",Ql));}),f=C.join(""),C=f.split(" ").filter(O=>O!==""),C=C.map(O=>O.replaceAll(Ql," ").replaceAll(Zl,'"').replaceAll(eu,"'").replaceAll(tu,"`"));let w=await r(C,c);if(w===!0)return;if(typeof w=="string")return w.startsWith("#")&&(w=w.substring(1)),A.run(w,p,c);let j=C.length>1?v(C[1]):"",P=C.length>0?v(C[0]):"";switch(j){case "image":case "imagecontainer":case "canvaselement":case "video":case "text":return j==="video"&&(P==="pause"||P==="resume")?{type:"video",operationType:P,alias:v(C[2])}:i(C,j);case "sound":case "allsounds":case "channel":return l(C,j);case "input":if(P==="request"){let O={type:"input",operationType:"request"};if(C.length>2)try{let q=C.slice(2),ue=d(q);"type"in ue&&typeof ue.type=="string"&&(O.valueType=ue.type),"default"in ue&&(O.defaultValue=ue.default);}catch{}return O}break;case "assets":case "bundle":switch(P){case "load":case "lazyload":return {type:j,operationType:P,aliases:C.slice(2)}}break;default:if(j)switch(P){case "call":case "jump":p.labelToOpen={label:j,type:P},p.goNextStep=void 0;return;case "shake":let O={};if(C.length>2)try{O=d(C.slice(2));}catch{}return {alias:j,type:P,props:O};case "animate":let ue={},qt={};if(C.length>2){let Ge=C.slice(2),zs=[];if(Ge.includes("options")){let hi=Ge.indexOf("options");zs=Ge.slice(hi+1),Ge=Ge.slice(0,hi);}try{ue=d(Ge);}catch{}if(zs.length>0)try{qt=d(zs);}catch{}}return {alias:j,type:P,keyframes:ue,options:qt}}else switch(P){case "pause":return "dialogue"in p&&delete p.dialogue,"goNextStep"in p&&delete p.goNextStep,{type:"dialogue",operationType:"clean"};case "continue":p.goNextStep=!0,p.glueEnabled=!1;return}}}catch(C){throw L.error("Error parsing ink hashtag-command",f),C}L.error("The operation is not valid",f);}A.run=n;function i(f,p){let c=v(f[0]),C=v(f[2]),m=g(f.slice(3));switch(c){case "show":switch(p){case "image":case "video":return a(p,C,m);case "imagecontainer":return o(p,C,m);case "text":return s(p,C,m);default:L.error("This show operation is not valid for this type of element",p);}case "edit":return {type:p,operationType:"edit",alias:C,props:y(m)};case "remove":let w={type:p,operationType:"remove",alias:C};if(m.length>1&&m[0]==="with"){let j=f[f.indexOf("with")+1],P=f.slice(f.indexOf("with")+2),O=h(j,P);O!==void 0&&(w.transition=O);}return w;default:L.error("The operation type is not valid",c);}}function a(f,p,c){let C,m;return c.length%2===0?(C=p,m=c):(C=v(c[0]),m=c.slice(1)),u({type:f,operationType:"show",alias:p,url:C},m)}function s(f,p,c){let C,m;return c.length%2===0?(C=p,m=c):(C=v(c[0]),m=c.slice(1)),u({type:f,operationType:"show",alias:p,text:C},m)}function o(f,p,c){let C=[],m=c.findIndex(P=>P.startsWith("[")),D=c.findIndex(P=>P.endsWith("]"));if(m===-1||D===-1){L.error("Show imagecontainer must have a list of image ulrs",c);return}if(C=c.slice(m,D+1),C.length<2){L.error("Show imagecontainer must have a list of image ulrs",c);return}C[0]==="["?C.shift():C[0]=C[0].substring(1),C[C.length-1]==="]"?C.pop():C[C.length-1]=C[C.length-1].substring(0,C[C.length-1].length-1);let w={type:f,operationType:"show",alias:p,urls:C.map(P=>v(P))},j=c.slice(D+1);return u(w,j)}function l(f,p){let c=v(f[0]),C=v(f[2]);switch(c){case "play":let m=g(f.slice(3)),D,w;m.length%2===0?(D=C,w=m):(D=v(m[0]),w=m.slice(1));let j={type:"sound",operationType:"play",alias:C};if(D&&(j.url=D),f.length>3){let ct=d(w);ct!==void 0&&(j.props=ct);}return j;case "pause":case "resume":return {type:p==="allsounds"?"all":p,operationType:c,alias:C};case "stop":case "remove":return {type:"sound",operationType:"stop",alias:C};case "edit":return {type:"sound",operationType:"edit",alias:C,props:d(f.slice(3))};case "volume":let ue=parseFloat(f[3]);return {type:"sound",operationType:"edit",alias:C,props:{volume:ue}}}}function u(f,p){if(p.length>0){if(p.includes("with")&&p.length>p.indexOf("with")+1){let c=p[p.indexOf("with")+1],C=p.slice(p.indexOf("with")+2);p=p.slice(0,p.indexOf("with"));let m=h(c,C);m!==void 0&&(f.transition=m);}if(p.length>0){let c=y(p);f.props=c;}}return f}function h(f,p){switch(f){case "dissolve":case "fade":case "movein":case "moveout":case "zoomin":case "zoomout":case "pushin":case "pushout":break;default:return}let c={type:f};if(p.length>0)try{let C=y(p);c.props=C;}catch{}return c}function d(f){let p=g(f);return y(p)}function g(f){let p=[],c=0,C="";for(let m=0;m<f.length;m++){let D=f[m];D.startsWith("{")?(c++,C+=D):D.endsWith("}")&&c>0?(c--,C+=D,c===0&&(p.push(C),C="")):c>0?C+=D:p.push(D);}return p}function y(f){if(f.length===0)return {};if(f.length%2!==0)throw L.error("The props list must have a pair number of elements",f),new Error("The props list must have a pair number of elements");let p="{";f.forEach((c,C)=>{if(C%2===0)p+=`"${c}": `;else {switch(c){case "null":case "undefined":case "true":case "false":p+=`${c}`;break;default:E(c)?(c=v(c),p+=`"${c}"`):c.startsWith("{")&&c.endsWith("}")?p+=`${c}`:c.startsWith('"')&&c.endsWith('"')?p+=`${c}`:isNaN(parseFloat(c))?p+=`"${c}"`:p+=`${c}`;}C<f.length-1&&(p+=", ");}}),p+="}";try{return Ei.parse(p)}catch(c){throw L.error("Error parsing ink json",p),c}}function v(f){return f.startsWith('"')&&f.endsWith('"')||f.startsWith("'")&&f.endsWith("'")||f.startsWith("`")&&f.endsWith("`")?f.substring(1,f.length-1):f}function E(f){return !!(f.startsWith('"')&&f.endsWith('"')||f.startsWith("'")&&f.endsWith("'")||f.startsWith("`")&&f.endsWith("`"))}})(Di||(Di={}));var $t=Di;function Wd(r){Di.add(r);}var Ft=class{};ci(Ft,"handlers",[]);var ca;(n=>{function r(i){Ft.handlers.push(i);}n.add=r;function e(){Ft.handlers=[];}n.clear=e;function t(i,a,s=0){if(s>=Ft.handlers.length)return a(i);let o=Ft.handlers[s];return o(i,l=>t(l,a,s+1))}n.getLogichValue=t;})(ca||(ca={}));var Si=ca;var ql=Ys(Jt());var Ai="global decl",ft="___external_value___";var Yh=Ys(Xh()),Qh=Ys(Jt());function li(r,e=[],t=[]){let n=[];try{return {json:new Yh.Compiler(r,{errorHandler:(o,l)=>{n.push({message:o,type:l});},countAllVisits:!0,fileHandler:{ResolveInkFilename:o=>o,LoadInkFileContents:()=>""},pluginNames:[],sourceFilename:null}).Compile().ToJson()||"",issues:n,labelToRemove:e,initialVarsToRemove:t}}catch(i){let a=n.find(s=>s.type===Qh.ErrorType.Error);if(a){if(a.message.includes("Divert target not found")){let s=a.message.match(/Divert target not found: '-> (\w+)'/);if(s&&s[1]){let o=s[1],l=`
60
60
 
61
61
  === ${o} ===
62
62
 
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export{a as HashtagCommands,c as VariableGetter,e as convertInkStoryToJson,d as convertInkText,d as convertInkToJson,k as generateJsonInkTranslation,f as importInkText,g as importJson,b as onInkHashtagScript,j as onInkTranslate,h as onReplaceTextAfterTranslation,i as onReplaceTextBeforeTranslation}from'./chunk-CYTZWQOB.mjs';import'./chunk-M7O5Q75X.mjs';
1
+ export{a as HashtagCommands,c as VariableGetter,e as convertInkStoryToJson,d as convertInkText,d as convertInkToJson,k as generateJsonInkTranslation,f as importInkText,g as importJson,b as onInkHashtagScript,j as onInkTranslate,h as onReplaceTextAfterTranslation,i as onReplaceTextBeforeTranslation}from'./chunk-BEGZMB57.mjs';import'./chunk-M7O5Q75X.mjs';
@@ -56,7 +56,7 @@ Error:${h}`);}return u!=null&&(l=new r(u,s,this._externalErrorHandler,this._root
56
56
  `+A+"}";}}return i.pop(),a=A,c}function y(E){if(E.length===0)return d(E);let A=String.fromCodePoint(E.codePointAt(0));if(!Z.isIdStartChar(A))return d(E);for(let f=A.length;f<E.length;f++)if(!Z.isIdContinueChar(String.fromCodePoint(E.codePointAt(f))))return d(E);return E}function v(E){if(i.indexOf(E)>=0)throw TypeError("Converting circular structure to JSON5");i.push(E);let A=a;a=a+l;let f=[];for(let c=0;c<E.length;c++){let C=h(String(c),E);f.push(C!==void 0?C:"null");}let p;if(f.length===0)p="[]";else if(l==="")p="["+f.join(",")+"]";else {let c=`,
57
57
  `+a,C=f.join(c);p=`[
58
58
  `+a+C+`,
59
- `+A+"]";}return i.pop(),a=A,p}},Ld={parse:Td,stringify:Rd},Bd=Ld,vi=Bd;var L;(i=>(i.log=(a,...s)=>console.log(`[Pixi\u2019VN Ink] ${a}`,...s),i.warn=(a,...s)=>console.warn(`[Pixi\u2019VN Ink] ${a}`,...s),i.error=(a,...s)=>console.error(`[Pixi\u2019VN Ink] ${a}`,...s),i.info=(a,...s)=>console.info(`[Pixi\u2019VN Ink] ${a}`,...s)))(L||(L={}));var Ql="\xA7SPACE\xA7",Zl="\xA7DOUBLE_QUOTES\xA7",eu="\xA7QUOTES\xA7",tu="SPECIAL_\xA7QUOTES\xA7",nu="\xA7CURLY_BRACKETS1\xA7",iu="\xA7CURLY_BRACKETS2\xA7",Gt=class{};hi(Gt,"handlers",[e=>false]);var oa;(A=>{async function r(f,p){let c=Gt.handlers;for(let C=0;C<c.length;C++)try{let m=await c[C](f,p,d);if(m===!0||typeof m=="string")return m}catch{}return false}function e(f){Gt.handlers.push(f);}A.add=e;function t(){Gt.handlers=[];}A.clear=t;async function n(f,p,c){try{f=f.replaceAll('\\"',Zl),f=f.replaceAll("\\'",eu),f=f.replaceAll("\\`",tu),f=f.replaceAll("\\{",nu),f=f.replaceAll("\\}",iu),f=f.replaceAll("{"," { "),f=f.replaceAll("}"," } "),f=f.replaceAll(nu,"{"),f=f.replaceAll(iu,"}");let C=[],m,D="";for(let O=0;O<f.length;O++){let q=f[O];q==='"'||q==="'"||q==="`"?m===void 0?(C.push(D),D="",m=q,D+=q):m===q?(m=void 0,D+=q,C.push(D),D=""):D+=q:D+=q;}D!==""&&C.push(D),C.forEach((O,q)=>{q%2===1&&(C[q]=O.replaceAll(" ",Ql));}),f=C.join(""),C=f.split(" ").filter(O=>O!==""),C=C.map(O=>O.replaceAll(Ql," ").replaceAll(Zl,'"').replaceAll(eu,"'").replaceAll(tu,"`"));let w=await r(C,c);if(w===!0)return;if(typeof w=="string")return w.startsWith("#")&&(w=w.substring(1)),A.run(w,p,c);let j=C.length>1?v(C[1]):"",P=C.length>0?v(C[0]):"";switch(j){case "image":case "imagecontainer":case "canvaselement":case "video":case "text":return j==="video"&&(P==="pause"||P==="resume")?{type:"video",operationType:P,alias:v(C[2])}:i(C,j);case "sound":case "allsound":case "channel":return l(C,j);case "input":if(P==="request"){let O={type:"input",operationType:"request"};if(C.length>2)try{let q=C.slice(2),le=d(q);"type"in le&&typeof le.type=="string"&&(O.valueType=le.type),"default"in le&&(O.defaultValue=le.default);}catch{}return O}break;case "assets":case "bundle":switch(P){case "load":case "lazyload":return {type:j,operationType:P,aliases:C.slice(2)}}break;default:if(j)switch(P){case "call":case "jump":p.labelToOpen={label:j,type:P},p.goNextStep=void 0;return;case "shake":let O={};if(C.length>2)try{O=d(C.slice(2));}catch{}return {alias:j,type:P,props:O};case "animate":let le={},qt={};if(C.length>2){let Ge=C.slice(2),Us=[];if(Ge.includes("options")){let ui=Ge.indexOf("options");Us=Ge.slice(ui+1),Ge=Ge.slice(0,ui);}try{le=d(Ge);}catch{}if(Us.length>0)try{qt=d(Us);}catch{}}return {alias:j,type:P,keyframes:le,options:qt}}else switch(P){case "pause":return "dialogue"in p&&delete p.dialogue,"goNextStep"in p&&delete p.goNextStep,{type:"dialogue",operationType:"clean"};case "continue":p.goNextStep=!0,p.glueEnabled=!1;return}}}catch(C){throw L.error("Error parsing ink hashtag-command",f),C}L.error("The operation is not valid",f);}A.run=n;function i(f,p){let c=v(f[0]),C=v(f[2]),m=g(f.slice(3));switch(c){case "show":switch(p){case "image":case "video":return a(p,C,m);case "imagecontainer":return o(p,C,m);case "text":return s(p,C,m);default:L.error("This show operation is not valid for this type of element",p);}case "edit":return {type:p,operationType:"edit",alias:C,props:y(m)};case "remove":let w={type:p,operationType:"remove",alias:C};if(m.length>1&&m[0]==="with"){let j=f[f.indexOf("with")+1],P=f.slice(f.indexOf("with")+2),O=h(j,P);O!==void 0&&(w.transition=O);}return w;default:L.error("The operation type is not valid",c);}}function a(f,p,c){let C,m;return c.length%2===0?(C=p,m=c):(C=v(c[0]),m=c.slice(1)),u({type:f,operationType:"show",alias:p,url:C},m)}function s(f,p,c){let C,m;return c.length%2===0?(C=p,m=c):(C=v(c[0]),m=c.slice(1)),u({type:f,operationType:"show",alias:p,text:C},m)}function o(f,p,c){let C=[],m=c.findIndex(P=>P.startsWith("[")),D=c.findIndex(P=>P.endsWith("]"));if(m===-1||D===-1){L.error("Show imagecontainer must have a list of image ulrs",c);return}if(C=c.slice(m,D+1),C.length<2){L.error("Show imagecontainer must have a list of image ulrs",c);return}C[0]==="["?C.shift():C[0]=C[0].substring(1),C[C.length-1]==="]"?C.pop():C[C.length-1]=C[C.length-1].substring(0,C[C.length-1].length-1);let w={type:f,operationType:"show",alias:p,urls:C.map(P=>v(P))},j=c.slice(D+1);return u(w,j)}function l(f,p){let c=v(f[0]),C=v(f[2]);switch(c){case "play":let m=g(f.slice(3)),D,w;m.length%2===0?(D=C,w=m):(D=v(m[0]),w=m.slice(1));let j={type:"sound",operationType:"play",alias:C};if(D&&(j.url=D),f.length>3){let ct=d(w);ct!==void 0&&(j.props=ct);}return j;case "pause":case "resume":return {type:p==="allsound"?"all":p,operationType:c,alias:C};case "stop":case "remove":return {type:"sound",operationType:"stop",alias:C};case "edit":return {type:"sound",operationType:"edit",alias:C,props:d(f.slice(3))};case "volume":let le=parseFloat(f[3]);return {type:"sound",operationType:"edit",alias:C,props:{volume:le}}}}function u(f,p){if(p.length>0){if(p.includes("with")&&p.length>p.indexOf("with")+1){let c=p[p.indexOf("with")+1],C=p.slice(p.indexOf("with")+2);p=p.slice(0,p.indexOf("with"));let m=h(c,C);m!==void 0&&(f.transition=m);}if(p.length>0){let c=y(p);f.props=c;}}return f}function h(f,p){switch(f){case "dissolve":case "fade":case "movein":case "moveout":case "zoomin":case "zoomout":case "pushin":case "pushout":break;default:return}let c={type:f};if(p.length>0)try{let C=y(p);c.props=C;}catch{}return c}function d(f){let p=g(f);return y(p)}function g(f){let p=[],c=0,C="";for(let m=0;m<f.length;m++){let D=f[m];D.startsWith("{")?(c++,C+=D):D.endsWith("}")&&c>0?(c--,C+=D,c===0&&(p.push(C),C="")):c>0?C+=D:p.push(D);}return p}function y(f){if(f.length===0)return {};if(f.length%2!==0)throw L.error("The props list must have a pair number of elements",f),new Error("The props list must have a pair number of elements");let p="{";f.forEach((c,C)=>{if(C%2===0)p+=`"${c}": `;else {switch(c){case "null":case "undefined":case "true":case "false":p+=`${c}`;break;default:E(c)?(c=v(c),p+=`"${c}"`):c.startsWith("{")&&c.endsWith("}")?p+=`${c}`:c.startsWith('"')&&c.endsWith('"')?p+=`${c}`:isNaN(parseFloat(c))?p+=`"${c}"`:p+=`${c}`;}C<f.length-1&&(p+=", ");}}),p+="}";try{return vi.parse(p)}catch(c){throw L.error("Error parsing ink json",p),c}}function v(f){return f.startsWith('"')&&f.endsWith('"')||f.startsWith("'")&&f.endsWith("'")||f.startsWith("`")&&f.endsWith("`")?f.substring(1,f.length-1):f}function E(f){return !!(f.startsWith('"')&&f.endsWith('"')||f.startsWith("'")&&f.endsWith("'")||f.startsWith("`")&&f.endsWith("`"))}})(oa||(oa={}));var Ei=oa;var Ft=class{};hi(Ft,"handlers",[]);var la;(n=>{function r(i){Ft.handlers.push(i);}n.add=r;function e(){Ft.handlers=[];}n.clear=e;function t(i,a,s=0){if(s>=Ft.handlers.length)return a(i);let o=Ft.handlers[s];return o(i,l=>t(l,a,s+1))}n.getLogichValue=t;})(la||(la={}));var ua=la;var Wl=zs($t());var Si="global decl",ft="___external_value___";var Yh=zs(Xh()),Qh=zs($t());function oi(r,e=[],t=[]){let n=[];try{return {json:new Yh.Compiler(r,{errorHandler:(o,l)=>{n.push({message:o,type:l});},countAllVisits:!0,fileHandler:{ResolveInkFilename:o=>o,LoadInkFileContents:()=>""},pluginNames:[],sourceFilename:null}).Compile().ToJson()||"",issues:n,labelToRemove:e,initialVarsToRemove:t}}catch(i){let a=n.find(s=>s.type===Qh.ErrorType.Error);if(a){if(a.message.includes("Divert target not found")){let s=a.message.match(/Divert target not found: '-> (\w+)'/);if(s&&s[1]){let o=s[1],l=`
59
+ `+A+"]";}return i.pop(),a=A,p}},Ld={parse:Td,stringify:Rd},Bd=Ld,vi=Bd;var L;(i=>(i.log=(a,...s)=>console.log(`[Pixi\u2019VN Ink] ${a}`,...s),i.warn=(a,...s)=>console.warn(`[Pixi\u2019VN Ink] ${a}`,...s),i.error=(a,...s)=>console.error(`[Pixi\u2019VN Ink] ${a}`,...s),i.info=(a,...s)=>console.info(`[Pixi\u2019VN Ink] ${a}`,...s)))(L||(L={}));var Ql="\xA7SPACE\xA7",Zl="\xA7DOUBLE_QUOTES\xA7",eu="\xA7QUOTES\xA7",tu="SPECIAL_\xA7QUOTES\xA7",nu="\xA7CURLY_BRACKETS1\xA7",iu="\xA7CURLY_BRACKETS2\xA7",Gt=class{};hi(Gt,"handlers",[e=>false]);var oa;(A=>{async function r(f,p){let c=Gt.handlers;for(let C=0;C<c.length;C++)try{let m=await c[C](f,p,d);if(m===!0||typeof m=="string")return m}catch{}return false}function e(f){Gt.handlers.push(f);}A.add=e;function t(){Gt.handlers=[];}A.clear=t;async function n(f,p,c){try{f=f.replaceAll('\\"',Zl),f=f.replaceAll("\\'",eu),f=f.replaceAll("\\`",tu),f=f.replaceAll("\\{",nu),f=f.replaceAll("\\}",iu),f=f.replaceAll("{"," { "),f=f.replaceAll("}"," } "),f=f.replaceAll(nu,"{"),f=f.replaceAll(iu,"}");let C=[],m,D="";for(let O=0;O<f.length;O++){let q=f[O];q==='"'||q==="'"||q==="`"?m===void 0?(C.push(D),D="",m=q,D+=q):m===q?(m=void 0,D+=q,C.push(D),D=""):D+=q:D+=q;}D!==""&&C.push(D),C.forEach((O,q)=>{q%2===1&&(C[q]=O.replaceAll(" ",Ql));}),f=C.join(""),C=f.split(" ").filter(O=>O!==""),C=C.map(O=>O.replaceAll(Ql," ").replaceAll(Zl,'"').replaceAll(eu,"'").replaceAll(tu,"`"));let w=await r(C,c);if(w===!0)return;if(typeof w=="string")return w.startsWith("#")&&(w=w.substring(1)),A.run(w,p,c);let j=C.length>1?v(C[1]):"",P=C.length>0?v(C[0]):"";switch(j){case "image":case "imagecontainer":case "canvaselement":case "video":case "text":return j==="video"&&(P==="pause"||P==="resume")?{type:"video",operationType:P,alias:v(C[2])}:i(C,j);case "sound":case "allsounds":case "channel":return l(C,j);case "input":if(P==="request"){let O={type:"input",operationType:"request"};if(C.length>2)try{let q=C.slice(2),le=d(q);"type"in le&&typeof le.type=="string"&&(O.valueType=le.type),"default"in le&&(O.defaultValue=le.default);}catch{}return O}break;case "assets":case "bundle":switch(P){case "load":case "lazyload":return {type:j,operationType:P,aliases:C.slice(2)}}break;default:if(j)switch(P){case "call":case "jump":p.labelToOpen={label:j,type:P},p.goNextStep=void 0;return;case "shake":let O={};if(C.length>2)try{O=d(C.slice(2));}catch{}return {alias:j,type:P,props:O};case "animate":let le={},qt={};if(C.length>2){let Ge=C.slice(2),Us=[];if(Ge.includes("options")){let ui=Ge.indexOf("options");Us=Ge.slice(ui+1),Ge=Ge.slice(0,ui);}try{le=d(Ge);}catch{}if(Us.length>0)try{qt=d(Us);}catch{}}return {alias:j,type:P,keyframes:le,options:qt}}else switch(P){case "pause":return "dialogue"in p&&delete p.dialogue,"goNextStep"in p&&delete p.goNextStep,{type:"dialogue",operationType:"clean"};case "continue":p.goNextStep=!0,p.glueEnabled=!1;return}}}catch(C){throw L.error("Error parsing ink hashtag-command",f),C}L.error("The operation is not valid",f);}A.run=n;function i(f,p){let c=v(f[0]),C=v(f[2]),m=g(f.slice(3));switch(c){case "show":switch(p){case "image":case "video":return a(p,C,m);case "imagecontainer":return o(p,C,m);case "text":return s(p,C,m);default:L.error("This show operation is not valid for this type of element",p);}case "edit":return {type:p,operationType:"edit",alias:C,props:y(m)};case "remove":let w={type:p,operationType:"remove",alias:C};if(m.length>1&&m[0]==="with"){let j=f[f.indexOf("with")+1],P=f.slice(f.indexOf("with")+2),O=h(j,P);O!==void 0&&(w.transition=O);}return w;default:L.error("The operation type is not valid",c);}}function a(f,p,c){let C,m;return c.length%2===0?(C=p,m=c):(C=v(c[0]),m=c.slice(1)),u({type:f,operationType:"show",alias:p,url:C},m)}function s(f,p,c){let C,m;return c.length%2===0?(C=p,m=c):(C=v(c[0]),m=c.slice(1)),u({type:f,operationType:"show",alias:p,text:C},m)}function o(f,p,c){let C=[],m=c.findIndex(P=>P.startsWith("[")),D=c.findIndex(P=>P.endsWith("]"));if(m===-1||D===-1){L.error("Show imagecontainer must have a list of image ulrs",c);return}if(C=c.slice(m,D+1),C.length<2){L.error("Show imagecontainer must have a list of image ulrs",c);return}C[0]==="["?C.shift():C[0]=C[0].substring(1),C[C.length-1]==="]"?C.pop():C[C.length-1]=C[C.length-1].substring(0,C[C.length-1].length-1);let w={type:f,operationType:"show",alias:p,urls:C.map(P=>v(P))},j=c.slice(D+1);return u(w,j)}function l(f,p){let c=v(f[0]),C=v(f[2]);switch(c){case "play":let m=g(f.slice(3)),D,w;m.length%2===0?(D=C,w=m):(D=v(m[0]),w=m.slice(1));let j={type:"sound",operationType:"play",alias:C};if(D&&(j.url=D),f.length>3){let ct=d(w);ct!==void 0&&(j.props=ct);}return j;case "pause":case "resume":return {type:p==="allsounds"?"all":p,operationType:c,alias:C};case "stop":case "remove":return {type:"sound",operationType:"stop",alias:C};case "edit":return {type:"sound",operationType:"edit",alias:C,props:d(f.slice(3))};case "volume":let le=parseFloat(f[3]);return {type:"sound",operationType:"edit",alias:C,props:{volume:le}}}}function u(f,p){if(p.length>0){if(p.includes("with")&&p.length>p.indexOf("with")+1){let c=p[p.indexOf("with")+1],C=p.slice(p.indexOf("with")+2);p=p.slice(0,p.indexOf("with"));let m=h(c,C);m!==void 0&&(f.transition=m);}if(p.length>0){let c=y(p);f.props=c;}}return f}function h(f,p){switch(f){case "dissolve":case "fade":case "movein":case "moveout":case "zoomin":case "zoomout":case "pushin":case "pushout":break;default:return}let c={type:f};if(p.length>0)try{let C=y(p);c.props=C;}catch{}return c}function d(f){let p=g(f);return y(p)}function g(f){let p=[],c=0,C="";for(let m=0;m<f.length;m++){let D=f[m];D.startsWith("{")?(c++,C+=D):D.endsWith("}")&&c>0?(c--,C+=D,c===0&&(p.push(C),C="")):c>0?C+=D:p.push(D);}return p}function y(f){if(f.length===0)return {};if(f.length%2!==0)throw L.error("The props list must have a pair number of elements",f),new Error("The props list must have a pair number of elements");let p="{";f.forEach((c,C)=>{if(C%2===0)p+=`"${c}": `;else {switch(c){case "null":case "undefined":case "true":case "false":p+=`${c}`;break;default:E(c)?(c=v(c),p+=`"${c}"`):c.startsWith("{")&&c.endsWith("}")?p+=`${c}`:c.startsWith('"')&&c.endsWith('"')?p+=`${c}`:isNaN(parseFloat(c))?p+=`"${c}"`:p+=`${c}`;}C<f.length-1&&(p+=", ");}}),p+="}";try{return vi.parse(p)}catch(c){throw L.error("Error parsing ink json",p),c}}function v(f){return f.startsWith('"')&&f.endsWith('"')||f.startsWith("'")&&f.endsWith("'")||f.startsWith("`")&&f.endsWith("`")?f.substring(1,f.length-1):f}function E(f){return !!(f.startsWith('"')&&f.endsWith('"')||f.startsWith("'")&&f.endsWith("'")||f.startsWith("`")&&f.endsWith("`"))}})(oa||(oa={}));var Ei=oa;var Ft=class{};hi(Ft,"handlers",[]);var la;(n=>{function r(i){Ft.handlers.push(i);}n.add=r;function e(){Ft.handlers=[];}n.clear=e;function t(i,a,s=0){if(s>=Ft.handlers.length)return a(i);let o=Ft.handlers[s];return o(i,l=>t(l,a,s+1))}n.getLogichValue=t;})(la||(la={}));var ua=la;var Wl=zs($t());var Si="global decl",ft="___external_value___";var Yh=zs(Xh()),Qh=zs($t());function oi(r,e=[],t=[]){let n=[];try{return {json:new Yh.Compiler(r,{errorHandler:(o,l)=>{n.push({message:o,type:l});},countAllVisits:!0,fileHandler:{ResolveInkFilename:o=>o,LoadInkFileContents:()=>""},pluginNames:[],sourceFilename:null}).Compile().ToJson()||"",issues:n,labelToRemove:e,initialVarsToRemove:t}}catch(i){let a=n.find(s=>s.type===Qh.ErrorType.Error);if(a){if(a.message.includes("Divert target not found")){let s=a.message.match(/Divert target not found: '-> (\w+)'/);if(s&&s[1]){let o=s[1],l=`
60
60
 
61
61
  === ${o} ===
62
62
 
@@ -1 +1 @@
1
- import {f}from'./chunk-CYTZWQOB.mjs';import'./chunk-M7O5Q75X.mjs';function o(){import.meta.hot&&import.meta.hot.on("ink-updated",e=>{f(e);});}export{o as setupInkHmrListener};
1
+ import {f}from'./chunk-BEGZMB57.mjs';import'./chunk-M7O5Q75X.mjs';function o(){import.meta.hot&&import.meta.hot.on("ink-updated",e=>{f(e);});}export{o as setupInkHmrListener};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drincs/pixi-vn-ink",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "type": "module",
5
5
  "description": "Pixi'VN gives you the ability to write your own narrative using Ink",
6
6
  "main": "./dist/index.cjs",