+
+
diff --git a/tqweb/main.go b/tqweb/main.go
new file mode 100644
index 0000000..a6e57eb
--- /dev/null
+++ b/tqweb/main.go
@@ -0,0 +1,57 @@
+//go:build js && wasm
+
+package main
+
+import (
+ "bytes"
+ _ "embed"
+ "html/template"
+ "net/http"
+ "strings"
+
+ "github.com/mdm-code/tq/v2"
+ "github.com/mdm-code/tq/v2/toml"
+ wasmhttp "github.com/nlepage/go-wasm-http-server/v2"
+)
+
+/*
+TODO:
+1. Tq config for GoTOML is sent from the frontend selection component.
+- Checkboxes: send true if checked.
+- Buttons: on click, keep highlighted and add to the payload.
+2. The config and TQ has to be instantiated with each call.
+3. Curl tailwind css scripts.
+*/
+
+var (
+ //go:embed views/index.html
+ index string
+ indexT = template.Must(template.New("index").Parse(index))
+)
+
+func main() {
+ conf := toml.GoTOMLConf{}
+ goToml := toml.NewGoTOML(conf)
+ adapter := toml.NewAdapter(goToml)
+ tq := tq.New(adapter)
+
+ http.HandleFunc("/process", func(w http.ResponseWriter, r *http.Request) {
+ var output bytes.Buffer
+ var data struct{ Output string }
+ input := r.FormValue("input")
+ query := r.FormValue("query")
+ err := tq.Run(strings.NewReader(input), &output, query)
+ if err != nil {
+ data.Output = err.Error()
+ } else {
+ data.Output = output.String()
+ }
+ if err := indexT.ExecuteTemplate(w, "output", data); err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ }
+ })
+
+ wasmhttp.Serve(nil)
+
+ select {}
+}
diff --git a/tqweb/sw.js b/tqweb/sw.js
new file mode 100644
index 0000000..11e0ae0
--- /dev/null
+++ b/tqweb/sw.js
@@ -0,0 +1,42 @@
+function registerWasmHTTPListener(wasm, { base, cacheName, passthrough, args = [] } = {}) {
+ let path = new URL(registration.scope).pathname
+ if (base && base !== '') path = `${trimEnd(path, '/')}/${trimStart(base, '/')}`
+
+ const handlerPromise = new Promise(setHandler => {
+ self.wasmhttp = {
+ path,
+ setHandler,
+ }
+ })
+
+ const go = new Go()
+ go.argv = [wasm, ...args]
+ const source = cacheName
+ ? caches.open(cacheName).then((cache) => cache.match(wasm)).then((response) => response ?? fetch(wasm))
+ : caches.match(wasm).then(response => (response) ?? fetch(wasm))
+ WebAssembly.instantiateStreaming(source, go.importObject).then(({ instance }) => go.run(instance))
+
+ addEventListener('fetch', e => {
+ if (passthrough?.(e.request)) {
+ e.respondWith(fetch(e.request))
+ return;
+ }
+
+ const { pathname } = new URL(e.request.url)
+ if (!pathname.startsWith(path)) return
+
+ e.respondWith(handlerPromise.then(handler => handler(e.request)))
+ })
+}
+
+function trimStart(s, c) {
+ let r = s
+ while (r.startsWith(c)) r = r.slice(c.length)
+ return r
+}
+
+function trimEnd(s, c) {
+ let r = s
+ while (r.endsWith(c)) r = r.slice(0, -c.length)
+ return r
+}
diff --git a/tqweb/tq.svg b/tqweb/tq.svg
new file mode 100644
index 0000000..8627225
--- /dev/null
+++ b/tqweb/tq.svg
@@ -0,0 +1,9 @@
+
+
diff --git a/tqweb/views/index.html b/tqweb/views/index.html
new file mode 100644
index 0000000..e73cb9d
--- /dev/null
+++ b/tqweb/views/index.html
@@ -0,0 +1,9 @@
+{{ block "output" . }}
+
+{{ end }}
diff --git a/tqweb/wasm_exec.js b/tqweb/wasm_exec.js
new file mode 100644
index 0000000..d71af9e
--- /dev/null
+++ b/tqweb/wasm_exec.js
@@ -0,0 +1,575 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+"use strict";
+
+(() => {
+ const enosys = () => {
+ const err = new Error("not implemented");
+ err.code = "ENOSYS";
+ return err;
+ };
+
+ if (!globalThis.fs) {
+ let outputBuf = "";
+ globalThis.fs = {
+ constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1, O_DIRECTORY: -1 }, // unused
+ writeSync(fd, buf) {
+ outputBuf += decoder.decode(buf);
+ const nl = outputBuf.lastIndexOf("\n");
+ if (nl != -1) {
+ console.log(outputBuf.substring(0, nl));
+ outputBuf = outputBuf.substring(nl + 1);
+ }
+ return buf.length;
+ },
+ write(fd, buf, offset, length, position, callback) {
+ if (offset !== 0 || length !== buf.length || position !== null) {
+ callback(enosys());
+ return;
+ }
+ const n = this.writeSync(fd, buf);
+ callback(null, n);
+ },
+ chmod(path, mode, callback) { callback(enosys()); },
+ chown(path, uid, gid, callback) { callback(enosys()); },
+ close(fd, callback) { callback(enosys()); },
+ fchmod(fd, mode, callback) { callback(enosys()); },
+ fchown(fd, uid, gid, callback) { callback(enosys()); },
+ fstat(fd, callback) { callback(enosys()); },
+ fsync(fd, callback) { callback(null); },
+ ftruncate(fd, length, callback) { callback(enosys()); },
+ lchown(path, uid, gid, callback) { callback(enosys()); },
+ link(path, link, callback) { callback(enosys()); },
+ lstat(path, callback) { callback(enosys()); },
+ mkdir(path, perm, callback) { callback(enosys()); },
+ open(path, flags, mode, callback) { callback(enosys()); },
+ read(fd, buffer, offset, length, position, callback) { callback(enosys()); },
+ readdir(path, callback) { callback(enosys()); },
+ readlink(path, callback) { callback(enosys()); },
+ rename(from, to, callback) { callback(enosys()); },
+ rmdir(path, callback) { callback(enosys()); },
+ stat(path, callback) { callback(enosys()); },
+ symlink(path, link, callback) { callback(enosys()); },
+ truncate(path, length, callback) { callback(enosys()); },
+ unlink(path, callback) { callback(enosys()); },
+ utimes(path, atime, mtime, callback) { callback(enosys()); },
+ };
+ }
+
+ if (!globalThis.process) {
+ globalThis.process = {
+ getuid() { return -1; },
+ getgid() { return -1; },
+ geteuid() { return -1; },
+ getegid() { return -1; },
+ getgroups() { throw enosys(); },
+ pid: -1,
+ ppid: -1,
+ umask() { throw enosys(); },
+ cwd() { throw enosys(); },
+ chdir() { throw enosys(); },
+ }
+ }
+
+ if (!globalThis.path) {
+ globalThis.path = {
+ resolve(...pathSegments) {
+ return pathSegments.join("/");
+ }
+ }
+ }
+
+ if (!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 encoder = new TextEncoder("utf-8");
+ const decoder = new TextDecoder("utf-8");
+
+ globalThis.Go = class {
+ constructor() {
+ this.argv = ["js"];
+ this.env = {};
+ this.exit = (code) => {
+ if (code !== 0) {
+ console.warn("exit code:", code);
+ }
+ };
+ this._exitPromise = new Promise((resolve) => {
+ this._resolveExitPromise = resolve;
+ });
+ this._pendingEvent = null;
+ this._scheduledTimeouts = new Map();
+ this._nextCallbackTimeoutID = 1;
+
+ const setInt64 = (addr, v) => {
+ this.mem.setUint32(addr + 0, v, true);
+ this.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true);
+ }
+
+ const setInt32 = (addr, v) => {
+ this.mem.setUint32(addr + 0, v, true);
+ }
+
+ const getInt64 = (addr) => {
+ const low = this.mem.getUint32(addr + 0, true);
+ const high = this.mem.getInt32(addr + 4, true);
+ return low + high * 4294967296;
+ }
+
+ const loadValue = (addr) => {
+ const f = this.mem.getFloat64(addr, true);
+ if (f === 0) {
+ return undefined;
+ }
+ if (!isNaN(f)) {
+ return f;
+ }
+
+ const id = this.mem.getUint32(addr, true);
+ return this._values[id];
+ }
+
+ const storeValue = (addr, v) => {
+ const nanHead = 0x7FF80000;
+
+ if (typeof v === "number" && v !== 0) {
+ if (isNaN(v)) {
+ this.mem.setUint32(addr + 4, nanHead, true);
+ this.mem.setUint32(addr, 0, true);
+ return;
+ }
+ this.mem.setFloat64(addr, v, true);
+ return;
+ }
+
+ if (v === undefined) {
+ this.mem.setFloat64(addr, 0, true);
+ return;
+ }
+
+ let id = this._ids.get(v);
+ if (id === undefined) {
+ id = this._idPool.pop();
+ if (id === undefined) {
+ id = this._values.length;
+ }
+ this._values[id] = v;
+ this._goRefCounts[id] = 0;
+ this._ids.set(v, id);
+ }
+ this._goRefCounts[id]++;
+ let typeFlag = 0;
+ switch (typeof v) {
+ case "object":
+ if (v !== null) {
+ typeFlag = 1;
+ }
+ break;
+ case "string":
+ typeFlag = 2;
+ break;
+ case "symbol":
+ typeFlag = 3;
+ break;
+ case "function":
+ typeFlag = 4;
+ break;
+ }
+ this.mem.setUint32(addr + 4, nanHead | typeFlag, true);
+ this.mem.setUint32(addr, id, true);
+ }
+
+ const loadSlice = (addr) => {
+ const array = getInt64(addr + 0);
+ const len = getInt64(addr + 8);
+ return new Uint8Array(this._inst.exports.mem.buffer, array, len);
+ }
+
+ const loadSliceOfValues = (addr) => {
+ const array = getInt64(addr + 0);
+ const len = getInt64(addr + 8);
+ const a = new Array(len);
+ for (let i = 0; i < len; i++) {
+ a[i] = loadValue(array + i * 8);
+ }
+ return a;
+ }
+
+ const loadString = (addr) => {
+ const saddr = getInt64(addr + 0);
+ const len = getInt64(addr + 8);
+ return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));
+ }
+
+ const testCallExport = (a, b) => {
+ this._inst.exports.testExport0();
+ return this._inst.exports.testExport(a, b);
+ }
+
+ const timeOrigin = Date.now() - performance.now();
+ this.importObject = {
+ _gotest: {
+ add: (a, b) => a + b,
+ callExport: testCallExport,
+ },
+ gojs: {
+ // Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)
+ // may synchronously trigger a Go event handler. This makes Go code get executed in the middle of the imported
+ // function. A goroutine can switch to a new stack if the current stack is too small (see morestack function).
+ // This changes the SP, thus we have to update the SP used by the imported function.
+
+ // func wasmExit(code int32)
+ "runtime.wasmExit": (sp) => {
+ sp >>>= 0;
+ const code = this.mem.getInt32(sp + 8, true);
+ this.exited = true;
+ delete this._inst;
+ delete this._values;
+ delete this._goRefCounts;
+ delete this._ids;
+ delete this._idPool;
+ this.exit(code);
+ },
+
+ // func wasmWrite(fd uintptr, p unsafe.Pointer, n int32)
+ "runtime.wasmWrite": (sp) => {
+ sp >>>= 0;
+ const fd = getInt64(sp + 8);
+ const p = getInt64(sp + 16);
+ const n = this.mem.getInt32(sp + 24, true);
+ fs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));
+ },
+
+ // func resetMemoryDataView()
+ "runtime.resetMemoryDataView": (sp) => {
+ sp >>>= 0;
+ this.mem = new DataView(this._inst.exports.mem.buffer);
+ },
+
+ // func nanotime1() int64
+ "runtime.nanotime1": (sp) => {
+ sp >>>= 0;
+ setInt64(sp + 8, (timeOrigin + performance.now()) * 1000000);
+ },
+
+ // func walltime() (sec int64, nsec int32)
+ "runtime.walltime": (sp) => {
+ sp >>>= 0;
+ const msec = (new Date).getTime();
+ setInt64(sp + 8, msec / 1000);
+ this.mem.setInt32(sp + 16, (msec % 1000) * 1000000, true);
+ },
+
+ // func scheduleTimeoutEvent(delay int64) int32
+ "runtime.scheduleTimeoutEvent": (sp) => {
+ sp >>>= 0;
+ const id = this._nextCallbackTimeoutID;
+ this._nextCallbackTimeoutID++;
+ this._scheduledTimeouts.set(id, setTimeout(
+ () => {
+ this._resume();
+ while (this._scheduledTimeouts.has(id)) {
+ // for some reason Go failed to register the timeout event, log and try again
+ // (temporary workaround for https://github.com/golang/go/issues/28975)
+ console.warn("scheduleTimeoutEvent: missed timeout event");
+ this._resume();
+ }
+ },
+ getInt64(sp + 8),
+ ));
+ this.mem.setInt32(sp + 16, id, true);
+ },
+
+ // func clearTimeoutEvent(id int32)
+ "runtime.clearTimeoutEvent": (sp) => {
+ sp >>>= 0;
+ const id = this.mem.getInt32(sp + 8, true);
+ clearTimeout(this._scheduledTimeouts.get(id));
+ this._scheduledTimeouts.delete(id);
+ },
+
+ // func getRandomData(r []byte)
+ "runtime.getRandomData": (sp) => {
+ sp >>>= 0;
+ crypto.getRandomValues(loadSlice(sp + 8));
+ },
+
+ // func finalizeRef(v ref)
+ "syscall/js.finalizeRef": (sp) => {
+ sp >>>= 0;
+ const id = this.mem.getUint32(sp + 8, true);
+ this._goRefCounts[id]--;
+ if (this._goRefCounts[id] === 0) {
+ const v = this._values[id];
+ this._values[id] = null;
+ this._ids.delete(v);
+ this._idPool.push(id);
+ }
+ },
+
+ // func stringVal(value string) ref
+ "syscall/js.stringVal": (sp) => {
+ sp >>>= 0;
+ storeValue(sp + 24, loadString(sp + 8));
+ },
+
+ // func valueGet(v ref, p string) ref
+ "syscall/js.valueGet": (sp) => {
+ sp >>>= 0;
+ const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));
+ sp = this._inst.exports.getsp() >>> 0; // see comment above
+ storeValue(sp + 32, result);
+ },
+
+ // func valueSet(v ref, p string, x ref)
+ "syscall/js.valueSet": (sp) => {
+ sp >>>= 0;
+ Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));
+ },
+
+ // func valueDelete(v ref, p string)
+ "syscall/js.valueDelete": (sp) => {
+ sp >>>= 0;
+ Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));
+ },
+
+ // func valueIndex(v ref, i int) ref
+ "syscall/js.valueIndex": (sp) => {
+ sp >>>= 0;
+ storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));
+ },
+
+ // valueSetIndex(v ref, i int, x ref)
+ "syscall/js.valueSetIndex": (sp) => {
+ sp >>>= 0;
+ Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));
+ },
+
+ // func valueCall(v ref, m string, args []ref) (ref, bool)
+ "syscall/js.valueCall": (sp) => {
+ sp >>>= 0;
+ try {
+ const v = loadValue(sp + 8);
+ const m = Reflect.get(v, loadString(sp + 16));
+ const args = loadSliceOfValues(sp + 32);
+ const result = Reflect.apply(m, v, args);
+ sp = this._inst.exports.getsp() >>> 0; // see comment above
+ storeValue(sp + 56, result);
+ this.mem.setUint8(sp + 64, 1);
+ } catch (err) {
+ sp = this._inst.exports.getsp() >>> 0; // see comment above
+ storeValue(sp + 56, err);
+ this.mem.setUint8(sp + 64, 0);
+ }
+ },
+
+ // func valueInvoke(v ref, args []ref) (ref, bool)
+ "syscall/js.valueInvoke": (sp) => {
+ sp >>>= 0;
+ try {
+ const v = loadValue(sp + 8);
+ const args = loadSliceOfValues(sp + 16);
+ const result = Reflect.apply(v, undefined, args);
+ sp = this._inst.exports.getsp() >>> 0; // see comment above
+ storeValue(sp + 40, result);
+ this.mem.setUint8(sp + 48, 1);
+ } catch (err) {
+ sp = this._inst.exports.getsp() >>> 0; // see comment above
+ storeValue(sp + 40, err);
+ this.mem.setUint8(sp + 48, 0);
+ }
+ },
+
+ // func valueNew(v ref, args []ref) (ref, bool)
+ "syscall/js.valueNew": (sp) => {
+ sp >>>= 0;
+ try {
+ const v = loadValue(sp + 8);
+ const args = loadSliceOfValues(sp + 16);
+ const result = Reflect.construct(v, args);
+ sp = this._inst.exports.getsp() >>> 0; // see comment above
+ storeValue(sp + 40, result);
+ this.mem.setUint8(sp + 48, 1);
+ } catch (err) {
+ sp = this._inst.exports.getsp() >>> 0; // see comment above
+ storeValue(sp + 40, err);
+ this.mem.setUint8(sp + 48, 0);
+ }
+ },
+
+ // func valueLength(v ref) int
+ "syscall/js.valueLength": (sp) => {
+ sp >>>= 0;
+ setInt64(sp + 16, parseInt(loadValue(sp + 8).length));
+ },
+
+ // valuePrepareString(v ref) (ref, int)
+ "syscall/js.valuePrepareString": (sp) => {
+ sp >>>= 0;
+ const str = encoder.encode(String(loadValue(sp + 8)));
+ storeValue(sp + 16, str);
+ setInt64(sp + 24, str.length);
+ },
+
+ // valueLoadString(v ref, b []byte)
+ "syscall/js.valueLoadString": (sp) => {
+ sp >>>= 0;
+ const str = loadValue(sp + 8);
+ loadSlice(sp + 16).set(str);
+ },
+
+ // func valueInstanceOf(v ref, t ref) bool
+ "syscall/js.valueInstanceOf": (sp) => {
+ sp >>>= 0;
+ this.mem.setUint8(sp + 24, (loadValue(sp + 8) instanceof loadValue(sp + 16)) ? 1 : 0);
+ },
+
+ // func copyBytesToGo(dst []byte, src ref) (int, bool)
+ "syscall/js.copyBytesToGo": (sp) => {
+ sp >>>= 0;
+ const dst = loadSlice(sp + 8);
+ const src = loadValue(sp + 32);
+ if (!(src instanceof Uint8Array || src instanceof Uint8ClampedArray)) {
+ this.mem.setUint8(sp + 48, 0);
+ return;
+ }
+ const toCopy = src.subarray(0, dst.length);
+ dst.set(toCopy);
+ setInt64(sp + 40, toCopy.length);
+ this.mem.setUint8(sp + 48, 1);
+ },
+
+ // func copyBytesToJS(dst ref, src []byte) (int, bool)
+ "syscall/js.copyBytesToJS": (sp) => {
+ sp >>>= 0;
+ const dst = loadValue(sp + 8);
+ const src = loadSlice(sp + 16);
+ if (!(dst instanceof Uint8Array || dst instanceof Uint8ClampedArray)) {
+ this.mem.setUint8(sp + 48, 0);
+ return;
+ }
+ const toCopy = src.subarray(0, dst.length);
+ dst.set(toCopy);
+ setInt64(sp + 40, toCopy.length);
+ this.mem.setUint8(sp + 48, 1);
+ },
+
+ "debug": (value) => {
+ console.log(value);
+ },
+ }
+ };
+ }
+
+ async run(instance) {
+ if (!(instance instanceof WebAssembly.Instance)) {
+ throw new Error("Go.run: WebAssembly.Instance expected");
+ }
+ this._inst = instance;
+ this.mem = new DataView(this._inst.exports.mem.buffer);
+ this._values = [ // JS values that Go currently has references to, indexed by reference id
+ NaN,
+ 0,
+ null,
+ true,
+ false,
+ globalThis,
+ this,
+ ];
+ this._goRefCounts = new Array(this._values.length).fill(Infinity); // number of references that Go has to a JS value, indexed by reference id
+ this._ids = new Map([ // mapping from JS values to reference ids
+ [0, 1],
+ [null, 2],
+ [true, 3],
+ [false, 4],
+ [globalThis, 5],
+ [this, 6],
+ ]);
+ this._idPool = []; // unused ids that have been garbage collected
+ this.exited = false; // whether the Go program has exited
+
+ // Pass command line arguments and environment variables to WebAssembly by writing them to the linear memory.
+ let offset = 4096;
+
+ const strPtr = (str) => {
+ const ptr = offset;
+ const bytes = encoder.encode(str + "\0");
+ new Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes);
+ offset += bytes.length;
+ if (offset % 8 !== 0) {
+ offset += 8 - (offset % 8);
+ }
+ return ptr;
+ };
+
+ const argc = this.argv.length;
+
+ const argvPtrs = [];
+ this.argv.forEach((arg) => {
+ argvPtrs.push(strPtr(arg));
+ });
+ argvPtrs.push(0);
+
+ const keys = Object.keys(this.env).sort();
+ keys.forEach((key) => {
+ argvPtrs.push(strPtr(`${key}=${this.env[key]}`));
+ });
+ argvPtrs.push(0);
+
+ const argv = offset;
+ argvPtrs.forEach((ptr) => {
+ this.mem.setUint32(offset, ptr, true);
+ this.mem.setUint32(offset + 4, 0, true);
+ offset += 8;
+ });
+
+ // The linker guarantees global data starts from at least wasmMinDataAddr.
+ // Keep in sync with cmd/link/internal/ld/data.go:wasmMinDataAddr.
+ const wasmMinDataAddr = 4096 + 8192;
+ if (offset >= wasmMinDataAddr) {
+ throw new Error("total length of command line and environment variables exceeds limit");
+ }
+
+ this._inst.exports.run(argc, argv);
+ if (this.exited) {
+ this._resolveExitPromise();
+ }
+ await this._exitPromise;
+ }
+
+ _resume() {
+ if (this.exited) {
+ throw new Error("Go program has already exited");
+ }
+ this._inst.exports.resume();
+ if (this.exited) {
+ this._resolveExitPromise();
+ }
+ }
+
+ _makeFuncWrapper(id) {
+ const go = this;
+ return function () {
+ const event = { id: id, this: this, args: arguments };
+ go._pendingEvent = event;
+ go._resume();
+ return event.result;
+ };
+ }
+ }
+})();
diff --git a/tqweb/worker.js b/tqweb/worker.js
new file mode 100644
index 0000000..e04a585
--- /dev/null
+++ b/tqweb/worker.js
@@ -0,0 +1,14 @@
+importScripts('wasm_exec.js');
+importScripts('sw.js');
+
+const wasm = 'api.wasm';
+
+addEventListener('install', (event) => {
+ event.waitUntil(caches.open('api').then((cache) => cache.add(wasm)));
+});
+
+addEventListener('activate', (event) => {
+ event.waitUntil(clients.claim());
+});
+
+registerWasmHTTPListener(wasm, { base: 'api' });
diff --git a/vendor/github.com/hack-pad/safejs/.env b/vendor/github.com/hack-pad/safejs/.env
new file mode 100644
index 0000000..13468cb
--- /dev/null
+++ b/vendor/github.com/hack-pad/safejs/.env
@@ -0,0 +1,3 @@
+# Env file defines useful environment variables for editors.
+GOOS=js
+GOARCH=wasm
diff --git a/vendor/github.com/hack-pad/safejs/.gitignore b/vendor/github.com/hack-pad/safejs/.gitignore
new file mode 100644
index 0000000..e87afd9
--- /dev/null
+++ b/vendor/github.com/hack-pad/safejs/.gitignore
@@ -0,0 +1 @@
+/*.out
diff --git a/vendor/github.com/hack-pad/safejs/.golangci.yml b/vendor/github.com/hack-pad/safejs/.golangci.yml
new file mode 100644
index 0000000..423e830
--- /dev/null
+++ b/vendor/github.com/hack-pad/safejs/.golangci.yml
@@ -0,0 +1,22 @@
+linters:
+ enable:
+ # Default linters, plus these:
+ - exportloopref
+ - gocognit
+ - goconst
+ - gocritic
+ - gofmt
+ - gosec
+ - misspell
+ - paralleltest
+ - revive
+
+issues:
+ include:
+ # Re-enable default excluded rules
+ - EXC0001
+ - EXC0002
+ - EXC0012
+ - EXC0013
+ - EXC0014
+ - EXC0015
diff --git a/vendor/github.com/hack-pad/safejs/LICENSE b/vendor/github.com/hack-pad/safejs/LICENSE
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/vendor/github.com/hack-pad/safejs/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/vendor/github.com/hack-pad/safejs/Makefile b/vendor/github.com/hack-pad/safejs/Makefile
new file mode 100644
index 0000000..124a6e1
--- /dev/null
+++ b/vendor/github.com/hack-pad/safejs/Makefile
@@ -0,0 +1,39 @@
+SHELL := /usr/bin/env bash
+BROWSERTEST_VERSION = v0.6
+LINT_VERSION = 1.50.1
+GO_BIN = $(shell printf '%s/bin' "$$(go env GOPATH)")
+
+.PHONY: all
+all: lint test
+
+.PHONY: lint-deps
+lint-deps:
+ @if ! which golangci-lint >/dev/null || [[ "$$(golangci-lint version 2>&1)" != *${LINT_VERSION}* ]]; then \
+ curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${GO_BIN}" v${LINT_VERSION}; \
+ fi
+
+.PHONY: lint
+lint: lint-deps
+ "${GO_BIN}/golangci-lint" run
+ GOOS=js GOARCH=wasm "${GO_BIN}/golangci-lint" run
+
+.PHONY: test-deps
+test-deps:
+ @if [[ ! -f "${GO_BIN}/go_js_wasm_exec" ]]; then \
+ set -ex; \
+ go install github.com/agnivade/wasmbrowsertest@${BROWSERTEST_VERSION}; \
+ mv "${GO_BIN}/wasmbrowsertest" "${GO_BIN}/go_js_wasm_exec"; \
+ fi
+
+.PHONY: test
+test: test-deps
+ go test wasm_tags_test.go # Verify build tags and whatnot first
+ go test -race -coverprofile=native-cover.out ./... # Test non-js side
+ GOOS=js GOARCH=wasm go test -coverprofile=js-cover.out -covermode=atomic ./... # Test js side
+ { echo 'mode: atomic'; cat *-cover.out | grep -v '^mode'; } > cover.out && rm *-cover.out # Combine JS and non-JS coverage.
+ go tool cover -func cover.out | grep total:
+
+.PHONY: test-publish-coverage
+test-publish-coverage:
+ go install github.com/mattn/goveralls@v0.0.11
+ COVERALLS_TOKEN=$$GITHUB_TOKEN goveralls -coverprofile="cover.out" -service=github
diff --git a/vendor/github.com/hack-pad/safejs/README.md b/vendor/github.com/hack-pad/safejs/README.md
new file mode 100644
index 0000000..dd7c104
--- /dev/null
+++ b/vendor/github.com/hack-pad/safejs/README.md
@@ -0,0 +1,91 @@
+# SafeJS [](https://pkg.go.dev/github.com/hack-pad/safejs) [](https://github.com/hack-pad/safejs/actions/workflows/ci.yml) [](https://coveralls.io/github/hack-pad/safejs?branch=main)
+
+A safer, drop-in replacement for Go's `syscall/js` JavaScript package.
+
+## What makes it safer?
+
+Today, `syscall/js` panics when the JavaScript runtime throws errors.
+While sensible in a JavaScript runtime, [Go libraries should avoid using `panic`](https://go.dev/doc/effective_go#panic).
+
+SafeJS provides a nearly identical API to `syscall/js`, but returns errors instead of panicking.
+
+Although returned errors aren't pretty, they make it much easier to integrate with existing Go tools and code patterns.
+
+#### Backward compatibility
+
+This package uses the same backward compatibility guarantee as `syscall/js`.
+
+In an effort to align with the Go standard library API, some breaking changes may become necessary and receive their own minor version bumps.
+
+## Quick start
+
+1. Get `safejs`:
+```
+go get github.com/hack-pad/safejs
+```
+2. Import `safejs`:
+```go
+import "github.com/hack-pad/safejs"
+```
+3. Replace uses of `syscall/js` with the `safejs` alternative.
+
+Before:
+```go
+//go:build js && wasm
+
+package buttons
+
+import "syscall/js"
+
+// InsertButton creates a new button, adds it to 'container', and returns it. Usually.
+func InsertButton(container js.Value) js.Value {
+ // *whisper:* There's a good chance it could panic! Eh, probably don't need to document it, right?
+ dom := js.Global().Get("document") // BOOM!
+ button := dom.Call("createElement", "button") // BANG!
+ container.Call("appendChild", button) // BAM!
+ return button
+}
+```
+
+After:
+```go
+//go:build js && wasm
+
+package buttons
+
+import "github.com/hack-pad/safejs"
+
+// InsertButton creates a new button, adds it to 'container', and returns the button or the first error.
+func InsertButton(container safejs.Value) (safejs.Value, error) {
+ dom, err := safejs.Global().Get("document")
+ if err != nil {
+ return err
+ }
+ button, err := dom.Call("createElement", "button")
+ if err != nil {
+ return err
+ }
+ _, err = container.Call("appendChild", button)
+ if err != nil {
+ return err
+ }
+ return button, nil
+}
+```
+
+## Even safer
+
+For additional JavaScript safety, use the `jsguard` linter too.
+
+`jsguard` reports the locations of unsafe JavaScript calls, which should be replaced with calls to SafeJS.
+
+```bash
+# When installed without specifying a version, uses the go.mod version.
+go install github.com/hack-pad/safejs/jsguard/cmd/jsguard
+export GOOS=js GOARCH=wasm
+jsguard ./...
+```
+
+It *does not* report use of types like `js.Value` -- only function calls on those types.
+
+This makes it easy to integrate SafeJS into existing libraries which expose only standard library types.
diff --git a/vendor/github.com/hack-pad/safejs/bytes.go b/vendor/github.com/hack-pad/safejs/bytes.go
new file mode 100644
index 0000000..7b42a3f
--- /dev/null
+++ b/vendor/github.com/hack-pad/safejs/bytes.go
@@ -0,0 +1,27 @@
+//go:build js && wasm
+
+package safejs
+
+import (
+ "syscall/js"
+
+ "github.com/hack-pad/safejs/internal/catch"
+)
+
+// CopyBytesToGo copies bytes from src to dst.
+// Returns the number of bytes copied, which is the minimum of the lengths of src and dst.
+// Returns an error if src is not an Uint8Array or Uint8ClampedArray.
+func CopyBytesToGo(dst []byte, src Value) (int, error) {
+ return catch.Try(func() int {
+ return js.CopyBytesToGo(dst, src.jsValue)
+ })
+}
+
+// CopyBytesToJS copies bytes from src to dst.
+// Returns the number of bytes copied, which is the minimum of the lengths of src and dst.
+// Returns an error if dst is not an Uint8Array or Uint8ClampedArray.
+func CopyBytesToJS(dst Value, src []byte) (int, error) {
+ return catch.Try(func() int {
+ return js.CopyBytesToJS(dst.jsValue, src)
+ })
+}
diff --git a/vendor/github.com/hack-pad/safejs/doc.go b/vendor/github.com/hack-pad/safejs/doc.go
new file mode 100644
index 0000000..ca77820
--- /dev/null
+++ b/vendor/github.com/hack-pad/safejs/doc.go
@@ -0,0 +1,8 @@
+//go:build js && wasm
+
+/*
+Package safejs provides guardrails around the [syscall/js] package, like turning thrown exceptions into errors.
+
+Since [syscall/js] is experimental, this package may have breaking changes to stay aligned with the latest versions of Go.
+*/
+package safejs
diff --git a/vendor/github.com/hack-pad/safejs/error.go b/vendor/github.com/hack-pad/safejs/error.go
new file mode 100644
index 0000000..fa81a65
--- /dev/null
+++ b/vendor/github.com/hack-pad/safejs/error.go
@@ -0,0 +1,23 @@
+//go:build js && wasm
+
+package safejs
+
+import (
+ "syscall/js"
+
+ "github.com/hack-pad/safejs/internal/catch"
+)
+
+// Error wraps a JavaScript error.
+type Error struct {
+ err js.Error
+}
+
+// Error implements the error interface.
+func (e Error) Error() string {
+ errStr, err := catch.Try(e.err.Error)
+ if err != nil {
+ return "failed generating error message: " + err.Error()
+ }
+ return errStr
+}
diff --git a/vendor/github.com/hack-pad/safejs/func.go b/vendor/github.com/hack-pad/safejs/func.go
new file mode 100644
index 0000000..44bc4ec
--- /dev/null
+++ b/vendor/github.com/hack-pad/safejs/func.go
@@ -0,0 +1,45 @@
+//go:build js && wasm
+
+package safejs
+
+import (
+ "syscall/js"
+
+ "github.com/hack-pad/safejs/internal/catch"
+)
+
+// Func is a wrapped Go function to be called by JavaScript.
+type Func struct {
+ fn js.Func
+}
+
+// FuncOf returns a function to be used by JavaScript. See [js.FuncOf] for details.
+func FuncOf(fn func(this Value, args []Value) any) (Func, error) {
+ jsFunc, err := toJSFunc(fn)
+ return Func{
+ fn: jsFunc,
+ }, err
+}
+
+func toJSFunc(fn func(this Value, args []Value) any) (js.Func, error) {
+ jsFunc := func(this js.Value, args []js.Value) any {
+ result := fn(Safe(this), toValues(args))
+ return toJSValue(result)
+ }
+ return catch.Try(func() js.Func {
+ return js.FuncOf(jsFunc)
+ })
+}
+
+// Release frees up resources allocated for the function. The function must not be invoked after calling Release.
+// It is allowed to call Release while the function is still running.
+func (f Func) Release() {
+ f.fn.Release()
+}
+
+// Value returns this Func's inner Value. For example, using value.Invoke() calls the function.
+//
+// Equivalent to accessing [js.Func]'s embedded [js.Value] field, only as a safejs type.
+func (f Func) Value() Value {
+ return Safe(f.fn.Value)
+}
diff --git a/vendor/github.com/hack-pad/safejs/global.go b/vendor/github.com/hack-pad/safejs/global.go
new file mode 100644
index 0000000..e46c3f6
--- /dev/null
+++ b/vendor/github.com/hack-pad/safejs/global.go
@@ -0,0 +1,42 @@
+//go:build js && wasm
+
+package safejs
+
+import (
+ "fmt"
+ "syscall/js"
+)
+
+// Global returns the JavaScript global object, usually "window" or "global".
+func Global() Value {
+ return Safe(js.Global())
+}
+
+// MustGetGlobal fetches the given global, then verifies it is truthy. Panics on error or falsy values.
+// This is intended for simple global variable initialization, like preparing classes for later instantiation.
+//
+// For example:
+//
+// var jsUint8Array = safejs.MustGetGlobal("Uint8Array")
+func MustGetGlobal(property string) Value {
+ value, err := getGlobal(property)
+ if err != nil {
+ panic(err)
+ }
+ return value
+}
+
+func getGlobal(property string) (Value, error) {
+ value, err := Global().Get(property)
+ if err != nil {
+ return Value{}, err
+ }
+ truthy, err := value.Truthy()
+ if err != nil {
+ return Value{}, err
+ }
+ if !truthy {
+ return Value{}, fmt.Errorf("global %q is not defined", property)
+ }
+ return value, nil
+}
diff --git a/vendor/github.com/hack-pad/safejs/internal/catch/catch.go b/vendor/github.com/hack-pad/safejs/internal/catch/catch.go
new file mode 100644
index 0000000..538daf3
--- /dev/null
+++ b/vendor/github.com/hack-pad/safejs/internal/catch/catch.go
@@ -0,0 +1,47 @@
+//go:build js && wasm
+
+// Package catch runs functions and returns panic values as errors instead.
+package catch
+
+import (
+ "fmt"
+ "syscall/js"
+
+ "github.com/hack-pad/safejs/internal/stackerr"
+)
+
+// Try runs fn and returns the result. If fn panicked, the panic value is returned as an error instead.
+func Try[Result any](fn func() Result) (result Result, err error) {
+ defer recoverErr(&err)
+ result = fn()
+ return
+}
+
+// TrySideEffect is like Try, but does not have a return value.
+func TrySideEffect(fn func()) (err error) {
+ defer recoverErr(&err)
+ fn()
+ return
+}
+
+func recoverErr(err *error) {
+ value := recover()
+ valueErr := recoverValueToError(value)
+ if valueErr != nil {
+ *err = stackerr.WithStack(valueErr)
+ }
+}
+
+func recoverValueToError(value any) error {
+ if value == nil {
+ return nil
+ }
+ switch value := value.(type) {
+ case error:
+ return value
+ case js.Value:
+ return js.Error{Value: value}
+ default:
+ return fmt.Errorf("%+v", value)
+ }
+}
diff --git a/vendor/github.com/hack-pad/safejs/internal/stackerr/stackerr.go b/vendor/github.com/hack-pad/safejs/internal/stackerr/stackerr.go
new file mode 100644
index 0000000..d341f22
--- /dev/null
+++ b/vendor/github.com/hack-pad/safejs/internal/stackerr/stackerr.go
@@ -0,0 +1,79 @@
+//go:build js && wasm
+
+// Package stackerr adds stack traces to verbose error messages.
+package stackerr
+
+import (
+ "fmt"
+ "runtime"
+ "strings"
+)
+
+type stackError struct {
+ err error
+ stack *stacktrace
+}
+
+// WithStack returns 'err' with a stack trace in its verbose formatter output.
+// Returns nil if err is nil.
+func WithStack(err error) error {
+ if err == nil {
+ return nil
+ }
+
+ return &stackError{
+ err: err,
+ stack: collectStacktrace(3),
+ }
+}
+
+func (s *stackError) Error() string {
+ return s.err.Error()
+}
+
+func (s *stackError) Unwrap() error {
+ return s.err
+}
+
+func (s *stackError) Format(f fmt.State, verb rune) {
+ switch verb {
+ case 'v':
+ if f.Flag('+') {
+ fmt.Fprintf(f, "%+v\n%s", s.err, s.stack)
+ return
+ }
+ fmt.Fprint(f, s.Error())
+ case 's':
+ fmt.Fprint(f, s.Error())
+ case 'q':
+ fmt.Fprintf(f, "%q", s.Error())
+ }
+}
+
+type stacktrace struct {
+ callers []uintptr
+}
+
+func collectStacktrace(skip int) *stacktrace {
+ const (
+ maxFrames = 32
+ )
+ pc := make([]uintptr, maxFrames)
+ n := runtime.Callers(1+skip, pc)
+ return &stacktrace{
+ callers: pc[:n],
+ }
+}
+
+func (s *stacktrace) String() string {
+ var sb strings.Builder
+ frames := runtime.CallersFrames(s.callers)
+ for frame, next := frames.Next(); next; frame, next = frames.Next() {
+ funcName := "unknown"
+ if frame.Func != nil {
+ funcName = frame.Func.Name()
+ }
+ sb.WriteString(fmt.Sprintf("%s\n\t%s:%d\n", funcName, frame.File, frame.Line))
+ }
+ return sb.String()
+}
diff --git a/vendor/github.com/hack-pad/safejs/type.go b/vendor/github.com/hack-pad/safejs/type.go
new file mode 100644
index 0000000..62db035
--- /dev/null
+++ b/vendor/github.com/hack-pad/safejs/type.go
@@ -0,0 +1,25 @@
+//go:build js && wasm
+
+package safejs
+
+import "syscall/js"
+
+// Type represents the JavaScript type of a Value.
+type Type int
+
+// Available JavaScript types
+const (
+ TypeUndefined = Type(js.TypeUndefined)
+ TypeNull = Type(js.TypeNull)
+ TypeBoolean = Type(js.TypeBoolean)
+ TypeNumber = Type(js.TypeNumber)
+ TypeString = Type(js.TypeString)
+ TypeSymbol = Type(js.TypeSymbol)
+ TypeObject = Type(js.TypeObject)
+ TypeFunction = Type(js.TypeFunction)
+)
+
+func (t Type) String() string {
+ // String() has a panic line, however it should be impossible to hit barring memory corruption
+ return js.Type(t).String()
+}
diff --git a/vendor/github.com/hack-pad/safejs/value.go b/vendor/github.com/hack-pad/safejs/value.go
new file mode 100644
index 0000000..c4542f5
--- /dev/null
+++ b/vendor/github.com/hack-pad/safejs/value.go
@@ -0,0 +1,242 @@
+//go:build js && wasm
+
+package safejs
+
+import (
+ "fmt"
+ "syscall/js"
+
+ "github.com/hack-pad/safejs/internal/catch"
+)
+
+// Value is a safer version of js.Value. Any panic returns an error instead.
+type Value struct {
+ jsValue js.Value
+}
+
+// Safe wraps a js.Value into a safejs.Value.
+// Ideal for use in libraries where exposed types must match the standard library.
+func Safe(value js.Value) Value {
+ return Value{
+ jsValue: value,
+ }
+}
+
+// Unsafe unwraps a safejs.Value back into its js.Value.
+// Ideal for use in libraries where exposed types must match the standard library.
+func Unsafe(value Value) js.Value {
+ return value.jsValue
+}
+
+// Null returns the JavaScript value of "null".
+func Null() Value {
+ return Safe(js.Null())
+}
+
+// Undefined returns the JavaScript value of "undefined".
+func Undefined() Value {
+ return Safe(js.Undefined())
+}
+
+func toJSValue(jsValue any) any {
+ switch value := jsValue.(type) {
+ case Value:
+ return value.jsValue
+ case Func:
+ return value.fn
+ case Error:
+ return value.err
+ case map[string]any:
+ newValue := make(map[string]any)
+ for mapKey, mapValue := range value {
+ newValue[mapKey] = toJSValue(mapValue)
+ }
+ return newValue
+ case []any:
+ newValue := make([]any, len(value))
+ for i, arg := range value {
+ newValue[i] = toJSValue(arg)
+ }
+ return newValue
+ default:
+ return jsValue
+ }
+}
+
+func toJSValues(args []any) []any {
+ return toJSValue(args).([]any)
+}
+
+func toValues(args []js.Value) []Value {
+ newArgs := make([]Value, len(args))
+ for i, arg := range args {
+ newArgs[i] = Safe(arg)
+ }
+ return newArgs
+}
+
+// ValueOf returns value as a JavaScript value. See [js.ValueOf] for details.
+func ValueOf(value any) (Value, error) {
+ jsValue, err := catch.Try(func() js.Value {
+ return js.ValueOf(value)
+ })
+ return Safe(jsValue), err
+}
+
+// Bool attempts to convert this value into a boolean, otherwise returns an error.
+func (v Value) Bool() (bool, error) {
+ return catch.Try(v.jsValue.Bool)
+}
+
+// Call does a JavaScript call to the method m of value v with the given arguments.
+// The arguments are mapped to JavaScript values according to the ValueOf function.
+// Returns an error if v has no method m, the arguments failed to map to JavaScript values, or the function throws an error.
+func (v Value) Call(m string, args ...any) (Value, error) {
+ args = toJSValues(args)
+ return catch.Try(func() Value {
+ return Safe(v.jsValue.Call(m, args...))
+ })
+}
+
+// Delete deletes the JavaScript property p of value v. Returns an error if v is not a JavaScript object.
+func (v Value) Delete(p string) error {
+ return catch.TrySideEffect(func() {
+ v.jsValue.Delete(p)
+ })
+}
+
+// Equal reports whether v and w are equal according to JavaScript's === operator.
+func (v Value) Equal(w Value) bool {
+ return v.jsValue.Equal(w.jsValue)
+}
+
+// Float returns the value v as a float64. Returns an error if v is not a JavaScript number.
+func (v Value) Float() (float64, error) {
+ return catch.Try(v.jsValue.Float)
+}
+
+// Get returns the JavaScript property p of value v. Returns an error if v is not a JavaScript object.
+func (v Value) Get(p string) (Value, error) {
+ return catch.Try(func() Value {
+ return Safe(v.jsValue.Get(p))
+ })
+}
+
+// Index returns JavaScript index i of value v. Returns an error if v is not a JavaScript object.
+func (v Value) Index(i int) (Value, error) {
+ return catch.Try(func() Value {
+ return Safe(v.jsValue.Index(i))
+ })
+}
+
+// InstanceOf reports whether v is an instance of type t according to JavaScript's instanceof operator.
+// Returns an error if v is not a constructable type.
+func (v Value) InstanceOf(t Value) (bool, error) {
+ // Type failures in JS throw "TypeError: Right-hand side of 'instanceof' is not an object"
+ // so catch those cases here.
+ //
+ // A valid type is a function with a field "prototype" which is an object.
+ if t.Type() != TypeFunction {
+ return false, fmt.Errorf("invalid type for instanceof: %v", t.Type())
+ }
+ prototype, err := t.Get("prototype")
+ if err != nil {
+ return false, fmt.Errorf("invalid constructor type for instanceof: %v", err)
+ } else if prototype.Type() != TypeObject {
+ return false, fmt.Errorf("invalid constructor type for instanceof: %v", prototype.Type())
+ }
+ return catch.Try(func() bool {
+ return v.jsValue.InstanceOf(t.jsValue)
+ })
+}
+
+// Int returns the value v truncated to an int. Returns an error if v is not a JavaScript number.
+func (v Value) Int() (int, error) {
+ return catch.Try(v.jsValue.Int)
+}
+
+// Invoke does a JavaScript call of the value v with the given arguments.
+// The arguments get mapped to JavaScript values according to the ValueOf function.
+// Returns an error if v is not a JavaScript function, the arguments failed to map to JavaScript values, or the function throws an error.
+func (v Value) Invoke(args ...any) (Value, error) {
+ args = toJSValues(args)
+ return catch.Try(func() Value {
+ return Safe(v.jsValue.Invoke(args...))
+ })
+}
+
+// IsNaN reports whether v is the JavaScript value "NaN".
+func (v Value) IsNaN() bool {
+ return v.jsValue.IsNaN()
+}
+
+// IsNull reports whether v is the JavaScript value "null".
+func (v Value) IsNull() bool {
+ return v.jsValue.IsNull()
+}
+
+// IsUndefined reports whether v is the JavaScript value "undefined".
+func (v Value) IsUndefined() bool {
+ return v.jsValue.IsUndefined()
+}
+
+// Length returns the JavaScript property "length" of v.
+// Returns an error if v is not a JavaScript object.
+func (v Value) Length() (int, error) {
+ return catch.Try(v.jsValue.Length)
+}
+
+// New uses JavaScript's "new" operator with value v as constructor and the given arguments.
+// The arguments get mapped to JavaScript values according to the ValueOf function.
+// Returns an error if v is not a JavaScript function, the arguments failed to map to JavaScript values, or the constructor throws an error.
+func (v Value) New(args ...any) (Value, error) {
+ args = toJSValues(args)
+ return catch.Try(func() Value {
+ return Safe(v.jsValue.New(args...))
+ })
+}
+
+// Set sets the JavaScript property p of value v to ValueOf(x).
+// Returns an error if v is not a JavaScript object or x failed to map to a JavaScript value.
+func (v Value) Set(p string, x any) error {
+ x = toJSValue(x)
+ return catch.TrySideEffect(func() {
+ v.jsValue.Set(p, x)
+ })
+}
+
+// SetIndex sets the JavaScript index i of value v to ValueOf(x).
+// Returns an error if if v is not a JavaScript object or x failed to map to a JavaScript value.
+func (v Value) SetIndex(i int, x any) error {
+ x = toJSValue(x)
+ return catch.TrySideEffect(func() {
+ v.jsValue.SetIndex(i, x)
+ })
+}
+
+// String returns the value v as a string.
+// Unlike the other getters, String() does not return an error if v's Type is not TypeString.
+// Instead, it returns a string of the form "" or "" where T is v's type and V is a string representation of v's value.
+//
+// Returns an error if v is an invalid type or the string failed to load from the JavaScript runtime.
+//
+// NOTE: [syscall/js] takes the stance that String is a special case due to Go's String method convention and avoids panicking.
+// However, js.String() can still fail in other ways so an error is returned anyway.
+func (v Value) String() (string, error) {
+ return catch.Try(v.jsValue.String)
+}
+
+// Truthy returns the JavaScript "truthiness" of the value v.
+// In JavaScript, false, 0, "", null, undefined, and NaN are "falsy", and everything else is "truthy".
+// See https://developer.mozilla.org/en-US/docs/Glossary/Truthy.
+//
+// Returns an error if v's type is invalid or if the value fails to load from the JavaScript runtime.
+func (v Value) Truthy() (bool, error) {
+ return catch.Try(v.jsValue.Truthy)
+}
+
+// Type returns the JavaScript type of the value v.
+// It is similar to JavaScript's typeof operator, except it returns TypeNull instead of TypeObject for null.
+func (v Value) Type() Type {
+ return Type(v.jsValue.Type())
+}
diff --git a/vendor/github.com/nlepage/go-js-promise/LICENSE b/vendor/github.com/nlepage/go-js-promise/LICENSE
new file mode 100644
index 0000000..fff153b
--- /dev/null
+++ b/vendor/github.com/nlepage/go-js-promise/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2021 Nicolas LEPAGE
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/vendor/github.com/nlepage/go-js-promise/README.md b/vendor/github.com/nlepage/go-js-promise/README.md
new file mode 100644
index 0000000..4827f46
--- /dev/null
+++ b/vendor/github.com/nlepage/go-js-promise/README.md
@@ -0,0 +1,3 @@
+# [github.com/nlepage/go-js-promise](https://pkg.go.dev/github.com/nlepage/go-js-promise)
+
+Go WebAssembly utility package for interacting with JavaScript promises
diff --git a/vendor/github.com/nlepage/go-js-promise/promise.go b/vendor/github.com/nlepage/go-js-promise/promise.go
new file mode 100644
index 0000000..8376bdb
--- /dev/null
+++ b/vendor/github.com/nlepage/go-js-promise/promise.go
@@ -0,0 +1,56 @@
+package promise
+
+import (
+ "syscall/js"
+)
+
+// New creates a new JavaScript Promise
+func New() (p js.Value, resolve func(interface{}), reject func(interface{})) {
+ var cbFunc js.Func
+ cbFunc = js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
+ cbFunc.Release()
+
+ resolve = func(value interface{}) {
+ args[0].Invoke(value)
+ }
+
+ reject = func(value interface{}) {
+ args[1].Invoke(value)
+ }
+
+ return js.Undefined()
+ })
+
+ p = js.Global().Get("Promise").New(cbFunc)
+
+ return
+}
+
+// Await waits for the Promise to be resolved and returns the value
+// or an error if the promise rejected
+func Await(p js.Value) (js.Value, error) {
+ resCh := make(chan js.Value)
+ var then js.Func
+ then = js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
+ resCh <- args[0]
+ return nil
+ })
+ defer then.Release()
+
+ errCh := make(chan error)
+ var catch js.Func
+ catch = js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
+ errCh <- js.Error{args[0]}
+ return nil
+ })
+ defer catch.Release()
+
+ p.Call("then", then).Call("catch", catch)
+
+ select {
+ case res := <-resCh:
+ return res, nil
+ case err := <-errCh:
+ return js.Undefined(), err
+ }
+}
diff --git a/vendor/github.com/nlepage/go-wasm-http-server/v2/.all-contributorsrc b/vendor/github.com/nlepage/go-wasm-http-server/v2/.all-contributorsrc
new file mode 100644
index 0000000..642c6b7
--- /dev/null
+++ b/vendor/github.com/nlepage/go-wasm-http-server/v2/.all-contributorsrc
@@ -0,0 +1,37 @@
+{
+ "projectName": "go-wasm-http-server",
+ "projectOwner": "nlepage",
+ "repoType": "github",
+ "repoHost": "https://github.com",
+ "files": [
+ "README.md"
+ ],
+ "imageSize": 100,
+ "commit": false,
+ "commitConvention": "gitmoji",
+ "contributors": [
+ {
+ "login": "jphastings",
+ "name": "JP Hastings-Edrei",
+ "avatar_url": "https://avatars.githubusercontent.com/u/42999?v=4",
+ "profile": "https://byjp.me/",
+ "contributions": [
+ "code",
+ "doc",
+ "example"
+ ]
+ },
+ {
+ "login": "EliCDavis",
+ "name": "Eli Davis",
+ "avatar_url": "https://avatars.githubusercontent.com/u/9094977?v=4",
+ "profile": "https://recolude.com/",
+ "contributions": [
+ "code",
+ "bug"
+ ]
+ }
+ ],
+ "contributorsPerLine": 7,
+ "linkToUsage": false
+}
diff --git a/vendor/github.com/nlepage/go-wasm-http-server/v2/.gitignore b/vendor/github.com/nlepage/go-wasm-http-server/v2/.gitignore
new file mode 100644
index 0000000..e3a2287
--- /dev/null
+++ b/vendor/github.com/nlepage/go-wasm-http-server/v2/.gitignore
@@ -0,0 +1,3 @@
+node_modules/
+*.wasm
+!docs/**/*.wasm
diff --git a/vendor/github.com/nlepage/go-wasm-http-server/v2/CODE_OF_CONDUCT.md b/vendor/github.com/nlepage/go-wasm-http-server/v2/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..c51d402
--- /dev/null
+++ b/vendor/github.com/nlepage/go-wasm-http-server/v2/CODE_OF_CONDUCT.md
@@ -0,0 +1,76 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as
+contributors and maintainers pledge to making participation in our project and
+our community a harassment-free experience for everyone, regardless of age, body
+size, disability, ethnicity, sex characteristics, gender identity and expression,
+level of experience, education, socio-economic status, nationality, personal
+appearance, race, religion, or sexual identity and orientation.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment
+include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery and unwelcome sexual attention or
+ advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or electronic
+ address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable
+behavior and are expected to take appropriate and fair corrective action in
+response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or
+reject comments, commits, code, wiki edits, issues, and other contributions
+that are not aligned to this Code of Conduct, or to ban temporarily or
+permanently any contributor for other behaviors that they deem inappropriate,
+threatening, offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies both within project spaces and in public spaces
+when an individual is representing the project or its community. Examples of
+representing a project or community include using an official project e-mail
+address, posting via an official social media account, or acting as an appointed
+representative at an online or offline event. Representation of a project may be
+further defined and clarified by project maintainers.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported by contacting the project team at nicolas.lepage+go-wasm-http-server@zenika.com. All
+complaints will be reviewed and investigated and will result in a response that
+is deemed necessary and appropriate to the circumstances. The project team is
+obligated to maintain confidentiality with regard to the reporter of an incident.
+Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good
+faith may face temporary or permanent repercussions as determined by other
+members of the project's leadership.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
+available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
+
+[homepage]: https://www.contributor-covenant.org
+
+For answers to common questions about this code of conduct, see
+https://www.contributor-covenant.org/faq
diff --git a/vendor/github.com/nlepage/go-wasm-http-server/v2/LICENSE b/vendor/github.com/nlepage/go-wasm-http-server/v2/LICENSE
new file mode 100644
index 0000000..907fcfd
--- /dev/null
+++ b/vendor/github.com/nlepage/go-wasm-http-server/v2/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2025 Nicolas Lepage
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/vendor/github.com/nlepage/go-wasm-http-server/v2/README.md b/vendor/github.com/nlepage/go-wasm-http-server/v2/README.md
new file mode 100644
index 0000000..c1181c9
--- /dev/null
+++ b/vendor/github.com/nlepage/go-wasm-http-server/v2/README.md
@@ -0,0 +1,238 @@
+
+
+> Embed your Go HTTP handlers in a ServiceWorker (using [WebAssembly](https://mdn.io/WebAssembly/)) and emulate an HTTP server!
+
+## Examples
+
+ - [Hello example](https://nlepage.github.io/go-wasm-http-server/hello) ([sources](https://github.com/nlepage/go-wasm-http-server/tree/master/docs/hello))
+ - [Hello example with state](https://nlepage.github.io/go-wasm-http-server/hello-state) ([sources](https://github.com/nlepage/go-wasm-http-server/tree/master/docs/hello-state))
+ - [Hello example with state and keepalive](https://nlepage.github.io/go-wasm-http-server/hello-state-keepalive) ([sources](https://github.com/nlepage/go-wasm-http-server/tree/master/docs/hello-state-keepalive))
+ - [Hello example with Server Sent Events](https://nlepage.github.io/go-wasm-http-server/hello-sse/) ([sources](https://nlepage.github.io/go-wasm-http-server/hello-sse/))
+ - [πΊ Catption generator example](https://nlepage.github.io/catption/wasm) ([sources](https://github.com/nlepage/catption/tree/wasm))
+ - [Random password generator web server](https://nlepage.github.io/random-password-please/) ([sources](https://github.com/nlepage/random-password-please) forked from [jbarham/random-password-please](https://github.com/jbarham/random-password-please))
+ - [Server fallbacks, and compiling with TinyGo](https://nlepage.github.io/go-wasm-http-server/tinygo/) (runs locally; see [sources & readme](https://github.com/nlepage/go-wasm-http-server/tree/master/docs/tinygo#readme) for how to run this example)
+
+## How?
+
+Talk given at the Go devroom of FOSDEM 2021 explaining how `go-wasm-http-server` works:
+
+[](https://youtu.be/O2RB_8ircdE)
+
+The slides are available [here](https://nlepage.github.io/go-wasm-http-talk/).
+
+## Why?
+
+`go-wasm-http-server` can help you put up a demonstration for a project without actually running a Go HTTP server.
+
+## Requirements
+
+`go-wasm-http-server` requires you to build your Go application to WebAssembly, so you need to make sure your code is compatible:
+- no C bindings
+- no System dependencies such as file system or network (database server for example)
+- For smaller WASM blobs, your code may also benefit from being compatible with, and compiled by, [TinyGo](https://tinygo.org/docs/reference/lang-support/stdlib/). See the TinyGo specific details below.
+
+## Usage
+
+### Step 1: Build to `js/wasm`
+
+In your Go code, replace [`http.ListenAndServe()`](https://pkg.go.dev/net/http#ListenAndServe) (or [`net.Listen()`](https://pkg.go.dev/net#Listen) + [`http.Serve()`](https://pkg.go.dev/net/http#Serve)) by [wasmhttp.Serve()](https://pkg.go.dev/github.com/nlepage/go-wasm-http-server#Serve):
+
+π `server.go`
+```go
+// +build !js,!wasm
+
+package main
+
+import (
+ "net/http"
+)
+
+func main() {
+ // Define handlers...
+
+ http.ListenAndServe(":8080", nil)
+}
+```
+
+becomes:
+
+π `server_js_wasm.go`
+```go
+// +build js,wasm
+
+package main
+
+import (
+ wasmhttp "github.com/nlepage/go-wasm-http-server/v2"
+)
+
+func main() {
+ // Define handlers...
+
+ wasmhttp.Serve(nil)
+}
+```
+
+You may want to use build tags as shown above (or file name suffixes) in order to be able to build both to WebAssembly and other targets.
+
+Then build your WebAssembly binary:
+
+```sh
+# To compile with Go
+GOOS=js GOARCH=wasm go build -o server.wasm .
+
+# To compile with TinyGo, if your code is compatible
+GOOS=js GOARCH=wasm tinygo build -o server.wasm .
+```
+
+### Step 2: Create ServiceWorker file
+
+First, check the version of Go/TinyGo you compiled your wasm with:
+
+```sh
+$ go version
+go version go1.23.4 darwin/arm64
+# ^------^
+
+$ tinygo version
+tinygo version 0.35.0 darwin/arm64 (using go version go1.23.4 and LLVM version 18.1.2)
+# ^----^
+```
+
+Create a ServiceWorker file with the following code:
+
+π `sw.js`
+```js
+// Note the 'go.1.23.4' below, that matches the version you just found:
+importScripts('https://cdn.jsdelivr.net/gh/golang/go@go1.23.4/misc/wasm/wasm_exec.js')
+// If you compiled with TinyGo then, similarly, use:
+importScripts('https://cdn.jsdelivr.net/gh/tinygo-org/tinygo@0.35.0/targets/wasm_exec.js')
+
+importScripts('https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@v2.2.1/sw.js')
+
+registerWasmHTTPListener('path/to/server.wasm')
+```
+
+By default the server will deploy at the ServiceWorker's scope root, check [`registerWasmHTTPListener()`'s API](https://github.com/nlepage/go-wasm-http-server#registerwasmhttplistenerwasmurl-options) for more information.
+
+You may want to add these additional event listeners in your ServiceWorker:
+
+```js
+// Skip installed stage and jump to activating stage
+addEventListener('install', (event) => {
+ event.waitUntil(skipWaiting())
+})
+
+// Start controlling clients as soon as the SW is activated
+addEventListener('activate', event => {
+ event.waitUntil(clients.claim())
+})
+```
+
+### Step 3: Register the ServiceWorker
+
+In your web page(s), register the ServiceWorker:
+
+```html
+
+```
+
+Now your web page(s) may start fetching from the server:
+
+```js
+// The server will receive a request for "/path/to/resource"
+fetch('server/path/to/resource').then(res => {
+ // use response...
+})
+```
+
+## API
+
+For Go API see [pkg.go.dev/github.com/nlepage/go-wasm-http-server](https://pkg.go.dev/github.com/nlepage/go-wasm-http-server#section-documentation)
+
+### JavaScript API
+
+### `registerWasmHTTPListener(wasmUrl, options)`
+
+Instantiates and runs the WebAssembly module at `wasmUrl`, and registers a fetch listener forwarding requests to the WebAssembly module's server.
+
+β This function must be called only once in a ServiceWorker, if you want to register several servers you must use several ServiceWorkers.
+
+The server will be "deployed" at the root of the ServiceWorker's scope by default, `base` may be used to deploy the server at a subpath of the scope.
+
+See [ServiceWorkerContainer.register()](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register) for more information about the scope of a ServiceWorker.
+
+#### `wasmUrl`
+
+URL string of the WebAssembly module, example: `"path/to/my-module.wasm"`.
+
+#### `options`
+
+An optional object containing:
+
+- `base` (`string`): Base path of the server, relative to the ServiceWorker's scope.
+- `cacheName` (`string`): Name of the [Cache](https://developer.mozilla.org/en-US/docs/Web/API/Cache) to store the WebAssembly binary.
+- `args` (`string[]`): Arguments for the WebAssembly module.
+- `passthrough` (`(request: Request): boolean`): Optional callback to allow passing the request through to network.
+
+## FAQ β
+
+### Are WebSockets supported?
+
+No, WebSockets arenβt and wonβt be supported, because Service Workers cannot intercept websocket connections.
+
+However [Server Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events), which is an alternative to WebSockets, are supported, you can find the code for an example [here](https://github.com/nlepage/go-wasm-http-server/tree/master/docs/hello-sse) and the demo [here](https://nlepage.github.io/go-wasm-http-server/hello-sse/).
+
+### Is it compatible with TinyGo?
+
+Yes, an example and some specific information is available [here](https://github.com/nlepage/go-wasm-http-server/tree/master/docs/tinygo).
+
+## Contributors β¨
+
+Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
+
+
+
+
+