-
Notifications
You must be signed in to change notification settings - Fork 0
/
wasm_exec.min.js
8 lines (8 loc) · 8.1 KB
/
wasm_exec.min.js
1
2
3
4
5
6
7
8
/**
* Minified by jsDelivr using Terser v5.19.2.
* Original file: /gh/golang/go@master/lib/wasm/wasm_exec.js
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
"use strict";(()=>{const t=()=>{const t=new Error("not implemented");return t.code="ENOSYS",t};if(!globalThis.fs){let e="";globalThis.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(t,i){e+=s.decode(i);const n=e.lastIndexOf("\n");return-1!=n&&(console.log(e.substring(0,n)),e=e.substring(n+1)),i.length},write(e,s,i,n,o,r){if(0!==i||n!==s.length||null!==o)return void r(t());r(null,this.writeSync(e,s))},chmod(e,s,i){i(t())},chown(e,s,i,n){n(t())},close(e,s){s(t())},fchmod(e,s,i){i(t())},fchown(e,s,i,n){n(t())},fstat(e,s){s(t())},fsync(t,e){e(null)},ftruncate(e,s,i){i(t())},lchown(e,s,i,n){n(t())},link(e,s,i){i(t())},lstat(e,s){s(t())},mkdir(e,s,i){i(t())},open(e,s,i,n){n(t())},read(e,s,i,n,o,r){r(t())},readdir(e,s){s(t())},readlink(e,s){s(t())},rename(e,s,i){i(t())},rmdir(e,s){s(t())},stat(e,s){s(t())},symlink(e,s,i){i(t())},truncate(e,s,i){i(t())},unlink(e,s){s(t())},utimes(e,s,i,n){n(t())}}}if(globalThis.process||(globalThis.process={getuid:()=>-1,getgid:()=>-1,geteuid:()=>-1,getegid:()=>-1,getgroups(){throw t()},pid:-1,ppid:-1,umask(){throw t()},cwd(){throw t()},chdir(){throw t()}}),globalThis.path||(globalThis.path={resolve:(...t)=>t.join("/")}),!globalThis.crypto)throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");if(!globalThis.performance)throw new Error("globalThis.performance is not available, polyfill required (performance.now only)");if(!globalThis.TextEncoder)throw new Error("globalThis.TextEncoder is not available, polyfill required");if(!globalThis.TextDecoder)throw new Error("globalThis.TextDecoder is not available, polyfill required");const e=new TextEncoder("utf-8"),s=new TextDecoder("utf-8");globalThis.Go=class{constructor(){this.argv=["js"],this.env={},this.exit=t=>{0!==t&&console.warn("exit code:",t)},this._exitPromise=new Promise((t=>{this._resolveExitPromise=t})),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;const t=(t,e)=>{this.mem.setUint32(t+0,e,!0),this.mem.setUint32(t+4,Math.floor(e/4294967296),!0)},i=t=>this.mem.getUint32(t+0,!0)+4294967296*this.mem.getInt32(t+4,!0),n=t=>{const e=this.mem.getFloat64(t,!0);if(0===e)return;if(!isNaN(e))return e;const s=this.mem.getUint32(t,!0);return this._values[s]},o=(t,e)=>{const s=2146959360;if("number"==typeof e&&0!==e)return isNaN(e)?(this.mem.setUint32(t+4,s,!0),void this.mem.setUint32(t,0,!0)):void this.mem.setFloat64(t,e,!0);if(void 0===e)return void this.mem.setFloat64(t,0,!0);let i=this._ids.get(e);void 0===i&&(i=this._idPool.pop(),void 0===i&&(i=this._values.length),this._values[i]=e,this._goRefCounts[i]=0,this._ids.set(e,i)),this._goRefCounts[i]++;let n=0;switch(typeof e){case"object":null!==e&&(n=1);break;case"string":n=2;break;case"symbol":n=3;break;case"function":n=4}this.mem.setUint32(t+4,s|n,!0),this.mem.setUint32(t,i,!0)},r=t=>{const e=i(t+0),s=i(t+8);return new Uint8Array(this._inst.exports.mem.buffer,e,s)},l=t=>{const e=i(t+0),s=i(t+8),o=new Array(s);for(let t=0;t<s;t++)o[t]=n(e+8*t);return o},a=t=>{const e=i(t+0),n=i(t+8);return s.decode(new DataView(this._inst.exports.mem.buffer,e,n))},h=Date.now()-performance.now();this.importObject={_gotest:{add:(t,e)=>t+e,callExport:(t,e)=>this._inst.exports.testExport(t,e)},gojs:{"runtime.wasmExit":t=>{t>>>=0;const e=this.mem.getInt32(t+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(e)},"runtime.wasmWrite":t=>{const e=i((t>>>=0)+8),s=i(t+16),n=this.mem.getInt32(t+24,!0);fs.writeSync(e,new Uint8Array(this._inst.exports.mem.buffer,s,n))},"runtime.resetMemoryDataView":t=>{this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":e=>{t((e>>>=0)+8,1e6*(h+performance.now()))},"runtime.walltime":e=>{e>>>=0;const s=(new Date).getTime();t(e+8,s/1e3),this.mem.setInt32(e+16,s%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":t=>{t>>>=0;const e=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(e,setTimeout((()=>{for(this._resume();this._scheduledTimeouts.has(e);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()}),i(t+8))),this.mem.setInt32(t+16,e,!0)},"runtime.clearTimeoutEvent":t=>{t>>>=0;const e=this.mem.getInt32(t+8,!0);clearTimeout(this._scheduledTimeouts.get(e)),this._scheduledTimeouts.delete(e)},"runtime.getRandomData":t=>{t>>>=0,crypto.getRandomValues(r(t+8))},"syscall/js.finalizeRef":t=>{t>>>=0;const e=this.mem.getUint32(t+8,!0);if(this._goRefCounts[e]--,0===this._goRefCounts[e]){const t=this._values[e];this._values[e]=null,this._ids.delete(t),this._idPool.push(e)}},"syscall/js.stringVal":t=>{o((t>>>=0)+24,a(t+8))},"syscall/js.valueGet":t=>{t>>>=0;const e=Reflect.get(n(t+8),a(t+16));t=this._inst.exports.getsp()>>>0,o(t+32,e)},"syscall/js.valueSet":t=>{t>>>=0,Reflect.set(n(t+8),a(t+16),n(t+32))},"syscall/js.valueDelete":t=>{t>>>=0,Reflect.deleteProperty(n(t+8),a(t+16))},"syscall/js.valueIndex":t=>{o((t>>>=0)+24,Reflect.get(n(t+8),i(t+16)))},"syscall/js.valueSetIndex":t=>{t>>>=0,Reflect.set(n(t+8),i(t+16),n(t+24))},"syscall/js.valueCall":t=>{t>>>=0;try{const e=n(t+8),s=Reflect.get(e,a(t+16)),i=l(t+32),r=Reflect.apply(s,e,i);t=this._inst.exports.getsp()>>>0,o(t+56,r),this.mem.setUint8(t+64,1)}catch(e){t=this._inst.exports.getsp()>>>0,o(t+56,e),this.mem.setUint8(t+64,0)}},"syscall/js.valueInvoke":t=>{t>>>=0;try{const e=n(t+8),s=l(t+16),i=Reflect.apply(e,void 0,s);t=this._inst.exports.getsp()>>>0,o(t+40,i),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,o(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueNew":t=>{t>>>=0;try{const e=n(t+8),s=l(t+16),i=Reflect.construct(e,s);t=this._inst.exports.getsp()>>>0,o(t+40,i),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,o(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueLength":e=>{t((e>>>=0)+16,parseInt(n(e+8).length))},"syscall/js.valuePrepareString":s=>{s>>>=0;const i=e.encode(String(n(s+8)));o(s+16,i),t(s+24,i.length)},"syscall/js.valueLoadString":t=>{const e=n((t>>>=0)+8);r(t+16).set(e)},"syscall/js.valueInstanceOf":t=>{t>>>=0,this.mem.setUint8(t+24,n(t+8)instanceof n(t+16)?1:0)},"syscall/js.copyBytesToGo":e=>{const s=r((e>>>=0)+8),i=n(e+32);if(!(i instanceof Uint8Array||i instanceof Uint8ClampedArray))return void this.mem.setUint8(e+48,0);const o=i.subarray(0,s.length);s.set(o),t(e+40,o.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{const s=n((e>>>=0)+8),i=r(e+16);if(!(s instanceof Uint8Array||s instanceof Uint8ClampedArray))return void this.mem.setUint8(e+48,0);const o=i.subarray(0,s.length);s.set(o),t(e+40,o.length),this.mem.setUint8(e+48,1)},debug:t=>{console.log(t)}}}}async run(t){if(!(t instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=t,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let s=4096;const i=t=>{const i=s,n=e.encode(t+"\0");return new Uint8Array(this.mem.buffer,s,n.length).set(n),s+=n.length,s%8!=0&&(s+=8-s%8),i},n=this.argv.length,o=[];this.argv.forEach((t=>{o.push(i(t))})),o.push(0);Object.keys(this.env).sort().forEach((t=>{o.push(i(`${t}=${this.env[t]}`))})),o.push(0);const r=s;o.forEach((t=>{this.mem.setUint32(s,t,!0),this.mem.setUint32(s+4,0,!0),s+=8}));if(s>=12288)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(n,r),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(t){const e=this;return function(){const s={id:t,this:this,args:arguments};return e._pendingEvent=s,e._resume(),s.result}}}})();
//# sourceMappingURL=/sm/149bd33b8323b5a24bb281c075ef881b8376f47f96e21cf46639c803479ab40d.map