esbuild-wasm-strapkit 0.25.0-build.1 → 0.25.2-build.1
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/README.md +3 -3
- package/esbuild.wasm +0 -0
- package/esm/browser.js +14 -9
- package/esm/browser.min.js +6 -6
- package/lib/browser.js +14 -9
- package/lib/browser.min.js +6 -6
- package/lib/main.js +16 -11
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# esbuild-wasm-strapkit
|
|
2
2
|
|
|
3
|
-
[esbuild-wasm](https://www.npmjs.com/package/esbuild-wasm) **0.25.
|
|
3
|
+
[esbuild-wasm](https://www.npmjs.com/package/esbuild-wasm) **0.25.2**, unchanged,
|
|
4
4
|
compiled with a Go toolchain patched to target 64-bit wasm memory (memory64), so
|
|
5
5
|
the esbuild service isn't capped at a 4GB heap on large projects. The API is
|
|
6
6
|
esbuild-wasm's; use it as a drop-in alias:
|
|
7
7
|
|
|
8
|
-
npm install esbuild-wasm@npm:esbuild-wasm-strapkit@esbuild-0.25.
|
|
8
|
+
npm install esbuild-wasm@npm:esbuild-wasm-strapkit@esbuild-0.25.2
|
|
9
9
|
|
|
10
10
|
The runtime needs wasm memory64: Chrome 133+, Firefox 134+, Node 24+ (or a Node
|
|
11
11
|
22 that enables it by default).
|
|
12
12
|
|
|
13
13
|
The `-build.N` suffix only changes when this build is refreshed; the
|
|
14
|
-
`esbuild-0.25.
|
|
14
|
+
`esbuild-0.25.2` tag always points at the newest build.
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
package/esbuild.wasm
CHANGED
|
Binary file
|
package/esm/browser.js
CHANGED
|
@@ -327,8 +327,8 @@ function pushCommonFlags(flags, options, keys) {
|
|
|
327
327
|
if (ignoreAnnotations) flags.push(`--ignore-annotations`);
|
|
328
328
|
if (drop) for (let what of drop) flags.push(`--drop:${validateStringValue(what, "drop")}`);
|
|
329
329
|
if (dropLabels) flags.push(`--drop-labels=${Array.from(dropLabels).map((what) => validateStringValue(what, "dropLabels")).join(",")}`);
|
|
330
|
-
if (mangleProps) flags.push(`--mangle-props=${mangleProps
|
|
331
|
-
if (reserveProps) flags.push(`--reserve-props=${reserveProps
|
|
330
|
+
if (mangleProps) flags.push(`--mangle-props=${jsRegExpToGoRegExp(mangleProps)}`);
|
|
331
|
+
if (reserveProps) flags.push(`--reserve-props=${jsRegExpToGoRegExp(reserveProps)}`);
|
|
332
332
|
if (mangleQuoted !== void 0) flags.push(`--mangle-quoted=${mangleQuoted}`);
|
|
333
333
|
if (jsx) flags.push(`--jsx=${jsx}`);
|
|
334
334
|
if (jsxFactory) flags.push(`--jsx-factory=${jsxFactory}`);
|
|
@@ -639,8 +639,8 @@ function createChannel(streamIn) {
|
|
|
639
639
|
if (isFirstPacket) {
|
|
640
640
|
isFirstPacket = false;
|
|
641
641
|
let binaryVersion = String.fromCharCode(...bytes);
|
|
642
|
-
if (binaryVersion !== "0.25.
|
|
643
|
-
throw new Error(`Cannot start service: Host version "${"0.25.
|
|
642
|
+
if (binaryVersion !== "0.25.2") {
|
|
643
|
+
throw new Error(`Cannot start service: Host version "${"0.25.2"}" does not match binary version ${quote(binaryVersion)}`);
|
|
644
644
|
}
|
|
645
645
|
return;
|
|
646
646
|
}
|
|
@@ -1149,7 +1149,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
|
1149
1149
|
if (filter == null) throw new Error(`onResolve() call is missing a filter`);
|
|
1150
1150
|
let id = nextCallbackID++;
|
|
1151
1151
|
onResolveCallbacks[id] = { name, callback, note: registeredNote };
|
|
1152
|
-
plugin.onResolve.push({ id, filter: filter
|
|
1152
|
+
plugin.onResolve.push({ id, filter: jsRegExpToGoRegExp(filter), namespace: namespace || "" });
|
|
1153
1153
|
},
|
|
1154
1154
|
onLoad(options, callback) {
|
|
1155
1155
|
let registeredText = `This error came from the "onLoad" callback registered here:`;
|
|
@@ -1161,7 +1161,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
|
1161
1161
|
if (filter == null) throw new Error(`onLoad() call is missing a filter`);
|
|
1162
1162
|
let id = nextCallbackID++;
|
|
1163
1163
|
onLoadCallbacks[id] = { name, callback, note: registeredNote };
|
|
1164
|
-
plugin.onLoad.push({ id, filter: filter
|
|
1164
|
+
plugin.onLoad.push({ id, filter: jsRegExpToGoRegExp(filter), namespace: namespace || "" });
|
|
1165
1165
|
},
|
|
1166
1166
|
onDispose(callback) {
|
|
1167
1167
|
onDisposeCallbacks.push(callback);
|
|
@@ -1572,9 +1572,14 @@ function convertOutputFiles({ path, contents, hash }) {
|
|
|
1572
1572
|
}
|
|
1573
1573
|
};
|
|
1574
1574
|
}
|
|
1575
|
+
function jsRegExpToGoRegExp(regexp) {
|
|
1576
|
+
let result = regexp.source;
|
|
1577
|
+
if (regexp.flags) result = `(?${regexp.flags})${result}`;
|
|
1578
|
+
return result;
|
|
1579
|
+
}
|
|
1575
1580
|
|
|
1576
1581
|
// lib/npm/browser.ts
|
|
1577
|
-
var version = "0.25.
|
|
1582
|
+
var version = "0.25.2";
|
|
1578
1583
|
var build = (options) => ensureServiceIsRunning().build(options);
|
|
1579
1584
|
var context = (options) => ensureServiceIsRunning().context(options);
|
|
1580
1585
|
var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
|
|
@@ -1622,7 +1627,7 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
|
1622
1627
|
let rejectAllWith;
|
|
1623
1628
|
const rejectAllPromise = new Promise((resolve) => rejectAllWith = resolve);
|
|
1624
1629
|
if (useWorker) {
|
|
1625
|
-
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 = (/* @__PURE__ */ 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) 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) resumeStdin();\n }\n return go;\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.25.0"}`];\n tryToInstantiateModule(wasm, go).then(\n (instance) => {\n postMessage(null);\n go.run(instance);\n },\n (error) => {\n postMessage(error);\n }\n );\n return go;\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) 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" });
|
|
1630
|
+
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 = (/* @__PURE__ */ 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) 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) resumeStdin();\n }\n return go;\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.25.2"}`];\n tryToInstantiateModule(wasm, go).then(\n (instance) => {\n postMessage(null);\n go.run(instance);\n },\n (error) => {\n postMessage(error);\n }\n );\n return go;\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) 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" });
|
|
1626
1631
|
worker = new Worker(URL.createObjectURL(blob));
|
|
1627
1632
|
} else {
|
|
1628
1633
|
let onmessage = ((postMessage) => {
|
|
@@ -2240,7 +2245,7 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
|
2240
2245
|
callback(null, count);
|
|
2241
2246
|
};
|
|
2242
2247
|
let go = new globalThis.Go();
|
|
2243
|
-
go.argv = ["", `--service=${"0.25.
|
|
2248
|
+
go.argv = ["", `--service=${"0.25.2"}`];
|
|
2244
2249
|
tryToInstantiateModule(wasm, go).then(
|
|
2245
2250
|
(instance) => {
|
|
2246
2251
|
postMessage(null);
|
package/esm/browser.min.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Ke=Object.defineProperty;var _e=(e,t)=>{for(var n in t)Ke(e,n,{get:t[n],enumerable:!0})};var Re={};_e(Re,{analyzeMetafile:()=>ft,analyzeMetafileSync:()=>mt,build:()=>ot,buildSync:()=>dt,context:()=>at,default:()=>wt,formatMessages:()=>ct,formatMessagesSync:()=>gt,initialize:()=>ht,stop:()=>yt,transform:()=>ut,transformSync:()=>pt,version:()=>st});function Ee(e){let t=i=>{if(i===null)n.write8(0);else if(typeof i=="boolean")n.write8(1),n.write8(+i);else if(typeof i=="number")n.write8(2),n.write32(i|0);else if(typeof i=="string")n.write8(3),n.write(Z(i));else if(i instanceof Uint8Array)n.write8(4),n.write(i);else if(i instanceof Array){n.write8(5),n.write32(i.length);for(let u of i)t(u)}else{let u=Object.keys(i);n.write8(6),n.write32(u.length);for(let l of u)n.write(Z(l)),t(i[l])}},n=new de;return n.write32(0),n.write32(e.id<<1|+!e.isRequest),t(e.value),Oe(n.buf,n.len-4,0),n.buf.subarray(0,n.len)}function ke(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 g=n.read32(),s=[];for(let m=0;m<g;m++)s.push(t());return s}case 6:{let g=n.read32(),s={};for(let m=0;m<g;m++)s[re(n.read())]=t();return s}default:throw new Error("Invalid packet")}},n=new de(e),i=n.read32(),u=(i&1)===0;i>>>=1;let l=t();if(n.ptr!==e.length)throw new Error("Invalid packet");return{id:i,isRequest:u,value:l}}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);Oe(this.buf,t,n)}write(t){let n=this._write(4+t.length);Oe(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 Se(this.buf,this._read(4))}read(){let t=this.read32(),n=new Uint8Array(t),i=this._read(n.length);return n.set(this.buf.subarray(i,i+t)),n}},Z,re,xe;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;Z=n=>e.encode(n),re=n=>t.decode(n),xe='new TextEncoder().encode("")'}else if(typeof Buffer!="undefined")Z=e=>Buffer.from(e),re=e=>{let{buffer:t,byteOffset:n,byteLength:i}=e;return Buffer.from(t,n,i).toString()},xe='Buffer.from("")';else throw new Error("No UTF-8 codec found");if(!(Z("")instanceof Uint8Array))throw new Error(`Invariant violation: "${xe} 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 Ee(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function xe(e,t,n){e[n++]=t,e[n++]=t>>8,e[n++]=t>>16,e[n++]=t>>24}var V=JSON.stringify,ke="warning",$e="silent";function Me(e){if(G(e,"target"),e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var me=()=>null,W=e=>typeof e=="boolean"?null:"a boolean",y=e=>typeof e=="string"?null:"a string",ye=e=>e instanceof RegExp?null:"a RegExp object",oe=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Ve=e=>typeof e=="number"&&e===(e|0)&&e>=0&&e<=65535?null:"a valid port number",Fe=e=>typeof e=="function"?null:"a function",K=e=>Array.isArray(e)?null:"an array",ee=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",Ye=e=>typeof e=="object"&&e!==null?null:"an array or an object",Je=e=>e instanceof WebAssembly.Module?null:"a WebAssembly.Module",Ce=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",Ge=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",Qe=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",Te=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array",He=e=>typeof e=="string"||e instanceof URL?null:"a string or a URL";function r(e,t,n,i){let u=e[n];if(t[n+""]=!0,u===void 0)return;let l=i(u);if(l!==null)throw new Error(`${V(n)} must be ${l}`);return u}function Y(e,t,n){for(let i in e)if(!(i in t))throw new Error(`Invalid option ${n}: ${V(i)}`)}function De(e){let t=Object.create(null),n=r(e,t,"wasmURL",He),i=r(e,t,"wasmModule",Je),u=r(e,t,"worker",W);return Y(e,t,"in initialize() call"),{wasmURL:n,wasmModule:i,worker:u}}function Be(e){let t;if(e!==void 0){t=Object.create(null);for(let n in e){let i=e[n];if(typeof i=="string"||i===!1)t[n]=i;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,i,u){let l=r(t,n,"color",W),g=r(t,n,"logLevel",y),s=r(t,n,"logLimit",oe);l!==void 0?e.push(`--color=${l}`):i&&e.push("--color=true"),e.push(`--log-level=${g||u}`),e.push(`--log-limit=${s||0}`)}function G(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 Ue(e,t,n){let i=r(t,n,"legalComments",y),u=r(t,n,"sourceRoot",y),l=r(t,n,"sourcesContent",W),g=r(t,n,"target",Qe),s=r(t,n,"format",y),m=r(t,n,"globalName",y),U=r(t,n,"mangleProps",ye),F=r(t,n,"reserveProps",ye),b=r(t,n,"mangleQuoted",W),j=r(t,n,"minify",W),T=r(t,n,"minifySyntax",W),L=r(t,n,"minifyWhitespace",W),N=r(t,n,"minifyIdentifiers",W),S=r(t,n,"lineLimit",oe),_=r(t,n,"drop",K),J=r(t,n,"dropLabels",K),w=r(t,n,"charset",y),p=r(t,n,"treeShaking",W),f=r(t,n,"ignoreAnnotations",W),o=r(t,n,"jsx",y),v=r(t,n,"jsxFactory",y),O=r(t,n,"jsxFragment",y),M=r(t,n,"jsxImportSource",y),E=r(t,n,"jsxDev",W),a=r(t,n,"jsxSideEffects",W),c=r(t,n,"define",ee),h=r(t,n,"logOverride",ee),C=r(t,n,"supported",ee),P=r(t,n,"pure",K),$=r(t,n,"keepNames",W),x=r(t,n,"platform",y),A=r(t,n,"tsconfigRaw",Ge);if(i&&e.push(`--legal-comments=${i}`),u!==void 0&&e.push(`--source-root=${u}`),l!==void 0&&e.push(`--sources-content=${l}`),g&&(Array.isArray(g)?e.push(`--target=${Array.from(g).map(Me).join(",")}`):e.push(`--target=${Me(g)}`)),s&&e.push(`--format=${s}`),m&&e.push(`--global-name=${m}`),x&&e.push(`--platform=${x}`),A&&e.push(`--tsconfig-raw=${typeof A=="string"?A:JSON.stringify(A)}`),j&&e.push("--minify"),T&&e.push("--minify-syntax"),L&&e.push("--minify-whitespace"),N&&e.push("--minify-identifiers"),S&&e.push(`--line-limit=${S}`),w&&e.push(`--charset=${w}`),p!==void 0&&e.push(`--tree-shaking=${p}`),f&&e.push("--ignore-annotations"),_)for(let R of _)e.push(`--drop:${G(R,"drop")}`);if(J&&e.push(`--drop-labels=${Array.from(J).map(R=>G(R,"dropLabels")).join(",")}`),U&&e.push(`--mangle-props=${U.source}`),F&&e.push(`--reserve-props=${F.source}`),b!==void 0&&e.push(`--mangle-quoted=${b}`),o&&e.push(`--jsx=${o}`),v&&e.push(`--jsx-factory=${v}`),O&&e.push(`--jsx-fragment=${O}`),M&&e.push(`--jsx-import-source=${M}`),E&&e.push("--jsx-dev"),a&&e.push("--jsx-side-effects"),c)for(let R in c){if(R.indexOf("=")>=0)throw new Error(`Invalid define: ${R}`);e.push(`--define:${R}=${G(c[R],"define",R)}`)}if(h)for(let R in h){if(R.indexOf("=")>=0)throw new Error(`Invalid log override: ${R}`);e.push(`--log-override:${R}=${G(h[R],"log override",R)}`)}if(C)for(let R in C){if(R.indexOf("=")>=0)throw new Error(`Invalid supported: ${R}`);let k=C[R];if(typeof k!="boolean")throw new Error(`Expected value for supported ${V(R)} to be a boolean, got ${typeof k} instead`);e.push(`--supported:${R}=${k}`)}if(P)for(let R of P)e.push(`--pure:${G(R,"pure")}`);$&&e.push("--keep-names")}function Xe(e,t,n,i,u){var se;let l=[],g=[],s=Object.create(null),m=null,U=null;he(l,t,s,n,i),Ue(l,t,s);let F=r(t,s,"sourcemap",Pe),b=r(t,s,"bundle",W),j=r(t,s,"splitting",W),T=r(t,s,"preserveSymlinks",W),L=r(t,s,"metafile",W),N=r(t,s,"outfile",y),S=r(t,s,"outdir",y),_=r(t,s,"outbase",y),J=r(t,s,"tsconfig",y),w=r(t,s,"resolveExtensions",K),p=r(t,s,"nodePaths",K),f=r(t,s,"mainFields",K),o=r(t,s,"conditions",K),v=r(t,s,"external",K),O=r(t,s,"packages",y),M=r(t,s,"alias",ee),E=r(t,s,"loader",ee),a=r(t,s,"outExtension",ee),c=r(t,s,"publicPath",y),h=r(t,s,"entryNames",y),C=r(t,s,"chunkNames",y),P=r(t,s,"assetNames",y),$=r(t,s,"inject",K),x=r(t,s,"banner",ee),A=r(t,s,"footer",ee),R=r(t,s,"entryPoints",Ye),k=r(t,s,"absWorkingDir",y),D=r(t,s,"stdin",ee),q=(se=r(t,s,"write",W))!=null?se:u,B=r(t,s,"allowOverwrite",W),H=r(t,s,"mangleCache",ee);if(s.plugins=!0,Y(t,s,`in ${e}() call`),F&&l.push(`--sourcemap${F===!0?"":`=${F}`}`),b&&l.push("--bundle"),B&&l.push("--allow-overwrite"),j&&l.push("--splitting"),T&&l.push("--preserve-symlinks"),L&&l.push("--metafile"),N&&l.push(`--outfile=${N}`),S&&l.push(`--outdir=${S}`),_&&l.push(`--outbase=${_}`),J&&l.push(`--tsconfig=${J}`),O&&l.push(`--packages=${O}`),w){let d=[];for(let I of w){if(G(I,"resolve extension"),I.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${I}`);d.push(I)}l.push(`--resolve-extensions=${d.join(",")}`)}if(c&&l.push(`--public-path=${c}`),h&&l.push(`--entry-names=${h}`),C&&l.push(`--chunk-names=${C}`),P&&l.push(`--asset-names=${P}`),f){let d=[];for(let I of f){if(G(I,"main field"),I.indexOf(",")>=0)throw new Error(`Invalid main field: ${I}`);d.push(I)}l.push(`--main-fields=${d.join(",")}`)}if(o){let d=[];for(let I of o){if(G(I,"condition"),I.indexOf(",")>=0)throw new Error(`Invalid condition: ${I}`);d.push(I)}l.push(`--conditions=${d.join(",")}`)}if(v)for(let d of v)l.push(`--external:${G(d,"external")}`);if(M)for(let d in M){if(d.indexOf("=")>=0)throw new Error(`Invalid package name in alias: ${d}`);l.push(`--alias:${d}=${G(M[d],"alias",d)}`)}if(x)for(let d in x){if(d.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${d}`);l.push(`--banner:${d}=${G(x[d],"banner",d)}`)}if(A)for(let d in A){if(d.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${d}`);l.push(`--footer:${d}=${G(A[d],"footer",d)}`)}if($)for(let d of $)l.push(`--inject:${G(d,"inject")}`);if(E)for(let d in E){if(d.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${d}`);l.push(`--loader:${d}=${G(E[d],"loader",d)}`)}if(a)for(let d in a){if(d.indexOf("=")>=0)throw new Error(`Invalid out extension: ${d}`);l.push(`--out-extension:${d}=${G(a[d],"out extension",d)}`)}if(R)if(Array.isArray(R))for(let d=0,I=R.length;d<I;d++){let X=R[d];if(typeof X=="object"&&X!==null){let te=Object.create(null),Q=r(X,te,"in",y),ue=r(X,te,"out",y);if(Y(X,te,"in entry point at index "+d),Q===void 0)throw new Error('Missing property "in" for entry point at index '+d);if(ue===void 0)throw new Error('Missing property "out" for entry point at index '+d);g.push([ue,Q])}else g.push(["",G(X,"entry point at index "+d)])}else for(let d in R)g.push([d,G(R[d],"entry point",d)]);if(D){let d=Object.create(null),I=r(D,d,"contents",Te),X=r(D,d,"resolveDir",y),te=r(D,d,"sourcefile",y),Q=r(D,d,"loader",y);Y(D,d,'in "stdin" object'),te&&l.push(`--sourcefile=${te}`),Q&&l.push(`--loader=${Q}`),X&&(U=X),typeof I=="string"?m=Z(I):I instanceof Uint8Array&&(m=I)}let z=[];if(p)for(let d of p)d+="",z.push(d);return{entries:g,flags:l,write:q,stdinContents:m,stdinResolveDir:U,absWorkingDir:k,nodePaths:z,mangleCache:Be(H)}}function Ze(e,t,n,i){let u=[],l=Object.create(null);he(u,t,l,n,i),Ue(u,t,l);let g=r(t,l,"sourcemap",Pe),s=r(t,l,"sourcefile",y),m=r(t,l,"loader",y),U=r(t,l,"banner",y),F=r(t,l,"footer",y),b=r(t,l,"mangleCache",ee);return Y(t,l,`in ${e}() call`),g&&u.push(`--sourcemap=${g===!0?"external":g}`),s&&u.push(`--sourcefile=${s}`),m&&u.push(`--loader=${m}`),U&&u.push(`--banner=${U}`),F&&u.push(`--footer=${F}`),{flags:u,mangleCache:Be(b)}}function je(e){let t={},n={didClose:!1,reason:""},i={},u=0,l=0,g=new Uint8Array(16*1024),s=0,m=w=>{let p=s+w.length;if(p>g.length){let o=new Uint8Array(p*2);o.set(g),g=o}g.set(w,s),s+=w.length;let f=0;for(;f+4<=s;){let o=Ee(g,f);if(f+4+o>s)break;f+=4,L(g.subarray(f,f+o)),f+=o}f>0&&(g.copyWithin(0,f,s),s-=f)},U=w=>{n.didClose=!0,w&&(n.reason=": "+(w.message||w));let p="The service was stopped"+n.reason;for(let f in i)i[f](p,null);i={}},F=(w,p,f)=>{if(n.didClose)return f("The service is no longer running"+n.reason,null);let o=u++;i[o]=(v,O)=>{try{f(v,O)}finally{w&&w.unref()}},w&&w.ref(),e.writeToStdin(Oe({id:o,isRequest:!0,value:p}))},b=(w,p)=>{if(n.didClose)throw new Error("The service is no longer running"+n.reason);e.writeToStdin(Oe({id:w,isRequest:!1,value:p}))},j=async(w,p)=>{try{if(p.command==="ping"){b(w,{});return}if(typeof p.key=="number"){let f=t[p.key];if(!f)return;let o=f[p.command];if(o){await o(w,p);return}}throw new Error("Invalid command: "+p.command)}catch(f){let o=[ie(f,e,null,void 0,"")];try{b(w,{errors:o})}catch(v){}}},T=!0,L=w=>{if(T){T=!1;let f=String.fromCharCode(...w);if(f!=="0.25.0")throw new Error(`Cannot start service: Host version "0.25.0" does not match binary version ${V(f)}`);return}let p=Se(w);if(p.isRequest)j(p.id,p.value);else{let f=i[p.id];delete i[p.id],p.value.error?f(p.value.error,{}):f(null,p.value)}};return{readFromStdout:m,afterClose:U,service:{buildOrContext:({callName:w,refs:p,options:f,isTTY:o,defaultWD:v,callback:O})=>{let M=0,E=l++,a={},c={ref(){++M===1&&p&&p.ref()},unref(){--M===0&&(delete t[E],p&&p.unref())}};t[E]=a,c.ref(),et(w,E,F,b,c,e,a,f,o,v,(h,C)=>{try{O(h,C)}finally{c.unref()}})},transform:({callName:w,refs:p,input:f,options:o,isTTY:v,fs:O,callback:M})=>{let E=Le(),a=c=>{try{if(typeof f!="string"&&!(f instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:h,mangleCache:C}=Ze(w,o,v,$e),P={command:"transform",flags:h,inputFS:c!==null,input:c!==null?Z(c):typeof f=="string"?Z(f):f};C&&(P.mangleCache=C),F(p,P,($,x)=>{if($)return M(new Error($),null);let A=ae(x.errors,E),R=ae(x.warnings,E),k=1,D=()=>{if(--k===0){let q={warnings:R,code:x.code,map:x.map,mangleCache:void 0,legalComments:void 0};"legalComments"in x&&(q.legalComments=x==null?void 0:x.legalComments),x.mangleCache&&(q.mangleCache=x==null?void 0:x.mangleCache),M(null,q)}};if(A.length>0)return M(ce("Transform failed",A,R),null);x.codeFS&&(k++,O.readFile(x.code,(q,B)=>{q!==null?M(q,null):(x.code=B,D())})),x.mapFS&&(k++,O.readFile(x.map,(q,B)=>{q!==null?M(q,null):(x.map=B,D())})),D()})}catch(h){let C=[];try{he(C,o,{},v,$e)}catch($){}let P=ie(h,e,E,void 0,"");F(p,{command:"error",flags:C,error:P},()=>{P.detail=E.load(P.detail),M(ce("Transform failed",[P],[]),null)})}};if((typeof f=="string"||f instanceof Uint8Array)&&f.length>1024*1024){let c=a;a=()=>O.writeFile(f,c)}a(null)},formatMessages:({callName:w,refs:p,messages:f,options:o,callback:v})=>{if(!o)throw new Error(`Missing second argument in ${w}() call`);let O={},M=r(o,O,"kind",y),E=r(o,O,"color",W),a=r(o,O,"terminalWidth",oe);if(Y(o,O,`in ${w}() call`),M===void 0)throw new Error(`Missing "kind" in ${w}() call`);if(M!=="error"&&M!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${w}() call`);let c={command:"format-msgs",messages:ne(f,"messages",null,"",a),isWarning:M==="warning"};E!==void 0&&(c.color=E),a!==void 0&&(c.terminalWidth=a),F(p,c,(h,C)=>{if(h)return v(new Error(h),null);v(null,C.messages)})},analyzeMetafile:({callName:w,refs:p,metafile:f,options:o,callback:v})=>{o===void 0&&(o={});let O={},M=r(o,O,"color",W),E=r(o,O,"verbose",W);Y(o,O,`in ${w}() call`);let a={command:"analyze-metafile",metafile:f};M!==void 0&&(a.color=M),E!==void 0&&(a.verbose=E),F(p,a,(c,h)=>{if(c)return v(new Error(c),null);v(null,h.result)})}}}}function et(e,t,n,i,u,l,g,s,m,U,F){let b=Le(),j=e==="context",T=(S,_)=>{let J=[];try{he(J,s,{},m,ke)}catch(p){}let w=ie(S,l,b,void 0,_);n(u,{command:"error",flags:J,error:w},()=>{w.detail=b.load(w.detail),F(ce(j?"Context failed":"Build failed",[w],[]),null)})},L;if(typeof s=="object"){let S=s.plugins;if(S!==void 0){if(!Array.isArray(S))return T(new Error('"plugins" must be an array'),"");L=S}}if(L&&L.length>0){if(l.isSync)return T(new Error("Cannot use plugins in synchronous API calls"),"");tt(t,n,i,u,l,g,s,L,b).then(S=>{if(!S.ok)return T(S.error,S.pluginName);try{N(S.requestPlugins,S.runOnEndCallbacks,S.scheduleOnDisposeCallbacks)}catch(_){T(_,"")}},S=>T(S,""));return}try{N(null,(S,_)=>_([],[]),()=>{})}catch(S){T(S,"")}function N(S,_,J){let w=l.hasFS,{entries:p,flags:f,write:o,stdinContents:v,stdinResolveDir:O,absWorkingDir:M,nodePaths:E,mangleCache:a}=Xe(e,s,m,ke,w);if(o&&!l.hasFS)throw new Error('The "write" option is unavailable in this environment');let c={command:"build",key:t,entries:p,flags:f,write:o,stdinContents:v,stdinResolveDir:O,absWorkingDir:M||U,nodePaths:E,context:j};S&&(c.plugins=S),a&&(c.mangleCache=a);let h=($,x)=>{let A={errors:ae($.errors,b),warnings:ae($.warnings,b),outputFiles:void 0,metafile:void 0,mangleCache:void 0},R=A.errors.slice(),k=A.warnings.slice();$.outputFiles&&(A.outputFiles=$.outputFiles.map(rt)),$.metafile&&(A.metafile=JSON.parse($.metafile)),$.mangleCache&&(A.mangleCache=$.mangleCache),$.writeToStdout!==void 0&&console.log(re($.writeToStdout).replace(/\n$/,"")),_(A,(D,q)=>{if(R.length>0||D.length>0){let B=ce("Build failed",R.concat(D),k.concat(q));return x(B,null,D,q)}x(null,A,D,q)})},C,P;j&&(g["on-end"]=($,x)=>new Promise(A=>{h(x,(R,k,D,q)=>{let B={errors:D,warnings:q};P&&P(R,k),C=void 0,P=void 0,i($,B),A()})})),n(u,c,($,x)=>{if($)return F(new Error($),null);if(!j)return h(x,(k,D)=>(J(),F(k,D)));if(x.errors.length>0)return F(ce("Context failed",x.errors,x.warnings),null);let A=!1,R={rebuild:()=>(C||(C=new Promise((k,D)=>{let q;P=(H,z)=>{q||(q=()=>H?D(H):k(z))};let B=()=>{n(u,{command:"rebuild",key:t},(z,se)=>{z?D(new Error(z)):q?q():B()})};B()})),C),watch:(k={})=>new Promise((D,q)=>{if(!l.hasFS)throw new Error('Cannot use the "watch" API in this environment');Y(k,{},"in watch() call"),n(u,{command:"watch",key:t},z=>{z?q(new Error(z)):D(void 0)})}),serve:(k={})=>new Promise((D,q)=>{if(!l.hasFS)throw new Error('Cannot use the "serve" API in this environment');let B={},H=r(k,B,"port",Ve),z=r(k,B,"host",y),se=r(k,B,"servedir",y),d=r(k,B,"keyfile",y),I=r(k,B,"certfile",y),X=r(k,B,"fallback",y),te=r(k,B,"onRequest",Fe);Y(k,B,"in serve() call");let Q={command:"serve",key:t,onRequest:!!te};H!==void 0&&(Q.port=H),z!==void 0&&(Q.host=z),se!==void 0&&(Q.servedir=se),d!==void 0&&(Q.keyfile=d),I!==void 0&&(Q.certfile=I),X!==void 0&&(Q.fallback=X),n(u,Q,(ue,qe)=>{if(ue)return q(new Error(ue));te&&(g["serve-request"]=(Ie,We)=>{te(We.args),i(Ie,{})}),D(qe)})}),cancel:()=>new Promise(k=>{if(A)return k();n(u,{command:"cancel",key:t},()=>{k()})}),dispose:()=>new Promise(k=>{if(A)return k();A=!0,n(u,{command:"dispose",key:t},()=>{k(),J(),u.unref()})})};u.ref(),F(null,R)})}}var tt=async(e,t,n,i,u,l,g,s,m)=>{let U=[],F=[],b={},j={},T=[],L=0,N=0,S=[],_=!1;s=[...s];for(let p of s){let f={};if(typeof p!="object")throw new Error(`Plugin at index ${N} must be an object`);let o=r(p,f,"name",y);if(typeof o!="string"||o==="")throw new Error(`Plugin at index ${N} is missing a name`);try{let v=r(p,f,"setup",Fe);if(typeof v!="function")throw new Error("Plugin is missing a setup function");Y(p,f,`on plugin ${V(o)}`);let O={name:o,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};N++;let E=v({initialOptions:g,resolve:(a,c={})=>{if(!_)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 h=Object.create(null),C=r(c,h,"pluginName",y),P=r(c,h,"importer",y),$=r(c,h,"namespace",y),x=r(c,h,"resolveDir",y),A=r(c,h,"kind",y),R=r(c,h,"pluginData",me),k=r(c,h,"with",ee);return Y(c,h,"in resolve() call"),new Promise((D,q)=>{let B={command:"resolve",path:a,key:e,pluginName:o};if(C!=null&&(B.pluginName=C),P!=null&&(B.importer=P),$!=null&&(B.namespace=$),x!=null&&(B.resolveDir=x),A!=null)B.kind=A;else throw new Error('Must specify "kind" when calling "resolve"');R!=null&&(B.pluginData=m.store(R)),k!=null&&(B.with=nt(k,"with")),t(i,B,(H,z)=>{H!==null?q(new Error(H)):D({errors:ae(z.errors,m),warnings:ae(z.warnings,m),path:z.path,external:z.external,sideEffects:z.sideEffects,namespace:z.namespace,suffix:z.suffix,pluginData:m.load(z.pluginData)})})})},onStart(a){let c='This error came from the "onStart" callback registered here:',h=pe(new Error(c),u,"onStart");U.push({name:o,callback:a,note:h}),O.onStart=!0},onEnd(a){let c='This error came from the "onEnd" callback registered here:',h=pe(new Error(c),u,"onEnd");F.push({name:o,callback:a,note:h}),O.onEnd=!0},onResolve(a,c){let h='This error came from the "onResolve" callback registered here:',C=pe(new Error(h),u,"onResolve"),P={},$=r(a,P,"filter",ye),x=r(a,P,"namespace",y);if(Y(a,P,`in onResolve() call for plugin ${V(o)}`),$==null)throw new Error("onResolve() call is missing a filter");let A=L++;b[A]={name:o,callback:c,note:C},O.onResolve.push({id:A,filter:$.source,namespace:x||""})},onLoad(a,c){let h='This error came from the "onLoad" callback registered here:',C=pe(new Error(h),u,"onLoad"),P={},$=r(a,P,"filter",ye),x=r(a,P,"namespace",y);if(Y(a,P,`in onLoad() call for plugin ${V(o)}`),$==null)throw new Error("onLoad() call is missing a filter");let A=L++;j[A]={name:o,callback:c,note:C},O.onLoad.push({id:A,filter:$.source,namespace:x||""})},onDispose(a){T.push(a)},esbuild:u.esbuild});E&&await E,S.push(O)}catch(v){return{ok:!1,error:v,pluginName:o}}}l["on-start"]=async(p,f)=>{m.clear();let o={errors:[],warnings:[]};await Promise.all(U.map(async({name:v,callback:O,note:M})=>{try{let E=await O();if(E!=null){if(typeof E!="object")throw new Error(`Expected onStart() callback in plugin ${V(v)} to return an object`);let a={},c=r(E,a,"errors",K),h=r(E,a,"warnings",K);Y(E,a,`from onStart() callback in plugin ${V(v)}`),c!=null&&o.errors.push(...ne(c,"errors",m,v,void 0)),h!=null&&o.warnings.push(...ne(h,"warnings",m,v,void 0))}}catch(E){o.errors.push(ie(E,u,m,M&&M(),v))}})),n(p,o)},l["on-resolve"]=async(p,f)=>{let o={},v="",O,M;for(let E of f.ids)try{({name:v,callback:O,note:M}=b[E]);let a=await O({path:f.path,importer:f.importer,namespace:f.namespace,resolveDir:f.resolveDir,kind:f.kind,pluginData:m.load(f.pluginData),with:f.with});if(a!=null){if(typeof a!="object")throw new Error(`Expected onResolve() callback in plugin ${V(v)} to return an object`);let c={},h=r(a,c,"pluginName",y),C=r(a,c,"path",y),P=r(a,c,"namespace",y),$=r(a,c,"suffix",y),x=r(a,c,"external",W),A=r(a,c,"sideEffects",W),R=r(a,c,"pluginData",me),k=r(a,c,"errors",K),D=r(a,c,"warnings",K),q=r(a,c,"watchFiles",K),B=r(a,c,"watchDirs",K);Y(a,c,`from onResolve() callback in plugin ${V(v)}`),o.id=E,h!=null&&(o.pluginName=h),C!=null&&(o.path=C),P!=null&&(o.namespace=P),$!=null&&(o.suffix=$),x!=null&&(o.external=x),A!=null&&(o.sideEffects=A),R!=null&&(o.pluginData=m.store(R)),k!=null&&(o.errors=ne(k,"errors",m,v,void 0)),D!=null&&(o.warnings=ne(D,"warnings",m,v,void 0)),q!=null&&(o.watchFiles=ge(q,"watchFiles")),B!=null&&(o.watchDirs=ge(B,"watchDirs"));break}}catch(a){o={id:E,errors:[ie(a,u,m,M&&M(),v)]};break}n(p,o)},l["on-load"]=async(p,f)=>{let o={},v="",O,M;for(let E of f.ids)try{({name:v,callback:O,note:M}=j[E]);let a=await O({path:f.path,namespace:f.namespace,suffix:f.suffix,pluginData:m.load(f.pluginData),with:f.with});if(a!=null){if(typeof a!="object")throw new Error(`Expected onLoad() callback in plugin ${V(v)} to return an object`);let c={},h=r(a,c,"pluginName",y),C=r(a,c,"contents",Te),P=r(a,c,"resolveDir",y),$=r(a,c,"pluginData",me),x=r(a,c,"loader",y),A=r(a,c,"errors",K),R=r(a,c,"warnings",K),k=r(a,c,"watchFiles",K),D=r(a,c,"watchDirs",K);Y(a,c,`from onLoad() callback in plugin ${V(v)}`),o.id=E,h!=null&&(o.pluginName=h),C instanceof Uint8Array?o.contents=C:C!=null&&(o.contents=Z(C)),P!=null&&(o.resolveDir=P),$!=null&&(o.pluginData=m.store($)),x!=null&&(o.loader=x),A!=null&&(o.errors=ne(A,"errors",m,v,void 0)),R!=null&&(o.warnings=ne(R,"warnings",m,v,void 0)),k!=null&&(o.watchFiles=ge(k,"watchFiles")),D!=null&&(o.watchDirs=ge(D,"watchDirs"));break}}catch(a){o={id:E,errors:[ie(a,u,m,M&&M(),v)]};break}n(p,o)};let J=(p,f)=>f([],[]);F.length>0&&(J=(p,f)=>{(async()=>{let o=[],v=[];for(let{name:O,callback:M,note:E}of F){let a,c;try{let h=await M(p);if(h!=null){if(typeof h!="object")throw new Error(`Expected onEnd() callback in plugin ${V(O)} to return an object`);let C={},P=r(h,C,"errors",K),$=r(h,C,"warnings",K);Y(h,C,`from onEnd() callback in plugin ${V(O)}`),P!=null&&(a=ne(P,"errors",m,O,void 0)),$!=null&&(c=ne($,"warnings",m,O,void 0))}}catch(h){a=[ie(h,u,m,E&&E(),O)]}if(a){o.push(...a);try{p.errors.push(...a)}catch(h){}}if(c){v.push(...c);try{p.warnings.push(...c)}catch(h){}}}f(o,v)})()});let w=()=>{for(let p of T)setTimeout(()=>p(),0)};return _=!0,{ok:!0,requestPlugins:S,runOnEndCallbacks:J,scheduleOnDisposeCallbacks:w}};function Le(){let e=new Map,t=0;return{clear(){e.clear()},load(n){return e.get(n)},store(n){if(n===void 0)return-1;let i=t++;return e.set(i,n),i}}}function pe(e,t,n){let i,u=!1;return()=>{if(u)return i;u=!0;try{let l=(e.stack+"").split(`
|
|
7
|
-
`);l.splice(1,1);let g=
|
|
8
|
-
`),"")}catch(s){}return{id:"",pluginName:u,text:l,location:g,notes:i?[i]:[],detail:n?n.store(e):-1}}function
|
|
6
|
+
`);function Se(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function Oe(e,t,n){e[n++]=t,e[n++]=t>>8,e[n++]=t>>16,e[n++]=t>>24}var V=JSON.stringify,$e="warning",Me="silent";function Ce(e){if(G(e,"target"),e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var me=()=>null,W=e=>typeof e=="boolean"?null:"a boolean",y=e=>typeof e=="string"?null:"a string",ye=e=>e instanceof RegExp?null:"a RegExp object",oe=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Ye=e=>typeof e=="number"&&e===(e|0)&&e>=0&&e<=65535?null:"a valid port number",Pe=e=>typeof e=="function"?null:"a function",K=e=>Array.isArray(e)?null:"an array",ee=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",Je=e=>typeof e=="object"&&e!==null?null:"an array or an object",Ge=e=>e instanceof WebAssembly.Module?null:"a WebAssembly.Module",Ae=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",Te=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",Qe=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",He=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",De=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array",Xe=e=>typeof e=="string"||e instanceof URL?null:"a string or a URL";function r(e,t,n,i){let u=e[n];if(t[n+""]=!0,u===void 0)return;let l=i(u);if(l!==null)throw new Error(`${V(n)} must be ${l}`);return u}function Y(e,t,n){for(let i in e)if(!(i in t))throw new Error(`Invalid option ${n}: ${V(i)}`)}function Be(e){let t=Object.create(null),n=r(e,t,"wasmURL",Xe),i=r(e,t,"wasmModule",Ge),u=r(e,t,"worker",W);return Y(e,t,"in initialize() call"),{wasmURL:n,wasmModule:i,worker:u}}function Ue(e){let t;if(e!==void 0){t=Object.create(null);for(let n in e){let i=e[n];if(typeof i=="string"||i===!1)t[n]=i;else throw new Error(`Expected ${V(n)} in mangle cache to map to either a string or false`)}}return t}function be(e,t,n,i,u){let l=r(t,n,"color",W),g=r(t,n,"logLevel",y),s=r(t,n,"logLimit",oe);l!==void 0?e.push(`--color=${l}`):i&&e.push("--color=true"),e.push(`--log-level=${g||u}`),e.push(`--log-limit=${s||0}`)}function G(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 je(e,t,n){let i=r(t,n,"legalComments",y),u=r(t,n,"sourceRoot",y),l=r(t,n,"sourcesContent",W),g=r(t,n,"target",He),s=r(t,n,"format",y),m=r(t,n,"globalName",y),U=r(t,n,"mangleProps",ye),F=r(t,n,"reserveProps",ye),b=r(t,n,"mangleQuoted",W),j=r(t,n,"minify",W),T=r(t,n,"minifySyntax",W),L=r(t,n,"minifyWhitespace",W),N=r(t,n,"minifyIdentifiers",W),S=r(t,n,"lineLimit",oe),_=r(t,n,"drop",K),J=r(t,n,"dropLabels",K),w=r(t,n,"charset",y),p=r(t,n,"treeShaking",W),f=r(t,n,"ignoreAnnotations",W),o=r(t,n,"jsx",y),v=r(t,n,"jsxFactory",y),O=r(t,n,"jsxFragment",y),M=r(t,n,"jsxImportSource",y),E=r(t,n,"jsxDev",W),a=r(t,n,"jsxSideEffects",W),c=r(t,n,"define",ee),h=r(t,n,"logOverride",ee),C=r(t,n,"supported",ee),P=r(t,n,"pure",K),$=r(t,n,"keepNames",W),x=r(t,n,"platform",y),A=r(t,n,"tsconfigRaw",Qe);if(i&&e.push(`--legal-comments=${i}`),u!==void 0&&e.push(`--source-root=${u}`),l!==void 0&&e.push(`--sources-content=${l}`),g&&(Array.isArray(g)?e.push(`--target=${Array.from(g).map(Ce).join(",")}`):e.push(`--target=${Ce(g)}`)),s&&e.push(`--format=${s}`),m&&e.push(`--global-name=${m}`),x&&e.push(`--platform=${x}`),A&&e.push(`--tsconfig-raw=${typeof A=="string"?A:JSON.stringify(A)}`),j&&e.push("--minify"),T&&e.push("--minify-syntax"),L&&e.push("--minify-whitespace"),N&&e.push("--minify-identifiers"),S&&e.push(`--line-limit=${S}`),w&&e.push(`--charset=${w}`),p!==void 0&&e.push(`--tree-shaking=${p}`),f&&e.push("--ignore-annotations"),_)for(let R of _)e.push(`--drop:${G(R,"drop")}`);if(J&&e.push(`--drop-labels=${Array.from(J).map(R=>G(R,"dropLabels")).join(",")}`),U&&e.push(`--mangle-props=${he(U)}`),F&&e.push(`--reserve-props=${he(F)}`),b!==void 0&&e.push(`--mangle-quoted=${b}`),o&&e.push(`--jsx=${o}`),v&&e.push(`--jsx-factory=${v}`),O&&e.push(`--jsx-fragment=${O}`),M&&e.push(`--jsx-import-source=${M}`),E&&e.push("--jsx-dev"),a&&e.push("--jsx-side-effects"),c)for(let R in c){if(R.indexOf("=")>=0)throw new Error(`Invalid define: ${R}`);e.push(`--define:${R}=${G(c[R],"define",R)}`)}if(h)for(let R in h){if(R.indexOf("=")>=0)throw new Error(`Invalid log override: ${R}`);e.push(`--log-override:${R}=${G(h[R],"log override",R)}`)}if(C)for(let R in C){if(R.indexOf("=")>=0)throw new Error(`Invalid supported: ${R}`);let k=C[R];if(typeof k!="boolean")throw new Error(`Expected value for supported ${V(R)} to be a boolean, got ${typeof k} instead`);e.push(`--supported:${R}=${k}`)}if(P)for(let R of P)e.push(`--pure:${G(R,"pure")}`);$&&e.push("--keep-names")}function Ze(e,t,n,i,u){var se;let l=[],g=[],s=Object.create(null),m=null,U=null;be(l,t,s,n,i),je(l,t,s);let F=r(t,s,"sourcemap",Te),b=r(t,s,"bundle",W),j=r(t,s,"splitting",W),T=r(t,s,"preserveSymlinks",W),L=r(t,s,"metafile",W),N=r(t,s,"outfile",y),S=r(t,s,"outdir",y),_=r(t,s,"outbase",y),J=r(t,s,"tsconfig",y),w=r(t,s,"resolveExtensions",K),p=r(t,s,"nodePaths",K),f=r(t,s,"mainFields",K),o=r(t,s,"conditions",K),v=r(t,s,"external",K),O=r(t,s,"packages",y),M=r(t,s,"alias",ee),E=r(t,s,"loader",ee),a=r(t,s,"outExtension",ee),c=r(t,s,"publicPath",y),h=r(t,s,"entryNames",y),C=r(t,s,"chunkNames",y),P=r(t,s,"assetNames",y),$=r(t,s,"inject",K),x=r(t,s,"banner",ee),A=r(t,s,"footer",ee),R=r(t,s,"entryPoints",Je),k=r(t,s,"absWorkingDir",y),D=r(t,s,"stdin",ee),q=(se=r(t,s,"write",W))!=null?se:u,B=r(t,s,"allowOverwrite",W),H=r(t,s,"mangleCache",ee);if(s.plugins=!0,Y(t,s,`in ${e}() call`),F&&l.push(`--sourcemap${F===!0?"":`=${F}`}`),b&&l.push("--bundle"),B&&l.push("--allow-overwrite"),j&&l.push("--splitting"),T&&l.push("--preserve-symlinks"),L&&l.push("--metafile"),N&&l.push(`--outfile=${N}`),S&&l.push(`--outdir=${S}`),_&&l.push(`--outbase=${_}`),J&&l.push(`--tsconfig=${J}`),O&&l.push(`--packages=${O}`),w){let d=[];for(let I of w){if(G(I,"resolve extension"),I.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${I}`);d.push(I)}l.push(`--resolve-extensions=${d.join(",")}`)}if(c&&l.push(`--public-path=${c}`),h&&l.push(`--entry-names=${h}`),C&&l.push(`--chunk-names=${C}`),P&&l.push(`--asset-names=${P}`),f){let d=[];for(let I of f){if(G(I,"main field"),I.indexOf(",")>=0)throw new Error(`Invalid main field: ${I}`);d.push(I)}l.push(`--main-fields=${d.join(",")}`)}if(o){let d=[];for(let I of o){if(G(I,"condition"),I.indexOf(",")>=0)throw new Error(`Invalid condition: ${I}`);d.push(I)}l.push(`--conditions=${d.join(",")}`)}if(v)for(let d of v)l.push(`--external:${G(d,"external")}`);if(M)for(let d in M){if(d.indexOf("=")>=0)throw new Error(`Invalid package name in alias: ${d}`);l.push(`--alias:${d}=${G(M[d],"alias",d)}`)}if(x)for(let d in x){if(d.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${d}`);l.push(`--banner:${d}=${G(x[d],"banner",d)}`)}if(A)for(let d in A){if(d.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${d}`);l.push(`--footer:${d}=${G(A[d],"footer",d)}`)}if($)for(let d of $)l.push(`--inject:${G(d,"inject")}`);if(E)for(let d in E){if(d.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${d}`);l.push(`--loader:${d}=${G(E[d],"loader",d)}`)}if(a)for(let d in a){if(d.indexOf("=")>=0)throw new Error(`Invalid out extension: ${d}`);l.push(`--out-extension:${d}=${G(a[d],"out extension",d)}`)}if(R)if(Array.isArray(R))for(let d=0,I=R.length;d<I;d++){let X=R[d];if(typeof X=="object"&&X!==null){let te=Object.create(null),Q=r(X,te,"in",y),ue=r(X,te,"out",y);if(Y(X,te,"in entry point at index "+d),Q===void 0)throw new Error('Missing property "in" for entry point at index '+d);if(ue===void 0)throw new Error('Missing property "out" for entry point at index '+d);g.push([ue,Q])}else g.push(["",G(X,"entry point at index "+d)])}else for(let d in R)g.push([d,G(R[d],"entry point",d)]);if(D){let d=Object.create(null),I=r(D,d,"contents",De),X=r(D,d,"resolveDir",y),te=r(D,d,"sourcefile",y),Q=r(D,d,"loader",y);Y(D,d,'in "stdin" object'),te&&l.push(`--sourcefile=${te}`),Q&&l.push(`--loader=${Q}`),X&&(U=X),typeof I=="string"?m=Z(I):I instanceof Uint8Array&&(m=I)}let z=[];if(p)for(let d of p)d+="",z.push(d);return{entries:g,flags:l,write:q,stdinContents:m,stdinResolveDir:U,absWorkingDir:k,nodePaths:z,mangleCache:Ue(H)}}function et(e,t,n,i){let u=[],l=Object.create(null);be(u,t,l,n,i),je(u,t,l);let g=r(t,l,"sourcemap",Te),s=r(t,l,"sourcefile",y),m=r(t,l,"loader",y),U=r(t,l,"banner",y),F=r(t,l,"footer",y),b=r(t,l,"mangleCache",ee);return Y(t,l,`in ${e}() call`),g&&u.push(`--sourcemap=${g===!0?"external":g}`),s&&u.push(`--sourcefile=${s}`),m&&u.push(`--loader=${m}`),U&&u.push(`--banner=${U}`),F&&u.push(`--footer=${F}`),{flags:u,mangleCache:Ue(b)}}function Le(e){let t={},n={didClose:!1,reason:""},i={},u=0,l=0,g=new Uint8Array(16*1024),s=0,m=w=>{let p=s+w.length;if(p>g.length){let o=new Uint8Array(p*2);o.set(g),g=o}g.set(w,s),s+=w.length;let f=0;for(;f+4<=s;){let o=Se(g,f);if(f+4+o>s)break;f+=4,L(g.subarray(f,f+o)),f+=o}f>0&&(g.copyWithin(0,f,s),s-=f)},U=w=>{n.didClose=!0,w&&(n.reason=": "+(w.message||w));let p="The service was stopped"+n.reason;for(let f in i)i[f](p,null);i={}},F=(w,p,f)=>{if(n.didClose)return f("The service is no longer running"+n.reason,null);let o=u++;i[o]=(v,O)=>{try{f(v,O)}finally{w&&w.unref()}},w&&w.ref(),e.writeToStdin(Ee({id:o,isRequest:!0,value:p}))},b=(w,p)=>{if(n.didClose)throw new Error("The service is no longer running"+n.reason);e.writeToStdin(Ee({id:w,isRequest:!1,value:p}))},j=async(w,p)=>{try{if(p.command==="ping"){b(w,{});return}if(typeof p.key=="number"){let f=t[p.key];if(!f)return;let o=f[p.command];if(o){await o(w,p);return}}throw new Error("Invalid command: "+p.command)}catch(f){let o=[ie(f,e,null,void 0,"")];try{b(w,{errors:o})}catch(v){}}},T=!0,L=w=>{if(T){T=!1;let f=String.fromCharCode(...w);if(f!=="0.25.2")throw new Error(`Cannot start service: Host version "0.25.2" does not match binary version ${V(f)}`);return}let p=ke(w);if(p.isRequest)j(p.id,p.value);else{let f=i[p.id];delete i[p.id],p.value.error?f(p.value.error,{}):f(null,p.value)}};return{readFromStdout:m,afterClose:U,service:{buildOrContext:({callName:w,refs:p,options:f,isTTY:o,defaultWD:v,callback:O})=>{let M=0,E=l++,a={},c={ref(){++M===1&&p&&p.ref()},unref(){--M===0&&(delete t[E],p&&p.unref())}};t[E]=a,c.ref(),tt(w,E,F,b,c,e,a,f,o,v,(h,C)=>{try{O(h,C)}finally{c.unref()}})},transform:({callName:w,refs:p,input:f,options:o,isTTY:v,fs:O,callback:M})=>{let E=Ne(),a=c=>{try{if(typeof f!="string"&&!(f instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:h,mangleCache:C}=et(w,o,v,Me),P={command:"transform",flags:h,inputFS:c!==null,input:c!==null?Z(c):typeof f=="string"?Z(f):f};C&&(P.mangleCache=C),F(p,P,($,x)=>{if($)return M(new Error($),null);let A=ae(x.errors,E),R=ae(x.warnings,E),k=1,D=()=>{if(--k===0){let q={warnings:R,code:x.code,map:x.map,mangleCache:void 0,legalComments:void 0};"legalComments"in x&&(q.legalComments=x==null?void 0:x.legalComments),x.mangleCache&&(q.mangleCache=x==null?void 0:x.mangleCache),M(null,q)}};if(A.length>0)return M(ce("Transform failed",A,R),null);x.codeFS&&(k++,O.readFile(x.code,(q,B)=>{q!==null?M(q,null):(x.code=B,D())})),x.mapFS&&(k++,O.readFile(x.map,(q,B)=>{q!==null?M(q,null):(x.map=B,D())})),D()})}catch(h){let C=[];try{be(C,o,{},v,Me)}catch($){}let P=ie(h,e,E,void 0,"");F(p,{command:"error",flags:C,error:P},()=>{P.detail=E.load(P.detail),M(ce("Transform failed",[P],[]),null)})}};if((typeof f=="string"||f instanceof Uint8Array)&&f.length>1024*1024){let c=a;a=()=>O.writeFile(f,c)}a(null)},formatMessages:({callName:w,refs:p,messages:f,options:o,callback:v})=>{if(!o)throw new Error(`Missing second argument in ${w}() call`);let O={},M=r(o,O,"kind",y),E=r(o,O,"color",W),a=r(o,O,"terminalWidth",oe);if(Y(o,O,`in ${w}() call`),M===void 0)throw new Error(`Missing "kind" in ${w}() call`);if(M!=="error"&&M!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${w}() call`);let c={command:"format-msgs",messages:ne(f,"messages",null,"",a),isWarning:M==="warning"};E!==void 0&&(c.color=E),a!==void 0&&(c.terminalWidth=a),F(p,c,(h,C)=>{if(h)return v(new Error(h),null);v(null,C.messages)})},analyzeMetafile:({callName:w,refs:p,metafile:f,options:o,callback:v})=>{o===void 0&&(o={});let O={},M=r(o,O,"color",W),E=r(o,O,"verbose",W);Y(o,O,`in ${w}() call`);let a={command:"analyze-metafile",metafile:f};M!==void 0&&(a.color=M),E!==void 0&&(a.verbose=E),F(p,a,(c,h)=>{if(c)return v(new Error(c),null);v(null,h.result)})}}}}function tt(e,t,n,i,u,l,g,s,m,U,F){let b=Ne(),j=e==="context",T=(S,_)=>{let J=[];try{be(J,s,{},m,$e)}catch(p){}let w=ie(S,l,b,void 0,_);n(u,{command:"error",flags:J,error:w},()=>{w.detail=b.load(w.detail),F(ce(j?"Context failed":"Build failed",[w],[]),null)})},L;if(typeof s=="object"){let S=s.plugins;if(S!==void 0){if(!Array.isArray(S))return T(new Error('"plugins" must be an array'),"");L=S}}if(L&&L.length>0){if(l.isSync)return T(new Error("Cannot use plugins in synchronous API calls"),"");nt(t,n,i,u,l,g,s,L,b).then(S=>{if(!S.ok)return T(S.error,S.pluginName);try{N(S.requestPlugins,S.runOnEndCallbacks,S.scheduleOnDisposeCallbacks)}catch(_){T(_,"")}},S=>T(S,""));return}try{N(null,(S,_)=>_([],[]),()=>{})}catch(S){T(S,"")}function N(S,_,J){let w=l.hasFS,{entries:p,flags:f,write:o,stdinContents:v,stdinResolveDir:O,absWorkingDir:M,nodePaths:E,mangleCache:a}=Ze(e,s,m,$e,w);if(o&&!l.hasFS)throw new Error('The "write" option is unavailable in this environment');let c={command:"build",key:t,entries:p,flags:f,write:o,stdinContents:v,stdinResolveDir:O,absWorkingDir:M||U,nodePaths:E,context:j};S&&(c.plugins=S),a&&(c.mangleCache=a);let h=($,x)=>{let A={errors:ae($.errors,b),warnings:ae($.warnings,b),outputFiles:void 0,metafile:void 0,mangleCache:void 0},R=A.errors.slice(),k=A.warnings.slice();$.outputFiles&&(A.outputFiles=$.outputFiles.map(it)),$.metafile&&(A.metafile=JSON.parse($.metafile)),$.mangleCache&&(A.mangleCache=$.mangleCache),$.writeToStdout!==void 0&&console.log(re($.writeToStdout).replace(/\n$/,"")),_(A,(D,q)=>{if(R.length>0||D.length>0){let B=ce("Build failed",R.concat(D),k.concat(q));return x(B,null,D,q)}x(null,A,D,q)})},C,P;j&&(g["on-end"]=($,x)=>new Promise(A=>{h(x,(R,k,D,q)=>{let B={errors:D,warnings:q};P&&P(R,k),C=void 0,P=void 0,i($,B),A()})})),n(u,c,($,x)=>{if($)return F(new Error($),null);if(!j)return h(x,(k,D)=>(J(),F(k,D)));if(x.errors.length>0)return F(ce("Context failed",x.errors,x.warnings),null);let A=!1,R={rebuild:()=>(C||(C=new Promise((k,D)=>{let q;P=(H,z)=>{q||(q=()=>H?D(H):k(z))};let B=()=>{n(u,{command:"rebuild",key:t},(z,se)=>{z?D(new Error(z)):q?q():B()})};B()})),C),watch:(k={})=>new Promise((D,q)=>{if(!l.hasFS)throw new Error('Cannot use the "watch" API in this environment');Y(k,{},"in watch() call"),n(u,{command:"watch",key:t},z=>{z?q(new Error(z)):D(void 0)})}),serve:(k={})=>new Promise((D,q)=>{if(!l.hasFS)throw new Error('Cannot use the "serve" API in this environment');let B={},H=r(k,B,"port",Ye),z=r(k,B,"host",y),se=r(k,B,"servedir",y),d=r(k,B,"keyfile",y),I=r(k,B,"certfile",y),X=r(k,B,"fallback",y),te=r(k,B,"onRequest",Pe);Y(k,B,"in serve() call");let Q={command:"serve",key:t,onRequest:!!te};H!==void 0&&(Q.port=H),z!==void 0&&(Q.host=z),se!==void 0&&(Q.servedir=se),d!==void 0&&(Q.keyfile=d),I!==void 0&&(Q.certfile=I),X!==void 0&&(Q.fallback=X),n(u,Q,(ue,Ie)=>{if(ue)return q(new Error(ue));te&&(g["serve-request"]=(We,ze)=>{te(ze.args),i(We,{})}),D(Ie)})}),cancel:()=>new Promise(k=>{if(A)return k();n(u,{command:"cancel",key:t},()=>{k()})}),dispose:()=>new Promise(k=>{if(A)return k();A=!0,n(u,{command:"dispose",key:t},()=>{k(),J(),u.unref()})})};u.ref(),F(null,R)})}}var nt=async(e,t,n,i,u,l,g,s,m)=>{let U=[],F=[],b={},j={},T=[],L=0,N=0,S=[],_=!1;s=[...s];for(let p of s){let f={};if(typeof p!="object")throw new Error(`Plugin at index ${N} must be an object`);let o=r(p,f,"name",y);if(typeof o!="string"||o==="")throw new Error(`Plugin at index ${N} is missing a name`);try{let v=r(p,f,"setup",Pe);if(typeof v!="function")throw new Error("Plugin is missing a setup function");Y(p,f,`on plugin ${V(o)}`);let O={name:o,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};N++;let E=v({initialOptions:g,resolve:(a,c={})=>{if(!_)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 h=Object.create(null),C=r(c,h,"pluginName",y),P=r(c,h,"importer",y),$=r(c,h,"namespace",y),x=r(c,h,"resolveDir",y),A=r(c,h,"kind",y),R=r(c,h,"pluginData",me),k=r(c,h,"with",ee);return Y(c,h,"in resolve() call"),new Promise((D,q)=>{let B={command:"resolve",path:a,key:e,pluginName:o};if(C!=null&&(B.pluginName=C),P!=null&&(B.importer=P),$!=null&&(B.namespace=$),x!=null&&(B.resolveDir=x),A!=null)B.kind=A;else throw new Error('Must specify "kind" when calling "resolve"');R!=null&&(B.pluginData=m.store(R)),k!=null&&(B.with=rt(k,"with")),t(i,B,(H,z)=>{H!==null?q(new Error(H)):D({errors:ae(z.errors,m),warnings:ae(z.warnings,m),path:z.path,external:z.external,sideEffects:z.sideEffects,namespace:z.namespace,suffix:z.suffix,pluginData:m.load(z.pluginData)})})})},onStart(a){let c='This error came from the "onStart" callback registered here:',h=pe(new Error(c),u,"onStart");U.push({name:o,callback:a,note:h}),O.onStart=!0},onEnd(a){let c='This error came from the "onEnd" callback registered here:',h=pe(new Error(c),u,"onEnd");F.push({name:o,callback:a,note:h}),O.onEnd=!0},onResolve(a,c){let h='This error came from the "onResolve" callback registered here:',C=pe(new Error(h),u,"onResolve"),P={},$=r(a,P,"filter",ye),x=r(a,P,"namespace",y);if(Y(a,P,`in onResolve() call for plugin ${V(o)}`),$==null)throw new Error("onResolve() call is missing a filter");let A=L++;b[A]={name:o,callback:c,note:C},O.onResolve.push({id:A,filter:he($),namespace:x||""})},onLoad(a,c){let h='This error came from the "onLoad" callback registered here:',C=pe(new Error(h),u,"onLoad"),P={},$=r(a,P,"filter",ye),x=r(a,P,"namespace",y);if(Y(a,P,`in onLoad() call for plugin ${V(o)}`),$==null)throw new Error("onLoad() call is missing a filter");let A=L++;j[A]={name:o,callback:c,note:C},O.onLoad.push({id:A,filter:he($),namespace:x||""})},onDispose(a){T.push(a)},esbuild:u.esbuild});E&&await E,S.push(O)}catch(v){return{ok:!1,error:v,pluginName:o}}}l["on-start"]=async(p,f)=>{m.clear();let o={errors:[],warnings:[]};await Promise.all(U.map(async({name:v,callback:O,note:M})=>{try{let E=await O();if(E!=null){if(typeof E!="object")throw new Error(`Expected onStart() callback in plugin ${V(v)} to return an object`);let a={},c=r(E,a,"errors",K),h=r(E,a,"warnings",K);Y(E,a,`from onStart() callback in plugin ${V(v)}`),c!=null&&o.errors.push(...ne(c,"errors",m,v,void 0)),h!=null&&o.warnings.push(...ne(h,"warnings",m,v,void 0))}}catch(E){o.errors.push(ie(E,u,m,M&&M(),v))}})),n(p,o)},l["on-resolve"]=async(p,f)=>{let o={},v="",O,M;for(let E of f.ids)try{({name:v,callback:O,note:M}=b[E]);let a=await O({path:f.path,importer:f.importer,namespace:f.namespace,resolveDir:f.resolveDir,kind:f.kind,pluginData:m.load(f.pluginData),with:f.with});if(a!=null){if(typeof a!="object")throw new Error(`Expected onResolve() callback in plugin ${V(v)} to return an object`);let c={},h=r(a,c,"pluginName",y),C=r(a,c,"path",y),P=r(a,c,"namespace",y),$=r(a,c,"suffix",y),x=r(a,c,"external",W),A=r(a,c,"sideEffects",W),R=r(a,c,"pluginData",me),k=r(a,c,"errors",K),D=r(a,c,"warnings",K),q=r(a,c,"watchFiles",K),B=r(a,c,"watchDirs",K);Y(a,c,`from onResolve() callback in plugin ${V(v)}`),o.id=E,h!=null&&(o.pluginName=h),C!=null&&(o.path=C),P!=null&&(o.namespace=P),$!=null&&(o.suffix=$),x!=null&&(o.external=x),A!=null&&(o.sideEffects=A),R!=null&&(o.pluginData=m.store(R)),k!=null&&(o.errors=ne(k,"errors",m,v,void 0)),D!=null&&(o.warnings=ne(D,"warnings",m,v,void 0)),q!=null&&(o.watchFiles=ge(q,"watchFiles")),B!=null&&(o.watchDirs=ge(B,"watchDirs"));break}}catch(a){o={id:E,errors:[ie(a,u,m,M&&M(),v)]};break}n(p,o)},l["on-load"]=async(p,f)=>{let o={},v="",O,M;for(let E of f.ids)try{({name:v,callback:O,note:M}=j[E]);let a=await O({path:f.path,namespace:f.namespace,suffix:f.suffix,pluginData:m.load(f.pluginData),with:f.with});if(a!=null){if(typeof a!="object")throw new Error(`Expected onLoad() callback in plugin ${V(v)} to return an object`);let c={},h=r(a,c,"pluginName",y),C=r(a,c,"contents",De),P=r(a,c,"resolveDir",y),$=r(a,c,"pluginData",me),x=r(a,c,"loader",y),A=r(a,c,"errors",K),R=r(a,c,"warnings",K),k=r(a,c,"watchFiles",K),D=r(a,c,"watchDirs",K);Y(a,c,`from onLoad() callback in plugin ${V(v)}`),o.id=E,h!=null&&(o.pluginName=h),C instanceof Uint8Array?o.contents=C:C!=null&&(o.contents=Z(C)),P!=null&&(o.resolveDir=P),$!=null&&(o.pluginData=m.store($)),x!=null&&(o.loader=x),A!=null&&(o.errors=ne(A,"errors",m,v,void 0)),R!=null&&(o.warnings=ne(R,"warnings",m,v,void 0)),k!=null&&(o.watchFiles=ge(k,"watchFiles")),D!=null&&(o.watchDirs=ge(D,"watchDirs"));break}}catch(a){o={id:E,errors:[ie(a,u,m,M&&M(),v)]};break}n(p,o)};let J=(p,f)=>f([],[]);F.length>0&&(J=(p,f)=>{(async()=>{let o=[],v=[];for(let{name:O,callback:M,note:E}of F){let a,c;try{let h=await M(p);if(h!=null){if(typeof h!="object")throw new Error(`Expected onEnd() callback in plugin ${V(O)} to return an object`);let C={},P=r(h,C,"errors",K),$=r(h,C,"warnings",K);Y(h,C,`from onEnd() callback in plugin ${V(O)}`),P!=null&&(a=ne(P,"errors",m,O,void 0)),$!=null&&(c=ne($,"warnings",m,O,void 0))}}catch(h){a=[ie(h,u,m,E&&E(),O)]}if(a){o.push(...a);try{p.errors.push(...a)}catch(h){}}if(c){v.push(...c);try{p.warnings.push(...c)}catch(h){}}}f(o,v)})()});let w=()=>{for(let p of T)setTimeout(()=>p(),0)};return _=!0,{ok:!0,requestPlugins:S,runOnEndCallbacks:J,scheduleOnDisposeCallbacks:w}};function Ne(){let e=new Map,t=0;return{clear(){e.clear()},load(n){return e.get(n)},store(n){if(n===void 0)return-1;let i=t++;return e.set(i,n),i}}}function pe(e,t,n){let i,u=!1;return()=>{if(u)return i;u=!0;try{let l=(e.stack+"").split(`
|
|
7
|
+
`);l.splice(1,1);let g=qe(t,l,n);if(g)return i={text:e.message,location:g},i}catch(l){}}}function ie(e,t,n,i,u){let l="Internal error",g=null;try{l=(e&&e.message||e)+""}catch(s){}try{g=qe(t,(e.stack+"").split(`
|
|
8
|
+
`),"")}catch(s){}return{id:"",pluginName:u,text:l,location:g,notes:i?[i]:[],detail:n?n.store(e):-1}}function qe(e,t,n){let i=" at ";if(e.readFileSync&&!t[0].startsWith(i)&&t[1].startsWith(i))for(let u=1;u<t.length;u++){let l=t[u];if(l.startsWith(i))for(l=l.slice(i.length);;){let g=/^(?:new |async )?\S+ \((.*)\)$/.exec(l);if(g){l=g[1];continue}if(g=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(l),g){l=g[1];continue}if(g=/^(\S+):(\d+):(\d+)$/.exec(l),g){let s;try{s=e.readFileSync(g[1],"utf8")}catch(b){break}let m=s.split(/\r\n|\r|\n|\u2028|\u2029/)[+g[2]-1]||"",U=+g[3]-1,F=m.slice(U,U+n.length)===n?n.length:0;return{file:g[1],namespace:"file",line:+g[2],column:Z(m.slice(0,U)).length,length:Z(m.slice(U,U+F)).length,lineText:m+`
|
|
9
9
|
`+t.slice(1).join(`
|
|
10
10
|
`),suggestion:""}}break}}return null}function ce(e,t,n){let i=5;e+=t.length<1?"":` with ${t.length} error${t.length<2?"":"s"}:`+t.slice(0,i+1).map((l,g)=>{if(g===i)return`
|
|
11
11
|
...`;if(!l.location)return`
|
|
12
12
|
error: ${l.text}`;let{file:s,line:m,column:U}=l.location,F=l.pluginName?`[plugin: ${l.pluginName}] `:"";return`
|
|
13
|
-
${s}:${m}:${U}: ERROR: ${F}${l.text}`}).join("");let u=new Error(e);for(let[l,g]of[["errors",t],["warnings",n]])Object.defineProperty(u,l,{configurable:!0,enumerable:!0,get:()=>g,set:s=>Object.defineProperty(u,l,{configurable:!0,enumerable:!0,value:s})});return u}function ae(e,t){for(let n of e)n.detail=t.load(n.detail);return e}function Ae(e,t,n){if(e==null)return null;let i={},u=r(e,i,"file",y),l=r(e,i,"namespace",y),g=r(e,i,"line",oe),s=r(e,i,"column",oe),m=r(e,i,"length",oe),U=r(e,i,"lineText",y),F=r(e,i,"suggestion",y);if(Y(e,i,t),U){let b=U.slice(0,(s&&s>0?s:0)+(m&&m>0?m:0)+(n&&n>0?n:80));!/[\x7F-\uFFFF]/.test(b)&&!/\n/.test(U)&&(U=b)}return{file:u||"",namespace:l||"",line:g||0,column:s||0,length:m||0,lineText:U||"",suggestion:F||""}}function ne(e,t,n,i,u){let l=[],g=0;for(let s of e){let m={},U=r(s,m,"id",y),F=r(s,m,"pluginName",y),b=r(s,m,"text",y),j=r(s,m,"location",Ce),T=r(s,m,"notes",K),L=r(s,m,"detail",me),N=`in element ${g} of "${t}"`;Y(s,m,N);let S=[];if(T)for(let _ of T){let J={},w=r(_,J,"text",y),p=r(_,J,"location",Ce);Y(_,J,N),S.push({text:w||"",location:Ae(p,N,u)})}l.push({id:U||"",pluginName:F||i,text:b||"",location:Ae(j,N,u),notes:S,detail:n?n.store(L):-1}),g++}return l}function ge(e,t){let n=[];for(let i of e){if(typeof i!="string")throw new Error(`${V(t)} must be an array of strings`);n.push(i)}return n}function nt(e,t){let n=Object.create(null);for(let i in e){let u=e[i];if(typeof u!="string")throw new Error(`key ${V(i)} in object ${V(t)} must be a string`);n[i]=u}return n}function rt({path:e,contents:t,hash:n}){let i=null;return{path:e,contents:t,hash:n,get text(){let u=this.contents;return(i===null||u!==t)&&(t=u,i=re(u)),i}}}var lt="0.25.0",st=e=>fe().build(e),ot=e=>fe().context(e),at=(e,t)=>fe().transform(e,t),ut=(e,t)=>fe().formatMessages(e,t),ct=(e,t)=>fe().analyzeMetafile(e,t),ft=()=>{throw new Error('The "buildSync" API only works in node')},dt=()=>{throw new Error('The "transformSync" API only works in node')},pt=()=>{throw new Error('The "formatMessagesSync" API only works in node')},gt=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},mt=()=>(be&&be(),Promise.resolve()),le,be,we,fe=()=>{if(we)return we;throw le?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')},yt=e=>{e=De(e||{});let t=e.wasmURL,n=e.wasmModule,i=e.worker!==!1;if(!t&&!n)throw new Error('Must provide either the "wasmURL" option or the "wasmModule" option');if(le)throw new Error('Cannot call "initialize" more than once');return le=ht(t||"",n,i),le.catch(()=>{le=void 0}),le},ht=async(e,t,n)=>{let i,u,l=new Promise(b=>u=b);if(n){let b=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 i=self;i;i=Object.getPrototypeOf(i))for(let f of Object.getOwnPropertyNames(i))f in globalThis||Object.defineProperty(globalThis,f,{get:()=>self[f]});(()=>{const i=()=>{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(r,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(r,s,n,o,c,m){if(n!==0||o!==s.length||c!==null){m(i());return}const h=this.writeSync(r,s);m(null,h)},chmod(r,s,n){n(i())},chown(r,s,n,o){o(i())},close(r,s){s(i())},fchmod(r,s,n){n(i())},fchown(r,s,n,o){o(i())},fstat(r,s){s(i())},fsync(r,s){s(null)},ftruncate(r,s,n){n(i())},lchown(r,s,n,o){o(i())},link(r,s,n){n(i())},lstat(r,s){s(i())},mkdir(r,s,n){n(i())},open(r,s,n,o){o(i())},read(r,s,n,o,c,m){m(i())},readdir(r,s){s(i())},readlink(r,s){s(i())},rename(r,s,n){n(i())},rmdir(r,s){s(i())},stat(r,s){s(i())},symlink(r,s,n){n(i())},truncate(r,s,n){n(i())},unlink(r,s){s(i())},utimes(r,s,n,o){o(i())}}}if(globalThis.process||(globalThis.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw i()},pid:-1,ppid:-1,umask(){throw i()},cwd(){throw i()},chdir(){throw i()}}),!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)},r=(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 r=4096;const s=d=>{const e=r,t=f.encode(d+"\\0");return new Uint8Array(this.mem.buffer,r,t.length).set(t),r+=t.length,r%8!==0&&(r+=8-r%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=r;if(o.forEach(d=>{this.mem.setUint32(r,d,!0),this.mem.setUint32(r+4,0,!0),r+=8}),r>=12288)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 r=this;return function(){const s={id:u,this:this,args:arguments};return r._pendingEvent=s,r._resume(),s.result}}}})(),onmessage=({data:i})=>{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 r=[],s,n=0;onmessage=({data:c})=>(c.length>0&&(r.push(c),s&&s()),o),y.read=(c,m,h,d,e,t)=>{if(c!==0||h!==0||d!==m.length||e!==null)throw new Error("Bad read");if(r.length===0){s=()=>y.read(c,m,h,d,e,t);return}let l=r[0],a=Math.max(0,Math.min(d,l.length-n));m.set(l.subarray(n,n+a),h),n+=a,n===l.length&&(r.shift(),n=0),t(null,a)};let o=new globalThis.Go;return o.argv=["","--service=0.25.0"],tryToInstantiateModule(i,o).then(c=>{postMessage(null),o.run(c)},c=>{postMessage(c)}),o};async function tryToInstantiateModule(i,f){if(i instanceof WebAssembly.Module)return WebAssembly.instantiate(i,f.importObject);const y=await fetch(i);if(!y.ok)throw new Error(`Failed to download ${JSON.stringify(i)}`);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 i=>onmessage(i);})(postMessage)'],{type:"text/javascript"});i=new Worker(URL.createObjectURL(b))}else{let b=(postMessage=>{
|
|
13
|
+
${s}:${m}:${U}: ERROR: ${F}${l.text}`}).join("");let u=new Error(e);for(let[l,g]of[["errors",t],["warnings",n]])Object.defineProperty(u,l,{configurable:!0,enumerable:!0,get:()=>g,set:s=>Object.defineProperty(u,l,{configurable:!0,enumerable:!0,value:s})});return u}function ae(e,t){for(let n of e)n.detail=t.load(n.detail);return e}function Fe(e,t,n){if(e==null)return null;let i={},u=r(e,i,"file",y),l=r(e,i,"namespace",y),g=r(e,i,"line",oe),s=r(e,i,"column",oe),m=r(e,i,"length",oe),U=r(e,i,"lineText",y),F=r(e,i,"suggestion",y);if(Y(e,i,t),U){let b=U.slice(0,(s&&s>0?s:0)+(m&&m>0?m:0)+(n&&n>0?n:80));!/[\x7F-\uFFFF]/.test(b)&&!/\n/.test(U)&&(U=b)}return{file:u||"",namespace:l||"",line:g||0,column:s||0,length:m||0,lineText:U||"",suggestion:F||""}}function ne(e,t,n,i,u){let l=[],g=0;for(let s of e){let m={},U=r(s,m,"id",y),F=r(s,m,"pluginName",y),b=r(s,m,"text",y),j=r(s,m,"location",Ae),T=r(s,m,"notes",K),L=r(s,m,"detail",me),N=`in element ${g} of "${t}"`;Y(s,m,N);let S=[];if(T)for(let _ of T){let J={},w=r(_,J,"text",y),p=r(_,J,"location",Ae);Y(_,J,N),S.push({text:w||"",location:Fe(p,N,u)})}l.push({id:U||"",pluginName:F||i,text:b||"",location:Fe(j,N,u),notes:S,detail:n?n.store(L):-1}),g++}return l}function ge(e,t){let n=[];for(let i of e){if(typeof i!="string")throw new Error(`${V(t)} must be an array of strings`);n.push(i)}return n}function rt(e,t){let n=Object.create(null);for(let i in e){let u=e[i];if(typeof u!="string")throw new Error(`key ${V(i)} in object ${V(t)} must be a string`);n[i]=u}return n}function it({path:e,contents:t,hash:n}){let i=null;return{path:e,contents:t,hash:n,get text(){let u=this.contents;return(i===null||u!==t)&&(t=u,i=re(u)),i}}}function he(e){let t=e.source;return e.flags&&(t=`(?${e.flags})${t}`),t}var st="0.25.2",ot=e=>fe().build(e),at=e=>fe().context(e),ut=(e,t)=>fe().transform(e,t),ct=(e,t)=>fe().formatMessages(e,t),ft=(e,t)=>fe().analyzeMetafile(e,t),dt=()=>{throw new Error('The "buildSync" API only works in node')},pt=()=>{throw new Error('The "transformSync" API only works in node')},gt=()=>{throw new Error('The "formatMessagesSync" API only works in node')},mt=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},yt=()=>(we&&we(),Promise.resolve()),le,we,ve,fe=()=>{if(ve)return ve;throw le?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')},ht=e=>{e=Be(e||{});let t=e.wasmURL,n=e.wasmModule,i=e.worker!==!1;if(!t&&!n)throw new Error('Must provide either the "wasmURL" option or the "wasmModule" option');if(le)throw new Error('Cannot call "initialize" more than once');return le=bt(t||"",n,i),le.catch(()=>{le=void 0}),le},bt=async(e,t,n)=>{let i,u,l=new Promise(b=>u=b);if(n){let b=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 i=self;i;i=Object.getPrototypeOf(i))for(let f of Object.getOwnPropertyNames(i))f in globalThis||Object.defineProperty(globalThis,f,{get:()=>self[f]});(()=>{const i=()=>{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(r,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(r,s,n,o,c,m){if(n!==0||o!==s.length||c!==null){m(i());return}const h=this.writeSync(r,s);m(null,h)},chmod(r,s,n){n(i())},chown(r,s,n,o){o(i())},close(r,s){s(i())},fchmod(r,s,n){n(i())},fchown(r,s,n,o){o(i())},fstat(r,s){s(i())},fsync(r,s){s(null)},ftruncate(r,s,n){n(i())},lchown(r,s,n,o){o(i())},link(r,s,n){n(i())},lstat(r,s){s(i())},mkdir(r,s,n){n(i())},open(r,s,n,o){o(i())},read(r,s,n,o,c,m){m(i())},readdir(r,s){s(i())},readlink(r,s){s(i())},rename(r,s,n){n(i())},rmdir(r,s){s(i())},stat(r,s){s(i())},symlink(r,s,n){n(i())},truncate(r,s,n){n(i())},unlink(r,s){s(i())},utimes(r,s,n,o){o(i())}}}if(globalThis.process||(globalThis.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw i()},pid:-1,ppid:-1,umask(){throw i()},cwd(){throw i()},chdir(){throw i()}}),!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)},r=(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 r=4096;const s=d=>{const e=r,t=f.encode(d+"\\0");return new Uint8Array(this.mem.buffer,r,t.length).set(t),r+=t.length,r%8!==0&&(r+=8-r%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=r;if(o.forEach(d=>{this.mem.setUint32(r,d,!0),this.mem.setUint32(r+4,0,!0),r+=8}),r>=12288)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 r=this;return function(){const s={id:u,this:this,args:arguments};return r._pendingEvent=s,r._resume(),s.result}}}})(),onmessage=({data:i})=>{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 r=[],s,n=0;onmessage=({data:c})=>(c.length>0&&(r.push(c),s&&s()),o),y.read=(c,m,h,d,e,t)=>{if(c!==0||h!==0||d!==m.length||e!==null)throw new Error("Bad read");if(r.length===0){s=()=>y.read(c,m,h,d,e,t);return}let l=r[0],a=Math.max(0,Math.min(d,l.length-n));m.set(l.subarray(n,n+a),h),n+=a,n===l.length&&(r.shift(),n=0),t(null,a)};let o=new globalThis.Go;return o.argv=["","--service=0.25.2"],tryToInstantiateModule(i,o).then(c=>{postMessage(null),o.run(c)},c=>{postMessage(c)}),o};async function tryToInstantiateModule(i,f){if(i instanceof WebAssembly.Module)return WebAssembly.instantiate(i,f.importObject);const y=await fetch(i);if(!y.ok)throw new Error(`Failed to download ${JSON.stringify(i)}`);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 i=>onmessage(i);})(postMessage)'],{type:"text/javascript"});i=new Worker(URL.createObjectURL(b))}else{let b=(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 i=self;i;i=Object.getPrototypeOf(i))for(let f of Object.getOwnPropertyNames(i))f in globalThis||Object.defineProperty(globalThis,f,{get:()=>self[f]});(()=>{const i=()=>{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(r,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(r,s,n,o,c,m){if(n!==0||o!==s.length||c!==null){m(i());return}const h=this.writeSync(r,s);m(null,h)},chmod(r,s,n){n(i())},chown(r,s,n,o){o(i())},close(r,s){s(i())},fchmod(r,s,n){n(i())},fchown(r,s,n,o){o(i())},fstat(r,s){s(i())},fsync(r,s){s(null)},ftruncate(r,s,n){n(i())},lchown(r,s,n,o){o(i())},link(r,s,n){n(i())},lstat(r,s){s(i())},mkdir(r,s,n){n(i())},open(r,s,n,o){o(i())},read(r,s,n,o,c,m){m(i())},readdir(r,s){s(i())},readlink(r,s){s(i())},rename(r,s,n){n(i())},rmdir(r,s){s(i())},stat(r,s){s(i())},symlink(r,s,n){n(i())},truncate(r,s,n){n(i())},unlink(r,s){s(i())},utimes(r,s,n,o){o(i())}}}if(globalThis.process||(globalThis.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw i()},pid:-1,ppid:-1,umask(){throw i()},cwd(){throw i()},chdir(){throw i()}}),!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)},r=(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 r=4096;const s=d=>{const e=r,t=f.encode(d+"\0");return new Uint8Array(this.mem.buffer,r,t.length).set(t),r+=t.length,r%8!==0&&(r+=8-r%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=r;if(o.forEach(d=>{this.mem.setUint32(r,d,!0),this.mem.setUint32(r+4,0,!0),r+=8}),r>=12288)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 r=this;return function(){const s={id:u,this:this,args:arguments};return r._pendingEvent=s,r._resume(),s.result}}}})(),onmessage=({data:i})=>{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 r=[],s,n=0;onmessage=({data:c})=>(c.length>0&&(r.push(c),s&&s()),o),y.read=(c,m,h,d,e,t)=>{if(c!==0||h!==0||d!==m.length||e!==null)throw new Error("Bad read");if(r.length===0){s=()=>y.read(c,m,h,d,e,t);return}let l=r[0],a=Math.max(0,Math.min(d,l.length-n));m.set(l.subarray(n,n+a),h),n+=a,n===l.length&&(r.shift(),n=0),t(null,a)};let o=new globalThis.Go;return o.argv=["","--service=0.25.
|
|
20
|
+
`)),u=h[h.length-1]}else throw new Error("Bad write");return m.length};let r=[],s,n=0;onmessage=({data:c})=>(c.length>0&&(r.push(c),s&&s()),o),y.read=(c,m,h,d,e,t)=>{if(c!==0||h!==0||d!==m.length||e!==null)throw new Error("Bad read");if(r.length===0){s=()=>y.read(c,m,h,d,e,t);return}let l=r[0],a=Math.max(0,Math.min(d,l.length-n));m.set(l.subarray(n,n+a),h),n+=a,n===l.length&&(r.shift(),n=0),t(null,a)};let o=new globalThis.Go;return o.argv=["","--service=0.25.2"],tryToInstantiateModule(i,o).then(c=>{postMessage(null),o.run(c)},c=>{postMessage(c)}),o};async function tryToInstantiateModule(i,f){if(i instanceof WebAssembly.Module)return WebAssembly.instantiate(i,f.importObject);const y=await fetch(i);if(!y.ok)throw new Error(`Failed to download ${JSON.stringify(i)}`);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 i=>onmessage(i);})(T=>i.onmessage({data:T})),j;i={onmessage:null,postMessage:T=>setTimeout(()=>{try{j=b({data:T})}catch(L){u(L)}}),terminate(){if(j)for(let T of j._scheduledTimeouts.values())clearTimeout(T)}}}let g,s,m=new Promise((b,j)=>{g=b,s=j});i.onmessage=({data:b})=>{i.onmessage=({data:j})=>U(j),b?s(b):g()},i.postMessage(t||new URL(e,location.href).toString());let{readFromStdout:U,service:F}=Le({writeToStdin(b){i.postMessage(b)},isSync:!1,hasFS:!1,esbuild:Re});await m,we=()=>{i.terminate(),le=void 0,we=void 0,ve=void 0},ve={build:b=>new Promise((j,T)=>{l.then(T),F.buildOrContext({callName:"build",refs:null,options:b,isTTY:!1,defaultWD:"/",callback:(L,N)=>L?T(L):j(N)})}),context:b=>new Promise((j,T)=>{l.then(T),F.buildOrContext({callName:"context",refs:null,options:b,isTTY:!1,defaultWD:"/",callback:(L,N)=>L?T(L):j(N)})}),transform:(b,j)=>new Promise((T,L)=>{l.then(L),F.transform({callName:"transform",refs:null,input:b,options:j||{},isTTY:!1,fs:{readFile(N,S){S(new Error("Internal error"),null)},writeFile(N,S){S(null)}},callback:(N,S)=>N?L(N):T(S)})}),formatMessages:(b,j)=>new Promise((T,L)=>{l.then(L),F.formatMessages({callName:"formatMessages",refs:null,messages:b,options:j,callback:(N,S)=>N?L(N):T(S)})}),analyzeMetafile:(b,j)=>new Promise((T,L)=>{l.then(L),F.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof b=="string"?b:JSON.stringify(b),options:j,callback:(N,S)=>N?L(N):T(S)})})}},wt=Re;export{ft as analyzeMetafile,mt as analyzeMetafileSync,ot as build,dt as buildSync,at as context,wt as default,ct as formatMessages,gt as formatMessagesSync,ht as initialize,yt as stop,ut as transform,pt as transformSync,st as version};
|
package/lib/browser.js
CHANGED
|
@@ -362,8 +362,8 @@ function pushCommonFlags(flags, options, keys) {
|
|
|
362
362
|
if (ignoreAnnotations) flags.push(`--ignore-annotations`);
|
|
363
363
|
if (drop) for (let what of drop) flags.push(`--drop:${validateStringValue(what, "drop")}`);
|
|
364
364
|
if (dropLabels) flags.push(`--drop-labels=${Array.from(dropLabels).map((what) => validateStringValue(what, "dropLabels")).join(",")}`);
|
|
365
|
-
if (mangleProps) flags.push(`--mangle-props=${mangleProps
|
|
366
|
-
if (reserveProps) flags.push(`--reserve-props=${reserveProps
|
|
365
|
+
if (mangleProps) flags.push(`--mangle-props=${jsRegExpToGoRegExp(mangleProps)}`);
|
|
366
|
+
if (reserveProps) flags.push(`--reserve-props=${jsRegExpToGoRegExp(reserveProps)}`);
|
|
367
367
|
if (mangleQuoted !== void 0) flags.push(`--mangle-quoted=${mangleQuoted}`);
|
|
368
368
|
if (jsx) flags.push(`--jsx=${jsx}`);
|
|
369
369
|
if (jsxFactory) flags.push(`--jsx-factory=${jsxFactory}`);
|
|
@@ -674,8 +674,8 @@ function createChannel(streamIn) {
|
|
|
674
674
|
if (isFirstPacket) {
|
|
675
675
|
isFirstPacket = false;
|
|
676
676
|
let binaryVersion = String.fromCharCode(...bytes);
|
|
677
|
-
if (binaryVersion !== "0.25.
|
|
678
|
-
throw new Error(`Cannot start service: Host version "${"0.25.
|
|
677
|
+
if (binaryVersion !== "0.25.2") {
|
|
678
|
+
throw new Error(`Cannot start service: Host version "${"0.25.2"}" does not match binary version ${quote(binaryVersion)}`);
|
|
679
679
|
}
|
|
680
680
|
return;
|
|
681
681
|
}
|
|
@@ -1184,7 +1184,7 @@ var handlePlugins = (buildKey, sendRequest, sendResponse, refs, streamIn, reques
|
|
|
1184
1184
|
if (filter == null) throw new Error(`onResolve() call is missing a filter`);
|
|
1185
1185
|
let id = nextCallbackID++;
|
|
1186
1186
|
onResolveCallbacks[id] = { name, callback, note: registeredNote };
|
|
1187
|
-
plugin.onResolve.push({ id, filter: filter
|
|
1187
|
+
plugin.onResolve.push({ id, filter: jsRegExpToGoRegExp(filter), namespace: namespace || "" });
|
|
1188
1188
|
},
|
|
1189
1189
|
onLoad(options, callback) {
|
|
1190
1190
|
let registeredText = `This error came from the "onLoad" callback registered here:`;
|
|
@@ -1196,7 +1196,7 @@ var handlePlugins = (buildKey, sendRequest, sendResponse, refs, streamIn, reques
|
|
|
1196
1196
|
if (filter == null) throw new Error(`onLoad() call is missing a filter`);
|
|
1197
1197
|
let id = nextCallbackID++;
|
|
1198
1198
|
onLoadCallbacks[id] = { name, callback, note: registeredNote };
|
|
1199
|
-
plugin.onLoad.push({ id, filter: filter
|
|
1199
|
+
plugin.onLoad.push({ id, filter: jsRegExpToGoRegExp(filter), namespace: namespace || "" });
|
|
1200
1200
|
},
|
|
1201
1201
|
onDispose(callback) {
|
|
1202
1202
|
onDisposeCallbacks.push(callback);
|
|
@@ -1607,9 +1607,14 @@ function convertOutputFiles({ path, contents, hash }) {
|
|
|
1607
1607
|
}
|
|
1608
1608
|
};
|
|
1609
1609
|
}
|
|
1610
|
+
function jsRegExpToGoRegExp(regexp) {
|
|
1611
|
+
let result = regexp.source;
|
|
1612
|
+
if (regexp.flags) result = `(?${regexp.flags})${result}`;
|
|
1613
|
+
return result;
|
|
1614
|
+
}
|
|
1610
1615
|
|
|
1611
1616
|
// lib/npm/browser.ts
|
|
1612
|
-
var version = "0.25.
|
|
1617
|
+
var version = "0.25.2";
|
|
1613
1618
|
var build = (options) => ensureServiceIsRunning().build(options);
|
|
1614
1619
|
var context = (options) => ensureServiceIsRunning().context(options);
|
|
1615
1620
|
var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
|
|
@@ -1657,7 +1662,7 @@ var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, nu
|
|
|
1657
1662
|
let rejectAllWith;
|
|
1658
1663
|
const rejectAllPromise = new Promise((resolve) => rejectAllWith = resolve);
|
|
1659
1664
|
if (useWorker) {
|
|
1660
|
-
let blob = new Blob([`onmessage=${'((postMessage) => {\n // Copyright 2018 The Go Authors. All rights reserved.\n // Use of this source code is governed by a BSD-style\n // license that can be found in the LICENSE file.\n var __async = (__this, __arguments, generator) => {\n return new Promise((resolve, reject) => {\n var fulfilled = (value) => {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n };\n var rejected = (value) => {\n try {\n step(generator.throw(value));\n } catch (e) {\n reject(e);\n }\n };\n var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);\n step((generator = generator.apply(__this, __arguments)).next());\n });\n };\n let onmessage;\n let globalThis = {};\n for (let o = self; o; o = Object.getPrototypeOf(o))\n for (let k of Object.getOwnPropertyNames(o))\n if (!(k in globalThis))\n Object.defineProperty(globalThis, k, { get: () => self[k] });\n "use strict";\n (() => {\n const enosys = () => {\n const err = new Error("not implemented");\n err.code = "ENOSYS";\n return err;\n };\n if (!globalThis.fs) {\n let outputBuf = "";\n globalThis.fs = {\n constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 },\n // unused\n writeSync(fd, buf) {\n outputBuf += decoder.decode(buf);\n const nl = outputBuf.lastIndexOf("\\n");\n if (nl != -1) {\n console.log(outputBuf.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 = (/* @__PURE__ */ 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 run(instance) {\n return __async(this, null, function* () {\n if (!(instance instanceof WebAssembly.Instance)) {\n throw new Error("Go.run: WebAssembly.Instance expected");\n }\n this._inst = instance;\n this.mem = new DataView(this._inst.exports.mem.buffer);\n this._values = [\n // JS values that Go currently has references to, indexed by reference id\n NaN,\n 0,\n null,\n true,\n false,\n globalThis,\n this\n ];\n this._goRefCounts = new Array(this._values.length).fill(Infinity);\n this._ids = /* @__PURE__ */ new Map([\n // mapping from JS values to reference ids\n [0, 1],\n [null, 2],\n [true, 3],\n [false, 4],\n [globalThis, 5],\n [this, 6]\n ]);\n this._idPool = [];\n this.exited = false;\n let offset = 4096;\n const strPtr = (str) => {\n const ptr = offset;\n const bytes = encoder.encode(str + "\\0");\n new Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes);\n offset += bytes.length;\n if (offset % 8 !== 0) {\n offset += 8 - offset % 8;\n }\n return ptr;\n };\n const argc = this.argv.length;\n const argvPtrs = [];\n this.argv.forEach((arg) => {\n argvPtrs.push(strPtr(arg));\n });\n argvPtrs.push(0);\n const keys = Object.keys(this.env).sort();\n keys.forEach((key) => {\n argvPtrs.push(strPtr(`${key}=${this.env[key]}`));\n });\n argvPtrs.push(0);\n const argv = offset;\n argvPtrs.forEach((ptr) => {\n this.mem.setUint32(offset, ptr, true);\n this.mem.setUint32(offset + 4, 0, true);\n offset += 8;\n });\n const wasmMinDataAddr = 4096 + 8192;\n if (offset >= wasmMinDataAddr) {\n throw new Error("total length of command line and environment variables exceeds limit");\n }\n this._inst.exports.run(argc, argv);\n if (this.exited) {\n this._resolveExitPromise();\n }\n yield this._exitPromise;\n });\n }\n _resume() {\n if (this.exited) {\n throw new Error("Go program has already exited");\n }\n this._inst.exports.resume();\n if (this.exited) {\n this._resolveExitPromise();\n }\n }\n _makeFuncWrapper(id) {\n const go = this;\n return function() {\n const event = { id, this: this, args: arguments };\n go._pendingEvent = event;\n go._resume();\n return event.result;\n };\n }\n };\n })();\n onmessage = ({ data: wasm }) => {\n let decoder = new TextDecoder();\n let fs = globalThis.fs;\n let stderr = "";\n fs.writeSync = (fd, buffer) => {\n if (fd === 1) {\n postMessage(buffer);\n } else if (fd === 2) {\n stderr += decoder.decode(buffer);\n let parts = stderr.split("\\n");\n if (parts.length > 1) 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) resumeStdin();\n }\n return go;\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.25.0"}`];\n tryToInstantiateModule(wasm, go).then(\n (instance) => {\n postMessage(null);\n go.run(instance);\n },\n (error) => {\n postMessage(error);\n }\n );\n return go;\n };\n function tryToInstantiateModule(wasm, go) {\n return __async(this, null, function* () {\n if (wasm instanceof WebAssembly.Module) {\n return WebAssembly.instantiate(wasm, go.importObject);\n }\n const res = yield fetch(wasm);\n if (!res.ok) throw new Error(`Failed to download ${JSON.stringify(wasm)}`);\n if ("instantiateStreaming" in WebAssembly && /^application\\/wasm($|;)/i.test(res.headers.get("Content-Type") || "")) {\n const result2 = yield WebAssembly.instantiateStreaming(res, go.importObject);\n return result2.instance;\n }\n const bytes = yield res.arrayBuffer();\n const result = yield WebAssembly.instantiate(bytes, go.importObject);\n return result.instance;\n });\n }\n return (m) => onmessage(m);\n })'}(postMessage)`], { type: "text/javascript" });
|
|
1665
|
+
let blob = new Blob([`onmessage=${'((postMessage) => {\n // Copyright 2018 The Go Authors. All rights reserved.\n // Use of this source code is governed by a BSD-style\n // license that can be found in the LICENSE file.\n var __async = (__this, __arguments, generator) => {\n return new Promise((resolve, reject) => {\n var fulfilled = (value) => {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n };\n var rejected = (value) => {\n try {\n step(generator.throw(value));\n } catch (e) {\n reject(e);\n }\n };\n var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);\n step((generator = generator.apply(__this, __arguments)).next());\n });\n };\n let onmessage;\n let globalThis = {};\n for (let o = self; o; o = Object.getPrototypeOf(o))\n for (let k of Object.getOwnPropertyNames(o))\n if (!(k in globalThis))\n Object.defineProperty(globalThis, k, { get: () => self[k] });\n "use strict";\n (() => {\n const enosys = () => {\n const err = new Error("not implemented");\n err.code = "ENOSYS";\n return err;\n };\n if (!globalThis.fs) {\n let outputBuf = "";\n globalThis.fs = {\n constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 },\n // unused\n writeSync(fd, buf) {\n outputBuf += decoder.decode(buf);\n const nl = outputBuf.lastIndexOf("\\n");\n if (nl != -1) {\n console.log(outputBuf.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 = (/* @__PURE__ */ 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 run(instance) {\n return __async(this, null, function* () {\n if (!(instance instanceof WebAssembly.Instance)) {\n throw new Error("Go.run: WebAssembly.Instance expected");\n }\n this._inst = instance;\n this.mem = new DataView(this._inst.exports.mem.buffer);\n this._values = [\n // JS values that Go currently has references to, indexed by reference id\n NaN,\n 0,\n null,\n true,\n false,\n globalThis,\n this\n ];\n this._goRefCounts = new Array(this._values.length).fill(Infinity);\n this._ids = /* @__PURE__ */ new Map([\n // mapping from JS values to reference ids\n [0, 1],\n [null, 2],\n [true, 3],\n [false, 4],\n [globalThis, 5],\n [this, 6]\n ]);\n this._idPool = [];\n this.exited = false;\n let offset = 4096;\n const strPtr = (str) => {\n const ptr = offset;\n const bytes = encoder.encode(str + "\\0");\n new Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes);\n offset += bytes.length;\n if (offset % 8 !== 0) {\n offset += 8 - offset % 8;\n }\n return ptr;\n };\n const argc = this.argv.length;\n const argvPtrs = [];\n this.argv.forEach((arg) => {\n argvPtrs.push(strPtr(arg));\n });\n argvPtrs.push(0);\n const keys = Object.keys(this.env).sort();\n keys.forEach((key) => {\n argvPtrs.push(strPtr(`${key}=${this.env[key]}`));\n });\n argvPtrs.push(0);\n const argv = offset;\n argvPtrs.forEach((ptr) => {\n this.mem.setUint32(offset, ptr, true);\n this.mem.setUint32(offset + 4, 0, true);\n offset += 8;\n });\n const wasmMinDataAddr = 4096 + 8192;\n if (offset >= wasmMinDataAddr) {\n throw new Error("total length of command line and environment variables exceeds limit");\n }\n this._inst.exports.run(argc, argv);\n if (this.exited) {\n this._resolveExitPromise();\n }\n yield this._exitPromise;\n });\n }\n _resume() {\n if (this.exited) {\n throw new Error("Go program has already exited");\n }\n this._inst.exports.resume();\n if (this.exited) {\n this._resolveExitPromise();\n }\n }\n _makeFuncWrapper(id) {\n const go = this;\n return function() {\n const event = { id, this: this, args: arguments };\n go._pendingEvent = event;\n go._resume();\n return event.result;\n };\n }\n };\n })();\n onmessage = ({ data: wasm }) => {\n let decoder = new TextDecoder();\n let fs = globalThis.fs;\n let stderr = "";\n fs.writeSync = (fd, buffer) => {\n if (fd === 1) {\n postMessage(buffer);\n } else if (fd === 2) {\n stderr += decoder.decode(buffer);\n let parts = stderr.split("\\n");\n if (parts.length > 1) 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) resumeStdin();\n }\n return go;\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.25.2"}`];\n tryToInstantiateModule(wasm, go).then(\n (instance) => {\n postMessage(null);\n go.run(instance);\n },\n (error) => {\n postMessage(error);\n }\n );\n return go;\n };\n function tryToInstantiateModule(wasm, go) {\n return __async(this, null, function* () {\n if (wasm instanceof WebAssembly.Module) {\n return WebAssembly.instantiate(wasm, go.importObject);\n }\n const res = yield fetch(wasm);\n if (!res.ok) throw new Error(`Failed to download ${JSON.stringify(wasm)}`);\n if ("instantiateStreaming" in WebAssembly && /^application\\/wasm($|;)/i.test(res.headers.get("Content-Type") || "")) {\n const result2 = yield WebAssembly.instantiateStreaming(res, go.importObject);\n return result2.instance;\n }\n const bytes = yield res.arrayBuffer();\n const result = yield WebAssembly.instantiate(bytes, go.importObject);\n return result.instance;\n });\n }\n return (m) => onmessage(m);\n })'}(postMessage)`], { type: "text/javascript" });
|
|
1661
1666
|
worker = new Worker(URL.createObjectURL(blob));
|
|
1662
1667
|
} else {
|
|
1663
1668
|
let onmessage = ((postMessage) => {
|
|
@@ -2297,7 +2302,7 @@ var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, nu
|
|
|
2297
2302
|
callback(null, count);
|
|
2298
2303
|
};
|
|
2299
2304
|
let go = new globalThis.Go();
|
|
2300
|
-
go.argv = ["", `--service=${"0.25.
|
|
2305
|
+
go.argv = ["", `--service=${"0.25.2"}`];
|
|
2301
2306
|
tryToInstantiateModule(wasm, go).then(
|
|
2302
2307
|
(instance) => {
|
|
2303
2308
|
postMessage(null);
|
package/lib/browser.min.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
(module=>{
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var Oe=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var Je=Object.prototype.hasOwnProperty;var Ge=(e,t)=>{for(var n in t)Oe(e,n,{get:t[n],enumerable:!0})},Qe=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ye(t))!Je.call(e,a)&&a!==n&&Oe(e,a,{get:()=>t[a],enumerable:!(i=Ve(t,a))||i.enumerable});return e};var He=e=>Qe(Oe({},"__esModule",{value:!0}),e);var ne=(e,t,n)=>new Promise((i,a)=>{var l=d=>{try{s(n.next(d))}catch(P){a(P)}},p=d=>{try{s(n.throw(d))}catch(P){a(P)}},s=d=>d.done?i(d.value):Promise.resolve(d.value).then(l,p);s((n=n.apply(e,t)).next())});var xe={};Ge(xe,{analyzeMetafile:()=>ht,analyzeMetafileSync:()=>Rt,build:()=>pt,buildSync:()=>bt,context:()=>gt,default:()=>St,formatMessages:()=>yt,formatMessagesSync:()=>vt,initialize:()=>Ot,stop:()=>xt,transform:()=>mt,transformSync:()=>wt,version:()=>dt});module.exports=He(xe);function ke(e){let t=i=>{if(i===null)n.write8(0);else if(typeof i=="boolean")n.write8(1),n.write8(+i);else if(typeof i=="number")n.write8(2),n.write32(i|0);else if(typeof i=="string")n.write8(3),n.write(Z(i));else if(i instanceof Uint8Array)n.write8(4),n.write(i);else if(i instanceof Array){n.write8(5),n.write32(i.length);for(let a of i)t(a)}else{let a=Object.keys(i);n.write8(6),n.write32(a.length);for(let l of a)n.write(Z(l)),t(i[l])}},n=new pe;return n.write32(0),n.write32(e.id<<1|+!e.isRequest),t(e.value),Se(n.buf,n.len-4,0),n.buf.subarray(0,n.len)}function Me(e){let t=()=>{switch(n.read8()){case 0:return null;case 1:return!!n.read8();case 2:return n.read32();case 3:return ie(n.read());case 4:return n.read();case 5:{let p=n.read32(),s=[];for(let d=0;d<p;d++)s.push(t());return s}case 6:{let p=n.read32(),s={};for(let d=0;d<p;d++)s[ie(n.read())]=t();return s}default:throw new Error("Invalid packet")}},n=new pe(e),i=n.read32(),a=(i&1)===0;i>>>=1;let l=t();if(n.ptr!==e.length)throw new Error("Invalid packet");return{id:i,isRequest:a,value:l}}var pe=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);Se(this.buf,t,n)}write(t){let n=this._write(4+t.length);Se(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 $e(this.buf,this._read(4))}read(){let t=this.read32(),n=new Uint8Array(t),i=this._read(n.length);return n.set(this.buf.subarray(i,i+t)),n}},Z,ie,Ee;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;Z=n=>e.encode(n),ie=n=>t.decode(n),Ee='new TextEncoder().encode("")'}else if(typeof Buffer!="undefined")Z=e=>Buffer.from(e),ie=e=>{let{buffer:t,byteOffset:n,byteLength:i}=e;return Buffer.from(t,n,i).toString()},Ee='Buffer.from("")';else throw new Error("No UTF-8 codec found");if(!(Z("")instanceof Uint8Array))throw new Error(`Invariant violation: "${Ee} instanceof Uint8Array" is incorrectly false
|
|
3
3
|
|
|
4
4
|
This indicates that your JavaScript environment is broken. You cannot use
|
|
5
5
|
esbuild in this environment because esbuild relies on this invariant. This
|
|
6
6
|
is not a problem with esbuild. You need to fix your environment instead.
|
|
7
|
-
`);function ke(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function Ee(e,t,n){e[n++]=t,e[n++]=t>>8,e[n++]=t>>16,e[n++]=t>>24}var V=JSON.stringify,Me="warning",Ce="silent";function Ae(e){if(G(e,"target"),e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var ye=()=>null,W=e=>typeof e=="boolean"?null:"a boolean",y=e=>typeof e=="string"?null:"a string",he=e=>e instanceof RegExp?null:"a RegExp object",ae=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Xe=e=>typeof e=="number"&&e===(e|0)&&e>=0&&e<=65535?null:"a valid port number",Te=e=>typeof e=="function"?null:"a function",K=e=>Array.isArray(e)?null:"an array",ee=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",et=e=>e instanceof WebAssembly.Module?null:"a WebAssembly.Module",Fe=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",tt=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",nt=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",Be=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array",rt=e=>typeof e=="string"||e instanceof URL?null:"a string or a URL";function r(e,t,n,i){let a=e[n];if(t[n+""]=!0,a===void 0)return;let l=i(a);if(l!==null)throw new Error(`${V(n)} must be ${l}`);return a}function Y(e,t,n){for(let i in e)if(!(i in t))throw new Error(`Invalid option ${n}: ${V(i)}`)}function Ue(e){let t=Object.create(null),n=r(e,t,"wasmURL",rt),i=r(e,t,"wasmModule",et),a=r(e,t,"worker",W);return Y(e,t,"in initialize() call"),{wasmURL:n,wasmModule:i,worker:a}}function je(e){let t;if(e!==void 0){t=Object.create(null);for(let n in e){let i=e[n];if(typeof i=="string"||i===!1)t[n]=i;else throw new Error(`Expected ${V(n)} in mangle cache to map to either a string or false`)}}return t}function be(e,t,n,i,a){let l=r(t,n,"color",W),p=r(t,n,"logLevel",y),s=r(t,n,"logLimit",ae);l!==void 0?e.push(`--color=${l}`):i&&e.push("--color=true"),e.push(`--log-level=${p||a}`),e.push(`--log-limit=${s||0}`)}function G(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 Le(e,t,n){let i=r(t,n,"legalComments",y),a=r(t,n,"sourceRoot",y),l=r(t,n,"sourcesContent",W),p=r(t,n,"target",nt),s=r(t,n,"format",y),d=r(t,n,"globalName",y),P=r(t,n,"mangleProps",he),A=r(t,n,"reserveProps",he),b=r(t,n,"mangleQuoted",W),j=r(t,n,"minify",W),T=r(t,n,"minifySyntax",W),L=r(t,n,"minifyWhitespace",W),N=r(t,n,"minifyIdentifiers",W),E=r(t,n,"lineLimit",ae),_=r(t,n,"drop",K),J=r(t,n,"dropLabels",K),w=r(t,n,"charset",y),m=r(t,n,"treeShaking",W),f=r(t,n,"ignoreAnnotations",W),o=r(t,n,"jsx",y),v=r(t,n,"jsxFactory",y),O=r(t,n,"jsxFragment",y),M=r(t,n,"jsxImportSource",y),D=r(t,n,"jsxDev",W),u=r(t,n,"jsxSideEffects",W),c=r(t,n,"define",ee),h=r(t,n,"logOverride",ee),S=r(t,n,"supported",ee),F=r(t,n,"pure",K),$=r(t,n,"keepNames",W),x=r(t,n,"platform",y),C=r(t,n,"tsconfigRaw",tt);if(i&&e.push(`--legal-comments=${i}`),a!==void 0&&e.push(`--source-root=${a}`),l!==void 0&&e.push(`--sources-content=${l}`),p&&(Array.isArray(p)?e.push(`--target=${Array.from(p).map(Ae).join(",")}`):e.push(`--target=${Ae(p)}`)),s&&e.push(`--format=${s}`),d&&e.push(`--global-name=${d}`),x&&e.push(`--platform=${x}`),C&&e.push(`--tsconfig-raw=${typeof C=="string"?C:JSON.stringify(C)}`),j&&e.push("--minify"),T&&e.push("--minify-syntax"),L&&e.push("--minify-whitespace"),N&&e.push("--minify-identifiers"),E&&e.push(`--line-limit=${E}`),w&&e.push(`--charset=${w}`),m!==void 0&&e.push(`--tree-shaking=${m}`),f&&e.push("--ignore-annotations"),_)for(let R of _)e.push(`--drop:${G(R,"drop")}`);if(J&&e.push(`--drop-labels=${Array.from(J).map(R=>G(R,"dropLabels")).join(",")}`),P&&e.push(`--mangle-props=${P.source}`),A&&e.push(`--reserve-props=${A.source}`),b!==void 0&&e.push(`--mangle-quoted=${b}`),o&&e.push(`--jsx=${o}`),v&&e.push(`--jsx-factory=${v}`),O&&e.push(`--jsx-fragment=${O}`),M&&e.push(`--jsx-import-source=${M}`),D&&e.push("--jsx-dev"),u&&e.push("--jsx-side-effects"),c)for(let R in c){if(R.indexOf("=")>=0)throw new Error(`Invalid define: ${R}`);e.push(`--define:${R}=${G(c[R],"define",R)}`)}if(h)for(let R in h){if(R.indexOf("=")>=0)throw new Error(`Invalid log override: ${R}`);e.push(`--log-override:${R}=${G(h[R],"log override",R)}`)}if(S)for(let R in S){if(R.indexOf("=")>=0)throw new Error(`Invalid supported: ${R}`);let k=S[R];if(typeof k!="boolean")throw new Error(`Expected value for supported ${V(R)} to be a boolean, got ${typeof k} instead`);e.push(`--supported:${R}=${k}`)}if(F)for(let R of F)e.push(`--pure:${G(R,"pure")}`);$&&e.push("--keep-names")}function it(e,t,n,i,a){var oe;let l=[],p=[],s=Object.create(null),d=null,P=null;be(l,t,s,n,i),Le(l,t,s);let A=r(t,s,"sourcemap",De),b=r(t,s,"bundle",W),j=r(t,s,"splitting",W),T=r(t,s,"preserveSymlinks",W),L=r(t,s,"metafile",W),N=r(t,s,"outfile",y),E=r(t,s,"outdir",y),_=r(t,s,"outbase",y),J=r(t,s,"tsconfig",y),w=r(t,s,"resolveExtensions",K),m=r(t,s,"nodePaths",K),f=r(t,s,"mainFields",K),o=r(t,s,"conditions",K),v=r(t,s,"external",K),O=r(t,s,"packages",y),M=r(t,s,"alias",ee),D=r(t,s,"loader",ee),u=r(t,s,"outExtension",ee),c=r(t,s,"publicPath",y),h=r(t,s,"entryNames",y),S=r(t,s,"chunkNames",y),F=r(t,s,"assetNames",y),$=r(t,s,"inject",K),x=r(t,s,"banner",ee),C=r(t,s,"footer",ee),R=r(t,s,"entryPoints",Ze),k=r(t,s,"absWorkingDir",y),B=r(t,s,"stdin",ee),q=(oe=r(t,s,"write",W))!=null?oe:a,U=r(t,s,"allowOverwrite",W),H=r(t,s,"mangleCache",ee);if(s.plugins=!0,Y(t,s,`in ${e}() call`),A&&l.push(`--sourcemap${A===!0?"":`=${A}`}`),b&&l.push("--bundle"),U&&l.push("--allow-overwrite"),j&&l.push("--splitting"),T&&l.push("--preserve-symlinks"),L&&l.push("--metafile"),N&&l.push(`--outfile=${N}`),E&&l.push(`--outdir=${E}`),_&&l.push(`--outbase=${_}`),J&&l.push(`--tsconfig=${J}`),O&&l.push(`--packages=${O}`),w){let g=[];for(let I of w){if(G(I,"resolve extension"),I.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${I}`);g.push(I)}l.push(`--resolve-extensions=${g.join(",")}`)}if(c&&l.push(`--public-path=${c}`),h&&l.push(`--entry-names=${h}`),S&&l.push(`--chunk-names=${S}`),F&&l.push(`--asset-names=${F}`),f){let g=[];for(let I of f){if(G(I,"main field"),I.indexOf(",")>=0)throw new Error(`Invalid main field: ${I}`);g.push(I)}l.push(`--main-fields=${g.join(",")}`)}if(o){let g=[];for(let I of o){if(G(I,"condition"),I.indexOf(",")>=0)throw new Error(`Invalid condition: ${I}`);g.push(I)}l.push(`--conditions=${g.join(",")}`)}if(v)for(let g of v)l.push(`--external:${G(g,"external")}`);if(M)for(let g in M){if(g.indexOf("=")>=0)throw new Error(`Invalid package name in alias: ${g}`);l.push(`--alias:${g}=${G(M[g],"alias",g)}`)}if(x)for(let g in x){if(g.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${g}`);l.push(`--banner:${g}=${G(x[g],"banner",g)}`)}if(C)for(let g in C){if(g.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${g}`);l.push(`--footer:${g}=${G(C[g],"footer",g)}`)}if($)for(let g of $)l.push(`--inject:${G(g,"inject")}`);if(D)for(let g in D){if(g.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${g}`);l.push(`--loader:${g}=${G(D[g],"loader",g)}`)}if(u)for(let g in u){if(g.indexOf("=")>=0)throw new Error(`Invalid out extension: ${g}`);l.push(`--out-extension:${g}=${G(u[g],"out extension",g)}`)}if(R)if(Array.isArray(R))for(let g=0,I=R.length;g<I;g++){let X=R[g];if(typeof X=="object"&&X!==null){let te=Object.create(null),Q=r(X,te,"in",y),ce=r(X,te,"out",y);if(Y(X,te,"in entry point at index "+g),Q===void 0)throw new Error('Missing property "in" for entry point at index '+g);if(ce===void 0)throw new Error('Missing property "out" for entry point at index '+g);p.push([ce,Q])}else p.push(["",G(X,"entry point at index "+g)])}else for(let g in R)p.push([g,G(R[g],"entry point",g)]);if(B){let g=Object.create(null),I=r(B,g,"contents",Be),X=r(B,g,"resolveDir",y),te=r(B,g,"sourcefile",y),Q=r(B,g,"loader",y);Y(B,g,'in "stdin" object'),te&&l.push(`--sourcefile=${te}`),Q&&l.push(`--loader=${Q}`),X&&(P=X),typeof I=="string"?d=Z(I):I instanceof Uint8Array&&(d=I)}let z=[];if(m)for(let g of m)g+="",z.push(g);return{entries:p,flags:l,write:q,stdinContents:d,stdinResolveDir:P,absWorkingDir:k,nodePaths:z,mangleCache:je(H)}}function lt(e,t,n,i){let a=[],l=Object.create(null);be(a,t,l,n,i),Le(a,t,l);let p=r(t,l,"sourcemap",De),s=r(t,l,"sourcefile",y),d=r(t,l,"loader",y),P=r(t,l,"banner",y),A=r(t,l,"footer",y),b=r(t,l,"mangleCache",ee);return Y(t,l,`in ${e}() call`),p&&a.push(`--sourcemap=${p===!0?"external":p}`),s&&a.push(`--sourcefile=${s}`),d&&a.push(`--loader=${d}`),P&&a.push(`--banner=${P}`),A&&a.push(`--footer=${A}`),{flags:a,mangleCache:je(b)}}function Ne(e){let t={},n={didClose:!1,reason:""},i={},a=0,l=0,p=new Uint8Array(16*1024),s=0,d=w=>{let m=s+w.length;if(m>p.length){let o=new Uint8Array(m*2);o.set(p),p=o}p.set(w,s),s+=w.length;let f=0;for(;f+4<=s;){let o=ke(p,f);if(f+4+o>s)break;f+=4,L(p.subarray(f,f+o)),f+=o}f>0&&(p.copyWithin(0,f,s),s-=f)},P=w=>{n.didClose=!0,w&&(n.reason=": "+(w.message||w));let m="The service was stopped"+n.reason;for(let f in i)i[f](m,null);i={}},A=(w,m,f)=>{if(n.didClose)return f("The service is no longer running"+n.reason,null);let o=a++;i[o]=(v,O)=>{try{f(v,O)}finally{w&&w.unref()}},w&&w.ref(),e.writeToStdin(Se({id:o,isRequest:!0,value:m}))},b=(w,m)=>{if(n.didClose)throw new Error("The service is no longer running"+n.reason);e.writeToStdin(Se({id:w,isRequest:!1,value:m}))},j=(w,m)=>ne(this,null,function*(){try{if(m.command==="ping"){b(w,{});return}if(typeof m.key=="number"){let f=t[m.key];if(!f)return;let o=f[m.command];if(o){yield o(w,m);return}}throw new Error("Invalid command: "+m.command)}catch(f){let o=[le(f,e,null,void 0,"")];try{b(w,{errors:o})}catch(v){}}}),T=!0,L=w=>{if(T){T=!1;let f=String.fromCharCode(...w);if(f!=="0.25.0")throw new Error(`Cannot start service: Host version "0.25.0" does not match binary version ${V(f)}`);return}let m=$e(w);if(m.isRequest)j(m.id,m.value);else{let f=i[m.id];delete i[m.id],m.value.error?f(m.value.error,{}):f(null,m.value)}};return{readFromStdout:d,afterClose:P,service:{buildOrContext:({callName:w,refs:m,options:f,isTTY:o,defaultWD:v,callback:O})=>{let M=0,D=l++,u={},c={ref(){++M===1&&m&&m.ref()},unref(){--M===0&&(delete t[D],m&&m.unref())}};t[D]=u,c.ref(),st(w,D,A,b,c,e,u,f,o,v,(h,S)=>{try{O(h,S)}finally{c.unref()}})},transform:({callName:w,refs:m,input:f,options:o,isTTY:v,fs:O,callback:M})=>{let D=qe(),u=c=>{try{if(typeof f!="string"&&!(f instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:h,mangleCache:S}=lt(w,o,v,Ce),F={command:"transform",flags:h,inputFS:c!==null,input:c!==null?Z(c):typeof f=="string"?Z(f):f};S&&(F.mangleCache=S),A(m,F,($,x)=>{if($)return M(new Error($),null);let C=ue(x.errors,D),R=ue(x.warnings,D),k=1,B=()=>{if(--k===0){let q={warnings:R,code:x.code,map:x.map,mangleCache:void 0,legalComments:void 0};"legalComments"in x&&(q.legalComments=x==null?void 0:x.legalComments),x.mangleCache&&(q.mangleCache=x==null?void 0:x.mangleCache),M(null,q)}};if(C.length>0)return M(fe("Transform failed",C,R),null);x.codeFS&&(k++,O.readFile(x.code,(q,U)=>{q!==null?M(q,null):(x.code=U,B())})),x.mapFS&&(k++,O.readFile(x.map,(q,U)=>{q!==null?M(q,null):(x.map=U,B())})),B()})}catch(h){let S=[];try{be(S,o,{},v,Ce)}catch($){}let F=le(h,e,D,void 0,"");A(m,{command:"error",flags:S,error:F},()=>{F.detail=D.load(F.detail),M(fe("Transform failed",[F],[]),null)})}};if((typeof f=="string"||f instanceof Uint8Array)&&f.length>1024*1024){let c=u;u=()=>O.writeFile(f,c)}u(null)},formatMessages:({callName:w,refs:m,messages:f,options:o,callback:v})=>{if(!o)throw new Error(`Missing second argument in ${w}() call`);let O={},M=r(o,O,"kind",y),D=r(o,O,"color",W),u=r(o,O,"terminalWidth",ae);if(Y(o,O,`in ${w}() call`),M===void 0)throw new Error(`Missing "kind" in ${w}() call`);if(M!=="error"&&M!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${w}() call`);let c={command:"format-msgs",messages:re(f,"messages",null,"",u),isWarning:M==="warning"};D!==void 0&&(c.color=D),u!==void 0&&(c.terminalWidth=u),A(m,c,(h,S)=>{if(h)return v(new Error(h),null);v(null,S.messages)})},analyzeMetafile:({callName:w,refs:m,metafile:f,options:o,callback:v})=>{o===void 0&&(o={});let O={},M=r(o,O,"color",W),D=r(o,O,"verbose",W);Y(o,O,`in ${w}() call`);let u={command:"analyze-metafile",metafile:f};M!==void 0&&(u.color=M),D!==void 0&&(u.verbose=D),A(m,u,(c,h)=>{if(c)return v(new Error(c),null);v(null,h.result)})}}}}function st(e,t,n,i,a,l,p,s,d,P,A){let b=qe(),j=e==="context",T=(E,_)=>{let J=[];try{be(J,s,{},d,Me)}catch(m){}let w=le(E,l,b,void 0,_);n(a,{command:"error",flags:J,error:w},()=>{w.detail=b.load(w.detail),A(fe(j?"Context failed":"Build failed",[w],[]),null)})},L;if(typeof s=="object"){let E=s.plugins;if(E!==void 0){if(!Array.isArray(E))return T(new Error('"plugins" must be an array'),"");L=E}}if(L&&L.length>0){if(l.isSync)return T(new Error("Cannot use plugins in synchronous API calls"),"");ot(t,n,i,a,l,p,s,L,b).then(E=>{if(!E.ok)return T(E.error,E.pluginName);try{N(E.requestPlugins,E.runOnEndCallbacks,E.scheduleOnDisposeCallbacks)}catch(_){T(_,"")}},E=>T(E,""));return}try{N(null,(E,_)=>_([],[]),()=>{})}catch(E){T(E,"")}function N(E,_,J){let w=l.hasFS,{entries:m,flags:f,write:o,stdinContents:v,stdinResolveDir:O,absWorkingDir:M,nodePaths:D,mangleCache:u}=it(e,s,d,Me,w);if(o&&!l.hasFS)throw new Error('The "write" option is unavailable in this environment');let c={command:"build",key:t,entries:m,flags:f,write:o,stdinContents:v,stdinResolveDir:O,absWorkingDir:M||P,nodePaths:D,context:j};E&&(c.plugins=E),u&&(c.mangleCache=u);let h=($,x)=>{let C={errors:ue($.errors,b),warnings:ue($.warnings,b),outputFiles:void 0,metafile:void 0,mangleCache:void 0},R=C.errors.slice(),k=C.warnings.slice();$.outputFiles&&(C.outputFiles=$.outputFiles.map(ut)),$.metafile&&(C.metafile=JSON.parse($.metafile)),$.mangleCache&&(C.mangleCache=$.mangleCache),$.writeToStdout!==void 0&&console.log(ie($.writeToStdout).replace(/\n$/,"")),_(C,(B,q)=>{if(R.length>0||B.length>0){let U=fe("Build failed",R.concat(B),k.concat(q));return x(U,null,B,q)}x(null,C,B,q)})},S,F;j&&(p["on-end"]=($,x)=>new Promise(C=>{h(x,(R,k,B,q)=>{let U={errors:B,warnings:q};F&&F(R,k),S=void 0,F=void 0,i($,U),C()})})),n(a,c,($,x)=>{if($)return A(new Error($),null);if(!j)return h(x,(k,B)=>(J(),A(k,B)));if(x.errors.length>0)return A(fe("Context failed",x.errors,x.warnings),null);let C=!1,R={rebuild:()=>(S||(S=new Promise((k,B)=>{let q;F=(H,z)=>{q||(q=()=>H?B(H):k(z))};let U=()=>{n(a,{command:"rebuild",key:t},(z,oe)=>{z?B(new Error(z)):q?q():U()})};U()})),S),watch:(k={})=>new Promise((B,q)=>{if(!l.hasFS)throw new Error('Cannot use the "watch" API in this environment');Y(k,{},"in watch() call"),n(a,{command:"watch",key:t},z=>{z?q(new Error(z)):B(void 0)})}),serve:(k={})=>new Promise((B,q)=>{if(!l.hasFS)throw new Error('Cannot use the "serve" API in this environment');let U={},H=r(k,U,"port",Xe),z=r(k,U,"host",y),oe=r(k,U,"servedir",y),g=r(k,U,"keyfile",y),I=r(k,U,"certfile",y),X=r(k,U,"fallback",y),te=r(k,U,"onRequest",Te);Y(k,U,"in serve() call");let Q={command:"serve",key:t,onRequest:!!te};H!==void 0&&(Q.port=H),z!==void 0&&(Q.host=z),oe!==void 0&&(Q.servedir=oe),g!==void 0&&(Q.keyfile=g),I!==void 0&&(Q.certfile=I),X!==void 0&&(Q.fallback=X),n(a,Q,(ce,We)=>{if(ce)return q(new Error(ce));te&&(p["serve-request"]=(ze,Ke)=>{te(Ke.args),i(ze,{})}),B(We)})}),cancel:()=>new Promise(k=>{if(C)return k();n(a,{command:"cancel",key:t},()=>{k()})}),dispose:()=>new Promise(k=>{if(C)return k();C=!0,n(a,{command:"dispose",key:t},()=>{k(),J(),a.unref()})})};a.ref(),A(null,R)})}}var ot=(e,t,n,i,a,l,p,s,d)=>ne(void 0,null,function*(){let P=[],A=[],b={},j={},T=[],L=0,N=0,E=[],_=!1;s=[...s];for(let m of s){let f={};if(typeof m!="object")throw new Error(`Plugin at index ${N} must be an object`);let o=r(m,f,"name",y);if(typeof o!="string"||o==="")throw new Error(`Plugin at index ${N} is missing a name`);try{let v=r(m,f,"setup",Te);if(typeof v!="function")throw new Error("Plugin is missing a setup function");Y(m,f,`on plugin ${V(o)}`);let O={name:o,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};N++;let D=v({initialOptions:p,resolve:(u,c={})=>{if(!_)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof u!="string")throw new Error("The path to resolve must be a string");let h=Object.create(null),S=r(c,h,"pluginName",y),F=r(c,h,"importer",y),$=r(c,h,"namespace",y),x=r(c,h,"resolveDir",y),C=r(c,h,"kind",y),R=r(c,h,"pluginData",ye),k=r(c,h,"with",ee);return Y(c,h,"in resolve() call"),new Promise((B,q)=>{let U={command:"resolve",path:u,key:e,pluginName:o};if(S!=null&&(U.pluginName=S),F!=null&&(U.importer=F),$!=null&&(U.namespace=$),x!=null&&(U.resolveDir=x),C!=null)U.kind=C;else throw new Error('Must specify "kind" when calling "resolve"');R!=null&&(U.pluginData=d.store(R)),k!=null&&(U.with=at(k,"with")),t(i,U,(H,z)=>{H!==null?q(new Error(H)):B({errors:ue(z.errors,d),warnings:ue(z.warnings,d),path:z.path,external:z.external,sideEffects:z.sideEffects,namespace:z.namespace,suffix:z.suffix,pluginData:d.load(z.pluginData)})})})},onStart(u){let c='This error came from the "onStart" callback registered here:',h=ge(new Error(c),a,"onStart");P.push({name:o,callback:u,note:h}),O.onStart=!0},onEnd(u){let c='This error came from the "onEnd" callback registered here:',h=ge(new Error(c),a,"onEnd");A.push({name:o,callback:u,note:h}),O.onEnd=!0},onResolve(u,c){let h='This error came from the "onResolve" callback registered here:',S=ge(new Error(h),a,"onResolve"),F={},$=r(u,F,"filter",he),x=r(u,F,"namespace",y);if(Y(u,F,`in onResolve() call for plugin ${V(o)}`),$==null)throw new Error("onResolve() call is missing a filter");let C=L++;b[C]={name:o,callback:c,note:S},O.onResolve.push({id:C,filter:$.source,namespace:x||""})},onLoad(u,c){let h='This error came from the "onLoad" callback registered here:',S=ge(new Error(h),a,"onLoad"),F={},$=r(u,F,"filter",he),x=r(u,F,"namespace",y);if(Y(u,F,`in onLoad() call for plugin ${V(o)}`),$==null)throw new Error("onLoad() call is missing a filter");let C=L++;j[C]={name:o,callback:c,note:S},O.onLoad.push({id:C,filter:$.source,namespace:x||""})},onDispose(u){T.push(u)},esbuild:a.esbuild});D&&(yield D),E.push(O)}catch(v){return{ok:!1,error:v,pluginName:o}}}l["on-start"]=(m,f)=>ne(void 0,null,function*(){d.clear();let o={errors:[],warnings:[]};yield Promise.all(P.map(D=>ne(void 0,[D],function*({name:v,callback:O,note:M}){try{let u=yield O();if(u!=null){if(typeof u!="object")throw new Error(`Expected onStart() callback in plugin ${V(v)} to return an object`);let c={},h=r(u,c,"errors",K),S=r(u,c,"warnings",K);Y(u,c,`from onStart() callback in plugin ${V(v)}`),h!=null&&o.errors.push(...re(h,"errors",d,v,void 0)),S!=null&&o.warnings.push(...re(S,"warnings",d,v,void 0))}}catch(u){o.errors.push(le(u,a,d,M&&M(),v))}}))),n(m,o)}),l["on-resolve"]=(m,f)=>ne(void 0,null,function*(){let o={},v="",O,M;for(let D of f.ids)try{({name:v,callback:O,note:M}=b[D]);let u=yield O({path:f.path,importer:f.importer,namespace:f.namespace,resolveDir:f.resolveDir,kind:f.kind,pluginData:d.load(f.pluginData),with:f.with});if(u!=null){if(typeof u!="object")throw new Error(`Expected onResolve() callback in plugin ${V(v)} to return an object`);let c={},h=r(u,c,"pluginName",y),S=r(u,c,"path",y),F=r(u,c,"namespace",y),$=r(u,c,"suffix",y),x=r(u,c,"external",W),C=r(u,c,"sideEffects",W),R=r(u,c,"pluginData",ye),k=r(u,c,"errors",K),B=r(u,c,"warnings",K),q=r(u,c,"watchFiles",K),U=r(u,c,"watchDirs",K);Y(u,c,`from onResolve() callback in plugin ${V(v)}`),o.id=D,h!=null&&(o.pluginName=h),S!=null&&(o.path=S),F!=null&&(o.namespace=F),$!=null&&(o.suffix=$),x!=null&&(o.external=x),C!=null&&(o.sideEffects=C),R!=null&&(o.pluginData=d.store(R)),k!=null&&(o.errors=re(k,"errors",d,v,void 0)),B!=null&&(o.warnings=re(B,"warnings",d,v,void 0)),q!=null&&(o.watchFiles=me(q,"watchFiles")),U!=null&&(o.watchDirs=me(U,"watchDirs"));break}}catch(u){o={id:D,errors:[le(u,a,d,M&&M(),v)]};break}n(m,o)}),l["on-load"]=(m,f)=>ne(void 0,null,function*(){let o={},v="",O,M;for(let D of f.ids)try{({name:v,callback:O,note:M}=j[D]);let u=yield O({path:f.path,namespace:f.namespace,suffix:f.suffix,pluginData:d.load(f.pluginData),with:f.with});if(u!=null){if(typeof u!="object")throw new Error(`Expected onLoad() callback in plugin ${V(v)} to return an object`);let c={},h=r(u,c,"pluginName",y),S=r(u,c,"contents",Be),F=r(u,c,"resolveDir",y),$=r(u,c,"pluginData",ye),x=r(u,c,"loader",y),C=r(u,c,"errors",K),R=r(u,c,"warnings",K),k=r(u,c,"watchFiles",K),B=r(u,c,"watchDirs",K);Y(u,c,`from onLoad() callback in plugin ${V(v)}`),o.id=D,h!=null&&(o.pluginName=h),S instanceof Uint8Array?o.contents=S:S!=null&&(o.contents=Z(S)),F!=null&&(o.resolveDir=F),$!=null&&(o.pluginData=d.store($)),x!=null&&(o.loader=x),C!=null&&(o.errors=re(C,"errors",d,v,void 0)),R!=null&&(o.warnings=re(R,"warnings",d,v,void 0)),k!=null&&(o.watchFiles=me(k,"watchFiles")),B!=null&&(o.watchDirs=me(B,"watchDirs"));break}}catch(u){o={id:D,errors:[le(u,a,d,M&&M(),v)]};break}n(m,o)});let J=(m,f)=>f([],[]);A.length>0&&(J=(m,f)=>{ne(void 0,null,function*(){let o=[],v=[];for(let{name:O,callback:M,note:D}of A){let u,c;try{let h=yield M(m);if(h!=null){if(typeof h!="object")throw new Error(`Expected onEnd() callback in plugin ${V(O)} to return an object`);let S={},F=r(h,S,"errors",K),$=r(h,S,"warnings",K);Y(h,S,`from onEnd() callback in plugin ${V(O)}`),F!=null&&(u=re(F,"errors",d,O,void 0)),$!=null&&(c=re($,"warnings",d,O,void 0))}}catch(h){u=[le(h,a,d,D&&D(),O)]}if(u){o.push(...u);try{m.errors.push(...u)}catch(h){}}if(c){v.push(...c);try{m.warnings.push(...c)}catch(h){}}}f(o,v)})});let w=()=>{for(let m of T)setTimeout(()=>m(),0)};return _=!0,{ok:!0,requestPlugins:E,runOnEndCallbacks:J,scheduleOnDisposeCallbacks:w}});function qe(){let e=new Map,t=0;return{clear(){e.clear()},load(n){return e.get(n)},store(n){if(n===void 0)return-1;let i=t++;return e.set(i,n),i}}}function ge(e,t,n){let i,a=!1;return()=>{if(a)return i;a=!0;try{let l=(e.stack+"").split(`
|
|
8
|
-
`);l.splice(1,1);let p=
|
|
9
|
-
`),"")}catch(s){}return{id:"",pluginName:a,text:l,location:p,notes:i?[i]:[],detail:n?n.store(e):-1}}function
|
|
7
|
+
`);function $e(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function Se(e,t,n){e[n++]=t,e[n++]=t>>8,e[n++]=t>>16,e[n++]=t>>24}var V=JSON.stringify,Ce="warning",Ae="silent";function Fe(e){if(G(e,"target"),e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var ye=()=>null,W=e=>typeof e=="boolean"?null:"a boolean",y=e=>typeof e=="string"?null:"a string",he=e=>e instanceof RegExp?null:"a RegExp object",ae=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Ze=e=>typeof e=="number"&&e===(e|0)&&e>=0&&e<=65535?null:"a valid port number",De=e=>typeof e=="function"?null:"a function",K=e=>Array.isArray(e)?null:"an array",ee=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",et=e=>typeof e=="object"&&e!==null?null:"an array or an object",tt=e=>e instanceof WebAssembly.Module?null:"a WebAssembly.Module",Pe=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",Be=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",nt=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",rt=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",Ue=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array",it=e=>typeof e=="string"||e instanceof URL?null:"a string or a URL";function r(e,t,n,i){let a=e[n];if(t[n+""]=!0,a===void 0)return;let l=i(a);if(l!==null)throw new Error(`${V(n)} must be ${l}`);return a}function Y(e,t,n){for(let i in e)if(!(i in t))throw new Error(`Invalid option ${n}: ${V(i)}`)}function je(e){let t=Object.create(null),n=r(e,t,"wasmURL",it),i=r(e,t,"wasmModule",tt),a=r(e,t,"worker",W);return Y(e,t,"in initialize() call"),{wasmURL:n,wasmModule:i,worker:a}}function Le(e){let t;if(e!==void 0){t=Object.create(null);for(let n in e){let i=e[n];if(typeof i=="string"||i===!1)t[n]=i;else throw new Error(`Expected ${V(n)} in mangle cache to map to either a string or false`)}}return t}function we(e,t,n,i,a){let l=r(t,n,"color",W),p=r(t,n,"logLevel",y),s=r(t,n,"logLimit",ae);l!==void 0?e.push(`--color=${l}`):i&&e.push("--color=true"),e.push(`--log-level=${p||a}`),e.push(`--log-limit=${s||0}`)}function G(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 Ne(e,t,n){let i=r(t,n,"legalComments",y),a=r(t,n,"sourceRoot",y),l=r(t,n,"sourcesContent",W),p=r(t,n,"target",rt),s=r(t,n,"format",y),d=r(t,n,"globalName",y),P=r(t,n,"mangleProps",he),A=r(t,n,"reserveProps",he),b=r(t,n,"mangleQuoted",W),j=r(t,n,"minify",W),T=r(t,n,"minifySyntax",W),L=r(t,n,"minifyWhitespace",W),N=r(t,n,"minifyIdentifiers",W),E=r(t,n,"lineLimit",ae),_=r(t,n,"drop",K),J=r(t,n,"dropLabels",K),w=r(t,n,"charset",y),m=r(t,n,"treeShaking",W),f=r(t,n,"ignoreAnnotations",W),o=r(t,n,"jsx",y),v=r(t,n,"jsxFactory",y),O=r(t,n,"jsxFragment",y),M=r(t,n,"jsxImportSource",y),D=r(t,n,"jsxDev",W),u=r(t,n,"jsxSideEffects",W),c=r(t,n,"define",ee),h=r(t,n,"logOverride",ee),S=r(t,n,"supported",ee),F=r(t,n,"pure",K),$=r(t,n,"keepNames",W),x=r(t,n,"platform",y),C=r(t,n,"tsconfigRaw",nt);if(i&&e.push(`--legal-comments=${i}`),a!==void 0&&e.push(`--source-root=${a}`),l!==void 0&&e.push(`--sources-content=${l}`),p&&(Array.isArray(p)?e.push(`--target=${Array.from(p).map(Fe).join(",")}`):e.push(`--target=${Fe(p)}`)),s&&e.push(`--format=${s}`),d&&e.push(`--global-name=${d}`),x&&e.push(`--platform=${x}`),C&&e.push(`--tsconfig-raw=${typeof C=="string"?C:JSON.stringify(C)}`),j&&e.push("--minify"),T&&e.push("--minify-syntax"),L&&e.push("--minify-whitespace"),N&&e.push("--minify-identifiers"),E&&e.push(`--line-limit=${E}`),w&&e.push(`--charset=${w}`),m!==void 0&&e.push(`--tree-shaking=${m}`),f&&e.push("--ignore-annotations"),_)for(let R of _)e.push(`--drop:${G(R,"drop")}`);if(J&&e.push(`--drop-labels=${Array.from(J).map(R=>G(R,"dropLabels")).join(",")}`),P&&e.push(`--mangle-props=${be(P)}`),A&&e.push(`--reserve-props=${be(A)}`),b!==void 0&&e.push(`--mangle-quoted=${b}`),o&&e.push(`--jsx=${o}`),v&&e.push(`--jsx-factory=${v}`),O&&e.push(`--jsx-fragment=${O}`),M&&e.push(`--jsx-import-source=${M}`),D&&e.push("--jsx-dev"),u&&e.push("--jsx-side-effects"),c)for(let R in c){if(R.indexOf("=")>=0)throw new Error(`Invalid define: ${R}`);e.push(`--define:${R}=${G(c[R],"define",R)}`)}if(h)for(let R in h){if(R.indexOf("=")>=0)throw new Error(`Invalid log override: ${R}`);e.push(`--log-override:${R}=${G(h[R],"log override",R)}`)}if(S)for(let R in S){if(R.indexOf("=")>=0)throw new Error(`Invalid supported: ${R}`);let k=S[R];if(typeof k!="boolean")throw new Error(`Expected value for supported ${V(R)} to be a boolean, got ${typeof k} instead`);e.push(`--supported:${R}=${k}`)}if(F)for(let R of F)e.push(`--pure:${G(R,"pure")}`);$&&e.push("--keep-names")}function lt(e,t,n,i,a){var oe;let l=[],p=[],s=Object.create(null),d=null,P=null;we(l,t,s,n,i),Ne(l,t,s);let A=r(t,s,"sourcemap",Be),b=r(t,s,"bundle",W),j=r(t,s,"splitting",W),T=r(t,s,"preserveSymlinks",W),L=r(t,s,"metafile",W),N=r(t,s,"outfile",y),E=r(t,s,"outdir",y),_=r(t,s,"outbase",y),J=r(t,s,"tsconfig",y),w=r(t,s,"resolveExtensions",K),m=r(t,s,"nodePaths",K),f=r(t,s,"mainFields",K),o=r(t,s,"conditions",K),v=r(t,s,"external",K),O=r(t,s,"packages",y),M=r(t,s,"alias",ee),D=r(t,s,"loader",ee),u=r(t,s,"outExtension",ee),c=r(t,s,"publicPath",y),h=r(t,s,"entryNames",y),S=r(t,s,"chunkNames",y),F=r(t,s,"assetNames",y),$=r(t,s,"inject",K),x=r(t,s,"banner",ee),C=r(t,s,"footer",ee),R=r(t,s,"entryPoints",et),k=r(t,s,"absWorkingDir",y),B=r(t,s,"stdin",ee),q=(oe=r(t,s,"write",W))!=null?oe:a,U=r(t,s,"allowOverwrite",W),H=r(t,s,"mangleCache",ee);if(s.plugins=!0,Y(t,s,`in ${e}() call`),A&&l.push(`--sourcemap${A===!0?"":`=${A}`}`),b&&l.push("--bundle"),U&&l.push("--allow-overwrite"),j&&l.push("--splitting"),T&&l.push("--preserve-symlinks"),L&&l.push("--metafile"),N&&l.push(`--outfile=${N}`),E&&l.push(`--outdir=${E}`),_&&l.push(`--outbase=${_}`),J&&l.push(`--tsconfig=${J}`),O&&l.push(`--packages=${O}`),w){let g=[];for(let I of w){if(G(I,"resolve extension"),I.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${I}`);g.push(I)}l.push(`--resolve-extensions=${g.join(",")}`)}if(c&&l.push(`--public-path=${c}`),h&&l.push(`--entry-names=${h}`),S&&l.push(`--chunk-names=${S}`),F&&l.push(`--asset-names=${F}`),f){let g=[];for(let I of f){if(G(I,"main field"),I.indexOf(",")>=0)throw new Error(`Invalid main field: ${I}`);g.push(I)}l.push(`--main-fields=${g.join(",")}`)}if(o){let g=[];for(let I of o){if(G(I,"condition"),I.indexOf(",")>=0)throw new Error(`Invalid condition: ${I}`);g.push(I)}l.push(`--conditions=${g.join(",")}`)}if(v)for(let g of v)l.push(`--external:${G(g,"external")}`);if(M)for(let g in M){if(g.indexOf("=")>=0)throw new Error(`Invalid package name in alias: ${g}`);l.push(`--alias:${g}=${G(M[g],"alias",g)}`)}if(x)for(let g in x){if(g.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${g}`);l.push(`--banner:${g}=${G(x[g],"banner",g)}`)}if(C)for(let g in C){if(g.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${g}`);l.push(`--footer:${g}=${G(C[g],"footer",g)}`)}if($)for(let g of $)l.push(`--inject:${G(g,"inject")}`);if(D)for(let g in D){if(g.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${g}`);l.push(`--loader:${g}=${G(D[g],"loader",g)}`)}if(u)for(let g in u){if(g.indexOf("=")>=0)throw new Error(`Invalid out extension: ${g}`);l.push(`--out-extension:${g}=${G(u[g],"out extension",g)}`)}if(R)if(Array.isArray(R))for(let g=0,I=R.length;g<I;g++){let X=R[g];if(typeof X=="object"&&X!==null){let te=Object.create(null),Q=r(X,te,"in",y),ce=r(X,te,"out",y);if(Y(X,te,"in entry point at index "+g),Q===void 0)throw new Error('Missing property "in" for entry point at index '+g);if(ce===void 0)throw new Error('Missing property "out" for entry point at index '+g);p.push([ce,Q])}else p.push(["",G(X,"entry point at index "+g)])}else for(let g in R)p.push([g,G(R[g],"entry point",g)]);if(B){let g=Object.create(null),I=r(B,g,"contents",Ue),X=r(B,g,"resolveDir",y),te=r(B,g,"sourcefile",y),Q=r(B,g,"loader",y);Y(B,g,'in "stdin" object'),te&&l.push(`--sourcefile=${te}`),Q&&l.push(`--loader=${Q}`),X&&(P=X),typeof I=="string"?d=Z(I):I instanceof Uint8Array&&(d=I)}let z=[];if(m)for(let g of m)g+="",z.push(g);return{entries:p,flags:l,write:q,stdinContents:d,stdinResolveDir:P,absWorkingDir:k,nodePaths:z,mangleCache:Le(H)}}function st(e,t,n,i){let a=[],l=Object.create(null);we(a,t,l,n,i),Ne(a,t,l);let p=r(t,l,"sourcemap",Be),s=r(t,l,"sourcefile",y),d=r(t,l,"loader",y),P=r(t,l,"banner",y),A=r(t,l,"footer",y),b=r(t,l,"mangleCache",ee);return Y(t,l,`in ${e}() call`),p&&a.push(`--sourcemap=${p===!0?"external":p}`),s&&a.push(`--sourcefile=${s}`),d&&a.push(`--loader=${d}`),P&&a.push(`--banner=${P}`),A&&a.push(`--footer=${A}`),{flags:a,mangleCache:Le(b)}}function qe(e){let t={},n={didClose:!1,reason:""},i={},a=0,l=0,p=new Uint8Array(16*1024),s=0,d=w=>{let m=s+w.length;if(m>p.length){let o=new Uint8Array(m*2);o.set(p),p=o}p.set(w,s),s+=w.length;let f=0;for(;f+4<=s;){let o=$e(p,f);if(f+4+o>s)break;f+=4,L(p.subarray(f,f+o)),f+=o}f>0&&(p.copyWithin(0,f,s),s-=f)},P=w=>{n.didClose=!0,w&&(n.reason=": "+(w.message||w));let m="The service was stopped"+n.reason;for(let f in i)i[f](m,null);i={}},A=(w,m,f)=>{if(n.didClose)return f("The service is no longer running"+n.reason,null);let o=a++;i[o]=(v,O)=>{try{f(v,O)}finally{w&&w.unref()}},w&&w.ref(),e.writeToStdin(ke({id:o,isRequest:!0,value:m}))},b=(w,m)=>{if(n.didClose)throw new Error("The service is no longer running"+n.reason);e.writeToStdin(ke({id:w,isRequest:!1,value:m}))},j=(w,m)=>ne(this,null,function*(){try{if(m.command==="ping"){b(w,{});return}if(typeof m.key=="number"){let f=t[m.key];if(!f)return;let o=f[m.command];if(o){yield o(w,m);return}}throw new Error("Invalid command: "+m.command)}catch(f){let o=[le(f,e,null,void 0,"")];try{b(w,{errors:o})}catch(v){}}}),T=!0,L=w=>{if(T){T=!1;let f=String.fromCharCode(...w);if(f!=="0.25.2")throw new Error(`Cannot start service: Host version "0.25.2" does not match binary version ${V(f)}`);return}let m=Me(w);if(m.isRequest)j(m.id,m.value);else{let f=i[m.id];delete i[m.id],m.value.error?f(m.value.error,{}):f(null,m.value)}};return{readFromStdout:d,afterClose:P,service:{buildOrContext:({callName:w,refs:m,options:f,isTTY:o,defaultWD:v,callback:O})=>{let M=0,D=l++,u={},c={ref(){++M===1&&m&&m.ref()},unref(){--M===0&&(delete t[D],m&&m.unref())}};t[D]=u,c.ref(),ot(w,D,A,b,c,e,u,f,o,v,(h,S)=>{try{O(h,S)}finally{c.unref()}})},transform:({callName:w,refs:m,input:f,options:o,isTTY:v,fs:O,callback:M})=>{let D=Ie(),u=c=>{try{if(typeof f!="string"&&!(f instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:h,mangleCache:S}=st(w,o,v,Ae),F={command:"transform",flags:h,inputFS:c!==null,input:c!==null?Z(c):typeof f=="string"?Z(f):f};S&&(F.mangleCache=S),A(m,F,($,x)=>{if($)return M(new Error($),null);let C=ue(x.errors,D),R=ue(x.warnings,D),k=1,B=()=>{if(--k===0){let q={warnings:R,code:x.code,map:x.map,mangleCache:void 0,legalComments:void 0};"legalComments"in x&&(q.legalComments=x==null?void 0:x.legalComments),x.mangleCache&&(q.mangleCache=x==null?void 0:x.mangleCache),M(null,q)}};if(C.length>0)return M(fe("Transform failed",C,R),null);x.codeFS&&(k++,O.readFile(x.code,(q,U)=>{q!==null?M(q,null):(x.code=U,B())})),x.mapFS&&(k++,O.readFile(x.map,(q,U)=>{q!==null?M(q,null):(x.map=U,B())})),B()})}catch(h){let S=[];try{we(S,o,{},v,Ae)}catch($){}let F=le(h,e,D,void 0,"");A(m,{command:"error",flags:S,error:F},()=>{F.detail=D.load(F.detail),M(fe("Transform failed",[F],[]),null)})}};if((typeof f=="string"||f instanceof Uint8Array)&&f.length>1024*1024){let c=u;u=()=>O.writeFile(f,c)}u(null)},formatMessages:({callName:w,refs:m,messages:f,options:o,callback:v})=>{if(!o)throw new Error(`Missing second argument in ${w}() call`);let O={},M=r(o,O,"kind",y),D=r(o,O,"color",W),u=r(o,O,"terminalWidth",ae);if(Y(o,O,`in ${w}() call`),M===void 0)throw new Error(`Missing "kind" in ${w}() call`);if(M!=="error"&&M!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${w}() call`);let c={command:"format-msgs",messages:re(f,"messages",null,"",u),isWarning:M==="warning"};D!==void 0&&(c.color=D),u!==void 0&&(c.terminalWidth=u),A(m,c,(h,S)=>{if(h)return v(new Error(h),null);v(null,S.messages)})},analyzeMetafile:({callName:w,refs:m,metafile:f,options:o,callback:v})=>{o===void 0&&(o={});let O={},M=r(o,O,"color",W),D=r(o,O,"verbose",W);Y(o,O,`in ${w}() call`);let u={command:"analyze-metafile",metafile:f};M!==void 0&&(u.color=M),D!==void 0&&(u.verbose=D),A(m,u,(c,h)=>{if(c)return v(new Error(c),null);v(null,h.result)})}}}}function ot(e,t,n,i,a,l,p,s,d,P,A){let b=Ie(),j=e==="context",T=(E,_)=>{let J=[];try{we(J,s,{},d,Ce)}catch(m){}let w=le(E,l,b,void 0,_);n(a,{command:"error",flags:J,error:w},()=>{w.detail=b.load(w.detail),A(fe(j?"Context failed":"Build failed",[w],[]),null)})},L;if(typeof s=="object"){let E=s.plugins;if(E!==void 0){if(!Array.isArray(E))return T(new Error('"plugins" must be an array'),"");L=E}}if(L&&L.length>0){if(l.isSync)return T(new Error("Cannot use plugins in synchronous API calls"),"");at(t,n,i,a,l,p,s,L,b).then(E=>{if(!E.ok)return T(E.error,E.pluginName);try{N(E.requestPlugins,E.runOnEndCallbacks,E.scheduleOnDisposeCallbacks)}catch(_){T(_,"")}},E=>T(E,""));return}try{N(null,(E,_)=>_([],[]),()=>{})}catch(E){T(E,"")}function N(E,_,J){let w=l.hasFS,{entries:m,flags:f,write:o,stdinContents:v,stdinResolveDir:O,absWorkingDir:M,nodePaths:D,mangleCache:u}=lt(e,s,d,Ce,w);if(o&&!l.hasFS)throw new Error('The "write" option is unavailable in this environment');let c={command:"build",key:t,entries:m,flags:f,write:o,stdinContents:v,stdinResolveDir:O,absWorkingDir:M||P,nodePaths:D,context:j};E&&(c.plugins=E),u&&(c.mangleCache=u);let h=($,x)=>{let C={errors:ue($.errors,b),warnings:ue($.warnings,b),outputFiles:void 0,metafile:void 0,mangleCache:void 0},R=C.errors.slice(),k=C.warnings.slice();$.outputFiles&&(C.outputFiles=$.outputFiles.map(ct)),$.metafile&&(C.metafile=JSON.parse($.metafile)),$.mangleCache&&(C.mangleCache=$.mangleCache),$.writeToStdout!==void 0&&console.log(ie($.writeToStdout).replace(/\n$/,"")),_(C,(B,q)=>{if(R.length>0||B.length>0){let U=fe("Build failed",R.concat(B),k.concat(q));return x(U,null,B,q)}x(null,C,B,q)})},S,F;j&&(p["on-end"]=($,x)=>new Promise(C=>{h(x,(R,k,B,q)=>{let U={errors:B,warnings:q};F&&F(R,k),S=void 0,F=void 0,i($,U),C()})})),n(a,c,($,x)=>{if($)return A(new Error($),null);if(!j)return h(x,(k,B)=>(J(),A(k,B)));if(x.errors.length>0)return A(fe("Context failed",x.errors,x.warnings),null);let C=!1,R={rebuild:()=>(S||(S=new Promise((k,B)=>{let q;F=(H,z)=>{q||(q=()=>H?B(H):k(z))};let U=()=>{n(a,{command:"rebuild",key:t},(z,oe)=>{z?B(new Error(z)):q?q():U()})};U()})),S),watch:(k={})=>new Promise((B,q)=>{if(!l.hasFS)throw new Error('Cannot use the "watch" API in this environment');Y(k,{},"in watch() call"),n(a,{command:"watch",key:t},z=>{z?q(new Error(z)):B(void 0)})}),serve:(k={})=>new Promise((B,q)=>{if(!l.hasFS)throw new Error('Cannot use the "serve" API in this environment');let U={},H=r(k,U,"port",Ze),z=r(k,U,"host",y),oe=r(k,U,"servedir",y),g=r(k,U,"keyfile",y),I=r(k,U,"certfile",y),X=r(k,U,"fallback",y),te=r(k,U,"onRequest",De);Y(k,U,"in serve() call");let Q={command:"serve",key:t,onRequest:!!te};H!==void 0&&(Q.port=H),z!==void 0&&(Q.host=z),oe!==void 0&&(Q.servedir=oe),g!==void 0&&(Q.keyfile=g),I!==void 0&&(Q.certfile=I),X!==void 0&&(Q.fallback=X),n(a,Q,(ce,ze)=>{if(ce)return q(new Error(ce));te&&(p["serve-request"]=(Ke,_e)=>{te(_e.args),i(Ke,{})}),B(ze)})}),cancel:()=>new Promise(k=>{if(C)return k();n(a,{command:"cancel",key:t},()=>{k()})}),dispose:()=>new Promise(k=>{if(C)return k();C=!0,n(a,{command:"dispose",key:t},()=>{k(),J(),a.unref()})})};a.ref(),A(null,R)})}}var at=(e,t,n,i,a,l,p,s,d)=>ne(void 0,null,function*(){let P=[],A=[],b={},j={},T=[],L=0,N=0,E=[],_=!1;s=[...s];for(let m of s){let f={};if(typeof m!="object")throw new Error(`Plugin at index ${N} must be an object`);let o=r(m,f,"name",y);if(typeof o!="string"||o==="")throw new Error(`Plugin at index ${N} is missing a name`);try{let v=r(m,f,"setup",De);if(typeof v!="function")throw new Error("Plugin is missing a setup function");Y(m,f,`on plugin ${V(o)}`);let O={name:o,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};N++;let D=v({initialOptions:p,resolve:(u,c={})=>{if(!_)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof u!="string")throw new Error("The path to resolve must be a string");let h=Object.create(null),S=r(c,h,"pluginName",y),F=r(c,h,"importer",y),$=r(c,h,"namespace",y),x=r(c,h,"resolveDir",y),C=r(c,h,"kind",y),R=r(c,h,"pluginData",ye),k=r(c,h,"with",ee);return Y(c,h,"in resolve() call"),new Promise((B,q)=>{let U={command:"resolve",path:u,key:e,pluginName:o};if(S!=null&&(U.pluginName=S),F!=null&&(U.importer=F),$!=null&&(U.namespace=$),x!=null&&(U.resolveDir=x),C!=null)U.kind=C;else throw new Error('Must specify "kind" when calling "resolve"');R!=null&&(U.pluginData=d.store(R)),k!=null&&(U.with=ut(k,"with")),t(i,U,(H,z)=>{H!==null?q(new Error(H)):B({errors:ue(z.errors,d),warnings:ue(z.warnings,d),path:z.path,external:z.external,sideEffects:z.sideEffects,namespace:z.namespace,suffix:z.suffix,pluginData:d.load(z.pluginData)})})})},onStart(u){let c='This error came from the "onStart" callback registered here:',h=ge(new Error(c),a,"onStart");P.push({name:o,callback:u,note:h}),O.onStart=!0},onEnd(u){let c='This error came from the "onEnd" callback registered here:',h=ge(new Error(c),a,"onEnd");A.push({name:o,callback:u,note:h}),O.onEnd=!0},onResolve(u,c){let h='This error came from the "onResolve" callback registered here:',S=ge(new Error(h),a,"onResolve"),F={},$=r(u,F,"filter",he),x=r(u,F,"namespace",y);if(Y(u,F,`in onResolve() call for plugin ${V(o)}`),$==null)throw new Error("onResolve() call is missing a filter");let C=L++;b[C]={name:o,callback:c,note:S},O.onResolve.push({id:C,filter:be($),namespace:x||""})},onLoad(u,c){let h='This error came from the "onLoad" callback registered here:',S=ge(new Error(h),a,"onLoad"),F={},$=r(u,F,"filter",he),x=r(u,F,"namespace",y);if(Y(u,F,`in onLoad() call for plugin ${V(o)}`),$==null)throw new Error("onLoad() call is missing a filter");let C=L++;j[C]={name:o,callback:c,note:S},O.onLoad.push({id:C,filter:be($),namespace:x||""})},onDispose(u){T.push(u)},esbuild:a.esbuild});D&&(yield D),E.push(O)}catch(v){return{ok:!1,error:v,pluginName:o}}}l["on-start"]=(m,f)=>ne(void 0,null,function*(){d.clear();let o={errors:[],warnings:[]};yield Promise.all(P.map(D=>ne(void 0,[D],function*({name:v,callback:O,note:M}){try{let u=yield O();if(u!=null){if(typeof u!="object")throw new Error(`Expected onStart() callback in plugin ${V(v)} to return an object`);let c={},h=r(u,c,"errors",K),S=r(u,c,"warnings",K);Y(u,c,`from onStart() callback in plugin ${V(v)}`),h!=null&&o.errors.push(...re(h,"errors",d,v,void 0)),S!=null&&o.warnings.push(...re(S,"warnings",d,v,void 0))}}catch(u){o.errors.push(le(u,a,d,M&&M(),v))}}))),n(m,o)}),l["on-resolve"]=(m,f)=>ne(void 0,null,function*(){let o={},v="",O,M;for(let D of f.ids)try{({name:v,callback:O,note:M}=b[D]);let u=yield O({path:f.path,importer:f.importer,namespace:f.namespace,resolveDir:f.resolveDir,kind:f.kind,pluginData:d.load(f.pluginData),with:f.with});if(u!=null){if(typeof u!="object")throw new Error(`Expected onResolve() callback in plugin ${V(v)} to return an object`);let c={},h=r(u,c,"pluginName",y),S=r(u,c,"path",y),F=r(u,c,"namespace",y),$=r(u,c,"suffix",y),x=r(u,c,"external",W),C=r(u,c,"sideEffects",W),R=r(u,c,"pluginData",ye),k=r(u,c,"errors",K),B=r(u,c,"warnings",K),q=r(u,c,"watchFiles",K),U=r(u,c,"watchDirs",K);Y(u,c,`from onResolve() callback in plugin ${V(v)}`),o.id=D,h!=null&&(o.pluginName=h),S!=null&&(o.path=S),F!=null&&(o.namespace=F),$!=null&&(o.suffix=$),x!=null&&(o.external=x),C!=null&&(o.sideEffects=C),R!=null&&(o.pluginData=d.store(R)),k!=null&&(o.errors=re(k,"errors",d,v,void 0)),B!=null&&(o.warnings=re(B,"warnings",d,v,void 0)),q!=null&&(o.watchFiles=me(q,"watchFiles")),U!=null&&(o.watchDirs=me(U,"watchDirs"));break}}catch(u){o={id:D,errors:[le(u,a,d,M&&M(),v)]};break}n(m,o)}),l["on-load"]=(m,f)=>ne(void 0,null,function*(){let o={},v="",O,M;for(let D of f.ids)try{({name:v,callback:O,note:M}=j[D]);let u=yield O({path:f.path,namespace:f.namespace,suffix:f.suffix,pluginData:d.load(f.pluginData),with:f.with});if(u!=null){if(typeof u!="object")throw new Error(`Expected onLoad() callback in plugin ${V(v)} to return an object`);let c={},h=r(u,c,"pluginName",y),S=r(u,c,"contents",Ue),F=r(u,c,"resolveDir",y),$=r(u,c,"pluginData",ye),x=r(u,c,"loader",y),C=r(u,c,"errors",K),R=r(u,c,"warnings",K),k=r(u,c,"watchFiles",K),B=r(u,c,"watchDirs",K);Y(u,c,`from onLoad() callback in plugin ${V(v)}`),o.id=D,h!=null&&(o.pluginName=h),S instanceof Uint8Array?o.contents=S:S!=null&&(o.contents=Z(S)),F!=null&&(o.resolveDir=F),$!=null&&(o.pluginData=d.store($)),x!=null&&(o.loader=x),C!=null&&(o.errors=re(C,"errors",d,v,void 0)),R!=null&&(o.warnings=re(R,"warnings",d,v,void 0)),k!=null&&(o.watchFiles=me(k,"watchFiles")),B!=null&&(o.watchDirs=me(B,"watchDirs"));break}}catch(u){o={id:D,errors:[le(u,a,d,M&&M(),v)]};break}n(m,o)});let J=(m,f)=>f([],[]);A.length>0&&(J=(m,f)=>{ne(void 0,null,function*(){let o=[],v=[];for(let{name:O,callback:M,note:D}of A){let u,c;try{let h=yield M(m);if(h!=null){if(typeof h!="object")throw new Error(`Expected onEnd() callback in plugin ${V(O)} to return an object`);let S={},F=r(h,S,"errors",K),$=r(h,S,"warnings",K);Y(h,S,`from onEnd() callback in plugin ${V(O)}`),F!=null&&(u=re(F,"errors",d,O,void 0)),$!=null&&(c=re($,"warnings",d,O,void 0))}}catch(h){u=[le(h,a,d,D&&D(),O)]}if(u){o.push(...u);try{m.errors.push(...u)}catch(h){}}if(c){v.push(...c);try{m.warnings.push(...c)}catch(h){}}}f(o,v)})});let w=()=>{for(let m of T)setTimeout(()=>m(),0)};return _=!0,{ok:!0,requestPlugins:E,runOnEndCallbacks:J,scheduleOnDisposeCallbacks:w}});function Ie(){let e=new Map,t=0;return{clear(){e.clear()},load(n){return e.get(n)},store(n){if(n===void 0)return-1;let i=t++;return e.set(i,n),i}}}function ge(e,t,n){let i,a=!1;return()=>{if(a)return i;a=!0;try{let l=(e.stack+"").split(`
|
|
8
|
+
`);l.splice(1,1);let p=We(t,l,n);if(p)return i={text:e.message,location:p},i}catch(l){}}}function le(e,t,n,i,a){let l="Internal error",p=null;try{l=(e&&e.message||e)+""}catch(s){}try{p=We(t,(e.stack+"").split(`
|
|
9
|
+
`),"")}catch(s){}return{id:"",pluginName:a,text:l,location:p,notes:i?[i]:[],detail:n?n.store(e):-1}}function We(e,t,n){let i=" at ";if(e.readFileSync&&!t[0].startsWith(i)&&t[1].startsWith(i))for(let a=1;a<t.length;a++){let l=t[a];if(l.startsWith(i))for(l=l.slice(i.length);;){let p=/^(?:new |async )?\S+ \((.*)\)$/.exec(l);if(p){l=p[1];continue}if(p=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(l),p){l=p[1];continue}if(p=/^(\S+):(\d+):(\d+)$/.exec(l),p){let s;try{s=e.readFileSync(p[1],"utf8")}catch(b){break}let d=s.split(/\r\n|\r|\n|\u2028|\u2029/)[+p[2]-1]||"",P=+p[3]-1,A=d.slice(P,P+n.length)===n?n.length:0;return{file:p[1],namespace:"file",line:+p[2],column:Z(d.slice(0,P)).length,length:Z(d.slice(P,P+A)).length,lineText:d+`
|
|
10
10
|
`+t.slice(1).join(`
|
|
11
11
|
`),suggestion:""}}break}}return null}function fe(e,t,n){let i=5;e+=t.length<1?"":` with ${t.length} error${t.length<2?"":"s"}:`+t.slice(0,i+1).map((l,p)=>{if(p===i)return`
|
|
12
12
|
...`;if(!l.location)return`
|
|
13
13
|
error: ${l.text}`;let{file:s,line:d,column:P}=l.location,A=l.pluginName?`[plugin: ${l.pluginName}] `:"";return`
|
|
14
|
-
${s}:${d}:${P}: ERROR: ${A}${l.text}`}).join("");let a=new Error(e);for(let[l,p]of[["errors",t],["warnings",n]])Object.defineProperty(a,l,{configurable:!0,enumerable:!0,get:()=>p,set:s=>Object.defineProperty(a,l,{configurable:!0,enumerable:!0,value:s})});return a}function ue(e,t){for(let n of e)n.detail=t.load(n.detail);return e}function Pe(e,t,n){if(e==null)return null;let i={},a=r(e,i,"file",y),l=r(e,i,"namespace",y),p=r(e,i,"line",ae),s=r(e,i,"column",ae),d=r(e,i,"length",ae),P=r(e,i,"lineText",y),A=r(e,i,"suggestion",y);if(Y(e,i,t),P){let b=P.slice(0,(s&&s>0?s:0)+(d&&d>0?d:0)+(n&&n>0?n:80));!/[\x7F-\uFFFF]/.test(b)&&!/\n/.test(P)&&(P=b)}return{file:a||"",namespace:l||"",line:p||0,column:s||0,length:d||0,lineText:P||"",suggestion:A||""}}function re(e,t,n,i,a){let l=[],p=0;for(let s of e){let d={},P=r(s,d,"id",y),A=r(s,d,"pluginName",y),b=r(s,d,"text",y),j=r(s,d,"location",Fe),T=r(s,d,"notes",K),L=r(s,d,"detail",ye),N=`in element ${p} of "${t}"`;Y(s,d,N);let E=[];if(T)for(let _ of T){let J={},w=r(_,J,"text",y),m=r(_,J,"location",Fe);Y(_,J,N),E.push({text:w||"",location:Pe(m,N,a)})}l.push({id:P||"",pluginName:A||i,text:b||"",location:Pe(j,N,a),notes:E,detail:n?n.store(L):-1}),p++}return l}function me(e,t){let n=[];for(let i of e){if(typeof i!="string")throw new Error(`${V(t)} must be an array of strings`);n.push(i)}return n}function at(e,t){let n=Object.create(null);for(let i in e){let a=e[i];if(typeof a!="string")throw new Error(`key ${V(i)} in object ${V(t)} must be a string`);n[i]=a}return n}function ut({path:e,contents:t,hash:n}){let i=null;return{path:e,contents:t,hash:n,get text(){let a=this.contents;return(i===null||a!==t)&&(t=a,i=ie(a)),i}}}var ft="0.25.0",dt=e=>de().build(e),pt=e=>de().context(e),gt=(e,t)=>de().transform(e,t),mt=(e,t)=>de().formatMessages(e,t),yt=(e,t)=>de().analyzeMetafile(e,t),ht=()=>{throw new Error('The "buildSync" API only works in node')},bt=()=>{throw new Error('The "transformSync" API only works in node')},wt=()=>{throw new Error('The "formatMessagesSync" API only works in node')},vt=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},Rt=()=>(we&&we(),Promise.resolve()),se,we,ve,de=()=>{if(ve)return ve;throw se?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')},xt=e=>{e=Ue(e||{});let t=e.wasmURL,n=e.wasmModule,i=e.worker!==!1;if(!t&&!n)throw new Error('Must provide either the "wasmURL" option or the "wasmModule" option');if(se)throw new Error('Cannot call "initialize" more than once');return se=Ot(t||"",n,i),se.catch(()=>{se=void 0}),se},Ot=(e,t,n)=>ne(void 0,null,function*(){let i,a,l=new Promise(b=>a=b);if(n){let b=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.\nvar b=(i,f,d)=>new Promise((c,r)=>{var s=u=>{try{o(d.next(u))}catch(m){r(m)}},n=u=>{try{o(d.throw(u))}catch(m){r(m)}},o=u=>u.done?c(u.value):Promise.resolve(u.value).then(s,n);o((d=d.apply(i,f)).next())});let onmessage,globalThis={};for(let i=self;i;i=Object.getPrototypeOf(i))for(let f of Object.getOwnPropertyNames(i))f in globalThis||Object.defineProperty(globalThis,f,{get:()=>self[f]});(()=>{const i=()=>{const c=new Error("not implemented");return c.code="ENOSYS",c};if(!globalThis.fs){let c="";globalThis.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(r,s){c+=d.decode(s);const n=c.lastIndexOf(`\n`);return n!=-1&&(console.log(c.substring(0,n)),c=c.substring(n+1)),s.length},write(r,s,n,o,u,m){if(n!==0||o!==s.length||u!==null){m(i());return}const h=this.writeSync(r,s);m(null,h)},chmod(r,s,n){n(i())},chown(r,s,n,o){o(i())},close(r,s){s(i())},fchmod(r,s,n){n(i())},fchown(r,s,n,o){o(i())},fstat(r,s){s(i())},fsync(r,s){s(null)},ftruncate(r,s,n){n(i())},lchown(r,s,n,o){o(i())},link(r,s,n){n(i())},lstat(r,s){s(i())},mkdir(r,s,n){n(i())},open(r,s,n,o){o(i())},read(r,s,n,o,u,m){m(i())},readdir(r,s){s(i())},readlink(r,s){s(i())},rename(r,s,n){n(i())},rmdir(r,s){s(i())},stat(r,s){s(i())},symlink(r,s,n){n(i())},truncate(r,s,n){n(i())},unlink(r,s){s(i())},utimes(r,s,n,o){o(i())}}}if(globalThis.process||(globalThis.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw i()},pid:-1,ppid:-1,umask(){throw i()},cwd(){throw i()},chdir(){throw i()}}),!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"),d=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 c=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},r=(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 y=0;switch(typeof t){case"object":t!==null&&(y=1);break;case"string":y=2;break;case"symbol":y=3;break;case"function":y=4;break}this.mem.setUint32(e+4,2146959360|y,!0),this.mem.setUint32(e,a,!0)},u=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 y=0;y<l;y++)a[y]=n(t+y*8);return a},h=e=>{const t=s(e+0),l=s(e+8);return d.decode(new DataView(this._inst.exports.mem.buffer,t,l))},g=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),c(e+8,(g+performance.now())*1e6)},"runtime.walltime":e=>{e=Number(e);const t=new Date().getTime();c(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(u(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),y=Reflect.apply(l,t,a);e=Number(this._inst.exports.getsp()),o(e+56,y),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),c(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),c(e+24,t.length)},"syscall/js.valueLoadString":e=>{e=Number(e);const t=n(e+8);u(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=u(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),c(e+40,a.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{e=Number(e);const t=n(e+8),l=u(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),c(e+40,a.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}run(c){return b(this,null,function*(){if(!(c instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=c,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 r=4096;const s=g=>{const e=r,t=f.encode(g+"\\0");return new Uint8Array(this.mem.buffer,r,t.length).set(t),r+=t.length,r%8!==0&&(r+=8-r%8),e},n=this.argv.length,o=[];this.argv.forEach(g=>{o.push(s(g))}),o.push(0),Object.keys(this.env).sort().forEach(g=>{o.push(s(`${g}=${this.env[g]}`))}),o.push(0);const m=r;if(o.forEach(g=>{this.mem.setUint32(r,g,!0),this.mem.setUint32(r+4,0,!0),r+=8}),r>=12288)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(n,m),this.exited&&this._resolveExitPromise(),yield this._exitPromise})}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(c){const r=this;return function(){const s={id:c,this:this,args:arguments};return r._pendingEvent=s,r._resume(),s.result}}}})(),onmessage=({data:i})=>{let f=new TextDecoder,d=globalThis.fs,c="";d.writeSync=(u,m)=>{if(u===1)postMessage(m);else if(u===2){c+=f.decode(m);let h=c.split(`\n`);h.length>1&&console.log(h.slice(0,-1).join(`\n`)),c=h[h.length-1]}else throw new Error("Bad write");return m.length};let r=[],s,n=0;onmessage=({data:u})=>(u.length>0&&(r.push(u),s&&s()),o),d.read=(u,m,h,g,e,t)=>{if(u!==0||h!==0||g!==m.length||e!==null)throw new Error("Bad read");if(r.length===0){s=()=>d.read(u,m,h,g,e,t);return}let l=r[0],a=Math.max(0,Math.min(g,l.length-n));m.set(l.subarray(n,n+a),h),n+=a,n===l.length&&(r.shift(),n=0),t(null,a)};let o=new globalThis.Go;return o.argv=["","--service=0.25.0"],tryToInstantiateModule(i,o).then(u=>{postMessage(null),o.run(u)},u=>{postMessage(u)}),o};function tryToInstantiateModule(i,f){return b(this,null,function*(){if(i instanceof WebAssembly.Module)return WebAssembly.instantiate(i,f.importObject);const d=yield fetch(i);if(!d.ok)throw new Error(`Failed to download ${JSON.stringify(i)}`);if("instantiateStreaming"in WebAssembly&&/^application\\/wasm($|;)/i.test(d.headers.get("Content-Type")||""))return(yield WebAssembly.instantiateStreaming(d,f.importObject)).instance;const c=yield d.arrayBuffer();return(yield WebAssembly.instantiate(c,f.importObject)).instance})}return i=>onmessage(i);})(postMessage)'],{type:"text/javascript"});i=new Worker(URL.createObjectURL(b))}else{let b=(postMessage=>{
|
|
14
|
+
${s}:${d}:${P}: ERROR: ${A}${l.text}`}).join("");let a=new Error(e);for(let[l,p]of[["errors",t],["warnings",n]])Object.defineProperty(a,l,{configurable:!0,enumerable:!0,get:()=>p,set:s=>Object.defineProperty(a,l,{configurable:!0,enumerable:!0,value:s})});return a}function ue(e,t){for(let n of e)n.detail=t.load(n.detail);return e}function Te(e,t,n){if(e==null)return null;let i={},a=r(e,i,"file",y),l=r(e,i,"namespace",y),p=r(e,i,"line",ae),s=r(e,i,"column",ae),d=r(e,i,"length",ae),P=r(e,i,"lineText",y),A=r(e,i,"suggestion",y);if(Y(e,i,t),P){let b=P.slice(0,(s&&s>0?s:0)+(d&&d>0?d:0)+(n&&n>0?n:80));!/[\x7F-\uFFFF]/.test(b)&&!/\n/.test(P)&&(P=b)}return{file:a||"",namespace:l||"",line:p||0,column:s||0,length:d||0,lineText:P||"",suggestion:A||""}}function re(e,t,n,i,a){let l=[],p=0;for(let s of e){let d={},P=r(s,d,"id",y),A=r(s,d,"pluginName",y),b=r(s,d,"text",y),j=r(s,d,"location",Pe),T=r(s,d,"notes",K),L=r(s,d,"detail",ye),N=`in element ${p} of "${t}"`;Y(s,d,N);let E=[];if(T)for(let _ of T){let J={},w=r(_,J,"text",y),m=r(_,J,"location",Pe);Y(_,J,N),E.push({text:w||"",location:Te(m,N,a)})}l.push({id:P||"",pluginName:A||i,text:b||"",location:Te(j,N,a),notes:E,detail:n?n.store(L):-1}),p++}return l}function me(e,t){let n=[];for(let i of e){if(typeof i!="string")throw new Error(`${V(t)} must be an array of strings`);n.push(i)}return n}function ut(e,t){let n=Object.create(null);for(let i in e){let a=e[i];if(typeof a!="string")throw new Error(`key ${V(i)} in object ${V(t)} must be a string`);n[i]=a}return n}function ct({path:e,contents:t,hash:n}){let i=null;return{path:e,contents:t,hash:n,get text(){let a=this.contents;return(i===null||a!==t)&&(t=a,i=ie(a)),i}}}function be(e){let t=e.source;return e.flags&&(t=`(?${e.flags})${t}`),t}var dt="0.25.2",pt=e=>de().build(e),gt=e=>de().context(e),mt=(e,t)=>de().transform(e,t),yt=(e,t)=>de().formatMessages(e,t),ht=(e,t)=>de().analyzeMetafile(e,t),bt=()=>{throw new Error('The "buildSync" API only works in node')},wt=()=>{throw new Error('The "transformSync" API only works in node')},vt=()=>{throw new Error('The "formatMessagesSync" API only works in node')},Rt=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},xt=()=>(ve&&ve(),Promise.resolve()),se,ve,Re,de=()=>{if(Re)return Re;throw se?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')},Ot=e=>{e=je(e||{});let t=e.wasmURL,n=e.wasmModule,i=e.worker!==!1;if(!t&&!n)throw new Error('Must provide either the "wasmURL" option or the "wasmModule" option');if(se)throw new Error('Cannot call "initialize" more than once');return se=Et(t||"",n,i),se.catch(()=>{se=void 0}),se},Et=(e,t,n)=>ne(void 0,null,function*(){let i,a,l=new Promise(b=>a=b);if(n){let b=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.\nvar b=(i,f,d)=>new Promise((c,r)=>{var s=u=>{try{o(d.next(u))}catch(m){r(m)}},n=u=>{try{o(d.throw(u))}catch(m){r(m)}},o=u=>u.done?c(u.value):Promise.resolve(u.value).then(s,n);o((d=d.apply(i,f)).next())});let onmessage,globalThis={};for(let i=self;i;i=Object.getPrototypeOf(i))for(let f of Object.getOwnPropertyNames(i))f in globalThis||Object.defineProperty(globalThis,f,{get:()=>self[f]});(()=>{const i=()=>{const c=new Error("not implemented");return c.code="ENOSYS",c};if(!globalThis.fs){let c="";globalThis.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(r,s){c+=d.decode(s);const n=c.lastIndexOf(`\n`);return n!=-1&&(console.log(c.substring(0,n)),c=c.substring(n+1)),s.length},write(r,s,n,o,u,m){if(n!==0||o!==s.length||u!==null){m(i());return}const h=this.writeSync(r,s);m(null,h)},chmod(r,s,n){n(i())},chown(r,s,n,o){o(i())},close(r,s){s(i())},fchmod(r,s,n){n(i())},fchown(r,s,n,o){o(i())},fstat(r,s){s(i())},fsync(r,s){s(null)},ftruncate(r,s,n){n(i())},lchown(r,s,n,o){o(i())},link(r,s,n){n(i())},lstat(r,s){s(i())},mkdir(r,s,n){n(i())},open(r,s,n,o){o(i())},read(r,s,n,o,u,m){m(i())},readdir(r,s){s(i())},readlink(r,s){s(i())},rename(r,s,n){n(i())},rmdir(r,s){s(i())},stat(r,s){s(i())},symlink(r,s,n){n(i())},truncate(r,s,n){n(i())},unlink(r,s){s(i())},utimes(r,s,n,o){o(i())}}}if(globalThis.process||(globalThis.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw i()},pid:-1,ppid:-1,umask(){throw i()},cwd(){throw i()},chdir(){throw i()}}),!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"),d=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 c=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},r=(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 y=0;switch(typeof t){case"object":t!==null&&(y=1);break;case"string":y=2;break;case"symbol":y=3;break;case"function":y=4;break}this.mem.setUint32(e+4,2146959360|y,!0),this.mem.setUint32(e,a,!0)},u=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 y=0;y<l;y++)a[y]=n(t+y*8);return a},h=e=>{const t=s(e+0),l=s(e+8);return d.decode(new DataView(this._inst.exports.mem.buffer,t,l))},g=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),c(e+8,(g+performance.now())*1e6)},"runtime.walltime":e=>{e=Number(e);const t=new Date().getTime();c(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(u(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),y=Reflect.apply(l,t,a);e=Number(this._inst.exports.getsp()),o(e+56,y),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),c(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),c(e+24,t.length)},"syscall/js.valueLoadString":e=>{e=Number(e);const t=n(e+8);u(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=u(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),c(e+40,a.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{e=Number(e);const t=n(e+8),l=u(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),c(e+40,a.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}run(c){return b(this,null,function*(){if(!(c instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=c,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 r=4096;const s=g=>{const e=r,t=f.encode(g+"\\0");return new Uint8Array(this.mem.buffer,r,t.length).set(t),r+=t.length,r%8!==0&&(r+=8-r%8),e},n=this.argv.length,o=[];this.argv.forEach(g=>{o.push(s(g))}),o.push(0),Object.keys(this.env).sort().forEach(g=>{o.push(s(`${g}=${this.env[g]}`))}),o.push(0);const m=r;if(o.forEach(g=>{this.mem.setUint32(r,g,!0),this.mem.setUint32(r+4,0,!0),r+=8}),r>=12288)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(n,m),this.exited&&this._resolveExitPromise(),yield this._exitPromise})}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(c){const r=this;return function(){const s={id:c,this:this,args:arguments};return r._pendingEvent=s,r._resume(),s.result}}}})(),onmessage=({data:i})=>{let f=new TextDecoder,d=globalThis.fs,c="";d.writeSync=(u,m)=>{if(u===1)postMessage(m);else if(u===2){c+=f.decode(m);let h=c.split(`\n`);h.length>1&&console.log(h.slice(0,-1).join(`\n`)),c=h[h.length-1]}else throw new Error("Bad write");return m.length};let r=[],s,n=0;onmessage=({data:u})=>(u.length>0&&(r.push(u),s&&s()),o),d.read=(u,m,h,g,e,t)=>{if(u!==0||h!==0||g!==m.length||e!==null)throw new Error("Bad read");if(r.length===0){s=()=>d.read(u,m,h,g,e,t);return}let l=r[0],a=Math.max(0,Math.min(g,l.length-n));m.set(l.subarray(n,n+a),h),n+=a,n===l.length&&(r.shift(),n=0),t(null,a)};let o=new globalThis.Go;return o.argv=["","--service=0.25.2"],tryToInstantiateModule(i,o).then(u=>{postMessage(null),o.run(u)},u=>{postMessage(u)}),o};function tryToInstantiateModule(i,f){return b(this,null,function*(){if(i instanceof WebAssembly.Module)return WebAssembly.instantiate(i,f.importObject);const d=yield fetch(i);if(!d.ok)throw new Error(`Failed to download ${JSON.stringify(i)}`);if("instantiateStreaming"in WebAssembly&&/^application\\/wasm($|;)/i.test(d.headers.get("Content-Type")||""))return(yield WebAssembly.instantiateStreaming(d,f.importObject)).instance;const c=yield d.arrayBuffer();return(yield WebAssembly.instantiate(c,f.importObject)).instance})}return i=>onmessage(i);})(postMessage)'],{type:"text/javascript"});i=new Worker(URL.createObjectURL(b))}else{let b=(postMessage=>{
|
|
15
15
|
// Copyright 2018 The Go Authors. All rights reserved.
|
|
16
16
|
// Use of this source code is governed by a BSD-style
|
|
17
17
|
// license that can be found in the LICENSE file.
|
|
18
18
|
var b=(i,f,d)=>new Promise((c,r)=>{var s=u=>{try{o(d.next(u))}catch(m){r(m)}},n=u=>{try{o(d.throw(u))}catch(m){r(m)}},o=u=>u.done?c(u.value):Promise.resolve(u.value).then(s,n);o((d=d.apply(i,f)).next())});let onmessage,globalThis={};for(let i=self;i;i=Object.getPrototypeOf(i))for(let f of Object.getOwnPropertyNames(i))f in globalThis||Object.defineProperty(globalThis,f,{get:()=>self[f]});(()=>{const i=()=>{const c=new Error("not implemented");return c.code="ENOSYS",c};if(!globalThis.fs){let c="";globalThis.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(r,s){c+=d.decode(s);const n=c.lastIndexOf(`
|
|
19
19
|
`);return n!=-1&&(console.log(c.substring(0,n)),c=c.substring(n+1)),s.length},write(r,s,n,o,u,m){if(n!==0||o!==s.length||u!==null){m(i());return}const h=this.writeSync(r,s);m(null,h)},chmod(r,s,n){n(i())},chown(r,s,n,o){o(i())},close(r,s){s(i())},fchmod(r,s,n){n(i())},fchown(r,s,n,o){o(i())},fstat(r,s){s(i())},fsync(r,s){s(null)},ftruncate(r,s,n){n(i())},lchown(r,s,n,o){o(i())},link(r,s,n){n(i())},lstat(r,s){s(i())},mkdir(r,s,n){n(i())},open(r,s,n,o){o(i())},read(r,s,n,o,u,m){m(i())},readdir(r,s){s(i())},readlink(r,s){s(i())},rename(r,s,n){n(i())},rmdir(r,s){s(i())},stat(r,s){s(i())},symlink(r,s,n){n(i())},truncate(r,s,n){n(i())},unlink(r,s){s(i())},utimes(r,s,n,o){o(i())}}}if(globalThis.process||(globalThis.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw i()},pid:-1,ppid:-1,umask(){throw i()},cwd(){throw i()},chdir(){throw i()}}),!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"),d=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 c=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},r=(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 y=0;switch(typeof t){case"object":t!==null&&(y=1);break;case"string":y=2;break;case"symbol":y=3;break;case"function":y=4;break}this.mem.setUint32(e+4,2146959360|y,!0),this.mem.setUint32(e,a,!0)},u=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 y=0;y<l;y++)a[y]=n(t+y*8);return a},h=e=>{const t=s(e+0),l=s(e+8);return d.decode(new DataView(this._inst.exports.mem.buffer,t,l))},g=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),c(e+8,(g+performance.now())*1e6)},"runtime.walltime":e=>{e=Number(e);const t=new Date().getTime();c(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(u(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),y=Reflect.apply(l,t,a);e=Number(this._inst.exports.getsp()),o(e+56,y),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),c(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),c(e+24,t.length)},"syscall/js.valueLoadString":e=>{e=Number(e);const t=n(e+8);u(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=u(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),c(e+40,a.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{e=Number(e);const t=n(e+8),l=u(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),c(e+40,a.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}run(c){return b(this,null,function*(){if(!(c instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=c,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 r=4096;const s=g=>{const e=r,t=f.encode(g+"\0");return new Uint8Array(this.mem.buffer,r,t.length).set(t),r+=t.length,r%8!==0&&(r+=8-r%8),e},n=this.argv.length,o=[];this.argv.forEach(g=>{o.push(s(g))}),o.push(0),Object.keys(this.env).sort().forEach(g=>{o.push(s(`${g}=${this.env[g]}`))}),o.push(0);const m=r;if(o.forEach(g=>{this.mem.setUint32(r,g,!0),this.mem.setUint32(r+4,0,!0),r+=8}),r>=12288)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(n,m),this.exited&&this._resolveExitPromise(),yield this._exitPromise})}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(c){const r=this;return function(){const s={id:c,this:this,args:arguments};return r._pendingEvent=s,r._resume(),s.result}}}})(),onmessage=({data:i})=>{let f=new TextDecoder,d=globalThis.fs,c="";d.writeSync=(u,m)=>{if(u===1)postMessage(m);else if(u===2){c+=f.decode(m);let h=c.split(`
|
|
20
20
|
`);h.length>1&&console.log(h.slice(0,-1).join(`
|
|
21
|
-
`)),c=h[h.length-1]}else throw new Error("Bad write");return m.length};let r=[],s,n=0;onmessage=({data:u})=>(u.length>0&&(r.push(u),s&&s()),o),d.read=(u,m,h,g,e,t)=>{if(u!==0||h!==0||g!==m.length||e!==null)throw new Error("Bad read");if(r.length===0){s=()=>d.read(u,m,h,g,e,t);return}let l=r[0],a=Math.max(0,Math.min(g,l.length-n));m.set(l.subarray(n,n+a),h),n+=a,n===l.length&&(r.shift(),n=0),t(null,a)};let o=new globalThis.Go;return o.argv=["","--service=0.25.
|
|
21
|
+
`)),c=h[h.length-1]}else throw new Error("Bad write");return m.length};let r=[],s,n=0;onmessage=({data:u})=>(u.length>0&&(r.push(u),s&&s()),o),d.read=(u,m,h,g,e,t)=>{if(u!==0||h!==0||g!==m.length||e!==null)throw new Error("Bad read");if(r.length===0){s=()=>d.read(u,m,h,g,e,t);return}let l=r[0],a=Math.max(0,Math.min(g,l.length-n));m.set(l.subarray(n,n+a),h),n+=a,n===l.length&&(r.shift(),n=0),t(null,a)};let o=new globalThis.Go;return o.argv=["","--service=0.25.2"],tryToInstantiateModule(i,o).then(u=>{postMessage(null),o.run(u)},u=>{postMessage(u)}),o};function tryToInstantiateModule(i,f){return b(this,null,function*(){if(i instanceof WebAssembly.Module)return WebAssembly.instantiate(i,f.importObject);const d=yield fetch(i);if(!d.ok)throw new Error(`Failed to download ${JSON.stringify(i)}`);if("instantiateStreaming"in WebAssembly&&/^application\/wasm($|;)/i.test(d.headers.get("Content-Type")||""))return(yield WebAssembly.instantiateStreaming(d,f.importObject)).instance;const c=yield d.arrayBuffer();return(yield WebAssembly.instantiate(c,f.importObject)).instance})}return i=>onmessage(i);})(T=>i.onmessage({data:T})),j;i={onmessage:null,postMessage:T=>setTimeout(()=>{try{j=b({data:T})}catch(L){a(L)}}),terminate(){if(j)for(let T of j._scheduledTimeouts.values())clearTimeout(T)}}}let p,s,d=new Promise((b,j)=>{p=b,s=j});i.onmessage=({data:b})=>{i.onmessage=({data:j})=>P(j),b?s(b):p()},i.postMessage(t||new URL(e,location.href).toString());let{readFromStdout:P,service:A}=qe({writeToStdin(b){i.postMessage(b)},isSync:!1,hasFS:!1,esbuild:xe});yield d,ve=()=>{i.terminate(),se=void 0,ve=void 0,Re=void 0},Re={build:b=>new Promise((j,T)=>{l.then(T),A.buildOrContext({callName:"build",refs:null,options:b,isTTY:!1,defaultWD:"/",callback:(L,N)=>L?T(L):j(N)})}),context:b=>new Promise((j,T)=>{l.then(T),A.buildOrContext({callName:"context",refs:null,options:b,isTTY:!1,defaultWD:"/",callback:(L,N)=>L?T(L):j(N)})}),transform:(b,j)=>new Promise((T,L)=>{l.then(L),A.transform({callName:"transform",refs:null,input:b,options:j||{},isTTY:!1,fs:{readFile(N,E){E(new Error("Internal error"),null)},writeFile(N,E){E(null)}},callback:(N,E)=>N?L(N):T(E)})}),formatMessages:(b,j)=>new Promise((T,L)=>{l.then(L),A.formatMessages({callName:"formatMessages",refs:null,messages:b,options:j,callback:(N,E)=>N?L(N):T(E)})}),analyzeMetafile:(b,j)=>new Promise((T,L)=>{l.then(L),A.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof b=="string"?b:JSON.stringify(b),options:j,callback:(N,E)=>N?L(N):T(E)})})}}),St=xe;
|
|
22
22
|
})(typeof module==="object"?module:{set exports(x){(typeof self!=="undefined"?self:this).esbuild=x}});
|
package/lib/main.js
CHANGED
|
@@ -341,8 +341,8 @@ function pushCommonFlags(flags, options, keys) {
|
|
|
341
341
|
if (ignoreAnnotations) flags.push(`--ignore-annotations`);
|
|
342
342
|
if (drop) for (let what of drop) flags.push(`--drop:${validateStringValue(what, "drop")}`);
|
|
343
343
|
if (dropLabels) flags.push(`--drop-labels=${Array.from(dropLabels).map((what) => validateStringValue(what, "dropLabels")).join(",")}`);
|
|
344
|
-
if (mangleProps) flags.push(`--mangle-props=${mangleProps
|
|
345
|
-
if (reserveProps) flags.push(`--reserve-props=${reserveProps
|
|
344
|
+
if (mangleProps) flags.push(`--mangle-props=${jsRegExpToGoRegExp(mangleProps)}`);
|
|
345
|
+
if (reserveProps) flags.push(`--reserve-props=${jsRegExpToGoRegExp(reserveProps)}`);
|
|
346
346
|
if (mangleQuoted !== void 0) flags.push(`--mangle-quoted=${mangleQuoted}`);
|
|
347
347
|
if (jsx) flags.push(`--jsx=${jsx}`);
|
|
348
348
|
if (jsxFactory) flags.push(`--jsx-factory=${jsxFactory}`);
|
|
@@ -653,8 +653,8 @@ function createChannel(streamIn) {
|
|
|
653
653
|
if (isFirstPacket) {
|
|
654
654
|
isFirstPacket = false;
|
|
655
655
|
let binaryVersion = String.fromCharCode(...bytes);
|
|
656
|
-
if (binaryVersion !== "0.25.
|
|
657
|
-
throw new Error(`Cannot start service: Host version "${"0.25.
|
|
656
|
+
if (binaryVersion !== "0.25.2") {
|
|
657
|
+
throw new Error(`Cannot start service: Host version "${"0.25.2"}" does not match binary version ${quote(binaryVersion)}`);
|
|
658
658
|
}
|
|
659
659
|
return;
|
|
660
660
|
}
|
|
@@ -1163,7 +1163,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
|
1163
1163
|
if (filter == null) throw new Error(`onResolve() call is missing a filter`);
|
|
1164
1164
|
let id = nextCallbackID++;
|
|
1165
1165
|
onResolveCallbacks[id] = { name, callback, note: registeredNote };
|
|
1166
|
-
plugin.onResolve.push({ id, filter: filter
|
|
1166
|
+
plugin.onResolve.push({ id, filter: jsRegExpToGoRegExp(filter), namespace: namespace || "" });
|
|
1167
1167
|
},
|
|
1168
1168
|
onLoad(options, callback) {
|
|
1169
1169
|
let registeredText = `This error came from the "onLoad" callback registered here:`;
|
|
@@ -1175,7 +1175,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
|
1175
1175
|
if (filter == null) throw new Error(`onLoad() call is missing a filter`);
|
|
1176
1176
|
let id = nextCallbackID++;
|
|
1177
1177
|
onLoadCallbacks[id] = { name, callback, note: registeredNote };
|
|
1178
|
-
plugin.onLoad.push({ id, filter: filter
|
|
1178
|
+
plugin.onLoad.push({ id, filter: jsRegExpToGoRegExp(filter), namespace: namespace || "" });
|
|
1179
1179
|
},
|
|
1180
1180
|
onDispose(callback) {
|
|
1181
1181
|
onDisposeCallbacks.push(callback);
|
|
@@ -1586,6 +1586,11 @@ function convertOutputFiles({ path: path3, contents, hash }) {
|
|
|
1586
1586
|
}
|
|
1587
1587
|
};
|
|
1588
1588
|
}
|
|
1589
|
+
function jsRegExpToGoRegExp(regexp) {
|
|
1590
|
+
let result = regexp.source;
|
|
1591
|
+
if (regexp.flags) result = `(?${regexp.flags})${result}`;
|
|
1592
|
+
return result;
|
|
1593
|
+
}
|
|
1589
1594
|
|
|
1590
1595
|
// lib/npm/node-platform.ts
|
|
1591
1596
|
var fs = require("fs");
|
|
@@ -1615,7 +1620,7 @@ if (process.env.ESBUILD_WORKER_THREADS !== "0") {
|
|
|
1615
1620
|
}
|
|
1616
1621
|
}
|
|
1617
1622
|
var _a;
|
|
1618
|
-
var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.25.
|
|
1623
|
+
var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.25.2";
|
|
1619
1624
|
var esbuildCommandAndArgs = () => {
|
|
1620
1625
|
if ((!ESBUILD_BINARY_PATH || true) && (path2.basename(__filename) !== "main.js" || path2.basename(__dirname) !== "lib")) {
|
|
1621
1626
|
throw new Error(
|
|
@@ -1682,7 +1687,7 @@ var fsAsync = {
|
|
|
1682
1687
|
}
|
|
1683
1688
|
}
|
|
1684
1689
|
};
|
|
1685
|
-
var version = "0.25.
|
|
1690
|
+
var version = "0.25.2";
|
|
1686
1691
|
var build = (options) => ensureServiceIsRunning().build(options);
|
|
1687
1692
|
var context = (buildOptions) => ensureServiceIsRunning().context(buildOptions);
|
|
1688
1693
|
var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
|
|
@@ -1785,7 +1790,7 @@ var stopService;
|
|
|
1785
1790
|
var ensureServiceIsRunning = () => {
|
|
1786
1791
|
if (longLivedService) return longLivedService;
|
|
1787
1792
|
let [command, args] = esbuildCommandAndArgs();
|
|
1788
|
-
let child = child_process.spawn(command, args.concat(`--service=${"0.25.
|
|
1793
|
+
let child = child_process.spawn(command, args.concat(`--service=${"0.25.2"}`, "--ping"), {
|
|
1789
1794
|
windowsHide: true,
|
|
1790
1795
|
stdio: ["pipe", "pipe", "inherit"],
|
|
1791
1796
|
cwd: defaultWD
|
|
@@ -1889,7 +1894,7 @@ var runServiceSync = (callback) => {
|
|
|
1889
1894
|
esbuild: node_exports
|
|
1890
1895
|
});
|
|
1891
1896
|
callback(service);
|
|
1892
|
-
let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.25.
|
|
1897
|
+
let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.25.2"}`), {
|
|
1893
1898
|
cwd: defaultWD,
|
|
1894
1899
|
windowsHide: true,
|
|
1895
1900
|
input: stdin,
|
|
@@ -1909,7 +1914,7 @@ var workerThreadService = null;
|
|
|
1909
1914
|
var startWorkerThreadService = (worker_threads2) => {
|
|
1910
1915
|
let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
|
|
1911
1916
|
let worker = new worker_threads2.Worker(__filename, {
|
|
1912
|
-
workerData: { workerPort, defaultWD, esbuildVersion: "0.25.
|
|
1917
|
+
workerData: { workerPort, defaultWD, esbuildVersion: "0.25.2" },
|
|
1913
1918
|
transferList: [workerPort],
|
|
1914
1919
|
// From node's documentation: https://nodejs.org/api/worker_threads.html
|
|
1915
1920
|
//
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esbuild-wasm-strapkit",
|
|
3
|
-
"version": "0.25.
|
|
4
|
-
"esbuildVersion": "0.25.
|
|
5
|
-
"description": "esbuild-wasm 0.25.
|
|
3
|
+
"version": "0.25.2-build.1",
|
|
4
|
+
"esbuildVersion": "0.25.2",
|
|
5
|
+
"description": "esbuild-wasm 0.25.2 built on 64-bit wasm memory (no 4GB heap cap). Install the dist-tag for your esbuild version, e.g. esbuild-wasm-strapkit@esbuild-0.25.2.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=18"
|