isomorfeus-asset-manager 0.16.1 → 0.16.4
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/LICENSE +1 -1
- data/README.md +2 -3
- data/lib/isomorfeus/asset_manager/version.rb +1 -1
- data/node_modules/.package-lock.json +4 -4
- data/node_modules/esbuild-wasm/esbuild.wasm +0 -0
- data/node_modules/esbuild-wasm/esm/browser.d.ts +11 -3
- data/node_modules/esbuild-wasm/esm/browser.js +46 -5
- data/node_modules/esbuild-wasm/esm/browser.min.js +8 -8
- data/node_modules/esbuild-wasm/lib/browser.d.ts +11 -3
- data/node_modules/esbuild-wasm/lib/browser.js +46 -5
- data/node_modules/esbuild-wasm/lib/browser.min.js +7 -7
- data/node_modules/esbuild-wasm/lib/main.d.ts +11 -3
- data/node_modules/esbuild-wasm/lib/main.js +33 -8
- data/node_modules/esbuild-wasm/package.json +1 -1
- data/package.json +1 -1
- metadata +36 -27
@@ -450,6 +450,7 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
450
450
|
let mainFields = getFlag(options, keys, "mainFields", mustBeArray);
|
451
451
|
let conditions = getFlag(options, keys, "conditions", mustBeArray);
|
452
452
|
let external = getFlag(options, keys, "external", mustBeArray);
|
453
|
+
let packages = getFlag(options, keys, "packages", mustBeString);
|
453
454
|
let alias = getFlag(options, keys, "alias", mustBeObject);
|
454
455
|
let loader = getFlag(options, keys, "loader", mustBeObject);
|
455
456
|
let outExtension = getFlag(options, keys, "outExtension", mustBeObject);
|
@@ -500,6 +501,8 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
500
501
|
flags.push(`--outbase=${outbase}`);
|
501
502
|
if (tsconfig)
|
502
503
|
flags.push(`--tsconfig=${tsconfig}`);
|
504
|
+
if (packages)
|
505
|
+
flags.push(`--packages=${packages}`);
|
503
506
|
if (resolveExtensions) {
|
504
507
|
let values = [];
|
505
508
|
for (let value of resolveExtensions) {
|
@@ -747,8 +750,8 @@ function createChannel(streamIn) {
|
|
747
750
|
if (isFirstPacket) {
|
748
751
|
isFirstPacket = false;
|
749
752
|
let binaryVersion = String.fromCharCode(...bytes);
|
750
|
-
if (binaryVersion !== "0.16.
|
751
|
-
throw new Error(`Cannot start service: Host version "${"0.16.
|
753
|
+
if (binaryVersion !== "0.16.17") {
|
754
|
+
throw new Error(`Cannot start service: Host version "${"0.16.17"}" does not match binary version ${quote(binaryVersion)}`);
|
752
755
|
}
|
753
756
|
return;
|
754
757
|
}
|
@@ -834,6 +837,8 @@ function createChannel(streamIn) {
|
|
834
837
|
let next = () => {
|
835
838
|
if (--outstanding === 0) {
|
836
839
|
let result = { warnings, code: response.code, map: response.map };
|
840
|
+
if ("legalComments" in response)
|
841
|
+
result.legalComments = response == null ? void 0 : response.legalComments;
|
837
842
|
if (response.mangleCache)
|
838
843
|
result.mangleCache = response == null ? void 0 : response.mangleCache;
|
839
844
|
callback(null, result);
|
@@ -1233,6 +1238,8 @@ var handlePlugins = (buildKey, sendRequest, sendResponse, refs, streamIn, reques
|
|
1233
1238
|
checkForInvalidFlags(item, keys, `on plugin ${quote(name)}`);
|
1234
1239
|
let plugin = {
|
1235
1240
|
name,
|
1241
|
+
onStart: false,
|
1242
|
+
onEnd: false,
|
1236
1243
|
onResolve: [],
|
1237
1244
|
onLoad: []
|
1238
1245
|
};
|
@@ -1295,11 +1302,13 @@ var handlePlugins = (buildKey, sendRequest, sendResponse, refs, streamIn, reques
|
|
1295
1302
|
let registeredText = `This error came from the "onStart" callback registered here:`;
|
1296
1303
|
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onStart");
|
1297
1304
|
onStartCallbacks.push({ name, callback, note: registeredNote });
|
1305
|
+
plugin.onStart = true;
|
1298
1306
|
},
|
1299
1307
|
onEnd(callback) {
|
1300
1308
|
let registeredText = `This error came from the "onEnd" callback registered here:`;
|
1301
1309
|
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onEnd");
|
1302
1310
|
onEndCallbacks.push({ name, callback, note: registeredNote });
|
1311
|
+
plugin.onEnd = true;
|
1303
1312
|
},
|
1304
1313
|
onResolve(options, callback) {
|
1305
1314
|
let registeredText = `This error came from the "onResolve" callback registered here:`;
|
@@ -1700,7 +1709,7 @@ function convertOutputFiles({ path, contents }) {
|
|
1700
1709
|
}
|
1701
1710
|
|
1702
1711
|
// lib/npm/browser.ts
|
1703
|
-
var version = "0.16.
|
1712
|
+
var version = "0.16.17";
|
1704
1713
|
var build = (options) => ensureServiceIsRunning().build(options);
|
1705
1714
|
var serve = () => {
|
1706
1715
|
throw new Error(`The "serve" API only works in node`);
|
@@ -1747,7 +1756,7 @@ var initialize = (options) => {
|
|
1747
1756
|
var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, null, function* () {
|
1748
1757
|
let worker;
|
1749
1758
|
if (useWorker) {
|
1750
|
-
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 () => {\n this._resume();\n while (this._scheduledTimeouts.has(id)) {\n console.warn("scheduleTimeoutEvent: missed timeout event");\n this._resume();\n }\n },\n getInt64(sp + 8) + 1\n ));\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.16.3"}`];\n tryToInstantiateModule(wasm, go).then(\n (instance) => {\n postMessage(null);\n go.run(instance);\n },\n (error) => {\n postMessage(error);\n }\n );\n };\n function tryToInstantiateModule(wasm, go) {\n return __async(this, null, function* () {\n if (wasm instanceof WebAssembly.Module) {\n return WebAssembly.instantiate(wasm, go.importObject);\n }\n const res = yield fetch(wasm);\n if (!res.ok)\n throw new Error(`Failed to download ${JSON.stringify(wasm)}`);\n if ("instantiateStreaming" in WebAssembly && /^application\\/wasm($|;)/i.test(res.headers.get("Content-Type") || "")) {\n const result2 = yield WebAssembly.instantiateStreaming(res, go.importObject);\n return result2.instance;\n }\n const bytes = yield res.arrayBuffer();\n const result = yield WebAssembly.instantiate(bytes, go.importObject);\n return result.instance;\n });\n }\n return (m) => onmessage(m);\n })'}(postMessage)`], { type: "text/javascript" });
|
1759
|
+
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 // unused\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 // Go\'s SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)\n // may synchronously trigger a Go event handler. This makes Go code get executed in the middle of the imported\n // function. A goroutine can switch to a new stack if the current stack is too small (see morestack function).\n // This changes the SP, thus we have to update the SP used by the imported function.\n // func wasmExit(code int32)\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 // func wasmWrite(fd uintptr, p unsafe.Pointer, n int32)\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 // func resetMemoryDataView()\n "runtime.resetMemoryDataView": (sp) => {\n sp >>>= 0;\n this.mem = new DataView(this._inst.exports.mem.buffer);\n },\n // func nanotime1() int64\n "runtime.nanotime1": (sp) => {\n sp >>>= 0;\n setInt64(sp + 8, (timeOrigin + performance.now()) * 1e6);\n },\n // func walltime() (sec int64, nsec int32)\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 // func scheduleTimeoutEvent(delay int64) int32\n "runtime.scheduleTimeoutEvent": (sp) => {\n sp >>>= 0;\n const id = this._nextCallbackTimeoutID;\n this._nextCallbackTimeoutID++;\n this._scheduledTimeouts.set(id, setTimeout(\n () => {\n this._resume();\n while (this._scheduledTimeouts.has(id)) {\n console.warn("scheduleTimeoutEvent: missed timeout event");\n this._resume();\n }\n },\n getInt64(sp + 8) + 1\n // setTimeout has been seen to fire up to 1 millisecond early\n ));\n this.mem.setInt32(sp + 16, id, true);\n },\n // func clearTimeoutEvent(id int32)\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 // func getRandomData(r []byte)\n "runtime.getRandomData": (sp) => {\n sp >>>= 0;\n crypto.getRandomValues(loadSlice(sp + 8));\n },\n // func finalizeRef(v ref)\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 // func stringVal(value string) ref\n "syscall/js.stringVal": (sp) => {\n sp >>>= 0;\n storeValue(sp + 24, loadString(sp + 8));\n },\n // func valueGet(v ref, p string) ref\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 // func valueSet(v ref, p string, x ref)\n "syscall/js.valueSet": (sp) => {\n sp >>>= 0;\n Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));\n },\n // func valueDelete(v ref, p string)\n "syscall/js.valueDelete": (sp) => {\n sp >>>= 0;\n Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));\n },\n // func valueIndex(v ref, i int) ref\n "syscall/js.valueIndex": (sp) => {\n sp >>>= 0;\n storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));\n },\n // valueSetIndex(v ref, i int, x ref)\n "syscall/js.valueSetIndex": (sp) => {\n sp >>>= 0;\n Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));\n },\n // func valueCall(v ref, m string, args []ref) (ref, bool)\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 // func valueInvoke(v ref, args []ref) (ref, bool)\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 // func valueNew(v ref, args []ref) (ref, bool)\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 // func valueLength(v ref) int\n "syscall/js.valueLength": (sp) => {\n sp >>>= 0;\n setInt64(sp + 16, parseInt(loadValue(sp + 8).length));\n },\n // valuePrepareString(v ref) (ref, int)\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 // valueLoadString(v ref, b []byte)\n "syscall/js.valueLoadString": (sp) => {\n sp >>>= 0;\n const str = loadValue(sp + 8);\n loadSlice(sp + 16).set(str);\n },\n // func valueInstanceOf(v ref, t ref) bool\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 // func copyBytesToGo(dst []byte, src ref) (int, bool)\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 // func copyBytesToJS(dst ref, src []byte) (int, bool)\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 // JS values that Go currently has references to, indexed by reference id\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 // mapping from JS values to reference ids\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.16.17"}`];\n tryToInstantiateModule(wasm, go).then(\n (instance) => {\n postMessage(null);\n go.run(instance);\n },\n (error) => {\n postMessage(error);\n }\n );\n };\n function tryToInstantiateModule(wasm, go) {\n return __async(this, null, function* () {\n if (wasm instanceof WebAssembly.Module) {\n return WebAssembly.instantiate(wasm, go.importObject);\n }\n const res = yield fetch(wasm);\n if (!res.ok)\n throw new Error(`Failed to download ${JSON.stringify(wasm)}`);\n if ("instantiateStreaming" in WebAssembly && /^application\\/wasm($|;)/i.test(res.headers.get("Content-Type") || "")) {\n const result2 = yield WebAssembly.instantiateStreaming(res, go.importObject);\n return result2.instance;\n }\n const bytes = yield res.arrayBuffer();\n const result = yield WebAssembly.instantiate(bytes, go.importObject);\n return result.instance;\n });\n }\n return (m) => onmessage(m);\n })'}(postMessage)`], { type: "text/javascript" });
|
1751
1760
|
worker = new Worker(URL.createObjectURL(blob));
|
1752
1761
|
} else {
|
1753
1762
|
let onmessage = ((postMessage) => {
|
@@ -1791,6 +1800,7 @@ var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, nu
|
|
1791
1800
|
let outputBuf = "";
|
1792
1801
|
globalThis.fs = {
|
1793
1802
|
constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 },
|
1803
|
+
// unused
|
1794
1804
|
writeSync(fd, buf) {
|
1795
1805
|
outputBuf += decoder.decode(buf);
|
1796
1806
|
const nl = outputBuf.lastIndexOf("\n");
|
@@ -2026,6 +2036,11 @@ var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, nu
|
|
2026
2036
|
const timeOrigin = Date.now() - performance.now();
|
2027
2037
|
this.importObject = {
|
2028
2038
|
go: {
|
2039
|
+
// Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)
|
2040
|
+
// may synchronously trigger a Go event handler. This makes Go code get executed in the middle of the imported
|
2041
|
+
// function. A goroutine can switch to a new stack if the current stack is too small (see morestack function).
|
2042
|
+
// This changes the SP, thus we have to update the SP used by the imported function.
|
2043
|
+
// func wasmExit(code int32)
|
2029
2044
|
"runtime.wasmExit": (sp) => {
|
2030
2045
|
sp >>>= 0;
|
2031
2046
|
const code = this.mem.getInt32(sp + 8, true);
|
@@ -2037,6 +2052,7 @@ var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, nu
|
|
2037
2052
|
delete this._idPool;
|
2038
2053
|
this.exit(code);
|
2039
2054
|
},
|
2055
|
+
// func wasmWrite(fd uintptr, p unsafe.Pointer, n int32)
|
2040
2056
|
"runtime.wasmWrite": (sp) => {
|
2041
2057
|
sp >>>= 0;
|
2042
2058
|
const fd = getInt64(sp + 8);
|
@@ -2044,20 +2060,24 @@ var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, nu
|
|
2044
2060
|
const n = this.mem.getInt32(sp + 24, true);
|
2045
2061
|
globalThis.fs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));
|
2046
2062
|
},
|
2063
|
+
// func resetMemoryDataView()
|
2047
2064
|
"runtime.resetMemoryDataView": (sp) => {
|
2048
2065
|
sp >>>= 0;
|
2049
2066
|
this.mem = new DataView(this._inst.exports.mem.buffer);
|
2050
2067
|
},
|
2068
|
+
// func nanotime1() int64
|
2051
2069
|
"runtime.nanotime1": (sp) => {
|
2052
2070
|
sp >>>= 0;
|
2053
2071
|
setInt64(sp + 8, (timeOrigin + performance.now()) * 1e6);
|
2054
2072
|
},
|
2073
|
+
// func walltime() (sec int64, nsec int32)
|
2055
2074
|
"runtime.walltime": (sp) => {
|
2056
2075
|
sp >>>= 0;
|
2057
2076
|
const msec = new Date().getTime();
|
2058
2077
|
setInt64(sp + 8, msec / 1e3);
|
2059
2078
|
this.mem.setInt32(sp + 16, msec % 1e3 * 1e6, true);
|
2060
2079
|
},
|
2080
|
+
// func scheduleTimeoutEvent(delay int64) int32
|
2061
2081
|
"runtime.scheduleTimeoutEvent": (sp) => {
|
2062
2082
|
sp >>>= 0;
|
2063
2083
|
const id = this._nextCallbackTimeoutID;
|
@@ -2071,19 +2091,23 @@ var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, nu
|
|
2071
2091
|
}
|
2072
2092
|
},
|
2073
2093
|
getInt64(sp + 8) + 1
|
2094
|
+
// setTimeout has been seen to fire up to 1 millisecond early
|
2074
2095
|
));
|
2075
2096
|
this.mem.setInt32(sp + 16, id, true);
|
2076
2097
|
},
|
2098
|
+
// func clearTimeoutEvent(id int32)
|
2077
2099
|
"runtime.clearTimeoutEvent": (sp) => {
|
2078
2100
|
sp >>>= 0;
|
2079
2101
|
const id = this.mem.getInt32(sp + 8, true);
|
2080
2102
|
clearTimeout(this._scheduledTimeouts.get(id));
|
2081
2103
|
this._scheduledTimeouts.delete(id);
|
2082
2104
|
},
|
2105
|
+
// func getRandomData(r []byte)
|
2083
2106
|
"runtime.getRandomData": (sp) => {
|
2084
2107
|
sp >>>= 0;
|
2085
2108
|
crypto.getRandomValues(loadSlice(sp + 8));
|
2086
2109
|
},
|
2110
|
+
// func finalizeRef(v ref)
|
2087
2111
|
"syscall/js.finalizeRef": (sp) => {
|
2088
2112
|
sp >>>= 0;
|
2089
2113
|
const id = this.mem.getUint32(sp + 8, true);
|
@@ -2095,32 +2119,39 @@ var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, nu
|
|
2095
2119
|
this._idPool.push(id);
|
2096
2120
|
}
|
2097
2121
|
},
|
2122
|
+
// func stringVal(value string) ref
|
2098
2123
|
"syscall/js.stringVal": (sp) => {
|
2099
2124
|
sp >>>= 0;
|
2100
2125
|
storeValue(sp + 24, loadString(sp + 8));
|
2101
2126
|
},
|
2127
|
+
// func valueGet(v ref, p string) ref
|
2102
2128
|
"syscall/js.valueGet": (sp) => {
|
2103
2129
|
sp >>>= 0;
|
2104
2130
|
const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));
|
2105
2131
|
sp = this._inst.exports.getsp() >>> 0;
|
2106
2132
|
storeValue(sp + 32, result);
|
2107
2133
|
},
|
2134
|
+
// func valueSet(v ref, p string, x ref)
|
2108
2135
|
"syscall/js.valueSet": (sp) => {
|
2109
2136
|
sp >>>= 0;
|
2110
2137
|
Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));
|
2111
2138
|
},
|
2139
|
+
// func valueDelete(v ref, p string)
|
2112
2140
|
"syscall/js.valueDelete": (sp) => {
|
2113
2141
|
sp >>>= 0;
|
2114
2142
|
Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));
|
2115
2143
|
},
|
2144
|
+
// func valueIndex(v ref, i int) ref
|
2116
2145
|
"syscall/js.valueIndex": (sp) => {
|
2117
2146
|
sp >>>= 0;
|
2118
2147
|
storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));
|
2119
2148
|
},
|
2149
|
+
// valueSetIndex(v ref, i int, x ref)
|
2120
2150
|
"syscall/js.valueSetIndex": (sp) => {
|
2121
2151
|
sp >>>= 0;
|
2122
2152
|
Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));
|
2123
2153
|
},
|
2154
|
+
// func valueCall(v ref, m string, args []ref) (ref, bool)
|
2124
2155
|
"syscall/js.valueCall": (sp) => {
|
2125
2156
|
sp >>>= 0;
|
2126
2157
|
try {
|
@@ -2137,6 +2168,7 @@ var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, nu
|
|
2137
2168
|
this.mem.setUint8(sp + 64, 0);
|
2138
2169
|
}
|
2139
2170
|
},
|
2171
|
+
// func valueInvoke(v ref, args []ref) (ref, bool)
|
2140
2172
|
"syscall/js.valueInvoke": (sp) => {
|
2141
2173
|
sp >>>= 0;
|
2142
2174
|
try {
|
@@ -2152,6 +2184,7 @@ var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, nu
|
|
2152
2184
|
this.mem.setUint8(sp + 48, 0);
|
2153
2185
|
}
|
2154
2186
|
},
|
2187
|
+
// func valueNew(v ref, args []ref) (ref, bool)
|
2155
2188
|
"syscall/js.valueNew": (sp) => {
|
2156
2189
|
sp >>>= 0;
|
2157
2190
|
try {
|
@@ -2167,25 +2200,30 @@ var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, nu
|
|
2167
2200
|
this.mem.setUint8(sp + 48, 0);
|
2168
2201
|
}
|
2169
2202
|
},
|
2203
|
+
// func valueLength(v ref) int
|
2170
2204
|
"syscall/js.valueLength": (sp) => {
|
2171
2205
|
sp >>>= 0;
|
2172
2206
|
setInt64(sp + 16, parseInt(loadValue(sp + 8).length));
|
2173
2207
|
},
|
2208
|
+
// valuePrepareString(v ref) (ref, int)
|
2174
2209
|
"syscall/js.valuePrepareString": (sp) => {
|
2175
2210
|
sp >>>= 0;
|
2176
2211
|
const str = encoder.encode(String(loadValue(sp + 8)));
|
2177
2212
|
storeValue(sp + 16, str);
|
2178
2213
|
setInt64(sp + 24, str.length);
|
2179
2214
|
},
|
2215
|
+
// valueLoadString(v ref, b []byte)
|
2180
2216
|
"syscall/js.valueLoadString": (sp) => {
|
2181
2217
|
sp >>>= 0;
|
2182
2218
|
const str = loadValue(sp + 8);
|
2183
2219
|
loadSlice(sp + 16).set(str);
|
2184
2220
|
},
|
2221
|
+
// func valueInstanceOf(v ref, t ref) bool
|
2185
2222
|
"syscall/js.valueInstanceOf": (sp) => {
|
2186
2223
|
sp >>>= 0;
|
2187
2224
|
this.mem.setUint8(sp + 24, loadValue(sp + 8) instanceof loadValue(sp + 16) ? 1 : 0);
|
2188
2225
|
},
|
2226
|
+
// func copyBytesToGo(dst []byte, src ref) (int, bool)
|
2189
2227
|
"syscall/js.copyBytesToGo": (sp) => {
|
2190
2228
|
sp >>>= 0;
|
2191
2229
|
const dst = loadSlice(sp + 8);
|
@@ -2199,6 +2237,7 @@ var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, nu
|
|
2199
2237
|
setInt64(sp + 40, toCopy.length);
|
2200
2238
|
this.mem.setUint8(sp + 48, 1);
|
2201
2239
|
},
|
2240
|
+
// func copyBytesToJS(dst ref, src []byte) (int, bool)
|
2202
2241
|
"syscall/js.copyBytesToJS": (sp) => {
|
2203
2242
|
sp >>>= 0;
|
2204
2243
|
const dst = loadValue(sp + 8);
|
@@ -2226,6 +2265,7 @@ var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, nu
|
|
2226
2265
|
this._inst = instance;
|
2227
2266
|
this.mem = new DataView(this._inst.exports.mem.buffer);
|
2228
2267
|
this._values = [
|
2268
|
+
// JS values that Go currently has references to, indexed by reference id
|
2229
2269
|
NaN,
|
2230
2270
|
0,
|
2231
2271
|
null,
|
@@ -2236,6 +2276,7 @@ var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, nu
|
|
2236
2276
|
];
|
2237
2277
|
this._goRefCounts = new Array(this._values.length).fill(Infinity);
|
2238
2278
|
this._ids = /* @__PURE__ */ new Map([
|
2279
|
+
// mapping from JS values to reference ids
|
2239
2280
|
[0, 1],
|
2240
2281
|
[null, 2],
|
2241
2282
|
[true, 3],
|
@@ -2351,7 +2392,7 @@ var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, nu
|
|
2351
2392
|
callback(null, count);
|
2352
2393
|
};
|
2353
2394
|
let go = new globalThis.Go();
|
2354
|
-
go.argv = ["", `--service=${"0.16.
|
2395
|
+
go.argv = ["", `--service=${"0.16.17"}`];
|
2355
2396
|
tryToInstantiateModule(wasm, go).then(
|
2356
2397
|
(instance) => {
|
2357
2398
|
postMessage(null);
|