+`);return o!=-1&&(console.log(t.substr(0,o)),t=t.substr(o+1)),s.length},write(t,n,s,o,i,a){if(s!==0||o!==n.length||i!==null){a(e());return}const r=this.writeSync(t,n);a(null,r)},chmod(t,n,s){s(e())},chown(t,n,s,o){o(e())},close(t,n){n(e())},fchmod(t,n,s){s(e())},fchown(t,n,s,o){o(e())},fstat(t,n){n(e())},fsync(e,t){t(null)},ftruncate(t,n,s){s(e())},lchown(t,n,s,o){o(e())},link(t,n,s){s(e())},lstat(t,n){n(e())},mkdir(t,n,s){s(e())},open(t,n,s,o){o(e())},read(t,n,s,o,i,a){a(e())},readdir(t,n){n(e())},readlink(t,n){n(e())},rename(t,n,s){s(e())},rmdir(t,n){n(e())},stat(t,n){n(e())},symlink(t,n,s){s(e())},truncate(t,n,s){s(e())},unlink(t,n){n(e())},utimes(t,n,s,o){o(e())}}}if(global.process||(global.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw e()},pid:-1,ppid:-1,umask(){throw e()},cwd(){throw e()},chdir(){throw e()}}),!global.crypto){const e=require("crypto");global.crypto={getRandomValues(t){e.randomFillSync(t)}}}global.performance||(global.performance={now(){const[e,t]=process.hrtime();return e*1e3+t/1e6}}),global.TextEncoder||(global.TextEncoder=require("util").TextEncoder),global.TextDecoder||(global.TextDecoder=require("util").TextDecoder);const o=new TextEncoder("utf-8"),n=new TextDecoder("utf-8");let t=new DataView(new ArrayBuffer(8));var s=[];if(global.Go=class{constructor(){this._callbackTimeouts=new Map,this._nextCallbackTimeoutID=1;const e=()=>new DataView(this._inst.exports.memory.buffer),i=e=>{t.setBigInt64(0,e,!0);const n=t.getFloat64(0,!0);if(n===0)return void 0;if(!isNaN(n))return n;const s=e&4294967295n;return this._values[s]},u=t=>{let n=e().getBigUint64(t,!0);return i(n)},c=e=>{const s=2146959360n;if(typeof e=="number")return isNaN(e)?s<<32n:e===0?s<<32n|1n:(t.setFloat64(0,e,!0),t.getBigInt64(0,!0));switch(e){case void 0:return 0n;case null:return s<<32n|2n;case!0:return s<<32n|3n;case!1:return s<<32n|4n}let n=this._ids.get(e);n===void 0&&(n=this._idPool.pop(),n===void 0&&(n=BigInt(this._values.length)),this._values[n]=e,this._goRefCounts[n]=0,this._ids.set(e,n)),this._goRefCounts[n]++;let o=1n;switch(typeof e){case"string":o=2n;break;case"symbol":o=3n;break;case"function":o=4n;break}return n|(s|o)<<32n},a=(t,n)=>{let s=c(n);e().setBigUint64(t,s,!0)},l=(e,t)=>new Uint8Array(this._inst.exports.memory.buffer,e,t),d=(e,t)=>{const s=new Array(t);for(let n=0;n<t;n++)s[n]=u(e+n*8);return s},r=(e,t)=>n.decode(new DataView(this._inst.exports.memory.buffer,e,t)),h=Date.now()-performance.now();this.importObject={wasi_snapshot_preview1:{fd_write:function(t,o,i,a){let r=0;if(t==1)for(let t=0;t<i;t++){let a=o+t*8,l=e().getUint32(a+0,!0),c=e().getUint32(a+4,!0);r+=c;for(let t=0;t<c;t++){let o=e().getUint8(l+t);if(o==13);else if(o==10){let e=n.decode(new Uint8Array(s));s=[],console.log(e)}else s.push(o)}}else console.error("invalid file descriptor:",t);return e().setUint32(a,r,!0),0},fd_close:()=>0,fd_fdstat_get:()=>0,fd_seek:()=>0,proc_exit:e=>{if(global.process)process.exit(e);else throw"trying to exit with code "+e},random_get:(e,t)=>(crypto.getRandomValues(l(e,t)),0)},gojs:{"runtime.ticks":()=>h+performance.now(),"runtime.sleepTicks":e=>{setTimeout(this._inst.exports.go_scheduler,e)},"syscall/js.finalizeRef":e=>{console.error("syscall/js.finalizeRef not implemented")},"syscall/js.stringVal":(e,t)=>{const n=r(e,t);return c(n)},"syscall/js.valueGet":(e,t,n)=>{let s=r(t,n),o=i(e),a=Reflect.get(o,s);return c(a)},"syscall/js.valueSet":(e,t,n,s)=>{const o=i(e),a=r(t,n),c=i(s);Reflect.set(o,a,c)},"syscall/js.valueDelete":(e,t,n)=>{const s=i(e),o=r(t,n);Reflect.deleteProperty(s,o)},"syscall/js.valueIndex":(e,t)=>c(Reflect.get(i(e),t)),"syscall/js.valueSetIndex":(e,t,n)=>{Reflect.set(i(e),t,i(n))},"syscall/js.valueCall":(t,n,s,o,c,l,u)=>{const h=i(n),m=r(s,o),f=d(c,l,u);try{const n=Reflect.get(h,m);a(t,Reflect.apply(n,h,f)),e().setUint8(t+8,1)}catch(n){a(t,n),e().setUint8(t+8,0)}},"syscall/js.valueInvoke":(t,n,s,o,r)=>{try{const c=i(n),l=d(s,o,r);a(t,Reflect.apply(c,void 0,l)),e().setUint8(t+8,1)}catch(n){a(t,n),e().setUint8(t+8,0)}},"syscall/js.valueNew":(t,n,s,o,r)=>{const c=i(n),l=d(s,o,r);try{a(t,Reflect.construct(c,l)),e().setUint8(t+8,1)}catch(n){a(t,n),e().setUint8(t+8,0)}},"syscall/js.valueLength":e=>i(e).length,"syscall/js.valuePrepareString":(t,n)=>{const r=String(i(n)),s=o.encode(r);a(t,s),e().setInt32(t+8,s.length,!0)},"syscall/js.valueLoadString":(e,t,n,s)=>{const o=i(e);l(t,n,s).set(o)},"syscall/js.valueInstanceOf":(e,t)=>i(e)instanceof i(t),"syscall/js.copyBytesToGo":(t,n,s,o,a)=>{let h=t,c=t+4;const d=l(n,s),r=i(a);if(!(r instanceof Uint8Array||r instanceof Uint8ClampedArray)){e().setUint8(c,0);return}const u=r.subarray(0,d.length);d.set(u),e().setUint32(h,u.length,!0),e().setUint8(c,1)},"syscall/js.copyBytesToJS":(t,n,s,o)=>{let u=t,c=t+4;const r=i(n),h=l(s,o);if(!(r instanceof Uint8Array||r instanceof Uint8ClampedArray)){e().setUint8(c,0);return}const d=h.subarray(0,r.length);r.set(d),e().setUint32(u,d.length,!0),e().setUint8(c,1)}}},this.importObject.env=this.importObject.gojs}async run(e){this._inst=e,this._values=[NaN,0,null,!0,!1,global,this],this._goRefCounts=[],this._ids=new Map,this._idPool=[],this.exited=!1;const t=new DataView(this._inst.exports.memory.buffer);for(;!0;){const e=new Promise(e=>{this._resolveCallbackPromise=()=>{if(this.exited)throw new Error("bad callback: Go program has already exited");setTimeout(e,0)}});if(this._inst.exports._start(),this.exited)break;await e}}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(e){const t=this;return function(){const n={id:e,this:this,args:arguments};return t._pendingEvent=n,t._resume(),n.result}}},global.require&&global.require.main===module&&global.process&&global.process.versions&&!global.process.versions.electron){process.argv.length!=3&&(console.error("usage: go_js_wasm_exec [wasm binary] [arguments]"),process.exit(1));const e=new Go;WebAssembly.instantiate(fs.readFileSync(process.argv[2]),e.importObject).then(t=>e.run(t.instance)).catch(e=>{console.error(e),process.exit(1)})}})();const go=new Go,fetched=fetch("main.wasm");"instantiateStreaming"in WebAssembly?WebAssembly.instantiateStreaming(fetched,go.importObject).then(e=>go.run(e.instance)):fetched.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,go.importObject).then(e=>go.run(e.instance)))</script>
0 commit comments