-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathwajic.minified.js
More file actions
1 lines (1 loc) · 4.12 KB
/
wajic.minified.js
File metadata and controls
1 lines (1 loc) · 4.12 KB
1
"use strict";var WA=WA||{};(function(){var e=WA.print||(WA.print=e=>console.log(e.replace(/\n$/,""))),r=WA.error||(WA.error=(r,t)=>e("[ERROR] "+r+": "+t+"\n")),WM,ASM,t,MU8,MU16,MU32,MI32,MF32,n=[0,0,0],a,o=WA.maxmem||268435456,WASM_STACK_SIZE=65536,STOP,abort=WA.abort=(e,t)=>{throw STOP=!0,r(e,t),"abort"},MStrPut=(e,r,t)=>{if(0===t)return 0;var n=(new TextEncoder).encode(e),a=n.length,o=r||ASM.malloc(a+1);if(t&&a>=t)for(a=t-1;128==(192&n[a]);a--);return MU8.set(n.subarray(0,a),o),MU8[o+a]=0,r?a:o},MStrGet=(e,r)=>{if(0===r||!e)return"";if(!r)for(r=0;r!=e+MU8.length&&MU8[e+r];r++);return(new TextDecoder).decode(MU8.subarray(e,e+r))},MArrPut=e=>{var r=e.byteLength||e.length,t=r&&ASM.malloc(r);return MU8.set(e,t),t},i=()=>{var e=t.buffer;MU8=new Uint8Array(e),MU16=new Uint16Array(e),MU32=new Uint32Array(e),MI32=new Int32Array(e),MF32=new Float32Array(e)},s=(e,r,t)=>{var a=WebAssembly.Module.customSections(WA.wm,"|"+MStrGet(e))[0];return a?n.push(new Uint8Array(a),0)-2:-1},l=(r,t,n,a)=>{t>>=2;for(var o=0,i="",s=0;s<n;s++){var l=MU32[t++],c=MI32[t++];if(c<0)return-1;o+=c,i+=MStrGet(l,c)}return e(i),MU32[a>>2]=o,0},c=(e,r,t,a)=>{var o=n[e++],i=0|n[e],s=0;if(!o)return 1;r>>=2;for(var l=0;l<t&&i!=o.length;l++){var c=MU32[r++],u=MU32[r++],f=Math.min(u,o.length-i);MU8.set(o.subarray(i,i+f),c),i+=f,s+=f}return n[e]=i,MU32[a>>2]=s,0},u=(e,r,t,a,o)=>{var i=n[e++],s=0|n[e];return i?(0==a&&(s=r),1==a&&(s+=r),2==a&&(s=i.length-r),s<0&&(s=0),s>i.length&&(s=i.length),n[e]=MU32[o>>2]=s,MU32[1+(o>>2)]=0,0):1},f=e=>n[e]?(n[e]=0,0):1,m=WA.module;m||(m="o"==(typeof process)[0]?require("fs").readFileSync(process.argv[2]):document.currentScript.getAttribute("data-wasm")),("s"==(typeof m)[0]?fetch(m).then(e=>e.arrayBuffer()):new Promise(e=>e(m))).then(e=>WebAssembly.compile(e).then(r=>{var n=()=>0,m=e=>abort("CRASH",e),J={},A={sbrk:e=>{var r=a,n=r+e,s=n-t.buffer.byteLength;return n>o&&abort("MEM","Out of memory"),s>0&&(t.grow(s+65535>>16),i()),a=n,r},time:e=>{var r=Date.now()/1e3|0;return e&&(MU32[e>>2]=r),r},gettimeofday:e=>{var r=Date.now();MU32[e>>2]=r/1e3|0,MU32[e+4>>2]=r%1e3*1e3|0},clock_gettime:(e,r)=>{e=e?window.performance.now():Date.now(),(r>>=2)&&(MU32[r]=e/1e3|0,MU32[r+1]=e%1e3*1e6+.1|0)},clock_getres:(e,r)=>{e=e?.1:1,(r>>=2)&&(MU32[r]=e/1e3|0,MU32[r+1]=e%1e3*1e6|0)},exit:e=>{abort("EXIT","Exit called: "+e)},__assert_fail:(e,r,t,n)=>m("assert "+MStrGet(e)+" at: "+(r?MStrGet(r):"?"),t,n?MStrGet(n):"?")},g={env:A,J:J},v={},N={};for(var d in WebAssembly.Module.imports(r).forEach(r=>{var a=r.module,o=r.name,i=r.kind[0],d=g[a]||(g[a]={});if("m"==i)for(let r,n,a,i,s,l=new Uint8Array(e),c=8,u=l.length;c<u&&(s=e=>{c+=0|e;for(var r,t,n=0;t|=(127&(r=l[c++]))<<n,r>>7;n+=7);return t},n=s(),a=s(),r=c+a,!(n<0||n>11||a<=0||r>u));c=r)if(2==n)for(a=s(),i=0;i!=a&&c<r;i++,1==n&&s(1)&&s(),2>n&&s(),3==n&&s(1))2==(n=s(s(s())))&&(t=d[o]=new WebAssembly.Memory({initial:s(1)}),c=r=u);if("f"==i){if(d==J){let[e,r,t,n,a]=o.split("");if(!t&&!a)return;n||(n=""),v[n]||(v[n]=""),r=r.replace(/^\(\s*void\s*\)$|^\(|\[.*?\]|(=|WA_ARG\()[^,]+|\)$/g,"").replace(/.*?(\w+)\s*(,|$)/g,"$1$2"),v[n]+=(a||"").replace(/^\(?\s*|\s*\)$/g,"")+"J[N."+e+"]=("+r+")=>"+t+";",N[e]=o}d!=A||A[o]||(d[o]=Math[o.replace(/^f?([^l].*?)f?$/,"$1").replace(/^rint$/,"round")]||o.match(/uncaught_excep|pure_virt|^abort$|^longjmp$/)&&(()=>m(o))||o.includes("open")&&s||n,A[o]==n&&console.log("[WASM] Importing empty function for env."+o)),a.includes("wasi")&&(d[o]=o.includes("write")?l:o.includes("read")?c:o.includes("seek")?u:o.includes("close")?f:n)}}),v)try{(()=>{eval(v[d].replace(/[\0-\37]/g,e=>"\\x"+escape(e).slice(1)))})()}catch(e){abort("BOOT","Error in #WAJIC function: "+e+"("+v[d]+")")}return WA.wm=WM=r,WebAssembly.instantiate(r,g)})).then(e=>{WA.asm=ASM=e.exports;var r=ASM.memory,n=ASM.__wasm_call_ctors,o=ASM.main||ASM.__main_argc_argv,s=ASM.__original_main||ASM.__main_void,l=ASM.malloc,c=ASM.WajicMain,u=WA.started;if(r&&(t=r),t&&(i(),a=MU8.length),n&&n(),o&&l){var f,m=WA.args||["W"],A=m.length,g=l(A+1<<2);for(f=0;f!=A;f++)MU32[(g>>2)+f]=MStrPut(m[f]);MU32[(g>>2)+A]=0,o(A,g)}else o&&o(0,0);s&&s(),c&&c(),u&&u()}).catch(e=>{"abort"!==e&&WA.error("BOOT","WASM instiantate error: "+e+(e.stack?"\n"+e.stack:""))})})();