@drincs/pixi-vn-ink 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/functions/choice-info-converter.cjs +3 -3
- package/dist/functions/choice-info-converter.js +3 -3
- package/dist/functions/hashtag-script.cjs +1 -1
- package/dist/functions/hashtag-script.js +1 -1
- package/dist/functions/importer.cjs +29 -29
- package/dist/functions/importer.js +29 -29
- package/dist/functions/index.cjs +29 -29
- package/dist/functions/index.js +29 -29
- package/dist/functions/ink-to-pixivn.cjs +37 -37
- package/dist/functions/ink-to-pixivn.js +37 -37
- package/dist/functions/replace.cjs +1 -1
- package/dist/functions/replace.js +1 -1
- package/dist/functions/story-info-converter.cjs +3 -3
- package/dist/functions/story-info-converter.js +3 -3
- package/dist/functions/translate.cjs +1 -1
- package/dist/functions/translate.js +1 -1
- package/dist/index.cjs +29 -29
- package/dist/index.js +29 -29
- package/dist/managers/HashtagScriptManager.cjs +1 -1
- package/dist/managers/HashtagScriptManager.d.cts +2 -2
- package/dist/managers/HashtagScriptManager.d.ts +2 -2
- package/dist/managers/HashtagScriptManager.js +1 -1
- package/dist/parser/adding-elements.cjs +2 -2
- package/dist/parser/adding-elements.js +2 -2
- package/dist/parser/conditiona-aritmetic-parser.d.cts +15 -15
- package/dist/parser/conditiona-aritmetic-parser.d.ts +15 -15
- package/dist/parser/conditional-statements-parser.cjs +3 -3
- package/dist/parser/conditional-statements-parser.js +3 -3
- package/dist/parser/label-parser.cjs +2 -2
- package/dist/parser/label-parser.js +2 -2
- package/dist/parser/switch-parser.cjs +3 -3
- package/dist/parser/switch-parser.js +3 -3
- package/package.json +2 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';require('@drincs/pixi-vn');var T="_|_";function R(i,e){if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(o=>!o.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".",T);if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let n=i.split("g-");return _(e)+T+"g-"+n[n.length-1]}let l=0;for(;new RegExp(/^\.\^.*$/).test(i);)l++,i=i.substring(2);if(l=l-1,new RegExp(/^\..*$/).test(i)&&e){let n=i.substring(1);return _(e,l)+T+n.replaceAll(".",T)}return i.replaceAll(".",T)||_(e,l).replaceAll(".",T)}function _(i,e=0){let l=i.split(T);for(;l.length>1&&e>0;)l.pop()?.includes("g-")&&e--,e--;return l.join(T)}var
|
|
2
|
-
`),i=i.replaceAll("\\t"," "),i=i.replaceAll(" "," "),i=i.replaceAll(
|
|
3
|
-
`)s=!0;else if(t=="done"||t=="end")o(n,t,e,r,s,y),s=!1;else if(t=="<>")o(n,t,e,r,s,y),s=!1;else if(t=="nop"&&V){let f=
|
|
1
|
+
'use strict';require('@drincs/pixi-vn');var T="_|_";function R(i,e){if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(o=>!o.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".",T);if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let n=i.split("g-");return _(e)+T+"g-"+n[n.length-1]}let l=0;for(;new RegExp(/^\.\^.*$/).test(i);)l++,i=i.substring(2);if(l=l-1,new RegExp(/^\..*$/).test(i)&&e){let n=i.substring(1);return _(e,l)+T+n.replaceAll(".",T)}return i.replaceAll(".",T)||_(e,l).replaceAll(".",T)}function _(i,e=0){let l=i.split(T);for(;l.length>1&&e>0;)l.pop()?.includes("g-")&&e--,e--;return l.join(T)}var B="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function A(i){return i.startsWith("^")&&(i=i.substring(1)),i=i.replaceAll("\\\\",B),i=i.replaceAll("\\n",`
|
|
2
|
+
`),i=i.replaceAll("\\t"," "),i=i.replaceAll(" "," "),i=i.replaceAll(B,"\\\\"),i}var G=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],w=["+","-","/","*","%","POW","RANDOM"],H=["INT","FLOOR","FLOAT"],$=["==",">","<",">=","<=","!=","CONTAINS"];function v(i,e,l){i=i.map(o=>{if(typeof o=="string"){if(o==="rnd")return "RANDOM";if(o==="?")return "CONTAINS"}return o});let n=[];return i.forEach(o=>{if(typeof o=="object"&&"CNT?"in o)if(new RegExp(/.*\.[0-9]\..*/).test(o["CNT?"])){let p=o["CNT?"].split("."),h=p.pop(),g=p.pop();if(g===void 0||h===void 0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);return}let c=parseInt(g),s=p.join(".");if(s.includes("^.")){let r=s.split("."),u=r[r.length-1].replaceAll(".",T);r.pop(),s=r.join(".")+"."+u,h.includes("c-")&&(s=s+T+h);}else s=s.replaceAll(".",T);n.push({type:"compare",leftValue:W(R(s,e)),operator:">=",rightValue:{type:"value",value:c}});}else n.push(W(R(o["CNT?"],e)));else if(typeof o=="object"&&"VAR?"in o)n.push(N(o["VAR?"],l));else if(o==="&&"||o==="||"){if(n.length>=2){let p={type:"union",unionType:o==="&&"?"and":"or",conditions:[n[n.length-2],n[n.length-1]]};n.pop(),n.pop(),n.push(p);}}else if(o==="!")if(n.length===0)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"union",unionType:"not",condition:n[n.length-1]};n[n.length-1]=p;}else if(o&&typeof o=="string"&&$.includes(o))if(n.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"compare",operator:o,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(p);}else if(o&&typeof o=="string"&&w.includes(o))if(n.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"arithmetic",operator:o,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(p);}else if(o&&typeof o=="string"&&H.includes(o)){let p={type:"arithmeticsingle",operator:o,leftValue:n[n.length-1]};n.pop(),n.push(p);}else o&&typeof o=="string"?o.startsWith("^")&&n.push(A(o)):typeof o=="object"&&"^->"in o?o["^->"].includes("$r")||n.push(o["^->"]):n.push(o);}),n}function W(i){return {type:"value",storageType:"label",storageOperationType:"get",label:i}}function Y(i,e,l){return v(i,e,l)}function N(i,e,l="storage"){let n=e.indexOf(i);return n>=0?{type:"value",storageType:"params",storageOperationType:"get",key:n}:{type:"value",storageOperationType:"get",storageType:l,key:i}}function F(i,e,l,n="storage"){let o=e.indexOf(i);return o>=0?{type:"value",storageType:"params",storageOperationType:"set",key:o,value:l}:{type:"value",storageOperationType:"set",storageType:n,key:i,value:l}}function q(i,e){e&&(typeof e=="string"?e.startsWith("^")&&i.push(A(e)):typeof e=="object"&&"type"in e&&e.type!=="value"&&i.push(e));}function D(i,e,l,n=!0,o=!1){return z(i,e,l,n,o)}function z(i,e,l,n,o=!1){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type=="value"&&e.storageOperationType==="get"?typeof e=="string"?i.push(A(e)):i.push(e):typeof e=="object"&&"type"in e&&i.push(e));}function m(i,e,l){if(i.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Arithmetic statement is not valid",i);return}let n=v(i,e,l);if(n.length===1){let o=n[0];return o&&typeof o=="object"&&"type"in o?{type:"value",storageType:"logic",storageOperationType:"get",operation:o}:o}}function E(i,e,l,n="",o,p,h=void 0){let g=[],c="sequential",s=!1,r=!0;i.forEach(V=>{V==="%"&&(c="loop"),V==="seq"&&(c="random"),V==="MIN"&&(s=!0);});let u=i[i.length-1];return Object.keys(u).forEach(V=>{let y=u[V];if(Array.isArray(y)&&y.length>3){y=y.slice(1,y.length-2);let S=[];J(y,n,o,S,e,e,l,O,h,!0,p),S.length===1?g.push(S[0]):g.push({type:"resulttocombine",combine:"cross",secondConditionalItem:S});}else Array.isArray(y)&&y.length===3&&(r=!1);}),c==="sequential"?{type:"stepswitch",elements:g,choiceType:c,end:r?"lastItem":void 0,nestedId:h}:s&&c==="random"?{type:"stepswitch",elements:g,choiceType:"sequentialrandom",end:r?"lastItem":void 0,nestedId:h}:{type:"stepswitch",elements:g,choiceType:c}}function J(i,e,l,n=[],o,p,h,g,c=void 0,s=!0,r=[]){let u=!1,a=[],V=!1,y=!1,S=[],C=[];if(l.preDialog[e]&&(s=!1,o(n,"^"+l.preDialog[e].text,e,r,s,y),l.preDialog[e].glue&&o(n,"<>",e,r,s,y),delete l.preDialog[e]),i.includes("visit")){let t=E(i,p,h,e,l,r,c);t&&(!s&&n.length>0&&o(n,"<>",e,r,s,y),o(n,t,e,r,s,y));return}let b=i[0];if(b&&typeof b=="object"&&"temp="in b){for(;i[0]&&typeof i[0]=="object"&&"temp="in i[0];)r.push(i[0]["temp="]),i.shift();r=r.reverse();}if(i.forEach((t,x)=>{if(y){if(typeof t=="string"&&t=="/#"){let f=[];J(C,e,l,f,D,D,h,g,c,s),o(n,f,e,r,s,y),y=!1,C=[];}else C.push(t);return}else if(u)if(Array.isArray(t))a.push(t);else if(t&&typeof t=="object")if("CNT?"in t)x>0&&i[x-1]=="ev"?(V=!0,S.push(t)):V?S.push(t):(a.push(t),s=!1);else if("VAR="in t||"temp="in t){let f=F("VAR="in t?t["VAR="]:t["temp="],r,i[x-1],"VAR="in t?"storage":"tempstorage");if(f.value&&typeof f.value=="string"&&f.value=="/str"&&(f.value=i[x-2]),f.value&&typeof f.value=="object"&&"^->"in f.value&&(f.value=f.value["^->"]),a.length>1){let d=m(a,e,r);a=[],d&&typeof d=="object"&&"type"in d&&d.type=="value"&&"storageType"in d&&d.storageType=="logic"&&(f.value=d.operation);}(typeof f.key!="string"||!f.key.includes("$r"))&&(o(n,f,e,r,s,y),s=!0);}else "VAR?"in t?a.push(t):"^->"in t&&(t["^->"].includes("$r")||a.push(t));else if(typeof t=="string"&&t=="/ev")V&&S.push(t),u=!1,a.push(t);else if(typeof t=="string"&&t=="out"){if(a.length>0){let f=a[a.length-1];if(f&&typeof f=="object"&&"VAR?"in f){a.pop();let d=N(f["VAR?"],r,"storage");o(n,d,e,r,s,y);}else {let d=[];for(;a.length>0&&a[a.length-1]!="/ev";)d.push(a.pop());d=d.reverse();let P=m(d,e,r);a=[],P&&typeof P=="object"&&"type"in P&&P.type=="value"&&"storageType"in P&&P.storageType=="logic"?o(n,{storageOperationType:"get",storageType:"logic",operation:P.operation,type:"value"},e,r,s,y):(o(n,"<>",e,r,s,y),P=`^${P}`,o(n,P,e,r,s,y));}s=!1;}}else a.push(t);else if(typeof t=="string")if(t.startsWith("^"))o(n,t,e,r,s,y),s=!1;else if(t=="ev")u=!0;else if(t==`
|
|
3
|
+
`)s=!0;else if(t=="done"||t=="end")o(n,t,e,r,s,y),s=!1;else if(t=="<>")o(n,t,e,r,s,y),s=!1;else if(t=="nop"&&V){let f=U(S,p,h,e,l,r,c);f&&o(n,f,e,r,s,y),V=!1,S=[];}else t=="#"&&(y=!0);else if(t instanceof Array)if(V)S.push(t);else if(t.length>1&&typeof t[t.length-2]=="object"&&t[t.length-2]&&"c"in t[t.length-2]&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"b"in t[t.length-1]){a.pop();let f=[],d=[];for(;a.length>0&&a[a.length-1]!="/ev";)f.push(a.pop());S=[...S,...f.reverse()],V=!0,d.push(t.pop()),d.push(t.pop()),S=[...S,...t],S.push(d);}else if(t.length>1&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"#n"in t[t.length-1]){let f=t.pop();if(!f){console.error("[Pixi\u2019VN Ink] Error parsing ink file: el is undefined");return}let d=f["#n"];delete f["#n"],t.push(f),o(n,{"->":e?e+T+d:d},e,r,s,y),h({[d]:t},e,l);}else J(t,e,l,n,o,p,h,g,c,s);else if(t&&typeof t=="object")if("->"in t&&typeof t["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(t["->"])){let f=[];a.length>0&&(f=Y(["ev",...a],e,r)),t.params=f,o(n,t,e,r,s,y),s=!1;}else if("*"in t&&typeof t["*"]=="string")t["*"].includes("c")&&(a.push(t),s=!1);else if("s"in t&&t.s instanceof Array)a.push(t),s=!1;else if("CNT?"in t)a.push(t),s=!1;else if("VAR="in t||"temp="in t){let f=[],d=F("VAR="in t?t["VAR="]:t["temp="],r,void 0,"VAR="in t?"storage":"tempstorage");if(d.key!=="$r"){for(a.pop(),a[a.length-1]=="/ev"&&a.pop();a.length>0&&a[a.length-1]!="/ev";)f.push(a.pop());f=f.reverse(),d.value=m(f,e,r),a=[],(d.value!==void 0||d.value!==null)&&o(n,d,e,r,s,y),s=!1;}}else h(t,e,l);}),g(a,n,e,l,r),e.includes(T)&&n.length==2){let t=n[0],x=n[1];t&&x&&typeof t=="object"&&"dialogue"in t&&typeof x=="object"&&"labelToOpen"in x&&t.dialogue==" "&&x.labelToOpen&&(n.shift(),delete x.glueEnabled,n[0]=x);}}function k(i,e,l,n,o){if(e.length===0)return;let p=v(e,n,l);if(p.length===1){let h={type:"ifelse",condition:p[0],then:i,else:o};return h.else||delete h.else,h}else if(p.length>1){let h={type:"ifelse",condition:{type:"union",unionType:"and",conditions:p},then:i,else:o};return h.else||delete h.else,h}}function U(i,e,l,n,o,p,h=void 0){if(i.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);return}let g=[],c=[];if(i.forEach(u=>{Array.isArray(u)?c.push(u):typeof u=="string"&&u==="du"?o.du?g.push(o.du):o.du=g[g.length-1]:(typeof u!="string"||u!=="/ev")&&g.push(u);}),c.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",c);return}let s=j(c[0],e,l,n+T+"then",o,p,`${h||""}then`),r;return c.length===2?r=j(c[1],e,l,n+T+"else",o,p,`${h||""}else`):c.length>2&&(c.shift(),c.push("nop"),c=[{b:c}],r=j(c,e,l,n+T+"else",o,p,`${h||""}else`)),o.du=void 0,k(s,g,p,n,r)}function j(i,e,l,n,o,p,h=void 0){let g=[];for(let s of i)typeof s=="object"&&"b"in s&&(s.b=s.b.filter(r=>r!==null&&!(typeof r=="object"&&"->"in r&&new RegExp(/.*\.[0-9]/).test(r["->"]))),J(s.b,n,o,g,e,e,l,O,h,!0,p));return g.length===1?g[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:g}}function M(i="",e=""){let l=Array.isArray(i)?i:[i],n=Array.isArray(e)?e:[e];return [...new Set([...l,...n])]}function O(i,e,l,n,o){if(i.length>0){let p={};L(i,p,o);for(let[h,g]of Object.entries(p)){let c=l+T+h,s={text:g.text.length===1?g.text[0]:g.text,label:c,props:{},type:"jump",oneTime:g.onetime};g.text.length===0&&(s.onlyHaveNoChoice=!0,s.autoSelect=!0),s.oneTime===!1&&delete s.oneTime;let r=k(s,g.conditions,o,l)||s,u=e[e.length-1];if(typeof u=="object"&&u&&"type"in u&&(u={conditionalStep:u}),e.length>0&&typeof u=="object"&&u&&"choices"in u&&u.choices){let a=u.choices;a&&Array.isArray(a)?a.push(r):console.error("[Pixi\u2019VN Ink] Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",g,a),u.choices=a.sort((V,y)=>{try{let S=V.label.split("."),C=S[S.length-1].replaceAll(".",T),b=y.label.split("."),t=b[b.length-1].replaceAll(".",T);if(C.includes("c-")&&t.includes("c-")){let x=C.split("c-")[1],f=parseInt(x),d=t.split("c-")[1],P=parseInt(d);return f-P}}catch{}return 0});}else e.push({choices:[r]});g.preDialog&&(n.preDialog[c]={...g.preDialog});}}}function L(i,e,l,n){let o=[],p="",h="",g=!1,c=[];for(let s=0;s<i.length;s++){let r=i[s];if(typeof r=="string")r.startsWith("^")?o.push(A(r)):G.includes(r)&&c.push(r);else if(Array.isArray(r)&&r.includes("visit")){let u=E(r,q,(a,V,y)=>{},n,{preDialog:{}},l);o.push(u);}else if(r&&typeof r=="object")if("*"in r&&typeof r["*"]&&typeof r["*"]=="string")r["*"].includes("c")&&(p="c"+r["*"].split("c")[1],r.flg&16&&(g=!0));else if("s"in r&&r.s instanceof Array){let u=X(r.s),a=r.s.includes("<>");u&&(n&&e[n]?(e[n].preDialog={text:u,glue:a},e[n].text=M(u,e[n].text)):(o.push(u),h=u));}else "CNT?"in r&&c.push(r);else c.push(r);if(p){e[p]?e[p].text=M(o,e[p].text):e[p]={text:o,onetime:g,conditions:c},h&&(e[p].preDialog={text:h,glue:!1});let u=i.slice(s+1);L(u,e,l,p);return}}}function X(i){for(let e of i)if(typeof e=="string"){if(e.startsWith("^"))return A(e)}else if(e instanceof Array){let l=X(e);if(l)return l}}exports.addChoiseIntoList=O;exports.getLabelChoice=L;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import'@drincs/pixi-vn';var T="_|_";function R(i,e){if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(o=>!o.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".",T);if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let n=i.split("g-");return _(e)+T+"g-"+n[n.length-1]}let l=0;for(;new RegExp(/^\.\^.*$/).test(i);)l++,i=i.substring(2);if(l=l-1,new RegExp(/^\..*$/).test(i)&&e){let n=i.substring(1);return _(e,l)+T+n.replaceAll(".",T)}return i.replaceAll(".",T)||_(e,l).replaceAll(".",T)}function _(i,e=0){let l=i.split(T);for(;l.length>1&&e>0;)l.pop()?.includes("g-")&&e--,e--;return l.join(T)}var
|
|
2
|
-
`),i=i.replaceAll("\\t"," "),i=i.replaceAll(" "," "),i=i.replaceAll(
|
|
3
|
-
`)s=!0;else if(t=="done"||t=="end")o(n,t,e,r,s,y),s=!1;else if(t=="<>")o(n,t,e,r,s,y),s=!1;else if(t=="nop"&&V){let f=
|
|
1
|
+
import'@drincs/pixi-vn';var T="_|_";function R(i,e){if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(o=>!o.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".",T);if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let n=i.split("g-");return _(e)+T+"g-"+n[n.length-1]}let l=0;for(;new RegExp(/^\.\^.*$/).test(i);)l++,i=i.substring(2);if(l=l-1,new RegExp(/^\..*$/).test(i)&&e){let n=i.substring(1);return _(e,l)+T+n.replaceAll(".",T)}return i.replaceAll(".",T)||_(e,l).replaceAll(".",T)}function _(i,e=0){let l=i.split(T);for(;l.length>1&&e>0;)l.pop()?.includes("g-")&&e--,e--;return l.join(T)}var B="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function A(i){return i.startsWith("^")&&(i=i.substring(1)),i=i.replaceAll("\\\\",B),i=i.replaceAll("\\n",`
|
|
2
|
+
`),i=i.replaceAll("\\t"," "),i=i.replaceAll(" "," "),i=i.replaceAll(B,"\\\\"),i}var G=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],w=["+","-","/","*","%","POW","RANDOM"],H=["INT","FLOOR","FLOAT"],$=["==",">","<",">=","<=","!=","CONTAINS"];function v(i,e,l){i=i.map(o=>{if(typeof o=="string"){if(o==="rnd")return "RANDOM";if(o==="?")return "CONTAINS"}return o});let n=[];return i.forEach(o=>{if(typeof o=="object"&&"CNT?"in o)if(new RegExp(/.*\.[0-9]\..*/).test(o["CNT?"])){let p=o["CNT?"].split("."),h=p.pop(),g=p.pop();if(g===void 0||h===void 0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);return}let c=parseInt(g),s=p.join(".");if(s.includes("^.")){let r=s.split("."),u=r[r.length-1].replaceAll(".",T);r.pop(),s=r.join(".")+"."+u,h.includes("c-")&&(s=s+T+h);}else s=s.replaceAll(".",T);n.push({type:"compare",leftValue:W(R(s,e)),operator:">=",rightValue:{type:"value",value:c}});}else n.push(W(R(o["CNT?"],e)));else if(typeof o=="object"&&"VAR?"in o)n.push(N(o["VAR?"],l));else if(o==="&&"||o==="||"){if(n.length>=2){let p={type:"union",unionType:o==="&&"?"and":"or",conditions:[n[n.length-2],n[n.length-1]]};n.pop(),n.pop(),n.push(p);}}else if(o==="!")if(n.length===0)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"union",unionType:"not",condition:n[n.length-1]};n[n.length-1]=p;}else if(o&&typeof o=="string"&&$.includes(o))if(n.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"compare",operator:o,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(p);}else if(o&&typeof o=="string"&&w.includes(o))if(n.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"arithmetic",operator:o,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(p);}else if(o&&typeof o=="string"&&H.includes(o)){let p={type:"arithmeticsingle",operator:o,leftValue:n[n.length-1]};n.pop(),n.push(p);}else o&&typeof o=="string"?o.startsWith("^")&&n.push(A(o)):typeof o=="object"&&"^->"in o?o["^->"].includes("$r")||n.push(o["^->"]):n.push(o);}),n}function W(i){return {type:"value",storageType:"label",storageOperationType:"get",label:i}}function Y(i,e,l){return v(i,e,l)}function N(i,e,l="storage"){let n=e.indexOf(i);return n>=0?{type:"value",storageType:"params",storageOperationType:"get",key:n}:{type:"value",storageOperationType:"get",storageType:l,key:i}}function F(i,e,l,n="storage"){let o=e.indexOf(i);return o>=0?{type:"value",storageType:"params",storageOperationType:"set",key:o,value:l}:{type:"value",storageOperationType:"set",storageType:n,key:i,value:l}}function q(i,e){e&&(typeof e=="string"?e.startsWith("^")&&i.push(A(e)):typeof e=="object"&&"type"in e&&e.type!=="value"&&i.push(e));}function D(i,e,l,n=!0,o=!1){return z(i,e,l,n,o)}function z(i,e,l,n,o=!1){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type=="value"&&e.storageOperationType==="get"?typeof e=="string"?i.push(A(e)):i.push(e):typeof e=="object"&&"type"in e&&i.push(e));}function m(i,e,l){if(i.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Arithmetic statement is not valid",i);return}let n=v(i,e,l);if(n.length===1){let o=n[0];return o&&typeof o=="object"&&"type"in o?{type:"value",storageType:"logic",storageOperationType:"get",operation:o}:o}}function E(i,e,l,n="",o,p,h=void 0){let g=[],c="sequential",s=!1,r=!0;i.forEach(V=>{V==="%"&&(c="loop"),V==="seq"&&(c="random"),V==="MIN"&&(s=!0);});let u=i[i.length-1];return Object.keys(u).forEach(V=>{let y=u[V];if(Array.isArray(y)&&y.length>3){y=y.slice(1,y.length-2);let S=[];J(y,n,o,S,e,e,l,O,h,!0,p),S.length===1?g.push(S[0]):g.push({type:"resulttocombine",combine:"cross",secondConditionalItem:S});}else Array.isArray(y)&&y.length===3&&(r=!1);}),c==="sequential"?{type:"stepswitch",elements:g,choiceType:c,end:r?"lastItem":void 0,nestedId:h}:s&&c==="random"?{type:"stepswitch",elements:g,choiceType:"sequentialrandom",end:r?"lastItem":void 0,nestedId:h}:{type:"stepswitch",elements:g,choiceType:c}}function J(i,e,l,n=[],o,p,h,g,c=void 0,s=!0,r=[]){let u=!1,a=[],V=!1,y=!1,S=[],C=[];if(l.preDialog[e]&&(s=!1,o(n,"^"+l.preDialog[e].text,e,r,s,y),l.preDialog[e].glue&&o(n,"<>",e,r,s,y),delete l.preDialog[e]),i.includes("visit")){let t=E(i,p,h,e,l,r,c);t&&(!s&&n.length>0&&o(n,"<>",e,r,s,y),o(n,t,e,r,s,y));return}let b=i[0];if(b&&typeof b=="object"&&"temp="in b){for(;i[0]&&typeof i[0]=="object"&&"temp="in i[0];)r.push(i[0]["temp="]),i.shift();r=r.reverse();}if(i.forEach((t,x)=>{if(y){if(typeof t=="string"&&t=="/#"){let f=[];J(C,e,l,f,D,D,h,g,c,s),o(n,f,e,r,s,y),y=!1,C=[];}else C.push(t);return}else if(u)if(Array.isArray(t))a.push(t);else if(t&&typeof t=="object")if("CNT?"in t)x>0&&i[x-1]=="ev"?(V=!0,S.push(t)):V?S.push(t):(a.push(t),s=!1);else if("VAR="in t||"temp="in t){let f=F("VAR="in t?t["VAR="]:t["temp="],r,i[x-1],"VAR="in t?"storage":"tempstorage");if(f.value&&typeof f.value=="string"&&f.value=="/str"&&(f.value=i[x-2]),f.value&&typeof f.value=="object"&&"^->"in f.value&&(f.value=f.value["^->"]),a.length>1){let d=m(a,e,r);a=[],d&&typeof d=="object"&&"type"in d&&d.type=="value"&&"storageType"in d&&d.storageType=="logic"&&(f.value=d.operation);}(typeof f.key!="string"||!f.key.includes("$r"))&&(o(n,f,e,r,s,y),s=!0);}else "VAR?"in t?a.push(t):"^->"in t&&(t["^->"].includes("$r")||a.push(t));else if(typeof t=="string"&&t=="/ev")V&&S.push(t),u=!1,a.push(t);else if(typeof t=="string"&&t=="out"){if(a.length>0){let f=a[a.length-1];if(f&&typeof f=="object"&&"VAR?"in f){a.pop();let d=N(f["VAR?"],r,"storage");o(n,d,e,r,s,y);}else {let d=[];for(;a.length>0&&a[a.length-1]!="/ev";)d.push(a.pop());d=d.reverse();let P=m(d,e,r);a=[],P&&typeof P=="object"&&"type"in P&&P.type=="value"&&"storageType"in P&&P.storageType=="logic"?o(n,{storageOperationType:"get",storageType:"logic",operation:P.operation,type:"value"},e,r,s,y):(o(n,"<>",e,r,s,y),P=`^${P}`,o(n,P,e,r,s,y));}s=!1;}}else a.push(t);else if(typeof t=="string")if(t.startsWith("^"))o(n,t,e,r,s,y),s=!1;else if(t=="ev")u=!0;else if(t==`
|
|
3
|
+
`)s=!0;else if(t=="done"||t=="end")o(n,t,e,r,s,y),s=!1;else if(t=="<>")o(n,t,e,r,s,y),s=!1;else if(t=="nop"&&V){let f=U(S,p,h,e,l,r,c);f&&o(n,f,e,r,s,y),V=!1,S=[];}else t=="#"&&(y=!0);else if(t instanceof Array)if(V)S.push(t);else if(t.length>1&&typeof t[t.length-2]=="object"&&t[t.length-2]&&"c"in t[t.length-2]&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"b"in t[t.length-1]){a.pop();let f=[],d=[];for(;a.length>0&&a[a.length-1]!="/ev";)f.push(a.pop());S=[...S,...f.reverse()],V=!0,d.push(t.pop()),d.push(t.pop()),S=[...S,...t],S.push(d);}else if(t.length>1&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"#n"in t[t.length-1]){let f=t.pop();if(!f){console.error("[Pixi\u2019VN Ink] Error parsing ink file: el is undefined");return}let d=f["#n"];delete f["#n"],t.push(f),o(n,{"->":e?e+T+d:d},e,r,s,y),h({[d]:t},e,l);}else J(t,e,l,n,o,p,h,g,c,s);else if(t&&typeof t=="object")if("->"in t&&typeof t["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(t["->"])){let f=[];a.length>0&&(f=Y(["ev",...a],e,r)),t.params=f,o(n,t,e,r,s,y),s=!1;}else if("*"in t&&typeof t["*"]=="string")t["*"].includes("c")&&(a.push(t),s=!1);else if("s"in t&&t.s instanceof Array)a.push(t),s=!1;else if("CNT?"in t)a.push(t),s=!1;else if("VAR="in t||"temp="in t){let f=[],d=F("VAR="in t?t["VAR="]:t["temp="],r,void 0,"VAR="in t?"storage":"tempstorage");if(d.key!=="$r"){for(a.pop(),a[a.length-1]=="/ev"&&a.pop();a.length>0&&a[a.length-1]!="/ev";)f.push(a.pop());f=f.reverse(),d.value=m(f,e,r),a=[],(d.value!==void 0||d.value!==null)&&o(n,d,e,r,s,y),s=!1;}}else h(t,e,l);}),g(a,n,e,l,r),e.includes(T)&&n.length==2){let t=n[0],x=n[1];t&&x&&typeof t=="object"&&"dialogue"in t&&typeof x=="object"&&"labelToOpen"in x&&t.dialogue==" "&&x.labelToOpen&&(n.shift(),delete x.glueEnabled,n[0]=x);}}function k(i,e,l,n,o){if(e.length===0)return;let p=v(e,n,l);if(p.length===1){let h={type:"ifelse",condition:p[0],then:i,else:o};return h.else||delete h.else,h}else if(p.length>1){let h={type:"ifelse",condition:{type:"union",unionType:"and",conditions:p},then:i,else:o};return h.else||delete h.else,h}}function U(i,e,l,n,o,p,h=void 0){if(i.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);return}let g=[],c=[];if(i.forEach(u=>{Array.isArray(u)?c.push(u):typeof u=="string"&&u==="du"?o.du?g.push(o.du):o.du=g[g.length-1]:(typeof u!="string"||u!=="/ev")&&g.push(u);}),c.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",c);return}let s=j(c[0],e,l,n+T+"then",o,p,`${h||""}then`),r;return c.length===2?r=j(c[1],e,l,n+T+"else",o,p,`${h||""}else`):c.length>2&&(c.shift(),c.push("nop"),c=[{b:c}],r=j(c,e,l,n+T+"else",o,p,`${h||""}else`)),o.du=void 0,k(s,g,p,n,r)}function j(i,e,l,n,o,p,h=void 0){let g=[];for(let s of i)typeof s=="object"&&"b"in s&&(s.b=s.b.filter(r=>r!==null&&!(typeof r=="object"&&"->"in r&&new RegExp(/.*\.[0-9]/).test(r["->"]))),J(s.b,n,o,g,e,e,l,O,h,!0,p));return g.length===1?g[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:g}}function M(i="",e=""){let l=Array.isArray(i)?i:[i],n=Array.isArray(e)?e:[e];return [...new Set([...l,...n])]}function O(i,e,l,n,o){if(i.length>0){let p={};L(i,p,o);for(let[h,g]of Object.entries(p)){let c=l+T+h,s={text:g.text.length===1?g.text[0]:g.text,label:c,props:{},type:"jump",oneTime:g.onetime};g.text.length===0&&(s.onlyHaveNoChoice=!0,s.autoSelect=!0),s.oneTime===!1&&delete s.oneTime;let r=k(s,g.conditions,o,l)||s,u=e[e.length-1];if(typeof u=="object"&&u&&"type"in u&&(u={conditionalStep:u}),e.length>0&&typeof u=="object"&&u&&"choices"in u&&u.choices){let a=u.choices;a&&Array.isArray(a)?a.push(r):console.error("[Pixi\u2019VN Ink] Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",g,a),u.choices=a.sort((V,y)=>{try{let S=V.label.split("."),C=S[S.length-1].replaceAll(".",T),b=y.label.split("."),t=b[b.length-1].replaceAll(".",T);if(C.includes("c-")&&t.includes("c-")){let x=C.split("c-")[1],f=parseInt(x),d=t.split("c-")[1],P=parseInt(d);return f-P}}catch{}return 0});}else e.push({choices:[r]});g.preDialog&&(n.preDialog[c]={...g.preDialog});}}}function L(i,e,l,n){let o=[],p="",h="",g=!1,c=[];for(let s=0;s<i.length;s++){let r=i[s];if(typeof r=="string")r.startsWith("^")?o.push(A(r)):G.includes(r)&&c.push(r);else if(Array.isArray(r)&&r.includes("visit")){let u=E(r,q,(a,V,y)=>{},n,{preDialog:{}},l);o.push(u);}else if(r&&typeof r=="object")if("*"in r&&typeof r["*"]&&typeof r["*"]=="string")r["*"].includes("c")&&(p="c"+r["*"].split("c")[1],r.flg&16&&(g=!0));else if("s"in r&&r.s instanceof Array){let u=X(r.s),a=r.s.includes("<>");u&&(n&&e[n]?(e[n].preDialog={text:u,glue:a},e[n].text=M(u,e[n].text)):(o.push(u),h=u));}else "CNT?"in r&&c.push(r);else c.push(r);if(p){e[p]?e[p].text=M(o,e[p].text):e[p]={text:o,onetime:g,conditions:c},h&&(e[p].preDialog={text:h,glue:!1});let u=i.slice(s+1);L(u,e,l,p);return}}}function X(i){for(let e of i)if(typeof e=="string"){if(e.startsWith("^"))return A(e)}else if(e instanceof Array){let l=X(e);if(l)return l}}export{O as addChoiseIntoList,L as getLabelChoice};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
'use strict';function E(i){}exports.onInkHashtagScript=E;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function E(i){}export{E as onInkHashtagScript};
|