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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ba7a9e3f549c45e94c1843118acee540a120fbd8e7b444187c051abcb5cd463
|
4
|
+
data.tar.gz: 17590b773c609fe082d52305b0b3f6c6c808c05d3ac1b537de19e8c70c056b2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fec9e9900ade23a59d9026c81c22e6ff92b26d6660c38340c3aa18ed7ad362403696f74124218e321b4a7d4470e821c4163bc601793da5879efd4912f9703f85
|
7
|
+
data.tar.gz: 6bd157d8354b7ad5117eaa7731ef7fb88a8626f787b0a4267e26cddb10436e4708fe6821f46f90c8cc622f0fc6abe51c3975060b0ffe04748c22cfe823d4b2ef
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
Convenient and well performing on demand asset bundling for the isomorfeus framework project, internally using esbuild (esbuild-wasm).
|
8
8
|
|
9
|
-
Version follows esbuild version: 0.
|
9
|
+
Version follows esbuild version: 0.16.x comes with esbuild 0.16.y.
|
10
10
|
|
11
11
|
No need to install esbuild separately, everything bundled ready to go.
|
12
12
|
However, if within the project the 'esbuild' npm package is installed in node_modules, that version will be used instead.
|
@@ -15,5 +15,4 @@ However, if within the project the 'esbuild' npm package is installed in node_mo
|
|
15
15
|
At the [Isomorfeus Framework Project](https://isomorfeus.com)
|
16
16
|
|
17
17
|
### Targets
|
18
|
-
By default bundles for browsers using the 'es6' target of esbuild.
|
19
|
-
By default bundles for node using the 'node16' target of esbuild.
|
18
|
+
By default Isomorfeus Asset Manager bundles for browsers using the 'es6' target and for node using the 'node16' target of esbuild.
|
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "isomorfeus-asset-manager",
|
3
|
-
"lockfileVersion":
|
3
|
+
"lockfileVersion": 3,
|
4
4
|
"requires": true,
|
5
5
|
"packages": {
|
6
6
|
"node_modules/esbuild-wasm": {
|
7
|
-
"version": "0.16.
|
8
|
-
"resolved": "https://registry.npmjs.org/esbuild-wasm/-/esbuild-wasm-0.16.
|
9
|
-
"integrity": "sha512-
|
7
|
+
"version": "0.16.17",
|
8
|
+
"resolved": "https://registry.npmjs.org/esbuild-wasm/-/esbuild-wasm-0.16.17.tgz",
|
9
|
+
"integrity": "sha512-Tn7NuMqRcM+T/qCOxbQRq0qrwWl1sUWp6ARfJRakE8Bepew6zata4qrKgH2YqovNC5e/2fcTa7o+VL/FAOZC1Q==",
|
10
10
|
"bin": {
|
11
11
|
"esbuild": "bin/esbuild"
|
12
12
|
},
|
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
1
|
export type Platform = 'browser' | 'node' | 'neutral';
|
2
2
|
export type Format = 'iife' | 'cjs' | 'esm';
|
3
|
-
export type Loader = '
|
3
|
+
export type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'text' | 'ts' | 'tsx';
|
4
4
|
export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent';
|
5
5
|
export type Charset = 'ascii' | 'utf8';
|
6
6
|
export type Drop = 'console' | 'debugger';
|
@@ -98,6 +98,8 @@ export interface BuildOptions extends CommonOptions {
|
|
98
98
|
outbase?: string;
|
99
99
|
/** Documentation: https://esbuild.github.io/api/#external */
|
100
100
|
external?: string[];
|
101
|
+
/** Documentation: https://esbuild.github.io/api/#packages */
|
102
|
+
packages?: 'external';
|
101
103
|
/** Documentation: https://esbuild.github.io/api/#alias */
|
102
104
|
alias?: Record<string, string>;
|
103
105
|
/** Documentation: https://esbuild.github.io/api/#loader */
|
@@ -194,7 +196,7 @@ export interface OutputFile {
|
|
194
196
|
/** "text" as bytes */
|
195
197
|
contents: Uint8Array;
|
196
198
|
/** "contents" as text (changes automatically with "contents") */
|
197
|
-
|
199
|
+
readonly text: string;
|
198
200
|
}
|
199
201
|
|
200
202
|
export interface BuildInvalidate {
|
@@ -278,6 +280,8 @@ export interface TransformResult {
|
|
278
280
|
warnings: Message[];
|
279
281
|
/** Only when "mangleCache" is present */
|
280
282
|
mangleCache?: Record<string, string | false>;
|
283
|
+
/** Only when "legalComments" is "external" */
|
284
|
+
legalComments?: string;
|
281
285
|
}
|
282
286
|
|
283
287
|
export interface TransformFailure extends Error {
|
@@ -437,7 +441,10 @@ export interface Metafile {
|
|
437
441
|
imports: {
|
438
442
|
path: string
|
439
443
|
kind: ImportKind
|
444
|
+
external?: boolean
|
445
|
+
original?: string
|
440
446
|
}[]
|
447
|
+
format?: 'cjs' | 'esm'
|
441
448
|
}
|
442
449
|
}
|
443
450
|
outputs: {
|
@@ -450,7 +457,8 @@ export interface Metafile {
|
|
450
457
|
}
|
451
458
|
imports: {
|
452
459
|
path: string
|
453
|
-
kind: ImportKind
|
460
|
+
kind: ImportKind | 'file-loader'
|
461
|
+
external?: boolean
|
454
462
|
}[]
|
455
463
|
exports: string[]
|
456
464
|
entryPoint?: string
|
@@ -415,6 +415,7 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
415
415
|
let mainFields = getFlag(options, keys, "mainFields", mustBeArray);
|
416
416
|
let conditions = getFlag(options, keys, "conditions", mustBeArray);
|
417
417
|
let external = getFlag(options, keys, "external", mustBeArray);
|
418
|
+
let packages = getFlag(options, keys, "packages", mustBeString);
|
418
419
|
let alias = getFlag(options, keys, "alias", mustBeObject);
|
419
420
|
let loader = getFlag(options, keys, "loader", mustBeObject);
|
420
421
|
let outExtension = getFlag(options, keys, "outExtension", mustBeObject);
|
@@ -465,6 +466,8 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
465
466
|
flags.push(`--outbase=${outbase}`);
|
466
467
|
if (tsconfig)
|
467
468
|
flags.push(`--tsconfig=${tsconfig}`);
|
469
|
+
if (packages)
|
470
|
+
flags.push(`--packages=${packages}`);
|
468
471
|
if (resolveExtensions) {
|
469
472
|
let values = [];
|
470
473
|
for (let value of resolveExtensions) {
|
@@ -712,8 +715,8 @@ function createChannel(streamIn) {
|
|
712
715
|
if (isFirstPacket) {
|
713
716
|
isFirstPacket = false;
|
714
717
|
let binaryVersion = String.fromCharCode(...bytes);
|
715
|
-
if (binaryVersion !== "0.16.
|
716
|
-
throw new Error(`Cannot start service: Host version "${"0.16.
|
718
|
+
if (binaryVersion !== "0.16.17") {
|
719
|
+
throw new Error(`Cannot start service: Host version "${"0.16.17"}" does not match binary version ${quote(binaryVersion)}`);
|
717
720
|
}
|
718
721
|
return;
|
719
722
|
}
|
@@ -799,6 +802,8 @@ function createChannel(streamIn) {
|
|
799
802
|
let next = () => {
|
800
803
|
if (--outstanding === 0) {
|
801
804
|
let result = { warnings, code: response.code, map: response.map };
|
805
|
+
if ("legalComments" in response)
|
806
|
+
result.legalComments = response == null ? void 0 : response.legalComments;
|
802
807
|
if (response.mangleCache)
|
803
808
|
result.mangleCache = response == null ? void 0 : response.mangleCache;
|
804
809
|
callback(null, result);
|
@@ -1198,6 +1203,8 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
1198
1203
|
checkForInvalidFlags(item, keys, `on plugin ${quote(name)}`);
|
1199
1204
|
let plugin = {
|
1200
1205
|
name,
|
1206
|
+
onStart: false,
|
1207
|
+
onEnd: false,
|
1201
1208
|
onResolve: [],
|
1202
1209
|
onLoad: []
|
1203
1210
|
};
|
@@ -1260,11 +1267,13 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
1260
1267
|
let registeredText = `This error came from the "onStart" callback registered here:`;
|
1261
1268
|
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onStart");
|
1262
1269
|
onStartCallbacks.push({ name, callback, note: registeredNote });
|
1270
|
+
plugin.onStart = true;
|
1263
1271
|
},
|
1264
1272
|
onEnd(callback) {
|
1265
1273
|
let registeredText = `This error came from the "onEnd" callback registered here:`;
|
1266
1274
|
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onEnd");
|
1267
1275
|
onEndCallbacks.push({ name, callback, note: registeredNote });
|
1276
|
+
plugin.onEnd = true;
|
1268
1277
|
},
|
1269
1278
|
onResolve(options, callback) {
|
1270
1279
|
let registeredText = `This error came from the "onResolve" callback registered here:`;
|
@@ -1665,7 +1674,7 @@ function convertOutputFiles({ path, contents }) {
|
|
1665
1674
|
}
|
1666
1675
|
|
1667
1676
|
// lib/npm/browser.ts
|
1668
|
-
var version = "0.16.
|
1677
|
+
var version = "0.16.17";
|
1669
1678
|
var build = (options) => ensureServiceIsRunning().build(options);
|
1670
1679
|
var serve = () => {
|
1671
1680
|
throw new Error(`The "serve" API only works in node`);
|
@@ -1712,7 +1721,7 @@ var initialize = (options) => {
|
|
1712
1721
|
var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
1713
1722
|
let worker;
|
1714
1723
|
if (useWorker) {
|
1715
|
-
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 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 async run(instance) {\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 await this._exitPromise;\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 async function tryToInstantiateModule(wasm, go) {\n if (wasm instanceof WebAssembly.Module) {\n return WebAssembly.instantiate(wasm, go.importObject);\n }\n const res = await 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 = await WebAssembly.instantiateStreaming(res, go.importObject);\n return result2.instance;\n }\n const bytes = await res.arrayBuffer();\n const result = await WebAssembly.instantiate(bytes, go.importObject);\n return result.instance;\n }\n return (m) => onmessage(m);\n })'}(postMessage)`], { type: "text/javascript" });
|
1724
|
+
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 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 async run(instance) {\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 await this._exitPromise;\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 async function tryToInstantiateModule(wasm, go) {\n if (wasm instanceof WebAssembly.Module) {\n return WebAssembly.instantiate(wasm, go.importObject);\n }\n const res = await 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 = await WebAssembly.instantiateStreaming(res, go.importObject);\n return result2.instance;\n }\n const bytes = await res.arrayBuffer();\n const result = await WebAssembly.instantiate(bytes, go.importObject);\n return result.instance;\n }\n return (m) => onmessage(m);\n })'}(postMessage)`], { type: "text/javascript" });
|
1716
1725
|
worker = new Worker(URL.createObjectURL(blob));
|
1717
1726
|
} else {
|
1718
1727
|
let onmessage = ((postMessage) => {
|
@@ -1736,6 +1745,7 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
1736
1745
|
let outputBuf = "";
|
1737
1746
|
globalThis.fs = {
|
1738
1747
|
constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 },
|
1748
|
+
// unused
|
1739
1749
|
writeSync(fd, buf) {
|
1740
1750
|
outputBuf += decoder.decode(buf);
|
1741
1751
|
const nl = outputBuf.lastIndexOf("\n");
|
@@ -1971,6 +1981,11 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
1971
1981
|
const timeOrigin = Date.now() - performance.now();
|
1972
1982
|
this.importObject = {
|
1973
1983
|
go: {
|
1984
|
+
// Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)
|
1985
|
+
// may synchronously trigger a Go event handler. This makes Go code get executed in the middle of the imported
|
1986
|
+
// function. A goroutine can switch to a new stack if the current stack is too small (see morestack function).
|
1987
|
+
// This changes the SP, thus we have to update the SP used by the imported function.
|
1988
|
+
// func wasmExit(code int32)
|
1974
1989
|
"runtime.wasmExit": (sp) => {
|
1975
1990
|
sp >>>= 0;
|
1976
1991
|
const code = this.mem.getInt32(sp + 8, true);
|
@@ -1982,6 +1997,7 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
1982
1997
|
delete this._idPool;
|
1983
1998
|
this.exit(code);
|
1984
1999
|
},
|
2000
|
+
// func wasmWrite(fd uintptr, p unsafe.Pointer, n int32)
|
1985
2001
|
"runtime.wasmWrite": (sp) => {
|
1986
2002
|
sp >>>= 0;
|
1987
2003
|
const fd = getInt64(sp + 8);
|
@@ -1989,20 +2005,24 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
1989
2005
|
const n = this.mem.getInt32(sp + 24, true);
|
1990
2006
|
globalThis.fs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));
|
1991
2007
|
},
|
2008
|
+
// func resetMemoryDataView()
|
1992
2009
|
"runtime.resetMemoryDataView": (sp) => {
|
1993
2010
|
sp >>>= 0;
|
1994
2011
|
this.mem = new DataView(this._inst.exports.mem.buffer);
|
1995
2012
|
},
|
2013
|
+
// func nanotime1() int64
|
1996
2014
|
"runtime.nanotime1": (sp) => {
|
1997
2015
|
sp >>>= 0;
|
1998
2016
|
setInt64(sp + 8, (timeOrigin + performance.now()) * 1e6);
|
1999
2017
|
},
|
2018
|
+
// func walltime() (sec int64, nsec int32)
|
2000
2019
|
"runtime.walltime": (sp) => {
|
2001
2020
|
sp >>>= 0;
|
2002
2021
|
const msec = new Date().getTime();
|
2003
2022
|
setInt64(sp + 8, msec / 1e3);
|
2004
2023
|
this.mem.setInt32(sp + 16, msec % 1e3 * 1e6, true);
|
2005
2024
|
},
|
2025
|
+
// func scheduleTimeoutEvent(delay int64) int32
|
2006
2026
|
"runtime.scheduleTimeoutEvent": (sp) => {
|
2007
2027
|
sp >>>= 0;
|
2008
2028
|
const id = this._nextCallbackTimeoutID;
|
@@ -2016,19 +2036,23 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
2016
2036
|
}
|
2017
2037
|
},
|
2018
2038
|
getInt64(sp + 8) + 1
|
2039
|
+
// setTimeout has been seen to fire up to 1 millisecond early
|
2019
2040
|
));
|
2020
2041
|
this.mem.setInt32(sp + 16, id, true);
|
2021
2042
|
},
|
2043
|
+
// func clearTimeoutEvent(id int32)
|
2022
2044
|
"runtime.clearTimeoutEvent": (sp) => {
|
2023
2045
|
sp >>>= 0;
|
2024
2046
|
const id = this.mem.getInt32(sp + 8, true);
|
2025
2047
|
clearTimeout(this._scheduledTimeouts.get(id));
|
2026
2048
|
this._scheduledTimeouts.delete(id);
|
2027
2049
|
},
|
2050
|
+
// func getRandomData(r []byte)
|
2028
2051
|
"runtime.getRandomData": (sp) => {
|
2029
2052
|
sp >>>= 0;
|
2030
2053
|
crypto.getRandomValues(loadSlice(sp + 8));
|
2031
2054
|
},
|
2055
|
+
// func finalizeRef(v ref)
|
2032
2056
|
"syscall/js.finalizeRef": (sp) => {
|
2033
2057
|
sp >>>= 0;
|
2034
2058
|
const id = this.mem.getUint32(sp + 8, true);
|
@@ -2040,32 +2064,39 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
2040
2064
|
this._idPool.push(id);
|
2041
2065
|
}
|
2042
2066
|
},
|
2067
|
+
// func stringVal(value string) ref
|
2043
2068
|
"syscall/js.stringVal": (sp) => {
|
2044
2069
|
sp >>>= 0;
|
2045
2070
|
storeValue(sp + 24, loadString(sp + 8));
|
2046
2071
|
},
|
2072
|
+
// func valueGet(v ref, p string) ref
|
2047
2073
|
"syscall/js.valueGet": (sp) => {
|
2048
2074
|
sp >>>= 0;
|
2049
2075
|
const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));
|
2050
2076
|
sp = this._inst.exports.getsp() >>> 0;
|
2051
2077
|
storeValue(sp + 32, result);
|
2052
2078
|
},
|
2079
|
+
// func valueSet(v ref, p string, x ref)
|
2053
2080
|
"syscall/js.valueSet": (sp) => {
|
2054
2081
|
sp >>>= 0;
|
2055
2082
|
Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));
|
2056
2083
|
},
|
2084
|
+
// func valueDelete(v ref, p string)
|
2057
2085
|
"syscall/js.valueDelete": (sp) => {
|
2058
2086
|
sp >>>= 0;
|
2059
2087
|
Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));
|
2060
2088
|
},
|
2089
|
+
// func valueIndex(v ref, i int) ref
|
2061
2090
|
"syscall/js.valueIndex": (sp) => {
|
2062
2091
|
sp >>>= 0;
|
2063
2092
|
storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));
|
2064
2093
|
},
|
2094
|
+
// valueSetIndex(v ref, i int, x ref)
|
2065
2095
|
"syscall/js.valueSetIndex": (sp) => {
|
2066
2096
|
sp >>>= 0;
|
2067
2097
|
Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));
|
2068
2098
|
},
|
2099
|
+
// func valueCall(v ref, m string, args []ref) (ref, bool)
|
2069
2100
|
"syscall/js.valueCall": (sp) => {
|
2070
2101
|
sp >>>= 0;
|
2071
2102
|
try {
|
@@ -2082,6 +2113,7 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
2082
2113
|
this.mem.setUint8(sp + 64, 0);
|
2083
2114
|
}
|
2084
2115
|
},
|
2116
|
+
// func valueInvoke(v ref, args []ref) (ref, bool)
|
2085
2117
|
"syscall/js.valueInvoke": (sp) => {
|
2086
2118
|
sp >>>= 0;
|
2087
2119
|
try {
|
@@ -2097,6 +2129,7 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
2097
2129
|
this.mem.setUint8(sp + 48, 0);
|
2098
2130
|
}
|
2099
2131
|
},
|
2132
|
+
// func valueNew(v ref, args []ref) (ref, bool)
|
2100
2133
|
"syscall/js.valueNew": (sp) => {
|
2101
2134
|
sp >>>= 0;
|
2102
2135
|
try {
|
@@ -2112,25 +2145,30 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
2112
2145
|
this.mem.setUint8(sp + 48, 0);
|
2113
2146
|
}
|
2114
2147
|
},
|
2148
|
+
// func valueLength(v ref) int
|
2115
2149
|
"syscall/js.valueLength": (sp) => {
|
2116
2150
|
sp >>>= 0;
|
2117
2151
|
setInt64(sp + 16, parseInt(loadValue(sp + 8).length));
|
2118
2152
|
},
|
2153
|
+
// valuePrepareString(v ref) (ref, int)
|
2119
2154
|
"syscall/js.valuePrepareString": (sp) => {
|
2120
2155
|
sp >>>= 0;
|
2121
2156
|
const str = encoder.encode(String(loadValue(sp + 8)));
|
2122
2157
|
storeValue(sp + 16, str);
|
2123
2158
|
setInt64(sp + 24, str.length);
|
2124
2159
|
},
|
2160
|
+
// valueLoadString(v ref, b []byte)
|
2125
2161
|
"syscall/js.valueLoadString": (sp) => {
|
2126
2162
|
sp >>>= 0;
|
2127
2163
|
const str = loadValue(sp + 8);
|
2128
2164
|
loadSlice(sp + 16).set(str);
|
2129
2165
|
},
|
2166
|
+
// func valueInstanceOf(v ref, t ref) bool
|
2130
2167
|
"syscall/js.valueInstanceOf": (sp) => {
|
2131
2168
|
sp >>>= 0;
|
2132
2169
|
this.mem.setUint8(sp + 24, loadValue(sp + 8) instanceof loadValue(sp + 16) ? 1 : 0);
|
2133
2170
|
},
|
2171
|
+
// func copyBytesToGo(dst []byte, src ref) (int, bool)
|
2134
2172
|
"syscall/js.copyBytesToGo": (sp) => {
|
2135
2173
|
sp >>>= 0;
|
2136
2174
|
const dst = loadSlice(sp + 8);
|
@@ -2144,6 +2182,7 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
2144
2182
|
setInt64(sp + 40, toCopy.length);
|
2145
2183
|
this.mem.setUint8(sp + 48, 1);
|
2146
2184
|
},
|
2185
|
+
// func copyBytesToJS(dst ref, src []byte) (int, bool)
|
2147
2186
|
"syscall/js.copyBytesToJS": (sp) => {
|
2148
2187
|
sp >>>= 0;
|
2149
2188
|
const dst = loadValue(sp + 8);
|
@@ -2170,6 +2209,7 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
2170
2209
|
this._inst = instance;
|
2171
2210
|
this.mem = new DataView(this._inst.exports.mem.buffer);
|
2172
2211
|
this._values = [
|
2212
|
+
// JS values that Go currently has references to, indexed by reference id
|
2173
2213
|
NaN,
|
2174
2214
|
0,
|
2175
2215
|
null,
|
@@ -2180,6 +2220,7 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
2180
2220
|
];
|
2181
2221
|
this._goRefCounts = new Array(this._values.length).fill(Infinity);
|
2182
2222
|
this._ids = /* @__PURE__ */ new Map([
|
2223
|
+
// mapping from JS values to reference ids
|
2183
2224
|
[0, 1],
|
2184
2225
|
[null, 2],
|
2185
2226
|
[true, 3],
|
@@ -2294,7 +2335,7 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
2294
2335
|
callback(null, count);
|
2295
2336
|
};
|
2296
2337
|
let go = new globalThis.Go();
|
2297
|
-
go.argv = ["", `--service=${"0.16.
|
2338
|
+
go.argv = ["", `--service=${"0.16.17"}`];
|
2298
2339
|
tryToInstantiateModule(wasm, go).then(
|
2299
2340
|
(instance) => {
|
2300
2341
|
postMessage(null);
|