isomorfeus-asset-manager 0.14.19 → 0.14.22
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.
- checksums.yaml +4 -4
- data/lib/isomorfeus/asset_manager/browser_asset.rb +5 -0
- data/lib/isomorfeus/asset_manager/config.rb +1 -1
- data/lib/isomorfeus/asset_manager/node_asset.rb +1 -1
- data/lib/isomorfeus/asset_manager/version.rb +1 -1
- data/lib/isomorfeus/asset_manager.rb +6 -15
- data/node_modules/.package-lock.json +18 -18
- data/node_modules/esbuild-wasm/bin/esbuild +37 -5
- data/node_modules/esbuild-wasm/esbuild.wasm +0 -0
- data/node_modules/esbuild-wasm/esm/browser.d.ts +13 -1
- data/node_modules/esbuild-wasm/esm/browser.js +625 -744
- data/node_modules/esbuild-wasm/esm/browser.min.js +14 -7
- data/node_modules/esbuild-wasm/exit0.js +2 -0
- data/node_modules/esbuild-wasm/lib/browser.d.ts +13 -1
- data/node_modules/esbuild-wasm/lib/browser.js +654 -756
- data/node_modules/esbuild-wasm/lib/browser.min.js +13 -6
- data/node_modules/esbuild-wasm/lib/main.d.ts +13 -1
- data/node_modules/esbuild-wasm/lib/main.js +57 -43
- data/node_modules/esbuild-wasm/package.json +1 -1
- data/node_modules/esbuild-wasm/wasm_exec.js +17 -127
- data/node_modules/esbuild-wasm/wasm_exec_node.js +49 -0
- data/package.json +1 -1
- metadata +17 -10
@@ -20,24 +20,19 @@ var __spreadValues = (a, b) => {
|
|
20
20
|
return a;
|
21
21
|
};
|
22
22
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
23
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
24
23
|
var __export = (target, all) => {
|
25
24
|
for (var name in all)
|
26
25
|
__defProp(target, name, { get: all[name], enumerable: true });
|
27
26
|
};
|
28
|
-
var
|
29
|
-
if (
|
30
|
-
for (let key of __getOwnPropNames(
|
31
|
-
if (!__hasOwnProp.call(
|
32
|
-
__defProp(
|
27
|
+
var __copyProps = (to, from, except, desc) => {
|
28
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
29
|
+
for (let key of __getOwnPropNames(from))
|
30
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
31
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
33
32
|
}
|
34
|
-
return
|
33
|
+
return to;
|
35
34
|
};
|
36
|
-
var __toCommonJS =
|
37
|
-
return (module2, temp) => {
|
38
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
39
|
-
};
|
40
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
35
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
41
36
|
var __async = (__this, __arguments, generator) => {
|
42
37
|
return new Promise((resolve, reject) => {
|
43
38
|
var fulfilled = (value) => {
|
@@ -75,6 +70,7 @@ __export(browser_exports, {
|
|
75
70
|
transformSync: () => transformSync,
|
76
71
|
version: () => version
|
77
72
|
});
|
73
|
+
module.exports = __toCommonJS(browser_exports);
|
78
74
|
|
79
75
|
// lib/shared/stdio_protocol.ts
|
80
76
|
function encodePacket(packet) {
|
@@ -256,6 +252,7 @@ var mustBeInteger = (value) => typeof value === "number" && value === (value | 0
|
|
256
252
|
var mustBeFunction = (value) => typeof value === "function" ? null : "a function";
|
257
253
|
var mustBeArray = (value) => Array.isArray(value) ? null : "an array";
|
258
254
|
var mustBeObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? null : "an object";
|
255
|
+
var mustBeWebAssemblyModule = (value) => value instanceof WebAssembly.Module ? null : "a WebAssembly.Module";
|
259
256
|
var mustBeArrayOrRecord = (value) => typeof value === "object" && value !== null ? null : "an array or an object";
|
260
257
|
var mustBeObjectOrNull = (value) => typeof value === "object" && !Array.isArray(value) ? null : "an object or null";
|
261
258
|
var mustBeStringOrBoolean = (value) => typeof value === "string" || typeof value === "boolean" ? null : "a string or a boolean";
|
@@ -282,10 +279,12 @@ function checkForInvalidFlags(object, keys, where) {
|
|
282
279
|
function validateInitializeOptions(options) {
|
283
280
|
let keys = /* @__PURE__ */ Object.create(null);
|
284
281
|
let wasmURL = getFlag(options, keys, "wasmURL", mustBeString);
|
282
|
+
let wasmModule = getFlag(options, keys, "wasmModule", mustBeWebAssemblyModule);
|
285
283
|
let worker = getFlag(options, keys, "worker", mustBeBoolean);
|
286
|
-
checkForInvalidFlags(options, keys, "in
|
284
|
+
checkForInvalidFlags(options, keys, "in initialize() call");
|
287
285
|
return {
|
288
286
|
wasmURL,
|
287
|
+
wasmModule,
|
289
288
|
worker
|
290
289
|
};
|
291
290
|
}
|
@@ -324,6 +323,7 @@ function pushCommonFlags(flags, options, keys) {
|
|
324
323
|
let globalName = getFlag(options, keys, "globalName", mustBeString);
|
325
324
|
let mangleProps = getFlag(options, keys, "mangleProps", mustBeRegExp);
|
326
325
|
let reserveProps = getFlag(options, keys, "reserveProps", mustBeRegExp);
|
326
|
+
let mangleQuoted = getFlag(options, keys, "mangleQuoted", mustBeBoolean);
|
327
327
|
let minify = getFlag(options, keys, "minify", mustBeBoolean);
|
328
328
|
let minifySyntax = getFlag(options, keys, "minifySyntax", mustBeBoolean);
|
329
329
|
let minifyWhitespace = getFlag(options, keys, "minifyWhitespace", mustBeBoolean);
|
@@ -375,6 +375,8 @@ function pushCommonFlags(flags, options, keys) {
|
|
375
375
|
flags.push(`--mangle-props=${mangleProps.source}`);
|
376
376
|
if (reserveProps)
|
377
377
|
flags.push(`--reserve-props=${reserveProps.source}`);
|
378
|
+
if (mangleQuoted !== void 0)
|
379
|
+
flags.push(`--mangle-quoted=${mangleQuoted}`);
|
378
380
|
if (jsx)
|
379
381
|
flags.push(`--jsx=${jsx}`);
|
380
382
|
if (jsxFactory)
|
@@ -624,7 +626,7 @@ function createChannel(streamIn) {
|
|
624
626
|
let pluginCallbacks = /* @__PURE__ */ new Map();
|
625
627
|
let watchCallbacks = /* @__PURE__ */ new Map();
|
626
628
|
let serveCallbacks = /* @__PURE__ */ new Map();
|
627
|
-
let
|
629
|
+
let closeData = null;
|
628
630
|
let nextRequestID = 0;
|
629
631
|
let nextBuildKey = 0;
|
630
632
|
let stdout = new Uint8Array(16 * 1024);
|
@@ -653,19 +655,20 @@ function createChannel(streamIn) {
|
|
653
655
|
stdoutUsed -= offset;
|
654
656
|
}
|
655
657
|
};
|
656
|
-
let afterClose = () => {
|
657
|
-
|
658
|
+
let afterClose = (error) => {
|
659
|
+
closeData = { reason: error ? ": " + (error.message || error) : "" };
|
660
|
+
const text = "The service was stopped" + closeData.reason;
|
658
661
|
for (let callback of responseCallbacks.values()) {
|
659
|
-
callback(
|
662
|
+
callback(text, null);
|
660
663
|
}
|
661
664
|
responseCallbacks.clear();
|
662
665
|
for (let callbacks of serveCallbacks.values()) {
|
663
|
-
callbacks.onWait(
|
666
|
+
callbacks.onWait(text);
|
664
667
|
}
|
665
668
|
serveCallbacks.clear();
|
666
669
|
for (let callback of watchCallbacks.values()) {
|
667
670
|
try {
|
668
|
-
callback(new Error(
|
671
|
+
callback(new Error(text), null);
|
669
672
|
} catch (e) {
|
670
673
|
console.error(e);
|
671
674
|
}
|
@@ -673,8 +676,8 @@ function createChannel(streamIn) {
|
|
673
676
|
watchCallbacks.clear();
|
674
677
|
};
|
675
678
|
let sendRequest = (refs, value, callback) => {
|
676
|
-
if (
|
677
|
-
return callback("The service is no longer running", null);
|
679
|
+
if (closeData)
|
680
|
+
return callback("The service is no longer running" + closeData.reason, null);
|
678
681
|
let id = nextRequestID++;
|
679
682
|
responseCallbacks.set(id, (error, response) => {
|
680
683
|
try {
|
@@ -689,8 +692,8 @@ function createChannel(streamIn) {
|
|
689
692
|
streamIn.writeToStdin(encodePacket({ id, isRequest: true, value }));
|
690
693
|
};
|
691
694
|
let sendResponse = (id, value) => {
|
692
|
-
if (
|
693
|
-
throw new Error("The service is no longer running");
|
695
|
+
if (closeData)
|
696
|
+
throw new Error("The service is no longer running" + closeData.reason);
|
694
697
|
streamIn.writeToStdin(encodePacket({ id, isRequest: false, value }));
|
695
698
|
};
|
696
699
|
let handleRequest = (id, request) => __async(this, null, function* () {
|
@@ -761,8 +764,8 @@ function createChannel(streamIn) {
|
|
761
764
|
if (isFirstPacket) {
|
762
765
|
isFirstPacket = false;
|
763
766
|
let binaryVersion = String.fromCharCode(...bytes);
|
764
|
-
if (binaryVersion !== "0.14.
|
765
|
-
throw new Error(`Cannot start service: Host version "${"0.14.
|
767
|
+
if (binaryVersion !== "0.14.36") {
|
768
|
+
throw new Error(`Cannot start service: Host version "${"0.14.36"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
|
766
769
|
}
|
767
770
|
return;
|
768
771
|
}
|
@@ -1267,7 +1270,7 @@ function createChannel(streamIn) {
|
|
1267
1270
|
if (!rebuild) {
|
1268
1271
|
let isDisposed = false;
|
1269
1272
|
rebuild = () => new Promise((resolve, reject) => {
|
1270
|
-
if (isDisposed ||
|
1273
|
+
if (isDisposed || closeData)
|
1271
1274
|
throw new Error("Cannot rebuild");
|
1272
1275
|
sendRequest(refs, { command: "rebuild", key }, (error2, response2) => {
|
1273
1276
|
if (error2) {
|
@@ -1707,7 +1710,7 @@ function convertOutputFiles({ path, contents }) {
|
|
1707
1710
|
}
|
1708
1711
|
|
1709
1712
|
// lib/npm/browser.ts
|
1710
|
-
var version = "0.14.
|
1713
|
+
var version = "0.14.36";
|
1711
1714
|
var build = (options) => ensureServiceIsRunning().build(options);
|
1712
1715
|
var serve = () => {
|
1713
1716
|
throw new Error(`The "serve" API only works in node`);
|
@@ -1739,747 +1742,643 @@ var ensureServiceIsRunning = () => {
|
|
1739
1742
|
var initialize = (options) => {
|
1740
1743
|
options = validateInitializeOptions(options || {});
|
1741
1744
|
let wasmURL = options.wasmURL;
|
1745
|
+
let wasmModule = options.wasmModule;
|
1742
1746
|
let useWorker = options.worker !== false;
|
1743
|
-
if (!wasmURL)
|
1744
|
-
throw new Error('Must provide the "wasmURL" option');
|
1745
|
-
wasmURL += "";
|
1747
|
+
if (!wasmURL && !wasmModule)
|
1748
|
+
throw new Error('Must provide either the "wasmURL" option or the "wasmModule" option');
|
1746
1749
|
if (initializePromise)
|
1747
1750
|
throw new Error('Cannot call "initialize" more than once');
|
1748
|
-
initializePromise = startRunningService(wasmURL, useWorker);
|
1751
|
+
initializePromise = startRunningService(wasmURL || "", wasmModule, useWorker);
|
1749
1752
|
initializePromise.catch(() => {
|
1750
1753
|
initializePromise = void 0;
|
1751
1754
|
});
|
1752
1755
|
return initializePromise;
|
1753
1756
|
};
|
1754
|
-
var startRunningService = (wasmURL, useWorker) => __async(void 0, null, function* () {
|
1755
|
-
let
|
1756
|
-
if (
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
//
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
} else if (typeof window !== "undefined") {
|
1777
|
-
window.global = window;
|
1778
|
-
} else if (typeof self !== "undefined") {
|
1779
|
-
self.global = self;
|
1780
|
-
} else {
|
1781
|
-
throw new Error("cannot export Go (neither global, window nor self is defined)");
|
1782
|
-
}
|
1783
|
-
|
1784
|
-
if (!global.require && typeof require !== "undefined") {
|
1785
|
-
global.require = require;
|
1786
|
-
}
|
1787
|
-
|
1788
|
-
if (!global.fs && global.require) {
|
1789
|
-
const fs = require("fs");
|
1790
|
-
if (typeof fs === "object" && fs !== null && Object.keys(fs).length !== 0) {
|
1791
|
-
|
1792
|
-
global.fs = Object.assign({}, fs, {
|
1793
|
-
// Hack around a Unicode bug in node: https://github.com/nodejs/node/issues/24550
|
1794
|
-
write(fd, buf, offset, length, position, callback) {
|
1795
|
-
if (offset === 0 && length === buf.length && position === null) {
|
1796
|
-
if (fd === process.stdout.fd) {
|
1757
|
+
var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, null, function* () {
|
1758
|
+
let wasm;
|
1759
|
+
if (wasmModule) {
|
1760
|
+
wasm = wasmModule;
|
1761
|
+
} else {
|
1762
|
+
let res = yield fetch(wasmURL);
|
1763
|
+
if (!res.ok)
|
1764
|
+
throw new Error(`Failed to download ${JSON.stringify(wasmURL)}`);
|
1765
|
+
wasm = yield res.arrayBuffer();
|
1766
|
+
}
|
1767
|
+
let worker;
|
1768
|
+
if (useWorker) {
|
1769
|
+
let blob = new Blob([`onmessage=${'((postMessage) => {\n // Copyright 2018 The Go Authors. All rights reserved.\n // Use of this source code is governed by a BSD-style\n // license that can be found in the LICENSE file.\n var __async = (__this, __arguments, generator) => {\n return new Promise((resolve, reject) => {\n var fulfilled = (value) => {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n };\n var rejected = (value) => {\n try {\n step(generator.throw(value));\n } catch (e) {\n reject(e);\n }\n };\n var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);\n step((generator = generator.apply(__this, __arguments)).next());\n });\n };\n let onmessage;\n let globalThis = {};\n for (let o = self; o; o = Object.getPrototypeOf(o))\n for (let k of Object.getOwnPropertyNames(o))\n if (!(k in globalThis))\n Object.defineProperty(globalThis, k, { get: () => self[k] });\n "use strict";\n (() => {\n const enosys = () => {\n const err = new Error("not implemented");\n err.code = "ENOSYS";\n return err;\n };\n if (!globalThis.fs) {\n let outputBuf = "";\n globalThis.fs = {\n constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 },\n writeSync(fd, buf) {\n outputBuf += decoder.decode(buf);\n const nl = outputBuf.lastIndexOf("\\n");\n if (nl != -1) {\n console.log(outputBuf.substr(0, nl));\n outputBuf = outputBuf.substr(nl + 1);\n }\n return buf.length;\n },\n write(fd, buf, offset, length, position, callback) {\n if (offset !== 0 || length !== buf.length || position !== null) {\n callback(enosys());\n return;\n }\n const n = this.writeSync(fd, buf);\n callback(null, n);\n },\n chmod(path, mode, callback) {\n callback(enosys());\n },\n chown(path, uid, gid, callback) {\n callback(enosys());\n },\n close(fd, callback) {\n callback(enosys());\n },\n fchmod(fd, mode, callback) {\n callback(enosys());\n },\n fchown(fd, uid, gid, callback) {\n callback(enosys());\n },\n fstat(fd, callback) {\n callback(enosys());\n },\n fsync(fd, callback) {\n callback(null);\n },\n ftruncate(fd, length, callback) {\n callback(enosys());\n },\n lchown(path, uid, gid, callback) {\n callback(enosys());\n },\n link(path, link, callback) {\n callback(enosys());\n },\n lstat(path, callback) {\n callback(enosys());\n },\n mkdir(path, perm, callback) {\n callback(enosys());\n },\n open(path, flags, mode, callback) {\n callback(enosys());\n },\n read(fd, buffer, offset, length, position, callback) {\n callback(enosys());\n },\n readdir(path, callback) {\n callback(enosys());\n },\n readlink(path, callback) {\n callback(enosys());\n },\n rename(from, to, callback) {\n callback(enosys());\n },\n rmdir(path, callback) {\n callback(enosys());\n },\n stat(path, callback) {\n callback(enosys());\n },\n symlink(path, link, callback) {\n callback(enosys());\n },\n truncate(path, length, callback) {\n callback(enosys());\n },\n unlink(path, callback) {\n callback(enosys());\n },\n utimes(path, atime, mtime, callback) {\n callback(enosys());\n }\n };\n }\n if (!globalThis.process) {\n globalThis.process = {\n getuid() {\n return -1;\n },\n getgid() {\n return -1;\n },\n geteuid() {\n return -1;\n },\n getegid() {\n return -1;\n },\n getgroups() {\n throw enosys();\n },\n pid: -1,\n ppid: -1,\n umask() {\n throw enosys();\n },\n cwd() {\n throw enosys();\n },\n chdir() {\n throw enosys();\n }\n };\n }\n if (!globalThis.crypto) {\n throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");\n }\n if (!globalThis.performance) {\n throw new Error("globalThis.performance is not available, polyfill required (performance.now only)");\n }\n if (!globalThis.TextEncoder) {\n throw new Error("globalThis.TextEncoder is not available, polyfill required");\n }\n if (!globalThis.TextDecoder) {\n throw new Error("globalThis.TextDecoder is not available, polyfill required");\n }\n const encoder = new TextEncoder("utf-8");\n const decoder = new TextDecoder("utf-8");\n globalThis.Go = class {\n constructor() {\n this.argv = ["js"];\n this.env = {};\n this.exit = (code) => {\n if (code !== 0) {\n console.warn("exit code:", code);\n }\n };\n this._exitPromise = new Promise((resolve) => {\n this._resolveExitPromise = resolve;\n });\n this._pendingEvent = null;\n this._scheduledTimeouts = /* @__PURE__ */ new Map();\n this._nextCallbackTimeoutID = 1;\n const setInt64 = (addr, v) => {\n this.mem.setUint32(addr + 0, v, true);\n this.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true);\n };\n const getInt64 = (addr) => {\n const low = this.mem.getUint32(addr + 0, true);\n const high = this.mem.getInt32(addr + 4, true);\n return low + high * 4294967296;\n };\n const loadValue = (addr) => {\n const f = this.mem.getFloat64(addr, true);\n if (f === 0) {\n return void 0;\n }\n if (!isNaN(f)) {\n return f;\n }\n const id = this.mem.getUint32(addr, true);\n return this._values[id];\n };\n const storeValue = (addr, v) => {\n const nanHead = 2146959360;\n if (typeof v === "number" && v !== 0) {\n if (isNaN(v)) {\n this.mem.setUint32(addr + 4, nanHead, true);\n this.mem.setUint32(addr, 0, true);\n return;\n }\n this.mem.setFloat64(addr, v, true);\n return;\n }\n if (v === void 0) {\n this.mem.setFloat64(addr, 0, true);\n return;\n }\n let id = this._ids.get(v);\n if (id === void 0) {\n id = this._idPool.pop();\n if (id === void 0) {\n id = this._values.length;\n }\n this._values[id] = v;\n this._goRefCounts[id] = 0;\n this._ids.set(v, id);\n }\n this._goRefCounts[id]++;\n let typeFlag = 0;\n switch (typeof v) {\n case "object":\n if (v !== null) {\n typeFlag = 1;\n }\n break;\n case "string":\n typeFlag = 2;\n break;\n case "symbol":\n typeFlag = 3;\n break;\n case "function":\n typeFlag = 4;\n break;\n }\n this.mem.setUint32(addr + 4, nanHead | typeFlag, true);\n this.mem.setUint32(addr, id, true);\n };\n const loadSlice = (addr) => {\n const array = getInt64(addr + 0);\n const len = getInt64(addr + 8);\n return new Uint8Array(this._inst.exports.mem.buffer, array, len);\n };\n const loadSliceOfValues = (addr) => {\n const array = getInt64(addr + 0);\n const len = getInt64(addr + 8);\n const a = new Array(len);\n for (let i = 0; i < len; i++) {\n a[i] = loadValue(array + i * 8);\n }\n return a;\n };\n const loadString = (addr) => {\n const saddr = getInt64(addr + 0);\n const len = getInt64(addr + 8);\n return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));\n };\n const timeOrigin = Date.now() - performance.now();\n this.importObject = {\n go: {\n "runtime.wasmExit": (sp) => {\n sp >>>= 0;\n const code = this.mem.getInt32(sp + 8, true);\n this.exited = true;\n delete this._inst;\n delete this._values;\n delete this._goRefCounts;\n delete this._ids;\n delete this._idPool;\n this.exit(code);\n },\n "runtime.wasmWrite": (sp) => {\n sp >>>= 0;\n const fd = getInt64(sp + 8);\n const p = getInt64(sp + 16);\n const n = this.mem.getInt32(sp + 24, true);\n globalThis.fs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));\n },\n "runtime.resetMemoryDataView": (sp) => {\n sp >>>= 0;\n this.mem = new DataView(this._inst.exports.mem.buffer);\n },\n "runtime.nanotime1": (sp) => {\n sp >>>= 0;\n setInt64(sp + 8, (timeOrigin + performance.now()) * 1e6);\n },\n "runtime.walltime": (sp) => {\n sp >>>= 0;\n const msec = new Date().getTime();\n setInt64(sp + 8, msec / 1e3);\n this.mem.setInt32(sp + 16, msec % 1e3 * 1e6, true);\n },\n "runtime.scheduleTimeoutEvent": (sp) => {\n sp >>>= 0;\n const id = this._nextCallbackTimeoutID;\n this._nextCallbackTimeoutID++;\n this._scheduledTimeouts.set(id, setTimeout(() => {\n this._resume();\n while (this._scheduledTimeouts.has(id)) {\n console.warn("scheduleTimeoutEvent: missed timeout event");\n this._resume();\n }\n }, getInt64(sp + 8) + 1));\n this.mem.setInt32(sp + 16, id, true);\n },\n "runtime.clearTimeoutEvent": (sp) => {\n sp >>>= 0;\n const id = this.mem.getInt32(sp + 8, true);\n clearTimeout(this._scheduledTimeouts.get(id));\n this._scheduledTimeouts.delete(id);\n },\n "runtime.getRandomData": (sp) => {\n sp >>>= 0;\n crypto.getRandomValues(loadSlice(sp + 8));\n },\n "syscall/js.finalizeRef": (sp) => {\n sp >>>= 0;\n const id = this.mem.getUint32(sp + 8, true);\n this._goRefCounts[id]--;\n if (this._goRefCounts[id] === 0) {\n const v = this._values[id];\n this._values[id] = null;\n this._ids.delete(v);\n this._idPool.push(id);\n }\n },\n "syscall/js.stringVal": (sp) => {\n sp >>>= 0;\n storeValue(sp + 24, loadString(sp + 8));\n },\n "syscall/js.valueGet": (sp) => {\n sp >>>= 0;\n const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 32, result);\n },\n "syscall/js.valueSet": (sp) => {\n sp >>>= 0;\n Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));\n },\n "syscall/js.valueDelete": (sp) => {\n sp >>>= 0;\n Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));\n },\n "syscall/js.valueIndex": (sp) => {\n sp >>>= 0;\n storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));\n },\n "syscall/js.valueSetIndex": (sp) => {\n sp >>>= 0;\n Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));\n },\n "syscall/js.valueCall": (sp) => {\n sp >>>= 0;\n try {\n const v = loadValue(sp + 8);\n const m = Reflect.get(v, loadString(sp + 16));\n const args = loadSliceOfValues(sp + 32);\n const result = Reflect.apply(m, v, args);\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 56, result);\n this.mem.setUint8(sp + 64, 1);\n } catch (err) {\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 56, err);\n this.mem.setUint8(sp + 64, 0);\n }\n },\n "syscall/js.valueInvoke": (sp) => {\n sp >>>= 0;\n try {\n const v = loadValue(sp + 8);\n const args = loadSliceOfValues(sp + 16);\n const result = Reflect.apply(v, void 0, args);\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 40, result);\n this.mem.setUint8(sp + 48, 1);\n } catch (err) {\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 40, err);\n this.mem.setUint8(sp + 48, 0);\n }\n },\n "syscall/js.valueNew": (sp) => {\n sp >>>= 0;\n try {\n const v = loadValue(sp + 8);\n const args = loadSliceOfValues(sp + 16);\n const result = Reflect.construct(v, args);\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 40, result);\n this.mem.setUint8(sp + 48, 1);\n } catch (err) {\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 40, err);\n this.mem.setUint8(sp + 48, 0);\n }\n },\n "syscall/js.valueLength": (sp) => {\n sp >>>= 0;\n setInt64(sp + 16, parseInt(loadValue(sp + 8).length));\n },\n "syscall/js.valuePrepareString": (sp) => {\n sp >>>= 0;\n const str = encoder.encode(String(loadValue(sp + 8)));\n storeValue(sp + 16, str);\n setInt64(sp + 24, str.length);\n },\n "syscall/js.valueLoadString": (sp) => {\n sp >>>= 0;\n const str = loadValue(sp + 8);\n loadSlice(sp + 16).set(str);\n },\n "syscall/js.valueInstanceOf": (sp) => {\n sp >>>= 0;\n this.mem.setUint8(sp + 24, loadValue(sp + 8) instanceof loadValue(sp + 16) ? 1 : 0);\n },\n "syscall/js.copyBytesToGo": (sp) => {\n sp >>>= 0;\n const dst = loadSlice(sp + 8);\n const src = loadValue(sp + 32);\n if (!(src instanceof Uint8Array || src instanceof Uint8ClampedArray)) {\n this.mem.setUint8(sp + 48, 0);\n return;\n }\n const toCopy = src.subarray(0, dst.length);\n dst.set(toCopy);\n setInt64(sp + 40, toCopy.length);\n this.mem.setUint8(sp + 48, 1);\n },\n "syscall/js.copyBytesToJS": (sp) => {\n sp >>>= 0;\n const dst = loadValue(sp + 8);\n const src = loadSlice(sp + 16);\n if (!(dst instanceof Uint8Array || dst instanceof Uint8ClampedArray)) {\n this.mem.setUint8(sp + 48, 0);\n return;\n }\n const toCopy = src.subarray(0, dst.length);\n dst.set(toCopy);\n setInt64(sp + 40, toCopy.length);\n this.mem.setUint8(sp + 48, 1);\n },\n "debug": (value) => {\n console.log(value);\n }\n }\n };\n }\n run(instance) {\n return __async(this, null, function* () {\n if (!(instance instanceof WebAssembly.Instance)) {\n throw new Error("Go.run: WebAssembly.Instance expected");\n }\n this._inst = instance;\n this.mem = new DataView(this._inst.exports.mem.buffer);\n this._values = [\n NaN,\n 0,\n null,\n true,\n false,\n globalThis,\n this\n ];\n this._goRefCounts = new Array(this._values.length).fill(Infinity);\n this._ids = /* @__PURE__ */ new Map([\n [0, 1],\n [null, 2],\n [true, 3],\n [false, 4],\n [globalThis, 5],\n [this, 6]\n ]);\n this._idPool = [];\n this.exited = false;\n let offset = 4096;\n const strPtr = (str) => {\n const ptr = offset;\n const bytes = encoder.encode(str + "\\0");\n new Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes);\n offset += bytes.length;\n if (offset % 8 !== 0) {\n offset += 8 - offset % 8;\n }\n return ptr;\n };\n const argc = this.argv.length;\n const argvPtrs = [];\n this.argv.forEach((arg) => {\n argvPtrs.push(strPtr(arg));\n });\n argvPtrs.push(0);\n const keys = Object.keys(this.env).sort();\n keys.forEach((key) => {\n argvPtrs.push(strPtr(`${key}=${this.env[key]}`));\n });\n argvPtrs.push(0);\n const argv = offset;\n argvPtrs.forEach((ptr) => {\n this.mem.setUint32(offset, ptr, true);\n this.mem.setUint32(offset + 4, 0, true);\n offset += 8;\n });\n const wasmMinDataAddr = 4096 + 8192;\n if (offset >= wasmMinDataAddr) {\n throw new Error("total length of command line and environment variables exceeds limit");\n }\n this._inst.exports.run(argc, argv);\n if (this.exited) {\n this._resolveExitPromise();\n }\n yield this._exitPromise;\n });\n }\n _resume() {\n if (this.exited) {\n throw new Error("Go program has already exited");\n }\n this._inst.exports.resume();\n if (this.exited) {\n this._resolveExitPromise();\n }\n }\n _makeFuncWrapper(id) {\n const go = this;\n return function() {\n const event = { id, this: this, args: arguments };\n go._pendingEvent = event;\n go._resume();\n return event.result;\n };\n }\n };\n })();\n onmessage = ({ data: wasm }) => {\n let decoder = new TextDecoder();\n let fs = globalThis.fs;\n let stderr = "";\n fs.writeSync = (fd, buffer) => {\n if (fd === 1) {\n postMessage(buffer);\n } else if (fd === 2) {\n stderr += decoder.decode(buffer);\n let parts = stderr.split("\\n");\n if (parts.length > 1)\n console.log(parts.slice(0, -1).join("\\n"));\n stderr = parts[parts.length - 1];\n } else {\n throw new Error("Bad write");\n }\n return buffer.length;\n };\n let stdin = [];\n let resumeStdin;\n let stdinPos = 0;\n onmessage = ({ data }) => {\n if (data.length > 0) {\n stdin.push(data);\n if (resumeStdin)\n resumeStdin();\n }\n };\n fs.read = (fd, buffer, offset, length, position, callback) => {\n if (fd !== 0 || offset !== 0 || length !== buffer.length || position !== null) {\n throw new Error("Bad read");\n }\n if (stdin.length === 0) {\n resumeStdin = () => fs.read(fd, buffer, offset, length, position, callback);\n return;\n }\n let first = stdin[0];\n let count = Math.max(0, Math.min(length, first.length - stdinPos));\n buffer.set(first.subarray(stdinPos, stdinPos + count), offset);\n stdinPos += count;\n if (stdinPos === first.length) {\n stdin.shift();\n stdinPos = 0;\n }\n callback(null, count);\n };\n let go = new globalThis.Go();\n go.argv = ["", `--service=${"0.14.36"}`];\n if (wasm instanceof WebAssembly.Module) {\n WebAssembly.instantiate(wasm, go.importObject).then((instance) => go.run(instance));\n } else {\n WebAssembly.instantiate(wasm, go.importObject).then(({ instance }) => go.run(instance));\n }\n };\n return (m) => onmessage(m);\n })'}(postMessage)`], { type: "text/javascript" });
|
1770
|
+
worker = new Worker(URL.createObjectURL(blob));
|
1771
|
+
} else {
|
1772
|
+
let onmessage = ((postMessage) => {
|
1773
|
+
// Copyright 2018 The Go Authors. All rights reserved.
|
1774
|
+
// Use of this source code is governed by a BSD-style
|
1775
|
+
// license that can be found in the LICENSE file.
|
1776
|
+
var __async = (__this, __arguments, generator) => {
|
1777
|
+
return new Promise((resolve, reject) => {
|
1778
|
+
var fulfilled = (value) => {
|
1797
1779
|
try {
|
1798
|
-
|
1799
|
-
} catch (
|
1800
|
-
|
1780
|
+
step(generator.next(value));
|
1781
|
+
} catch (e) {
|
1782
|
+
reject(e);
|
1801
1783
|
}
|
1802
|
-
|
1803
|
-
|
1804
|
-
if (fd === process.stderr.fd) {
|
1784
|
+
};
|
1785
|
+
var rejected = (value) => {
|
1805
1786
|
try {
|
1806
|
-
|
1807
|
-
} catch (
|
1808
|
-
|
1787
|
+
step(generator.throw(value));
|
1788
|
+
} catch (e) {
|
1789
|
+
reject(e);
|
1790
|
+
}
|
1791
|
+
};
|
1792
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
1793
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
1794
|
+
});
|
1795
|
+
};
|
1796
|
+
let onmessage;
|
1797
|
+
let globalThis = {};
|
1798
|
+
for (let o = self; o; o = Object.getPrototypeOf(o))
|
1799
|
+
for (let k of Object.getOwnPropertyNames(o))
|
1800
|
+
if (!(k in globalThis))
|
1801
|
+
Object.defineProperty(globalThis, k, { get: () => self[k] });
|
1802
|
+
"use strict";
|
1803
|
+
(() => {
|
1804
|
+
const enosys = () => {
|
1805
|
+
const err = new Error("not implemented");
|
1806
|
+
err.code = "ENOSYS";
|
1807
|
+
return err;
|
1808
|
+
};
|
1809
|
+
if (!globalThis.fs) {
|
1810
|
+
let outputBuf = "";
|
1811
|
+
globalThis.fs = {
|
1812
|
+
constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 },
|
1813
|
+
writeSync(fd, buf) {
|
1814
|
+
outputBuf += decoder.decode(buf);
|
1815
|
+
const nl = outputBuf.lastIndexOf("\n");
|
1816
|
+
if (nl != -1) {
|
1817
|
+
console.log(outputBuf.substr(0, nl));
|
1818
|
+
outputBuf = outputBuf.substr(nl + 1);
|
1819
|
+
}
|
1820
|
+
return buf.length;
|
1821
|
+
},
|
1822
|
+
write(fd, buf, offset, length, position, callback) {
|
1823
|
+
if (offset !== 0 || length !== buf.length || position !== null) {
|
1824
|
+
callback(enosys());
|
1825
|
+
return;
|
1826
|
+
}
|
1827
|
+
const n = this.writeSync(fd, buf);
|
1828
|
+
callback(null, n);
|
1829
|
+
},
|
1830
|
+
chmod(path, mode, callback) {
|
1831
|
+
callback(enosys());
|
1832
|
+
},
|
1833
|
+
chown(path, uid, gid, callback) {
|
1834
|
+
callback(enosys());
|
1835
|
+
},
|
1836
|
+
close(fd, callback) {
|
1837
|
+
callback(enosys());
|
1838
|
+
},
|
1839
|
+
fchmod(fd, mode, callback) {
|
1840
|
+
callback(enosys());
|
1841
|
+
},
|
1842
|
+
fchown(fd, uid, gid, callback) {
|
1843
|
+
callback(enosys());
|
1844
|
+
},
|
1845
|
+
fstat(fd, callback) {
|
1846
|
+
callback(enosys());
|
1847
|
+
},
|
1848
|
+
fsync(fd, callback) {
|
1849
|
+
callback(null);
|
1850
|
+
},
|
1851
|
+
ftruncate(fd, length, callback) {
|
1852
|
+
callback(enosys());
|
1853
|
+
},
|
1854
|
+
lchown(path, uid, gid, callback) {
|
1855
|
+
callback(enosys());
|
1856
|
+
},
|
1857
|
+
link(path, link, callback) {
|
1858
|
+
callback(enosys());
|
1859
|
+
},
|
1860
|
+
lstat(path, callback) {
|
1861
|
+
callback(enosys());
|
1862
|
+
},
|
1863
|
+
mkdir(path, perm, callback) {
|
1864
|
+
callback(enosys());
|
1865
|
+
},
|
1866
|
+
open(path, flags, mode, callback) {
|
1867
|
+
callback(enosys());
|
1868
|
+
},
|
1869
|
+
read(fd, buffer, offset, length, position, callback) {
|
1870
|
+
callback(enosys());
|
1871
|
+
},
|
1872
|
+
readdir(path, callback) {
|
1873
|
+
callback(enosys());
|
1874
|
+
},
|
1875
|
+
readlink(path, callback) {
|
1876
|
+
callback(enosys());
|
1877
|
+
},
|
1878
|
+
rename(from, to, callback) {
|
1879
|
+
callback(enosys());
|
1880
|
+
},
|
1881
|
+
rmdir(path, callback) {
|
1882
|
+
callback(enosys());
|
1883
|
+
},
|
1884
|
+
stat(path, callback) {
|
1885
|
+
callback(enosys());
|
1886
|
+
},
|
1887
|
+
symlink(path, link, callback) {
|
1888
|
+
callback(enosys());
|
1889
|
+
},
|
1890
|
+
truncate(path, length, callback) {
|
1891
|
+
callback(enosys());
|
1892
|
+
},
|
1893
|
+
unlink(path, callback) {
|
1894
|
+
callback(enosys());
|
1895
|
+
},
|
1896
|
+
utimes(path, atime, mtime, callback) {
|
1897
|
+
callback(enosys());
|
1898
|
+
}
|
1899
|
+
};
|
1900
|
+
}
|
1901
|
+
if (!globalThis.process) {
|
1902
|
+
globalThis.process = {
|
1903
|
+
getuid() {
|
1904
|
+
return -1;
|
1905
|
+
},
|
1906
|
+
getgid() {
|
1907
|
+
return -1;
|
1908
|
+
},
|
1909
|
+
geteuid() {
|
1910
|
+
return -1;
|
1911
|
+
},
|
1912
|
+
getegid() {
|
1913
|
+
return -1;
|
1914
|
+
},
|
1915
|
+
getgroups() {
|
1916
|
+
throw enosys();
|
1917
|
+
},
|
1918
|
+
pid: -1,
|
1919
|
+
ppid: -1,
|
1920
|
+
umask() {
|
1921
|
+
throw enosys();
|
1922
|
+
},
|
1923
|
+
cwd() {
|
1924
|
+
throw enosys();
|
1925
|
+
},
|
1926
|
+
chdir() {
|
1927
|
+
throw enosys();
|
1928
|
+
}
|
1929
|
+
};
|
1930
|
+
}
|
1931
|
+
if (!globalThis.crypto) {
|
1932
|
+
throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");
|
1933
|
+
}
|
1934
|
+
if (!globalThis.performance) {
|
1935
|
+
throw new Error("globalThis.performance is not available, polyfill required (performance.now only)");
|
1936
|
+
}
|
1937
|
+
if (!globalThis.TextEncoder) {
|
1938
|
+
throw new Error("globalThis.TextEncoder is not available, polyfill required");
|
1939
|
+
}
|
1940
|
+
if (!globalThis.TextDecoder) {
|
1941
|
+
throw new Error("globalThis.TextDecoder is not available, polyfill required");
|
1942
|
+
}
|
1943
|
+
const encoder = new TextEncoder("utf-8");
|
1944
|
+
const decoder = new TextDecoder("utf-8");
|
1945
|
+
globalThis.Go = class {
|
1946
|
+
constructor() {
|
1947
|
+
this.argv = ["js"];
|
1948
|
+
this.env = {};
|
1949
|
+
this.exit = (code) => {
|
1950
|
+
if (code !== 0) {
|
1951
|
+
console.warn("exit code:", code);
|
1952
|
+
}
|
1953
|
+
};
|
1954
|
+
this._exitPromise = new Promise((resolve) => {
|
1955
|
+
this._resolveExitPromise = resolve;
|
1956
|
+
});
|
1957
|
+
this._pendingEvent = null;
|
1958
|
+
this._scheduledTimeouts = /* @__PURE__ */ new Map();
|
1959
|
+
this._nextCallbackTimeoutID = 1;
|
1960
|
+
const setInt64 = (addr, v) => {
|
1961
|
+
this.mem.setUint32(addr + 0, v, true);
|
1962
|
+
this.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true);
|
1963
|
+
};
|
1964
|
+
const getInt64 = (addr) => {
|
1965
|
+
const low = this.mem.getUint32(addr + 0, true);
|
1966
|
+
const high = this.mem.getInt32(addr + 4, true);
|
1967
|
+
return low + high * 4294967296;
|
1968
|
+
};
|
1969
|
+
const loadValue = (addr) => {
|
1970
|
+
const f = this.mem.getFloat64(addr, true);
|
1971
|
+
if (f === 0) {
|
1972
|
+
return void 0;
|
1973
|
+
}
|
1974
|
+
if (!isNaN(f)) {
|
1975
|
+
return f;
|
1976
|
+
}
|
1977
|
+
const id = this.mem.getUint32(addr, true);
|
1978
|
+
return this._values[id];
|
1979
|
+
};
|
1980
|
+
const storeValue = (addr, v) => {
|
1981
|
+
const nanHead = 2146959360;
|
1982
|
+
if (typeof v === "number" && v !== 0) {
|
1983
|
+
if (isNaN(v)) {
|
1984
|
+
this.mem.setUint32(addr + 4, nanHead, true);
|
1985
|
+
this.mem.setUint32(addr, 0, true);
|
1986
|
+
return;
|
1987
|
+
}
|
1988
|
+
this.mem.setFloat64(addr, v, true);
|
1989
|
+
return;
|
1990
|
+
}
|
1991
|
+
if (v === void 0) {
|
1992
|
+
this.mem.setFloat64(addr, 0, true);
|
1993
|
+
return;
|
1994
|
+
}
|
1995
|
+
let id = this._ids.get(v);
|
1996
|
+
if (id === void 0) {
|
1997
|
+
id = this._idPool.pop();
|
1998
|
+
if (id === void 0) {
|
1999
|
+
id = this._values.length;
|
2000
|
+
}
|
2001
|
+
this._values[id] = v;
|
2002
|
+
this._goRefCounts[id] = 0;
|
2003
|
+
this._ids.set(v, id);
|
2004
|
+
}
|
2005
|
+
this._goRefCounts[id]++;
|
2006
|
+
let typeFlag = 0;
|
2007
|
+
switch (typeof v) {
|
2008
|
+
case "object":
|
2009
|
+
if (v !== null) {
|
2010
|
+
typeFlag = 1;
|
2011
|
+
}
|
2012
|
+
break;
|
2013
|
+
case "string":
|
2014
|
+
typeFlag = 2;
|
2015
|
+
break;
|
2016
|
+
case "symbol":
|
2017
|
+
typeFlag = 3;
|
2018
|
+
break;
|
2019
|
+
case "function":
|
2020
|
+
typeFlag = 4;
|
2021
|
+
break;
|
2022
|
+
}
|
2023
|
+
this.mem.setUint32(addr + 4, nanHead | typeFlag, true);
|
2024
|
+
this.mem.setUint32(addr, id, true);
|
2025
|
+
};
|
2026
|
+
const loadSlice = (addr) => {
|
2027
|
+
const array = getInt64(addr + 0);
|
2028
|
+
const len = getInt64(addr + 8);
|
2029
|
+
return new Uint8Array(this._inst.exports.mem.buffer, array, len);
|
2030
|
+
};
|
2031
|
+
const loadSliceOfValues = (addr) => {
|
2032
|
+
const array = getInt64(addr + 0);
|
2033
|
+
const len = getInt64(addr + 8);
|
2034
|
+
const a = new Array(len);
|
2035
|
+
for (let i = 0; i < len; i++) {
|
2036
|
+
a[i] = loadValue(array + i * 8);
|
2037
|
+
}
|
2038
|
+
return a;
|
2039
|
+
};
|
2040
|
+
const loadString = (addr) => {
|
2041
|
+
const saddr = getInt64(addr + 0);
|
2042
|
+
const len = getInt64(addr + 8);
|
2043
|
+
return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));
|
2044
|
+
};
|
2045
|
+
const timeOrigin = Date.now() - performance.now();
|
2046
|
+
this.importObject = {
|
2047
|
+
go: {
|
2048
|
+
"runtime.wasmExit": (sp) => {
|
2049
|
+
sp >>>= 0;
|
2050
|
+
const code = this.mem.getInt32(sp + 8, true);
|
2051
|
+
this.exited = true;
|
2052
|
+
delete this._inst;
|
2053
|
+
delete this._values;
|
2054
|
+
delete this._goRefCounts;
|
2055
|
+
delete this._ids;
|
2056
|
+
delete this._idPool;
|
2057
|
+
this.exit(code);
|
2058
|
+
},
|
2059
|
+
"runtime.wasmWrite": (sp) => {
|
2060
|
+
sp >>>= 0;
|
2061
|
+
const fd = getInt64(sp + 8);
|
2062
|
+
const p = getInt64(sp + 16);
|
2063
|
+
const n = this.mem.getInt32(sp + 24, true);
|
2064
|
+
globalThis.fs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));
|
2065
|
+
},
|
2066
|
+
"runtime.resetMemoryDataView": (sp) => {
|
2067
|
+
sp >>>= 0;
|
2068
|
+
this.mem = new DataView(this._inst.exports.mem.buffer);
|
2069
|
+
},
|
2070
|
+
"runtime.nanotime1": (sp) => {
|
2071
|
+
sp >>>= 0;
|
2072
|
+
setInt64(sp + 8, (timeOrigin + performance.now()) * 1e6);
|
2073
|
+
},
|
2074
|
+
"runtime.walltime": (sp) => {
|
2075
|
+
sp >>>= 0;
|
2076
|
+
const msec = new Date().getTime();
|
2077
|
+
setInt64(sp + 8, msec / 1e3);
|
2078
|
+
this.mem.setInt32(sp + 16, msec % 1e3 * 1e6, true);
|
2079
|
+
},
|
2080
|
+
"runtime.scheduleTimeoutEvent": (sp) => {
|
2081
|
+
sp >>>= 0;
|
2082
|
+
const id = this._nextCallbackTimeoutID;
|
2083
|
+
this._nextCallbackTimeoutID++;
|
2084
|
+
this._scheduledTimeouts.set(id, setTimeout(() => {
|
2085
|
+
this._resume();
|
2086
|
+
while (this._scheduledTimeouts.has(id)) {
|
2087
|
+
console.warn("scheduleTimeoutEvent: missed timeout event");
|
2088
|
+
this._resume();
|
2089
|
+
}
|
2090
|
+
}, getInt64(sp + 8) + 1));
|
2091
|
+
this.mem.setInt32(sp + 16, id, true);
|
2092
|
+
},
|
2093
|
+
"runtime.clearTimeoutEvent": (sp) => {
|
2094
|
+
sp >>>= 0;
|
2095
|
+
const id = this.mem.getInt32(sp + 8, true);
|
2096
|
+
clearTimeout(this._scheduledTimeouts.get(id));
|
2097
|
+
this._scheduledTimeouts.delete(id);
|
2098
|
+
},
|
2099
|
+
"runtime.getRandomData": (sp) => {
|
2100
|
+
sp >>>= 0;
|
2101
|
+
crypto.getRandomValues(loadSlice(sp + 8));
|
2102
|
+
},
|
2103
|
+
"syscall/js.finalizeRef": (sp) => {
|
2104
|
+
sp >>>= 0;
|
2105
|
+
const id = this.mem.getUint32(sp + 8, true);
|
2106
|
+
this._goRefCounts[id]--;
|
2107
|
+
if (this._goRefCounts[id] === 0) {
|
2108
|
+
const v = this._values[id];
|
2109
|
+
this._values[id] = null;
|
2110
|
+
this._ids.delete(v);
|
2111
|
+
this._idPool.push(id);
|
2112
|
+
}
|
2113
|
+
},
|
2114
|
+
"syscall/js.stringVal": (sp) => {
|
2115
|
+
sp >>>= 0;
|
2116
|
+
storeValue(sp + 24, loadString(sp + 8));
|
2117
|
+
},
|
2118
|
+
"syscall/js.valueGet": (sp) => {
|
2119
|
+
sp >>>= 0;
|
2120
|
+
const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));
|
2121
|
+
sp = this._inst.exports.getsp() >>> 0;
|
2122
|
+
storeValue(sp + 32, result);
|
2123
|
+
},
|
2124
|
+
"syscall/js.valueSet": (sp) => {
|
2125
|
+
sp >>>= 0;
|
2126
|
+
Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));
|
2127
|
+
},
|
2128
|
+
"syscall/js.valueDelete": (sp) => {
|
2129
|
+
sp >>>= 0;
|
2130
|
+
Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));
|
2131
|
+
},
|
2132
|
+
"syscall/js.valueIndex": (sp) => {
|
2133
|
+
sp >>>= 0;
|
2134
|
+
storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));
|
2135
|
+
},
|
2136
|
+
"syscall/js.valueSetIndex": (sp) => {
|
2137
|
+
sp >>>= 0;
|
2138
|
+
Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));
|
2139
|
+
},
|
2140
|
+
"syscall/js.valueCall": (sp) => {
|
2141
|
+
sp >>>= 0;
|
2142
|
+
try {
|
2143
|
+
const v = loadValue(sp + 8);
|
2144
|
+
const m = Reflect.get(v, loadString(sp + 16));
|
2145
|
+
const args = loadSliceOfValues(sp + 32);
|
2146
|
+
const result = Reflect.apply(m, v, args);
|
2147
|
+
sp = this._inst.exports.getsp() >>> 0;
|
2148
|
+
storeValue(sp + 56, result);
|
2149
|
+
this.mem.setUint8(sp + 64, 1);
|
2150
|
+
} catch (err) {
|
2151
|
+
sp = this._inst.exports.getsp() >>> 0;
|
2152
|
+
storeValue(sp + 56, err);
|
2153
|
+
this.mem.setUint8(sp + 64, 0);
|
2154
|
+
}
|
2155
|
+
},
|
2156
|
+
"syscall/js.valueInvoke": (sp) => {
|
2157
|
+
sp >>>= 0;
|
2158
|
+
try {
|
2159
|
+
const v = loadValue(sp + 8);
|
2160
|
+
const args = loadSliceOfValues(sp + 16);
|
2161
|
+
const result = Reflect.apply(v, void 0, args);
|
2162
|
+
sp = this._inst.exports.getsp() >>> 0;
|
2163
|
+
storeValue(sp + 40, result);
|
2164
|
+
this.mem.setUint8(sp + 48, 1);
|
2165
|
+
} catch (err) {
|
2166
|
+
sp = this._inst.exports.getsp() >>> 0;
|
2167
|
+
storeValue(sp + 40, err);
|
2168
|
+
this.mem.setUint8(sp + 48, 0);
|
2169
|
+
}
|
2170
|
+
},
|
2171
|
+
"syscall/js.valueNew": (sp) => {
|
2172
|
+
sp >>>= 0;
|
2173
|
+
try {
|
2174
|
+
const v = loadValue(sp + 8);
|
2175
|
+
const args = loadSliceOfValues(sp + 16);
|
2176
|
+
const result = Reflect.construct(v, args);
|
2177
|
+
sp = this._inst.exports.getsp() >>> 0;
|
2178
|
+
storeValue(sp + 40, result);
|
2179
|
+
this.mem.setUint8(sp + 48, 1);
|
2180
|
+
} catch (err) {
|
2181
|
+
sp = this._inst.exports.getsp() >>> 0;
|
2182
|
+
storeValue(sp + 40, err);
|
2183
|
+
this.mem.setUint8(sp + 48, 0);
|
2184
|
+
}
|
2185
|
+
},
|
2186
|
+
"syscall/js.valueLength": (sp) => {
|
2187
|
+
sp >>>= 0;
|
2188
|
+
setInt64(sp + 16, parseInt(loadValue(sp + 8).length));
|
2189
|
+
},
|
2190
|
+
"syscall/js.valuePrepareString": (sp) => {
|
2191
|
+
sp >>>= 0;
|
2192
|
+
const str = encoder.encode(String(loadValue(sp + 8)));
|
2193
|
+
storeValue(sp + 16, str);
|
2194
|
+
setInt64(sp + 24, str.length);
|
2195
|
+
},
|
2196
|
+
"syscall/js.valueLoadString": (sp) => {
|
2197
|
+
sp >>>= 0;
|
2198
|
+
const str = loadValue(sp + 8);
|
2199
|
+
loadSlice(sp + 16).set(str);
|
2200
|
+
},
|
2201
|
+
"syscall/js.valueInstanceOf": (sp) => {
|
2202
|
+
sp >>>= 0;
|
2203
|
+
this.mem.setUint8(sp + 24, loadValue(sp + 8) instanceof loadValue(sp + 16) ? 1 : 0);
|
2204
|
+
},
|
2205
|
+
"syscall/js.copyBytesToGo": (sp) => {
|
2206
|
+
sp >>>= 0;
|
2207
|
+
const dst = loadSlice(sp + 8);
|
2208
|
+
const src = loadValue(sp + 32);
|
2209
|
+
if (!(src instanceof Uint8Array || src instanceof Uint8ClampedArray)) {
|
2210
|
+
this.mem.setUint8(sp + 48, 0);
|
2211
|
+
return;
|
2212
|
+
}
|
2213
|
+
const toCopy = src.subarray(0, dst.length);
|
2214
|
+
dst.set(toCopy);
|
2215
|
+
setInt64(sp + 40, toCopy.length);
|
2216
|
+
this.mem.setUint8(sp + 48, 1);
|
2217
|
+
},
|
2218
|
+
"syscall/js.copyBytesToJS": (sp) => {
|
2219
|
+
sp >>>= 0;
|
2220
|
+
const dst = loadValue(sp + 8);
|
2221
|
+
const src = loadSlice(sp + 16);
|
2222
|
+
if (!(dst instanceof Uint8Array || dst instanceof Uint8ClampedArray)) {
|
2223
|
+
this.mem.setUint8(sp + 48, 0);
|
2224
|
+
return;
|
2225
|
+
}
|
2226
|
+
const toCopy = src.subarray(0, dst.length);
|
2227
|
+
dst.set(toCopy);
|
2228
|
+
setInt64(sp + 40, toCopy.length);
|
2229
|
+
this.mem.setUint8(sp + 48, 1);
|
2230
|
+
},
|
2231
|
+
"debug": (value) => {
|
2232
|
+
console.log(value);
|
2233
|
+
}
|
2234
|
+
}
|
2235
|
+
};
|
2236
|
+
}
|
2237
|
+
run(instance) {
|
2238
|
+
return __async(this, null, function* () {
|
2239
|
+
if (!(instance instanceof WebAssembly.Instance)) {
|
2240
|
+
throw new Error("Go.run: WebAssembly.Instance expected");
|
2241
|
+
}
|
2242
|
+
this._inst = instance;
|
2243
|
+
this.mem = new DataView(this._inst.exports.mem.buffer);
|
2244
|
+
this._values = [
|
2245
|
+
NaN,
|
2246
|
+
0,
|
2247
|
+
null,
|
2248
|
+
true,
|
2249
|
+
false,
|
2250
|
+
globalThis,
|
2251
|
+
this
|
2252
|
+
];
|
2253
|
+
this._goRefCounts = new Array(this._values.length).fill(Infinity);
|
2254
|
+
this._ids = /* @__PURE__ */ new Map([
|
2255
|
+
[0, 1],
|
2256
|
+
[null, 2],
|
2257
|
+
[true, 3],
|
2258
|
+
[false, 4],
|
2259
|
+
[globalThis, 5],
|
2260
|
+
[this, 6]
|
2261
|
+
]);
|
2262
|
+
this._idPool = [];
|
2263
|
+
this.exited = false;
|
2264
|
+
let offset = 4096;
|
2265
|
+
const strPtr = (str) => {
|
2266
|
+
const ptr = offset;
|
2267
|
+
const bytes = encoder.encode(str + "\0");
|
2268
|
+
new Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes);
|
2269
|
+
offset += bytes.length;
|
2270
|
+
if (offset % 8 !== 0) {
|
2271
|
+
offset += 8 - offset % 8;
|
2272
|
+
}
|
2273
|
+
return ptr;
|
2274
|
+
};
|
2275
|
+
const argc = this.argv.length;
|
2276
|
+
const argvPtrs = [];
|
2277
|
+
this.argv.forEach((arg) => {
|
2278
|
+
argvPtrs.push(strPtr(arg));
|
2279
|
+
});
|
2280
|
+
argvPtrs.push(0);
|
2281
|
+
const keys = Object.keys(this.env).sort();
|
2282
|
+
keys.forEach((key) => {
|
2283
|
+
argvPtrs.push(strPtr(`${key}=${this.env[key]}`));
|
2284
|
+
});
|
2285
|
+
argvPtrs.push(0);
|
2286
|
+
const argv = offset;
|
2287
|
+
argvPtrs.forEach((ptr) => {
|
2288
|
+
this.mem.setUint32(offset, ptr, true);
|
2289
|
+
this.mem.setUint32(offset + 4, 0, true);
|
2290
|
+
offset += 8;
|
2291
|
+
});
|
2292
|
+
const wasmMinDataAddr = 4096 + 8192;
|
2293
|
+
if (offset >= wasmMinDataAddr) {
|
2294
|
+
throw new Error("total length of command line and environment variables exceeds limit");
|
2295
|
+
}
|
2296
|
+
this._inst.exports.run(argc, argv);
|
2297
|
+
if (this.exited) {
|
2298
|
+
this._resolveExitPromise();
|
2299
|
+
}
|
2300
|
+
yield this._exitPromise;
|
2301
|
+
});
|
2302
|
+
}
|
2303
|
+
_resume() {
|
2304
|
+
if (this.exited) {
|
2305
|
+
throw new Error("Go program has already exited");
|
2306
|
+
}
|
2307
|
+
this._inst.exports.resume();
|
2308
|
+
if (this.exited) {
|
2309
|
+
this._resolveExitPromise();
|
1809
2310
|
}
|
2311
|
+
}
|
2312
|
+
_makeFuncWrapper(id) {
|
2313
|
+
const go = this;
|
2314
|
+
return function() {
|
2315
|
+
const event = { id, this: this, args: arguments };
|
2316
|
+
go._pendingEvent = event;
|
2317
|
+
go._resume();
|
2318
|
+
return event.result;
|
2319
|
+
};
|
2320
|
+
}
|
2321
|
+
};
|
2322
|
+
})();
|
2323
|
+
onmessage = ({ data: wasm }) => {
|
2324
|
+
let decoder = new TextDecoder();
|
2325
|
+
let fs = globalThis.fs;
|
2326
|
+
let stderr = "";
|
2327
|
+
fs.writeSync = (fd, buffer) => {
|
2328
|
+
if (fd === 1) {
|
2329
|
+
postMessage(buffer);
|
2330
|
+
} else if (fd === 2) {
|
2331
|
+
stderr += decoder.decode(buffer);
|
2332
|
+
let parts = stderr.split("\n");
|
2333
|
+
if (parts.length > 1)
|
2334
|
+
console.log(parts.slice(0, -1).join("\n"));
|
2335
|
+
stderr = parts[parts.length - 1];
|
2336
|
+
} else {
|
2337
|
+
throw new Error("Bad write");
|
2338
|
+
}
|
2339
|
+
return buffer.length;
|
2340
|
+
};
|
2341
|
+
let stdin = [];
|
2342
|
+
let resumeStdin;
|
2343
|
+
let stdinPos = 0;
|
2344
|
+
onmessage = ({ data }) => {
|
2345
|
+
if (data.length > 0) {
|
2346
|
+
stdin.push(data);
|
2347
|
+
if (resumeStdin)
|
2348
|
+
resumeStdin();
|
2349
|
+
}
|
2350
|
+
};
|
2351
|
+
fs.read = (fd, buffer, offset, length, position, callback) => {
|
2352
|
+
if (fd !== 0 || offset !== 0 || length !== buffer.length || position !== null) {
|
2353
|
+
throw new Error("Bad read");
|
2354
|
+
}
|
2355
|
+
if (stdin.length === 0) {
|
2356
|
+
resumeStdin = () => fs.read(fd, buffer, offset, length, position, callback);
|
1810
2357
|
return;
|
1811
2358
|
}
|
2359
|
+
let first = stdin[0];
|
2360
|
+
let count = Math.max(0, Math.min(length, first.length - stdinPos));
|
2361
|
+
buffer.set(first.subarray(stdinPos, stdinPos + count), offset);
|
2362
|
+
stdinPos += count;
|
2363
|
+
if (stdinPos === first.length) {
|
2364
|
+
stdin.shift();
|
2365
|
+
stdinPos = 0;
|
2366
|
+
}
|
2367
|
+
callback(null, count);
|
2368
|
+
};
|
2369
|
+
let go = new globalThis.Go();
|
2370
|
+
go.argv = ["", `--service=${"0.14.36"}`];
|
2371
|
+
if (wasm instanceof WebAssembly.Module) {
|
2372
|
+
WebAssembly.instantiate(wasm, go.importObject).then((instance) => go.run(instance));
|
2373
|
+
} else {
|
2374
|
+
WebAssembly.instantiate(wasm, go.importObject).then(({ instance }) => go.run(instance));
|
1812
2375
|
}
|
1813
|
-
|
1814
|
-
|
1815
|
-
});
|
1816
|
-
|
1817
|
-
}
|
1818
|
-
}
|
1819
|
-
|
1820
|
-
const enosys = () => {
|
1821
|
-
const err = new Error("not implemented");
|
1822
|
-
err.code = "ENOSYS";
|
1823
|
-
return err;
|
1824
|
-
};
|
1825
|
-
|
1826
|
-
if (!global.fs) {
|
1827
|
-
let outputBuf = "";
|
1828
|
-
global.fs = {
|
1829
|
-
constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 }, // unused
|
1830
|
-
writeSync(fd, buf) {
|
1831
|
-
outputBuf += decoder.decode(buf);
|
1832
|
-
const nl = outputBuf.lastIndexOf("\\n");
|
1833
|
-
if (nl != -1) {
|
1834
|
-
console.log(outputBuf.substr(0, nl));
|
1835
|
-
outputBuf = outputBuf.substr(nl + 1);
|
1836
|
-
}
|
1837
|
-
return buf.length;
|
1838
|
-
},
|
1839
|
-
write(fd, buf, offset, length, position, callback) {
|
1840
|
-
if (offset !== 0 || length !== buf.length || position !== null) {
|
1841
|
-
callback(enosys());
|
1842
|
-
return;
|
1843
|
-
}
|
1844
|
-
const n = this.writeSync(fd, buf);
|
1845
|
-
callback(null, n);
|
1846
|
-
},
|
1847
|
-
chmod(path, mode, callback) { callback(enosys()); },
|
1848
|
-
chown(path, uid, gid, callback) { callback(enosys()); },
|
1849
|
-
close(fd, callback) { callback(enosys()); },
|
1850
|
-
fchmod(fd, mode, callback) { callback(enosys()); },
|
1851
|
-
fchown(fd, uid, gid, callback) { callback(enosys()); },
|
1852
|
-
fstat(fd, callback) { callback(enosys()); },
|
1853
|
-
fsync(fd, callback) { callback(null); },
|
1854
|
-
ftruncate(fd, length, callback) { callback(enosys()); },
|
1855
|
-
lchown(path, uid, gid, callback) { callback(enosys()); },
|
1856
|
-
link(path, link, callback) { callback(enosys()); },
|
1857
|
-
lstat(path, callback) { callback(enosys()); },
|
1858
|
-
mkdir(path, perm, callback) { callback(enosys()); },
|
1859
|
-
open(path, flags, mode, callback) { callback(enosys()); },
|
1860
|
-
read(fd, buffer, offset, length, position, callback) { callback(enosys()); },
|
1861
|
-
readdir(path, callback) { callback(enosys()); },
|
1862
|
-
readlink(path, callback) { callback(enosys()); },
|
1863
|
-
rename(from, to, callback) { callback(enosys()); },
|
1864
|
-
rmdir(path, callback) { callback(enosys()); },
|
1865
|
-
stat(path, callback) { callback(enosys()); },
|
1866
|
-
symlink(path, link, callback) { callback(enosys()); },
|
1867
|
-
truncate(path, length, callback) { callback(enosys()); },
|
1868
|
-
unlink(path, callback) { callback(enosys()); },
|
1869
|
-
utimes(path, atime, mtime, callback) { callback(enosys()); },
|
1870
|
-
};
|
1871
|
-
}
|
1872
|
-
|
1873
|
-
if (!global.process) {
|
1874
|
-
global.process = {
|
1875
|
-
getuid() { return -1; },
|
1876
|
-
getgid() { return -1; },
|
1877
|
-
geteuid() { return -1; },
|
1878
|
-
getegid() { return -1; },
|
1879
|
-
getgroups() { throw enosys(); },
|
1880
|
-
pid: -1,
|
1881
|
-
ppid: -1,
|
1882
|
-
umask() { throw enosys(); },
|
1883
|
-
cwd() { throw enosys(); },
|
1884
|
-
chdir() { throw enosys(); },
|
1885
|
-
}
|
1886
|
-
}
|
1887
|
-
|
1888
|
-
if (!global.crypto && global.require) {
|
1889
|
-
const nodeCrypto = require("crypto");
|
1890
|
-
global.crypto = {
|
1891
|
-
getRandomValues(b) {
|
1892
|
-
nodeCrypto.randomFillSync(b);
|
1893
|
-
},
|
1894
|
-
};
|
1895
|
-
}
|
1896
|
-
if (!global.crypto) {
|
1897
|
-
throw new Error("global.crypto is not available, polyfill required (getRandomValues only)");
|
1898
|
-
}
|
1899
|
-
|
1900
|
-
if (!global.performance) {
|
1901
|
-
global.performance = {
|
1902
|
-
now() {
|
1903
|
-
const [sec, nsec] = process.hrtime();
|
1904
|
-
return sec * 1000 + nsec / 1000000;
|
1905
|
-
},
|
1906
|
-
};
|
1907
|
-
}
|
1908
|
-
|
1909
|
-
if (!global.TextEncoder && global.require) {
|
1910
|
-
global.TextEncoder = require("util").TextEncoder;
|
1911
|
-
}
|
1912
|
-
if (!global.TextEncoder) {
|
1913
|
-
throw new Error("global.TextEncoder is not available, polyfill required");
|
1914
|
-
}
|
1915
|
-
|
1916
|
-
if (!global.TextDecoder && global.require) {
|
1917
|
-
global.TextDecoder = require("util").TextDecoder;
|
1918
|
-
}
|
1919
|
-
if (!global.TextDecoder) {
|
1920
|
-
throw new Error("global.TextDecoder is not available, polyfill required");
|
1921
|
-
}
|
1922
|
-
|
1923
|
-
|
1924
|
-
// Make sure Go sees the shadowed "fs" global
|
1925
|
-
const { fs } = global;
|
1926
|
-
|
1927
|
-
|
1928
|
-
const encoder = new TextEncoder("utf-8");
|
1929
|
-
const decoder = new TextDecoder("utf-8");
|
1930
|
-
|
1931
|
-
global.Go = class {
|
1932
|
-
constructor() {
|
1933
|
-
this.argv = ["js"];
|
1934
|
-
this.env = {};
|
1935
|
-
this.exit = (code) => {
|
1936
|
-
if (code !== 0) {
|
1937
|
-
console.warn("exit code:", code);
|
1938
|
-
}
|
1939
|
-
};
|
1940
|
-
this._exitPromise = new Promise((resolve) => {
|
1941
|
-
this._resolveExitPromise = resolve;
|
1942
|
-
});
|
1943
|
-
this._pendingEvent = null;
|
1944
|
-
this._scheduledTimeouts = new Map();
|
1945
|
-
this._nextCallbackTimeoutID = 1;
|
1946
|
-
|
1947
|
-
const setInt64 = (addr, v) => {
|
1948
|
-
this.mem.setUint32(addr + 0, v, true);
|
1949
|
-
this.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true);
|
1950
|
-
}
|
1951
|
-
|
1952
|
-
const getInt64 = (addr) => {
|
1953
|
-
const low = this.mem.getUint32(addr + 0, true);
|
1954
|
-
const high = this.mem.getInt32(addr + 4, true);
|
1955
|
-
return low + high * 4294967296;
|
1956
|
-
}
|
1957
|
-
|
1958
|
-
const loadValue = (addr) => {
|
1959
|
-
const f = this.mem.getFloat64(addr, true);
|
1960
|
-
if (f === 0) {
|
1961
|
-
return undefined;
|
1962
|
-
}
|
1963
|
-
if (!isNaN(f)) {
|
1964
|
-
return f;
|
1965
|
-
}
|
1966
|
-
|
1967
|
-
const id = this.mem.getUint32(addr, true);
|
1968
|
-
return this._values[id];
|
1969
|
-
}
|
1970
|
-
|
1971
|
-
const storeValue = (addr, v) => {
|
1972
|
-
const nanHead = 0x7FF80000;
|
1973
|
-
|
1974
|
-
if (typeof v === "number" && v !== 0) {
|
1975
|
-
if (isNaN(v)) {
|
1976
|
-
this.mem.setUint32(addr + 4, nanHead, true);
|
1977
|
-
this.mem.setUint32(addr, 0, true);
|
1978
|
-
return;
|
1979
|
-
}
|
1980
|
-
this.mem.setFloat64(addr, v, true);
|
1981
|
-
return;
|
1982
|
-
}
|
1983
|
-
|
1984
|
-
if (v === undefined) {
|
1985
|
-
this.mem.setFloat64(addr, 0, true);
|
1986
|
-
return;
|
1987
|
-
}
|
1988
|
-
|
1989
|
-
let id = this._ids.get(v);
|
1990
|
-
if (id === undefined) {
|
1991
|
-
id = this._idPool.pop();
|
1992
|
-
if (id === undefined) {
|
1993
|
-
id = this._values.length;
|
1994
|
-
}
|
1995
|
-
this._values[id] = v;
|
1996
|
-
this._goRefCounts[id] = 0;
|
1997
|
-
this._ids.set(v, id);
|
1998
|
-
}
|
1999
|
-
this._goRefCounts[id]++;
|
2000
|
-
let typeFlag = 0;
|
2001
|
-
switch (typeof v) {
|
2002
|
-
case "object":
|
2003
|
-
if (v !== null) {
|
2004
|
-
typeFlag = 1;
|
2005
|
-
}
|
2006
|
-
break;
|
2007
|
-
case "string":
|
2008
|
-
typeFlag = 2;
|
2009
|
-
break;
|
2010
|
-
case "symbol":
|
2011
|
-
typeFlag = 3;
|
2012
|
-
break;
|
2013
|
-
case "function":
|
2014
|
-
typeFlag = 4;
|
2015
|
-
break;
|
2016
|
-
}
|
2017
|
-
this.mem.setUint32(addr + 4, nanHead | typeFlag, true);
|
2018
|
-
this.mem.setUint32(addr, id, true);
|
2019
|
-
}
|
2020
|
-
|
2021
|
-
const loadSlice = (addr) => {
|
2022
|
-
const array = getInt64(addr + 0);
|
2023
|
-
const len = getInt64(addr + 8);
|
2024
|
-
return new Uint8Array(this._inst.exports.mem.buffer, array, len);
|
2025
|
-
}
|
2026
|
-
|
2027
|
-
const loadSliceOfValues = (addr) => {
|
2028
|
-
const array = getInt64(addr + 0);
|
2029
|
-
const len = getInt64(addr + 8);
|
2030
|
-
const a = new Array(len);
|
2031
|
-
for (let i = 0; i < len; i++) {
|
2032
|
-
a[i] = loadValue(array + i * 8);
|
2033
|
-
}
|
2034
|
-
return a;
|
2035
|
-
}
|
2036
|
-
|
2037
|
-
const loadString = (addr) => {
|
2038
|
-
const saddr = getInt64(addr + 0);
|
2039
|
-
const len = getInt64(addr + 8);
|
2040
|
-
return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));
|
2041
|
-
}
|
2042
|
-
|
2043
|
-
const timeOrigin = Date.now() - performance.now();
|
2044
|
-
this.importObject = {
|
2045
|
-
go: {
|
2046
|
-
// Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)
|
2047
|
-
// may synchronously trigger a Go event handler. This makes Go code get executed in the middle of the imported
|
2048
|
-
// function. A goroutine can switch to a new stack if the current stack is too small (see morestack function).
|
2049
|
-
// This changes the SP, thus we have to update the SP used by the imported function.
|
2050
|
-
|
2051
|
-
// func wasmExit(code int32)
|
2052
|
-
"runtime.wasmExit": (sp) => {
|
2053
|
-
sp >>>= 0;
|
2054
|
-
const code = this.mem.getInt32(sp + 8, true);
|
2055
|
-
this.exited = true;
|
2056
|
-
delete this._inst;
|
2057
|
-
delete this._values;
|
2058
|
-
delete this._goRefCounts;
|
2059
|
-
delete this._ids;
|
2060
|
-
delete this._idPool;
|
2061
|
-
this.exit(code);
|
2062
|
-
},
|
2063
|
-
|
2064
|
-
// func wasmWrite(fd uintptr, p unsafe.Pointer, n int32)
|
2065
|
-
"runtime.wasmWrite": (sp) => {
|
2066
|
-
sp >>>= 0;
|
2067
|
-
const fd = getInt64(sp + 8);
|
2068
|
-
const p = getInt64(sp + 16);
|
2069
|
-
const n = this.mem.getInt32(sp + 24, true);
|
2070
|
-
fs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));
|
2071
|
-
},
|
2072
|
-
|
2073
|
-
// func resetMemoryDataView()
|
2074
|
-
"runtime.resetMemoryDataView": (sp) => {
|
2075
|
-
sp >>>= 0;
|
2076
|
-
this.mem = new DataView(this._inst.exports.mem.buffer);
|
2077
|
-
},
|
2078
|
-
|
2079
|
-
// func nanotime1() int64
|
2080
|
-
"runtime.nanotime1": (sp) => {
|
2081
|
-
sp >>>= 0;
|
2082
|
-
setInt64(sp + 8, (timeOrigin + performance.now()) * 1000000);
|
2083
|
-
},
|
2084
|
-
|
2085
|
-
// func walltime() (sec int64, nsec int32)
|
2086
|
-
"runtime.walltime": (sp) => {
|
2087
|
-
sp >>>= 0;
|
2088
|
-
const msec = (new Date).getTime();
|
2089
|
-
setInt64(sp + 8, msec / 1000);
|
2090
|
-
this.mem.setInt32(sp + 16, (msec % 1000) * 1000000, true);
|
2091
|
-
},
|
2092
|
-
|
2093
|
-
// func scheduleTimeoutEvent(delay int64) int32
|
2094
|
-
"runtime.scheduleTimeoutEvent": (sp) => {
|
2095
|
-
sp >>>= 0;
|
2096
|
-
const id = this._nextCallbackTimeoutID;
|
2097
|
-
this._nextCallbackTimeoutID++;
|
2098
|
-
this._scheduledTimeouts.set(id, setTimeout(
|
2099
|
-
() => {
|
2100
|
-
this._resume();
|
2101
|
-
while (this._scheduledTimeouts.has(id)) {
|
2102
|
-
// for some reason Go failed to register the timeout event, log and try again
|
2103
|
-
// (temporary workaround for https://github.com/golang/go/issues/28975)
|
2104
|
-
console.warn("scheduleTimeoutEvent: missed timeout event");
|
2105
|
-
this._resume();
|
2106
|
-
}
|
2107
|
-
},
|
2108
|
-
getInt64(sp + 8) + 1, // setTimeout has been seen to fire up to 1 millisecond early
|
2109
|
-
));
|
2110
|
-
this.mem.setInt32(sp + 16, id, true);
|
2111
|
-
},
|
2112
|
-
|
2113
|
-
// func clearTimeoutEvent(id int32)
|
2114
|
-
"runtime.clearTimeoutEvent": (sp) => {
|
2115
|
-
sp >>>= 0;
|
2116
|
-
const id = this.mem.getInt32(sp + 8, true);
|
2117
|
-
clearTimeout(this._scheduledTimeouts.get(id));
|
2118
|
-
this._scheduledTimeouts.delete(id);
|
2119
|
-
},
|
2120
|
-
|
2121
|
-
// func getRandomData(r []byte)
|
2122
|
-
"runtime.getRandomData": (sp) => {
|
2123
|
-
sp >>>= 0;
|
2124
|
-
crypto.getRandomValues(loadSlice(sp + 8));
|
2125
|
-
},
|
2126
|
-
|
2127
|
-
// func finalizeRef(v ref)
|
2128
|
-
"syscall/js.finalizeRef": (sp) => {
|
2129
|
-
sp >>>= 0;
|
2130
|
-
const id = this.mem.getUint32(sp + 8, true);
|
2131
|
-
this._goRefCounts[id]--;
|
2132
|
-
if (this._goRefCounts[id] === 0) {
|
2133
|
-
const v = this._values[id];
|
2134
|
-
this._values[id] = null;
|
2135
|
-
this._ids.delete(v);
|
2136
|
-
this._idPool.push(id);
|
2137
|
-
}
|
2138
|
-
},
|
2139
|
-
|
2140
|
-
// func stringVal(value string) ref
|
2141
|
-
"syscall/js.stringVal": (sp) => {
|
2142
|
-
sp >>>= 0;
|
2143
|
-
storeValue(sp + 24, loadString(sp + 8));
|
2144
|
-
},
|
2145
|
-
|
2146
|
-
// func valueGet(v ref, p string) ref
|
2147
|
-
"syscall/js.valueGet": (sp) => {
|
2148
|
-
sp >>>= 0;
|
2149
|
-
const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));
|
2150
|
-
sp = this._inst.exports.getsp() >>> 0; // see comment above
|
2151
|
-
storeValue(sp + 32, result);
|
2152
|
-
},
|
2153
|
-
|
2154
|
-
// func valueSet(v ref, p string, x ref)
|
2155
|
-
"syscall/js.valueSet": (sp) => {
|
2156
|
-
sp >>>= 0;
|
2157
|
-
Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));
|
2158
|
-
},
|
2159
|
-
|
2160
|
-
// func valueDelete(v ref, p string)
|
2161
|
-
"syscall/js.valueDelete": (sp) => {
|
2162
|
-
sp >>>= 0;
|
2163
|
-
Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));
|
2164
|
-
},
|
2165
|
-
|
2166
|
-
// func valueIndex(v ref, i int) ref
|
2167
|
-
"syscall/js.valueIndex": (sp) => {
|
2168
|
-
sp >>>= 0;
|
2169
|
-
storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));
|
2170
|
-
},
|
2171
|
-
|
2172
|
-
// valueSetIndex(v ref, i int, x ref)
|
2173
|
-
"syscall/js.valueSetIndex": (sp) => {
|
2174
|
-
sp >>>= 0;
|
2175
|
-
Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));
|
2176
|
-
},
|
2177
|
-
|
2178
|
-
// func valueCall(v ref, m string, args []ref) (ref, bool)
|
2179
|
-
"syscall/js.valueCall": (sp) => {
|
2180
|
-
sp >>>= 0;
|
2181
|
-
try {
|
2182
|
-
const v = loadValue(sp + 8);
|
2183
|
-
const m = Reflect.get(v, loadString(sp + 16));
|
2184
|
-
const args = loadSliceOfValues(sp + 32);
|
2185
|
-
const result = Reflect.apply(m, v, args);
|
2186
|
-
sp = this._inst.exports.getsp() >>> 0; // see comment above
|
2187
|
-
storeValue(sp + 56, result);
|
2188
|
-
this.mem.setUint8(sp + 64, 1);
|
2189
|
-
} catch (err) {
|
2190
|
-
sp = this._inst.exports.getsp() >>> 0; // see comment above
|
2191
|
-
storeValue(sp + 56, err);
|
2192
|
-
this.mem.setUint8(sp + 64, 0);
|
2193
|
-
}
|
2194
|
-
},
|
2195
|
-
|
2196
|
-
// func valueInvoke(v ref, args []ref) (ref, bool)
|
2197
|
-
"syscall/js.valueInvoke": (sp) => {
|
2198
|
-
sp >>>= 0;
|
2199
|
-
try {
|
2200
|
-
const v = loadValue(sp + 8);
|
2201
|
-
const args = loadSliceOfValues(sp + 16);
|
2202
|
-
const result = Reflect.apply(v, undefined, args);
|
2203
|
-
sp = this._inst.exports.getsp() >>> 0; // see comment above
|
2204
|
-
storeValue(sp + 40, result);
|
2205
|
-
this.mem.setUint8(sp + 48, 1);
|
2206
|
-
} catch (err) {
|
2207
|
-
sp = this._inst.exports.getsp() >>> 0; // see comment above
|
2208
|
-
storeValue(sp + 40, err);
|
2209
|
-
this.mem.setUint8(sp + 48, 0);
|
2210
|
-
}
|
2211
|
-
},
|
2212
|
-
|
2213
|
-
// func valueNew(v ref, args []ref) (ref, bool)
|
2214
|
-
"syscall/js.valueNew": (sp) => {
|
2215
|
-
sp >>>= 0;
|
2216
|
-
try {
|
2217
|
-
const v = loadValue(sp + 8);
|
2218
|
-
const args = loadSliceOfValues(sp + 16);
|
2219
|
-
const result = Reflect.construct(v, args);
|
2220
|
-
sp = this._inst.exports.getsp() >>> 0; // see comment above
|
2221
|
-
storeValue(sp + 40, result);
|
2222
|
-
this.mem.setUint8(sp + 48, 1);
|
2223
|
-
} catch (err) {
|
2224
|
-
sp = this._inst.exports.getsp() >>> 0; // see comment above
|
2225
|
-
storeValue(sp + 40, err);
|
2226
|
-
this.mem.setUint8(sp + 48, 0);
|
2227
|
-
}
|
2228
|
-
},
|
2229
|
-
|
2230
|
-
// func valueLength(v ref) int
|
2231
|
-
"syscall/js.valueLength": (sp) => {
|
2232
|
-
sp >>>= 0;
|
2233
|
-
setInt64(sp + 16, parseInt(loadValue(sp + 8).length));
|
2234
|
-
},
|
2235
|
-
|
2236
|
-
// valuePrepareString(v ref) (ref, int)
|
2237
|
-
"syscall/js.valuePrepareString": (sp) => {
|
2238
|
-
sp >>>= 0;
|
2239
|
-
const str = encoder.encode(String(loadValue(sp + 8)));
|
2240
|
-
storeValue(sp + 16, str);
|
2241
|
-
setInt64(sp + 24, str.length);
|
2242
|
-
},
|
2243
|
-
|
2244
|
-
// valueLoadString(v ref, b []byte)
|
2245
|
-
"syscall/js.valueLoadString": (sp) => {
|
2246
|
-
sp >>>= 0;
|
2247
|
-
const str = loadValue(sp + 8);
|
2248
|
-
loadSlice(sp + 16).set(str);
|
2249
|
-
},
|
2250
|
-
|
2251
|
-
// func valueInstanceOf(v ref, t ref) bool
|
2252
|
-
"syscall/js.valueInstanceOf": (sp) => {
|
2253
|
-
sp >>>= 0;
|
2254
|
-
this.mem.setUint8(sp + 24, (loadValue(sp + 8) instanceof loadValue(sp + 16)) ? 1 : 0);
|
2255
|
-
},
|
2256
|
-
|
2257
|
-
// func copyBytesToGo(dst []byte, src ref) (int, bool)
|
2258
|
-
"syscall/js.copyBytesToGo": (sp) => {
|
2259
|
-
sp >>>= 0;
|
2260
|
-
const dst = loadSlice(sp + 8);
|
2261
|
-
const src = loadValue(sp + 32);
|
2262
|
-
if (!(src instanceof Uint8Array || src instanceof Uint8ClampedArray)) {
|
2263
|
-
this.mem.setUint8(sp + 48, 0);
|
2264
|
-
return;
|
2265
|
-
}
|
2266
|
-
const toCopy = src.subarray(0, dst.length);
|
2267
|
-
dst.set(toCopy);
|
2268
|
-
setInt64(sp + 40, toCopy.length);
|
2269
|
-
this.mem.setUint8(sp + 48, 1);
|
2270
|
-
},
|
2271
|
-
|
2272
|
-
// func copyBytesToJS(dst ref, src []byte) (int, bool)
|
2273
|
-
"syscall/js.copyBytesToJS": (sp) => {
|
2274
|
-
sp >>>= 0;
|
2275
|
-
const dst = loadValue(sp + 8);
|
2276
|
-
const src = loadSlice(sp + 16);
|
2277
|
-
if (!(dst instanceof Uint8Array || dst instanceof Uint8ClampedArray)) {
|
2278
|
-
this.mem.setUint8(sp + 48, 0);
|
2279
|
-
return;
|
2280
|
-
}
|
2281
|
-
const toCopy = src.subarray(0, dst.length);
|
2282
|
-
dst.set(toCopy);
|
2283
|
-
setInt64(sp + 40, toCopy.length);
|
2284
|
-
this.mem.setUint8(sp + 48, 1);
|
2285
|
-
},
|
2286
|
-
|
2287
|
-
"debug": (value) => {
|
2288
|
-
console.log(value);
|
2289
|
-
},
|
2290
|
-
}
|
2291
|
-
};
|
2292
|
-
}
|
2293
|
-
|
2294
|
-
async run(instance) {
|
2295
|
-
if (!(instance instanceof WebAssembly.Instance)) {
|
2296
|
-
throw new Error("Go.run: WebAssembly.Instance expected");
|
2297
|
-
}
|
2298
|
-
this._inst = instance;
|
2299
|
-
this.mem = new DataView(this._inst.exports.mem.buffer);
|
2300
|
-
this._values = [ // JS values that Go currently has references to, indexed by reference id
|
2301
|
-
NaN,
|
2302
|
-
0,
|
2303
|
-
null,
|
2304
|
-
true,
|
2305
|
-
false,
|
2306
|
-
global,
|
2307
|
-
this,
|
2308
|
-
];
|
2309
|
-
this._goRefCounts = new Array(this._values.length).fill(Infinity); // number of references that Go has to a JS value, indexed by reference id
|
2310
|
-
this._ids = new Map([ // mapping from JS values to reference ids
|
2311
|
-
[0, 1],
|
2312
|
-
[null, 2],
|
2313
|
-
[true, 3],
|
2314
|
-
[false, 4],
|
2315
|
-
[global, 5],
|
2316
|
-
[this, 6],
|
2317
|
-
]);
|
2318
|
-
this._idPool = []; // unused ids that have been garbage collected
|
2319
|
-
this.exited = false; // whether the Go program has exited
|
2320
|
-
|
2321
|
-
// Pass command line arguments and environment variables to WebAssembly by writing them to the linear memory.
|
2322
|
-
let offset = 4096;
|
2323
|
-
|
2324
|
-
const strPtr = (str) => {
|
2325
|
-
const ptr = offset;
|
2326
|
-
const bytes = encoder.encode(str + "\\0");
|
2327
|
-
new Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes);
|
2328
|
-
offset += bytes.length;
|
2329
|
-
if (offset % 8 !== 0) {
|
2330
|
-
offset += 8 - (offset % 8);
|
2331
|
-
}
|
2332
|
-
return ptr;
|
2333
|
-
};
|
2334
|
-
|
2335
|
-
const argc = this.argv.length;
|
2336
|
-
|
2337
|
-
const argvPtrs = [];
|
2338
|
-
this.argv.forEach((arg) => {
|
2339
|
-
argvPtrs.push(strPtr(arg));
|
2340
|
-
});
|
2341
|
-
argvPtrs.push(0);
|
2342
|
-
|
2343
|
-
const keys = Object.keys(this.env).sort();
|
2344
|
-
keys.forEach((key) => {
|
2345
|
-
argvPtrs.push(strPtr(\`\${key}=\${this.env[key]}\`));
|
2346
|
-
});
|
2347
|
-
argvPtrs.push(0);
|
2348
|
-
|
2349
|
-
const argv = offset;
|
2350
|
-
argvPtrs.forEach((ptr) => {
|
2351
|
-
this.mem.setUint32(offset, ptr, true);
|
2352
|
-
this.mem.setUint32(offset + 4, 0, true);
|
2353
|
-
offset += 8;
|
2354
|
-
});
|
2355
|
-
|
2356
|
-
// The linker guarantees global data starts from at least wasmMinDataAddr.
|
2357
|
-
// Keep in sync with cmd/link/internal/ld/data.go:wasmMinDataAddr.
|
2358
|
-
const wasmMinDataAddr = 4096 + 8192;
|
2359
|
-
if (offset >= wasmMinDataAddr) {
|
2360
|
-
throw new Error("total length of command line and environment variables exceeds limit");
|
2361
|
-
}
|
2362
|
-
|
2363
|
-
this._inst.exports.run(argc, argv);
|
2364
|
-
if (this.exited) {
|
2365
|
-
this._resolveExitPromise();
|
2366
|
-
}
|
2367
|
-
await this._exitPromise;
|
2368
|
-
}
|
2369
|
-
|
2370
|
-
_resume() {
|
2371
|
-
if (this.exited) {
|
2372
|
-
throw new Error("Go program has already exited");
|
2373
|
-
}
|
2374
|
-
this._inst.exports.resume();
|
2375
|
-
if (this.exited) {
|
2376
|
-
this._resolveExitPromise();
|
2377
|
-
}
|
2378
|
-
}
|
2379
|
-
|
2380
|
-
_makeFuncWrapper(id) {
|
2381
|
-
const go = this;
|
2382
|
-
return function () {
|
2383
|
-
const event = { id: id, this: this, args: arguments };
|
2384
|
-
go._pendingEvent = event;
|
2385
|
-
go._resume();
|
2386
|
-
return event.result;
|
2387
|
-
};
|
2388
|
-
}
|
2389
|
-
}
|
2390
|
-
|
2391
|
-
if (
|
2392
|
-
typeof module !== "undefined" &&
|
2393
|
-
global.require &&
|
2394
|
-
global.require.main === module &&
|
2395
|
-
global.process &&
|
2396
|
-
global.process.versions &&
|
2397
|
-
!global.process.versions.electron
|
2398
|
-
) {
|
2399
|
-
if (process.argv.length < 3) {
|
2400
|
-
console.error("usage: go_js_wasm_exec [wasm binary] [arguments]");
|
2401
|
-
process.exit(1);
|
2402
|
-
}
|
2403
|
-
|
2404
|
-
const go = new Go();
|
2405
|
-
go.argv = process.argv.slice(2);
|
2406
|
-
go.env = Object.assign({ TMPDIR: require("os").tmpdir() }, process.env);
|
2407
|
-
go.exit = process.exit;
|
2408
|
-
WebAssembly.instantiate(fs.readFileSync(process.argv[2]), go.importObject).then((result) => {
|
2409
|
-
process.on("exit", (code) => { // Node.js exits if no event handler is pending
|
2410
|
-
if (code === 0 && !go.exited) {
|
2411
|
-
// deadlock, make Go print error and stack traces
|
2412
|
-
go._pendingEvent = { id: 0 };
|
2413
|
-
go._resume();
|
2414
|
-
}
|
2415
|
-
});
|
2416
|
-
return go.run(result.instance);
|
2417
|
-
}).catch((err) => {
|
2418
|
-
console.error(err);
|
2419
|
-
process.exit(1);
|
2420
|
-
});
|
2421
|
-
}
|
2422
|
-
})();
|
2423
|
-
onmessage = ({ data: wasm }) => {
|
2424
|
-
let decoder = new TextDecoder();
|
2425
|
-
let fs = global.fs;
|
2426
|
-
let stderr = "";
|
2427
|
-
fs.writeSync = (fd, buffer) => {
|
2428
|
-
if (fd === 1) {
|
2429
|
-
postMessage(buffer);
|
2430
|
-
} else if (fd === 2) {
|
2431
|
-
stderr += decoder.decode(buffer);
|
2432
|
-
let parts = stderr.split("\\n");
|
2433
|
-
if (parts.length > 1)
|
2434
|
-
console.log(parts.slice(0, -1).join("\\n"));
|
2435
|
-
stderr = parts[parts.length - 1];
|
2436
|
-
} else {
|
2437
|
-
throw new Error("Bad write");
|
2438
|
-
}
|
2439
|
-
return buffer.length;
|
2440
|
-
};
|
2441
|
-
let stdin = [];
|
2442
|
-
let resumeStdin;
|
2443
|
-
let stdinPos = 0;
|
2444
|
-
onmessage = ({ data }) => {
|
2445
|
-
if (data.length > 0) {
|
2446
|
-
stdin.push(data);
|
2447
|
-
if (resumeStdin)
|
2448
|
-
resumeStdin();
|
2449
|
-
}
|
2450
|
-
};
|
2451
|
-
fs.read = (fd, buffer, offset, length, position, callback) => {
|
2452
|
-
if (fd !== 0 || offset !== 0 || length !== buffer.length || position !== null) {
|
2453
|
-
throw new Error("Bad read");
|
2454
|
-
}
|
2455
|
-
if (stdin.length === 0) {
|
2456
|
-
resumeStdin = () => fs.read(fd, buffer, offset, length, position, callback);
|
2457
|
-
return;
|
2458
|
-
}
|
2459
|
-
let first = stdin[0];
|
2460
|
-
let count = Math.max(0, Math.min(length, first.length - stdinPos));
|
2461
|
-
buffer.set(first.subarray(stdinPos, stdinPos + count), offset);
|
2462
|
-
stdinPos += count;
|
2463
|
-
if (stdinPos === first.length) {
|
2464
|
-
stdin.shift();
|
2465
|
-
stdinPos = 0;
|
2466
|
-
}
|
2467
|
-
callback(null, count);
|
2468
|
-
};
|
2469
|
-
let go = new global.Go();
|
2470
|
-
go.argv = ["", \`--service=\${"0.14.23"}\`];
|
2471
|
-
WebAssembly.instantiate(wasm, go.importObject).then(({ instance }) => go.run(instance));
|
2472
|
-
};}`;
|
2473
|
-
let worker;
|
2474
|
-
if (useWorker) {
|
2475
|
-
let blob = new Blob([code], { type: "text/javascript" });
|
2476
|
-
worker = new Worker(URL.createObjectURL(blob));
|
2477
|
-
} else {
|
2478
|
-
let fn = new Function("postMessage", code + `var onmessage; return m => onmessage(m)`);
|
2479
|
-
let onmessage = fn((data) => worker.onmessage({ data }));
|
2376
|
+
};
|
2377
|
+
return (m) => onmessage(m);
|
2378
|
+
})((data) => worker.onmessage({ data }));
|
2480
2379
|
worker = {
|
2481
2380
|
onmessage: null,
|
2482
|
-
postMessage: (data) => onmessage({ data }),
|
2381
|
+
postMessage: (data) => setTimeout(() => onmessage({ data })),
|
2483
2382
|
terminate() {
|
2484
2383
|
}
|
2485
2384
|
};
|
@@ -2502,7 +2401,7 @@ onmessage = ({ data: wasm }) => {
|
|
2502
2401
|
options,
|
2503
2402
|
isTTY: false,
|
2504
2403
|
defaultWD: "/",
|
2505
|
-
callback: (err,
|
2404
|
+
callback: (err, res) => err ? reject(err) : resolve(res)
|
2506
2405
|
})),
|
2507
2406
|
transform: (input, options) => new Promise((resolve, reject) => service.transform({
|
2508
2407
|
callName: "transform",
|
@@ -2518,24 +2417,23 @@ onmessage = ({ data: wasm }) => {
|
|
2518
2417
|
callback(null);
|
2519
2418
|
}
|
2520
2419
|
},
|
2521
|
-
callback: (err,
|
2420
|
+
callback: (err, res) => err ? reject(err) : resolve(res)
|
2522
2421
|
})),
|
2523
2422
|
formatMessages: (messages, options) => new Promise((resolve, reject) => service.formatMessages({
|
2524
2423
|
callName: "formatMessages",
|
2525
2424
|
refs: null,
|
2526
2425
|
messages,
|
2527
2426
|
options,
|
2528
|
-
callback: (err,
|
2427
|
+
callback: (err, res) => err ? reject(err) : resolve(res)
|
2529
2428
|
})),
|
2530
2429
|
analyzeMetafile: (metafile, options) => new Promise((resolve, reject) => service.analyzeMetafile({
|
2531
2430
|
callName: "analyzeMetafile",
|
2532
2431
|
refs: null,
|
2533
2432
|
metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
|
2534
2433
|
options,
|
2535
|
-
callback: (err,
|
2434
|
+
callback: (err, res) => err ? reject(err) : resolve(res)
|
2536
2435
|
}))
|
2537
2436
|
};
|
2538
2437
|
});
|
2539
2438
|
var browser_default = browser_exports;
|
2540
|
-
module.exports = __toCommonJS(browser_exports);
|
2541
2439
|
})(typeof module==="object"?module:{set exports(x){(typeof self!=="undefined"?self:this).esbuild=x}});
|