@codraft/core
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -1,1 +0,1 @@ | ||
var t={87:(t,e,a)=>{var n=a(361);n.prototype.formulaEval=function(){for(var t,e,a,n=[],o=this.value,s=0;s<o.length;s++)1===o[s].type||3===o[s].type?n.push({value:3===o[s].type?o[s].show:o[s].value,type:1}):13===o[s].type?n.push({value:o[s].show,type:1}):0===o[s].type?n[n.length-1]={value:o[s].show+("-"!=o[s].show?"(":"")+n[n.length-1].value+("-"!=o[s].show?")":""),type:0}:7===o[s].type?n[n.length-1]={value:(1!=n[n.length-1].type?"(":"")+n[n.length-1].value+(1!=n[n.length-1].type?")":"")+o[s].show,type:7}:10===o[s].type?(t=n.pop(),e=n.pop(),"P"===o[s].show||"C"===o[s].show?n.push({value:"<sup>"+e.value+"</sup>"+o[s].show+"<sub>"+t.value+"</sub>",type:10}):n.push({value:(1!=e.type?"(":"")+e.value+(1!=e.type?")":"")+"<sup>"+t.value+"</sup>",type:1})):2===o[s].type||9===o[s].type?(t=n.pop(),e=n.pop(),n.push({value:(1!=e.type?"(":"")+e.value+(1!=e.type?")":"")+o[s].show+(1!=t.type?"(":"")+t.value+(1!=t.type?")":""),type:o[s].type})):12===o[s].type&&(t=n.pop(),e=n.pop(),a=n.pop(),n.push({value:o[s].show+"("+a.value+","+e.value+","+t.value+")",type:12}));return n[0].value},t.exports=n},735:(t,e,a)=>{var n=a(553);function o(t,e){for(var a=0;a<t.length;a++)t[a]+=e;return t}var s=["sin","cos","tan","pi","(",")","P","C"," ","asin","acos","atan","7","8","9","int","cosh","acosh","ln","^","root","4","5","6","/","!","tanh","atanh","Mod","1","2","3","*","sinh","asinh","e","log","0",".","+","-",",","Sigma","n","Pi","pow","&"],r=["sin","cos","tan","π","(",")","P","C"," ","asin","acos","atan","7","8","9","Int","cosh","acosh"," ln","^","root","4","5","6","÷","!","tanh","atanh"," Mod ","1","2","3","×","sinh","asinh","e"," log","0",".","+","-",",","Σ","n","Π","pow","&"],h=[n.math.sin,n.math.cos,n.math.tan,"PI","(",")",n.math.P,n.math.C," ".anchor,n.math.asin,n.math.acos,n.math.atan,"7","8","9",Math.floor,n.math.cosh,n.math.acosh,Math.log,Math.pow,Math.sqrt,"4","5","6",n.math.div,n.math.fact,n.math.tanh,n.math.atanh,n.math.mod,"1","2","3",n.math.mul,n.math.sinh,n.math.asinh,"E",n.math.log,"0",".",n.math.add,n.math.sub,",",n.math.sigma,"n",n.math.Pi,Math.pow,n.math.and],i={0:11,1:0,2:3,3:0,4:0,5:0,6:0,7:11,8:11,9:1,10:10,11:0,12:11,13:0,14:-1},u=[0,0,0,3,4,5,10,10,14,0,0,0,1,1,1,0,0,0,0,10,0,1,1,1,2,7,0,0,2,1,1,1,2,0,0,3,0,1,6,9,9,11,12,13,12,8,9],p={0:!0,1:!0,3:!0,4:!0,6:!0,8:!0,9:!0,12:!0,13:!0,14:!0},l={0:!0,1:!0,2:!0,3:!0,4:!0,5:!0,6:!0,7:!0,8:!0,9:!0,10:!0,11:!0,12:!0,13:!0},c={0:!0,3:!0,4:!0,8:!0,12:!0,13:!0},v={},f={0:!0,1:!0,3:!0,4:!0,6:!0,8:!0,12:!0,13:!0},m={1:!0},y=[[],["1","2","3","7","8","9","4","5","6","+","-","*","/","(",")","^","!","P","C","e","0",".",",","n"," ","&"],["pi","ln","Pi"],["sin","cos","tan","Del","int","Mod","log","pow"],["asin","acos","atan","cosh","root","tanh","sinh"],["acosh","atanh","asinh","Sigma"]];function d(t,e,a,n){for(var o=0;o<n;o++)if(t[a+o]!==e[o])return!1;return!0}n.addToken=function(t){for(var e=0;e<t.length;e++){var a=t[e].token.length,n=-1;y[a]=y[a]||[];for(var o=0;o<y[a].length;o++)if(t[e].token===y[a][o]){n=s.indexOf(y[a][o]);break}-1===n?(s.push(t[e].token),u.push(t[e].type),y.length<=t[e].token.length&&(y[t[e].token.length]=[]),y[t[e].token.length].push(t[e].token),h.push(t[e].value),r.push(t[e].show)):(s[n]=t[e].token,u[n]=t[e].type,h[n]=t[e].value,r[n]=t[e].show)}},n.lex=function(t,e){var a,g={value:n.math.changeSign,type:0,pre:21,show:"-"},w={value:")",show:")",type:5,pre:0},_={value:"(",type:4,pre:0,show:"("},x=[_],M=[],b=t,E=p,P=0,S=v,C="";void 0!==e&&n.addToken(e);var D={},k=function(t){for(var e,a,o,p=[],l=t.length,c=0;c<l;c++)if(!(c<l-1&&" "===t[c]&&" "===t[c+1])){for(e="",a=t.length-c>y.length-2?y.length-1:t.length-c;a>0;a--)if(void 0!==y[a])for(o=0;o<y[a].length;o++)d(t,y[a][o],c,a)&&(e=y[a][o],o=y[a].length,a=0);if(c+=e.length-1,""===e)throw new n.Exception("Can't understand after "+t.slice(c));var v=s.indexOf(e);p.push({index:v,token:e,type:u[v],eval:h[v],precedence:i[u[v]],show:r[v]})}return p}(b);for(a=0;a<k.length;a++){var N=k[a];if(14!==N.type){var R,V=N.token,B=N.type,I=N.eval,O=N.precedence,T=N.show,F=x[x.length-1];for(R=M.length;R--&&0===M[R];)if(-1!==[0,2,3,4,5,9,11,12,13].indexOf(B)){if(!0!==E[B])throw new n.Exception(V+" is not allowed after "+C);x.push(w),E=l,S=f,M.pop()}if(!0!==E[B])throw new n.Exception(V+" is not allowed after "+C);if(!0===S[B]&&(B=2,I=n.math.mul,T="×",O=3,a-=1),D={value:I,type:B,pre:O,show:T},0===B)E=p,S=v,o(M,2),x.push(D),4!==k[a+1].type&&(x.push(_),M.push(2));else if(1===B)1===F.type?(F.value+=I,o(M,1)):x.push(D),E=l,S=c;else if(2===B)E=p,S=v,o(M,2),x.push(D);else if(3===B)x.push(D),E=l,S=f;else if(4===B)o(M,1),P++,E=p,S=v,x.push(D);else if(5===B){if(!P)throw new n.Exception("Closing parenthesis are more than opening one, wait What!!!");P--,E=l,S=f,x.push(D),o(M,1)}else if(6===B){if(F.hasDec)throw new n.Exception("Two decimals are not allowed in one number");1!==F.type&&(F={value:0,type:1,pre:0},x.push(F)),E=m,o(M,1),S=v,F.value+=I,F.hasDec=!0}else 7===B&&(E=l,S=f,o(M,1),x.push(D));8===B?(E=p,S=v,o(M,4),x.push(D),4!==k[a+1].type&&(x.push(_),M.push(4))):9===B?(9===F.type?F.value===n.math.add?(F.value=I,F.show=T,o(M,1)):F.value===n.math.sub&&"-"===T&&(F.value=n.math.add,F.show="+",o(M,1)):5!==F.type&&7!==F.type&&1!==F.type&&3!==F.type&&13!==F.type?"-"===V&&(E=p,S=v,o(M,2).push(2),x.push(g),x.push(_)):(x.push(D),o(M,2)),E=p,S=v):10===B?(E=p,S=v,o(M,2),x.push(D)):11===B?(E=p,S=v,x.push(D)):12===B?(E=p,S=v,o(M,6),x.push(D),4!==k[a+1].type&&(x.push(_),M.push(6))):13===B&&(E=l,S=f,x.push(D)),o(M,-1),C=V}else if(a>0&&a<k.length-1&&1===k[a+1].type&&(1===k[a-1].type||6===k[a-1].type))throw new n.Exception("Unexpected Space")}for(R=M.length;R--;)x.push(w);if(!0!==E[5])throw new n.Exception("complete the expression");for(;P--;)x.push(w);return x.push(w),new n(x)},t.exports=n},553:t=>{var e=function(t){this.value=t};e.math={isDegree:!0,acos:function(t){return e.math.isDegree?180/Math.PI*Math.acos(t):Math.acos(t)},add:function(t,e){return t+e},asin:function(t){return e.math.isDegree?180/Math.PI*Math.asin(t):Math.asin(t)},atan:function(t){return e.math.isDegree?180/Math.PI*Math.atan(t):Math.atan(t)},acosh:function(t){return Math.log(t+Math.sqrt(t*t-1))},asinh:function(t){return Math.log(t+Math.sqrt(t*t+1))},atanh:function(t){return Math.log((1+t)/(1-t))},C:function(t,a){var n=1,o=t-a,s=a;s<o&&(s=o,o=a);for(var r=s+1;r<=t;r++)n*=r;return n/e.math.fact(o)},changeSign:function(t){return-t},cos:function(t){return e.math.isDegree&&(t=e.math.toRadian(t)),Math.cos(t)},cosh:function(t){return(Math.pow(Math.E,t)+Math.pow(Math.E,-1*t))/2},div:function(t,e){return t/e},fact:function(t){if(t%1!=0)return"NaN";for(var e=1,a=2;a<=t;a++)e*=a;return e},inverse:function(t){return 1/t},log:function(t){return Math.log(t)/Math.log(10)},mod:function(t,e){return t%e},mul:function(t,e){return t*e},P:function(t,e){for(var a=1,n=Math.floor(t)-Math.floor(e)+1;n<=Math.floor(t);n++)a*=n;return a},Pi:function(t,e,a){for(var n=1,o=t;o<=e;o++)n*=Number(a.postfixEval({n:o}));return n},pow10x:function(t){for(var e=1;t--;)e*=10;return e},sigma:function(t,e,a){for(var n=0,o=t;o<=e;o++)n+=Number(a.postfixEval({n:o}));return n},sin:function(t){return e.math.isDegree&&(t=e.math.toRadian(t)),Math.sin(t)},sinh:function(t){return(Math.pow(Math.E,t)-Math.pow(Math.E,-1*t))/2},sub:function(t,e){return t-e},tan:function(t){return e.math.isDegree&&(t=e.math.toRadian(t)),Math.tan(t)},tanh:function(t){return e.sinha(t)/e.cosha(t)},toRadian:function(t){return t*Math.PI/180},and:function(t,e){return t&e}},e.Exception=function(t){this.message=t},t.exports=e},186:(t,e,a)=>{var n=a(735);n.prototype.toPostfix=function(){for(var t,e,a,o,s,r=[],h=[{value:"(",type:4,pre:0}],i=this.value,u=1;u<i.length;u++)if(1===i[u].type||3===i[u].type||13===i[u].type)1===i[u].type&&(i[u].value=Number(i[u].value)),r.push(i[u]);else if(4===i[u].type)h.push(i[u]);else if(5===i[u].type)for(;4!==(e=h.pop()).type;)r.push(e);else if(11===i[u].type){for(;4!==(e=h.pop()).type;)r.push(e);h.push(e)}else{o=(t=i[u]).pre,a=(s=h[h.length-1]).pre;var p="Math.pow"==s.value&&"Math.pow"==t.value;if(o>a)h.push(t);else{for(;a>=o&&!p||p&&o<a;)e=h.pop(),s=h[h.length-1],r.push(e),a=s.pre,p="Math.pow"==t.value&&"Math.pow"==s.value;h.push(t)}}return new n(r)},t.exports=n},361:(t,e,a)=>{var n=a(186);n.prototype.postfixEval=function(t){(t=t||{}).PI=Math.PI,t.E=Math.E;for(var e,a,o,s=[],r=this.value,h=void 0!==t.n,i=0;i<r.length;i++)1===r[i].type?s.push({value:r[i].value,type:1}):3===r[i].type?s.push({value:t[r[i].value],type:1}):0===r[i].type||7===r[i].type?void 0===s[s.length-1].type?s[s.length-1].value.push(r[i]):s[s.length-1].value=r[i].value(s[s.length-1].value):8===r[i].type?(e=s.pop(),a=s.pop(),s.push({type:1,value:r[i].value(a.value,e.value)})):10===r[i].type?(e=s.pop(),void 0===(a=s.pop()).type?(a.value=a.concat(e),a.value.push(r[i]),s.push(a)):void 0===e.type?(e.unshift(a),e.push(r[i]),s.push(e)):s.push({type:1,value:r[i].value(a.value,e.value)})):2===r[i].type||9===r[i].type?(e=s.pop(),void 0===(a=s.pop()).type?((a=a.concat(e)).push(r[i]),s.push(a)):void 0===e.type?(e.unshift(a),e.push(r[i]),s.push(e)):s.push({type:1,value:r[i].value(a.value,e.value)})):12===r[i].type?(void 0!==(e=s.pop()).type&&(e=[e]),a=s.pop(),o=s.pop(),s.push({type:1,value:r[i].value(o.value,a.value,new n(e))})):13===r[i].type&&(h?s.push({value:t[r[i].value],type:3}):s.push([r[i]]));if(s.length>1)throw new n.Exception("Uncaught Syntax error");return s[0].value>1e15?"Infinity":parseFloat(s[0].value.toFixed(15))},n.eval=function(t,e,a){return void 0===e?this.lex(t).toPostfix().postfixEval():void 0===a?void 0!==e.length?this.lex(t,e).toPostfix().postfixEval():this.lex(t).toPostfix().postfixEval(e):this.lex(t,e).toPostfix().postfixEval(a)},t.exports=n}},e={};function a(n){var o=e[n];if(void 0!==o)return o.exports;var s=e[n]={exports:{}};return t[n](s,s.exports,a),s.exports}a.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return a.d(e,{a:e}),e},a.d=(t,e)=>{for(var n in e)a.o(e,n)&&!a.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var n={};(()=>{a.d(n,{R:()=>s});var t=a(87),e=a.n(t);class o{static SolveString(t){return t}static SolveNumber(t){const a=e().eval(t);return Number(a)}static SolveBoolean(t){return!0===Boolean(t)}static SolveDynamic(t){let e;try{e=o.SolveNumber(t)}catch(a){try{e=JSON.parse(t)}catch(a){e=t}}return e}static GetVariableType(t,e){return e in t.variables?t.variables[e].type:null}static GetVariableSolver(t){var e;return null===t?null:null!==(e=o.VariableSolver[t])&&void 0!==e?e:null}}o.VariableSolver={string:t=>o.SolveString(t),number:t=>o.SolveNumber(t),boolean:t=>o.SolveBoolean(t),dynamic:t=>o.SolveDynamic(t)};class s{constructor(t,e,a,n,o=!1){this.__events=t,this.__conditions=e,this.__actions=a,this.__boxes=n.boxes,this.__usedCommands=n.used_commands,this.__isDebug=o,this.__commandHashMap=s.CreateHashMap([...this.__events,...this.__conditions,...this.__actions])}static CreateHashMap(t){const e=new Map;return t.forEach((t=>e.set(t.id,t))),e}static ParseVariables(t,e,a,n){const o={};for(const r in e)o[r]=s.ParseVariable(t,e,r,a,n);return o}static ParseVariable(t,e,a,n,s){const r=e[a].replace(/{{3}\s*(.*?)\s*}{3}/gim,((t,e)=>{let a=t;return e in s&&(a=s[e]),"string"!=typeof a&&(a=JSON.stringify(a)),a})).replace(/{{2}\s*(.*?)\s*}{2}/gim,((t,e)=>{let a=null;return e in n?a=n[e]:e in s&&(a=s[e]),"string"!=typeof a&&(a=JSON.stringify(a)),a})),h=o.GetVariableType(t,a),i=o.GetVariableSolver(h);if(!i)throw new Error(`The unknown '${h}' type.`);return i(r)}static RunCommand(t,e,a){return new Promise(((n,o)=>{const r=s.ParseVariables(t,e,a.local,a.global);t.fn.call(r,a,n,o)}))}static RunCommandAsync(t,e,a,n,o){const r=s.ParseVariables(t,e,a.local,a.global);t.fn.call(r,a,n,o)}static FindBox(t,e){var a;return null!==(a=t.find((t=>t.id===e)))&&void 0!==a?a:null}async __runCommand(t,e){var a;const{command_id:n,variables:o}=t,r=null!==(a=this.__commandHashMap.get(n))&&void 0!==a?a:null;if(null!==r)return await s.RunCommand(r,o,e);throw new Error(`The '${n}' command not exists.`)}__runCommandAsync(t,e,a,n){var o;const{command_id:r,variables:h}=t,i=null!==(o=this.__commandHashMap.get(r))&&void 0!==o?o:null;if(null===i)throw new Error(`The '${r}' command not exists.`);s.RunCommandAsync(i,h,e,a,n)}__runCommands(t,e){const a=new Promise((async(a,n)=>{let o=!1;for(const a of t){if(o)return;await new Promise(((t,n)=>this.__runCommand(a,e).then(t).catch(n))).catch((t=>{o=!0,n({format:a,data:e,reason:t})}))}a()}));return a.catch((t=>{this.__isDebug&&console.error(t)})),a}__recursiveBox(t,e){const a=t.next_box_ids.filter((t=>s.FindBox(this.__boxes,t))).map((t=>s.FindBox(this.__boxes,t)));this.__runCommands(t.conditions,e).then((()=>this.__runCommands(t.actions,e))).then((()=>{a.forEach((t=>this.__recursiveBox(t,e)))}))}__attachEvent(){this.__boxes.forEach((t=>{t.events.forEach((e=>{this.__runCommandAsync(e,{event:null,local:{},global:globalThis},(e=>this.__recursiveBox(t,e)),(t=>console.error(t)))}))}))}init(){this.__attachEvent()}setDebugMode(t){this.__isDebug=t}}})();var o=n.R;export{o as Runner}; | ||
var t={87:(t,e,a)=>{var n=a(361);n.prototype.formulaEval=function(){for(var t,e,a,n=[],o=this.value,s=0;s<o.length;s++)1===o[s].type||3===o[s].type?n.push({value:3===o[s].type?o[s].show:o[s].value,type:1}):13===o[s].type?n.push({value:o[s].show,type:1}):0===o[s].type?n[n.length-1]={value:o[s].show+("-"!=o[s].show?"(":"")+n[n.length-1].value+("-"!=o[s].show?")":""),type:0}:7===o[s].type?n[n.length-1]={value:(1!=n[n.length-1].type?"(":"")+n[n.length-1].value+(1!=n[n.length-1].type?")":"")+o[s].show,type:7}:10===o[s].type?(t=n.pop(),e=n.pop(),"P"===o[s].show||"C"===o[s].show?n.push({value:"<sup>"+e.value+"</sup>"+o[s].show+"<sub>"+t.value+"</sub>",type:10}):n.push({value:(1!=e.type?"(":"")+e.value+(1!=e.type?")":"")+"<sup>"+t.value+"</sup>",type:1})):2===o[s].type||9===o[s].type?(t=n.pop(),e=n.pop(),n.push({value:(1!=e.type?"(":"")+e.value+(1!=e.type?")":"")+o[s].show+(1!=t.type?"(":"")+t.value+(1!=t.type?")":""),type:o[s].type})):12===o[s].type&&(t=n.pop(),e=n.pop(),a=n.pop(),n.push({value:o[s].show+"("+a.value+","+e.value+","+t.value+")",type:12}));return n[0].value},t.exports=n},735:(t,e,a)=>{var n=a(553);function o(t,e){for(var a=0;a<t.length;a++)t[a]+=e;return t}var s=["sin","cos","tan","pi","(",")","P","C"," ","asin","acos","atan","7","8","9","int","cosh","acosh","ln","^","root","4","5","6","/","!","tanh","atanh","Mod","1","2","3","*","sinh","asinh","e","log","0",".","+","-",",","Sigma","n","Pi","pow","&"],r=["sin","cos","tan","π","(",")","P","C"," ","asin","acos","atan","7","8","9","Int","cosh","acosh"," ln","^","root","4","5","6","÷","!","tanh","atanh"," Mod ","1","2","3","×","sinh","asinh","e"," log","0",".","+","-",",","Σ","n","Π","pow","&"],h=[n.math.sin,n.math.cos,n.math.tan,"PI","(",")",n.math.P,n.math.C," ".anchor,n.math.asin,n.math.acos,n.math.atan,"7","8","9",Math.floor,n.math.cosh,n.math.acosh,Math.log,Math.pow,Math.sqrt,"4","5","6",n.math.div,n.math.fact,n.math.tanh,n.math.atanh,n.math.mod,"1","2","3",n.math.mul,n.math.sinh,n.math.asinh,"E",n.math.log,"0",".",n.math.add,n.math.sub,",",n.math.sigma,"n",n.math.Pi,Math.pow,n.math.and],i={0:11,1:0,2:3,3:0,4:0,5:0,6:0,7:11,8:11,9:1,10:10,11:0,12:11,13:0,14:-1},u=[0,0,0,3,4,5,10,10,14,0,0,0,1,1,1,0,0,0,0,10,0,1,1,1,2,7,0,0,2,1,1,1,2,0,0,3,0,1,6,9,9,11,12,13,12,8,9],p={0:!0,1:!0,3:!0,4:!0,6:!0,8:!0,9:!0,12:!0,13:!0,14:!0},l={0:!0,1:!0,2:!0,3:!0,4:!0,5:!0,6:!0,7:!0,8:!0,9:!0,10:!0,11:!0,12:!0,13:!0},c={0:!0,3:!0,4:!0,8:!0,12:!0,13:!0},v={},f={0:!0,1:!0,3:!0,4:!0,6:!0,8:!0,12:!0,13:!0},m={1:!0},y=[[],["1","2","3","7","8","9","4","5","6","+","-","*","/","(",")","^","!","P","C","e","0",".",",","n"," ","&"],["pi","ln","Pi"],["sin","cos","tan","Del","int","Mod","log","pow"],["asin","acos","atan","cosh","root","tanh","sinh"],["acosh","atanh","asinh","Sigma"]];function d(t,e,a,n){for(var o=0;o<n;o++)if(t[a+o]!==e[o])return!1;return!0}n.addToken=function(t){for(var e=0;e<t.length;e++){var a=t[e].token.length,n=-1;y[a]=y[a]||[];for(var o=0;o<y[a].length;o++)if(t[e].token===y[a][o]){n=s.indexOf(y[a][o]);break}-1===n?(s.push(t[e].token),u.push(t[e].type),y.length<=t[e].token.length&&(y[t[e].token.length]=[]),y[t[e].token.length].push(t[e].token),h.push(t[e].value),r.push(t[e].show)):(s[n]=t[e].token,u[n]=t[e].type,h[n]=t[e].value,r[n]=t[e].show)}},n.lex=function(t,e){var a,g={value:n.math.changeSign,type:0,pre:21,show:"-"},w={value:")",show:")",type:5,pre:0},_={value:"(",type:4,pre:0,show:"("},x=[_],M=[],b=t,E=p,P=0,S=v,C="";void 0!==e&&n.addToken(e);var D={},k=function(t){for(var e,a,o,p=[],l=t.length,c=0;c<l;c++)if(!(c<l-1&&" "===t[c]&&" "===t[c+1])){for(e="",a=t.length-c>y.length-2?y.length-1:t.length-c;a>0;a--)if(void 0!==y[a])for(o=0;o<y[a].length;o++)d(t,y[a][o],c,a)&&(e=y[a][o],o=y[a].length,a=0);if(c+=e.length-1,""===e)throw new n.Exception("Can't understand after "+t.slice(c));var v=s.indexOf(e);p.push({index:v,token:e,type:u[v],eval:h[v],precedence:i[u[v]],show:r[v]})}return p}(b);for(a=0;a<k.length;a++){var N=k[a];if(14!==N.type){var R,V=N.token,B=N.type,I=N.eval,O=N.precedence,T=N.show,F=x[x.length-1];for(R=M.length;R--&&0===M[R];)if(-1!==[0,2,3,4,5,9,11,12,13].indexOf(B)){if(!0!==E[B])throw new n.Exception(V+" is not allowed after "+C);x.push(w),E=l,S=f,M.pop()}if(!0!==E[B])throw new n.Exception(V+" is not allowed after "+C);if(!0===S[B]&&(B=2,I=n.math.mul,T="×",O=3,a-=1),D={value:I,type:B,pre:O,show:T},0===B)E=p,S=v,o(M,2),x.push(D),4!==k[a+1].type&&(x.push(_),M.push(2));else if(1===B)1===F.type?(F.value+=I,o(M,1)):x.push(D),E=l,S=c;else if(2===B)E=p,S=v,o(M,2),x.push(D);else if(3===B)x.push(D),E=l,S=f;else if(4===B)o(M,1),P++,E=p,S=v,x.push(D);else if(5===B){if(!P)throw new n.Exception("Closing parenthesis are more than opening one, wait What!!!");P--,E=l,S=f,x.push(D),o(M,1)}else if(6===B){if(F.hasDec)throw new n.Exception("Two decimals are not allowed in one number");1!==F.type&&(F={value:0,type:1,pre:0},x.push(F)),E=m,o(M,1),S=v,F.value+=I,F.hasDec=!0}else 7===B&&(E=l,S=f,o(M,1),x.push(D));8===B?(E=p,S=v,o(M,4),x.push(D),4!==k[a+1].type&&(x.push(_),M.push(4))):9===B?(9===F.type?F.value===n.math.add?(F.value=I,F.show=T,o(M,1)):F.value===n.math.sub&&"-"===T&&(F.value=n.math.add,F.show="+",o(M,1)):5!==F.type&&7!==F.type&&1!==F.type&&3!==F.type&&13!==F.type?"-"===V&&(E=p,S=v,o(M,2).push(2),x.push(g),x.push(_)):(x.push(D),o(M,2)),E=p,S=v):10===B?(E=p,S=v,o(M,2),x.push(D)):11===B?(E=p,S=v,x.push(D)):12===B?(E=p,S=v,o(M,6),x.push(D),4!==k[a+1].type&&(x.push(_),M.push(6))):13===B&&(E=l,S=f,x.push(D)),o(M,-1),C=V}else if(a>0&&a<k.length-1&&1===k[a+1].type&&(1===k[a-1].type||6===k[a-1].type))throw new n.Exception("Unexpected Space")}for(R=M.length;R--;)x.push(w);if(!0!==E[5])throw new n.Exception("complete the expression");for(;P--;)x.push(w);return x.push(w),new n(x)},t.exports=n},553:t=>{var e=function(t){this.value=t};e.math={isDegree:!0,acos:function(t){return e.math.isDegree?180/Math.PI*Math.acos(t):Math.acos(t)},add:function(t,e){return t+e},asin:function(t){return e.math.isDegree?180/Math.PI*Math.asin(t):Math.asin(t)},atan:function(t){return e.math.isDegree?180/Math.PI*Math.atan(t):Math.atan(t)},acosh:function(t){return Math.log(t+Math.sqrt(t*t-1))},asinh:function(t){return Math.log(t+Math.sqrt(t*t+1))},atanh:function(t){return Math.log((1+t)/(1-t))},C:function(t,a){var n=1,o=t-a,s=a;s<o&&(s=o,o=a);for(var r=s+1;r<=t;r++)n*=r;return n/e.math.fact(o)},changeSign:function(t){return-t},cos:function(t){return e.math.isDegree&&(t=e.math.toRadian(t)),Math.cos(t)},cosh:function(t){return(Math.pow(Math.E,t)+Math.pow(Math.E,-1*t))/2},div:function(t,e){return t/e},fact:function(t){if(t%1!=0)return"NaN";for(var e=1,a=2;a<=t;a++)e*=a;return e},inverse:function(t){return 1/t},log:function(t){return Math.log(t)/Math.log(10)},mod:function(t,e){return t%e},mul:function(t,e){return t*e},P:function(t,e){for(var a=1,n=Math.floor(t)-Math.floor(e)+1;n<=Math.floor(t);n++)a*=n;return a},Pi:function(t,e,a){for(var n=1,o=t;o<=e;o++)n*=Number(a.postfixEval({n:o}));return n},pow10x:function(t){for(var e=1;t--;)e*=10;return e},sigma:function(t,e,a){for(var n=0,o=t;o<=e;o++)n+=Number(a.postfixEval({n:o}));return n},sin:function(t){return e.math.isDegree&&(t=e.math.toRadian(t)),Math.sin(t)},sinh:function(t){return(Math.pow(Math.E,t)-Math.pow(Math.E,-1*t))/2},sub:function(t,e){return t-e},tan:function(t){return e.math.isDegree&&(t=e.math.toRadian(t)),Math.tan(t)},tanh:function(t){return e.sinha(t)/e.cosha(t)},toRadian:function(t){return t*Math.PI/180},and:function(t,e){return t&e}},e.Exception=function(t){this.message=t},t.exports=e},186:(t,e,a)=>{var n=a(735);n.prototype.toPostfix=function(){for(var t,e,a,o,s,r=[],h=[{value:"(",type:4,pre:0}],i=this.value,u=1;u<i.length;u++)if(1===i[u].type||3===i[u].type||13===i[u].type)1===i[u].type&&(i[u].value=Number(i[u].value)),r.push(i[u]);else if(4===i[u].type)h.push(i[u]);else if(5===i[u].type)for(;4!==(e=h.pop()).type;)r.push(e);else if(11===i[u].type){for(;4!==(e=h.pop()).type;)r.push(e);h.push(e)}else{o=(t=i[u]).pre,a=(s=h[h.length-1]).pre;var p="Math.pow"==s.value&&"Math.pow"==t.value;if(o>a)h.push(t);else{for(;a>=o&&!p||p&&o<a;)e=h.pop(),s=h[h.length-1],r.push(e),a=s.pre,p="Math.pow"==t.value&&"Math.pow"==s.value;h.push(t)}}return new n(r)},t.exports=n},361:(t,e,a)=>{var n=a(186);n.prototype.postfixEval=function(t){(t=t||{}).PI=Math.PI,t.E=Math.E;for(var e,a,o,s=[],r=this.value,h=void 0!==t.n,i=0;i<r.length;i++)1===r[i].type?s.push({value:r[i].value,type:1}):3===r[i].type?s.push({value:t[r[i].value],type:1}):0===r[i].type||7===r[i].type?void 0===s[s.length-1].type?s[s.length-1].value.push(r[i]):s[s.length-1].value=r[i].value(s[s.length-1].value):8===r[i].type?(e=s.pop(),a=s.pop(),s.push({type:1,value:r[i].value(a.value,e.value)})):10===r[i].type?(e=s.pop(),void 0===(a=s.pop()).type?(a.value=a.concat(e),a.value.push(r[i]),s.push(a)):void 0===e.type?(e.unshift(a),e.push(r[i]),s.push(e)):s.push({type:1,value:r[i].value(a.value,e.value)})):2===r[i].type||9===r[i].type?(e=s.pop(),void 0===(a=s.pop()).type?((a=a.concat(e)).push(r[i]),s.push(a)):void 0===e.type?(e.unshift(a),e.push(r[i]),s.push(e)):s.push({type:1,value:r[i].value(a.value,e.value)})):12===r[i].type?(void 0!==(e=s.pop()).type&&(e=[e]),a=s.pop(),o=s.pop(),s.push({type:1,value:r[i].value(o.value,a.value,new n(e))})):13===r[i].type&&(h?s.push({value:t[r[i].value],type:3}):s.push([r[i]]));if(s.length>1)throw new n.Exception("Uncaught Syntax error");return s[0].value>1e15?"Infinity":parseFloat(s[0].value.toFixed(15))},n.eval=function(t,e,a){return void 0===e?this.lex(t).toPostfix().postfixEval():void 0===a?void 0!==e.length?this.lex(t,e).toPostfix().postfixEval():this.lex(t).toPostfix().postfixEval(e):this.lex(t,e).toPostfix().postfixEval(a)},t.exports=n}},e={};function a(n){var o=e[n];if(void 0!==o)return o.exports;var s=e[n]={exports:{}};return t[n](s,s.exports,a),s.exports}a.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return a.d(e,{a:e}),e},a.d=(t,e)=>{for(var n in e)a.o(e,n)&&!a.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var n={};(()=>{a.d(n,{R:()=>s});var t=a(87),e=a.n(t);class o{static SolveString(t){return t}static SolveNumber(t){const a=e().eval(t);return Number(a)}static SolveBoolean(t){return!0===Boolean(t)}static SolveDynamic(t){let e;try{e=o.SolveNumber(t)}catch(a){try{e=JSON.parse(t)}catch(a){e=t}}return e}static GetVariableType(t,e){return e in t.variables?t.variables[e].type:null}static GetVariableSolver(t){var e;return null===t?null:null!==(e=o.VariableSolver[t])&&void 0!==e?e:null}}o.VariableSolver={string:t=>o.SolveString(t),number:t=>o.SolveNumber(t),boolean:t=>o.SolveBoolean(t),dynamic:t=>o.SolveDynamic(t)};class s{constructor(t,e,a,n,o=!1){this.__events=t,this.__conditions=e,this.__actions=a,this.__boxes=n.boxes,this.__usedCommands=n.used_commands,this.__isDebug=o,this.__commandHashMap=s.CreateHashMap([...this.__events,...this.__conditions,...this.__actions])}static CreateHashMap(t){const e=new Map;return t.forEach((t=>e.set(t.id,t))),e}static ParseVariables(t,e,a,n){const o={};for(const r in e)o[r]=s.ParseVariable(t,e,r,a,n);return o}static ParseVariable(t,e,a,n,s){const r=e[a].replace(/{{3}\s*(.*?)\s*}{3}/gim,((t,e)=>{let a=t;return e in s&&(a=s[e]),"string"!=typeof a&&(a=JSON.stringify(a)),a})).replace(/{{2}\s*(.*?)\s*}{2}/gim,((t,e)=>{let a=null;return e in n?a=n[e]:e in s&&(a=s[e]),"string"!=typeof a&&(a=JSON.stringify(a)),a})),h=o.GetVariableType(t,a),i=o.GetVariableSolver(h);if(!i)throw new Error(`The unknown '${h}' type.`);return i(r)}static RunCommand(t,e,a){return new Promise(((n,o)=>{const r=s.ParseVariables(t,e,a.local,a.global);t.fn.call(r,a,n,o)}))}static RunCommandAsync(t,e,a,n,o){const r=s.ParseVariables(t,e,a.local,a.global);t.fn.call(r,a,n,o)}static FindBox(t,e){var a;return null!==(a=t.find((t=>t.id===e)))&&void 0!==a?a:null}async __runCommand(t,e){var a;const{command_id:n,variables:o}=t,r=null!==(a=this.__commandHashMap.get(n))&&void 0!==a?a:null;if(null!==r)return await s.RunCommand(r,o,e);throw new Error(`The '${n}' command not exists.`)}__runCommandAsync(t,e,a,n){var o;const{command_id:r,variables:h}=t,i=null!==(o=this.__commandHashMap.get(r))&&void 0!==o?o:null;if(null===i)throw new Error(`The '${r}' command not exists.`);s.RunCommandAsync(i,h,e,a,n)}__runCommands(t,e){return new Promise((async(a,n)=>{for(const a of t)try{await this.__runCommand(a,e)}catch(t){return void n({format:a,data:e,reason:t})}a()}))}async __recursiveBox(t,e){const a=t.next_box_ids.filter((t=>s.FindBox(this.__boxes,t))).map((t=>s.FindBox(this.__boxes,t)));try{await this.__runCommands(t.conditions,e),await this.__runCommands(t.actions,e),a.forEach((t=>this.__recursiveBox(t,e)))}catch(t){this.__isDebug&&console.error(t)}}__attachEvent(){this.__boxes.forEach((t=>{t.events.forEach((e=>{const a={event:null,local:{},global:globalThis};this.__runCommandAsync(e,a,(e=>this.__recursiveBox(t,e)),(t=>console.error(t)))}))}))}init(){this.__attachEvent()}setDebugMode(t){this.__isDebug=t}}})();var o=n.R;export{o as Runner}; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Codraft=e():t.Codraft=e()}(self,(function(){return(()=>{var t={87:(t,e,a)=>{var n=a(361);n.prototype.formulaEval=function(){"use strict";for(var t,e,a,n=[],o=this.value,r=0;r<o.length;r++)1===o[r].type||3===o[r].type?n.push({value:3===o[r].type?o[r].show:o[r].value,type:1}):13===o[r].type?n.push({value:o[r].show,type:1}):0===o[r].type?n[n.length-1]={value:o[r].show+("-"!=o[r].show?"(":"")+n[n.length-1].value+("-"!=o[r].show?")":""),type:0}:7===o[r].type?n[n.length-1]={value:(1!=n[n.length-1].type?"(":"")+n[n.length-1].value+(1!=n[n.length-1].type?")":"")+o[r].show,type:7}:10===o[r].type?(t=n.pop(),e=n.pop(),"P"===o[r].show||"C"===o[r].show?n.push({value:"<sup>"+e.value+"</sup>"+o[r].show+"<sub>"+t.value+"</sub>",type:10}):n.push({value:(1!=e.type?"(":"")+e.value+(1!=e.type?")":"")+"<sup>"+t.value+"</sup>",type:1})):2===o[r].type||9===o[r].type?(t=n.pop(),e=n.pop(),n.push({value:(1!=e.type?"(":"")+e.value+(1!=e.type?")":"")+o[r].show+(1!=t.type?"(":"")+t.value+(1!=t.type?")":""),type:o[r].type})):12===o[r].type&&(t=n.pop(),e=n.pop(),a=n.pop(),n.push({value:o[r].show+"("+a.value+","+e.value+","+t.value+")",type:12}));return n[0].value},t.exports=n},735:(t,e,a)=>{"use strict";var n=a(553);function o(t,e){for(var a=0;a<t.length;a++)t[a]+=e;return t}var r=["sin","cos","tan","pi","(",")","P","C"," ","asin","acos","atan","7","8","9","int","cosh","acosh","ln","^","root","4","5","6","/","!","tanh","atanh","Mod","1","2","3","*","sinh","asinh","e","log","0",".","+","-",",","Sigma","n","Pi","pow","&"],s=["sin","cos","tan","π","(",")","P","C"," ","asin","acos","atan","7","8","9","Int","cosh","acosh"," ln","^","root","4","5","6","÷","!","tanh","atanh"," Mod ","1","2","3","×","sinh","asinh","e"," log","0",".","+","-",",","Σ","n","Π","pow","&"],i=[n.math.sin,n.math.cos,n.math.tan,"PI","(",")",n.math.P,n.math.C," ".anchor,n.math.asin,n.math.acos,n.math.atan,"7","8","9",Math.floor,n.math.cosh,n.math.acosh,Math.log,Math.pow,Math.sqrt,"4","5","6",n.math.div,n.math.fact,n.math.tanh,n.math.atanh,n.math.mod,"1","2","3",n.math.mul,n.math.sinh,n.math.asinh,"E",n.math.log,"0",".",n.math.add,n.math.sub,",",n.math.sigma,"n",n.math.Pi,Math.pow,n.math.and],u={0:11,1:0,2:3,3:0,4:0,5:0,6:0,7:11,8:11,9:1,10:10,11:0,12:11,13:0,14:-1},h=[0,0,0,3,4,5,10,10,14,0,0,0,1,1,1,0,0,0,0,10,0,1,1,1,2,7,0,0,2,1,1,1,2,0,0,3,0,1,6,9,9,11,12,13,12,8,9],p={0:!0,1:!0,3:!0,4:!0,6:!0,8:!0,9:!0,12:!0,13:!0,14:!0},l={0:!0,1:!0,2:!0,3:!0,4:!0,5:!0,6:!0,7:!0,8:!0,9:!0,10:!0,11:!0,12:!0,13:!0},c={0:!0,3:!0,4:!0,8:!0,12:!0,13:!0},v={},f={0:!0,1:!0,3:!0,4:!0,6:!0,8:!0,12:!0,13:!0},m={1:!0},y=[[],["1","2","3","7","8","9","4","5","6","+","-","*","/","(",")","^","!","P","C","e","0",".",",","n"," ","&"],["pi","ln","Pi"],["sin","cos","tan","Del","int","Mod","log","pow"],["asin","acos","atan","cosh","root","tanh","sinh"],["acosh","atanh","asinh","Sigma"]];function d(t,e,a,n){for(var o=0;o<n;o++)if(t[a+o]!==e[o])return!1;return!0}n.addToken=function(t){for(var e=0;e<t.length;e++){var a=t[e].token.length,n=-1;y[a]=y[a]||[];for(var o=0;o<y[a].length;o++)if(t[e].token===y[a][o]){n=r.indexOf(y[a][o]);break}-1===n?(r.push(t[e].token),h.push(t[e].type),y.length<=t[e].token.length&&(y[t[e].token.length]=[]),y[t[e].token.length].push(t[e].token),i.push(t[e].value),s.push(t[e].show)):(r[n]=t[e].token,h[n]=t[e].type,i[n]=t[e].value,s[n]=t[e].show)}},n.lex=function(t,e){var a,g={value:n.math.changeSign,type:0,pre:21,show:"-"},w={value:")",show:")",type:5,pre:0},_={value:"(",type:4,pre:0,show:"("},x=[_],b=[],M=t,P=p,E=0,S=v,C="";void 0!==e&&n.addToken(e);var D={},k=function(t){for(var e,a,o,p=[],l=t.length,c=0;c<l;c++)if(!(c<l-1&&" "===t[c]&&" "===t[c+1])){for(e="",a=t.length-c>y.length-2?y.length-1:t.length-c;a>0;a--)if(void 0!==y[a])for(o=0;o<y[a].length;o++)d(t,y[a][o],c,a)&&(e=y[a][o],o=y[a].length,a=0);if(c+=e.length-1,""===e)throw new n.Exception("Can't understand after "+t.slice(c));var v=r.indexOf(e);p.push({index:v,token:e,type:h[v],eval:i[v],precedence:u[h[v]],show:s[v]})}return p}(M);for(a=0;a<k.length;a++){var N=k[a];if(14!==N.type){var O,T=N.token,V=N.type,B=N.eval,I=N.precedence,R=N.show,j=x[x.length-1];for(O=b.length;O--&&0===b[O];)if(-1!==[0,2,3,4,5,9,11,12,13].indexOf(V)){if(!0!==P[V])throw new n.Exception(T+" is not allowed after "+C);x.push(w),P=l,S=f,b.pop()}if(!0!==P[V])throw new n.Exception(T+" is not allowed after "+C);if(!0===S[V]&&(V=2,B=n.math.mul,R="×",I=3,a-=1),D={value:B,type:V,pre:I,show:R},0===V)P=p,S=v,o(b,2),x.push(D),4!==k[a+1].type&&(x.push(_),b.push(2));else if(1===V)1===j.type?(j.value+=B,o(b,1)):x.push(D),P=l,S=c;else if(2===V)P=p,S=v,o(b,2),x.push(D);else if(3===V)x.push(D),P=l,S=f;else if(4===V)o(b,1),E++,P=p,S=v,x.push(D);else if(5===V){if(!E)throw new n.Exception("Closing parenthesis are more than opening one, wait What!!!");E--,P=l,S=f,x.push(D),o(b,1)}else if(6===V){if(j.hasDec)throw new n.Exception("Two decimals are not allowed in one number");1!==j.type&&(j={value:0,type:1,pre:0},x.push(j)),P=m,o(b,1),S=v,j.value+=B,j.hasDec=!0}else 7===V&&(P=l,S=f,o(b,1),x.push(D));8===V?(P=p,S=v,o(b,4),x.push(D),4!==k[a+1].type&&(x.push(_),b.push(4))):9===V?(9===j.type?j.value===n.math.add?(j.value=B,j.show=R,o(b,1)):j.value===n.math.sub&&"-"===R&&(j.value=n.math.add,j.show="+",o(b,1)):5!==j.type&&7!==j.type&&1!==j.type&&3!==j.type&&13!==j.type?"-"===T&&(P=p,S=v,o(b,2).push(2),x.push(g),x.push(_)):(x.push(D),o(b,2)),P=p,S=v):10===V?(P=p,S=v,o(b,2),x.push(D)):11===V?(P=p,S=v,x.push(D)):12===V?(P=p,S=v,o(b,6),x.push(D),4!==k[a+1].type&&(x.push(_),b.push(6))):13===V&&(P=l,S=f,x.push(D)),o(b,-1),C=T}else if(a>0&&a<k.length-1&&1===k[a+1].type&&(1===k[a-1].type||6===k[a-1].type))throw new n.Exception("Unexpected Space")}for(O=b.length;O--;)x.push(w);if(!0!==P[5])throw new n.Exception("complete the expression");for(;E--;)x.push(w);return x.push(w),new n(x)},t.exports=n},553:t=>{"use strict";var e=function(t){this.value=t};e.math={isDegree:!0,acos:function(t){return e.math.isDegree?180/Math.PI*Math.acos(t):Math.acos(t)},add:function(t,e){return t+e},asin:function(t){return e.math.isDegree?180/Math.PI*Math.asin(t):Math.asin(t)},atan:function(t){return e.math.isDegree?180/Math.PI*Math.atan(t):Math.atan(t)},acosh:function(t){return Math.log(t+Math.sqrt(t*t-1))},asinh:function(t){return Math.log(t+Math.sqrt(t*t+1))},atanh:function(t){return Math.log((1+t)/(1-t))},C:function(t,a){var n=1,o=t-a,r=a;r<o&&(r=o,o=a);for(var s=r+1;s<=t;s++)n*=s;return n/e.math.fact(o)},changeSign:function(t){return-t},cos:function(t){return e.math.isDegree&&(t=e.math.toRadian(t)),Math.cos(t)},cosh:function(t){return(Math.pow(Math.E,t)+Math.pow(Math.E,-1*t))/2},div:function(t,e){return t/e},fact:function(t){if(t%1!=0)return"NaN";for(var e=1,a=2;a<=t;a++)e*=a;return e},inverse:function(t){return 1/t},log:function(t){return Math.log(t)/Math.log(10)},mod:function(t,e){return t%e},mul:function(t,e){return t*e},P:function(t,e){for(var a=1,n=Math.floor(t)-Math.floor(e)+1;n<=Math.floor(t);n++)a*=n;return a},Pi:function(t,e,a){for(var n=1,o=t;o<=e;o++)n*=Number(a.postfixEval({n:o}));return n},pow10x:function(t){for(var e=1;t--;)e*=10;return e},sigma:function(t,e,a){for(var n=0,o=t;o<=e;o++)n+=Number(a.postfixEval({n:o}));return n},sin:function(t){return e.math.isDegree&&(t=e.math.toRadian(t)),Math.sin(t)},sinh:function(t){return(Math.pow(Math.E,t)-Math.pow(Math.E,-1*t))/2},sub:function(t,e){return t-e},tan:function(t){return e.math.isDegree&&(t=e.math.toRadian(t)),Math.tan(t)},tanh:function(t){return e.sinha(t)/e.cosha(t)},toRadian:function(t){return t*Math.PI/180},and:function(t,e){return t&e}},e.Exception=function(t){this.message=t},t.exports=e},186:(t,e,a)=>{var n=a(735);n.prototype.toPostfix=function(){"use strict";for(var t,e,a,o,r,s=[],i=[{value:"(",type:4,pre:0}],u=this.value,h=1;h<u.length;h++)if(1===u[h].type||3===u[h].type||13===u[h].type)1===u[h].type&&(u[h].value=Number(u[h].value)),s.push(u[h]);else if(4===u[h].type)i.push(u[h]);else if(5===u[h].type)for(;4!==(e=i.pop()).type;)s.push(e);else if(11===u[h].type){for(;4!==(e=i.pop()).type;)s.push(e);i.push(e)}else{o=(t=u[h]).pre,a=(r=i[i.length-1]).pre;var p="Math.pow"==r.value&&"Math.pow"==t.value;if(o>a)i.push(t);else{for(;a>=o&&!p||p&&o<a;)e=i.pop(),r=i[i.length-1],s.push(e),a=r.pre,p="Math.pow"==t.value&&"Math.pow"==r.value;i.push(t)}}return new n(s)},t.exports=n},361:(t,e,a)=>{var n=a(186);n.prototype.postfixEval=function(t){"use strict";(t=t||{}).PI=Math.PI,t.E=Math.E;for(var e,a,o,r=[],s=this.value,i=void 0!==t.n,u=0;u<s.length;u++)1===s[u].type?r.push({value:s[u].value,type:1}):3===s[u].type?r.push({value:t[s[u].value],type:1}):0===s[u].type||7===s[u].type?void 0===r[r.length-1].type?r[r.length-1].value.push(s[u]):r[r.length-1].value=s[u].value(r[r.length-1].value):8===s[u].type?(e=r.pop(),a=r.pop(),r.push({type:1,value:s[u].value(a.value,e.value)})):10===s[u].type?(e=r.pop(),void 0===(a=r.pop()).type?(a.value=a.concat(e),a.value.push(s[u]),r.push(a)):void 0===e.type?(e.unshift(a),e.push(s[u]),r.push(e)):r.push({type:1,value:s[u].value(a.value,e.value)})):2===s[u].type||9===s[u].type?(e=r.pop(),void 0===(a=r.pop()).type?((a=a.concat(e)).push(s[u]),r.push(a)):void 0===e.type?(e.unshift(a),e.push(s[u]),r.push(e)):r.push({type:1,value:s[u].value(a.value,e.value)})):12===s[u].type?(void 0!==(e=r.pop()).type&&(e=[e]),a=r.pop(),o=r.pop(),r.push({type:1,value:s[u].value(o.value,a.value,new n(e))})):13===s[u].type&&(i?r.push({value:t[s[u].value],type:3}):r.push([s[u]]));if(r.length>1)throw new n.Exception("Uncaught Syntax error");return r[0].value>1e15?"Infinity":parseFloat(r[0].value.toFixed(15))},n.eval=function(t,e,a){return void 0===e?this.lex(t).toPostfix().postfixEval():void 0===a?void 0!==e.length?this.lex(t,e).toPostfix().postfixEval():this.lex(t).toPostfix().postfixEval(e):this.lex(t,e).toPostfix().postfixEval(a)},t.exports=n}},e={};function a(n){var o=e[n];if(void 0!==o)return o.exports;var r=e[n]={exports:{}};return t[n](r,r.exports,a),r.exports}a.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return a.d(e,{a:e}),e},a.d=(t,e)=>{for(var n in e)a.o(e,n)&&!a.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";a.r(n),a.d(n,{Runner:()=>r});var t=a(87),e=a.n(t);class o{static SolveString(t){return t}static SolveNumber(t){const a=e().eval(t);return Number(a)}static SolveBoolean(t){return!0===Boolean(t)}static SolveDynamic(t){let e;try{e=o.SolveNumber(t)}catch(a){try{e=JSON.parse(t)}catch(a){e=t}}return e}static GetVariableType(t,e){return e in t.variables?t.variables[e].type:null}static GetVariableSolver(t){var e;return null===t?null:null!==(e=o.VariableSolver[t])&&void 0!==e?e:null}}o.VariableSolver={string:t=>o.SolveString(t),number:t=>o.SolveNumber(t),boolean:t=>o.SolveBoolean(t),dynamic:t=>o.SolveDynamic(t)};class r{constructor(t,e,a,n,o=!1){this.__events=t,this.__conditions=e,this.__actions=a,this.__boxes=n.boxes,this.__usedCommands=n.used_commands,this.__isDebug=o,this.__commandHashMap=r.CreateHashMap([...this.__events,...this.__conditions,...this.__actions])}static CreateHashMap(t){const e=new Map;return t.forEach((t=>e.set(t.id,t))),e}static ParseVariables(t,e,a,n){const o={};for(const s in e)o[s]=r.ParseVariable(t,e,s,a,n);return o}static ParseVariable(t,e,a,n,r){const s=e[a].replace(/{{3}\s*(.*?)\s*}{3}/gim,((t,e)=>{let a=t;return e in r&&(a=r[e]),"string"!=typeof a&&(a=JSON.stringify(a)),a})).replace(/{{2}\s*(.*?)\s*}{2}/gim,((t,e)=>{let a=null;return e in n?a=n[e]:e in r&&(a=r[e]),"string"!=typeof a&&(a=JSON.stringify(a)),a})),i=o.GetVariableType(t,a),u=o.GetVariableSolver(i);if(!u)throw new Error(`The unknown '${i}' type.`);return u(s)}static RunCommand(t,e,a){return new Promise(((n,o)=>{const s=r.ParseVariables(t,e,a.local,a.global);t.fn.call(s,a,n,o)}))}static RunCommandAsync(t,e,a,n,o){const s=r.ParseVariables(t,e,a.local,a.global);t.fn.call(s,a,n,o)}static FindBox(t,e){var a;return null!==(a=t.find((t=>t.id===e)))&&void 0!==a?a:null}async __runCommand(t,e){var a;const{command_id:n,variables:o}=t,s=null!==(a=this.__commandHashMap.get(n))&&void 0!==a?a:null;if(null!==s)return await r.RunCommand(s,o,e);throw new Error(`The '${n}' command not exists.`)}__runCommandAsync(t,e,a,n){var o;const{command_id:s,variables:i}=t,u=null!==(o=this.__commandHashMap.get(s))&&void 0!==o?o:null;if(null===u)throw new Error(`The '${s}' command not exists.`);r.RunCommandAsync(u,i,e,a,n)}__runCommands(t,e){const a=new Promise((async(a,n)=>{let o=!1;for(const a of t){if(o)return;await new Promise(((t,n)=>this.__runCommand(a,e).then(t).catch(n))).catch((t=>{o=!0,n({format:a,data:e,reason:t})}))}a()}));return a.catch((t=>{this.__isDebug&&console.error(t)})),a}__recursiveBox(t,e){const a=t.next_box_ids.filter((t=>r.FindBox(this.__boxes,t))).map((t=>r.FindBox(this.__boxes,t)));this.__runCommands(t.conditions,e).then((()=>this.__runCommands(t.actions,e))).then((()=>{a.forEach((t=>this.__recursiveBox(t,e)))}))}__attachEvent(){this.__boxes.forEach((t=>{t.events.forEach((e=>{this.__runCommandAsync(e,{event:null,local:{},global:globalThis},(e=>this.__recursiveBox(t,e)),(t=>console.error(t)))}))}))}init(){this.__attachEvent()}setDebugMode(t){this.__isDebug=t}}})(),n})()})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Codraft=e():t.Codraft=e()}(self,(function(){return(()=>{var t={87:(t,e,a)=>{var n=a(361);n.prototype.formulaEval=function(){"use strict";for(var t,e,a,n=[],o=this.value,r=0;r<o.length;r++)1===o[r].type||3===o[r].type?n.push({value:3===o[r].type?o[r].show:o[r].value,type:1}):13===o[r].type?n.push({value:o[r].show,type:1}):0===o[r].type?n[n.length-1]={value:o[r].show+("-"!=o[r].show?"(":"")+n[n.length-1].value+("-"!=o[r].show?")":""),type:0}:7===o[r].type?n[n.length-1]={value:(1!=n[n.length-1].type?"(":"")+n[n.length-1].value+(1!=n[n.length-1].type?")":"")+o[r].show,type:7}:10===o[r].type?(t=n.pop(),e=n.pop(),"P"===o[r].show||"C"===o[r].show?n.push({value:"<sup>"+e.value+"</sup>"+o[r].show+"<sub>"+t.value+"</sub>",type:10}):n.push({value:(1!=e.type?"(":"")+e.value+(1!=e.type?")":"")+"<sup>"+t.value+"</sup>",type:1})):2===o[r].type||9===o[r].type?(t=n.pop(),e=n.pop(),n.push({value:(1!=e.type?"(":"")+e.value+(1!=e.type?")":"")+o[r].show+(1!=t.type?"(":"")+t.value+(1!=t.type?")":""),type:o[r].type})):12===o[r].type&&(t=n.pop(),e=n.pop(),a=n.pop(),n.push({value:o[r].show+"("+a.value+","+e.value+","+t.value+")",type:12}));return n[0].value},t.exports=n},735:(t,e,a)=>{"use strict";var n=a(553);function o(t,e){for(var a=0;a<t.length;a++)t[a]+=e;return t}var r=["sin","cos","tan","pi","(",")","P","C"," ","asin","acos","atan","7","8","9","int","cosh","acosh","ln","^","root","4","5","6","/","!","tanh","atanh","Mod","1","2","3","*","sinh","asinh","e","log","0",".","+","-",",","Sigma","n","Pi","pow","&"],s=["sin","cos","tan","π","(",")","P","C"," ","asin","acos","atan","7","8","9","Int","cosh","acosh"," ln","^","root","4","5","6","÷","!","tanh","atanh"," Mod ","1","2","3","×","sinh","asinh","e"," log","0",".","+","-",",","Σ","n","Π","pow","&"],i=[n.math.sin,n.math.cos,n.math.tan,"PI","(",")",n.math.P,n.math.C," ".anchor,n.math.asin,n.math.acos,n.math.atan,"7","8","9",Math.floor,n.math.cosh,n.math.acosh,Math.log,Math.pow,Math.sqrt,"4","5","6",n.math.div,n.math.fact,n.math.tanh,n.math.atanh,n.math.mod,"1","2","3",n.math.mul,n.math.sinh,n.math.asinh,"E",n.math.log,"0",".",n.math.add,n.math.sub,",",n.math.sigma,"n",n.math.Pi,Math.pow,n.math.and],u={0:11,1:0,2:3,3:0,4:0,5:0,6:0,7:11,8:11,9:1,10:10,11:0,12:11,13:0,14:-1},h=[0,0,0,3,4,5,10,10,14,0,0,0,1,1,1,0,0,0,0,10,0,1,1,1,2,7,0,0,2,1,1,1,2,0,0,3,0,1,6,9,9,11,12,13,12,8,9],p={0:!0,1:!0,3:!0,4:!0,6:!0,8:!0,9:!0,12:!0,13:!0,14:!0},l={0:!0,1:!0,2:!0,3:!0,4:!0,5:!0,6:!0,7:!0,8:!0,9:!0,10:!0,11:!0,12:!0,13:!0},c={0:!0,3:!0,4:!0,8:!0,12:!0,13:!0},v={},f={0:!0,1:!0,3:!0,4:!0,6:!0,8:!0,12:!0,13:!0},y={1:!0},m=[[],["1","2","3","7","8","9","4","5","6","+","-","*","/","(",")","^","!","P","C","e","0",".",",","n"," ","&"],["pi","ln","Pi"],["sin","cos","tan","Del","int","Mod","log","pow"],["asin","acos","atan","cosh","root","tanh","sinh"],["acosh","atanh","asinh","Sigma"]];function d(t,e,a,n){for(var o=0;o<n;o++)if(t[a+o]!==e[o])return!1;return!0}n.addToken=function(t){for(var e=0;e<t.length;e++){var a=t[e].token.length,n=-1;m[a]=m[a]||[];for(var o=0;o<m[a].length;o++)if(t[e].token===m[a][o]){n=r.indexOf(m[a][o]);break}-1===n?(r.push(t[e].token),h.push(t[e].type),m.length<=t[e].token.length&&(m[t[e].token.length]=[]),m[t[e].token.length].push(t[e].token),i.push(t[e].value),s.push(t[e].show)):(r[n]=t[e].token,h[n]=t[e].type,i[n]=t[e].value,s[n]=t[e].show)}},n.lex=function(t,e){var a,g={value:n.math.changeSign,type:0,pre:21,show:"-"},w={value:")",show:")",type:5,pre:0},_={value:"(",type:4,pre:0,show:"("},x=[_],b=[],M=t,P=p,E=0,S=v,C="";void 0!==e&&n.addToken(e);var D={},k=function(t){for(var e,a,o,p=[],l=t.length,c=0;c<l;c++)if(!(c<l-1&&" "===t[c]&&" "===t[c+1])){for(e="",a=t.length-c>m.length-2?m.length-1:t.length-c;a>0;a--)if(void 0!==m[a])for(o=0;o<m[a].length;o++)d(t,m[a][o],c,a)&&(e=m[a][o],o=m[a].length,a=0);if(c+=e.length-1,""===e)throw new n.Exception("Can't understand after "+t.slice(c));var v=r.indexOf(e);p.push({index:v,token:e,type:h[v],eval:i[v],precedence:u[h[v]],show:s[v]})}return p}(M);for(a=0;a<k.length;a++){var N=k[a];if(14!==N.type){var O,T=N.token,V=N.type,B=N.eval,I=N.precedence,R=N.show,j=x[x.length-1];for(O=b.length;O--&&0===b[O];)if(-1!==[0,2,3,4,5,9,11,12,13].indexOf(V)){if(!0!==P[V])throw new n.Exception(T+" is not allowed after "+C);x.push(w),P=l,S=f,b.pop()}if(!0!==P[V])throw new n.Exception(T+" is not allowed after "+C);if(!0===S[V]&&(V=2,B=n.math.mul,R="×",I=3,a-=1),D={value:B,type:V,pre:I,show:R},0===V)P=p,S=v,o(b,2),x.push(D),4!==k[a+1].type&&(x.push(_),b.push(2));else if(1===V)1===j.type?(j.value+=B,o(b,1)):x.push(D),P=l,S=c;else if(2===V)P=p,S=v,o(b,2),x.push(D);else if(3===V)x.push(D),P=l,S=f;else if(4===V)o(b,1),E++,P=p,S=v,x.push(D);else if(5===V){if(!E)throw new n.Exception("Closing parenthesis are more than opening one, wait What!!!");E--,P=l,S=f,x.push(D),o(b,1)}else if(6===V){if(j.hasDec)throw new n.Exception("Two decimals are not allowed in one number");1!==j.type&&(j={value:0,type:1,pre:0},x.push(j)),P=y,o(b,1),S=v,j.value+=B,j.hasDec=!0}else 7===V&&(P=l,S=f,o(b,1),x.push(D));8===V?(P=p,S=v,o(b,4),x.push(D),4!==k[a+1].type&&(x.push(_),b.push(4))):9===V?(9===j.type?j.value===n.math.add?(j.value=B,j.show=R,o(b,1)):j.value===n.math.sub&&"-"===R&&(j.value=n.math.add,j.show="+",o(b,1)):5!==j.type&&7!==j.type&&1!==j.type&&3!==j.type&&13!==j.type?"-"===T&&(P=p,S=v,o(b,2).push(2),x.push(g),x.push(_)):(x.push(D),o(b,2)),P=p,S=v):10===V?(P=p,S=v,o(b,2),x.push(D)):11===V?(P=p,S=v,x.push(D)):12===V?(P=p,S=v,o(b,6),x.push(D),4!==k[a+1].type&&(x.push(_),b.push(6))):13===V&&(P=l,S=f,x.push(D)),o(b,-1),C=T}else if(a>0&&a<k.length-1&&1===k[a+1].type&&(1===k[a-1].type||6===k[a-1].type))throw new n.Exception("Unexpected Space")}for(O=b.length;O--;)x.push(w);if(!0!==P[5])throw new n.Exception("complete the expression");for(;E--;)x.push(w);return x.push(w),new n(x)},t.exports=n},553:t=>{"use strict";var e=function(t){this.value=t};e.math={isDegree:!0,acos:function(t){return e.math.isDegree?180/Math.PI*Math.acos(t):Math.acos(t)},add:function(t,e){return t+e},asin:function(t){return e.math.isDegree?180/Math.PI*Math.asin(t):Math.asin(t)},atan:function(t){return e.math.isDegree?180/Math.PI*Math.atan(t):Math.atan(t)},acosh:function(t){return Math.log(t+Math.sqrt(t*t-1))},asinh:function(t){return Math.log(t+Math.sqrt(t*t+1))},atanh:function(t){return Math.log((1+t)/(1-t))},C:function(t,a){var n=1,o=t-a,r=a;r<o&&(r=o,o=a);for(var s=r+1;s<=t;s++)n*=s;return n/e.math.fact(o)},changeSign:function(t){return-t},cos:function(t){return e.math.isDegree&&(t=e.math.toRadian(t)),Math.cos(t)},cosh:function(t){return(Math.pow(Math.E,t)+Math.pow(Math.E,-1*t))/2},div:function(t,e){return t/e},fact:function(t){if(t%1!=0)return"NaN";for(var e=1,a=2;a<=t;a++)e*=a;return e},inverse:function(t){return 1/t},log:function(t){return Math.log(t)/Math.log(10)},mod:function(t,e){return t%e},mul:function(t,e){return t*e},P:function(t,e){for(var a=1,n=Math.floor(t)-Math.floor(e)+1;n<=Math.floor(t);n++)a*=n;return a},Pi:function(t,e,a){for(var n=1,o=t;o<=e;o++)n*=Number(a.postfixEval({n:o}));return n},pow10x:function(t){for(var e=1;t--;)e*=10;return e},sigma:function(t,e,a){for(var n=0,o=t;o<=e;o++)n+=Number(a.postfixEval({n:o}));return n},sin:function(t){return e.math.isDegree&&(t=e.math.toRadian(t)),Math.sin(t)},sinh:function(t){return(Math.pow(Math.E,t)-Math.pow(Math.E,-1*t))/2},sub:function(t,e){return t-e},tan:function(t){return e.math.isDegree&&(t=e.math.toRadian(t)),Math.tan(t)},tanh:function(t){return e.sinha(t)/e.cosha(t)},toRadian:function(t){return t*Math.PI/180},and:function(t,e){return t&e}},e.Exception=function(t){this.message=t},t.exports=e},186:(t,e,a)=>{var n=a(735);n.prototype.toPostfix=function(){"use strict";for(var t,e,a,o,r,s=[],i=[{value:"(",type:4,pre:0}],u=this.value,h=1;h<u.length;h++)if(1===u[h].type||3===u[h].type||13===u[h].type)1===u[h].type&&(u[h].value=Number(u[h].value)),s.push(u[h]);else if(4===u[h].type)i.push(u[h]);else if(5===u[h].type)for(;4!==(e=i.pop()).type;)s.push(e);else if(11===u[h].type){for(;4!==(e=i.pop()).type;)s.push(e);i.push(e)}else{o=(t=u[h]).pre,a=(r=i[i.length-1]).pre;var p="Math.pow"==r.value&&"Math.pow"==t.value;if(o>a)i.push(t);else{for(;a>=o&&!p||p&&o<a;)e=i.pop(),r=i[i.length-1],s.push(e),a=r.pre,p="Math.pow"==t.value&&"Math.pow"==r.value;i.push(t)}}return new n(s)},t.exports=n},361:(t,e,a)=>{var n=a(186);n.prototype.postfixEval=function(t){"use strict";(t=t||{}).PI=Math.PI,t.E=Math.E;for(var e,a,o,r=[],s=this.value,i=void 0!==t.n,u=0;u<s.length;u++)1===s[u].type?r.push({value:s[u].value,type:1}):3===s[u].type?r.push({value:t[s[u].value],type:1}):0===s[u].type||7===s[u].type?void 0===r[r.length-1].type?r[r.length-1].value.push(s[u]):r[r.length-1].value=s[u].value(r[r.length-1].value):8===s[u].type?(e=r.pop(),a=r.pop(),r.push({type:1,value:s[u].value(a.value,e.value)})):10===s[u].type?(e=r.pop(),void 0===(a=r.pop()).type?(a.value=a.concat(e),a.value.push(s[u]),r.push(a)):void 0===e.type?(e.unshift(a),e.push(s[u]),r.push(e)):r.push({type:1,value:s[u].value(a.value,e.value)})):2===s[u].type||9===s[u].type?(e=r.pop(),void 0===(a=r.pop()).type?((a=a.concat(e)).push(s[u]),r.push(a)):void 0===e.type?(e.unshift(a),e.push(s[u]),r.push(e)):r.push({type:1,value:s[u].value(a.value,e.value)})):12===s[u].type?(void 0!==(e=r.pop()).type&&(e=[e]),a=r.pop(),o=r.pop(),r.push({type:1,value:s[u].value(o.value,a.value,new n(e))})):13===s[u].type&&(i?r.push({value:t[s[u].value],type:3}):r.push([s[u]]));if(r.length>1)throw new n.Exception("Uncaught Syntax error");return r[0].value>1e15?"Infinity":parseFloat(r[0].value.toFixed(15))},n.eval=function(t,e,a){return void 0===e?this.lex(t).toPostfix().postfixEval():void 0===a?void 0!==e.length?this.lex(t,e).toPostfix().postfixEval():this.lex(t).toPostfix().postfixEval(e):this.lex(t,e).toPostfix().postfixEval(a)},t.exports=n}},e={};function a(n){var o=e[n];if(void 0!==o)return o.exports;var r=e[n]={exports:{}};return t[n](r,r.exports,a),r.exports}a.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return a.d(e,{a:e}),e},a.d=(t,e)=>{for(var n in e)a.o(e,n)&&!a.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";a.r(n),a.d(n,{Runner:()=>r});var t=a(87),e=a.n(t);class o{static SolveString(t){return t}static SolveNumber(t){const a=e().eval(t);return Number(a)}static SolveBoolean(t){return!0===Boolean(t)}static SolveDynamic(t){let e;try{e=o.SolveNumber(t)}catch(a){try{e=JSON.parse(t)}catch(a){e=t}}return e}static GetVariableType(t,e){return e in t.variables?t.variables[e].type:null}static GetVariableSolver(t){var e;return null===t?null:null!==(e=o.VariableSolver[t])&&void 0!==e?e:null}}o.VariableSolver={string:t=>o.SolveString(t),number:t=>o.SolveNumber(t),boolean:t=>o.SolveBoolean(t),dynamic:t=>o.SolveDynamic(t)};class r{constructor(t,e,a,n,o=!1){this.__events=t,this.__conditions=e,this.__actions=a,this.__boxes=n.boxes,this.__usedCommands=n.used_commands,this.__isDebug=o,this.__commandHashMap=r.CreateHashMap([...this.__events,...this.__conditions,...this.__actions])}static CreateHashMap(t){const e=new Map;return t.forEach((t=>e.set(t.id,t))),e}static ParseVariables(t,e,a,n){const o={};for(const s in e)o[s]=r.ParseVariable(t,e,s,a,n);return o}static ParseVariable(t,e,a,n,r){const s=e[a].replace(/{{3}\s*(.*?)\s*}{3}/gim,((t,e)=>{let a=t;return e in r&&(a=r[e]),"string"!=typeof a&&(a=JSON.stringify(a)),a})).replace(/{{2}\s*(.*?)\s*}{2}/gim,((t,e)=>{let a=null;return e in n?a=n[e]:e in r&&(a=r[e]),"string"!=typeof a&&(a=JSON.stringify(a)),a})),i=o.GetVariableType(t,a),u=o.GetVariableSolver(i);if(!u)throw new Error(`The unknown '${i}' type.`);return u(s)}static RunCommand(t,e,a){return new Promise(((n,o)=>{const s=r.ParseVariables(t,e,a.local,a.global);t.fn.call(s,a,n,o)}))}static RunCommandAsync(t,e,a,n,o){const s=r.ParseVariables(t,e,a.local,a.global);t.fn.call(s,a,n,o)}static FindBox(t,e){var a;return null!==(a=t.find((t=>t.id===e)))&&void 0!==a?a:null}async __runCommand(t,e){var a;const{command_id:n,variables:o}=t,s=null!==(a=this.__commandHashMap.get(n))&&void 0!==a?a:null;if(null!==s)return await r.RunCommand(s,o,e);throw new Error(`The '${n}' command not exists.`)}__runCommandAsync(t,e,a,n){var o;const{command_id:s,variables:i}=t,u=null!==(o=this.__commandHashMap.get(s))&&void 0!==o?o:null;if(null===u)throw new Error(`The '${s}' command not exists.`);r.RunCommandAsync(u,i,e,a,n)}__runCommands(t,e){return new Promise((async(a,n)=>{for(const a of t)try{await this.__runCommand(a,e)}catch(t){return void n({format:a,data:e,reason:t})}a()}))}async __recursiveBox(t,e){const a=t.next_box_ids.filter((t=>r.FindBox(this.__boxes,t))).map((t=>r.FindBox(this.__boxes,t)));try{await this.__runCommands(t.conditions,e),await this.__runCommands(t.actions,e),a.forEach((t=>this.__recursiveBox(t,e)))}catch(t){this.__isDebug&&console.error(t)}}__attachEvent(){this.__boxes.forEach((t=>{t.events.forEach((e=>{const a={event:null,local:{},global:globalThis};this.__runCommandAsync(e,a,(e=>this.__recursiveBox(t,e)),(t=>console.error(t)))}))}))}init(){this.__attachEvent()}setDebugMode(t){this.__isDebug=t}}})(),n})()})); |
{ | ||
"name": "@codraft/core", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Codraft parser", | ||
"main": "dist/umd/index.js", | ||
"module": "dist/esm/index.js", | ||
"types": "types/core/src/index.d.ts", | ||
"typings": "types/core/src/index.d.ts", | ||
"scripts": { | ||
@@ -9,0 +9,0 @@ "build": "npx webpack build --config ./build/webpack.config.js", |
@@ -1,2 +0,2 @@ | ||
import { Codraft, MacroDataTransfer, SupportedVariableType } from "../../@typings/codraft"; | ||
import { Codraft, MacroDataTransfer } from "../../@typings/codraft"; | ||
export declare class CodraftRunner { | ||
@@ -13,4 +13,4 @@ private __events; | ||
}>(sources: T[]): Map<string, T>; | ||
protected static ParseVariables(command: Codraft.MacroCommand, variables: Record<string, string>, local: Record<string, SupportedVariableType>, global: Record<string, SupportedVariableType>): Record<string, SupportedVariableType>; | ||
protected static ParseVariable(command: Codraft.MacroCommand, variables: Record<string, string>, key: string, local: Record<string, SupportedVariableType>, global: Record<string, SupportedVariableType>): SupportedVariableType; | ||
protected static ParseVariables(command: Codraft.MacroCommand, variables: Record<string, string>, local: Record<string, any>, global: Record<string, any>): Record<string, any>; | ||
protected static ParseVariable(command: Codraft.MacroCommand, variables: Record<string, string>, key: string, local: Record<string, any>, global: Record<string, any>): any; | ||
protected static RunCommand(command: Codraft.MacroCommand, variables: Record<string, string>, dataTransfer: MacroDataTransfer): Promise<MacroDataTransfer>; | ||
@@ -23,3 +23,3 @@ protected static RunCommandAsync(command: Codraft.MacroCommand, variables: Record<string, string>, dataTransfer: MacroDataTransfer, resolve: (data: MacroDataTransfer) => void, reject: (reason?: Error) => void): void; | ||
protected __runCommands(formats: Codraft.MacroCommandSaveFormat[], data: MacroDataTransfer): Promise<void>; | ||
protected __recursiveBox(box: Codraft.MacroBox, data: MacroDataTransfer): void; | ||
protected __recursiveBox(box: Codraft.MacroBox, data: MacroDataTransfer): Promise<void>; | ||
protected __attachEvent(): void; | ||
@@ -26,0 +26,0 @@ init(): void; |
@@ -6,3 +6,3 @@ import { Codraft, RawVariable, SupportedVariableType } from "../../@typings/codraft"; | ||
static SolveBoolean(v: string): boolean; | ||
static SolveDynamic(v: string): SupportedVariableType; | ||
static SolveDynamic(v: string): any; | ||
static readonly VariableSolver: { | ||
@@ -12,6 +12,6 @@ string: (v: string) => string; | ||
boolean: (v: string) => boolean; | ||
dynamic: (v: string) => SupportedVariableType; | ||
dynamic: (v: string) => any; | ||
}; | ||
static GetVariableType(command: Codraft.MacroCommand, key: string): RawVariable<SupportedVariableType>['type'] | null; | ||
static GetVariableSolver(type: ReturnType<typeof CodraftSolver.GetVariableType>): ((v: string) => SupportedVariableType) | null; | ||
static GetVariableSolver(type: ReturnType<typeof CodraftSolver.GetVariableType>): ((v: string) => any) | null; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
33525