esbuild-wasm-strapkit 0.17.1-build.3 → 0.17.2-build.3
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.
- package/esbuild.wasm +0 -0
- package/esm/browser.d.ts +4 -1
- package/esm/browser.js +26 -10
- package/esm/browser.min.js +8 -8
- package/lib/browser.d.ts +4 -1
- package/lib/browser.js +26 -10
- package/lib/browser.min.js +9 -9
- package/lib/main.d.ts +4 -1
- package/lib/main.js +28 -12
- package/package.json +3 -3
package/esbuild.wasm
CHANGED
|
Binary file
|
package/esm/browser.d.ts
CHANGED
|
@@ -296,6 +296,9 @@ export interface PluginBuild {
|
|
|
296
296
|
onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) =>
|
|
297
297
|
(OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void
|
|
298
298
|
|
|
299
|
+
/** Documentation: https://esbuild.github.io/plugins/#on-dispose */
|
|
300
|
+
onDispose(callback: () => void): void
|
|
301
|
+
|
|
299
302
|
// This is a full copy of the esbuild library in case you need it
|
|
300
303
|
esbuild: {
|
|
301
304
|
context: typeof context,
|
|
@@ -489,7 +492,7 @@ export interface BuildContext<SpecificOptions extends BuildOptions = BuildOption
|
|
|
489
492
|
rebuild(): Promise<BuildResult<SpecificOptions>>
|
|
490
493
|
|
|
491
494
|
/** Documentation: https://esbuild.github.io/api/#watch */
|
|
492
|
-
watch(options?: WatchOptions): void
|
|
495
|
+
watch(options?: WatchOptions): Promise<void>
|
|
493
496
|
|
|
494
497
|
/** Documentation: https://esbuild.github.io/api/#serve */
|
|
495
498
|
serve(options?: ServeOptions): Promise<ServeResult>
|
package/esm/browser.js
CHANGED
|
@@ -711,8 +711,8 @@ function createChannel(streamIn) {
|
|
|
711
711
|
if (isFirstPacket) {
|
|
712
712
|
isFirstPacket = false;
|
|
713
713
|
let binaryVersion = String.fromCharCode(...bytes);
|
|
714
|
-
if (binaryVersion !== "0.17.
|
|
715
|
-
throw new Error(`Cannot start service: Host version "${"0.17.
|
|
714
|
+
if (binaryVersion !== "0.17.2") {
|
|
715
|
+
throw new Error(`Cannot start service: Host version "${"0.17.2"}" does not match binary version ${quote(binaryVersion)}`);
|
|
716
716
|
}
|
|
717
717
|
return;
|
|
718
718
|
}
|
|
@@ -956,7 +956,7 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
|
|
|
956
956
|
if (!result.ok)
|
|
957
957
|
return handleError(result.error, result.pluginName);
|
|
958
958
|
try {
|
|
959
|
-
buildOrContextContinue(result.requestPlugins, result.runOnEndCallbacks);
|
|
959
|
+
buildOrContextContinue(result.requestPlugins, result.runOnEndCallbacks, result.scheduleOnDisposeCallbacks);
|
|
960
960
|
} catch (e) {
|
|
961
961
|
handleError(e, "");
|
|
962
962
|
}
|
|
@@ -966,11 +966,12 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
|
|
|
966
966
|
return;
|
|
967
967
|
}
|
|
968
968
|
try {
|
|
969
|
-
buildOrContextContinue(null, (result, done) => done([], []))
|
|
969
|
+
buildOrContextContinue(null, (result, done) => done([], []), () => {
|
|
970
|
+
});
|
|
970
971
|
} catch (e) {
|
|
971
972
|
handleError(e, "");
|
|
972
973
|
}
|
|
973
|
-
function buildOrContextContinue(requestPlugins, runOnEndCallbacks) {
|
|
974
|
+
function buildOrContextContinue(requestPlugins, runOnEndCallbacks, scheduleOnDisposeCallbacks) {
|
|
974
975
|
const writeDefault = streamIn.hasFS;
|
|
975
976
|
const {
|
|
976
977
|
entries,
|
|
@@ -1047,7 +1048,10 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
|
|
|
1047
1048
|
if (error)
|
|
1048
1049
|
return callback(new Error(error), null);
|
|
1049
1050
|
if (!isContext) {
|
|
1050
|
-
return buildResponseToResult(response,
|
|
1051
|
+
return buildResponseToResult(response, (err, res) => {
|
|
1052
|
+
scheduleOnDisposeCallbacks();
|
|
1053
|
+
return callback(err, res);
|
|
1054
|
+
});
|
|
1051
1055
|
}
|
|
1052
1056
|
if (response.errors.length > 0) {
|
|
1053
1057
|
return callback(failureErrorWithLog("Context failed", response.errors, response.warnings), null);
|
|
@@ -1149,12 +1153,14 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
|
|
|
1149
1153
|
dispose: () => new Promise((resolve) => {
|
|
1150
1154
|
if (didDispose)
|
|
1151
1155
|
return resolve();
|
|
1156
|
+
didDispose = true;
|
|
1152
1157
|
const request2 = {
|
|
1153
1158
|
command: "dispose",
|
|
1154
1159
|
key: buildKey
|
|
1155
1160
|
};
|
|
1156
1161
|
sendRequest(refs, request2, () => {
|
|
1157
1162
|
resolve();
|
|
1163
|
+
scheduleOnDisposeCallbacks();
|
|
1158
1164
|
refs.unref();
|
|
1159
1165
|
});
|
|
1160
1166
|
})
|
|
@@ -1169,6 +1175,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
|
1169
1175
|
let onEndCallbacks = [];
|
|
1170
1176
|
let onResolveCallbacks = {};
|
|
1171
1177
|
let onLoadCallbacks = {};
|
|
1178
|
+
let onDisposeCallbacks = [];
|
|
1172
1179
|
let nextCallbackID = 0;
|
|
1173
1180
|
let i = 0;
|
|
1174
1181
|
let requestPlugins = [];
|
|
@@ -1286,6 +1293,9 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
|
1286
1293
|
onLoadCallbacks[id] = { name, callback, note: registeredNote };
|
|
1287
1294
|
plugin.onLoad.push({ id, filter: filter.source, namespace: namespace || "" });
|
|
1288
1295
|
},
|
|
1296
|
+
onDispose(callback) {
|
|
1297
|
+
onDisposeCallbacks.push(callback);
|
|
1298
|
+
},
|
|
1289
1299
|
esbuild: streamIn.esbuild
|
|
1290
1300
|
});
|
|
1291
1301
|
if (promise)
|
|
@@ -1479,11 +1489,17 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
|
1479
1489
|
})();
|
|
1480
1490
|
};
|
|
1481
1491
|
}
|
|
1492
|
+
let scheduleOnDisposeCallbacks = () => {
|
|
1493
|
+
for (const cb of onDisposeCallbacks) {
|
|
1494
|
+
setTimeout(() => cb(), 0);
|
|
1495
|
+
}
|
|
1496
|
+
};
|
|
1482
1497
|
isSetupDone = true;
|
|
1483
1498
|
return {
|
|
1484
1499
|
ok: true,
|
|
1485
1500
|
requestPlugins,
|
|
1486
|
-
runOnEndCallbacks
|
|
1501
|
+
runOnEndCallbacks,
|
|
1502
|
+
scheduleOnDisposeCallbacks
|
|
1487
1503
|
};
|
|
1488
1504
|
};
|
|
1489
1505
|
function createObjectStash() {
|
|
@@ -1690,7 +1706,7 @@ function convertOutputFiles({ path, contents }) {
|
|
|
1690
1706
|
}
|
|
1691
1707
|
|
|
1692
1708
|
// lib/npm/browser.ts
|
|
1693
|
-
var version = "0.17.
|
|
1709
|
+
var version = "0.17.2";
|
|
1694
1710
|
var build = (options) => ensureServiceIsRunning().build(options);
|
|
1695
1711
|
var context = (options) => ensureServiceIsRunning().context(options);
|
|
1696
1712
|
var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
|
|
@@ -1735,7 +1751,7 @@ var initialize = (options) => {
|
|
|
1735
1751
|
var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
1736
1752
|
let worker;
|
|
1737
1753
|
if (useWorker) {
|
|
1738
|
-
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.substring(0, nl));\n outputBuf = outputBuf.substring(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 setInt32 = (addr, v) => {\n this.mem.setUint32(addr + 0, v, 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 _gotest: {\n add: (a, b) => a + b\n },\n gojs: {\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 = Number(sp);\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 = Number(sp);\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 = Number(sp);\n this.mem = new DataView(this._inst.exports.mem.buffer);\n },\n // func nanotime1() int64\n "runtime.nanotime1": (sp) => {\n sp = Number(sp);\n setInt64(sp + 8, (timeOrigin + performance.now()) * 1e6);\n },\n // func walltime() (sec int64, nsec int32)\n "runtime.walltime": (sp) => {\n sp = Number(sp);\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 = Number(sp);\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)\n ));\n this.mem.setInt32(sp + 16, id, true);\n },\n // func clearTimeoutEvent(id int32)\n "runtime.clearTimeoutEvent": (sp) => {\n sp = Number(sp);\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 = Number(sp);\n crypto.getRandomValues(loadSlice(sp + 8));\n },\n // func finalizeRef(v ref)\n "syscall/js.finalizeRef": (sp) => {\n sp = Number(sp);\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 = Number(sp);\n storeValue(sp + 24, loadString(sp + 8));\n },\n // func valueGet(v ref, p string) ref\n "syscall/js.valueGet": (sp) => {\n sp = Number(sp);\n const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));\n sp = Number(this._inst.exports.getsp());\n storeValue(sp + 32, result);\n },\n // func valueSet(v ref, p string, x ref)\n "syscall/js.valueSet": (sp) => {\n sp = Number(sp);\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 = Number(sp);\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 = Number(sp);\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 = Number(sp);\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 = Number(sp);\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 = Number(this._inst.exports.getsp());\n storeValue(sp + 56, result);\n this.mem.setUint8(sp + 64, 1);\n } catch (err) {\n sp = Number(this._inst.exports.getsp());\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 = Number(sp);\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 = Number(this._inst.exports.getsp());\n storeValue(sp + 40, result);\n this.mem.setUint8(sp + 48, 1);\n } catch (err) {\n sp = Number(this._inst.exports.getsp());\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 = Number(sp);\n try {\n const v = loadValue(sp + 8);\n const args = loadSliceOfValues(sp + 16);\n const result = Reflect.construct(v, args);\n sp = Number(this._inst.exports.getsp());\n storeValue(sp + 40, result);\n this.mem.setUint8(sp + 48, 1);\n } catch (err) {\n sp = Number(this._inst.exports.getsp());\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 = Number(sp);\n setInt64(sp + 16, parseInt(loadValue(sp + 8).length));\n },\n // valuePrepareString(v ref) (ref, int)\n "syscall/js.valuePrepareString": (sp) => {\n sp = Number(sp);\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 = Number(sp);\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 = Number(sp);\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 = Number(sp);\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 = Number(sp);\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.17.1"}`];\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" });
|
|
1754
|
+
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.substring(0, nl));\n outputBuf = outputBuf.substring(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 setInt32 = (addr, v) => {\n this.mem.setUint32(addr + 0, v, 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 _gotest: {\n add: (a, b) => a + b\n },\n gojs: {\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 = Number(sp);\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 = Number(sp);\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 = Number(sp);\n this.mem = new DataView(this._inst.exports.mem.buffer);\n },\n // func nanotime1() int64\n "runtime.nanotime1": (sp) => {\n sp = Number(sp);\n setInt64(sp + 8, (timeOrigin + performance.now()) * 1e6);\n },\n // func walltime() (sec int64, nsec int32)\n "runtime.walltime": (sp) => {\n sp = Number(sp);\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 = Number(sp);\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)\n ));\n this.mem.setInt32(sp + 16, id, true);\n },\n // func clearTimeoutEvent(id int32)\n "runtime.clearTimeoutEvent": (sp) => {\n sp = Number(sp);\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 = Number(sp);\n crypto.getRandomValues(loadSlice(sp + 8));\n },\n // func finalizeRef(v ref)\n "syscall/js.finalizeRef": (sp) => {\n sp = Number(sp);\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 = Number(sp);\n storeValue(sp + 24, loadString(sp + 8));\n },\n // func valueGet(v ref, p string) ref\n "syscall/js.valueGet": (sp) => {\n sp = Number(sp);\n const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));\n sp = Number(this._inst.exports.getsp());\n storeValue(sp + 32, result);\n },\n // func valueSet(v ref, p string, x ref)\n "syscall/js.valueSet": (sp) => {\n sp = Number(sp);\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 = Number(sp);\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 = Number(sp);\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 = Number(sp);\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 = Number(sp);\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 = Number(this._inst.exports.getsp());\n storeValue(sp + 56, result);\n this.mem.setUint8(sp + 64, 1);\n } catch (err) {\n sp = Number(this._inst.exports.getsp());\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 = Number(sp);\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 = Number(this._inst.exports.getsp());\n storeValue(sp + 40, result);\n this.mem.setUint8(sp + 48, 1);\n } catch (err) {\n sp = Number(this._inst.exports.getsp());\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 = Number(sp);\n try {\n const v = loadValue(sp + 8);\n const args = loadSliceOfValues(sp + 16);\n const result = Reflect.construct(v, args);\n sp = Number(this._inst.exports.getsp());\n storeValue(sp + 40, result);\n this.mem.setUint8(sp + 48, 1);\n } catch (err) {\n sp = Number(this._inst.exports.getsp());\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 = Number(sp);\n setInt64(sp + 16, parseInt(loadValue(sp + 8).length));\n },\n // valuePrepareString(v ref) (ref, int)\n "syscall/js.valuePrepareString": (sp) => {\n sp = Number(sp);\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 = Number(sp);\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 = Number(sp);\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 = Number(sp);\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 = Number(sp);\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.17.2"}`];\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" });
|
|
1739
1755
|
worker = new Worker(URL.createObjectURL(blob));
|
|
1740
1756
|
} else {
|
|
1741
1757
|
let onmessage = ((postMessage) => {
|
|
@@ -2354,7 +2370,7 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
|
2354
2370
|
callback(null, count);
|
|
2355
2371
|
};
|
|
2356
2372
|
let go = new globalThis.Go();
|
|
2357
|
-
go.argv = ["", `--service=${"0.17.
|
|
2373
|
+
go.argv = ["", `--service=${"0.17.2"}`];
|
|
2358
2374
|
tryToInstantiateModule(wasm, go).then(
|
|
2359
2375
|
(instance) => {
|
|
2360
2376
|
postMessage(null);
|
package/esm/browser.min.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Ie=Object.defineProperty;var We=(e,t)=>{for(var n in t)Ie(e,n,{get:t[n],enumerable:!0})};var be={};We(be,{analyzeMetafile:()=>st,analyzeMetafileSync:()=>ct,build:()=>nt,buildSync:()=>ot,context:()=>rt,default:()=>pt,formatMessages:()=>lt,formatMessagesSync:()=>ut,initialize:()=>ft,transform:()=>it,transformSync:()=>at,version:()=>tt});function xe(e){let t=l=>{if(l===null)n.write8(0);else if(typeof l=="boolean")n.write8(1),n.write8(+l);else if(typeof l=="number")n.write8(2),n.write32(l|0);else if(typeof l=="string")n.write8(3),n.write(Z(l));else if(l instanceof Uint8Array)n.write8(4),n.write(l);else if(l instanceof Array){n.write8(5),n.write32(l.length);for(let f of l)t(f)}else{let f=Object.keys(l);n.write8(6),n.write32(f.length);for(let i of f)n.write(Z(i)),t(l[i])}},n=new de;return n.write32(0),n.write32(e.id<<1|+!e.isRequest),t(e.value),ve(n.buf,n.len-4,0),n.buf.subarray(0,n.len)}function Ee(e){let t=()=>{switch(n.read8()){case 0:return null;case 1:return!!n.read8();case 2:return n.read32();case 3:return re(n.read());case 4:return n.read();case 5:{let d=n.read32(),s=[];for(let y=0;y<d;y++)s.push(t());return s}case 6:{let d=n.read32(),s={};for(let y=0;y<d;y++)s[re(n.read())]=t();return s}default:throw new Error("Invalid packet")}},n=new de(e),l=n.read32(),f=(l&1)===0;l>>>=1;let i=t();if(n.ptr!==e.length)throw new Error("Invalid packet");return{id:l,isRequest:f,value:i}}var de=class{constructor(t=new Uint8Array(1024)){this.buf=t;this.len=0;this.ptr=0}_write(t){if(this.len+t>this.buf.length){let n=new Uint8Array((this.len+t)*2);n.set(this.buf),this.buf=n}return this.len+=t,this.len-t}write8(t){let n=this._write(1);this.buf[n]=t}write32(t){let n=this._write(4);ve(this.buf,t,n)}write(t){let n=this._write(4+t.length);ve(this.buf,t.length,n),this.buf.set(t,n+4)}_read(t){if(this.ptr+t>this.buf.length)throw new Error("Invalid packet");return this.ptr+=t,this.ptr-t}read8(){return this.buf[this._read(1)]}read32(){return Re(this.buf,this._read(4))}read(){let t=this.read32(),n=new Uint8Array(t),l=this._read(n.length);return n.set(this.buf.subarray(l,l+t)),n}},Z,re,we;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;Z=n=>e.encode(n),re=n=>t.decode(n),we='new TextEncoder().encode("")'}else if(typeof Buffer!="undefined")Z=e=>Buffer.from(e),re=e=>{let{buffer:t,byteOffset:n,byteLength:l}=e;return Buffer.from(t,n,l).toString()},we='Buffer.from("")';else throw new Error("No UTF-8 codec found");if(!(Z("")instanceof Uint8Array))throw new Error(`Invariant violation: "${we} instanceof Uint8Array" is incorrectly false
|
|
2
2
|
|
|
3
3
|
This indicates that your JavaScript environment is broken. You cannot use
|
|
4
4
|
esbuild in this environment because esbuild relies on this invariant. This
|
|
5
5
|
is not a problem with esbuild. You need to fix your environment instead.
|
|
6
|
-
`);function Re(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function ve(e,t,n){e[n++]=t,e[n++]=t>>8,e[n++]=t>>16,e[n++]=t>>24}var _=JSON.stringify,Se="warning",ke="silent";function $e(e){if(V(e,"target"),e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var me=()=>null,N=e=>typeof e=="boolean"?null:"a boolean",h=e=>typeof e=="string"?null:"a string",ye=e=>e instanceof RegExp?null:"a RegExp object",le=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Ae=e=>typeof e=="function"?null:"a function",z=e=>Array.isArray(e)?null:"an array",X=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",ze=e=>typeof e=="object"&&e!==null?null:"an array or an object",Ke=e=>e instanceof WebAssembly.Module?null:"a WebAssembly.Module",Me=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",Pe=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",_e=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",Ve=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",Fe=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array",Ye=e=>typeof e=="string"||e instanceof URL?null:"a string or a URL";function r(e,t,n,l){let f=e[n];if(t[n+""]=!0,f===void 0)return;let i=l(f);if(i!==null)throw new Error(`${_(n)} must be ${i}`);return f}function K(e,t,n){for(let l in e)if(!(l in t))throw new Error(`Invalid option ${n}: ${_(l)}`)}function Be(e){let t=Object.create(null),n=r(e,t,"wasmURL",Ye),l=r(e,t,"wasmModule",Ke),f=r(e,t,"worker",N);return K(e,t,"in initialize() call"),{wasmURL:n,wasmModule:l,worker:f}}function Te(e){let t;if(e!==void 0){t=Object.create(null);for(let n in e){let l=e[n];if(typeof l=="string"||l===!1)t[n]=l;else throw new Error(`Expected ${_(n)} in mangle cache to map to either a string or false`)}}return t}function he(e,t,n,l,f){let i=r(t,n,"color",N),d=r(t,n,"logLevel",h),o=r(t,n,"logLimit",le);i!==void 0?e.push(`--color=${i}`):l&&e.push("--color=true"),e.push(`--log-level=${d||f}`),e.push(`--log-limit=${o||0}`)}function V(e,t,n){if(typeof e!="string")throw new Error(`Expected value for ${t}${n!==void 0?" "+_(n):""} to be a string, got ${typeof e} instead`);return e}function De(e,t,n){let l=r(t,n,"legalComments",h),f=r(t,n,"sourceRoot",h),i=r(t,n,"sourcesContent",N),d=r(t,n,"target",Ve),o=r(t,n,"format",h),y=r(t,n,"globalName",h),v=r(t,n,"mangleProps",ye),x=r(t,n,"reserveProps",ye),A=r(t,n,"mangleQuoted",N),U=r(t,n,"minify",N),F=r(t,n,"minifySyntax",N),j=r(t,n,"minifyWhitespace",N),J=r(t,n,"minifyIdentifiers",N),B=r(t,n,"drop",z),I=r(t,n,"charset",h),q=r(t,n,"treeShaking",N),p=r(t,n,"ignoreAnnotations",N),s=r(t,n,"jsx",h),u=r(t,n,"jsxFactory",h),w=r(t,n,"jsxFragment",h),P=r(t,n,"jsxImportSource",h),S=r(t,n,"jsxDev",N),a=r(t,n,"jsxSideEffects",N),c=r(t,n,"define",X),m=r(t,n,"logOverride",X),O=r(t,n,"supported",X),k=r(t,n,"pure",z),M=r(t,n,"keepNames",N),E=r(t,n,"platform",h);if(l&&e.push(`--legal-comments=${l}`),f!==void 0&&e.push(`--source-root=${f}`),i!==void 0&&e.push(`--sources-content=${i}`),d&&(Array.isArray(d)?e.push(`--target=${Array.from(d).map($e).join(",")}`):e.push(`--target=${$e(d)}`)),o&&e.push(`--format=${o}`),y&&e.push(`--global-name=${y}`),E&&e.push(`--platform=${E}`),U&&e.push("--minify"),F&&e.push("--minify-syntax"),j&&e.push("--minify-whitespace"),J&&e.push("--minify-identifiers"),I&&e.push(`--charset=${I}`),q!==void 0&&e.push(`--tree-shaking=${q}`),p&&e.push("--ignore-annotations"),B)for(let b of B)e.push(`--drop:${V(b,"drop")}`);if(v&&e.push(`--mangle-props=${v.source}`),x&&e.push(`--reserve-props=${x.source}`),A!==void 0&&e.push(`--mangle-quoted=${A}`),s&&e.push(`--jsx=${s}`),u&&e.push(`--jsx-factory=${u}`),w&&e.push(`--jsx-fragment=${w}`),P&&e.push(`--jsx-import-source=${P}`),S&&e.push("--jsx-dev"),a&&e.push("--jsx-side-effects"),c)for(let b in c){if(b.indexOf("=")>=0)throw new Error(`Invalid define: ${b}`);e.push(`--define:${b}=${V(c[b],"define",b)}`)}if(m)for(let b in m){if(b.indexOf("=")>=0)throw new Error(`Invalid log override: ${b}`);e.push(`--log-override:${b}=${V(m[b],"log override",b)}`)}if(O)for(let b in O){if(b.indexOf("=")>=0)throw new Error(`Invalid supported: ${b}`);let R=O[b];if(typeof R!="boolean")throw new Error(`Expected value for supported ${_(b)} to be a boolean, got ${typeof R} instead`);e.push(`--supported:${b}=${R}`)}if(k)for(let b of k)e.push(`--pure:${V(b,"pure")}`);M&&e.push("--keep-names")}function Je(e,t,n,l,f){var ae;let i=[],d=[],o=Object.create(null),y=null,v=null;he(i,t,o,n,l),De(i,t,o);let x=r(t,o,"sourcemap",Pe),A=r(t,o,"bundle",N),U=r(t,o,"splitting",N),F=r(t,o,"preserveSymlinks",N),j=r(t,o,"metafile",N),J=r(t,o,"outfile",h),B=r(t,o,"outdir",h),I=r(t,o,"outbase",h),q=r(t,o,"tsconfig",h),p=r(t,o,"resolveExtensions",z),s=r(t,o,"nodePaths",z),u=r(t,o,"mainFields",z),w=r(t,o,"conditions",z),P=r(t,o,"external",z),S=r(t,o,"packages",h),a=r(t,o,"alias",X),c=r(t,o,"loader",X),m=r(t,o,"outExtension",X),O=r(t,o,"publicPath",h),k=r(t,o,"entryNames",h),M=r(t,o,"chunkNames",h),E=r(t,o,"assetNames",h),b=r(t,o,"inject",z),R=r(t,o,"banner",X),W=r(t,o,"footer",X),$=r(t,o,"entryPoints",ze),T=r(t,o,"absWorkingDir",h),D=r(t,o,"stdin",X),C=(ae=r(t,o,"write",N))!=null?ae:f,Q=r(t,o,"allowOverwrite",N),H=r(t,o,"mangleCache",X);if(o.plugins=!0,K(t,o,`in ${e}() call`),x&&i.push(`--sourcemap${x===!0?"":`=${x}`}`),A&&i.push("--bundle"),Q&&i.push("--allow-overwrite"),U&&i.push("--splitting"),F&&i.push("--preserve-symlinks"),j&&i.push("--metafile"),J&&i.push(`--outfile=${J}`),B&&i.push(`--outdir=${B}`),I&&i.push(`--outbase=${I}`),q&&i.push(`--tsconfig=${q}`),S&&i.push(`--packages=${S}`),p){let g=[];for(let L of p){if(V(L,"resolve extension"),L.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${L}`);g.push(L)}i.push(`--resolve-extensions=${g.join(",")}`)}if(O&&i.push(`--public-path=${O}`),k&&i.push(`--entry-names=${k}`),M&&i.push(`--chunk-names=${M}`),E&&i.push(`--asset-names=${E}`),u){let g=[];for(let L of u){if(V(L,"main field"),L.indexOf(",")>=0)throw new Error(`Invalid main field: ${L}`);g.push(L)}i.push(`--main-fields=${g.join(",")}`)}if(w){let g=[];for(let L of w){if(V(L,"condition"),L.indexOf(",")>=0)throw new Error(`Invalid condition: ${L}`);g.push(L)}i.push(`--conditions=${g.join(",")}`)}if(P)for(let g of P)i.push(`--external:${V(g,"external")}`);if(a)for(let g in a){if(g.indexOf("=")>=0)throw new Error(`Invalid package name in alias: ${g}`);i.push(`--alias:${g}=${V(a[g],"alias",g)}`)}if(R)for(let g in R){if(g.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${g}`);i.push(`--banner:${g}=${V(R[g],"banner",g)}`)}if(W)for(let g in W){if(g.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${g}`);i.push(`--footer:${g}=${V(W[g],"footer",g)}`)}if(b)for(let g of b)i.push(`--inject:${V(g,"inject")}`);if(c)for(let g in c){if(g.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${g}`);i.push(`--loader:${g}=${V(c[g],"loader",g)}`)}if(m)for(let g in m){if(g.indexOf("=")>=0)throw new Error(`Invalid out extension: ${g}`);i.push(`--out-extension:${g}=${V(m[g],"out extension",g)}`)}if($)if(Array.isArray($))for(let g=0,L=$.length;g<L;g++){let Y=$[g];if(typeof Y=="object"&&Y!==null){let Z=Object.create(null),te=r(Y,Z,"in",h),fe=r(Y,Z,"out",h);if(K(Y,Z,"in entry point at index "+g),te===void 0)throw new Error('Missing property "in" for entry point at index '+g);if(fe===void 0)throw new Error('Missing property "out" for entry point at index '+g);d.push([fe,te])}else d.push(["",V(Y,"entry point at index "+g)])}else for(let g in $)d.push([g,V($[g],"entry point",g)]);if(D){let g=Object.create(null),L=r(D,g,"contents",Fe),Y=r(D,g,"resolveDir",h),Z=r(D,g,"sourcefile",h),te=r(D,g,"loader",h);K(D,g,'in "stdin" object'),Z&&i.push(`--sourcefile=${Z}`),te&&i.push(`--loader=${te}`),Y&&(v=Y),typeof L=="string"?y=G(L):L instanceof Uint8Array&&(y=L)}let ie=[];if(s)for(let g of s)g+="",ie.push(g);return{entries:d,flags:i,write:C,stdinContents:y,stdinResolveDir:v,absWorkingDir:T,nodePaths:ie,mangleCache:Te(H)}}function Qe(e,t,n,l){let f=[],i=Object.create(null);he(f,t,i,n,l),De(f,t,i);let d=r(t,i,"sourcemap",Pe),o=r(t,i,"tsconfigRaw",_e),y=r(t,i,"sourcefile",h),v=r(t,i,"loader",h),x=r(t,i,"banner",h),A=r(t,i,"footer",h),U=r(t,i,"mangleCache",X);return K(t,i,`in ${e}() call`),d&&f.push(`--sourcemap=${d===!0?"external":d}`),o&&f.push(`--tsconfig-raw=${typeof o=="string"?o:JSON.stringify(o)}`),y&&f.push(`--sourcefile=${y}`),v&&f.push(`--loader=${v}`),x&&f.push(`--banner=${x}`),A&&f.push(`--footer=${A}`),{flags:f,mangleCache:Te(U)}}function Ue(e){let t={},n={didClose:!1,reason:""},l={},f=0,i=0,d=new Uint8Array(16*1024),o=0,y=p=>{let s=o+p.length;if(s>d.length){let w=new Uint8Array(s*2);w.set(d),d=w}d.set(p,o),o+=p.length;let u=0;for(;u+4<=o;){let w=Re(d,u);if(u+4+w>o)break;u+=4,j(d.subarray(u,u+w)),u+=w}u>0&&(d.copyWithin(0,u,o),o-=u)},v=p=>{n.didClose=!0,p&&(n.reason=": "+(p.message||p));let s="The service was stopped"+n.reason;for(let u in l)l[u](s,null);l={}},x=(p,s,u)=>{if(n.didClose)return u("The service is no longer running"+n.reason,null);let w=f++;l[w]=(P,S)=>{try{u(P,S)}finally{p&&p.unref()}},p&&p.ref(),e.writeToStdin(xe({id:w,isRequest:!0,value:s}))},A=(p,s)=>{if(n.didClose)throw new Error("The service is no longer running"+n.reason);e.writeToStdin(xe({id:p,isRequest:!1,value:s}))},U=async(p,s)=>{try{if(s.command==="ping"){A(p,{});return}if(typeof s.key=="number"){let u=t[s.key];if(u){let w=u[s.command];if(w){await w(p,s);return}}}throw new Error("Invalid command: "+s.command)}catch(u){A(p,{errors:[re(u,e,null,void 0,"")]})}},F=!0,j=p=>{if(F){F=!1;let u=String.fromCharCode(...p);if(u!=="0.17.1")throw new Error(`Cannot start service: Host version "0.17.1" does not match binary version ${_(u)}`);return}let s=Ee(p);if(s.isRequest)U(s.id,s.value);else{let u=l[s.id];delete l[s.id],s.value.error?u(s.value.error,{}):u(null,s.value)}};return{readFromStdout:y,afterClose:v,service:{buildOrContext:({callName:p,refs:s,options:u,isTTY:w,defaultWD:P,callback:S})=>{let a=0,c=i++,m={},O={ref(){++a===1&&s&&s.ref()},unref(){--a===0&&(delete t[c],s&&s.unref())}};t[c]=m,O.ref(),He(p,c,x,A,O,e,m,u,w,P,(k,M)=>{try{S(k,M)}finally{O.unref()}})},transform:({callName:p,refs:s,input:u,options:w,isTTY:P,fs:S,callback:a})=>{let c=je(),m=O=>{try{if(typeof u!="string"&&!(u instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:k,mangleCache:M}=Qe(p,w,P,ke),E={command:"transform",flags:k,inputFS:O!==null,input:O!==null?G(O):typeof u=="string"?G(u):u};M&&(E.mangleCache=M),x(s,E,(b,R)=>{if(b)return a(new Error(b),null);let W=se(R.errors,c),$=se(R.warnings,c),T=1,D=()=>{if(--T===0){let C={warnings:$,code:R.code,map:R.map,mangleCache:void 0,legalComments:void 0};"legalComments"in R&&(C.legalComments=R==null?void 0:R.legalComments),R.mangleCache&&(C.mangleCache=R==null?void 0:R.mangleCache),a(null,C)}};if(W.length>0)return a(ue("Transform failed",W,$),null);R.codeFS&&(T++,S.readFile(R.code,(C,Q)=>{C!==null?a(C,null):(R.code=Q,D())})),R.mapFS&&(T++,S.readFile(R.map,(C,Q)=>{C!==null?a(C,null):(R.map=Q,D())})),D()})}catch(k){let M=[];try{he(M,w,{},P,ke)}catch(b){}let E=re(k,e,c,void 0,"");x(s,{command:"error",flags:M,error:E},()=>{E.detail=c.load(E.detail),a(ue("Transform failed",[E],[]),null)})}};if((typeof u=="string"||u instanceof Uint8Array)&&u.length>1024*1024){let O=m;m=()=>S.writeFile(u,O)}m(null)},formatMessages:({callName:p,refs:s,messages:u,options:w,callback:P})=>{let S=ee(u,"messages",null,"");if(!w)throw new Error(`Missing second argument in ${p}() call`);let a={},c=r(w,a,"kind",h),m=r(w,a,"color",N),O=r(w,a,"terminalWidth",le);if(K(w,a,`in ${p}() call`),c===void 0)throw new Error(`Missing "kind" in ${p}() call`);if(c!=="error"&&c!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${p}() call`);let k={command:"format-msgs",messages:S,isWarning:c==="warning"};m!==void 0&&(k.color=m),O!==void 0&&(k.terminalWidth=O),x(s,k,(M,E)=>{if(M)return P(new Error(M),null);P(null,E.messages)})},analyzeMetafile:({callName:p,refs:s,metafile:u,options:w,callback:P})=>{w===void 0&&(w={});let S={},a=r(w,S,"color",N),c=r(w,S,"verbose",N);K(w,S,`in ${p}() call`);let m={command:"analyze-metafile",metafile:u};a!==void 0&&(m.color=a),c!==void 0&&(m.verbose=c),x(s,m,(O,k)=>{if(O)return P(new Error(O),null);P(null,k.result)})}}}}function He(e,t,n,l,f,i,d,o,y,v,x){let A=je(),U=e==="context",F=(B,I)=>{let q=[];try{he(q,o,{},y,Se)}catch(s){}let p=re(B,i,A,void 0,I);n(f,{command:"error",flags:q,error:p},()=>{p.detail=A.load(p.detail),x(ue(U?"Context failed":"Build failed",[p],[]),null)})},j;if(typeof o=="object"){let B=o.plugins;if(B!==void 0){if(!Array.isArray(B))return F(new Error('"plugins" must be an array'),"");j=B}}if(j&&j.length>0){if(i.isSync)return F(new Error("Cannot use plugins in synchronous API calls"),"");Ge(t,n,l,f,i,d,o,j,A).then(B=>{if(!B.ok)return F(B.error,B.pluginName);try{J(B.requestPlugins,B.runOnEndCallbacks)}catch(I){F(I,"")}},B=>F(B,""));return}try{J(null,(B,I)=>I([],[]))}catch(B){F(B,"")}function J(B,I){let q=i.hasFS,{entries:p,flags:s,write:u,stdinContents:w,stdinResolveDir:P,absWorkingDir:S,nodePaths:a,mangleCache:c}=Je(e,o,y,Se,q);if(u&&!i.hasFS)throw new Error('The "write" option is unavailable in this environment');let m={command:"build",key:t,entries:p,flags:s,write:u,stdinContents:w,stdinResolveDir:P,absWorkingDir:S||v,nodePaths:a,context:U};B&&(m.plugins=B),c&&(m.mangleCache=c);let O=(E,b)=>{let R={errors:se(E.errors,A),warnings:se(E.warnings,A),outputFiles:void 0,metafile:void 0,mangleCache:void 0},W=R.errors.slice(),$=R.warnings.slice();E.outputFiles&&(R.outputFiles=E.outputFiles.map(Xe)),E.metafile&&(R.metafile=JSON.parse(E.metafile)),E.mangleCache&&(R.mangleCache=E.mangleCache),E.writeToStdout!==void 0&&console.log(ne(E.writeToStdout).replace(/\n$/,"")),I(R,(T,D)=>{if(W.length>0||T.length>0){let C=ue("Build failed",W.concat(T),$.concat(D));return b(C,null,T,D)}b(null,R,T,D)})},k,M;U&&(d["on-end"]=(E,b)=>new Promise(R=>{O(b,(W,$,T,D)=>{let C={errors:T,warnings:D};M&&M(W,$),k=void 0,M=void 0,l(E,C),R()})})),n(f,m,(E,b)=>{if(E)return x(new Error(E),null);if(!U)return O(b,x);if(b.errors.length>0)return x(ue("Context failed",b.errors,b.warnings),null);let R=!1,W={rebuild:()=>(k||(k=new Promise(($,T)=>{let D;M=(Q,H)=>{D||(D=()=>Q?T(Q):$(H))};let C=()=>{n(f,{command:"rebuild",key:t},(H,ie)=>{H?T(new Error(H)):D?D():C()})};C()})),k),watch:($={})=>new Promise((T,D)=>{if(!i.hasFS)throw new Error('Cannot use the "watch" API in this environment');K($,{},"in watch() call"),n(f,{command:"watch",key:t},H=>{H?D(new Error(H)):T(void 0)})}),serve:($={})=>new Promise((T,D)=>{if(!i.hasFS)throw new Error('Cannot use the "serve" API in this environment');let C={},Q=r($,C,"port",le),H=r($,C,"host",h),ie=r($,C,"servedir",h),ae=r($,C,"keyfile",h),g=r($,C,"certfile",h),L=r($,C,"onRequest",Ae);K($,C,"in serve() call");let Y={command:"serve",key:t,onRequest:!!L};Q!==void 0&&(Y.port=Q),H!==void 0&&(Y.host=H),ie!==void 0&&(Y.servedir=ie),ae!==void 0&&(Y.keyfile=ae),g!==void 0&&(Y.certfile=g),n(f,Y,(Z,te)=>{if(Z)return D(new Error(Z));L&&(d["serve-request"]=(fe,Le)=>{L(Le.args),l(fe,{})}),T(te)})}),cancel:()=>new Promise($=>{if(R)return $();n(f,{command:"cancel",key:t},()=>{$()})}),dispose:()=>new Promise($=>{if(R)return $();n(f,{command:"dispose",key:t},()=>{$(),f.unref()})})};f.ref(),x(null,W)})}}var Ge=async(e,t,n,l,f,i,d,o,y)=>{let v=[],x=[],A={},U={},F=0,j=0,J=[],B=!1;o=[...o];for(let q of o){let p={};if(typeof q!="object")throw new Error(`Plugin at index ${j} must be an object`);let s=r(q,p,"name",h);if(typeof s!="string"||s==="")throw new Error(`Plugin at index ${j} is missing a name`);try{let u=r(q,p,"setup",Ae);if(typeof u!="function")throw new Error("Plugin is missing a setup function");K(q,p,`on plugin ${_(s)}`);let w={name:s,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};j++;let S=u({initialOptions:d,resolve:(a,c={})=>{if(!B)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof a!="string")throw new Error("The path to resolve must be a string");let m=Object.create(null),O=r(c,m,"pluginName",h),k=r(c,m,"importer",h),M=r(c,m,"namespace",h),E=r(c,m,"resolveDir",h),b=r(c,m,"kind",h),R=r(c,m,"pluginData",me);return K(c,m,"in resolve() call"),new Promise((W,$)=>{let T={command:"resolve",path:a,key:e,pluginName:s};if(O!=null&&(T.pluginName=O),k!=null&&(T.importer=k),M!=null&&(T.namespace=M),E!=null&&(T.resolveDir=E),b!=null)T.kind=b;else throw new Error('Must specify "kind" when calling "resolve"');R!=null&&(T.pluginData=y.store(R)),t(l,T,(D,C)=>{D!==null?$(new Error(D)):W({errors:se(C.errors,y),warnings:se(C.warnings,y),path:C.path,external:C.external,sideEffects:C.sideEffects,namespace:C.namespace,suffix:C.suffix,pluginData:y.load(C.pluginData)})})})},onStart(a){let c='This error came from the "onStart" callback registered here:',m=pe(new Error(c),f,"onStart");v.push({name:s,callback:a,note:m}),w.onStart=!0},onEnd(a){let c='This error came from the "onEnd" callback registered here:',m=pe(new Error(c),f,"onEnd");x.push({name:s,callback:a,note:m}),w.onEnd=!0},onResolve(a,c){let m='This error came from the "onResolve" callback registered here:',O=pe(new Error(m),f,"onResolve"),k={},M=r(a,k,"filter",ye),E=r(a,k,"namespace",h);if(K(a,k,`in onResolve() call for plugin ${_(s)}`),M==null)throw new Error("onResolve() call is missing a filter");let b=F++;A[b]={name:s,callback:c,note:O},w.onResolve.push({id:b,filter:M.source,namespace:E||""})},onLoad(a,c){let m='This error came from the "onLoad" callback registered here:',O=pe(new Error(m),f,"onLoad"),k={},M=r(a,k,"filter",ye),E=r(a,k,"namespace",h);if(K(a,k,`in onLoad() call for plugin ${_(s)}`),M==null)throw new Error("onLoad() call is missing a filter");let b=F++;U[b]={name:s,callback:c,note:O},w.onLoad.push({id:b,filter:M.source,namespace:E||""})},esbuild:f.esbuild});S&&await S,J.push(w)}catch(u){return{ok:!1,error:u,pluginName:s}}}i["on-start"]=async(q,p)=>{let s={errors:[],warnings:[]};await Promise.all(v.map(async({name:u,callback:w,note:P})=>{try{let S=await w();if(S!=null){if(typeof S!="object")throw new Error(`Expected onStart() callback in plugin ${_(u)} to return an object`);let a={},c=r(S,a,"errors",z),m=r(S,a,"warnings",z);K(S,a,`from onStart() callback in plugin ${_(u)}`),c!=null&&s.errors.push(...ee(c,"errors",y,u)),m!=null&&s.warnings.push(...ee(m,"warnings",y,u))}}catch(S){s.errors.push(re(S,f,y,P&&P(),u))}})),n(q,s)},i["on-resolve"]=async(q,p)=>{let s={},u="",w,P;for(let S of p.ids)try{({name:u,callback:w,note:P}=A[S]);let a=await w({path:p.path,importer:p.importer,namespace:p.namespace,resolveDir:p.resolveDir,kind:p.kind,pluginData:y.load(p.pluginData)});if(a!=null){if(typeof a!="object")throw new Error(`Expected onResolve() callback in plugin ${_(u)} to return an object`);let c={},m=r(a,c,"pluginName",h),O=r(a,c,"path",h),k=r(a,c,"namespace",h),M=r(a,c,"suffix",h),E=r(a,c,"external",N),b=r(a,c,"sideEffects",N),R=r(a,c,"pluginData",me),W=r(a,c,"errors",z),$=r(a,c,"warnings",z),T=r(a,c,"watchFiles",z),D=r(a,c,"watchDirs",z);K(a,c,`from onResolve() callback in plugin ${_(u)}`),s.id=S,m!=null&&(s.pluginName=m),O!=null&&(s.path=O),k!=null&&(s.namespace=k),M!=null&&(s.suffix=M),E!=null&&(s.external=E),b!=null&&(s.sideEffects=b),R!=null&&(s.pluginData=y.store(R)),W!=null&&(s.errors=ee(W,"errors",y,u)),$!=null&&(s.warnings=ee($,"warnings",y,u)),T!=null&&(s.watchFiles=ge(T,"watchFiles")),D!=null&&(s.watchDirs=ge(D,"watchDirs"));break}}catch(a){s={id:S,errors:[re(a,f,y,P&&P(),u)]};break}n(q,s)},i["on-load"]=async(q,p)=>{let s={},u="",w,P;for(let S of p.ids)try{({name:u,callback:w,note:P}=U[S]);let a=await w({path:p.path,namespace:p.namespace,suffix:p.suffix,pluginData:y.load(p.pluginData)});if(a!=null){if(typeof a!="object")throw new Error(`Expected onLoad() callback in plugin ${_(u)} to return an object`);let c={},m=r(a,c,"pluginName",h),O=r(a,c,"contents",Fe),k=r(a,c,"resolveDir",h),M=r(a,c,"pluginData",me),E=r(a,c,"loader",h),b=r(a,c,"errors",z),R=r(a,c,"warnings",z),W=r(a,c,"watchFiles",z),$=r(a,c,"watchDirs",z);K(a,c,`from onLoad() callback in plugin ${_(u)}`),s.id=S,m!=null&&(s.pluginName=m),O instanceof Uint8Array?s.contents=O:O!=null&&(s.contents=G(O)),k!=null&&(s.resolveDir=k),M!=null&&(s.pluginData=y.store(M)),E!=null&&(s.loader=E),b!=null&&(s.errors=ee(b,"errors",y,u)),R!=null&&(s.warnings=ee(R,"warnings",y,u)),W!=null&&(s.watchFiles=ge(W,"watchFiles")),$!=null&&(s.watchDirs=ge($,"watchDirs"));break}}catch(a){s={id:S,errors:[re(a,f,y,P&&P(),u)]};break}n(q,s)};let I=(q,p)=>p([],[]);return x.length>0&&(I=(q,p)=>{(async()=>{let s=[],u=[];for(let{name:w,callback:P,note:S}of x){let a,c;try{let m=await P(q);if(m!=null){if(typeof m!="object")throw new Error(`Expected onEnd() callback in plugin ${_(w)} to return an object`);let O={},k=r(m,O,"errors",z),M=r(m,O,"warnings",z);K(m,O,`from onEnd() callback in plugin ${_(w)}`),k!=null&&(a=ee(k,"errors",y,w)),M!=null&&(c=ee(M,"warnings",y,w))}}catch(m){a=[re(m,f,y,S&&S(),w)]}if(a){s.push(...a);try{q.errors.push(...a)}catch(m){}}if(c){u.push(...c);try{q.warnings.push(...c)}catch(m){}}}p(s,u)})()}),B=!0,{ok:!0,requestPlugins:J,runOnEndCallbacks:I}};function je(){let e=new Map,t=0;return{load(n){return e.get(n)},store(n){if(n===void 0)return-1;let l=t++;return e.set(l,n),l}}}function pe(e,t,n){let l,f=!1;return()=>{if(f)return l;f=!0;try{let i=(e.stack+"").split(`
|
|
7
|
-
`);i.splice(1,1);let d=qe(t,i,n);if(d)return l={text:e.message,location:d},l}catch(i){}}}function
|
|
8
|
-
`),"")}catch(
|
|
6
|
+
`);function Re(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function ve(e,t,n){e[n++]=t,e[n++]=t>>8,e[n++]=t>>16,e[n++]=t>>24}var V=JSON.stringify,Se="warning",ke="silent";function $e(e){if(J(e,"target"),e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var me=()=>null,I=e=>typeof e=="boolean"?null:"a boolean",h=e=>typeof e=="string"?null:"a string",ye=e=>e instanceof RegExp?null:"a RegExp object",se=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Ae=e=>typeof e=="function"?null:"a function",z=e=>Array.isArray(e)?null:"an array",ee=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",Ke=e=>typeof e=="object"&&e!==null?null:"an array or an object",_e=e=>e instanceof WebAssembly.Module?null:"a WebAssembly.Module",Me=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",De=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",Ve=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",Ye=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",Pe=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array",Je=e=>typeof e=="string"||e instanceof URL?null:"a string or a URL";function r(e,t,n,l){let f=e[n];if(t[n+""]=!0,f===void 0)return;let i=l(f);if(i!==null)throw new Error(`${V(n)} must be ${i}`);return f}function K(e,t,n){for(let l in e)if(!(l in t))throw new Error(`Invalid option ${n}: ${V(l)}`)}function Fe(e){let t=Object.create(null),n=r(e,t,"wasmURL",Je),l=r(e,t,"wasmModule",_e),f=r(e,t,"worker",I);return K(e,t,"in initialize() call"),{wasmURL:n,wasmModule:l,worker:f}}function Te(e){let t;if(e!==void 0){t=Object.create(null);for(let n in e){let l=e[n];if(typeof l=="string"||l===!1)t[n]=l;else throw new Error(`Expected ${V(n)} in mangle cache to map to either a string or false`)}}return t}function he(e,t,n,l,f){let i=r(t,n,"color",I),d=r(t,n,"logLevel",h),s=r(t,n,"logLimit",se);i!==void 0?e.push(`--color=${i}`):l&&e.push("--color=true"),e.push(`--log-level=${d||f}`),e.push(`--log-limit=${s||0}`)}function J(e,t,n){if(typeof e!="string")throw new Error(`Expected value for ${t}${n!==void 0?" "+V(n):""} to be a string, got ${typeof e} instead`);return e}function Be(e,t,n){let l=r(t,n,"legalComments",h),f=r(t,n,"sourceRoot",h),i=r(t,n,"sourcesContent",I),d=r(t,n,"target",Ye),s=r(t,n,"format",h),y=r(t,n,"globalName",h),w=r(t,n,"mangleProps",ye),v=r(t,n,"reserveProps",ye),P=r(t,n,"mangleQuoted",I),U=r(t,n,"minify",I),B=r(t,n,"minifySyntax",I),j=r(t,n,"minifyWhitespace",I),Q=r(t,n,"minifyIdentifiers",I),T=r(t,n,"drop",z),W=r(t,n,"charset",h),Y=r(t,n,"treeShaking",I),R=r(t,n,"ignoreAnnotations",I),g=r(t,n,"jsx",h),c=r(t,n,"jsxFactory",h),o=r(t,n,"jsxFragment",h),O=r(t,n,"jsxImportSource",h),S=r(t,n,"jsxDev",I),$=r(t,n,"jsxSideEffects",I),E=r(t,n,"define",ee),a=r(t,n,"logOverride",ee),u=r(t,n,"supported",ee),b=r(t,n,"pure",z),M=r(t,n,"keepNames",I),k=r(t,n,"platform",h);if(l&&e.push(`--legal-comments=${l}`),f!==void 0&&e.push(`--source-root=${f}`),i!==void 0&&e.push(`--sources-content=${i}`),d&&(Array.isArray(d)?e.push(`--target=${Array.from(d).map($e).join(",")}`):e.push(`--target=${$e(d)}`)),s&&e.push(`--format=${s}`),y&&e.push(`--global-name=${y}`),k&&e.push(`--platform=${k}`),U&&e.push("--minify"),B&&e.push("--minify-syntax"),j&&e.push("--minify-whitespace"),Q&&e.push("--minify-identifiers"),W&&e.push(`--charset=${W}`),Y!==void 0&&e.push(`--tree-shaking=${Y}`),R&&e.push("--ignore-annotations"),T)for(let m of T)e.push(`--drop:${J(m,"drop")}`);if(w&&e.push(`--mangle-props=${w.source}`),v&&e.push(`--reserve-props=${v.source}`),P!==void 0&&e.push(`--mangle-quoted=${P}`),g&&e.push(`--jsx=${g}`),c&&e.push(`--jsx-factory=${c}`),o&&e.push(`--jsx-fragment=${o}`),O&&e.push(`--jsx-import-source=${O}`),S&&e.push("--jsx-dev"),$&&e.push("--jsx-side-effects"),E)for(let m in E){if(m.indexOf("=")>=0)throw new Error(`Invalid define: ${m}`);e.push(`--define:${m}=${J(E[m],"define",m)}`)}if(a)for(let m in a){if(m.indexOf("=")>=0)throw new Error(`Invalid log override: ${m}`);e.push(`--log-override:${m}=${J(a[m],"log override",m)}`)}if(u)for(let m in u){if(m.indexOf("=")>=0)throw new Error(`Invalid supported: ${m}`);let x=u[m];if(typeof x!="boolean")throw new Error(`Expected value for supported ${V(m)} to be a boolean, got ${typeof x} instead`);e.push(`--supported:${m}=${x}`)}if(b)for(let m of b)e.push(`--pure:${J(m,"pure")}`);M&&e.push("--keep-names")}function Qe(e,t,n,l,f){var le;let i=[],d=[],s=Object.create(null),y=null,w=null;he(i,t,s,n,l),Be(i,t,s);let v=r(t,s,"sourcemap",De),P=r(t,s,"bundle",I),U=r(t,s,"splitting",I),B=r(t,s,"preserveSymlinks",I),j=r(t,s,"metafile",I),Q=r(t,s,"outfile",h),T=r(t,s,"outdir",h),W=r(t,s,"outbase",h),Y=r(t,s,"tsconfig",h),R=r(t,s,"resolveExtensions",z),g=r(t,s,"nodePaths",z),c=r(t,s,"mainFields",z),o=r(t,s,"conditions",z),O=r(t,s,"external",z),S=r(t,s,"packages",h),$=r(t,s,"alias",ee),E=r(t,s,"loader",ee),a=r(t,s,"outExtension",ee),u=r(t,s,"publicPath",h),b=r(t,s,"entryNames",h),M=r(t,s,"chunkNames",h),k=r(t,s,"assetNames",h),m=r(t,s,"inject",z),x=r(t,s,"banner",ee),F=r(t,s,"footer",ee),L=r(t,s,"entryPoints",Ke),C=r(t,s,"absWorkingDir",h),D=r(t,s,"stdin",ee),A=(le=r(t,s,"write",I))!=null?le:f,q=r(t,s,"allowOverwrite",I),_=r(t,s,"mangleCache",ee);if(s.plugins=!0,K(t,s,`in ${e}() call`),v&&i.push(`--sourcemap${v===!0?"":`=${v}`}`),P&&i.push("--bundle"),q&&i.push("--allow-overwrite"),U&&i.push("--splitting"),B&&i.push("--preserve-symlinks"),j&&i.push("--metafile"),Q&&i.push(`--outfile=${Q}`),T&&i.push(`--outdir=${T}`),W&&i.push(`--outbase=${W}`),Y&&i.push(`--tsconfig=${Y}`),S&&i.push(`--packages=${S}`),R){let p=[];for(let N of R){if(J(N,"resolve extension"),N.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${N}`);p.push(N)}i.push(`--resolve-extensions=${p.join(",")}`)}if(u&&i.push(`--public-path=${u}`),b&&i.push(`--entry-names=${b}`),M&&i.push(`--chunk-names=${M}`),k&&i.push(`--asset-names=${k}`),c){let p=[];for(let N of c){if(J(N,"main field"),N.indexOf(",")>=0)throw new Error(`Invalid main field: ${N}`);p.push(N)}i.push(`--main-fields=${p.join(",")}`)}if(o){let p=[];for(let N of o){if(J(N,"condition"),N.indexOf(",")>=0)throw new Error(`Invalid condition: ${N}`);p.push(N)}i.push(`--conditions=${p.join(",")}`)}if(O)for(let p of O)i.push(`--external:${J(p,"external")}`);if($)for(let p in $){if(p.indexOf("=")>=0)throw new Error(`Invalid package name in alias: ${p}`);i.push(`--alias:${p}=${J($[p],"alias",p)}`)}if(x)for(let p in x){if(p.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${p}`);i.push(`--banner:${p}=${J(x[p],"banner",p)}`)}if(F)for(let p in F){if(p.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${p}`);i.push(`--footer:${p}=${J(F[p],"footer",p)}`)}if(m)for(let p of m)i.push(`--inject:${J(p,"inject")}`);if(E)for(let p in E){if(p.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${p}`);i.push(`--loader:${p}=${J(E[p],"loader",p)}`)}if(a)for(let p in a){if(p.indexOf("=")>=0)throw new Error(`Invalid out extension: ${p}`);i.push(`--out-extension:${p}=${J(a[p],"out extension",p)}`)}if(L)if(Array.isArray(L))for(let p=0,N=L.length;p<N;p++){let G=L[p];if(typeof G=="object"&&G!==null){let X=Object.create(null),ne=r(G,X,"in",h),fe=r(G,X,"out",h);if(K(G,X,"in entry point at index "+p),ne===void 0)throw new Error('Missing property "in" for entry point at index '+p);if(fe===void 0)throw new Error('Missing property "out" for entry point at index '+p);d.push([fe,ne])}else d.push(["",J(G,"entry point at index "+p)])}else for(let p in L)d.push([p,J(L[p],"entry point",p)]);if(D){let p=Object.create(null),N=r(D,p,"contents",Pe),G=r(D,p,"resolveDir",h),X=r(D,p,"sourcefile",h),ne=r(D,p,"loader",h);K(D,p,'in "stdin" object'),X&&i.push(`--sourcefile=${X}`),ne&&i.push(`--loader=${ne}`),G&&(w=G),typeof N=="string"?y=Z(N):N instanceof Uint8Array&&(y=N)}let H=[];if(g)for(let p of g)p+="",H.push(p);return{entries:d,flags:i,write:A,stdinContents:y,stdinResolveDir:w,absWorkingDir:C,nodePaths:H,mangleCache:Te(_)}}function He(e,t,n,l){let f=[],i=Object.create(null);he(f,t,i,n,l),Be(f,t,i);let d=r(t,i,"sourcemap",De),s=r(t,i,"tsconfigRaw",Ve),y=r(t,i,"sourcefile",h),w=r(t,i,"loader",h),v=r(t,i,"banner",h),P=r(t,i,"footer",h),U=r(t,i,"mangleCache",ee);return K(t,i,`in ${e}() call`),d&&f.push(`--sourcemap=${d===!0?"external":d}`),s&&f.push(`--tsconfig-raw=${typeof s=="string"?s:JSON.stringify(s)}`),y&&f.push(`--sourcefile=${y}`),w&&f.push(`--loader=${w}`),v&&f.push(`--banner=${v}`),P&&f.push(`--footer=${P}`),{flags:f,mangleCache:Te(U)}}function Ue(e){let t={},n={didClose:!1,reason:""},l={},f=0,i=0,d=new Uint8Array(16*1024),s=0,y=R=>{let g=s+R.length;if(g>d.length){let o=new Uint8Array(g*2);o.set(d),d=o}d.set(R,s),s+=R.length;let c=0;for(;c+4<=s;){let o=Re(d,c);if(c+4+o>s)break;c+=4,j(d.subarray(c,c+o)),c+=o}c>0&&(d.copyWithin(0,c,s),s-=c)},w=R=>{n.didClose=!0,R&&(n.reason=": "+(R.message||R));let g="The service was stopped"+n.reason;for(let c in l)l[c](g,null);l={}},v=(R,g,c)=>{if(n.didClose)return c("The service is no longer running"+n.reason,null);let o=f++;l[o]=(O,S)=>{try{c(O,S)}finally{R&&R.unref()}},R&&R.ref(),e.writeToStdin(xe({id:o,isRequest:!0,value:g}))},P=(R,g)=>{if(n.didClose)throw new Error("The service is no longer running"+n.reason);e.writeToStdin(xe({id:R,isRequest:!1,value:g}))},U=async(R,g)=>{try{if(g.command==="ping"){P(R,{});return}if(typeof g.key=="number"){let c=t[g.key];if(c){let o=c[g.command];if(o){await o(R,g);return}}}throw new Error("Invalid command: "+g.command)}catch(c){P(R,{errors:[ie(c,e,null,void 0,"")]})}},B=!0,j=R=>{if(B){B=!1;let c=String.fromCharCode(...R);if(c!=="0.17.2")throw new Error(`Cannot start service: Host version "0.17.2" does not match binary version ${V(c)}`);return}let g=Ee(R);if(g.isRequest)U(g.id,g.value);else{let c=l[g.id];delete l[g.id],g.value.error?c(g.value.error,{}):c(null,g.value)}};return{readFromStdout:y,afterClose:w,service:{buildOrContext:({callName:R,refs:g,options:c,isTTY:o,defaultWD:O,callback:S})=>{let $=0,E=i++,a={},u={ref(){++$===1&&g&&g.ref()},unref(){--$===0&&(delete t[E],g&&g.unref())}};t[E]=a,u.ref(),Ge(R,E,v,P,u,e,a,c,o,O,(b,M)=>{try{S(b,M)}finally{u.unref()}})},transform:({callName:R,refs:g,input:c,options:o,isTTY:O,fs:S,callback:$})=>{let E=je(),a=u=>{try{if(typeof c!="string"&&!(c instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:b,mangleCache:M}=He(R,o,O,ke),k={command:"transform",flags:b,inputFS:u!==null,input:u!==null?Z(u):typeof c=="string"?Z(c):c};M&&(k.mangleCache=M),v(g,k,(m,x)=>{if(m)return $(new Error(m),null);let F=oe(x.errors,E),L=oe(x.warnings,E),C=1,D=()=>{if(--C===0){let A={warnings:L,code:x.code,map:x.map,mangleCache:void 0,legalComments:void 0};"legalComments"in x&&(A.legalComments=x==null?void 0:x.legalComments),x.mangleCache&&(A.mangleCache=x==null?void 0:x.mangleCache),$(null,A)}};if(F.length>0)return $(ue("Transform failed",F,L),null);x.codeFS&&(C++,S.readFile(x.code,(A,q)=>{A!==null?$(A,null):(x.code=q,D())})),x.mapFS&&(C++,S.readFile(x.map,(A,q)=>{A!==null?$(A,null):(x.map=q,D())})),D()})}catch(b){let M=[];try{he(M,o,{},O,ke)}catch(m){}let k=ie(b,e,E,void 0,"");v(g,{command:"error",flags:M,error:k},()=>{k.detail=E.load(k.detail),$(ue("Transform failed",[k],[]),null)})}};if((typeof c=="string"||c instanceof Uint8Array)&&c.length>1024*1024){let u=a;a=()=>S.writeFile(c,u)}a(null)},formatMessages:({callName:R,refs:g,messages:c,options:o,callback:O})=>{let S=te(c,"messages",null,"");if(!o)throw new Error(`Missing second argument in ${R}() call`);let $={},E=r(o,$,"kind",h),a=r(o,$,"color",I),u=r(o,$,"terminalWidth",se);if(K(o,$,`in ${R}() call`),E===void 0)throw new Error(`Missing "kind" in ${R}() call`);if(E!=="error"&&E!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${R}() call`);let b={command:"format-msgs",messages:S,isWarning:E==="warning"};a!==void 0&&(b.color=a),u!==void 0&&(b.terminalWidth=u),v(g,b,(M,k)=>{if(M)return O(new Error(M),null);O(null,k.messages)})},analyzeMetafile:({callName:R,refs:g,metafile:c,options:o,callback:O})=>{o===void 0&&(o={});let S={},$=r(o,S,"color",I),E=r(o,S,"verbose",I);K(o,S,`in ${R}() call`);let a={command:"analyze-metafile",metafile:c};$!==void 0&&(a.color=$),E!==void 0&&(a.verbose=E),v(g,a,(u,b)=>{if(u)return O(new Error(u),null);O(null,b.result)})}}}}function Ge(e,t,n,l,f,i,d,s,y,w,v){let P=je(),U=e==="context",B=(T,W)=>{let Y=[];try{he(Y,s,{},y,Se)}catch(g){}let R=ie(T,i,P,void 0,W);n(f,{command:"error",flags:Y,error:R},()=>{R.detail=P.load(R.detail),v(ue(U?"Context failed":"Build failed",[R],[]),null)})},j;if(typeof s=="object"){let T=s.plugins;if(T!==void 0){if(!Array.isArray(T))return B(new Error('"plugins" must be an array'),"");j=T}}if(j&&j.length>0){if(i.isSync)return B(new Error("Cannot use plugins in synchronous API calls"),"");Xe(t,n,l,f,i,d,s,j,P).then(T=>{if(!T.ok)return B(T.error,T.pluginName);try{Q(T.requestPlugins,T.runOnEndCallbacks,T.scheduleOnDisposeCallbacks)}catch(W){B(W,"")}},T=>B(T,""));return}try{Q(null,(T,W)=>W([],[]),()=>{})}catch(T){B(T,"")}function Q(T,W,Y){let R=i.hasFS,{entries:g,flags:c,write:o,stdinContents:O,stdinResolveDir:S,absWorkingDir:$,nodePaths:E,mangleCache:a}=Qe(e,s,y,Se,R);if(o&&!i.hasFS)throw new Error('The "write" option is unavailable in this environment');let u={command:"build",key:t,entries:g,flags:c,write:o,stdinContents:O,stdinResolveDir:S,absWorkingDir:$||w,nodePaths:E,context:U};T&&(u.plugins=T),a&&(u.mangleCache=a);let b=(m,x)=>{let F={errors:oe(m.errors,P),warnings:oe(m.warnings,P),outputFiles:void 0,metafile:void 0,mangleCache:void 0},L=F.errors.slice(),C=F.warnings.slice();m.outputFiles&&(F.outputFiles=m.outputFiles.map(Ze)),m.metafile&&(F.metafile=JSON.parse(m.metafile)),m.mangleCache&&(F.mangleCache=m.mangleCache),m.writeToStdout!==void 0&&console.log(re(m.writeToStdout).replace(/\n$/,"")),W(F,(D,A)=>{if(L.length>0||D.length>0){let q=ue("Build failed",L.concat(D),C.concat(A));return x(q,null,D,A)}x(null,F,D,A)})},M,k;U&&(d["on-end"]=(m,x)=>new Promise(F=>{b(x,(L,C,D,A)=>{let q={errors:D,warnings:A};k&&k(L,C),M=void 0,k=void 0,l(m,q),F()})})),n(f,u,(m,x)=>{if(m)return v(new Error(m),null);if(!U)return b(x,(C,D)=>(Y(),v(C,D)));if(x.errors.length>0)return v(ue("Context failed",x.errors,x.warnings),null);let F=!1,L={rebuild:()=>(M||(M=new Promise((C,D)=>{let A;k=(_,H)=>{A||(A=()=>_?D(_):C(H))};let q=()=>{n(f,{command:"rebuild",key:t},(H,le)=>{H?D(new Error(H)):A?A():q()})};q()})),M),watch:(C={})=>new Promise((D,A)=>{if(!i.hasFS)throw new Error('Cannot use the "watch" API in this environment');K(C,{},"in watch() call"),n(f,{command:"watch",key:t},H=>{H?A(new Error(H)):D(void 0)})}),serve:(C={})=>new Promise((D,A)=>{if(!i.hasFS)throw new Error('Cannot use the "serve" API in this environment');let q={},_=r(C,q,"port",se),H=r(C,q,"host",h),le=r(C,q,"servedir",h),p=r(C,q,"keyfile",h),N=r(C,q,"certfile",h),G=r(C,q,"onRequest",Ae);K(C,q,"in serve() call");let X={command:"serve",key:t,onRequest:!!G};_!==void 0&&(X.port=_),H!==void 0&&(X.host=H),le!==void 0&&(X.servedir=le),p!==void 0&&(X.keyfile=p),N!==void 0&&(X.certfile=N),n(f,X,(ne,fe)=>{if(ne)return A(new Error(ne));G&&(d["serve-request"]=(Le,Ne)=>{G(Ne.args),l(Le,{})}),D(fe)})}),cancel:()=>new Promise(C=>{if(F)return C();n(f,{command:"cancel",key:t},()=>{C()})}),dispose:()=>new Promise(C=>{if(F)return C();F=!0,n(f,{command:"dispose",key:t},()=>{C(),Y(),f.unref()})})};f.ref(),v(null,L)})}}var Xe=async(e,t,n,l,f,i,d,s,y)=>{let w=[],v=[],P={},U={},B=[],j=0,Q=0,T=[],W=!1;s=[...s];for(let g of s){let c={};if(typeof g!="object")throw new Error(`Plugin at index ${Q} must be an object`);let o=r(g,c,"name",h);if(typeof o!="string"||o==="")throw new Error(`Plugin at index ${Q} is missing a name`);try{let O=r(g,c,"setup",Ae);if(typeof O!="function")throw new Error("Plugin is missing a setup function");K(g,c,`on plugin ${V(o)}`);let S={name:o,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};Q++;let E=O({initialOptions:d,resolve:(a,u={})=>{if(!W)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof a!="string")throw new Error("The path to resolve must be a string");let b=Object.create(null),M=r(u,b,"pluginName",h),k=r(u,b,"importer",h),m=r(u,b,"namespace",h),x=r(u,b,"resolveDir",h),F=r(u,b,"kind",h),L=r(u,b,"pluginData",me);return K(u,b,"in resolve() call"),new Promise((C,D)=>{let A={command:"resolve",path:a,key:e,pluginName:o};if(M!=null&&(A.pluginName=M),k!=null&&(A.importer=k),m!=null&&(A.namespace=m),x!=null&&(A.resolveDir=x),F!=null)A.kind=F;else throw new Error('Must specify "kind" when calling "resolve"');L!=null&&(A.pluginData=y.store(L)),t(l,A,(q,_)=>{q!==null?D(new Error(q)):C({errors:oe(_.errors,y),warnings:oe(_.warnings,y),path:_.path,external:_.external,sideEffects:_.sideEffects,namespace:_.namespace,suffix:_.suffix,pluginData:y.load(_.pluginData)})})})},onStart(a){let u='This error came from the "onStart" callback registered here:',b=pe(new Error(u),f,"onStart");w.push({name:o,callback:a,note:b}),S.onStart=!0},onEnd(a){let u='This error came from the "onEnd" callback registered here:',b=pe(new Error(u),f,"onEnd");v.push({name:o,callback:a,note:b}),S.onEnd=!0},onResolve(a,u){let b='This error came from the "onResolve" callback registered here:',M=pe(new Error(b),f,"onResolve"),k={},m=r(a,k,"filter",ye),x=r(a,k,"namespace",h);if(K(a,k,`in onResolve() call for plugin ${V(o)}`),m==null)throw new Error("onResolve() call is missing a filter");let F=j++;P[F]={name:o,callback:u,note:M},S.onResolve.push({id:F,filter:m.source,namespace:x||""})},onLoad(a,u){let b='This error came from the "onLoad" callback registered here:',M=pe(new Error(b),f,"onLoad"),k={},m=r(a,k,"filter",ye),x=r(a,k,"namespace",h);if(K(a,k,`in onLoad() call for plugin ${V(o)}`),m==null)throw new Error("onLoad() call is missing a filter");let F=j++;U[F]={name:o,callback:u,note:M},S.onLoad.push({id:F,filter:m.source,namespace:x||""})},onDispose(a){B.push(a)},esbuild:f.esbuild});E&&await E,T.push(S)}catch(O){return{ok:!1,error:O,pluginName:o}}}i["on-start"]=async(g,c)=>{let o={errors:[],warnings:[]};await Promise.all(w.map(async({name:O,callback:S,note:$})=>{try{let E=await S();if(E!=null){if(typeof E!="object")throw new Error(`Expected onStart() callback in plugin ${V(O)} to return an object`);let a={},u=r(E,a,"errors",z),b=r(E,a,"warnings",z);K(E,a,`from onStart() callback in plugin ${V(O)}`),u!=null&&o.errors.push(...te(u,"errors",y,O)),b!=null&&o.warnings.push(...te(b,"warnings",y,O))}}catch(E){o.errors.push(ie(E,f,y,$&&$(),O))}})),n(g,o)},i["on-resolve"]=async(g,c)=>{let o={},O="",S,$;for(let E of c.ids)try{({name:O,callback:S,note:$}=P[E]);let a=await S({path:c.path,importer:c.importer,namespace:c.namespace,resolveDir:c.resolveDir,kind:c.kind,pluginData:y.load(c.pluginData)});if(a!=null){if(typeof a!="object")throw new Error(`Expected onResolve() callback in plugin ${V(O)} to return an object`);let u={},b=r(a,u,"pluginName",h),M=r(a,u,"path",h),k=r(a,u,"namespace",h),m=r(a,u,"suffix",h),x=r(a,u,"external",I),F=r(a,u,"sideEffects",I),L=r(a,u,"pluginData",me),C=r(a,u,"errors",z),D=r(a,u,"warnings",z),A=r(a,u,"watchFiles",z),q=r(a,u,"watchDirs",z);K(a,u,`from onResolve() callback in plugin ${V(O)}`),o.id=E,b!=null&&(o.pluginName=b),M!=null&&(o.path=M),k!=null&&(o.namespace=k),m!=null&&(o.suffix=m),x!=null&&(o.external=x),F!=null&&(o.sideEffects=F),L!=null&&(o.pluginData=y.store(L)),C!=null&&(o.errors=te(C,"errors",y,O)),D!=null&&(o.warnings=te(D,"warnings",y,O)),A!=null&&(o.watchFiles=ge(A,"watchFiles")),q!=null&&(o.watchDirs=ge(q,"watchDirs"));break}}catch(a){o={id:E,errors:[ie(a,f,y,$&&$(),O)]};break}n(g,o)},i["on-load"]=async(g,c)=>{let o={},O="",S,$;for(let E of c.ids)try{({name:O,callback:S,note:$}=U[E]);let a=await S({path:c.path,namespace:c.namespace,suffix:c.suffix,pluginData:y.load(c.pluginData)});if(a!=null){if(typeof a!="object")throw new Error(`Expected onLoad() callback in plugin ${V(O)} to return an object`);let u={},b=r(a,u,"pluginName",h),M=r(a,u,"contents",Pe),k=r(a,u,"resolveDir",h),m=r(a,u,"pluginData",me),x=r(a,u,"loader",h),F=r(a,u,"errors",z),L=r(a,u,"warnings",z),C=r(a,u,"watchFiles",z),D=r(a,u,"watchDirs",z);K(a,u,`from onLoad() callback in plugin ${V(O)}`),o.id=E,b!=null&&(o.pluginName=b),M instanceof Uint8Array?o.contents=M:M!=null&&(o.contents=Z(M)),k!=null&&(o.resolveDir=k),m!=null&&(o.pluginData=y.store(m)),x!=null&&(o.loader=x),F!=null&&(o.errors=te(F,"errors",y,O)),L!=null&&(o.warnings=te(L,"warnings",y,O)),C!=null&&(o.watchFiles=ge(C,"watchFiles")),D!=null&&(o.watchDirs=ge(D,"watchDirs"));break}}catch(a){o={id:E,errors:[ie(a,f,y,$&&$(),O)]};break}n(g,o)};let Y=(g,c)=>c([],[]);v.length>0&&(Y=(g,c)=>{(async()=>{let o=[],O=[];for(let{name:S,callback:$,note:E}of v){let a,u;try{let b=await $(g);if(b!=null){if(typeof b!="object")throw new Error(`Expected onEnd() callback in plugin ${V(S)} to return an object`);let M={},k=r(b,M,"errors",z),m=r(b,M,"warnings",z);K(b,M,`from onEnd() callback in plugin ${V(S)}`),k!=null&&(a=te(k,"errors",y,S)),m!=null&&(u=te(m,"warnings",y,S))}}catch(b){a=[ie(b,f,y,E&&E(),S)]}if(a){o.push(...a);try{g.errors.push(...a)}catch(b){}}if(u){O.push(...u);try{g.warnings.push(...u)}catch(b){}}}c(o,O)})()});let R=()=>{for(let g of B)setTimeout(()=>g(),0)};return W=!0,{ok:!0,requestPlugins:T,runOnEndCallbacks:Y,scheduleOnDisposeCallbacks:R}};function je(){let e=new Map,t=0;return{load(n){return e.get(n)},store(n){if(n===void 0)return-1;let l=t++;return e.set(l,n),l}}}function pe(e,t,n){let l,f=!1;return()=>{if(f)return l;f=!0;try{let i=(e.stack+"").split(`
|
|
7
|
+
`);i.splice(1,1);let d=qe(t,i,n);if(d)return l={text:e.message,location:d},l}catch(i){}}}function ie(e,t,n,l,f){let i="Internal error",d=null;try{i=(e&&e.message||e)+""}catch(s){}try{d=qe(t,(e.stack+"").split(`
|
|
8
|
+
`),"")}catch(s){}return{id:"",pluginName:f,text:i,location:d,notes:l?[l]:[],detail:n?n.store(e):-1}}function qe(e,t,n){let l=" at ";if(e.readFileSync&&!t[0].startsWith(l)&&t[1].startsWith(l))for(let f=1;f<t.length;f++){let i=t[f];if(i.startsWith(l))for(i=i.slice(l.length);;){let d=/^(?:new |async )?\S+ \((.*)\)$/.exec(i);if(d){i=d[1];continue}if(d=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(i),d){i=d[1];continue}if(d=/^(\S+):(\d+):(\d+)$/.exec(i),d){let s;try{s=e.readFileSync(d[1],"utf8")}catch(P){break}let y=s.split(/\r\n|\r|\n|\u2028|\u2029/)[+d[2]-1]||"",w=+d[3]-1,v=y.slice(w,w+n.length)===n?n.length:0;return{file:d[1],namespace:"file",line:+d[2],column:Z(y.slice(0,w)).length,length:Z(y.slice(w,w+v)).length,lineText:y+`
|
|
9
9
|
`+t.slice(1).join(`
|
|
10
|
-
`),suggestion:""}}break}}return null}function ue(e,t,n){let l=5,f=t.length<1?"":` with ${t.length} error${t.length<2?"":"s"}:`+t.slice(0,l+1).map((d,
|
|
10
|
+
`),suggestion:""}}break}}return null}function ue(e,t,n){let l=5,f=t.length<1?"":` with ${t.length} error${t.length<2?"":"s"}:`+t.slice(0,l+1).map((d,s)=>{if(s===l)return`
|
|
11
11
|
...`;if(!d.location)return`
|
|
12
|
-
error: ${d.text}`;let{file:y,line:
|
|
13
|
-
${y}:${v}:${x}: ERROR: ${A}${d.text}`}).join(""),i=new Error(`${e}${f}`);return i.errors=t,i.warnings=n,i}function se(e,t){for(let n of e)n.detail=t.load(n.detail);return e}function Ce(e,t){if(e==null)return null;let n={},l=r(e,n,"file",h),f=r(e,n,"namespace",h),i=r(e,n,"line",le),d=r(e,n,"column",le),o=r(e,n,"length",le),y=r(e,n,"lineText",h),v=r(e,n,"suggestion",h);return K(e,n,t),{file:l||"",namespace:f||"",line:i||0,column:d||0,length:o||0,lineText:y||"",suggestion:v||""}}function ee(e,t,n,l){let f=[],i=0;for(let d of e){let o={},y=r(d,o,"id",h),v=r(d,o,"pluginName",h),x=r(d,o,"text",h),A=r(d,o,"location",Me),U=r(d,o,"notes",z),F=r(d,o,"detail",me),j=`in element ${i} of "${t}"`;K(d,o,j);let J=[];if(U)for(let B of U){let I={},q=r(B,I,"text",h),p=r(B,I,"location",Me);K(B,I,j),J.push({text:q||"",location:Ce(p,j)})}f.push({id:y||"",pluginName:v||l,text:x||"",location:Ce(A,j),notes:J,detail:n?n.store(F):-1}),i++}return f}function ge(e,t){let n=[];for(let l of e){if(typeof l!="string")throw new Error(`${_(t)} must be an array of strings`);n.push(l)}return n}function Xe({path:e,contents:t}){let n=null;return{path:e,contents:t,get text(){let l=this.contents;return(n===null||l!==t)&&(t=l,n=ne(l)),n}}}var et="0.17.1",tt=e=>ce().build(e),nt=e=>ce().context(e),rt=(e,t)=>ce().transform(e,t),it=(e,t)=>ce().formatMessages(e,t),lt=(e,t)=>ce().analyzeMetafile(e,t),st=()=>{throw new Error('The "buildSync" API only works in node')},ot=()=>{throw new Error('The "transformSync" API only works in node')},at=()=>{throw new Error('The "formatMessagesSync" API only works in node')},ut=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},oe,Oe,ce=()=>{if(Oe)return Oe;throw oe?new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this'):new Error('You need to call "initialize" before calling this')},ct=e=>{e=Be(e||{});let t=e.wasmURL,n=e.wasmModule,l=e.worker!==!1;if(!t&&!n)throw new Error('Must provide either the "wasmURL" option or the "wasmModule" option');if(oe)throw new Error('Cannot call "initialize" more than once');return oe=ft(t||"",n,l),oe.catch(()=>{oe=void 0}),oe},ft=async(e,t,n)=>{let l;if(n){let v=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.\nlet onmessage,globalThis={};for(let r=self;r;r=Object.getPrototypeOf(r))for(let f of Object.getOwnPropertyNames(r))f in globalThis||Object.defineProperty(globalThis,f,{get:()=>self[f]});(()=>{const r=()=>{const u=new Error("not implemented");return u.code="ENOSYS",u};if(!globalThis.fs){let u="";globalThis.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(i,s){u+=y.decode(s);const n=u.lastIndexOf(`\n`);return n!=-1&&(console.log(u.substring(0,n)),u=u.substring(n+1)),s.length},write(i,s,n,o,c,m){if(n!==0||o!==s.length||c!==null){m(r());return}const h=this.writeSync(i,s);m(null,h)},chmod(i,s,n){n(r())},chown(i,s,n,o){o(r())},close(i,s){s(r())},fchmod(i,s,n){n(r())},fchown(i,s,n,o){o(r())},fstat(i,s){s(r())},fsync(i,s){s(null)},ftruncate(i,s,n){n(r())},lchown(i,s,n,o){o(r())},link(i,s,n){n(r())},lstat(i,s){s(r())},mkdir(i,s,n){n(r())},open(i,s,n,o){o(r())},read(i,s,n,o,c,m){m(r())},readdir(i,s){s(r())},readlink(i,s){s(r())},rename(i,s,n){n(r())},rmdir(i,s){s(r())},stat(i,s){s(r())},symlink(i,s,n){n(r())},truncate(i,s,n){n(r())},unlink(i,s){s(r())},utimes(i,s,n,o){o(r())}}}if(globalThis.process||(globalThis.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw r()},pid:-1,ppid:-1,umask(){throw r()},cwd(){throw r()},chdir(){throw r()}}),!globalThis.crypto)throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");if(!globalThis.performance)throw new Error("globalThis.performance is not available, polyfill required (performance.now only)");if(!globalThis.TextEncoder)throw new Error("globalThis.TextEncoder is not available, polyfill required");if(!globalThis.TextDecoder)throw new Error("globalThis.TextDecoder is not available, polyfill required");const f=new TextEncoder("utf-8"),y=new TextDecoder("utf-8");globalThis.Go=class{constructor(){this.argv=["js"],this.env={},this.exit=e=>{e!==0&&console.warn("exit code:",e)},this._exitPromise=new Promise(e=>{this._resolveExitPromise=e}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;const u=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},i=(e,t)=>{this.mem.setUint32(e+0,t,!0)},s=e=>{const t=this.mem.getUint32(e+0,!0),l=this.mem.getInt32(e+4,!0);return t+l*4294967296},n=e=>{const t=this.mem.getFloat64(e,!0);if(t===0)return;if(!isNaN(t))return t;const l=this.mem.getUint32(e,!0);return this._values[l]},o=(e,t)=>{if(typeof t=="number"&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,2146959360,!0),this.mem.setUint32(e,0,!0);return}this.mem.setFloat64(e,t,!0);return}if(t===void 0){this.mem.setFloat64(e,0,!0);return}let a=this._ids.get(t);a===void 0&&(a=this._idPool.pop(),a===void 0&&(a=this._values.length),this._values[a]=t,this._goRefCounts[a]=0,this._ids.set(t,a)),this._goRefCounts[a]++;let g=0;switch(typeof t){case"object":t!==null&&(g=1);break;case"string":g=2;break;case"symbol":g=3;break;case"function":g=4;break}this.mem.setUint32(e+4,2146959360|g,!0),this.mem.setUint32(e,a,!0)},c=e=>{const t=s(e+0),l=s(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,l)},m=e=>{const t=s(e+0),l=s(e+8),a=new Array(l);for(let g=0;g<l;g++)a[g]=n(t+g*8);return a},h=e=>{const t=s(e+0),l=s(e+8);return y.decode(new DataView(this._inst.exports.mem.buffer,t,l))},d=Date.now()-performance.now();this.importObject={_gotest:{add:(e,t)=>e+t},gojs:{"runtime.wasmExit":e=>{e=Number(e);const t=this.mem.getInt32(e+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(t)},"runtime.wasmWrite":e=>{e=Number(e);const t=s(e+8),l=s(e+16),a=this.mem.getInt32(e+24,!0);globalThis.fs.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,l,a))},"runtime.resetMemoryDataView":e=>{e=Number(e),this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":e=>{e=Number(e),u(e+8,(d+performance.now())*1e6)},"runtime.walltime":e=>{e=Number(e);const t=new Date().getTime();u(e+8,t/1e3),this.mem.setInt32(e+16,t%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":e=>{e=Number(e);const t=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(t,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(t);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},s(e+8))),this.mem.setInt32(e+16,t,!0)},"runtime.clearTimeoutEvent":e=>{e=Number(e);const t=this.mem.getInt32(e+8,!0);clearTimeout(this._scheduledTimeouts.get(t)),this._scheduledTimeouts.delete(t)},"runtime.getRandomData":e=>{e=Number(e),crypto.getRandomValues(c(e+8))},"syscall/js.finalizeRef":e=>{e=Number(e);const t=this.mem.getUint32(e+8,!0);if(this._goRefCounts[t]--,this._goRefCounts[t]===0){const l=this._values[t];this._values[t]=null,this._ids.delete(l),this._idPool.push(t)}},"syscall/js.stringVal":e=>{e=Number(e),o(e+24,h(e+8))},"syscall/js.valueGet":e=>{e=Number(e);const t=Reflect.get(n(e+8),h(e+16));e=Number(this._inst.exports.getsp()),o(e+32,t)},"syscall/js.valueSet":e=>{e=Number(e),Reflect.set(n(e+8),h(e+16),n(e+32))},"syscall/js.valueDelete":e=>{e=Number(e),Reflect.deleteProperty(n(e+8),h(e+16))},"syscall/js.valueIndex":e=>{e=Number(e),o(e+24,Reflect.get(n(e+8),s(e+16)))},"syscall/js.valueSetIndex":e=>{e=Number(e),Reflect.set(n(e+8),s(e+16),n(e+24))},"syscall/js.valueCall":e=>{e=Number(e);try{const t=n(e+8),l=Reflect.get(t,h(e+16)),a=m(e+32),g=Reflect.apply(l,t,a);e=Number(this._inst.exports.getsp()),o(e+56,g),this.mem.setUint8(e+64,1)}catch(t){e=Number(this._inst.exports.getsp()),o(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e=Number(e);try{const t=n(e+8),l=m(e+16),a=Reflect.apply(t,void 0,l);e=Number(this._inst.exports.getsp()),o(e+40,a),this.mem.setUint8(e+48,1)}catch(t){e=Number(this._inst.exports.getsp()),o(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e=Number(e);try{const t=n(e+8),l=m(e+16),a=Reflect.construct(t,l);e=Number(this._inst.exports.getsp()),o(e+40,a),this.mem.setUint8(e+48,1)}catch(t){e=Number(this._inst.exports.getsp()),o(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueLength":e=>{e=Number(e),u(e+16,parseInt(n(e+8).length))},"syscall/js.valuePrepareString":e=>{e=Number(e);const t=f.encode(String(n(e+8)));o(e+16,t),u(e+24,t.length)},"syscall/js.valueLoadString":e=>{e=Number(e);const t=n(e+8);c(e+16).set(t)},"syscall/js.valueInstanceOf":e=>{e=Number(e),this.mem.setUint8(e+24,n(e+8)instanceof n(e+16)?1:0)},"syscall/js.copyBytesToGo":e=>{e=Number(e);const t=c(e+8),l=n(e+32);if(!(l instanceof Uint8Array||l instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const a=l.subarray(0,t.length);t.set(a),u(e+40,a.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{e=Number(e);const t=n(e+8),l=c(e+16);if(!(t instanceof Uint8Array||t instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const a=l.subarray(0,t.length);t.set(a),u(e+40,a.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}async run(u){if(!(u instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=u,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let i=4096;const s=d=>{const e=i,t=f.encode(d+"\\0");return new Uint8Array(this.mem.buffer,i,t.length).set(t),i+=t.length,i%8!==0&&(i+=8-i%8),e},n=this.argv.length,o=[];this.argv.forEach(d=>{o.push(s(d))}),o.push(0),Object.keys(this.env).sort().forEach(d=>{o.push(s(`${d}=${this.env[d]}`))}),o.push(0);const m=i;o.forEach(d=>{this.mem.setUint32(i,d,!0),this.mem.setUint32(i+4,0,!0),i+=8});const h=4096+8192;if(i>=h)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(n,m),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(u){const i=this;return function(){const s={id:u,this:this,args:arguments};return i._pendingEvent=s,i._resume(),s.result}}}})(),onmessage=({data:r})=>{let f=new TextDecoder,y=globalThis.fs,u="";y.writeSync=(c,m)=>{if(c===1)postMessage(m);else if(c===2){u+=f.decode(m);let h=u.split(`\n`);h.length>1&&console.log(h.slice(0,-1).join(`\n`)),u=h[h.length-1]}else throw new Error("Bad write");return m.length};let i=[],s,n=0;onmessage=({data:c})=>{c.length>0&&(i.push(c),s&&s())},y.read=(c,m,h,d,e,t)=>{if(c!==0||h!==0||d!==m.length||e!==null)throw new Error("Bad read");if(i.length===0){s=()=>y.read(c,m,h,d,e,t);return}let l=i[0],a=Math.max(0,Math.min(d,l.length-n));m.set(l.subarray(n,n+a),h),n+=a,n===l.length&&(i.shift(),n=0),t(null,a)};let o=new globalThis.Go;o.argv=["","--service=0.17.1"],tryToInstantiateModule(r,o).then(c=>{postMessage(null),o.run(c)},c=>{postMessage(c)})};async function tryToInstantiateModule(r,f){if(r instanceof WebAssembly.Module)return WebAssembly.instantiate(r,f.importObject);const y=await fetch(r);if(!y.ok)throw new Error(`Failed to download ${JSON.stringify(r)}`);if("instantiateStreaming"in WebAssembly&&/^application\\/wasm($|;)/i.test(y.headers.get("Content-Type")||""))return(await WebAssembly.instantiateStreaming(y,f.importObject)).instance;const u=await y.arrayBuffer();return(await WebAssembly.instantiate(u,f.importObject)).instance}return r=>onmessage(r);})(postMessage)'],{type:"text/javascript"});l=new Worker(URL.createObjectURL(v))}else{let v=(postMessage=>{
|
|
12
|
+
error: ${d.text}`;let{file:y,line:w,column:v}=d.location,P=d.pluginName?`[plugin: ${d.pluginName}] `:"";return`
|
|
13
|
+
${y}:${w}:${v}: ERROR: ${P}${d.text}`}).join(""),i=new Error(`${e}${f}`);return i.errors=t,i.warnings=n,i}function oe(e,t){for(let n of e)n.detail=t.load(n.detail);return e}function Ce(e,t){if(e==null)return null;let n={},l=r(e,n,"file",h),f=r(e,n,"namespace",h),i=r(e,n,"line",se),d=r(e,n,"column",se),s=r(e,n,"length",se),y=r(e,n,"lineText",h),w=r(e,n,"suggestion",h);return K(e,n,t),{file:l||"",namespace:f||"",line:i||0,column:d||0,length:s||0,lineText:y||"",suggestion:w||""}}function te(e,t,n,l){let f=[],i=0;for(let d of e){let s={},y=r(d,s,"id",h),w=r(d,s,"pluginName",h),v=r(d,s,"text",h),P=r(d,s,"location",Me),U=r(d,s,"notes",z),B=r(d,s,"detail",me),j=`in element ${i} of "${t}"`;K(d,s,j);let Q=[];if(U)for(let T of U){let W={},Y=r(T,W,"text",h),R=r(T,W,"location",Me);K(T,W,j),Q.push({text:Y||"",location:Ce(R,j)})}f.push({id:y||"",pluginName:w||l,text:v||"",location:Ce(P,j),notes:Q,detail:n?n.store(B):-1}),i++}return f}function ge(e,t){let n=[];for(let l of e){if(typeof l!="string")throw new Error(`${V(t)} must be an array of strings`);n.push(l)}return n}function Ze({path:e,contents:t}){let n=null;return{path:e,contents:t,get text(){let l=this.contents;return(n===null||l!==t)&&(t=l,n=re(l)),n}}}var tt="0.17.2",nt=e=>ce().build(e),rt=e=>ce().context(e),it=(e,t)=>ce().transform(e,t),lt=(e,t)=>ce().formatMessages(e,t),st=(e,t)=>ce().analyzeMetafile(e,t),ot=()=>{throw new Error('The "buildSync" API only works in node')},at=()=>{throw new Error('The "transformSync" API only works in node')},ut=()=>{throw new Error('The "formatMessagesSync" API only works in node')},ct=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},ae,Oe,ce=()=>{if(Oe)return Oe;throw ae?new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this'):new Error('You need to call "initialize" before calling this')},ft=e=>{e=Fe(e||{});let t=e.wasmURL,n=e.wasmModule,l=e.worker!==!1;if(!t&&!n)throw new Error('Must provide either the "wasmURL" option or the "wasmModule" option');if(ae)throw new Error('Cannot call "initialize" more than once');return ae=dt(t||"",n,l),ae.catch(()=>{ae=void 0}),ae},dt=async(e,t,n)=>{let l;if(n){let w=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.\nlet onmessage,globalThis={};for(let r=self;r;r=Object.getPrototypeOf(r))for(let f of Object.getOwnPropertyNames(r))f in globalThis||Object.defineProperty(globalThis,f,{get:()=>self[f]});(()=>{const r=()=>{const u=new Error("not implemented");return u.code="ENOSYS",u};if(!globalThis.fs){let u="";globalThis.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(i,s){u+=y.decode(s);const n=u.lastIndexOf(`\n`);return n!=-1&&(console.log(u.substring(0,n)),u=u.substring(n+1)),s.length},write(i,s,n,o,c,m){if(n!==0||o!==s.length||c!==null){m(r());return}const h=this.writeSync(i,s);m(null,h)},chmod(i,s,n){n(r())},chown(i,s,n,o){o(r())},close(i,s){s(r())},fchmod(i,s,n){n(r())},fchown(i,s,n,o){o(r())},fstat(i,s){s(r())},fsync(i,s){s(null)},ftruncate(i,s,n){n(r())},lchown(i,s,n,o){o(r())},link(i,s,n){n(r())},lstat(i,s){s(r())},mkdir(i,s,n){n(r())},open(i,s,n,o){o(r())},read(i,s,n,o,c,m){m(r())},readdir(i,s){s(r())},readlink(i,s){s(r())},rename(i,s,n){n(r())},rmdir(i,s){s(r())},stat(i,s){s(r())},symlink(i,s,n){n(r())},truncate(i,s,n){n(r())},unlink(i,s){s(r())},utimes(i,s,n,o){o(r())}}}if(globalThis.process||(globalThis.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw r()},pid:-1,ppid:-1,umask(){throw r()},cwd(){throw r()},chdir(){throw r()}}),!globalThis.crypto)throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");if(!globalThis.performance)throw new Error("globalThis.performance is not available, polyfill required (performance.now only)");if(!globalThis.TextEncoder)throw new Error("globalThis.TextEncoder is not available, polyfill required");if(!globalThis.TextDecoder)throw new Error("globalThis.TextDecoder is not available, polyfill required");const f=new TextEncoder("utf-8"),y=new TextDecoder("utf-8");globalThis.Go=class{constructor(){this.argv=["js"],this.env={},this.exit=e=>{e!==0&&console.warn("exit code:",e)},this._exitPromise=new Promise(e=>{this._resolveExitPromise=e}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;const u=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},i=(e,t)=>{this.mem.setUint32(e+0,t,!0)},s=e=>{const t=this.mem.getUint32(e+0,!0),l=this.mem.getInt32(e+4,!0);return t+l*4294967296},n=e=>{const t=this.mem.getFloat64(e,!0);if(t===0)return;if(!isNaN(t))return t;const l=this.mem.getUint32(e,!0);return this._values[l]},o=(e,t)=>{if(typeof t=="number"&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,2146959360,!0),this.mem.setUint32(e,0,!0);return}this.mem.setFloat64(e,t,!0);return}if(t===void 0){this.mem.setFloat64(e,0,!0);return}let a=this._ids.get(t);a===void 0&&(a=this._idPool.pop(),a===void 0&&(a=this._values.length),this._values[a]=t,this._goRefCounts[a]=0,this._ids.set(t,a)),this._goRefCounts[a]++;let g=0;switch(typeof t){case"object":t!==null&&(g=1);break;case"string":g=2;break;case"symbol":g=3;break;case"function":g=4;break}this.mem.setUint32(e+4,2146959360|g,!0),this.mem.setUint32(e,a,!0)},c=e=>{const t=s(e+0),l=s(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,l)},m=e=>{const t=s(e+0),l=s(e+8),a=new Array(l);for(let g=0;g<l;g++)a[g]=n(t+g*8);return a},h=e=>{const t=s(e+0),l=s(e+8);return y.decode(new DataView(this._inst.exports.mem.buffer,t,l))},d=Date.now()-performance.now();this.importObject={_gotest:{add:(e,t)=>e+t},gojs:{"runtime.wasmExit":e=>{e=Number(e);const t=this.mem.getInt32(e+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(t)},"runtime.wasmWrite":e=>{e=Number(e);const t=s(e+8),l=s(e+16),a=this.mem.getInt32(e+24,!0);globalThis.fs.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,l,a))},"runtime.resetMemoryDataView":e=>{e=Number(e),this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":e=>{e=Number(e),u(e+8,(d+performance.now())*1e6)},"runtime.walltime":e=>{e=Number(e);const t=new Date().getTime();u(e+8,t/1e3),this.mem.setInt32(e+16,t%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":e=>{e=Number(e);const t=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(t,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(t);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},s(e+8))),this.mem.setInt32(e+16,t,!0)},"runtime.clearTimeoutEvent":e=>{e=Number(e);const t=this.mem.getInt32(e+8,!0);clearTimeout(this._scheduledTimeouts.get(t)),this._scheduledTimeouts.delete(t)},"runtime.getRandomData":e=>{e=Number(e),crypto.getRandomValues(c(e+8))},"syscall/js.finalizeRef":e=>{e=Number(e);const t=this.mem.getUint32(e+8,!0);if(this._goRefCounts[t]--,this._goRefCounts[t]===0){const l=this._values[t];this._values[t]=null,this._ids.delete(l),this._idPool.push(t)}},"syscall/js.stringVal":e=>{e=Number(e),o(e+24,h(e+8))},"syscall/js.valueGet":e=>{e=Number(e);const t=Reflect.get(n(e+8),h(e+16));e=Number(this._inst.exports.getsp()),o(e+32,t)},"syscall/js.valueSet":e=>{e=Number(e),Reflect.set(n(e+8),h(e+16),n(e+32))},"syscall/js.valueDelete":e=>{e=Number(e),Reflect.deleteProperty(n(e+8),h(e+16))},"syscall/js.valueIndex":e=>{e=Number(e),o(e+24,Reflect.get(n(e+8),s(e+16)))},"syscall/js.valueSetIndex":e=>{e=Number(e),Reflect.set(n(e+8),s(e+16),n(e+24))},"syscall/js.valueCall":e=>{e=Number(e);try{const t=n(e+8),l=Reflect.get(t,h(e+16)),a=m(e+32),g=Reflect.apply(l,t,a);e=Number(this._inst.exports.getsp()),o(e+56,g),this.mem.setUint8(e+64,1)}catch(t){e=Number(this._inst.exports.getsp()),o(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e=Number(e);try{const t=n(e+8),l=m(e+16),a=Reflect.apply(t,void 0,l);e=Number(this._inst.exports.getsp()),o(e+40,a),this.mem.setUint8(e+48,1)}catch(t){e=Number(this._inst.exports.getsp()),o(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e=Number(e);try{const t=n(e+8),l=m(e+16),a=Reflect.construct(t,l);e=Number(this._inst.exports.getsp()),o(e+40,a),this.mem.setUint8(e+48,1)}catch(t){e=Number(this._inst.exports.getsp()),o(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueLength":e=>{e=Number(e),u(e+16,parseInt(n(e+8).length))},"syscall/js.valuePrepareString":e=>{e=Number(e);const t=f.encode(String(n(e+8)));o(e+16,t),u(e+24,t.length)},"syscall/js.valueLoadString":e=>{e=Number(e);const t=n(e+8);c(e+16).set(t)},"syscall/js.valueInstanceOf":e=>{e=Number(e),this.mem.setUint8(e+24,n(e+8)instanceof n(e+16)?1:0)},"syscall/js.copyBytesToGo":e=>{e=Number(e);const t=c(e+8),l=n(e+32);if(!(l instanceof Uint8Array||l instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const a=l.subarray(0,t.length);t.set(a),u(e+40,a.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{e=Number(e);const t=n(e+8),l=c(e+16);if(!(t instanceof Uint8Array||t instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const a=l.subarray(0,t.length);t.set(a),u(e+40,a.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}async run(u){if(!(u instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=u,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let i=4096;const s=d=>{const e=i,t=f.encode(d+"\\0");return new Uint8Array(this.mem.buffer,i,t.length).set(t),i+=t.length,i%8!==0&&(i+=8-i%8),e},n=this.argv.length,o=[];this.argv.forEach(d=>{o.push(s(d))}),o.push(0),Object.keys(this.env).sort().forEach(d=>{o.push(s(`${d}=${this.env[d]}`))}),o.push(0);const m=i;o.forEach(d=>{this.mem.setUint32(i,d,!0),this.mem.setUint32(i+4,0,!0),i+=8});const h=4096+8192;if(i>=h)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(n,m),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(u){const i=this;return function(){const s={id:u,this:this,args:arguments};return i._pendingEvent=s,i._resume(),s.result}}}})(),onmessage=({data:r})=>{let f=new TextDecoder,y=globalThis.fs,u="";y.writeSync=(c,m)=>{if(c===1)postMessage(m);else if(c===2){u+=f.decode(m);let h=u.split(`\n`);h.length>1&&console.log(h.slice(0,-1).join(`\n`)),u=h[h.length-1]}else throw new Error("Bad write");return m.length};let i=[],s,n=0;onmessage=({data:c})=>{c.length>0&&(i.push(c),s&&s())},y.read=(c,m,h,d,e,t)=>{if(c!==0||h!==0||d!==m.length||e!==null)throw new Error("Bad read");if(i.length===0){s=()=>y.read(c,m,h,d,e,t);return}let l=i[0],a=Math.max(0,Math.min(d,l.length-n));m.set(l.subarray(n,n+a),h),n+=a,n===l.length&&(i.shift(),n=0),t(null,a)};let o=new globalThis.Go;o.argv=["","--service=0.17.2"],tryToInstantiateModule(r,o).then(c=>{postMessage(null),o.run(c)},c=>{postMessage(c)})};async function tryToInstantiateModule(r,f){if(r instanceof WebAssembly.Module)return WebAssembly.instantiate(r,f.importObject);const y=await fetch(r);if(!y.ok)throw new Error(`Failed to download ${JSON.stringify(r)}`);if("instantiateStreaming"in WebAssembly&&/^application\\/wasm($|;)/i.test(y.headers.get("Content-Type")||""))return(await WebAssembly.instantiateStreaming(y,f.importObject)).instance;const u=await y.arrayBuffer();return(await WebAssembly.instantiate(u,f.importObject)).instance}return r=>onmessage(r);})(postMessage)'],{type:"text/javascript"});l=new Worker(URL.createObjectURL(w))}else{let w=(postMessage=>{
|
|
14
14
|
// Copyright 2018 The Go Authors. All rights reserved.
|
|
15
15
|
// Use of this source code is governed by a BSD-style
|
|
16
16
|
// license that can be found in the LICENSE file.
|
|
17
17
|
let onmessage,globalThis={};for(let r=self;r;r=Object.getPrototypeOf(r))for(let f of Object.getOwnPropertyNames(r))f in globalThis||Object.defineProperty(globalThis,f,{get:()=>self[f]});(()=>{const r=()=>{const u=new Error("not implemented");return u.code="ENOSYS",u};if(!globalThis.fs){let u="";globalThis.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(i,s){u+=y.decode(s);const n=u.lastIndexOf(`
|
|
18
18
|
`);return n!=-1&&(console.log(u.substring(0,n)),u=u.substring(n+1)),s.length},write(i,s,n,o,c,m){if(n!==0||o!==s.length||c!==null){m(r());return}const h=this.writeSync(i,s);m(null,h)},chmod(i,s,n){n(r())},chown(i,s,n,o){o(r())},close(i,s){s(r())},fchmod(i,s,n){n(r())},fchown(i,s,n,o){o(r())},fstat(i,s){s(r())},fsync(i,s){s(null)},ftruncate(i,s,n){n(r())},lchown(i,s,n,o){o(r())},link(i,s,n){n(r())},lstat(i,s){s(r())},mkdir(i,s,n){n(r())},open(i,s,n,o){o(r())},read(i,s,n,o,c,m){m(r())},readdir(i,s){s(r())},readlink(i,s){s(r())},rename(i,s,n){n(r())},rmdir(i,s){s(r())},stat(i,s){s(r())},symlink(i,s,n){n(r())},truncate(i,s,n){n(r())},unlink(i,s){s(r())},utimes(i,s,n,o){o(r())}}}if(globalThis.process||(globalThis.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw r()},pid:-1,ppid:-1,umask(){throw r()},cwd(){throw r()},chdir(){throw r()}}),!globalThis.crypto)throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");if(!globalThis.performance)throw new Error("globalThis.performance is not available, polyfill required (performance.now only)");if(!globalThis.TextEncoder)throw new Error("globalThis.TextEncoder is not available, polyfill required");if(!globalThis.TextDecoder)throw new Error("globalThis.TextDecoder is not available, polyfill required");const f=new TextEncoder("utf-8"),y=new TextDecoder("utf-8");globalThis.Go=class{constructor(){this.argv=["js"],this.env={},this.exit=e=>{e!==0&&console.warn("exit code:",e)},this._exitPromise=new Promise(e=>{this._resolveExitPromise=e}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;const u=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},i=(e,t)=>{this.mem.setUint32(e+0,t,!0)},s=e=>{const t=this.mem.getUint32(e+0,!0),l=this.mem.getInt32(e+4,!0);return t+l*4294967296},n=e=>{const t=this.mem.getFloat64(e,!0);if(t===0)return;if(!isNaN(t))return t;const l=this.mem.getUint32(e,!0);return this._values[l]},o=(e,t)=>{if(typeof t=="number"&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,2146959360,!0),this.mem.setUint32(e,0,!0);return}this.mem.setFloat64(e,t,!0);return}if(t===void 0){this.mem.setFloat64(e,0,!0);return}let a=this._ids.get(t);a===void 0&&(a=this._idPool.pop(),a===void 0&&(a=this._values.length),this._values[a]=t,this._goRefCounts[a]=0,this._ids.set(t,a)),this._goRefCounts[a]++;let g=0;switch(typeof t){case"object":t!==null&&(g=1);break;case"string":g=2;break;case"symbol":g=3;break;case"function":g=4;break}this.mem.setUint32(e+4,2146959360|g,!0),this.mem.setUint32(e,a,!0)},c=e=>{const t=s(e+0),l=s(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,l)},m=e=>{const t=s(e+0),l=s(e+8),a=new Array(l);for(let g=0;g<l;g++)a[g]=n(t+g*8);return a},h=e=>{const t=s(e+0),l=s(e+8);return y.decode(new DataView(this._inst.exports.mem.buffer,t,l))},d=Date.now()-performance.now();this.importObject={_gotest:{add:(e,t)=>e+t},gojs:{"runtime.wasmExit":e=>{e=Number(e);const t=this.mem.getInt32(e+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(t)},"runtime.wasmWrite":e=>{e=Number(e);const t=s(e+8),l=s(e+16),a=this.mem.getInt32(e+24,!0);globalThis.fs.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,l,a))},"runtime.resetMemoryDataView":e=>{e=Number(e),this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":e=>{e=Number(e),u(e+8,(d+performance.now())*1e6)},"runtime.walltime":e=>{e=Number(e);const t=new Date().getTime();u(e+8,t/1e3),this.mem.setInt32(e+16,t%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":e=>{e=Number(e);const t=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(t,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(t);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},s(e+8))),this.mem.setInt32(e+16,t,!0)},"runtime.clearTimeoutEvent":e=>{e=Number(e);const t=this.mem.getInt32(e+8,!0);clearTimeout(this._scheduledTimeouts.get(t)),this._scheduledTimeouts.delete(t)},"runtime.getRandomData":e=>{e=Number(e),crypto.getRandomValues(c(e+8))},"syscall/js.finalizeRef":e=>{e=Number(e);const t=this.mem.getUint32(e+8,!0);if(this._goRefCounts[t]--,this._goRefCounts[t]===0){const l=this._values[t];this._values[t]=null,this._ids.delete(l),this._idPool.push(t)}},"syscall/js.stringVal":e=>{e=Number(e),o(e+24,h(e+8))},"syscall/js.valueGet":e=>{e=Number(e);const t=Reflect.get(n(e+8),h(e+16));e=Number(this._inst.exports.getsp()),o(e+32,t)},"syscall/js.valueSet":e=>{e=Number(e),Reflect.set(n(e+8),h(e+16),n(e+32))},"syscall/js.valueDelete":e=>{e=Number(e),Reflect.deleteProperty(n(e+8),h(e+16))},"syscall/js.valueIndex":e=>{e=Number(e),o(e+24,Reflect.get(n(e+8),s(e+16)))},"syscall/js.valueSetIndex":e=>{e=Number(e),Reflect.set(n(e+8),s(e+16),n(e+24))},"syscall/js.valueCall":e=>{e=Number(e);try{const t=n(e+8),l=Reflect.get(t,h(e+16)),a=m(e+32),g=Reflect.apply(l,t,a);e=Number(this._inst.exports.getsp()),o(e+56,g),this.mem.setUint8(e+64,1)}catch(t){e=Number(this._inst.exports.getsp()),o(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e=Number(e);try{const t=n(e+8),l=m(e+16),a=Reflect.apply(t,void 0,l);e=Number(this._inst.exports.getsp()),o(e+40,a),this.mem.setUint8(e+48,1)}catch(t){e=Number(this._inst.exports.getsp()),o(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e=Number(e);try{const t=n(e+8),l=m(e+16),a=Reflect.construct(t,l);e=Number(this._inst.exports.getsp()),o(e+40,a),this.mem.setUint8(e+48,1)}catch(t){e=Number(this._inst.exports.getsp()),o(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueLength":e=>{e=Number(e),u(e+16,parseInt(n(e+8).length))},"syscall/js.valuePrepareString":e=>{e=Number(e);const t=f.encode(String(n(e+8)));o(e+16,t),u(e+24,t.length)},"syscall/js.valueLoadString":e=>{e=Number(e);const t=n(e+8);c(e+16).set(t)},"syscall/js.valueInstanceOf":e=>{e=Number(e),this.mem.setUint8(e+24,n(e+8)instanceof n(e+16)?1:0)},"syscall/js.copyBytesToGo":e=>{e=Number(e);const t=c(e+8),l=n(e+32);if(!(l instanceof Uint8Array||l instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const a=l.subarray(0,t.length);t.set(a),u(e+40,a.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{e=Number(e);const t=n(e+8),l=c(e+16);if(!(t instanceof Uint8Array||t instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const a=l.subarray(0,t.length);t.set(a),u(e+40,a.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}async run(u){if(!(u instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=u,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let i=4096;const s=d=>{const e=i,t=f.encode(d+"\0");return new Uint8Array(this.mem.buffer,i,t.length).set(t),i+=t.length,i%8!==0&&(i+=8-i%8),e},n=this.argv.length,o=[];this.argv.forEach(d=>{o.push(s(d))}),o.push(0),Object.keys(this.env).sort().forEach(d=>{o.push(s(`${d}=${this.env[d]}`))}),o.push(0);const m=i;o.forEach(d=>{this.mem.setUint32(i,d,!0),this.mem.setUint32(i+4,0,!0),i+=8});const h=4096+8192;if(i>=h)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(n,m),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(u){const i=this;return function(){const s={id:u,this:this,args:arguments};return i._pendingEvent=s,i._resume(),s.result}}}})(),onmessage=({data:r})=>{let f=new TextDecoder,y=globalThis.fs,u="";y.writeSync=(c,m)=>{if(c===1)postMessage(m);else if(c===2){u+=f.decode(m);let h=u.split(`
|
|
19
19
|
`);h.length>1&&console.log(h.slice(0,-1).join(`
|
|
20
|
-
`)),u=h[h.length-1]}else throw new Error("Bad write");return m.length};let i=[],s,n=0;onmessage=({data:c})=>{c.length>0&&(i.push(c),s&&s())},y.read=(c,m,h,d,e,t)=>{if(c!==0||h!==0||d!==m.length||e!==null)throw new Error("Bad read");if(i.length===0){s=()=>y.read(c,m,h,d,e,t);return}let l=i[0],a=Math.max(0,Math.min(d,l.length-n));m.set(l.subarray(n,n+a),h),n+=a,n===l.length&&(i.shift(),n=0),t(null,a)};let o=new globalThis.Go;o.argv=["","--service=0.17.
|
|
20
|
+
`)),u=h[h.length-1]}else throw new Error("Bad write");return m.length};let i=[],s,n=0;onmessage=({data:c})=>{c.length>0&&(i.push(c),s&&s())},y.read=(c,m,h,d,e,t)=>{if(c!==0||h!==0||d!==m.length||e!==null)throw new Error("Bad read");if(i.length===0){s=()=>y.read(c,m,h,d,e,t);return}let l=i[0],a=Math.max(0,Math.min(d,l.length-n));m.set(l.subarray(n,n+a),h),n+=a,n===l.length&&(i.shift(),n=0),t(null,a)};let o=new globalThis.Go;o.argv=["","--service=0.17.2"],tryToInstantiateModule(r,o).then(c=>{postMessage(null),o.run(c)},c=>{postMessage(c)})};async function tryToInstantiateModule(r,f){if(r instanceof WebAssembly.Module)return WebAssembly.instantiate(r,f.importObject);const y=await fetch(r);if(!y.ok)throw new Error(`Failed to download ${JSON.stringify(r)}`);if("instantiateStreaming"in WebAssembly&&/^application\/wasm($|;)/i.test(y.headers.get("Content-Type")||""))return(await WebAssembly.instantiateStreaming(y,f.importObject)).instance;const u=await y.arrayBuffer();return(await WebAssembly.instantiate(u,f.importObject)).instance}return r=>onmessage(r);})(v=>l.onmessage({data:v}));l={onmessage:null,postMessage:v=>setTimeout(()=>w({data:v})),terminate(){}}}let f,i,d=new Promise((w,v)=>{f=w,i=v});l.onmessage=({data:w})=>{l.onmessage=({data:v})=>s(v),w?i(w):f()},l.postMessage(t||new URL(e,location.href).toString());let{readFromStdout:s,service:y}=Ue({writeToStdin(w){l.postMessage(w)},isSync:!1,hasFS:!1,esbuild:be});await d,Oe={build:w=>new Promise((v,P)=>y.buildOrContext({callName:"build",refs:null,options:w,isTTY:!1,defaultWD:"/",callback:(U,B)=>U?P(U):v(B)})),context:w=>new Promise((v,P)=>y.buildOrContext({callName:"context",refs:null,options:w,isTTY:!1,defaultWD:"/",callback:(U,B)=>U?P(U):v(B)})),transform:(w,v)=>new Promise((P,U)=>y.transform({callName:"transform",refs:null,input:w,options:v||{},isTTY:!1,fs:{readFile(B,j){j(new Error("Internal error"),null)},writeFile(B,j){j(null)}},callback:(B,j)=>B?U(B):P(j)})),formatMessages:(w,v)=>new Promise((P,U)=>y.formatMessages({callName:"formatMessages",refs:null,messages:w,options:v,callback:(B,j)=>B?U(B):P(j)})),analyzeMetafile:(w,v)=>new Promise((P,U)=>y.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof w=="string"?w:JSON.stringify(w),options:v,callback:(B,j)=>B?U(B):P(j)}))}},pt=be;export{st as analyzeMetafile,ct as analyzeMetafileSync,nt as build,ot as buildSync,rt as context,pt as default,lt as formatMessages,ut as formatMessagesSync,ft as initialize,it as transform,at as transformSync,tt as version};
|
package/lib/browser.d.ts
CHANGED
|
@@ -296,6 +296,9 @@ export interface PluginBuild {
|
|
|
296
296
|
onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) =>
|
|
297
297
|
(OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void
|
|
298
298
|
|
|
299
|
+
/** Documentation: https://esbuild.github.io/plugins/#on-dispose */
|
|
300
|
+
onDispose(callback: () => void): void
|
|
301
|
+
|
|
299
302
|
// This is a full copy of the esbuild library in case you need it
|
|
300
303
|
esbuild: {
|
|
301
304
|
context: typeof context,
|
|
@@ -489,7 +492,7 @@ export interface BuildContext<SpecificOptions extends BuildOptions = BuildOption
|
|
|
489
492
|
rebuild(): Promise<BuildResult<SpecificOptions>>
|
|
490
493
|
|
|
491
494
|
/** Documentation: https://esbuild.github.io/api/#watch */
|
|
492
|
-
watch(options?: WatchOptions): void
|
|
495
|
+
watch(options?: WatchOptions): Promise<void>
|
|
493
496
|
|
|
494
497
|
/** Documentation: https://esbuild.github.io/api/#serve */
|
|
495
498
|
serve(options?: ServeOptions): Promise<ServeResult>
|