esbuild-wasm-strapkit 0.21.3-build.2 → 0.21.4-build.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esbuild.wasm +0 -0
- package/esm/browser.d.ts +2 -0
- package/esm/browser.js +18 -6
- package/esm/browser.min.js +5 -5
- package/lib/browser.d.ts +2 -0
- package/lib/browser.js +18 -6
- package/lib/browser.min.js +8 -8
- package/lib/main.d.ts +2 -0
- package/lib/main.js +20 -8
- package/package.json +3 -3
package/esbuild.wasm
CHANGED
|
Binary file
|
package/esm/browser.d.ts
CHANGED
|
@@ -340,6 +340,7 @@ export interface ResolveOptions {
|
|
|
340
340
|
resolveDir?: string
|
|
341
341
|
kind?: ImportKind
|
|
342
342
|
pluginData?: any
|
|
343
|
+
with?: Record<string, string>
|
|
343
344
|
}
|
|
344
345
|
|
|
345
346
|
/** Documentation: https://esbuild.github.io/plugins/#resolve-results */
|
|
@@ -379,6 +380,7 @@ export interface OnResolveArgs {
|
|
|
379
380
|
resolveDir: string
|
|
380
381
|
kind: ImportKind
|
|
381
382
|
pluginData: any
|
|
383
|
+
with: Record<string, string>
|
|
382
384
|
}
|
|
383
385
|
|
|
384
386
|
export type ImportKind =
|
package/esm/browser.js
CHANGED
|
@@ -638,8 +638,8 @@ function createChannel(streamIn) {
|
|
|
638
638
|
if (isFirstPacket) {
|
|
639
639
|
isFirstPacket = false;
|
|
640
640
|
let binaryVersion = String.fromCharCode(...bytes);
|
|
641
|
-
if (binaryVersion !== "0.21.
|
|
642
|
-
throw new Error(`Cannot start service: Host version "${"0.21.
|
|
641
|
+
if (binaryVersion !== "0.21.4") {
|
|
642
|
+
throw new Error(`Cannot start service: Host version "${"0.21.4"}" does not match binary version ${quote(binaryVersion)}`);
|
|
643
643
|
}
|
|
644
644
|
return;
|
|
645
645
|
}
|
|
@@ -1091,6 +1091,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
|
1091
1091
|
let resolveDir = getFlag(options, keys2, "resolveDir", mustBeString);
|
|
1092
1092
|
let kind = getFlag(options, keys2, "kind", mustBeString);
|
|
1093
1093
|
let pluginData = getFlag(options, keys2, "pluginData", canBeAnything);
|
|
1094
|
+
let importAttributes = getFlag(options, keys2, "with", mustBeObject);
|
|
1094
1095
|
checkForInvalidFlags(options, keys2, "in resolve() call");
|
|
1095
1096
|
return new Promise((resolve2, reject) => {
|
|
1096
1097
|
const request = {
|
|
@@ -1106,6 +1107,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
|
1106
1107
|
if (kind != null) request.kind = kind;
|
|
1107
1108
|
else throw new Error(`Must specify "kind" when calling "resolve"`);
|
|
1108
1109
|
if (pluginData != null) request.pluginData = details.store(pluginData);
|
|
1110
|
+
if (importAttributes != null) request.with = sanitizeStringMap(importAttributes, "with");
|
|
1109
1111
|
sendRequest(refs, request, (error, response) => {
|
|
1110
1112
|
if (error !== null) reject(new Error(error));
|
|
1111
1113
|
else resolve2({
|
|
@@ -1202,7 +1204,8 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
|
1202
1204
|
namespace: request.namespace,
|
|
1203
1205
|
resolveDir: request.resolveDir,
|
|
1204
1206
|
kind: request.kind,
|
|
1205
|
-
pluginData: details.load(request.pluginData)
|
|
1207
|
+
pluginData: details.load(request.pluginData),
|
|
1208
|
+
with: request.with
|
|
1206
1209
|
});
|
|
1207
1210
|
if (result != null) {
|
|
1208
1211
|
if (typeof result !== "object") throw new Error(`Expected onResolve() callback in plugin ${quote(name)} to return an object`);
|
|
@@ -1539,6 +1542,15 @@ function sanitizeStringArray(values, property) {
|
|
|
1539
1542
|
}
|
|
1540
1543
|
return result;
|
|
1541
1544
|
}
|
|
1545
|
+
function sanitizeStringMap(map, property) {
|
|
1546
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
1547
|
+
for (const key in map) {
|
|
1548
|
+
const value = map[key];
|
|
1549
|
+
if (typeof value !== "string") throw new Error(`key ${quote(key)} in object ${quote(property)} must be a string`);
|
|
1550
|
+
result[key] = value;
|
|
1551
|
+
}
|
|
1552
|
+
return result;
|
|
1553
|
+
}
|
|
1542
1554
|
function convertOutputFiles({ path, contents, hash }) {
|
|
1543
1555
|
let text = null;
|
|
1544
1556
|
return {
|
|
@@ -1557,7 +1569,7 @@ function convertOutputFiles({ path, contents, hash }) {
|
|
|
1557
1569
|
}
|
|
1558
1570
|
|
|
1559
1571
|
// lib/npm/browser.ts
|
|
1560
|
-
var version = "0.21.
|
|
1572
|
+
var version = "0.21.4";
|
|
1561
1573
|
var build = (options) => ensureServiceIsRunning().build(options);
|
|
1562
1574
|
var context = (options) => ensureServiceIsRunning().context(options);
|
|
1563
1575
|
var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
|
|
@@ -1603,7 +1615,7 @@ var initialize = (options) => {
|
|
|
1603
1615
|
var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
1604
1616
|
let worker;
|
|
1605
1617
|
if (useWorker) {
|
|
1606
|
-
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.21.3"}`];\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" });
|
|
1618
|
+
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.21.4"}`];\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" });
|
|
1607
1619
|
worker = new Worker(URL.createObjectURL(blob));
|
|
1608
1620
|
} else {
|
|
1609
1621
|
let onmessage = ((postMessage) => {
|
|
@@ -2221,7 +2233,7 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
|
2221
2233
|
callback(null, count);
|
|
2222
2234
|
};
|
|
2223
2235
|
let go = new globalThis.Go();
|
|
2224
|
-
go.argv = ["", `--service=${"0.21.
|
|
2236
|
+
go.argv = ["", `--service=${"0.21.4"}`];
|
|
2225
2237
|
tryToInstantiateModule(wasm, go).then(
|
|
2226
2238
|
(instance) => {
|
|
2227
2239
|
postMessage(null);
|
package/esm/browser.min.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var ze=Object.defineProperty;var Ke=(e,t)=>{for(var n in t)ze(e,n,{get:t[n],enumerable:!0})};var ve={};Ke(ve,{analyzeMetafile:()=>
|
|
1
|
+
var ze=Object.defineProperty;var Ke=(e,t)=>{for(var n in t)ze(e,n,{get:t[n],enumerable:!0})};var ve={};Ke(ve,{analyzeMetafile:()=>ut,analyzeMetafileSync:()=>pt,build:()=>lt,buildSync:()=>ct,context:()=>st,default:()=>ht,formatMessages:()=>at,formatMessagesSync:()=>dt,initialize:()=>mt,stop:()=>gt,transform:()=>ot,transformSync:()=>ft,version:()=>it});function Oe(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),xe(n.buf,n.len-4,0),n.buf.subarray(0,n.len)}function Se(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 m=n.read32(),s=[];for(let d=0;d<m;d++)s.push(t());return s}case 6:{let m=n.read32(),s={};for(let d=0;d<m;d++)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);xe(this.buf,t,n)}write(t){let n=this._write(4+t.length);xe(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 Ee(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,Re;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;Z=n=>e.encode(n),re=n=>t.decode(n),Re='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()},Re='Buffer.from("")';else throw new Error("No UTF-8 codec found");if(!(Z("")instanceof Uint8Array))throw new Error(`Invariant violation: "${Re} 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 Re(e,t,n){e[n++]=t,e[n++]=t>>8,e[n++]=t>>16,e[n++]=t>>24}var J=JSON.stringify,ke="warning",$e="silent";function Me(e){if(Y(e,"target"),e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var me=()=>null,I=e=>typeof e=="boolean"?null:"a boolean",y=e=>typeof e=="string"?null:"a string",ye=e=>e instanceof RegExp?null:"a RegExp object",le=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Fe=e=>typeof e=="function"?null:"a function",W=e=>Array.isArray(e)?null:"an array",ee=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",Ve=e=>typeof e=="object"&&e!==null?null:"an array or an object",Ye=e=>e instanceof WebAssembly.Module?null:"a WebAssembly.Module",Ce=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",Je=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",Ge=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",Pe=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array",Qe=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(`${J(n)} must be ${l}`);return u}function K(e,t,n){for(let i in e)if(!(i in t))throw new Error(`Invalid option ${n}: ${J(i)}`)}function De(e){let t=Object.create(null),n=r(e,t,"wasmURL",Qe),i=r(e,t,"wasmModule",Ye),u=r(e,t,"worker",I);return K(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 ${J(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",I),m=r(t,n,"logLevel",y),s=r(t,n,"logLimit",le);l!==void 0?e.push(`--color=${l}`):i&&e.push("--color=true"),e.push(`--log-level=${m||u}`),e.push(`--log-limit=${s||0}`)}function Y(e,t,n){if(typeof e!="string")throw new Error(`Expected value for ${t}${n!==void 0?" "+J(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",I),m=r(t,n,"target",Ge),s=r(t,n,"format",y),d=r(t,n,"globalName",y),b=r(t,n,"mangleProps",ye),w=r(t,n,"reserveProps",ye),M=r(t,n,"mangleQuoted",I),L=r(t,n,"minify",I),B=r(t,n,"minifySyntax",I),q=r(t,n,"minifyWhitespace",I),G=r(t,n,"minifyIdentifiers",I),U=r(t,n,"lineLimit",le),z=r(t,n,"drop",W),_=r(t,n,"dropLabels",W),v=r(t,n,"charset",y),g=r(t,n,"treeShaking",I),c=r(t,n,"ignoreAnnotations",I),o=r(t,n,"jsx",y),x=r(t,n,"jsxFactory",y),E=r(t,n,"jsxFragment",y),C=r(t,n,"jsxImportSource",y),S=r(t,n,"jsxDev",I),a=r(t,n,"jsxSideEffects",I),f=r(t,n,"define",ee),h=r(t,n,"logOverride",ee),A=r(t,n,"supported",ee),T=r(t,n,"pure",W),k=r(t,n,"keepNames",I),O=r(t,n,"platform",y),F=r(t,n,"tsconfigRaw",Je);if(i&&e.push(`--legal-comments=${i}`),u!==void 0&&e.push(`--source-root=${u}`),l!==void 0&&e.push(`--sources-content=${l}`),m&&(Array.isArray(m)?e.push(`--target=${Array.from(m).map(Me).join(",")}`):e.push(`--target=${Me(m)}`)),s&&e.push(`--format=${s}`),d&&e.push(`--global-name=${d}`),O&&e.push(`--platform=${O}`),F&&e.push(`--tsconfig-raw=${typeof F=="string"?F:JSON.stringify(F)}`),L&&e.push("--minify"),B&&e.push("--minify-syntax"),q&&e.push("--minify-whitespace"),G&&e.push("--minify-identifiers"),U&&e.push(`--line-limit=${U}`),v&&e.push(`--charset=${v}`),g!==void 0&&e.push(`--tree-shaking=${g}`),c&&e.push("--ignore-annotations"),z)for(let R of z)e.push(`--drop:${Y(R,"drop")}`);if(_&&e.push(`--drop-labels=${Array.from(_).map(R=>Y(R,"dropLabels")).join(",")}`),b&&e.push(`--mangle-props=${b.source}`),w&&e.push(`--reserve-props=${w.source}`),M!==void 0&&e.push(`--mangle-quoted=${M}`),o&&e.push(`--jsx=${o}`),x&&e.push(`--jsx-factory=${x}`),E&&e.push(`--jsx-fragment=${E}`),C&&e.push(`--jsx-import-source=${C}`),S&&e.push("--jsx-dev"),a&&e.push("--jsx-side-effects"),f)for(let R in f){if(R.indexOf("=")>=0)throw new Error(`Invalid define: ${R}`);e.push(`--define:${R}=${Y(f[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}=${Y(h[R],"log override",R)}`)}if(A)for(let R in A){if(R.indexOf("=")>=0)throw new Error(`Invalid supported: ${R}`);let $=A[R];if(typeof $!="boolean")throw new Error(`Expected value for supported ${J(R)} to be a boolean, got ${typeof $} instead`);e.push(`--supported:${R}=${$}`)}if(T)for(let R of T)e.push(`--pure:${Y(R,"pure")}`);k&&e.push("--keep-names")}function He(e,t,n,i,u){var oe;let l=[],m=[],s=Object.create(null),d=null,b=null;he(l,t,s,n,i),Ue(l,t,s);let w=r(t,s,"sourcemap",Te),M=r(t,s,"bundle",I),L=r(t,s,"splitting",I),B=r(t,s,"preserveSymlinks",I),q=r(t,s,"metafile",I),G=r(t,s,"outfile",y),U=r(t,s,"outdir",y),z=r(t,s,"outbase",y),_=r(t,s,"tsconfig",y),v=r(t,s,"resolveExtensions",W),g=r(t,s,"nodePaths",W),c=r(t,s,"mainFields",W),o=r(t,s,"conditions",W),x=r(t,s,"external",W),E=r(t,s,"packages",y),C=r(t,s,"alias",ee),S=r(t,s,"loader",ee),a=r(t,s,"outExtension",ee),f=r(t,s,"publicPath",y),h=r(t,s,"entryNames",y),A=r(t,s,"chunkNames",y),T=r(t,s,"assetNames",y),k=r(t,s,"inject",W),O=r(t,s,"banner",ee),F=r(t,s,"footer",ee),R=r(t,s,"entryPoints",Ve),$=r(t,s,"absWorkingDir",y),D=r(t,s,"stdin",ee),P=(oe=r(t,s,"write",I))!=null?oe:u,j=r(t,s,"allowOverwrite",I),V=r(t,s,"mangleCache",ee);if(s.plugins=!0,K(t,s,`in ${e}() call`),w&&l.push(`--sourcemap${w===!0?"":`=${w}`}`),M&&l.push("--bundle"),j&&l.push("--allow-overwrite"),L&&l.push("--splitting"),B&&l.push("--preserve-symlinks"),q&&l.push("--metafile"),G&&l.push(`--outfile=${G}`),U&&l.push(`--outdir=${U}`),z&&l.push(`--outbase=${z}`),_&&l.push(`--tsconfig=${_}`),E&&l.push(`--packages=${E}`),v){let p=[];for(let N of v){if(Y(N,"resolve extension"),N.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${N}`);p.push(N)}l.push(`--resolve-extensions=${p.join(",")}`)}if(f&&l.push(`--public-path=${f}`),h&&l.push(`--entry-names=${h}`),A&&l.push(`--chunk-names=${A}`),T&&l.push(`--asset-names=${T}`),c){let p=[];for(let N of c){if(Y(N,"main field"),N.indexOf(",")>=0)throw new Error(`Invalid main field: ${N}`);p.push(N)}l.push(`--main-fields=${p.join(",")}`)}if(o){let p=[];for(let N of o){if(Y(N,"condition"),N.indexOf(",")>=0)throw new Error(`Invalid condition: ${N}`);p.push(N)}l.push(`--conditions=${p.join(",")}`)}if(x)for(let p of x)l.push(`--external:${Y(p,"external")}`);if(C)for(let p in C){if(p.indexOf("=")>=0)throw new Error(`Invalid package name in alias: ${p}`);l.push(`--alias:${p}=${Y(C[p],"alias",p)}`)}if(O)for(let p in O){if(p.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${p}`);l.push(`--banner:${p}=${Y(O[p],"banner",p)}`)}if(F)for(let p in F){if(p.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${p}`);l.push(`--footer:${p}=${Y(F[p],"footer",p)}`)}if(k)for(let p of k)l.push(`--inject:${Y(p,"inject")}`);if(S)for(let p in S){if(p.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${p}`);l.push(`--loader:${p}=${Y(S[p],"loader",p)}`)}if(a)for(let p in a){if(p.indexOf("=")>=0)throw new Error(`Invalid out extension: ${p}`);l.push(`--out-extension:${p}=${Y(a[p],"out extension",p)}`)}if(R)if(Array.isArray(R))for(let p=0,N=R.length;p<N;p++){let X=R[p];if(typeof X=="object"&&X!==null){let te=Object.create(null),H=r(X,te,"in",y),ue=r(X,te,"out",y);if(K(X,te,"in entry point at index "+p),H===void 0)throw new Error('Missing property "in" for entry point at index '+p);if(ue===void 0)throw new Error('Missing property "out" for entry point at index '+p);m.push([ue,H])}else m.push(["",Y(X,"entry point at index "+p)])}else for(let p in R)m.push([p,Y(R[p],"entry point",p)]);if(D){let p=Object.create(null),N=r(D,p,"contents",Pe),X=r(D,p,"resolveDir",y),te=r(D,p,"sourcefile",y),H=r(D,p,"loader",y);K(D,p,'in "stdin" object'),te&&l.push(`--sourcefile=${te}`),H&&l.push(`--loader=${H}`),X&&(b=X),typeof N=="string"?d=Z(N):N instanceof Uint8Array&&(d=N)}let Q=[];if(g)for(let p of g)p+="",Q.push(p);return{entries:m,flags:l,write:P,stdinContents:d,stdinResolveDir:b,absWorkingDir:$,nodePaths:Q,mangleCache:Be(V)}}function Xe(e,t,n,i){let u=[],l=Object.create(null);he(u,t,l,n,i),Ue(u,t,l);let m=r(t,l,"sourcemap",Te),s=r(t,l,"sourcefile",y),d=r(t,l,"loader",y),b=r(t,l,"banner",y),w=r(t,l,"footer",y),M=r(t,l,"mangleCache",ee);return K(t,l,`in ${e}() call`),m&&u.push(`--sourcemap=${m===!0?"external":m}`),s&&u.push(`--sourcefile=${s}`),d&&u.push(`--loader=${d}`),b&&u.push(`--banner=${b}`),w&&u.push(`--footer=${w}`),{flags:u,mangleCache:Be(M)}}function je(e){let t={},n={didClose:!1,reason:""},i={},u=0,l=0,m=new Uint8Array(16*1024),s=0,d=v=>{let g=s+v.length;if(g>m.length){let o=new Uint8Array(g*2);o.set(m),m=o}m.set(v,s),s+=v.length;let c=0;for(;c+4<=s;){let o=Ee(m,c);if(c+4+o>s)break;c+=4,q(m.subarray(c,c+o)),c+=o}c>0&&(m.copyWithin(0,c,s),s-=c)},b=v=>{n.didClose=!0,v&&(n.reason=": "+(v.message||v));let g="The service was stopped"+n.reason;for(let c in i)i[c](g,null);i={}},w=(v,g,c)=>{if(n.didClose)return c("The service is no longer running"+n.reason,null);let o=u++;i[o]=(x,E)=>{try{c(x,E)}finally{v&&v.unref()}},v&&v.ref(),e.writeToStdin(Oe({id:o,isRequest:!0,value:g}))},M=(v,g)=>{if(n.didClose)throw new Error("The service is no longer running"+n.reason);e.writeToStdin(Oe({id:v,isRequest:!1,value:g}))},L=async(v,g)=>{try{if(g.command==="ping"){M(v,{});return}if(typeof g.key=="number"){let c=t[g.key];if(!c)return;let o=c[g.command];if(o){await o(v,g);return}}throw new Error("Invalid command: "+g.command)}catch(c){let o=[ie(c,e,null,void 0,"")];try{M(v,{errors:o})}catch(x){}}},B=!0,q=v=>{if(B){B=!1;let c=String.fromCharCode(...v);if(c!=="0.21.3")throw new Error(`Cannot start service: Host version "0.21.3" does not match binary version ${J(c)}`);return}let g=Se(v);if(g.isRequest)L(g.id,g.value);else{let c=i[g.id];delete i[g.id],g.value.error?c(g.value.error,{}):c(null,g.value)}};return{readFromStdout:d,afterClose:b,service:{buildOrContext:({callName:v,refs:g,options:c,isTTY:o,defaultWD:x,callback:E})=>{let C=0,S=l++,a={},f={ref(){++C===1&&g&&g.ref()},unref(){--C===0&&(delete t[S],g&&g.unref())}};t[S]=a,f.ref(),Ze(v,S,w,M,f,e,a,c,o,x,(h,A)=>{try{E(h,A)}finally{f.unref()}})},transform:({callName:v,refs:g,input:c,options:o,isTTY:x,fs:E,callback:C})=>{let S=Le(),a=f=>{try{if(typeof c!="string"&&!(c instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:h,mangleCache:A}=Xe(v,o,x,$e),T={command:"transform",flags:h,inputFS:f!==null,input:f!==null?Z(f):typeof c=="string"?Z(c):c};A&&(T.mangleCache=A),w(g,T,(k,O)=>{if(k)return C(new Error(k),null);let F=ae(O.errors,S),R=ae(O.warnings,S),$=1,D=()=>{if(--$===0){let P={warnings:R,code:O.code,map:O.map,mangleCache:void 0,legalComments:void 0};"legalComments"in O&&(P.legalComments=O==null?void 0:O.legalComments),O.mangleCache&&(P.mangleCache=O==null?void 0:O.mangleCache),C(null,P)}};if(F.length>0)return C(fe("Transform failed",F,R),null);O.codeFS&&($++,E.readFile(O.code,(P,j)=>{P!==null?C(P,null):(O.code=j,D())})),O.mapFS&&($++,E.readFile(O.map,(P,j)=>{P!==null?C(P,null):(O.map=j,D())})),D()})}catch(h){let A=[];try{he(A,o,{},x,$e)}catch(k){}let T=ie(h,e,S,void 0,"");w(g,{command:"error",flags:A,error:T},()=>{T.detail=S.load(T.detail),C(fe("Transform failed",[T],[]),null)})}};if((typeof c=="string"||c instanceof Uint8Array)&&c.length>1024*1024){let f=a;a=()=>E.writeFile(c,f)}a(null)},formatMessages:({callName:v,refs:g,messages:c,options:o,callback:x})=>{if(!o)throw new Error(`Missing second argument in ${v}() call`);let E={},C=r(o,E,"kind",y),S=r(o,E,"color",I),a=r(o,E,"terminalWidth",le);if(K(o,E,`in ${v}() call`),C===void 0)throw new Error(`Missing "kind" in ${v}() call`);if(C!=="error"&&C!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${v}() call`);let f={command:"format-msgs",messages:ne(c,"messages",null,"",a),isWarning:C==="warning"};S!==void 0&&(f.color=S),a!==void 0&&(f.terminalWidth=a),w(g,f,(h,A)=>{if(h)return x(new Error(h),null);x(null,A.messages)})},analyzeMetafile:({callName:v,refs:g,metafile:c,options:o,callback:x})=>{o===void 0&&(o={});let E={},C=r(o,E,"color",I),S=r(o,E,"verbose",I);K(o,E,`in ${v}() call`);let a={command:"analyze-metafile",metafile:c};C!==void 0&&(a.color=C),S!==void 0&&(a.verbose=S),w(g,a,(f,h)=>{if(f)return x(new Error(f),null);x(null,h.result)})}}}}function Ze(e,t,n,i,u,l,m,s,d,b,w){let M=Le(),L=e==="context",B=(U,z)=>{let _=[];try{he(_,s,{},d,ke)}catch(g){}let v=ie(U,l,M,void 0,z);n(u,{command:"error",flags:_,error:v},()=>{v.detail=M.load(v.detail),w(fe(L?"Context failed":"Build failed",[v],[]),null)})},q;if(typeof s=="object"){let U=s.plugins;if(U!==void 0){if(!Array.isArray(U))return B(new Error('"plugins" must be an array'),"");q=U}}if(q&&q.length>0){if(l.isSync)return B(new Error("Cannot use plugins in synchronous API calls"),"");et(t,n,i,u,l,m,s,q,M).then(U=>{if(!U.ok)return B(U.error,U.pluginName);try{G(U.requestPlugins,U.runOnEndCallbacks,U.scheduleOnDisposeCallbacks)}catch(z){B(z,"")}},U=>B(U,""));return}try{G(null,(U,z)=>z([],[]),()=>{})}catch(U){B(U,"")}function G(U,z,_){let v=l.hasFS,{entries:g,flags:c,write:o,stdinContents:x,stdinResolveDir:E,absWorkingDir:C,nodePaths:S,mangleCache:a}=He(e,s,d,ke,v);if(o&&!l.hasFS)throw new Error('The "write" option is unavailable in this environment');let f={command:"build",key:t,entries:g,flags:c,write:o,stdinContents:x,stdinResolveDir:E,absWorkingDir:C||b,nodePaths:S,context:L};U&&(f.plugins=U),a&&(f.mangleCache=a);let h=(k,O)=>{let F={errors:ae(k.errors,M),warnings:ae(k.warnings,M),outputFiles:void 0,metafile:void 0,mangleCache:void 0},R=F.errors.slice(),$=F.warnings.slice();k.outputFiles&&(F.outputFiles=k.outputFiles.map(tt)),k.metafile&&(F.metafile=JSON.parse(k.metafile)),k.mangleCache&&(F.mangleCache=k.mangleCache),k.writeToStdout!==void 0&&console.log(re(k.writeToStdout).replace(/\n$/,"")),z(F,(D,P)=>{if(R.length>0||D.length>0){let j=fe("Build failed",R.concat(D),$.concat(P));return O(j,null,D,P)}O(null,F,D,P)})},A,T;L&&(m["on-end"]=(k,O)=>new Promise(F=>{h(O,(R,$,D,P)=>{let j={errors:D,warnings:P};T&&T(R,$),A=void 0,T=void 0,i(k,j),F()})})),n(u,f,(k,O)=>{if(k)return w(new Error(k),null);if(!L)return h(O,($,D)=>(_(),w($,D)));if(O.errors.length>0)return w(fe("Context failed",O.errors,O.warnings),null);let F=!1,R={rebuild:()=>(A||(A=new Promise(($,D)=>{let P;T=(V,Q)=>{P||(P=()=>V?D(V):$(Q))};let j=()=>{n(u,{command:"rebuild",key:t},(Q,oe)=>{Q?D(new Error(Q)):P?P():j()})};j()})),A),watch:($={})=>new Promise((D,P)=>{if(!l.hasFS)throw new Error('Cannot use the "watch" API in this environment');K($,{},"in watch() call"),n(u,{command:"watch",key:t},Q=>{Q?P(new Error(Q)):D(void 0)})}),serve:($={})=>new Promise((D,P)=>{if(!l.hasFS)throw new Error('Cannot use the "serve" API in this environment');let j={},V=r($,j,"port",le),Q=r($,j,"host",y),oe=r($,j,"servedir",y),p=r($,j,"keyfile",y),N=r($,j,"certfile",y),X=r($,j,"fallback",y),te=r($,j,"onRequest",Fe);K($,j,"in serve() call");let H={command:"serve",key:t,onRequest:!!te};V!==void 0&&(H.port=V),Q!==void 0&&(H.host=Q),oe!==void 0&&(H.servedir=oe),p!==void 0&&(H.keyfile=p),N!==void 0&&(H.certfile=N),X!==void 0&&(H.fallback=X),n(u,H,(ue,Ne)=>{if(ue)return P(new Error(ue));te&&(m["serve-request"]=(Ie,We)=>{te(We.args),i(Ie,{})}),D(Ne)})}),cancel:()=>new Promise($=>{if(F)return $();n(u,{command:"cancel",key:t},()=>{$()})}),dispose:()=>new Promise($=>{if(F)return $();F=!0,n(u,{command:"dispose",key:t},()=>{$(),_(),u.unref()})})};u.ref(),w(null,R)})}}var et=async(e,t,n,i,u,l,m,s,d)=>{let b=[],w=[],M={},L={},B=[],q=0,G=0,U=[],z=!1;s=[...s];for(let g of s){let c={};if(typeof g!="object")throw new Error(`Plugin at index ${G} must be an object`);let o=r(g,c,"name",y);if(typeof o!="string"||o==="")throw new Error(`Plugin at index ${G} is missing a name`);try{let x=r(g,c,"setup",Fe);if(typeof x!="function")throw new Error("Plugin is missing a setup function");K(g,c,`on plugin ${J(o)}`);let E={name:o,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};G++;let S=x({initialOptions:m,resolve:(a,f={})=>{if(!z)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),A=r(f,h,"pluginName",y),T=r(f,h,"importer",y),k=r(f,h,"namespace",y),O=r(f,h,"resolveDir",y),F=r(f,h,"kind",y),R=r(f,h,"pluginData",me);return K(f,h,"in resolve() call"),new Promise(($,D)=>{let P={command:"resolve",path:a,key:e,pluginName:o};if(A!=null&&(P.pluginName=A),T!=null&&(P.importer=T),k!=null&&(P.namespace=k),O!=null&&(P.resolveDir=O),F!=null)P.kind=F;else throw new Error('Must specify "kind" when calling "resolve"');R!=null&&(P.pluginData=d.store(R)),t(i,P,(j,V)=>{j!==null?D(new Error(j)):$({errors:ae(V.errors,d),warnings:ae(V.warnings,d),path:V.path,external:V.external,sideEffects:V.sideEffects,namespace:V.namespace,suffix:V.suffix,pluginData:d.load(V.pluginData)})})})},onStart(a){let f='This error came from the "onStart" callback registered here:',h=pe(new Error(f),u,"onStart");b.push({name:o,callback:a,note:h}),E.onStart=!0},onEnd(a){let f='This error came from the "onEnd" callback registered here:',h=pe(new Error(f),u,"onEnd");w.push({name:o,callback:a,note:h}),E.onEnd=!0},onResolve(a,f){let h='This error came from the "onResolve" callback registered here:',A=pe(new Error(h),u,"onResolve"),T={},k=r(a,T,"filter",ye),O=r(a,T,"namespace",y);if(K(a,T,`in onResolve() call for plugin ${J(o)}`),k==null)throw new Error("onResolve() call is missing a filter");let F=q++;M[F]={name:o,callback:f,note:A},E.onResolve.push({id:F,filter:k.source,namespace:O||""})},onLoad(a,f){let h='This error came from the "onLoad" callback registered here:',A=pe(new Error(h),u,"onLoad"),T={},k=r(a,T,"filter",ye),O=r(a,T,"namespace",y);if(K(a,T,`in onLoad() call for plugin ${J(o)}`),k==null)throw new Error("onLoad() call is missing a filter");let F=q++;L[F]={name:o,callback:f,note:A},E.onLoad.push({id:F,filter:k.source,namespace:O||""})},onDispose(a){B.push(a)},esbuild:u.esbuild});S&&await S,U.push(E)}catch(x){return{ok:!1,error:x,pluginName:o}}}l["on-start"]=async(g,c)=>{let o={errors:[],warnings:[]};await Promise.all(b.map(async({name:x,callback:E,note:C})=>{try{let S=await E();if(S!=null){if(typeof S!="object")throw new Error(`Expected onStart() callback in plugin ${J(x)} to return an object`);let a={},f=r(S,a,"errors",W),h=r(S,a,"warnings",W);K(S,a,`from onStart() callback in plugin ${J(x)}`),f!=null&&o.errors.push(...ne(f,"errors",d,x,void 0)),h!=null&&o.warnings.push(...ne(h,"warnings",d,x,void 0))}}catch(S){o.errors.push(ie(S,u,d,C&&C(),x))}})),n(g,o)},l["on-resolve"]=async(g,c)=>{let o={},x="",E,C;for(let S of c.ids)try{({name:x,callback:E,note:C}=M[S]);let a=await E({path:c.path,importer:c.importer,namespace:c.namespace,resolveDir:c.resolveDir,kind:c.kind,pluginData:d.load(c.pluginData)});if(a!=null){if(typeof a!="object")throw new Error(`Expected onResolve() callback in plugin ${J(x)} to return an object`);let f={},h=r(a,f,"pluginName",y),A=r(a,f,"path",y),T=r(a,f,"namespace",y),k=r(a,f,"suffix",y),O=r(a,f,"external",I),F=r(a,f,"sideEffects",I),R=r(a,f,"pluginData",me),$=r(a,f,"errors",W),D=r(a,f,"warnings",W),P=r(a,f,"watchFiles",W),j=r(a,f,"watchDirs",W);K(a,f,`from onResolve() callback in plugin ${J(x)}`),o.id=S,h!=null&&(o.pluginName=h),A!=null&&(o.path=A),T!=null&&(o.namespace=T),k!=null&&(o.suffix=k),O!=null&&(o.external=O),F!=null&&(o.sideEffects=F),R!=null&&(o.pluginData=d.store(R)),$!=null&&(o.errors=ne($,"errors",d,x,void 0)),D!=null&&(o.warnings=ne(D,"warnings",d,x,void 0)),P!=null&&(o.watchFiles=ge(P,"watchFiles")),j!=null&&(o.watchDirs=ge(j,"watchDirs"));break}}catch(a){o={id:S,errors:[ie(a,u,d,C&&C(),x)]};break}n(g,o)},l["on-load"]=async(g,c)=>{let o={},x="",E,C;for(let S of c.ids)try{({name:x,callback:E,note:C}=L[S]);let a=await E({path:c.path,namespace:c.namespace,suffix:c.suffix,pluginData:d.load(c.pluginData),with:c.with});if(a!=null){if(typeof a!="object")throw new Error(`Expected onLoad() callback in plugin ${J(x)} to return an object`);let f={},h=r(a,f,"pluginName",y),A=r(a,f,"contents",Pe),T=r(a,f,"resolveDir",y),k=r(a,f,"pluginData",me),O=r(a,f,"loader",y),F=r(a,f,"errors",W),R=r(a,f,"warnings",W),$=r(a,f,"watchFiles",W),D=r(a,f,"watchDirs",W);K(a,f,`from onLoad() callback in plugin ${J(x)}`),o.id=S,h!=null&&(o.pluginName=h),A instanceof Uint8Array?o.contents=A:A!=null&&(o.contents=Z(A)),T!=null&&(o.resolveDir=T),k!=null&&(o.pluginData=d.store(k)),O!=null&&(o.loader=O),F!=null&&(o.errors=ne(F,"errors",d,x,void 0)),R!=null&&(o.warnings=ne(R,"warnings",d,x,void 0)),$!=null&&(o.watchFiles=ge($,"watchFiles")),D!=null&&(o.watchDirs=ge(D,"watchDirs"));break}}catch(a){o={id:S,errors:[ie(a,u,d,C&&C(),x)]};break}n(g,o)};let _=(g,c)=>c([],[]);w.length>0&&(_=(g,c)=>{(async()=>{let o=[],x=[];for(let{name:E,callback:C,note:S}of w){let a,f;try{let h=await C(g);if(h!=null){if(typeof h!="object")throw new Error(`Expected onEnd() callback in plugin ${J(E)} to return an object`);let A={},T=r(h,A,"errors",W),k=r(h,A,"warnings",W);K(h,A,`from onEnd() callback in plugin ${J(E)}`),T!=null&&(a=ne(T,"errors",d,E,void 0)),k!=null&&(f=ne(k,"warnings",d,E,void 0))}}catch(h){a=[ie(h,u,d,S&&S(),E)]}if(a){o.push(...a);try{g.errors.push(...a)}catch(h){}}if(f){x.push(...f);try{g.warnings.push(...f)}catch(h){}}}c(o,x)})()});let v=()=>{for(let g of B)setTimeout(()=>g(),0)};return z=!0,{ok:!0,requestPlugins:U,runOnEndCallbacks:_,scheduleOnDisposeCallbacks:v}};function Le(){let e=new Map,t=0;return{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(`
|
|
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 _=JSON.stringify,ke="warning",$e="silent";function Me(e){if(J(e,"target"),e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var me=()=>null,I=e=>typeof e=="boolean"?null:"a boolean",y=e=>typeof e=="string"?null:"a string",ye=e=>e instanceof RegExp?null:"a RegExp object",le=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Fe=e=>typeof e=="function"?null:"a function",z=e=>Array.isArray(e)?null:"an array",ee=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",Ve=e=>typeof e=="object"&&e!==null?null:"an array or an object",Ye=e=>e instanceof WebAssembly.Module?null:"a WebAssembly.Module",Ce=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",Je=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",Ge=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",Pe=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array",Qe=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(`${_(n)} must be ${l}`);return u}function V(e,t,n){for(let i in e)if(!(i in t))throw new Error(`Invalid option ${n}: ${_(i)}`)}function De(e){let t=Object.create(null),n=r(e,t,"wasmURL",Qe),i=r(e,t,"wasmModule",Ye),u=r(e,t,"worker",I);return V(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 ${_(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",I),m=r(t,n,"logLevel",y),s=r(t,n,"logLimit",le);l!==void 0?e.push(`--color=${l}`):i&&e.push("--color=true"),e.push(`--log-level=${m||u}`),e.push(`--log-limit=${s||0}`)}function J(e,t,n){if(typeof e!="string")throw new Error(`Expected value for ${t}${n!==void 0?" "+_(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",I),m=r(t,n,"target",Ge),s=r(t,n,"format",y),d=r(t,n,"globalName",y),b=r(t,n,"mangleProps",ye),w=r(t,n,"reserveProps",ye),M=r(t,n,"mangleQuoted",I),L=r(t,n,"minify",I),D=r(t,n,"minifySyntax",I),q=r(t,n,"minifyWhitespace",I),G=r(t,n,"minifyIdentifiers",I),U=r(t,n,"lineLimit",le),K=r(t,n,"drop",z),Y=r(t,n,"dropLabels",z),v=r(t,n,"charset",y),g=r(t,n,"treeShaking",I),f=r(t,n,"ignoreAnnotations",I),o=r(t,n,"jsx",y),R=r(t,n,"jsxFactory",y),E=r(t,n,"jsxFragment",y),C=r(t,n,"jsxImportSource",y),S=r(t,n,"jsxDev",I),a=r(t,n,"jsxSideEffects",I),c=r(t,n,"define",ee),h=r(t,n,"logOverride",ee),A=r(t,n,"supported",ee),T=r(t,n,"pure",z),$=r(t,n,"keepNames",I),O=r(t,n,"platform",y),F=r(t,n,"tsconfigRaw",Je);if(i&&e.push(`--legal-comments=${i}`),u!==void 0&&e.push(`--source-root=${u}`),l!==void 0&&e.push(`--sources-content=${l}`),m&&(Array.isArray(m)?e.push(`--target=${Array.from(m).map(Me).join(",")}`):e.push(`--target=${Me(m)}`)),s&&e.push(`--format=${s}`),d&&e.push(`--global-name=${d}`),O&&e.push(`--platform=${O}`),F&&e.push(`--tsconfig-raw=${typeof F=="string"?F:JSON.stringify(F)}`),L&&e.push("--minify"),D&&e.push("--minify-syntax"),q&&e.push("--minify-whitespace"),G&&e.push("--minify-identifiers"),U&&e.push(`--line-limit=${U}`),v&&e.push(`--charset=${v}`),g!==void 0&&e.push(`--tree-shaking=${g}`),f&&e.push("--ignore-annotations"),K)for(let x of K)e.push(`--drop:${J(x,"drop")}`);if(Y&&e.push(`--drop-labels=${Array.from(Y).map(x=>J(x,"dropLabels")).join(",")}`),b&&e.push(`--mangle-props=${b.source}`),w&&e.push(`--reserve-props=${w.source}`),M!==void 0&&e.push(`--mangle-quoted=${M}`),o&&e.push(`--jsx=${o}`),R&&e.push(`--jsx-factory=${R}`),E&&e.push(`--jsx-fragment=${E}`),C&&e.push(`--jsx-import-source=${C}`),S&&e.push("--jsx-dev"),a&&e.push("--jsx-side-effects"),c)for(let x in c){if(x.indexOf("=")>=0)throw new Error(`Invalid define: ${x}`);e.push(`--define:${x}=${J(c[x],"define",x)}`)}if(h)for(let x in h){if(x.indexOf("=")>=0)throw new Error(`Invalid log override: ${x}`);e.push(`--log-override:${x}=${J(h[x],"log override",x)}`)}if(A)for(let x in A){if(x.indexOf("=")>=0)throw new Error(`Invalid supported: ${x}`);let k=A[x];if(typeof k!="boolean")throw new Error(`Expected value for supported ${_(x)} to be a boolean, got ${typeof k} instead`);e.push(`--supported:${x}=${k}`)}if(T)for(let x of T)e.push(`--pure:${J(x,"pure")}`);$&&e.push("--keep-names")}function He(e,t,n,i,u){var oe;let l=[],m=[],s=Object.create(null),d=null,b=null;he(l,t,s,n,i),Ue(l,t,s);let w=r(t,s,"sourcemap",Te),M=r(t,s,"bundle",I),L=r(t,s,"splitting",I),D=r(t,s,"preserveSymlinks",I),q=r(t,s,"metafile",I),G=r(t,s,"outfile",y),U=r(t,s,"outdir",y),K=r(t,s,"outbase",y),Y=r(t,s,"tsconfig",y),v=r(t,s,"resolveExtensions",z),g=r(t,s,"nodePaths",z),f=r(t,s,"mainFields",z),o=r(t,s,"conditions",z),R=r(t,s,"external",z),E=r(t,s,"packages",y),C=r(t,s,"alias",ee),S=r(t,s,"loader",ee),a=r(t,s,"outExtension",ee),c=r(t,s,"publicPath",y),h=r(t,s,"entryNames",y),A=r(t,s,"chunkNames",y),T=r(t,s,"assetNames",y),$=r(t,s,"inject",z),O=r(t,s,"banner",ee),F=r(t,s,"footer",ee),x=r(t,s,"entryPoints",Ve),k=r(t,s,"absWorkingDir",y),P=r(t,s,"stdin",ee),j=(oe=r(t,s,"write",I))!=null?oe:u,B=r(t,s,"allowOverwrite",I),H=r(t,s,"mangleCache",ee);if(s.plugins=!0,V(t,s,`in ${e}() call`),w&&l.push(`--sourcemap${w===!0?"":`=${w}`}`),M&&l.push("--bundle"),B&&l.push("--allow-overwrite"),L&&l.push("--splitting"),D&&l.push("--preserve-symlinks"),q&&l.push("--metafile"),G&&l.push(`--outfile=${G}`),U&&l.push(`--outdir=${U}`),K&&l.push(`--outbase=${K}`),Y&&l.push(`--tsconfig=${Y}`),E&&l.push(`--packages=${E}`),v){let p=[];for(let N of v){if(J(N,"resolve extension"),N.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${N}`);p.push(N)}l.push(`--resolve-extensions=${p.join(",")}`)}if(c&&l.push(`--public-path=${c}`),h&&l.push(`--entry-names=${h}`),A&&l.push(`--chunk-names=${A}`),T&&l.push(`--asset-names=${T}`),f){let p=[];for(let N of f){if(J(N,"main field"),N.indexOf(",")>=0)throw new Error(`Invalid main field: ${N}`);p.push(N)}l.push(`--main-fields=${p.join(",")}`)}if(o){let p=[];for(let N of o){if(J(N,"condition"),N.indexOf(",")>=0)throw new Error(`Invalid condition: ${N}`);p.push(N)}l.push(`--conditions=${p.join(",")}`)}if(R)for(let p of R)l.push(`--external:${J(p,"external")}`);if(C)for(let p in C){if(p.indexOf("=")>=0)throw new Error(`Invalid package name in alias: ${p}`);l.push(`--alias:${p}=${J(C[p],"alias",p)}`)}if(O)for(let p in O){if(p.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${p}`);l.push(`--banner:${p}=${J(O[p],"banner",p)}`)}if(F)for(let p in F){if(p.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${p}`);l.push(`--footer:${p}=${J(F[p],"footer",p)}`)}if($)for(let p of $)l.push(`--inject:${J(p,"inject")}`);if(S)for(let p in S){if(p.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${p}`);l.push(`--loader:${p}=${J(S[p],"loader",p)}`)}if(a)for(let p in a){if(p.indexOf("=")>=0)throw new Error(`Invalid out extension: ${p}`);l.push(`--out-extension:${p}=${J(a[p],"out extension",p)}`)}if(x)if(Array.isArray(x))for(let p=0,N=x.length;p<N;p++){let X=x[p];if(typeof X=="object"&&X!==null){let te=Object.create(null),Q=r(X,te,"in",y),ue=r(X,te,"out",y);if(V(X,te,"in entry point at index "+p),Q===void 0)throw new Error('Missing property "in" for entry point at index '+p);if(ue===void 0)throw new Error('Missing property "out" for entry point at index '+p);m.push([ue,Q])}else m.push(["",J(X,"entry point at index "+p)])}else for(let p in x)m.push([p,J(x[p],"entry point",p)]);if(P){let p=Object.create(null),N=r(P,p,"contents",Pe),X=r(P,p,"resolveDir",y),te=r(P,p,"sourcefile",y),Q=r(P,p,"loader",y);V(P,p,'in "stdin" object'),te&&l.push(`--sourcefile=${te}`),Q&&l.push(`--loader=${Q}`),X&&(b=X),typeof N=="string"?d=Z(N):N instanceof Uint8Array&&(d=N)}let W=[];if(g)for(let p of g)p+="",W.push(p);return{entries:m,flags:l,write:j,stdinContents:d,stdinResolveDir:b,absWorkingDir:k,nodePaths:W,mangleCache:Be(H)}}function Xe(e,t,n,i){let u=[],l=Object.create(null);he(u,t,l,n,i),Ue(u,t,l);let m=r(t,l,"sourcemap",Te),s=r(t,l,"sourcefile",y),d=r(t,l,"loader",y),b=r(t,l,"banner",y),w=r(t,l,"footer",y),M=r(t,l,"mangleCache",ee);return V(t,l,`in ${e}() call`),m&&u.push(`--sourcemap=${m===!0?"external":m}`),s&&u.push(`--sourcefile=${s}`),d&&u.push(`--loader=${d}`),b&&u.push(`--banner=${b}`),w&&u.push(`--footer=${w}`),{flags:u,mangleCache:Be(M)}}function je(e){let t={},n={didClose:!1,reason:""},i={},u=0,l=0,m=new Uint8Array(16*1024),s=0,d=v=>{let g=s+v.length;if(g>m.length){let o=new Uint8Array(g*2);o.set(m),m=o}m.set(v,s),s+=v.length;let f=0;for(;f+4<=s;){let o=Ee(m,f);if(f+4+o>s)break;f+=4,q(m.subarray(f,f+o)),f+=o}f>0&&(m.copyWithin(0,f,s),s-=f)},b=v=>{n.didClose=!0,v&&(n.reason=": "+(v.message||v));let g="The service was stopped"+n.reason;for(let f in i)i[f](g,null);i={}},w=(v,g,f)=>{if(n.didClose)return f("The service is no longer running"+n.reason,null);let o=u++;i[o]=(R,E)=>{try{f(R,E)}finally{v&&v.unref()}},v&&v.ref(),e.writeToStdin(Oe({id:o,isRequest:!0,value:g}))},M=(v,g)=>{if(n.didClose)throw new Error("The service is no longer running"+n.reason);e.writeToStdin(Oe({id:v,isRequest:!1,value:g}))},L=async(v,g)=>{try{if(g.command==="ping"){M(v,{});return}if(typeof g.key=="number"){let f=t[g.key];if(!f)return;let o=f[g.command];if(o){await o(v,g);return}}throw new Error("Invalid command: "+g.command)}catch(f){let o=[ie(f,e,null,void 0,"")];try{M(v,{errors:o})}catch(R){}}},D=!0,q=v=>{if(D){D=!1;let f=String.fromCharCode(...v);if(f!=="0.21.4")throw new Error(`Cannot start service: Host version "0.21.4" does not match binary version ${_(f)}`);return}let g=Se(v);if(g.isRequest)L(g.id,g.value);else{let f=i[g.id];delete i[g.id],g.value.error?f(g.value.error,{}):f(null,g.value)}};return{readFromStdout:d,afterClose:b,service:{buildOrContext:({callName:v,refs:g,options:f,isTTY:o,defaultWD:R,callback:E})=>{let C=0,S=l++,a={},c={ref(){++C===1&&g&&g.ref()},unref(){--C===0&&(delete t[S],g&&g.unref())}};t[S]=a,c.ref(),Ze(v,S,w,M,c,e,a,f,o,R,(h,A)=>{try{E(h,A)}finally{c.unref()}})},transform:({callName:v,refs:g,input:f,options:o,isTTY:R,fs:E,callback:C})=>{let S=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:A}=Xe(v,o,R,$e),T={command:"transform",flags:h,inputFS:c!==null,input:c!==null?Z(c):typeof f=="string"?Z(f):f};A&&(T.mangleCache=A),w(g,T,($,O)=>{if($)return C(new Error($),null);let F=ae(O.errors,S),x=ae(O.warnings,S),k=1,P=()=>{if(--k===0){let j={warnings:x,code:O.code,map:O.map,mangleCache:void 0,legalComments:void 0};"legalComments"in O&&(j.legalComments=O==null?void 0:O.legalComments),O.mangleCache&&(j.mangleCache=O==null?void 0:O.mangleCache),C(null,j)}};if(F.length>0)return C(ce("Transform failed",F,x),null);O.codeFS&&(k++,E.readFile(O.code,(j,B)=>{j!==null?C(j,null):(O.code=B,P())})),O.mapFS&&(k++,E.readFile(O.map,(j,B)=>{j!==null?C(j,null):(O.map=B,P())})),P()})}catch(h){let A=[];try{he(A,o,{},R,$e)}catch($){}let T=ie(h,e,S,void 0,"");w(g,{command:"error",flags:A,error:T},()=>{T.detail=S.load(T.detail),C(ce("Transform failed",[T],[]),null)})}};if((typeof f=="string"||f instanceof Uint8Array)&&f.length>1024*1024){let c=a;a=()=>E.writeFile(f,c)}a(null)},formatMessages:({callName:v,refs:g,messages:f,options:o,callback:R})=>{if(!o)throw new Error(`Missing second argument in ${v}() call`);let E={},C=r(o,E,"kind",y),S=r(o,E,"color",I),a=r(o,E,"terminalWidth",le);if(V(o,E,`in ${v}() call`),C===void 0)throw new Error(`Missing "kind" in ${v}() call`);if(C!=="error"&&C!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${v}() call`);let c={command:"format-msgs",messages:ne(f,"messages",null,"",a),isWarning:C==="warning"};S!==void 0&&(c.color=S),a!==void 0&&(c.terminalWidth=a),w(g,c,(h,A)=>{if(h)return R(new Error(h),null);R(null,A.messages)})},analyzeMetafile:({callName:v,refs:g,metafile:f,options:o,callback:R})=>{o===void 0&&(o={});let E={},C=r(o,E,"color",I),S=r(o,E,"verbose",I);V(o,E,`in ${v}() call`);let a={command:"analyze-metafile",metafile:f};C!==void 0&&(a.color=C),S!==void 0&&(a.verbose=S),w(g,a,(c,h)=>{if(c)return R(new Error(c),null);R(null,h.result)})}}}}function Ze(e,t,n,i,u,l,m,s,d,b,w){let M=Le(),L=e==="context",D=(U,K)=>{let Y=[];try{he(Y,s,{},d,ke)}catch(g){}let v=ie(U,l,M,void 0,K);n(u,{command:"error",flags:Y,error:v},()=>{v.detail=M.load(v.detail),w(ce(L?"Context failed":"Build failed",[v],[]),null)})},q;if(typeof s=="object"){let U=s.plugins;if(U!==void 0){if(!Array.isArray(U))return D(new Error('"plugins" must be an array'),"");q=U}}if(q&&q.length>0){if(l.isSync)return D(new Error("Cannot use plugins in synchronous API calls"),"");et(t,n,i,u,l,m,s,q,M).then(U=>{if(!U.ok)return D(U.error,U.pluginName);try{G(U.requestPlugins,U.runOnEndCallbacks,U.scheduleOnDisposeCallbacks)}catch(K){D(K,"")}},U=>D(U,""));return}try{G(null,(U,K)=>K([],[]),()=>{})}catch(U){D(U,"")}function G(U,K,Y){let v=l.hasFS,{entries:g,flags:f,write:o,stdinContents:R,stdinResolveDir:E,absWorkingDir:C,nodePaths:S,mangleCache:a}=He(e,s,d,ke,v);if(o&&!l.hasFS)throw new Error('The "write" option is unavailable in this environment');let c={command:"build",key:t,entries:g,flags:f,write:o,stdinContents:R,stdinResolveDir:E,absWorkingDir:C||b,nodePaths:S,context:L};U&&(c.plugins=U),a&&(c.mangleCache=a);let h=($,O)=>{let F={errors:ae($.errors,M),warnings:ae($.warnings,M),outputFiles:void 0,metafile:void 0,mangleCache:void 0},x=F.errors.slice(),k=F.warnings.slice();$.outputFiles&&(F.outputFiles=$.outputFiles.map(nt)),$.metafile&&(F.metafile=JSON.parse($.metafile)),$.mangleCache&&(F.mangleCache=$.mangleCache),$.writeToStdout!==void 0&&console.log(re($.writeToStdout).replace(/\n$/,"")),K(F,(P,j)=>{if(x.length>0||P.length>0){let B=ce("Build failed",x.concat(P),k.concat(j));return O(B,null,P,j)}O(null,F,P,j)})},A,T;L&&(m["on-end"]=($,O)=>new Promise(F=>{h(O,(x,k,P,j)=>{let B={errors:P,warnings:j};T&&T(x,k),A=void 0,T=void 0,i($,B),F()})})),n(u,c,($,O)=>{if($)return w(new Error($),null);if(!L)return h(O,(k,P)=>(Y(),w(k,P)));if(O.errors.length>0)return w(ce("Context failed",O.errors,O.warnings),null);let F=!1,x={rebuild:()=>(A||(A=new Promise((k,P)=>{let j;T=(H,W)=>{j||(j=()=>H?P(H):k(W))};let B=()=>{n(u,{command:"rebuild",key:t},(W,oe)=>{W?P(new Error(W)):j?j():B()})};B()})),A),watch:(k={})=>new Promise((P,j)=>{if(!l.hasFS)throw new Error('Cannot use the "watch" API in this environment');V(k,{},"in watch() call"),n(u,{command:"watch",key:t},W=>{W?j(new Error(W)):P(void 0)})}),serve:(k={})=>new Promise((P,j)=>{if(!l.hasFS)throw new Error('Cannot use the "serve" API in this environment');let B={},H=r(k,B,"port",le),W=r(k,B,"host",y),oe=r(k,B,"servedir",y),p=r(k,B,"keyfile",y),N=r(k,B,"certfile",y),X=r(k,B,"fallback",y),te=r(k,B,"onRequest",Fe);V(k,B,"in serve() call");let Q={command:"serve",key:t,onRequest:!!te};H!==void 0&&(Q.port=H),W!==void 0&&(Q.host=W),oe!==void 0&&(Q.servedir=oe),p!==void 0&&(Q.keyfile=p),N!==void 0&&(Q.certfile=N),X!==void 0&&(Q.fallback=X),n(u,Q,(ue,Ne)=>{if(ue)return j(new Error(ue));te&&(m["serve-request"]=(Ie,We)=>{te(We.args),i(Ie,{})}),P(Ne)})}),cancel:()=>new Promise(k=>{if(F)return k();n(u,{command:"cancel",key:t},()=>{k()})}),dispose:()=>new Promise(k=>{if(F)return k();F=!0,n(u,{command:"dispose",key:t},()=>{k(),Y(),u.unref()})})};u.ref(),w(null,x)})}}var et=async(e,t,n,i,u,l,m,s,d)=>{let b=[],w=[],M={},L={},D=[],q=0,G=0,U=[],K=!1;s=[...s];for(let g of s){let f={};if(typeof g!="object")throw new Error(`Plugin at index ${G} must be an object`);let o=r(g,f,"name",y);if(typeof o!="string"||o==="")throw new Error(`Plugin at index ${G} is missing a name`);try{let R=r(g,f,"setup",Fe);if(typeof R!="function")throw new Error("Plugin is missing a setup function");V(g,f,`on plugin ${_(o)}`);let E={name:o,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};G++;let S=R({initialOptions:m,resolve:(a,c={})=>{if(!K)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),A=r(c,h,"pluginName",y),T=r(c,h,"importer",y),$=r(c,h,"namespace",y),O=r(c,h,"resolveDir",y),F=r(c,h,"kind",y),x=r(c,h,"pluginData",me),k=r(c,h,"with",ee);return V(c,h,"in resolve() call"),new Promise((P,j)=>{let B={command:"resolve",path:a,key:e,pluginName:o};if(A!=null&&(B.pluginName=A),T!=null&&(B.importer=T),$!=null&&(B.namespace=$),O!=null&&(B.resolveDir=O),F!=null)B.kind=F;else throw new Error('Must specify "kind" when calling "resolve"');x!=null&&(B.pluginData=d.store(x)),k!=null&&(B.with=tt(k,"with")),t(i,B,(H,W)=>{H!==null?j(new Error(H)):P({errors:ae(W.errors,d),warnings:ae(W.warnings,d),path:W.path,external:W.external,sideEffects:W.sideEffects,namespace:W.namespace,suffix:W.suffix,pluginData:d.load(W.pluginData)})})})},onStart(a){let c='This error came from the "onStart" callback registered here:',h=pe(new Error(c),u,"onStart");b.push({name:o,callback:a,note:h}),E.onStart=!0},onEnd(a){let c='This error came from the "onEnd" callback registered here:',h=pe(new Error(c),u,"onEnd");w.push({name:o,callback:a,note:h}),E.onEnd=!0},onResolve(a,c){let h='This error came from the "onResolve" callback registered here:',A=pe(new Error(h),u,"onResolve"),T={},$=r(a,T,"filter",ye),O=r(a,T,"namespace",y);if(V(a,T,`in onResolve() call for plugin ${_(o)}`),$==null)throw new Error("onResolve() call is missing a filter");let F=q++;M[F]={name:o,callback:c,note:A},E.onResolve.push({id:F,filter:$.source,namespace:O||""})},onLoad(a,c){let h='This error came from the "onLoad" callback registered here:',A=pe(new Error(h),u,"onLoad"),T={},$=r(a,T,"filter",ye),O=r(a,T,"namespace",y);if(V(a,T,`in onLoad() call for plugin ${_(o)}`),$==null)throw new Error("onLoad() call is missing a filter");let F=q++;L[F]={name:o,callback:c,note:A},E.onLoad.push({id:F,filter:$.source,namespace:O||""})},onDispose(a){D.push(a)},esbuild:u.esbuild});S&&await S,U.push(E)}catch(R){return{ok:!1,error:R,pluginName:o}}}l["on-start"]=async(g,f)=>{let o={errors:[],warnings:[]};await Promise.all(b.map(async({name:R,callback:E,note:C})=>{try{let S=await E();if(S!=null){if(typeof S!="object")throw new Error(`Expected onStart() callback in plugin ${_(R)} to return an object`);let a={},c=r(S,a,"errors",z),h=r(S,a,"warnings",z);V(S,a,`from onStart() callback in plugin ${_(R)}`),c!=null&&o.errors.push(...ne(c,"errors",d,R,void 0)),h!=null&&o.warnings.push(...ne(h,"warnings",d,R,void 0))}}catch(S){o.errors.push(ie(S,u,d,C&&C(),R))}})),n(g,o)},l["on-resolve"]=async(g,f)=>{let o={},R="",E,C;for(let S of f.ids)try{({name:R,callback:E,note:C}=M[S]);let a=await E({path:f.path,importer:f.importer,namespace:f.namespace,resolveDir:f.resolveDir,kind:f.kind,pluginData:d.load(f.pluginData),with:f.with});if(a!=null){if(typeof a!="object")throw new Error(`Expected onResolve() callback in plugin ${_(R)} to return an object`);let c={},h=r(a,c,"pluginName",y),A=r(a,c,"path",y),T=r(a,c,"namespace",y),$=r(a,c,"suffix",y),O=r(a,c,"external",I),F=r(a,c,"sideEffects",I),x=r(a,c,"pluginData",me),k=r(a,c,"errors",z),P=r(a,c,"warnings",z),j=r(a,c,"watchFiles",z),B=r(a,c,"watchDirs",z);V(a,c,`from onResolve() callback in plugin ${_(R)}`),o.id=S,h!=null&&(o.pluginName=h),A!=null&&(o.path=A),T!=null&&(o.namespace=T),$!=null&&(o.suffix=$),O!=null&&(o.external=O),F!=null&&(o.sideEffects=F),x!=null&&(o.pluginData=d.store(x)),k!=null&&(o.errors=ne(k,"errors",d,R,void 0)),P!=null&&(o.warnings=ne(P,"warnings",d,R,void 0)),j!=null&&(o.watchFiles=ge(j,"watchFiles")),B!=null&&(o.watchDirs=ge(B,"watchDirs"));break}}catch(a){o={id:S,errors:[ie(a,u,d,C&&C(),R)]};break}n(g,o)},l["on-load"]=async(g,f)=>{let o={},R="",E,C;for(let S of f.ids)try{({name:R,callback:E,note:C}=L[S]);let a=await E({path:f.path,namespace:f.namespace,suffix:f.suffix,pluginData:d.load(f.pluginData),with:f.with});if(a!=null){if(typeof a!="object")throw new Error(`Expected onLoad() callback in plugin ${_(R)} to return an object`);let c={},h=r(a,c,"pluginName",y),A=r(a,c,"contents",Pe),T=r(a,c,"resolveDir",y),$=r(a,c,"pluginData",me),O=r(a,c,"loader",y),F=r(a,c,"errors",z),x=r(a,c,"warnings",z),k=r(a,c,"watchFiles",z),P=r(a,c,"watchDirs",z);V(a,c,`from onLoad() callback in plugin ${_(R)}`),o.id=S,h!=null&&(o.pluginName=h),A instanceof Uint8Array?o.contents=A:A!=null&&(o.contents=Z(A)),T!=null&&(o.resolveDir=T),$!=null&&(o.pluginData=d.store($)),O!=null&&(o.loader=O),F!=null&&(o.errors=ne(F,"errors",d,R,void 0)),x!=null&&(o.warnings=ne(x,"warnings",d,R,void 0)),k!=null&&(o.watchFiles=ge(k,"watchFiles")),P!=null&&(o.watchDirs=ge(P,"watchDirs"));break}}catch(a){o={id:S,errors:[ie(a,u,d,C&&C(),R)]};break}n(g,o)};let Y=(g,f)=>f([],[]);w.length>0&&(Y=(g,f)=>{(async()=>{let o=[],R=[];for(let{name:E,callback:C,note:S}of w){let a,c;try{let h=await C(g);if(h!=null){if(typeof h!="object")throw new Error(`Expected onEnd() callback in plugin ${_(E)} to return an object`);let A={},T=r(h,A,"errors",z),$=r(h,A,"warnings",z);V(h,A,`from onEnd() callback in plugin ${_(E)}`),T!=null&&(a=ne(T,"errors",d,E,void 0)),$!=null&&(c=ne($,"warnings",d,E,void 0))}}catch(h){a=[ie(h,u,d,S&&S(),E)]}if(a){o.push(...a);try{g.errors.push(...a)}catch(h){}}if(c){R.push(...c);try{g.warnings.push(...c)}catch(h){}}}f(o,R)})()});let v=()=>{for(let g of D)setTimeout(()=>g(),0)};return K=!0,{ok:!0,requestPlugins:U,runOnEndCallbacks:Y,scheduleOnDisposeCallbacks:v}};function Le(){let e=new Map,t=0;return{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
7
|
`);l.splice(1,1);let m=qe(t,l,n);if(m)return i={text:e.message,location:m},i}catch(l){}}}function ie(e,t,n,i,u){let l="Internal error",m=null;try{l=(e&&e.message||e)+""}catch(s){}try{m=qe(t,(e.stack+"").split(`
|
|
8
8
|
`),"")}catch(s){}return{id:"",pluginName:u,text:l,location:m,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 m=/^(?:new |async )?\S+ \((.*)\)$/.exec(l);if(m){l=m[1];continue}if(m=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(l),m){l=m[1];continue}if(m=/^(\S+):(\d+):(\d+)$/.exec(l),m){let s;try{s=e.readFileSync(m[1],"utf8")}catch(M){break}let d=s.split(/\r\n|\r|\n|\u2028|\u2029/)[+m[2]-1]||"",b=+m[3]-1,w=d.slice(b,b+n.length)===n?n.length:0;return{file:m[1],namespace:"file",line:+m[2],column:Z(d.slice(0,b)).length,length:Z(d.slice(b,b+w)).length,lineText:d+`
|
|
9
9
|
`+t.slice(1).join(`
|
|
10
|
-
`),suggestion:""}}break}}return null}function
|
|
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,m)=>{if(m===i)return`
|
|
11
11
|
...`;if(!l.location)return`
|
|
12
12
|
error: ${l.text}`;let{file:s,line:d,column:b}=l.location,w=l.pluginName?`[plugin: ${l.pluginName}] `:"";return`
|
|
13
|
-
${s}:${d}:${b}: ERROR: ${w}${l.text}`}).join("");let u=new Error(e);for(let[l,m]of[["errors",t],["warnings",n]])Object.defineProperty(u,l,{configurable:!0,enumerable:!0,get:()=>m,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),m=r(e,i,"line",le),s=r(e,i,"column",le),d=r(e,i,"length",le),b=r(e,i,"lineText",y),w=r(e,i,"suggestion",y);if(K(e,i,t),b){let M=b.slice(0,(s&&s>0?s:0)+(d&&d>0?d:0)+(n&&n>0?n:80));!/[\x7F-\uFFFF]/.test(M)&&!/\n/.test(b)&&(b=M)}return{file:u||"",namespace:l||"",line:m||0,column:s||0,length:d||0,lineText:b||"",suggestion:w||""}}function ne(e,t,n,i,u){let l=[],m=0;for(let s of e){let d={},b=r(s,d,"id",y),w=r(s,d,"pluginName",y),M=r(s,d,"text",y),L=r(s,d,"location",Ce),B=r(s,d,"notes",W),q=r(s,d,"detail",me),G=`in element ${m} of "${t}"`;K(s,d,G);let U=[];if(B)for(let z of B){let _={},v=r(z,_,"text",y),g=r(z,_,"location",Ce);K(z,_,G),U.push({text:v||"",location:Ae(g,G,u)})}l.push({id:b||"",pluginName:w||i,text:M||"",location:Ae(L,G,u),notes:U,detail:n?n.store(q):-1}),m++}return l}function ge(e,t){let n=[];for(let i of e){if(typeof i!="string")throw new Error(`${J(t)} must be an array of strings`);n.push(i)}return n}function tt({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 rt="0.21.3",it=e=>ce().build(e),lt=e=>ce().context(e),st=(e,t)=>ce().transform(e,t),ot=(e,t)=>ce().formatMessages(e,t),at=(e,t)=>ce().analyzeMetafile(e,t),ut=()=>{throw new Error('The "buildSync" API only works in node')},ft=()=>{throw new Error('The "transformSync" API only works in node')},ct=()=>{throw new Error('The "formatMessagesSync" API only works in node')},dt=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},pt=()=>(be&&be(),Promise.resolve()),se,be,we,ce=()=>{if(we)return we;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')},gt=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(se)throw new Error('Cannot call "initialize" more than once');return se=mt(t||"",n,i),se.catch(()=>{se=void 0}),se},mt=async(e,t,n)=>{let i;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.21.3"],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}:${d}:${b}: ERROR: ${w}${l.text}`}).join("");let u=new Error(e);for(let[l,m]of[["errors",t],["warnings",n]])Object.defineProperty(u,l,{configurable:!0,enumerable:!0,get:()=>m,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),m=r(e,i,"line",le),s=r(e,i,"column",le),d=r(e,i,"length",le),b=r(e,i,"lineText",y),w=r(e,i,"suggestion",y);if(V(e,i,t),b){let M=b.slice(0,(s&&s>0?s:0)+(d&&d>0?d:0)+(n&&n>0?n:80));!/[\x7F-\uFFFF]/.test(M)&&!/\n/.test(b)&&(b=M)}return{file:u||"",namespace:l||"",line:m||0,column:s||0,length:d||0,lineText:b||"",suggestion:w||""}}function ne(e,t,n,i,u){let l=[],m=0;for(let s of e){let d={},b=r(s,d,"id",y),w=r(s,d,"pluginName",y),M=r(s,d,"text",y),L=r(s,d,"location",Ce),D=r(s,d,"notes",z),q=r(s,d,"detail",me),G=`in element ${m} of "${t}"`;V(s,d,G);let U=[];if(D)for(let K of D){let Y={},v=r(K,Y,"text",y),g=r(K,Y,"location",Ce);V(K,Y,G),U.push({text:v||"",location:Ae(g,G,u)})}l.push({id:b||"",pluginName:w||i,text:M||"",location:Ae(L,G,u),notes:U,detail:n?n.store(q):-1}),m++}return l}function ge(e,t){let n=[];for(let i of e){if(typeof i!="string")throw new Error(`${_(t)} must be an array of strings`);n.push(i)}return n}function tt(e,t){let n=Object.create(null);for(let i in e){let u=e[i];if(typeof u!="string")throw new Error(`key ${_(i)} in object ${_(t)} must be a string`);n[i]=u}return n}function nt({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 it="0.21.4",lt=e=>fe().build(e),st=e=>fe().context(e),ot=(e,t)=>fe().transform(e,t),at=(e,t)=>fe().formatMessages(e,t),ut=(e,t)=>fe().analyzeMetafile(e,t),ct=()=>{throw new Error('The "buildSync" API only works in node')},ft=()=>{throw new Error('The "transformSync" API only works in node')},dt=()=>{throw new Error('The "formatMessagesSync" API only works in node')},pt=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},gt=()=>(be&&be(),Promise.resolve()),se,be,we,fe=()=>{if(we)return we;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')},mt=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(se)throw new Error('Cannot call "initialize" more than once');return se=yt(t||"",n,i),se.catch(()=>{se=void 0}),se},yt=async(e,t,n)=>{let i;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.21.4"],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.21.
|
|
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.21.4"],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);})(M=>i.onmessage({data:M})),w;i={onmessage:null,postMessage:M=>setTimeout(()=>w=b({data:M})),terminate(){if(w)for(let M of w._scheduledTimeouts.values())clearTimeout(M)}}}let u,l,m=new Promise((b,w)=>{u=b,l=w});i.onmessage=({data:b})=>{i.onmessage=({data:w})=>s(w),b?l(b):u()},i.postMessage(t||new URL(e,location.href).toString());let{readFromStdout:s,service:d}=je({writeToStdin(b){i.postMessage(b)},isSync:!1,hasFS:!1,esbuild:ve});await m,be=()=>{i.terminate(),se=void 0,be=void 0,we=void 0},we={build:b=>new Promise((w,M)=>d.buildOrContext({callName:"build",refs:null,options:b,isTTY:!1,defaultWD:"/",callback:(L,D)=>L?M(L):w(D)})),context:b=>new Promise((w,M)=>d.buildOrContext({callName:"context",refs:null,options:b,isTTY:!1,defaultWD:"/",callback:(L,D)=>L?M(L):w(D)})),transform:(b,w)=>new Promise((M,L)=>d.transform({callName:"transform",refs:null,input:b,options:w||{},isTTY:!1,fs:{readFile(D,q){q(new Error("Internal error"),null)},writeFile(D,q){q(null)}},callback:(D,q)=>D?L(D):M(q)})),formatMessages:(b,w)=>new Promise((M,L)=>d.formatMessages({callName:"formatMessages",refs:null,messages:b,options:w,callback:(D,q)=>D?L(D):M(q)})),analyzeMetafile:(b,w)=>new Promise((M,L)=>d.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof b=="string"?b:JSON.stringify(b),options:w,callback:(D,q)=>D?L(D):M(q)}))}},ht=ve;export{ut as analyzeMetafile,pt as analyzeMetafileSync,lt as build,ct as buildSync,st as context,ht as default,at as formatMessages,dt as formatMessagesSync,mt as initialize,gt as stop,ot as transform,ft as transformSync,it as version};
|
package/lib/browser.d.ts
CHANGED
|
@@ -340,6 +340,7 @@ export interface ResolveOptions {
|
|
|
340
340
|
resolveDir?: string
|
|
341
341
|
kind?: ImportKind
|
|
342
342
|
pluginData?: any
|
|
343
|
+
with?: Record<string, string>
|
|
343
344
|
}
|
|
344
345
|
|
|
345
346
|
/** Documentation: https://esbuild.github.io/plugins/#resolve-results */
|
|
@@ -379,6 +380,7 @@ export interface OnResolveArgs {
|
|
|
379
380
|
resolveDir: string
|
|
380
381
|
kind: ImportKind
|
|
381
382
|
pluginData: any
|
|
383
|
+
with: Record<string, string>
|
|
382
384
|
}
|
|
383
385
|
|
|
384
386
|
export type ImportKind =
|
package/lib/browser.js
CHANGED
|
@@ -673,8 +673,8 @@ function createChannel(streamIn) {
|
|
|
673
673
|
if (isFirstPacket) {
|
|
674
674
|
isFirstPacket = false;
|
|
675
675
|
let binaryVersion = String.fromCharCode(...bytes);
|
|
676
|
-
if (binaryVersion !== "0.21.
|
|
677
|
-
throw new Error(`Cannot start service: Host version "${"0.21.
|
|
676
|
+
if (binaryVersion !== "0.21.4") {
|
|
677
|
+
throw new Error(`Cannot start service: Host version "${"0.21.4"}" does not match binary version ${quote(binaryVersion)}`);
|
|
678
678
|
}
|
|
679
679
|
return;
|
|
680
680
|
}
|
|
@@ -1126,6 +1126,7 @@ var handlePlugins = (buildKey, sendRequest, sendResponse, refs, streamIn, reques
|
|
|
1126
1126
|
let resolveDir = getFlag(options, keys2, "resolveDir", mustBeString);
|
|
1127
1127
|
let kind = getFlag(options, keys2, "kind", mustBeString);
|
|
1128
1128
|
let pluginData = getFlag(options, keys2, "pluginData", canBeAnything);
|
|
1129
|
+
let importAttributes = getFlag(options, keys2, "with", mustBeObject);
|
|
1129
1130
|
checkForInvalidFlags(options, keys2, "in resolve() call");
|
|
1130
1131
|
return new Promise((resolve2, reject) => {
|
|
1131
1132
|
const request = {
|
|
@@ -1141,6 +1142,7 @@ var handlePlugins = (buildKey, sendRequest, sendResponse, refs, streamIn, reques
|
|
|
1141
1142
|
if (kind != null) request.kind = kind;
|
|
1142
1143
|
else throw new Error(`Must specify "kind" when calling "resolve"`);
|
|
1143
1144
|
if (pluginData != null) request.pluginData = details.store(pluginData);
|
|
1145
|
+
if (importAttributes != null) request.with = sanitizeStringMap(importAttributes, "with");
|
|
1144
1146
|
sendRequest(refs, request, (error, response) => {
|
|
1145
1147
|
if (error !== null) reject(new Error(error));
|
|
1146
1148
|
else resolve2({
|
|
@@ -1237,7 +1239,8 @@ var handlePlugins = (buildKey, sendRequest, sendResponse, refs, streamIn, reques
|
|
|
1237
1239
|
namespace: request.namespace,
|
|
1238
1240
|
resolveDir: request.resolveDir,
|
|
1239
1241
|
kind: request.kind,
|
|
1240
|
-
pluginData: details.load(request.pluginData)
|
|
1242
|
+
pluginData: details.load(request.pluginData),
|
|
1243
|
+
with: request.with
|
|
1241
1244
|
});
|
|
1242
1245
|
if (result != null) {
|
|
1243
1246
|
if (typeof result !== "object") throw new Error(`Expected onResolve() callback in plugin ${quote(name)} to return an object`);
|
|
@@ -1574,6 +1577,15 @@ function sanitizeStringArray(values, property) {
|
|
|
1574
1577
|
}
|
|
1575
1578
|
return result;
|
|
1576
1579
|
}
|
|
1580
|
+
function sanitizeStringMap(map, property) {
|
|
1581
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
1582
|
+
for (const key in map) {
|
|
1583
|
+
const value = map[key];
|
|
1584
|
+
if (typeof value !== "string") throw new Error(`key ${quote(key)} in object ${quote(property)} must be a string`);
|
|
1585
|
+
result[key] = value;
|
|
1586
|
+
}
|
|
1587
|
+
return result;
|
|
1588
|
+
}
|
|
1577
1589
|
function convertOutputFiles({ path, contents, hash }) {
|
|
1578
1590
|
let text = null;
|
|
1579
1591
|
return {
|
|
@@ -1592,7 +1604,7 @@ function convertOutputFiles({ path, contents, hash }) {
|
|
|
1592
1604
|
}
|
|
1593
1605
|
|
|
1594
1606
|
// lib/npm/browser.ts
|
|
1595
|
-
var version = "0.21.
|
|
1607
|
+
var version = "0.21.4";
|
|
1596
1608
|
var build = (options) => ensureServiceIsRunning().build(options);
|
|
1597
1609
|
var context = (options) => ensureServiceIsRunning().context(options);
|
|
1598
1610
|
var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
|
|
@@ -1638,7 +1650,7 @@ var initialize = (options) => {
|
|
|
1638
1650
|
var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, null, function* () {
|
|
1639
1651
|
let worker;
|
|
1640
1652
|
if (useWorker) {
|
|
1641
|
-
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.21.3"}`];\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" });
|
|
1653
|
+
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.21.4"}`];\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" });
|
|
1642
1654
|
worker = new Worker(URL.createObjectURL(blob));
|
|
1643
1655
|
} else {
|
|
1644
1656
|
let onmessage = ((postMessage) => {
|
|
@@ -2278,7 +2290,7 @@ var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, nu
|
|
|
2278
2290
|
callback(null, count);
|
|
2279
2291
|
};
|
|
2280
2292
|
let go = new globalThis.Go();
|
|
2281
|
-
go.argv = ["", `--service=${"0.21.
|
|
2293
|
+
go.argv = ["", `--service=${"0.21.4"}`];
|
|
2282
2294
|
tryToInstantiateModule(wasm, go).then(
|
|
2283
2295
|
(instance) => {
|
|
2284
2296
|
postMessage(null);
|
package/lib/browser.min.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
(module=>{
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var xe=Object.defineProperty;var _e=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Je=(e,t)=>{for(var n in t)xe(e,n,{get:t[n],enumerable:!0})},Ge=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ve(t))!Ye.call(e,a)&&a!==n&&xe(e,a,{get:()=>t[a],enumerable:!(i=_e(t,a))||i.enumerable});return e};var Qe=e=>Ge(xe({},"__esModule",{value:!0}),e);var ne=(e,t,n)=>new Promise((i,a)=>{var l=f=>{try{s(n.next(f))}catch(h){a(h)}},g=f=>{try{s(n.throw(f))}catch(h){a(h)}},s=f=>f.done?i(f.value):Promise.resolve(f.value).then(l,g);s((n=n.apply(e,t)).next())});var Re={};Je(Re,{analyzeMetafile:()=>mt,analyzeMetafileSync:()=>wt,build:()=>ft,buildSync:()=>yt,context:()=>dt,default:()=>Ot,formatMessages:()=>gt,formatMessagesSync:()=>bt,initialize:()=>Rt,stop:()=>vt,transform:()=>pt,transformSync:()=>ht,version:()=>ct});module.exports=Qe(Re);function Se(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),Ee(n.buf,n.len-4,0),n.buf.subarray(0,n.len)}function $e(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 g=n.read32(),s=[];for(let f=0;f<g;f++)s.push(t());return s}case 6:{let g=n.read32(),s={};for(let f=0;f<g;f++)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);Ee(this.buf,t,n)}write(t){let n=this._write(4+t.length);Ee(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 ke(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,Oe;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;Z=n=>e.encode(n),ie=n=>t.decode(n),Oe='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()},Oe='Buffer.from("")';else throw new Error("No UTF-8 codec found");if(!(Z("")instanceof Uint8Array))throw new Error(`Invariant violation: "${Oe} 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 J=JSON.stringify,Me="warning",Ce="silent";function Ae(e){if(Y(e,"target"),e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var ye=()=>null,I=e=>typeof e=="boolean"?null:"a boolean",y=e=>typeof e=="string"?null:"a string",he=e=>e instanceof RegExp?null:"a RegExp object",se=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Pe=e=>typeof e=="function"?null:"a function",W=e=>Array.isArray(e)?null:"an array",ee=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",Xe=e=>typeof e=="object"&&e!==null?null:"an array or an object",Ze=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",et=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",tt=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",nt=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(`${J(n)} must be ${l}`);return u}function K(e,t,n){for(let i in e)if(!(i in t))throw new Error(`Invalid option ${n}: ${J(i)}`)}function Ue(e){let t=Object.create(null),n=r(e,t,"wasmURL",nt),i=r(e,t,"wasmModule",Ze),u=r(e,t,"worker",I);return K(e,t,"in initialize() call"),{wasmURL:n,wasmModule:i,worker:u}}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 ${J(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",I),g=r(t,n,"logLevel",y),s=r(t,n,"logLimit",se);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 Y(e,t,n){if(typeof e!="string")throw new Error(`Expected value for ${t}${n!==void 0?" "+J(n):""} to be a string, got ${typeof e} instead`);return e}function Le(e,t,n){let i=r(t,n,"legalComments",y),u=r(t,n,"sourceRoot",y),l=r(t,n,"sourcesContent",I),g=r(t,n,"target",tt),s=r(t,n,"format",y),c=r(t,n,"globalName",y),h=r(t,n,"mangleProps",he),w=r(t,n,"reserveProps",he),M=r(t,n,"mangleQuoted",I),L=r(t,n,"minify",I),B=r(t,n,"minifySyntax",I),q=r(t,n,"minifyWhitespace",I),G=r(t,n,"minifyIdentifiers",I),U=r(t,n,"lineLimit",se),z=r(t,n,"drop",W),_=r(t,n,"dropLabels",W),v=r(t,n,"charset",y),m=r(t,n,"treeShaking",I),d=r(t,n,"ignoreAnnotations",I),o=r(t,n,"jsx",y),x=r(t,n,"jsxFactory",y),E=r(t,n,"jsxFragment",y),C=r(t,n,"jsxImportSource",y),P=r(t,n,"jsxDev",I),a=r(t,n,"jsxSideEffects",I),f=r(t,n,"define",ee),b=r(t,n,"logOverride",ee),S=r(t,n,"supported",ee),F=r(t,n,"pure",W),k=r(t,n,"keepNames",I),O=r(t,n,"platform",y),A=r(t,n,"tsconfigRaw",et);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(Ae).join(",")}`):e.push(`--target=${Ae(g)}`)),s&&e.push(`--format=${s}`),c&&e.push(`--global-name=${c}`),O&&e.push(`--platform=${O}`),A&&e.push(`--tsconfig-raw=${typeof A=="string"?A:JSON.stringify(A)}`),L&&e.push("--minify"),B&&e.push("--minify-syntax"),q&&e.push("--minify-whitespace"),G&&e.push("--minify-identifiers"),U&&e.push(`--line-limit=${U}`),v&&e.push(`--charset=${v}`),m!==void 0&&e.push(`--tree-shaking=${m}`),d&&e.push("--ignore-annotations"),z)for(let R of z)e.push(`--drop:${Y(R,"drop")}`);if(_&&e.push(`--drop-labels=${Array.from(_).map(R=>Y(R,"dropLabels")).join(",")}`),h&&e.push(`--mangle-props=${h.source}`),w&&e.push(`--reserve-props=${w.source}`),M!==void 0&&e.push(`--mangle-quoted=${M}`),o&&e.push(`--jsx=${o}`),x&&e.push(`--jsx-factory=${x}`),E&&e.push(`--jsx-fragment=${E}`),C&&e.push(`--jsx-import-source=${C}`),P&&e.push("--jsx-dev"),a&&e.push("--jsx-side-effects"),f)for(let R in f){if(R.indexOf("=")>=0)throw new Error(`Invalid define: ${R}`);e.push(`--define:${R}=${Y(f[R],"define",R)}`)}if(b)for(let R in b){if(R.indexOf("=")>=0)throw new Error(`Invalid log override: ${R}`);e.push(`--log-override:${R}=${Y(b[R],"log override",R)}`)}if(S)for(let R in S){if(R.indexOf("=")>=0)throw new Error(`Invalid supported: ${R}`);let $=S[R];if(typeof $!="boolean")throw new Error(`Expected value for supported ${J(R)} to be a boolean, got ${typeof $} instead`);e.push(`--supported:${R}=${$}`)}if(F)for(let R of F)e.push(`--pure:${Y(R,"pure")}`);k&&e.push("--keep-names")}function rt(e,t,n,i,u){var ae;let l=[],g=[],s=Object.create(null),c=null,h=null;be(l,t,s,n,i),Le(l,t,s);let w=r(t,s,"sourcemap",De),M=r(t,s,"bundle",I),L=r(t,s,"splitting",I),B=r(t,s,"preserveSymlinks",I),q=r(t,s,"metafile",I),G=r(t,s,"outfile",y),U=r(t,s,"outdir",y),z=r(t,s,"outbase",y),_=r(t,s,"tsconfig",y),v=r(t,s,"resolveExtensions",W),m=r(t,s,"nodePaths",W),d=r(t,s,"mainFields",W),o=r(t,s,"conditions",W),x=r(t,s,"external",W),E=r(t,s,"packages",y),C=r(t,s,"alias",ee),P=r(t,s,"loader",ee),a=r(t,s,"outExtension",ee),f=r(t,s,"publicPath",y),b=r(t,s,"entryNames",y),S=r(t,s,"chunkNames",y),F=r(t,s,"assetNames",y),k=r(t,s,"inject",W),O=r(t,s,"banner",ee),A=r(t,s,"footer",ee),R=r(t,s,"entryPoints",Xe),$=r(t,s,"absWorkingDir",y),D=r(t,s,"stdin",ee),T=(ae=r(t,s,"write",I))!=null?ae:u,j=r(t,s,"allowOverwrite",I),V=r(t,s,"mangleCache",ee);if(s.plugins=!0,K(t,s,`in ${e}() call`),w&&l.push(`--sourcemap${w===!0?"":`=${w}`}`),M&&l.push("--bundle"),j&&l.push("--allow-overwrite"),L&&l.push("--splitting"),B&&l.push("--preserve-symlinks"),q&&l.push("--metafile"),G&&l.push(`--outfile=${G}`),U&&l.push(`--outdir=${U}`),z&&l.push(`--outbase=${z}`),_&&l.push(`--tsconfig=${_}`),E&&l.push(`--packages=${E}`),v){let p=[];for(let N of v){if(Y(N,"resolve extension"),N.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${N}`);p.push(N)}l.push(`--resolve-extensions=${p.join(",")}`)}if(f&&l.push(`--public-path=${f}`),b&&l.push(`--entry-names=${b}`),S&&l.push(`--chunk-names=${S}`),F&&l.push(`--asset-names=${F}`),d){let p=[];for(let N of d){if(Y(N,"main field"),N.indexOf(",")>=0)throw new Error(`Invalid main field: ${N}`);p.push(N)}l.push(`--main-fields=${p.join(",")}`)}if(o){let p=[];for(let N of o){if(Y(N,"condition"),N.indexOf(",")>=0)throw new Error(`Invalid condition: ${N}`);p.push(N)}l.push(`--conditions=${p.join(",")}`)}if(x)for(let p of x)l.push(`--external:${Y(p,"external")}`);if(C)for(let p in C){if(p.indexOf("=")>=0)throw new Error(`Invalid package name in alias: ${p}`);l.push(`--alias:${p}=${Y(C[p],"alias",p)}`)}if(O)for(let p in O){if(p.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${p}`);l.push(`--banner:${p}=${Y(O[p],"banner",p)}`)}if(A)for(let p in A){if(p.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${p}`);l.push(`--footer:${p}=${Y(A[p],"footer",p)}`)}if(k)for(let p of k)l.push(`--inject:${Y(p,"inject")}`);if(P)for(let p in P){if(p.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${p}`);l.push(`--loader:${p}=${Y(P[p],"loader",p)}`)}if(a)for(let p in a){if(p.indexOf("=")>=0)throw new Error(`Invalid out extension: ${p}`);l.push(`--out-extension:${p}=${Y(a[p],"out extension",p)}`)}if(R)if(Array.isArray(R))for(let p=0,N=R.length;p<N;p++){let X=R[p];if(typeof X=="object"&&X!==null){let te=Object.create(null),H=r(X,te,"in",y),fe=r(X,te,"out",y);if(K(X,te,"in entry point at index "+p),H===void 0)throw new Error('Missing property "in" for entry point at index '+p);if(fe===void 0)throw new Error('Missing property "out" for entry point at index '+p);g.push([fe,H])}else g.push(["",Y(X,"entry point at index "+p)])}else for(let p in R)g.push([p,Y(R[p],"entry point",p)]);if(D){let p=Object.create(null),N=r(D,p,"contents",Be),X=r(D,p,"resolveDir",y),te=r(D,p,"sourcefile",y),H=r(D,p,"loader",y);K(D,p,'in "stdin" object'),te&&l.push(`--sourcefile=${te}`),H&&l.push(`--loader=${H}`),X&&(h=X),typeof N=="string"?c=Z(N):N instanceof Uint8Array&&(c=N)}let Q=[];if(m)for(let p of m)p+="",Q.push(p);return{entries:g,flags:l,write:T,stdinContents:c,stdinResolveDir:h,absWorkingDir:$,nodePaths:Q,mangleCache:je(V)}}function it(e,t,n,i){let u=[],l=Object.create(null);be(u,t,l,n,i),Le(u,t,l);let g=r(t,l,"sourcemap",De),s=r(t,l,"sourcefile",y),c=r(t,l,"loader",y),h=r(t,l,"banner",y),w=r(t,l,"footer",y),M=r(t,l,"mangleCache",ee);return K(t,l,`in ${e}() call`),g&&u.push(`--sourcemap=${g===!0?"external":g}`),s&&u.push(`--sourcefile=${s}`),c&&u.push(`--loader=${c}`),h&&u.push(`--banner=${h}`),w&&u.push(`--footer=${w}`),{flags:u,mangleCache:je(M)}}function qe(e){let t={},n={didClose:!1,reason:""},i={},u=0,l=0,g=new Uint8Array(16*1024),s=0,c=v=>{let m=s+v.length;if(m>g.length){let o=new Uint8Array(m*2);o.set(g),g=o}g.set(v,s),s+=v.length;let d=0;for(;d+4<=s;){let o=ke(g,d);if(d+4+o>s)break;d+=4,q(g.subarray(d,d+o)),d+=o}d>0&&(g.copyWithin(0,d,s),s-=d)},h=v=>{n.didClose=!0,v&&(n.reason=": "+(v.message||v));let m="The service was stopped"+n.reason;for(let d in i)i[d](m,null);i={}},w=(v,m,d)=>{if(n.didClose)return d("The service is no longer running"+n.reason,null);let o=u++;i[o]=(x,E)=>{try{d(x,E)}finally{v&&v.unref()}},v&&v.ref(),e.writeToStdin(Se({id:o,isRequest:!0,value:m}))},M=(v,m)=>{if(n.didClose)throw new Error("The service is no longer running"+n.reason);e.writeToStdin(Se({id:v,isRequest:!1,value:m}))},L=(v,m)=>ne(this,null,function*(){try{if(m.command==="ping"){M(v,{});return}if(typeof m.key=="number"){let d=t[m.key];if(!d)return;let o=d[m.command];if(o){yield o(v,m);return}}throw new Error("Invalid command: "+m.command)}catch(d){let o=[le(d,e,null,void 0,"")];try{M(v,{errors:o})}catch(x){}}}),B=!0,q=v=>{if(B){B=!1;let d=String.fromCharCode(...v);if(d!=="0.21.3")throw new Error(`Cannot start service: Host version "0.21.3" does not match binary version ${J(d)}`);return}let m=$e(v);if(m.isRequest)L(m.id,m.value);else{let d=i[m.id];delete i[m.id],m.value.error?d(m.value.error,{}):d(null,m.value)}};return{readFromStdout:c,afterClose:h,service:{buildOrContext:({callName:v,refs:m,options:d,isTTY:o,defaultWD:x,callback:E})=>{let C=0,P=l++,a={},f={ref(){++C===1&&m&&m.ref()},unref(){--C===0&&(delete t[P],m&&m.unref())}};t[P]=a,f.ref(),lt(v,P,w,M,f,e,a,d,o,x,(b,S)=>{try{E(b,S)}finally{f.unref()}})},transform:({callName:v,refs:m,input:d,options:o,isTTY:x,fs:E,callback:C})=>{let P=Ne(),a=f=>{try{if(typeof d!="string"&&!(d instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:b,mangleCache:S}=it(v,o,x,Ce),F={command:"transform",flags:b,inputFS:f!==null,input:f!==null?Z(f):typeof d=="string"?Z(d):d};S&&(F.mangleCache=S),w(m,F,(k,O)=>{if(k)return C(new Error(k),null);let A=ue(O.errors,P),R=ue(O.warnings,P),$=1,D=()=>{if(--$===0){let T={warnings:R,code:O.code,map:O.map,mangleCache:void 0,legalComments:void 0};"legalComments"in O&&(T.legalComments=O==null?void 0:O.legalComments),O.mangleCache&&(T.mangleCache=O==null?void 0:O.mangleCache),C(null,T)}};if(A.length>0)return C(ce("Transform failed",A,R),null);O.codeFS&&($++,E.readFile(O.code,(T,j)=>{T!==null?C(T,null):(O.code=j,D())})),O.mapFS&&($++,E.readFile(O.map,(T,j)=>{T!==null?C(T,null):(O.map=j,D())})),D()})}catch(b){let S=[];try{be(S,o,{},x,Ce)}catch(k){}let F=le(b,e,P,void 0,"");w(m,{command:"error",flags:S,error:F},()=>{F.detail=P.load(F.detail),C(ce("Transform failed",[F],[]),null)})}};if((typeof d=="string"||d instanceof Uint8Array)&&d.length>1024*1024){let f=a;a=()=>E.writeFile(d,f)}a(null)},formatMessages:({callName:v,refs:m,messages:d,options:o,callback:x})=>{if(!o)throw new Error(`Missing second argument in ${v}() call`);let E={},C=r(o,E,"kind",y),P=r(o,E,"color",I),a=r(o,E,"terminalWidth",se);if(K(o,E,`in ${v}() call`),C===void 0)throw new Error(`Missing "kind" in ${v}() call`);if(C!=="error"&&C!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${v}() call`);let f={command:"format-msgs",messages:re(d,"messages",null,"",a),isWarning:C==="warning"};P!==void 0&&(f.color=P),a!==void 0&&(f.terminalWidth=a),w(m,f,(b,S)=>{if(b)return x(new Error(b),null);x(null,S.messages)})},analyzeMetafile:({callName:v,refs:m,metafile:d,options:o,callback:x})=>{o===void 0&&(o={});let E={},C=r(o,E,"color",I),P=r(o,E,"verbose",I);K(o,E,`in ${v}() call`);let a={command:"analyze-metafile",metafile:d};C!==void 0&&(a.color=C),P!==void 0&&(a.verbose=P),w(m,a,(f,b)=>{if(f)return x(new Error(f),null);x(null,b.result)})}}}}function lt(e,t,n,i,u,l,g,s,c,h,w){let M=Ne(),L=e==="context",B=(U,z)=>{let _=[];try{be(_,s,{},c,Me)}catch(m){}let v=le(U,l,M,void 0,z);n(u,{command:"error",flags:_,error:v},()=>{v.detail=M.load(v.detail),w(ce(L?"Context failed":"Build failed",[v],[]),null)})},q;if(typeof s=="object"){let U=s.plugins;if(U!==void 0){if(!Array.isArray(U))return B(new Error('"plugins" must be an array'),"");q=U}}if(q&&q.length>0){if(l.isSync)return B(new Error("Cannot use plugins in synchronous API calls"),"");st(t,n,i,u,l,g,s,q,M).then(U=>{if(!U.ok)return B(U.error,U.pluginName);try{G(U.requestPlugins,U.runOnEndCallbacks,U.scheduleOnDisposeCallbacks)}catch(z){B(z,"")}},U=>B(U,""));return}try{G(null,(U,z)=>z([],[]),()=>{})}catch(U){B(U,"")}function G(U,z,_){let v=l.hasFS,{entries:m,flags:d,write:o,stdinContents:x,stdinResolveDir:E,absWorkingDir:C,nodePaths:P,mangleCache:a}=rt(e,s,c,Me,v);if(o&&!l.hasFS)throw new Error('The "write" option is unavailable in this environment');let f={command:"build",key:t,entries:m,flags:d,write:o,stdinContents:x,stdinResolveDir:E,absWorkingDir:C||h,nodePaths:P,context:L};U&&(f.plugins=U),a&&(f.mangleCache=a);let b=(k,O)=>{let A={errors:ue(k.errors,M),warnings:ue(k.warnings,M),outputFiles:void 0,metafile:void 0,mangleCache:void 0},R=A.errors.slice(),$=A.warnings.slice();k.outputFiles&&(A.outputFiles=k.outputFiles.map(ot)),k.metafile&&(A.metafile=JSON.parse(k.metafile)),k.mangleCache&&(A.mangleCache=k.mangleCache),k.writeToStdout!==void 0&&console.log(ie(k.writeToStdout).replace(/\n$/,"")),z(A,(D,T)=>{if(R.length>0||D.length>0){let j=ce("Build failed",R.concat(D),$.concat(T));return O(j,null,D,T)}O(null,A,D,T)})},S,F;L&&(g["on-end"]=(k,O)=>new Promise(A=>{b(O,(R,$,D,T)=>{let j={errors:D,warnings:T};F&&F(R,$),S=void 0,F=void 0,i(k,j),A()})})),n(u,f,(k,O)=>{if(k)return w(new Error(k),null);if(!L)return b(O,($,D)=>(_(),w($,D)));if(O.errors.length>0)return w(ce("Context failed",O.errors,O.warnings),null);let A=!1,R={rebuild:()=>(S||(S=new Promise(($,D)=>{let T;F=(V,Q)=>{T||(T=()=>V?D(V):$(Q))};let j=()=>{n(u,{command:"rebuild",key:t},(Q,ae)=>{Q?D(new Error(Q)):T?T():j()})};j()})),S),watch:($={})=>new Promise((D,T)=>{if(!l.hasFS)throw new Error('Cannot use the "watch" API in this environment');K($,{},"in watch() call"),n(u,{command:"watch",key:t},Q=>{Q?T(new Error(Q)):D(void 0)})}),serve:($={})=>new Promise((D,T)=>{if(!l.hasFS)throw new Error('Cannot use the "serve" API in this environment');let j={},V=r($,j,"port",se),Q=r($,j,"host",y),ae=r($,j,"servedir",y),p=r($,j,"keyfile",y),N=r($,j,"certfile",y),X=r($,j,"fallback",y),te=r($,j,"onRequest",Pe);K($,j,"in serve() call");let H={command:"serve",key:t,onRequest:!!te};V!==void 0&&(H.port=V),Q!==void 0&&(H.host=Q),ae!==void 0&&(H.servedir=ae),p!==void 0&&(H.keyfile=p),N!==void 0&&(H.certfile=N),X!==void 0&&(H.fallback=X),n(u,H,(fe,We)=>{if(fe)return T(new Error(fe));te&&(g["serve-request"]=(ze,Ke)=>{te(Ke.args),i(ze,{})}),D(We)})}),cancel:()=>new Promise($=>{if(A)return $();n(u,{command:"cancel",key:t},()=>{$()})}),dispose:()=>new Promise($=>{if(A)return $();A=!0,n(u,{command:"dispose",key:t},()=>{$(),_(),u.unref()})})};u.ref(),w(null,R)})}}var st=(e,t,n,i,u,l,g,s,c)=>ne(void 0,null,function*(){let h=[],w=[],M={},L={},B=[],q=0,G=0,U=[],z=!1;s=[...s];for(let m of s){let d={};if(typeof m!="object")throw new Error(`Plugin at index ${G} must be an object`);let o=r(m,d,"name",y);if(typeof o!="string"||o==="")throw new Error(`Plugin at index ${G} is missing a name`);try{let x=r(m,d,"setup",Pe);if(typeof x!="function")throw new Error("Plugin is missing a setup function");K(m,d,`on plugin ${J(o)}`);let E={name:o,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};G++;let P=x({initialOptions:g,resolve:(a,f={})=>{if(!z)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof a!="string")throw new Error("The path to resolve must be a string");let b=Object.create(null),S=r(f,b,"pluginName",y),F=r(f,b,"importer",y),k=r(f,b,"namespace",y),O=r(f,b,"resolveDir",y),A=r(f,b,"kind",y),R=r(f,b,"pluginData",ye);return K(f,b,"in resolve() call"),new Promise(($,D)=>{let T={command:"resolve",path:a,key:e,pluginName:o};if(S!=null&&(T.pluginName=S),F!=null&&(T.importer=F),k!=null&&(T.namespace=k),O!=null&&(T.resolveDir=O),A!=null)T.kind=A;else throw new Error('Must specify "kind" when calling "resolve"');R!=null&&(T.pluginData=c.store(R)),t(i,T,(j,V)=>{j!==null?D(new Error(j)):$({errors:ue(V.errors,c),warnings:ue(V.warnings,c),path:V.path,external:V.external,sideEffects:V.sideEffects,namespace:V.namespace,suffix:V.suffix,pluginData:c.load(V.pluginData)})})})},onStart(a){let f='This error came from the "onStart" callback registered here:',b=ge(new Error(f),u,"onStart");h.push({name:o,callback:a,note:b}),E.onStart=!0},onEnd(a){let f='This error came from the "onEnd" callback registered here:',b=ge(new Error(f),u,"onEnd");w.push({name:o,callback:a,note:b}),E.onEnd=!0},onResolve(a,f){let b='This error came from the "onResolve" callback registered here:',S=ge(new Error(b),u,"onResolve"),F={},k=r(a,F,"filter",he),O=r(a,F,"namespace",y);if(K(a,F,`in onResolve() call for plugin ${J(o)}`),k==null)throw new Error("onResolve() call is missing a filter");let A=q++;M[A]={name:o,callback:f,note:S},E.onResolve.push({id:A,filter:k.source,namespace:O||""})},onLoad(a,f){let b='This error came from the "onLoad" callback registered here:',S=ge(new Error(b),u,"onLoad"),F={},k=r(a,F,"filter",he),O=r(a,F,"namespace",y);if(K(a,F,`in onLoad() call for plugin ${J(o)}`),k==null)throw new Error("onLoad() call is missing a filter");let A=q++;L[A]={name:o,callback:f,note:S},E.onLoad.push({id:A,filter:k.source,namespace:O||""})},onDispose(a){B.push(a)},esbuild:u.esbuild});P&&(yield P),U.push(E)}catch(x){return{ok:!1,error:x,pluginName:o}}}l["on-start"]=(m,d)=>ne(void 0,null,function*(){let o={errors:[],warnings:[]};yield Promise.all(h.map(P=>ne(void 0,[P],function*({name:x,callback:E,note:C}){try{let a=yield E();if(a!=null){if(typeof a!="object")throw new Error(`Expected onStart() callback in plugin ${J(x)} to return an object`);let f={},b=r(a,f,"errors",W),S=r(a,f,"warnings",W);K(a,f,`from onStart() callback in plugin ${J(x)}`),b!=null&&o.errors.push(...re(b,"errors",c,x,void 0)),S!=null&&o.warnings.push(...re(S,"warnings",c,x,void 0))}}catch(a){o.errors.push(le(a,u,c,C&&C(),x))}}))),n(m,o)}),l["on-resolve"]=(m,d)=>ne(void 0,null,function*(){let o={},x="",E,C;for(let P of d.ids)try{({name:x,callback:E,note:C}=M[P]);let a=yield E({path:d.path,importer:d.importer,namespace:d.namespace,resolveDir:d.resolveDir,kind:d.kind,pluginData:c.load(d.pluginData)});if(a!=null){if(typeof a!="object")throw new Error(`Expected onResolve() callback in plugin ${J(x)} to return an object`);let f={},b=r(a,f,"pluginName",y),S=r(a,f,"path",y),F=r(a,f,"namespace",y),k=r(a,f,"suffix",y),O=r(a,f,"external",I),A=r(a,f,"sideEffects",I),R=r(a,f,"pluginData",ye),$=r(a,f,"errors",W),D=r(a,f,"warnings",W),T=r(a,f,"watchFiles",W),j=r(a,f,"watchDirs",W);K(a,f,`from onResolve() callback in plugin ${J(x)}`),o.id=P,b!=null&&(o.pluginName=b),S!=null&&(o.path=S),F!=null&&(o.namespace=F),k!=null&&(o.suffix=k),O!=null&&(o.external=O),A!=null&&(o.sideEffects=A),R!=null&&(o.pluginData=c.store(R)),$!=null&&(o.errors=re($,"errors",c,x,void 0)),D!=null&&(o.warnings=re(D,"warnings",c,x,void 0)),T!=null&&(o.watchFiles=me(T,"watchFiles")),j!=null&&(o.watchDirs=me(j,"watchDirs"));break}}catch(a){o={id:P,errors:[le(a,u,c,C&&C(),x)]};break}n(m,o)}),l["on-load"]=(m,d)=>ne(void 0,null,function*(){let o={},x="",E,C;for(let P of d.ids)try{({name:x,callback:E,note:C}=L[P]);let a=yield E({path:d.path,namespace:d.namespace,suffix:d.suffix,pluginData:c.load(d.pluginData),with:d.with});if(a!=null){if(typeof a!="object")throw new Error(`Expected onLoad() callback in plugin ${J(x)} to return an object`);let f={},b=r(a,f,"pluginName",y),S=r(a,f,"contents",Be),F=r(a,f,"resolveDir",y),k=r(a,f,"pluginData",ye),O=r(a,f,"loader",y),A=r(a,f,"errors",W),R=r(a,f,"warnings",W),$=r(a,f,"watchFiles",W),D=r(a,f,"watchDirs",W);K(a,f,`from onLoad() callback in plugin ${J(x)}`),o.id=P,b!=null&&(o.pluginName=b),S instanceof Uint8Array?o.contents=S:S!=null&&(o.contents=Z(S)),F!=null&&(o.resolveDir=F),k!=null&&(o.pluginData=c.store(k)),O!=null&&(o.loader=O),A!=null&&(o.errors=re(A,"errors",c,x,void 0)),R!=null&&(o.warnings=re(R,"warnings",c,x,void 0)),$!=null&&(o.watchFiles=me($,"watchFiles")),D!=null&&(o.watchDirs=me(D,"watchDirs"));break}}catch(a){o={id:P,errors:[le(a,u,c,C&&C(),x)]};break}n(m,o)});let _=(m,d)=>d([],[]);w.length>0&&(_=(m,d)=>{ne(void 0,null,function*(){let o=[],x=[];for(let{name:E,callback:C,note:P}of w){let a,f;try{let b=yield C(m);if(b!=null){if(typeof b!="object")throw new Error(`Expected onEnd() callback in plugin ${J(E)} to return an object`);let S={},F=r(b,S,"errors",W),k=r(b,S,"warnings",W);K(b,S,`from onEnd() callback in plugin ${J(E)}`),F!=null&&(a=re(F,"errors",c,E,void 0)),k!=null&&(f=re(k,"warnings",c,E,void 0))}}catch(b){a=[le(b,u,c,P&&P(),E)]}if(a){o.push(...a);try{m.errors.push(...a)}catch(b){}}if(f){x.push(...f);try{m.warnings.push(...f)}catch(b){}}}d(o,x)})});let v=()=>{for(let m of B)setTimeout(()=>m(),0)};return z=!0,{ok:!0,requestPlugins:U,runOnEndCallbacks:_,scheduleOnDisposeCallbacks:v}});function Ne(){let e=new Map,t=0;return{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,u=!1;return()=>{if(u)return i;u=!0;try{let l=(e.stack+"").split(`
|
|
8
|
-
`);l.splice(1,1);let g=Ie(t,l,n);if(g)return i={text:e.message,location:g},i}catch(l){}}}function le(e,t,n,i,
|
|
9
|
-
`),"")}catch(s){}return{id:"",pluginName:
|
|
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 _=JSON.stringify,Me="warning",Ce="silent";function Ae(e){if(J(e,"target"),e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var ye=()=>null,I=e=>typeof e=="boolean"?null:"a boolean",y=e=>typeof e=="string"?null:"a string",he=e=>e instanceof RegExp?null:"a RegExp object",se=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Pe=e=>typeof e=="function"?null:"a function",z=e=>Array.isArray(e)?null:"an array",ee=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",Xe=e=>typeof e=="object"&&e!==null?null:"an array or an object",Ze=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",et=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",tt=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",nt=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(`${_(n)} must be ${l}`);return a}function V(e,t,n){for(let i in e)if(!(i in t))throw new Error(`Invalid option ${n}: ${_(i)}`)}function Ue(e){let t=Object.create(null),n=r(e,t,"wasmURL",nt),i=r(e,t,"wasmModule",Ze),a=r(e,t,"worker",I);return V(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 ${_(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",I),g=r(t,n,"logLevel",y),s=r(t,n,"logLimit",se);l!==void 0?e.push(`--color=${l}`):i&&e.push("--color=true"),e.push(`--log-level=${g||a}`),e.push(`--log-limit=${s||0}`)}function J(e,t,n){if(typeof e!="string")throw new Error(`Expected value for ${t}${n!==void 0?" "+_(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",I),g=r(t,n,"target",tt),s=r(t,n,"format",y),f=r(t,n,"globalName",y),h=r(t,n,"mangleProps",he),w=r(t,n,"reserveProps",he),M=r(t,n,"mangleQuoted",I),L=r(t,n,"minify",I),D=r(t,n,"minifySyntax",I),q=r(t,n,"minifyWhitespace",I),G=r(t,n,"minifyIdentifiers",I),U=r(t,n,"lineLimit",se),K=r(t,n,"drop",z),Y=r(t,n,"dropLabels",z),v=r(t,n,"charset",y),m=r(t,n,"treeShaking",I),d=r(t,n,"ignoreAnnotations",I),o=r(t,n,"jsx",y),R=r(t,n,"jsxFactory",y),E=r(t,n,"jsxFragment",y),C=r(t,n,"jsxImportSource",y),T=r(t,n,"jsxDev",I),u=r(t,n,"jsxSideEffects",I),c=r(t,n,"define",ee),b=r(t,n,"logOverride",ee),S=r(t,n,"supported",ee),F=r(t,n,"pure",z),$=r(t,n,"keepNames",I),O=r(t,n,"platform",y),A=r(t,n,"tsconfigRaw",et);if(i&&e.push(`--legal-comments=${i}`),a!==void 0&&e.push(`--source-root=${a}`),l!==void 0&&e.push(`--sources-content=${l}`),g&&(Array.isArray(g)?e.push(`--target=${Array.from(g).map(Ae).join(",")}`):e.push(`--target=${Ae(g)}`)),s&&e.push(`--format=${s}`),f&&e.push(`--global-name=${f}`),O&&e.push(`--platform=${O}`),A&&e.push(`--tsconfig-raw=${typeof A=="string"?A:JSON.stringify(A)}`),L&&e.push("--minify"),D&&e.push("--minify-syntax"),q&&e.push("--minify-whitespace"),G&&e.push("--minify-identifiers"),U&&e.push(`--line-limit=${U}`),v&&e.push(`--charset=${v}`),m!==void 0&&e.push(`--tree-shaking=${m}`),d&&e.push("--ignore-annotations"),K)for(let x of K)e.push(`--drop:${J(x,"drop")}`);if(Y&&e.push(`--drop-labels=${Array.from(Y).map(x=>J(x,"dropLabels")).join(",")}`),h&&e.push(`--mangle-props=${h.source}`),w&&e.push(`--reserve-props=${w.source}`),M!==void 0&&e.push(`--mangle-quoted=${M}`),o&&e.push(`--jsx=${o}`),R&&e.push(`--jsx-factory=${R}`),E&&e.push(`--jsx-fragment=${E}`),C&&e.push(`--jsx-import-source=${C}`),T&&e.push("--jsx-dev"),u&&e.push("--jsx-side-effects"),c)for(let x in c){if(x.indexOf("=")>=0)throw new Error(`Invalid define: ${x}`);e.push(`--define:${x}=${J(c[x],"define",x)}`)}if(b)for(let x in b){if(x.indexOf("=")>=0)throw new Error(`Invalid log override: ${x}`);e.push(`--log-override:${x}=${J(b[x],"log override",x)}`)}if(S)for(let x in S){if(x.indexOf("=")>=0)throw new Error(`Invalid supported: ${x}`);let k=S[x];if(typeof k!="boolean")throw new Error(`Expected value for supported ${_(x)} to be a boolean, got ${typeof k} instead`);e.push(`--supported:${x}=${k}`)}if(F)for(let x of F)e.push(`--pure:${J(x,"pure")}`);$&&e.push("--keep-names")}function rt(e,t,n,i,a){var ae;let l=[],g=[],s=Object.create(null),f=null,h=null;be(l,t,s,n,i),Le(l,t,s);let w=r(t,s,"sourcemap",De),M=r(t,s,"bundle",I),L=r(t,s,"splitting",I),D=r(t,s,"preserveSymlinks",I),q=r(t,s,"metafile",I),G=r(t,s,"outfile",y),U=r(t,s,"outdir",y),K=r(t,s,"outbase",y),Y=r(t,s,"tsconfig",y),v=r(t,s,"resolveExtensions",z),m=r(t,s,"nodePaths",z),d=r(t,s,"mainFields",z),o=r(t,s,"conditions",z),R=r(t,s,"external",z),E=r(t,s,"packages",y),C=r(t,s,"alias",ee),T=r(t,s,"loader",ee),u=r(t,s,"outExtension",ee),c=r(t,s,"publicPath",y),b=r(t,s,"entryNames",y),S=r(t,s,"chunkNames",y),F=r(t,s,"assetNames",y),$=r(t,s,"inject",z),O=r(t,s,"banner",ee),A=r(t,s,"footer",ee),x=r(t,s,"entryPoints",Xe),k=r(t,s,"absWorkingDir",y),P=r(t,s,"stdin",ee),j=(ae=r(t,s,"write",I))!=null?ae:a,B=r(t,s,"allowOverwrite",I),H=r(t,s,"mangleCache",ee);if(s.plugins=!0,V(t,s,`in ${e}() call`),w&&l.push(`--sourcemap${w===!0?"":`=${w}`}`),M&&l.push("--bundle"),B&&l.push("--allow-overwrite"),L&&l.push("--splitting"),D&&l.push("--preserve-symlinks"),q&&l.push("--metafile"),G&&l.push(`--outfile=${G}`),U&&l.push(`--outdir=${U}`),K&&l.push(`--outbase=${K}`),Y&&l.push(`--tsconfig=${Y}`),E&&l.push(`--packages=${E}`),v){let p=[];for(let N of v){if(J(N,"resolve extension"),N.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${N}`);p.push(N)}l.push(`--resolve-extensions=${p.join(",")}`)}if(c&&l.push(`--public-path=${c}`),b&&l.push(`--entry-names=${b}`),S&&l.push(`--chunk-names=${S}`),F&&l.push(`--asset-names=${F}`),d){let p=[];for(let N of d){if(J(N,"main field"),N.indexOf(",")>=0)throw new Error(`Invalid main field: ${N}`);p.push(N)}l.push(`--main-fields=${p.join(",")}`)}if(o){let p=[];for(let N of o){if(J(N,"condition"),N.indexOf(",")>=0)throw new Error(`Invalid condition: ${N}`);p.push(N)}l.push(`--conditions=${p.join(",")}`)}if(R)for(let p of R)l.push(`--external:${J(p,"external")}`);if(C)for(let p in C){if(p.indexOf("=")>=0)throw new Error(`Invalid package name in alias: ${p}`);l.push(`--alias:${p}=${J(C[p],"alias",p)}`)}if(O)for(let p in O){if(p.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${p}`);l.push(`--banner:${p}=${J(O[p],"banner",p)}`)}if(A)for(let p in A){if(p.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${p}`);l.push(`--footer:${p}=${J(A[p],"footer",p)}`)}if($)for(let p of $)l.push(`--inject:${J(p,"inject")}`);if(T)for(let p in T){if(p.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${p}`);l.push(`--loader:${p}=${J(T[p],"loader",p)}`)}if(u)for(let p in u){if(p.indexOf("=")>=0)throw new Error(`Invalid out extension: ${p}`);l.push(`--out-extension:${p}=${J(u[p],"out extension",p)}`)}if(x)if(Array.isArray(x))for(let p=0,N=x.length;p<N;p++){let X=x[p];if(typeof X=="object"&&X!==null){let te=Object.create(null),Q=r(X,te,"in",y),ce=r(X,te,"out",y);if(V(X,te,"in entry point at index "+p),Q===void 0)throw new Error('Missing property "in" for entry point at index '+p);if(ce===void 0)throw new Error('Missing property "out" for entry point at index '+p);g.push([ce,Q])}else g.push(["",J(X,"entry point at index "+p)])}else for(let p in x)g.push([p,J(x[p],"entry point",p)]);if(P){let p=Object.create(null),N=r(P,p,"contents",Be),X=r(P,p,"resolveDir",y),te=r(P,p,"sourcefile",y),Q=r(P,p,"loader",y);V(P,p,'in "stdin" object'),te&&l.push(`--sourcefile=${te}`),Q&&l.push(`--loader=${Q}`),X&&(h=X),typeof N=="string"?f=Z(N):N instanceof Uint8Array&&(f=N)}let W=[];if(m)for(let p of m)p+="",W.push(p);return{entries:g,flags:l,write:j,stdinContents:f,stdinResolveDir:h,absWorkingDir:k,nodePaths:W,mangleCache:je(H)}}function it(e,t,n,i){let a=[],l=Object.create(null);be(a,t,l,n,i),Le(a,t,l);let g=r(t,l,"sourcemap",De),s=r(t,l,"sourcefile",y),f=r(t,l,"loader",y),h=r(t,l,"banner",y),w=r(t,l,"footer",y),M=r(t,l,"mangleCache",ee);return V(t,l,`in ${e}() call`),g&&a.push(`--sourcemap=${g===!0?"external":g}`),s&&a.push(`--sourcefile=${s}`),f&&a.push(`--loader=${f}`),h&&a.push(`--banner=${h}`),w&&a.push(`--footer=${w}`),{flags:a,mangleCache:je(M)}}function qe(e){let t={},n={didClose:!1,reason:""},i={},a=0,l=0,g=new Uint8Array(16*1024),s=0,f=v=>{let m=s+v.length;if(m>g.length){let o=new Uint8Array(m*2);o.set(g),g=o}g.set(v,s),s+=v.length;let d=0;for(;d+4<=s;){let o=ke(g,d);if(d+4+o>s)break;d+=4,q(g.subarray(d,d+o)),d+=o}d>0&&(g.copyWithin(0,d,s),s-=d)},h=v=>{n.didClose=!0,v&&(n.reason=": "+(v.message||v));let m="The service was stopped"+n.reason;for(let d in i)i[d](m,null);i={}},w=(v,m,d)=>{if(n.didClose)return d("The service is no longer running"+n.reason,null);let o=a++;i[o]=(R,E)=>{try{d(R,E)}finally{v&&v.unref()}},v&&v.ref(),e.writeToStdin(Se({id:o,isRequest:!0,value:m}))},M=(v,m)=>{if(n.didClose)throw new Error("The service is no longer running"+n.reason);e.writeToStdin(Se({id:v,isRequest:!1,value:m}))},L=(v,m)=>ne(this,null,function*(){try{if(m.command==="ping"){M(v,{});return}if(typeof m.key=="number"){let d=t[m.key];if(!d)return;let o=d[m.command];if(o){yield o(v,m);return}}throw new Error("Invalid command: "+m.command)}catch(d){let o=[le(d,e,null,void 0,"")];try{M(v,{errors:o})}catch(R){}}}),D=!0,q=v=>{if(D){D=!1;let d=String.fromCharCode(...v);if(d!=="0.21.4")throw new Error(`Cannot start service: Host version "0.21.4" does not match binary version ${_(d)}`);return}let m=$e(v);if(m.isRequest)L(m.id,m.value);else{let d=i[m.id];delete i[m.id],m.value.error?d(m.value.error,{}):d(null,m.value)}};return{readFromStdout:f,afterClose:h,service:{buildOrContext:({callName:v,refs:m,options:d,isTTY:o,defaultWD:R,callback:E})=>{let C=0,T=l++,u={},c={ref(){++C===1&&m&&m.ref()},unref(){--C===0&&(delete t[T],m&&m.unref())}};t[T]=u,c.ref(),lt(v,T,w,M,c,e,u,d,o,R,(b,S)=>{try{E(b,S)}finally{c.unref()}})},transform:({callName:v,refs:m,input:d,options:o,isTTY:R,fs:E,callback:C})=>{let T=Ne(),u=c=>{try{if(typeof d!="string"&&!(d instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:b,mangleCache:S}=it(v,o,R,Ce),F={command:"transform",flags:b,inputFS:c!==null,input:c!==null?Z(c):typeof d=="string"?Z(d):d};S&&(F.mangleCache=S),w(m,F,($,O)=>{if($)return C(new Error($),null);let A=ue(O.errors,T),x=ue(O.warnings,T),k=1,P=()=>{if(--k===0){let j={warnings:x,code:O.code,map:O.map,mangleCache:void 0,legalComments:void 0};"legalComments"in O&&(j.legalComments=O==null?void 0:O.legalComments),O.mangleCache&&(j.mangleCache=O==null?void 0:O.mangleCache),C(null,j)}};if(A.length>0)return C(fe("Transform failed",A,x),null);O.codeFS&&(k++,E.readFile(O.code,(j,B)=>{j!==null?C(j,null):(O.code=B,P())})),O.mapFS&&(k++,E.readFile(O.map,(j,B)=>{j!==null?C(j,null):(O.map=B,P())})),P()})}catch(b){let S=[];try{be(S,o,{},R,Ce)}catch($){}let F=le(b,e,T,void 0,"");w(m,{command:"error",flags:S,error:F},()=>{F.detail=T.load(F.detail),C(fe("Transform failed",[F],[]),null)})}};if((typeof d=="string"||d instanceof Uint8Array)&&d.length>1024*1024){let c=u;u=()=>E.writeFile(d,c)}u(null)},formatMessages:({callName:v,refs:m,messages:d,options:o,callback:R})=>{if(!o)throw new Error(`Missing second argument in ${v}() call`);let E={},C=r(o,E,"kind",y),T=r(o,E,"color",I),u=r(o,E,"terminalWidth",se);if(V(o,E,`in ${v}() call`),C===void 0)throw new Error(`Missing "kind" in ${v}() call`);if(C!=="error"&&C!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${v}() call`);let c={command:"format-msgs",messages:re(d,"messages",null,"",u),isWarning:C==="warning"};T!==void 0&&(c.color=T),u!==void 0&&(c.terminalWidth=u),w(m,c,(b,S)=>{if(b)return R(new Error(b),null);R(null,S.messages)})},analyzeMetafile:({callName:v,refs:m,metafile:d,options:o,callback:R})=>{o===void 0&&(o={});let E={},C=r(o,E,"color",I),T=r(o,E,"verbose",I);V(o,E,`in ${v}() call`);let u={command:"analyze-metafile",metafile:d};C!==void 0&&(u.color=C),T!==void 0&&(u.verbose=T),w(m,u,(c,b)=>{if(c)return R(new Error(c),null);R(null,b.result)})}}}}function lt(e,t,n,i,a,l,g,s,f,h,w){let M=Ne(),L=e==="context",D=(U,K)=>{let Y=[];try{be(Y,s,{},f,Me)}catch(m){}let v=le(U,l,M,void 0,K);n(a,{command:"error",flags:Y,error:v},()=>{v.detail=M.load(v.detail),w(fe(L?"Context failed":"Build failed",[v],[]),null)})},q;if(typeof s=="object"){let U=s.plugins;if(U!==void 0){if(!Array.isArray(U))return D(new Error('"plugins" must be an array'),"");q=U}}if(q&&q.length>0){if(l.isSync)return D(new Error("Cannot use plugins in synchronous API calls"),"");st(t,n,i,a,l,g,s,q,M).then(U=>{if(!U.ok)return D(U.error,U.pluginName);try{G(U.requestPlugins,U.runOnEndCallbacks,U.scheduleOnDisposeCallbacks)}catch(K){D(K,"")}},U=>D(U,""));return}try{G(null,(U,K)=>K([],[]),()=>{})}catch(U){D(U,"")}function G(U,K,Y){let v=l.hasFS,{entries:m,flags:d,write:o,stdinContents:R,stdinResolveDir:E,absWorkingDir:C,nodePaths:T,mangleCache:u}=rt(e,s,f,Me,v);if(o&&!l.hasFS)throw new Error('The "write" option is unavailable in this environment');let c={command:"build",key:t,entries:m,flags:d,write:o,stdinContents:R,stdinResolveDir:E,absWorkingDir:C||h,nodePaths:T,context:L};U&&(c.plugins=U),u&&(c.mangleCache=u);let b=($,O)=>{let A={errors:ue($.errors,M),warnings:ue($.warnings,M),outputFiles:void 0,metafile:void 0,mangleCache:void 0},x=A.errors.slice(),k=A.warnings.slice();$.outputFiles&&(A.outputFiles=$.outputFiles.map(at)),$.metafile&&(A.metafile=JSON.parse($.metafile)),$.mangleCache&&(A.mangleCache=$.mangleCache),$.writeToStdout!==void 0&&console.log(ie($.writeToStdout).replace(/\n$/,"")),K(A,(P,j)=>{if(x.length>0||P.length>0){let B=fe("Build failed",x.concat(P),k.concat(j));return O(B,null,P,j)}O(null,A,P,j)})},S,F;L&&(g["on-end"]=($,O)=>new Promise(A=>{b(O,(x,k,P,j)=>{let B={errors:P,warnings:j};F&&F(x,k),S=void 0,F=void 0,i($,B),A()})})),n(a,c,($,O)=>{if($)return w(new Error($),null);if(!L)return b(O,(k,P)=>(Y(),w(k,P)));if(O.errors.length>0)return w(fe("Context failed",O.errors,O.warnings),null);let A=!1,x={rebuild:()=>(S||(S=new Promise((k,P)=>{let j;F=(H,W)=>{j||(j=()=>H?P(H):k(W))};let B=()=>{n(a,{command:"rebuild",key:t},(W,ae)=>{W?P(new Error(W)):j?j():B()})};B()})),S),watch:(k={})=>new Promise((P,j)=>{if(!l.hasFS)throw new Error('Cannot use the "watch" API in this environment');V(k,{},"in watch() call"),n(a,{command:"watch",key:t},W=>{W?j(new Error(W)):P(void 0)})}),serve:(k={})=>new Promise((P,j)=>{if(!l.hasFS)throw new Error('Cannot use the "serve" API in this environment');let B={},H=r(k,B,"port",se),W=r(k,B,"host",y),ae=r(k,B,"servedir",y),p=r(k,B,"keyfile",y),N=r(k,B,"certfile",y),X=r(k,B,"fallback",y),te=r(k,B,"onRequest",Pe);V(k,B,"in serve() call");let Q={command:"serve",key:t,onRequest:!!te};H!==void 0&&(Q.port=H),W!==void 0&&(Q.host=W),ae!==void 0&&(Q.servedir=ae),p!==void 0&&(Q.keyfile=p),N!==void 0&&(Q.certfile=N),X!==void 0&&(Q.fallback=X),n(a,Q,(ce,We)=>{if(ce)return j(new Error(ce));te&&(g["serve-request"]=(ze,Ke)=>{te(Ke.args),i(ze,{})}),P(We)})}),cancel:()=>new Promise(k=>{if(A)return k();n(a,{command:"cancel",key:t},()=>{k()})}),dispose:()=>new Promise(k=>{if(A)return k();A=!0,n(a,{command:"dispose",key:t},()=>{k(),Y(),a.unref()})})};a.ref(),w(null,x)})}}var st=(e,t,n,i,a,l,g,s,f)=>ne(void 0,null,function*(){let h=[],w=[],M={},L={},D=[],q=0,G=0,U=[],K=!1;s=[...s];for(let m of s){let d={};if(typeof m!="object")throw new Error(`Plugin at index ${G} must be an object`);let o=r(m,d,"name",y);if(typeof o!="string"||o==="")throw new Error(`Plugin at index ${G} is missing a name`);try{let R=r(m,d,"setup",Pe);if(typeof R!="function")throw new Error("Plugin is missing a setup function");V(m,d,`on plugin ${_(o)}`);let E={name:o,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};G++;let T=R({initialOptions:g,resolve:(u,c={})=>{if(!K)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 b=Object.create(null),S=r(c,b,"pluginName",y),F=r(c,b,"importer",y),$=r(c,b,"namespace",y),O=r(c,b,"resolveDir",y),A=r(c,b,"kind",y),x=r(c,b,"pluginData",ye),k=r(c,b,"with",ee);return V(c,b,"in resolve() call"),new Promise((P,j)=>{let B={command:"resolve",path:u,key:e,pluginName:o};if(S!=null&&(B.pluginName=S),F!=null&&(B.importer=F),$!=null&&(B.namespace=$),O!=null&&(B.resolveDir=O),A!=null)B.kind=A;else throw new Error('Must specify "kind" when calling "resolve"');x!=null&&(B.pluginData=f.store(x)),k!=null&&(B.with=ot(k,"with")),t(i,B,(H,W)=>{H!==null?j(new Error(H)):P({errors:ue(W.errors,f),warnings:ue(W.warnings,f),path:W.path,external:W.external,sideEffects:W.sideEffects,namespace:W.namespace,suffix:W.suffix,pluginData:f.load(W.pluginData)})})})},onStart(u){let c='This error came from the "onStart" callback registered here:',b=ge(new Error(c),a,"onStart");h.push({name:o,callback:u,note:b}),E.onStart=!0},onEnd(u){let c='This error came from the "onEnd" callback registered here:',b=ge(new Error(c),a,"onEnd");w.push({name:o,callback:u,note:b}),E.onEnd=!0},onResolve(u,c){let b='This error came from the "onResolve" callback registered here:',S=ge(new Error(b),a,"onResolve"),F={},$=r(u,F,"filter",he),O=r(u,F,"namespace",y);if(V(u,F,`in onResolve() call for plugin ${_(o)}`),$==null)throw new Error("onResolve() call is missing a filter");let A=q++;M[A]={name:o,callback:c,note:S},E.onResolve.push({id:A,filter:$.source,namespace:O||""})},onLoad(u,c){let b='This error came from the "onLoad" callback registered here:',S=ge(new Error(b),a,"onLoad"),F={},$=r(u,F,"filter",he),O=r(u,F,"namespace",y);if(V(u,F,`in onLoad() call for plugin ${_(o)}`),$==null)throw new Error("onLoad() call is missing a filter");let A=q++;L[A]={name:o,callback:c,note:S},E.onLoad.push({id:A,filter:$.source,namespace:O||""})},onDispose(u){D.push(u)},esbuild:a.esbuild});T&&(yield T),U.push(E)}catch(R){return{ok:!1,error:R,pluginName:o}}}l["on-start"]=(m,d)=>ne(void 0,null,function*(){let o={errors:[],warnings:[]};yield Promise.all(h.map(T=>ne(void 0,[T],function*({name:R,callback:E,note:C}){try{let u=yield E();if(u!=null){if(typeof u!="object")throw new Error(`Expected onStart() callback in plugin ${_(R)} to return an object`);let c={},b=r(u,c,"errors",z),S=r(u,c,"warnings",z);V(u,c,`from onStart() callback in plugin ${_(R)}`),b!=null&&o.errors.push(...re(b,"errors",f,R,void 0)),S!=null&&o.warnings.push(...re(S,"warnings",f,R,void 0))}}catch(u){o.errors.push(le(u,a,f,C&&C(),R))}}))),n(m,o)}),l["on-resolve"]=(m,d)=>ne(void 0,null,function*(){let o={},R="",E,C;for(let T of d.ids)try{({name:R,callback:E,note:C}=M[T]);let u=yield E({path:d.path,importer:d.importer,namespace:d.namespace,resolveDir:d.resolveDir,kind:d.kind,pluginData:f.load(d.pluginData),with:d.with});if(u!=null){if(typeof u!="object")throw new Error(`Expected onResolve() callback in plugin ${_(R)} to return an object`);let c={},b=r(u,c,"pluginName",y),S=r(u,c,"path",y),F=r(u,c,"namespace",y),$=r(u,c,"suffix",y),O=r(u,c,"external",I),A=r(u,c,"sideEffects",I),x=r(u,c,"pluginData",ye),k=r(u,c,"errors",z),P=r(u,c,"warnings",z),j=r(u,c,"watchFiles",z),B=r(u,c,"watchDirs",z);V(u,c,`from onResolve() callback in plugin ${_(R)}`),o.id=T,b!=null&&(o.pluginName=b),S!=null&&(o.path=S),F!=null&&(o.namespace=F),$!=null&&(o.suffix=$),O!=null&&(o.external=O),A!=null&&(o.sideEffects=A),x!=null&&(o.pluginData=f.store(x)),k!=null&&(o.errors=re(k,"errors",f,R,void 0)),P!=null&&(o.warnings=re(P,"warnings",f,R,void 0)),j!=null&&(o.watchFiles=me(j,"watchFiles")),B!=null&&(o.watchDirs=me(B,"watchDirs"));break}}catch(u){o={id:T,errors:[le(u,a,f,C&&C(),R)]};break}n(m,o)}),l["on-load"]=(m,d)=>ne(void 0,null,function*(){let o={},R="",E,C;for(let T of d.ids)try{({name:R,callback:E,note:C}=L[T]);let u=yield E({path:d.path,namespace:d.namespace,suffix:d.suffix,pluginData:f.load(d.pluginData),with:d.with});if(u!=null){if(typeof u!="object")throw new Error(`Expected onLoad() callback in plugin ${_(R)} to return an object`);let c={},b=r(u,c,"pluginName",y),S=r(u,c,"contents",Be),F=r(u,c,"resolveDir",y),$=r(u,c,"pluginData",ye),O=r(u,c,"loader",y),A=r(u,c,"errors",z),x=r(u,c,"warnings",z),k=r(u,c,"watchFiles",z),P=r(u,c,"watchDirs",z);V(u,c,`from onLoad() callback in plugin ${_(R)}`),o.id=T,b!=null&&(o.pluginName=b),S instanceof Uint8Array?o.contents=S:S!=null&&(o.contents=Z(S)),F!=null&&(o.resolveDir=F),$!=null&&(o.pluginData=f.store($)),O!=null&&(o.loader=O),A!=null&&(o.errors=re(A,"errors",f,R,void 0)),x!=null&&(o.warnings=re(x,"warnings",f,R,void 0)),k!=null&&(o.watchFiles=me(k,"watchFiles")),P!=null&&(o.watchDirs=me(P,"watchDirs"));break}}catch(u){o={id:T,errors:[le(u,a,f,C&&C(),R)]};break}n(m,o)});let Y=(m,d)=>d([],[]);w.length>0&&(Y=(m,d)=>{ne(void 0,null,function*(){let o=[],R=[];for(let{name:E,callback:C,note:T}of w){let u,c;try{let b=yield C(m);if(b!=null){if(typeof b!="object")throw new Error(`Expected onEnd() callback in plugin ${_(E)} to return an object`);let S={},F=r(b,S,"errors",z),$=r(b,S,"warnings",z);V(b,S,`from onEnd() callback in plugin ${_(E)}`),F!=null&&(u=re(F,"errors",f,E,void 0)),$!=null&&(c=re($,"warnings",f,E,void 0))}}catch(b){u=[le(b,a,f,T&&T(),E)]}if(u){o.push(...u);try{m.errors.push(...u)}catch(b){}}if(c){R.push(...c);try{m.warnings.push(...c)}catch(b){}}}d(o,R)})});let v=()=>{for(let m of D)setTimeout(()=>m(),0)};return K=!0,{ok:!0,requestPlugins:U,runOnEndCallbacks:Y,scheduleOnDisposeCallbacks:v}});function Ne(){let e=new Map,t=0;return{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 g=Ie(t,l,n);if(g)return i={text:e.message,location:g},i}catch(l){}}}function le(e,t,n,i,a){let l="Internal error",g=null;try{l=(e&&e.message||e)+""}catch(s){}try{g=Ie(t,(e.stack+"").split(`
|
|
9
|
+
`),"")}catch(s){}return{id:"",pluginName:a,text:l,location:g,notes:i?[i]:[],detail:n?n.store(e):-1}}function Ie(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 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(M){break}let f=s.split(/\r\n|\r|\n|\u2028|\u2029/)[+g[2]-1]||"",h=+g[3]-1,w=f.slice(h,h+n.length)===n?n.length:0;return{file:g[1],namespace:"file",line:+g[2],column:Z(f.slice(0,h)).length,length:Z(f.slice(h,h+w)).length,lineText:f+`
|
|
10
10
|
`+t.slice(1).join(`
|
|
11
|
-
`),suggestion:""}}break}}return null}function
|
|
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,g)=>{if(g===i)return`
|
|
12
12
|
...`;if(!l.location)return`
|
|
13
|
-
error: ${l.text}`;let{file:s,line:
|
|
14
|
-
${s}:${c}:${h}: ERROR: ${w}${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 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={},u=r(e,i,"file",y),l=r(e,i,"namespace",y),g=r(e,i,"line",se),s=r(e,i,"column",se),c=r(e,i,"length",se),h=r(e,i,"lineText",y),w=r(e,i,"suggestion",y);if(K(e,i,t),h){let M=h.slice(0,(s&&s>0?s:0)+(c&&c>0?c:0)+(n&&n>0?n:80));!/[\x7F-\uFFFF]/.test(M)&&!/\n/.test(h)&&(h=M)}return{file:u||"",namespace:l||"",line:g||0,column:s||0,length:c||0,lineText:h||"",suggestion:w||""}}function re(e,t,n,i,u){let l=[],g=0;for(let s of e){let c={},h=r(s,c,"id",y),w=r(s,c,"pluginName",y),M=r(s,c,"text",y),L=r(s,c,"location",Fe),B=r(s,c,"notes",W),q=r(s,c,"detail",ye),G=`in element ${g} of "${t}"`;K(s,c,G);let U=[];if(B)for(let z of B){let _={},v=r(z,_,"text",y),m=r(z,_,"location",Fe);K(z,_,G),U.push({text:v||"",location:Te(m,G,u)})}l.push({id:h||"",pluginName:w||i,text:M||"",location:Te(L,G,u),notes:U,detail:n?n.store(q):-1}),g++}return l}function me(e,t){let n=[];for(let i of e){if(typeof i!="string")throw new Error(`${J(t)} must be an array of strings`);n.push(i)}return n}function ot({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=ie(u)),i}}}var ut="0.21.3",ft=e=>de().build(e),ct=e=>de().context(e),dt=(e,t)=>de().transform(e,t),pt=(e,t)=>de().formatMessages(e,t),gt=(e,t)=>de().analyzeMetafile(e,t),mt=()=>{throw new Error('The "buildSync" API only works in node')},yt=()=>{throw new Error('The "transformSync" API only works in node')},ht=()=>{throw new Error('The "formatMessagesSync" API only works in node')},bt=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},wt=()=>(we&&we(),Promise.resolve()),oe,we,ve,de=()=>{if(ve)return ve;throw oe?new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this'):new Error('You need to call "initialize" before calling this')},vt=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(oe)throw new Error('Cannot call "initialize" more than once');return oe=xt(t||"",n,i),oe.catch(()=>{oe=void 0}),oe},xt=(e,t,n)=>ne(void 0,null,function*(){let i;if(n){let h=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.21.3"],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(h))}else{let h=(postMessage=>{
|
|
13
|
+
error: ${l.text}`;let{file:s,line:f,column:h}=l.location,w=l.pluginName?`[plugin: ${l.pluginName}] `:"";return`
|
|
14
|
+
${s}:${f}:${h}: ERROR: ${w}${l.text}`}).join("");let a=new Error(e);for(let[l,g]of[["errors",t],["warnings",n]])Object.defineProperty(a,l,{configurable:!0,enumerable:!0,get:()=>g,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),g=r(e,i,"line",se),s=r(e,i,"column",se),f=r(e,i,"length",se),h=r(e,i,"lineText",y),w=r(e,i,"suggestion",y);if(V(e,i,t),h){let M=h.slice(0,(s&&s>0?s:0)+(f&&f>0?f:0)+(n&&n>0?n:80));!/[\x7F-\uFFFF]/.test(M)&&!/\n/.test(h)&&(h=M)}return{file:a||"",namespace:l||"",line:g||0,column:s||0,length:f||0,lineText:h||"",suggestion:w||""}}function re(e,t,n,i,a){let l=[],g=0;for(let s of e){let f={},h=r(s,f,"id",y),w=r(s,f,"pluginName",y),M=r(s,f,"text",y),L=r(s,f,"location",Fe),D=r(s,f,"notes",z),q=r(s,f,"detail",ye),G=`in element ${g} of "${t}"`;V(s,f,G);let U=[];if(D)for(let K of D){let Y={},v=r(K,Y,"text",y),m=r(K,Y,"location",Fe);V(K,Y,G),U.push({text:v||"",location:Te(m,G,a)})}l.push({id:h||"",pluginName:w||i,text:M||"",location:Te(L,G,a),notes:U,detail:n?n.store(q):-1}),g++}return l}function me(e,t){let n=[];for(let i of e){if(typeof i!="string")throw new Error(`${_(t)} must be an array of strings`);n.push(i)}return n}function ot(e,t){let n=Object.create(null);for(let i in e){let a=e[i];if(typeof a!="string")throw new Error(`key ${_(i)} in object ${_(t)} must be a string`);n[i]=a}return n}function at({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 ct="0.21.4",ft=e=>de().build(e),dt=e=>de().context(e),pt=(e,t)=>de().transform(e,t),gt=(e,t)=>de().formatMessages(e,t),mt=(e,t)=>de().analyzeMetafile(e,t),yt=()=>{throw new Error('The "buildSync" API only works in node')},ht=()=>{throw new Error('The "transformSync" API only works in node')},bt=()=>{throw new Error('The "formatMessagesSync" API only works in node')},wt=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},vt=()=>(we&&we(),Promise.resolve()),oe,we,ve,de=()=>{if(ve)return ve;throw oe?new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this'):new Error('You need to call "initialize" before calling this')},Rt=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(oe)throw new Error('Cannot call "initialize" more than once');return oe=xt(t||"",n,i),oe.catch(()=>{oe=void 0}),oe},xt=(e,t,n)=>ne(void 0,null,function*(){let i;if(n){let h=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.21.4"],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(h))}else{let h=(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.21.
|
|
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.21.4"],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);})(M=>i.onmessage({data:M})),w;i={onmessage:null,postMessage:M=>setTimeout(()=>w=h({data:M})),terminate(){if(w)for(let M of w._scheduledTimeouts.values())clearTimeout(M)}}}let a,l,g=new Promise((h,w)=>{a=h,l=w});i.onmessage=({data:h})=>{i.onmessage=({data:w})=>s(w),h?l(h):a()},i.postMessage(t||new URL(e,location.href).toString());let{readFromStdout:s,service:f}=qe({writeToStdin(h){i.postMessage(h)},isSync:!1,hasFS:!1,esbuild:Re});yield g,we=()=>{i.terminate(),oe=void 0,we=void 0,ve=void 0},ve={build:h=>new Promise((w,M)=>f.buildOrContext({callName:"build",refs:null,options:h,isTTY:!1,defaultWD:"/",callback:(L,D)=>L?M(L):w(D)})),context:h=>new Promise((w,M)=>f.buildOrContext({callName:"context",refs:null,options:h,isTTY:!1,defaultWD:"/",callback:(L,D)=>L?M(L):w(D)})),transform:(h,w)=>new Promise((M,L)=>f.transform({callName:"transform",refs:null,input:h,options:w||{},isTTY:!1,fs:{readFile(D,q){q(new Error("Internal error"),null)},writeFile(D,q){q(null)}},callback:(D,q)=>D?L(D):M(q)})),formatMessages:(h,w)=>new Promise((M,L)=>f.formatMessages({callName:"formatMessages",refs:null,messages:h,options:w,callback:(D,q)=>D?L(D):M(q)})),analyzeMetafile:(h,w)=>new Promise((M,L)=>f.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof h=="string"?h:JSON.stringify(h),options:w,callback:(D,q)=>D?L(D):M(q)}))}}),Ot=Re;
|
|
22
22
|
})(typeof module==="object"?module:{set exports(x){(typeof self!=="undefined"?self:this).esbuild=x}});
|
package/lib/main.d.ts
CHANGED
|
@@ -340,6 +340,7 @@ export interface ResolveOptions {
|
|
|
340
340
|
resolveDir?: string
|
|
341
341
|
kind?: ImportKind
|
|
342
342
|
pluginData?: any
|
|
343
|
+
with?: Record<string, string>
|
|
343
344
|
}
|
|
344
345
|
|
|
345
346
|
/** Documentation: https://esbuild.github.io/plugins/#resolve-results */
|
|
@@ -379,6 +380,7 @@ export interface OnResolveArgs {
|
|
|
379
380
|
resolveDir: string
|
|
380
381
|
kind: ImportKind
|
|
381
382
|
pluginData: any
|
|
383
|
+
with: Record<string, string>
|
|
382
384
|
}
|
|
383
385
|
|
|
384
386
|
export type ImportKind =
|
package/lib/main.js
CHANGED
|
@@ -652,8 +652,8 @@ function createChannel(streamIn) {
|
|
|
652
652
|
if (isFirstPacket) {
|
|
653
653
|
isFirstPacket = false;
|
|
654
654
|
let binaryVersion = String.fromCharCode(...bytes);
|
|
655
|
-
if (binaryVersion !== "0.21.
|
|
656
|
-
throw new Error(`Cannot start service: Host version "${"0.21.
|
|
655
|
+
if (binaryVersion !== "0.21.4") {
|
|
656
|
+
throw new Error(`Cannot start service: Host version "${"0.21.4"}" does not match binary version ${quote(binaryVersion)}`);
|
|
657
657
|
}
|
|
658
658
|
return;
|
|
659
659
|
}
|
|
@@ -1105,6 +1105,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
|
1105
1105
|
let resolveDir = getFlag(options, keys2, "resolveDir", mustBeString);
|
|
1106
1106
|
let kind = getFlag(options, keys2, "kind", mustBeString);
|
|
1107
1107
|
let pluginData = getFlag(options, keys2, "pluginData", canBeAnything);
|
|
1108
|
+
let importAttributes = getFlag(options, keys2, "with", mustBeObject);
|
|
1108
1109
|
checkForInvalidFlags(options, keys2, "in resolve() call");
|
|
1109
1110
|
return new Promise((resolve2, reject) => {
|
|
1110
1111
|
const request = {
|
|
@@ -1120,6 +1121,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
|
1120
1121
|
if (kind != null) request.kind = kind;
|
|
1121
1122
|
else throw new Error(`Must specify "kind" when calling "resolve"`);
|
|
1122
1123
|
if (pluginData != null) request.pluginData = details.store(pluginData);
|
|
1124
|
+
if (importAttributes != null) request.with = sanitizeStringMap(importAttributes, "with");
|
|
1123
1125
|
sendRequest(refs, request, (error, response) => {
|
|
1124
1126
|
if (error !== null) reject(new Error(error));
|
|
1125
1127
|
else resolve2({
|
|
@@ -1216,7 +1218,8 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
|
1216
1218
|
namespace: request.namespace,
|
|
1217
1219
|
resolveDir: request.resolveDir,
|
|
1218
1220
|
kind: request.kind,
|
|
1219
|
-
pluginData: details.load(request.pluginData)
|
|
1221
|
+
pluginData: details.load(request.pluginData),
|
|
1222
|
+
with: request.with
|
|
1220
1223
|
});
|
|
1221
1224
|
if (result != null) {
|
|
1222
1225
|
if (typeof result !== "object") throw new Error(`Expected onResolve() callback in plugin ${quote(name)} to return an object`);
|
|
@@ -1553,6 +1556,15 @@ function sanitizeStringArray(values, property) {
|
|
|
1553
1556
|
}
|
|
1554
1557
|
return result;
|
|
1555
1558
|
}
|
|
1559
|
+
function sanitizeStringMap(map, property) {
|
|
1560
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
1561
|
+
for (const key in map) {
|
|
1562
|
+
const value = map[key];
|
|
1563
|
+
if (typeof value !== "string") throw new Error(`key ${quote(key)} in object ${quote(property)} must be a string`);
|
|
1564
|
+
result[key] = value;
|
|
1565
|
+
}
|
|
1566
|
+
return result;
|
|
1567
|
+
}
|
|
1556
1568
|
function convertOutputFiles({ path: path3, contents, hash }) {
|
|
1557
1569
|
let text = null;
|
|
1558
1570
|
return {
|
|
@@ -1598,7 +1610,7 @@ if (process.env.ESBUILD_WORKER_THREADS !== "0") {
|
|
|
1598
1610
|
}
|
|
1599
1611
|
}
|
|
1600
1612
|
var _a;
|
|
1601
|
-
var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.21.
|
|
1613
|
+
var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.21.4";
|
|
1602
1614
|
var esbuildCommandAndArgs = () => {
|
|
1603
1615
|
if ((!ESBUILD_BINARY_PATH || true) && (path2.basename(__filename) !== "main.js" || path2.basename(__dirname) !== "lib")) {
|
|
1604
1616
|
throw new Error(
|
|
@@ -1665,7 +1677,7 @@ var fsAsync = {
|
|
|
1665
1677
|
}
|
|
1666
1678
|
}
|
|
1667
1679
|
};
|
|
1668
|
-
var version = "0.21.
|
|
1680
|
+
var version = "0.21.4";
|
|
1669
1681
|
var build = (options) => ensureServiceIsRunning().build(options);
|
|
1670
1682
|
var context = (buildOptions) => ensureServiceIsRunning().context(buildOptions);
|
|
1671
1683
|
var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
|
|
@@ -1768,7 +1780,7 @@ var stopService;
|
|
|
1768
1780
|
var ensureServiceIsRunning = () => {
|
|
1769
1781
|
if (longLivedService) return longLivedService;
|
|
1770
1782
|
let [command, args] = esbuildCommandAndArgs();
|
|
1771
|
-
let child = child_process.spawn(command, args.concat(`--service=${"0.21.
|
|
1783
|
+
let child = child_process.spawn(command, args.concat(`--service=${"0.21.4"}`, "--ping"), {
|
|
1772
1784
|
windowsHide: true,
|
|
1773
1785
|
stdio: ["pipe", "pipe", "inherit"],
|
|
1774
1786
|
cwd: defaultWD
|
|
@@ -1872,7 +1884,7 @@ var runServiceSync = (callback) => {
|
|
|
1872
1884
|
esbuild: node_exports
|
|
1873
1885
|
});
|
|
1874
1886
|
callback(service);
|
|
1875
|
-
let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.21.
|
|
1887
|
+
let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.21.4"}`), {
|
|
1876
1888
|
cwd: defaultWD,
|
|
1877
1889
|
windowsHide: true,
|
|
1878
1890
|
input: stdin,
|
|
@@ -1892,7 +1904,7 @@ var workerThreadService = null;
|
|
|
1892
1904
|
var startWorkerThreadService = (worker_threads2) => {
|
|
1893
1905
|
let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
|
|
1894
1906
|
let worker = new worker_threads2.Worker(__filename, {
|
|
1895
|
-
workerData: { workerPort, defaultWD, esbuildVersion: "0.21.
|
|
1907
|
+
workerData: { workerPort, defaultWD, esbuildVersion: "0.21.4" },
|
|
1896
1908
|
transferList: [workerPort],
|
|
1897
1909
|
// From node's documentation: https://nodejs.org/api/worker_threads.html
|
|
1898
1910
|
//
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esbuild-wasm-strapkit",
|
|
3
|
-
"version": "0.21.
|
|
4
|
-
"esbuildVersion": "0.21.
|
|
5
|
-
"description": "esbuild-wasm 0.21.
|
|
3
|
+
"version": "0.21.4-build.2",
|
|
4
|
+
"esbuildVersion": "0.21.4",
|
|
5
|
+
"description": "esbuild-wasm 0.21.4 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.21.4.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=12"
|