From eaa0c4c328e7f76c1fd08d64f70d522d41674385 Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Fri, 7 Jun 2024 16:54:12 -0400 Subject: [PATCH] started --- app-dynamic.tsx | 2 + app.tsx | 4 +- bundler-inc.tsx | 15 + bundler.tsx | 24 -- deno.json | 6 +- deno.lock | 10 + dump.js | 869 ------------------------------------------------ introspect.tsx | 78 +++++ mod.ts | 70 ++++ serve.tsx | 30 ++ 10 files changed, 213 insertions(+), 895 deletions(-) create mode 100644 app-dynamic.tsx create mode 100644 bundler-inc.tsx delete mode 100644 bundler.tsx delete mode 100644 dump.js create mode 100644 introspect.tsx create mode 100644 mod.ts create mode 100644 serve.tsx diff --git a/app-dynamic.tsx b/app-dynamic.tsx new file mode 100644 index 0000000..4de9ac5 --- /dev/null +++ b/app-dynamic.tsx @@ -0,0 +1,2 @@ +console.log("hey included") +export default "async include"; \ No newline at end of file diff --git a/app.tsx b/app.tsx index f682b75..d776be6 100644 --- a/app.tsx +++ b/app.tsx @@ -1,5 +1,7 @@ import React from "react"; -import * as Other from "other"; +//const other = import("./app-dynamic.tsx"); + +import * as Other from "./other.tsx"; console.log(Other.default, Other.app); React.render(React.createElement(Other.app, null), document.querySelector("#app")); diff --git a/bundler-inc.tsx b/bundler-inc.tsx new file mode 100644 index 0000000..8ffb5ab --- /dev/null +++ b/bundler-inc.tsx @@ -0,0 +1,15 @@ +import B from "./mod.ts"; + +const results = await B({ + imports: { + "react": "https://esm.sh/preact@10.22.0/compat", + "react/": "https://esm.sh/preact@10.22.0/compat/", + "other": "./other.tsx", + "entry": "./app.tsx" + } +}); + +for await(const file of results.outputFiles) +{ + console.log(file.path); +} diff --git a/bundler.tsx b/bundler.tsx deleted file mode 100644 index db0599e..0000000 --- a/bundler.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import * as ESBuild from "https://deno.land/x/esbuild@v0.19.2/wasm.js"; -import * as Mapper from "https://esm.sh/esbuild-plugin-importmaps@1.0.0"; -await ESBuild.initialize({ worker: false } as ESBuild.InitializeOptions); -const options = { - plugins: [Mapper.importmapPlugin({ - "imports": { - "react": "https://esm.sh/preact@10.22.0/compat", - "react/": "https://esm.sh/preact@10.22.0/compat/", - "other": "./other.tsx", - "entry": "./app.tsx" - } -})], - entryPoints: ["entry"], - bundle: true, - minify: false, - format: "esm", - jsx: "automatic", - jsxImportSource: "react" -} as ESBuild.BuildOptions; - -const result = await ESBuild.build(options); -const decode = new TextDecoder("utf-8") -await Deno.writeTextFile("./dump.js", decode.decode(result.outputFiles?.[0].contents)); -ESBuild.stop(); \ No newline at end of file diff --git a/deno.json b/deno.json index 9d2d473..5907466 100644 --- a/deno.json +++ b/deno.json @@ -1,9 +1,13 @@ { + "name": "@ttf/deploy-bundler", + "version": "0.1.0", + "exports": "./mod.ts", "imports": { "react": "https://esm.sh/preact@10.22.0/compat", "react/": "https://esm.sh/preact@10.22.0/compat/", "other": "./other.tsx", - "entry": "./app.tsx" + "entry": "./app.tsx", + "config": "./deno.json" }, "compilerOptions": { "jsx": "react-jsx", diff --git a/deno.lock b/deno.lock index 581533f..7c28539 100644 --- a/deno.lock +++ b/deno.lock @@ -12,6 +12,7 @@ } }, "redirects": { + "https://esm.sh/@jspm/import-map": "https://esm.sh/@jspm/import-map@1.0.8", "https://esm.sh/esbuild-plugin-importmaps": "https://esm.sh/esbuild-plugin-importmaps@1.0.0", "https://esm.sh/v135/@types/esbuild-plugin-import-map@latest/index.d.ts": "https://esm.sh/v135/@types/esbuild-plugin-import-map@0.0.3/index.d.ts" }, @@ -162,8 +163,13 @@ "https://deno.land/x/deno_cache@0.6.2/lib/snippets/deno_cache_dir-a2aecaa9536c9402/fs.js": "cbe3a976ed63c72c7cb34ef845c27013033a3b11f9d8d3e2c4aa5dda2c0c7af6", "https://deno.land/x/deno_cache@0.6.2/mod.ts": "b4004287e1c6123d7f07fe9b5b3e94ce6d990c4102949a89c527c68b19627867", "https://deno.land/x/deno_cache@0.6.2/util.ts": "f3f5a0cfc60051f09162942fb0ee87a0e27b11a12aec4c22076e3006be4cc1e2", + "https://deno.land/x/denoflate@1.2.1/mod.ts": "f5628e44b80b3d80ed525afa2ba0f12408e3849db817d47a883b801f9ce69dd6", + "https://deno.land/x/denoflate@1.2.1/pkg/denoflate.js": "b9f9ad9457d3f12f28b1fb35c555f57443427f74decb403113d67364e4f2caf4", + "https://deno.land/x/denoflate@1.2.1/pkg/denoflate_bg.wasm.js": "d581956245407a2115a3d7e8d85a9641c032940a8e810acbd59ca86afd34d44d", "https://deno.land/x/esbuild@v0.19.11/wasm.js": "e5935e262c7b5b3ed4d842e780293d6ff7132c9ddc3077b31ae305c73c741e7b", "https://deno.land/x/esbuild@v0.19.2/wasm.js": "5ffeb3d973e57351eb4d2d03ffafc8ce5672e946d0f0a786c4aed2ca29cec004", + "https://deno.land/x/esbuild@v0.21.4/mod.js": "2baa2fee0098fe9cec9c1a5e66e394afce85ccb966a9be52d7c617ea5c67769f", + "https://deno.land/x/esbuild@v0.21.4/wasm.js": "5909c90c89b45085cfd2cbc43881e1082c7f4b3ad980b77a066c5ba1d1b71a1e", "https://deno.land/x/esbuild_deno_loader@0.9.0/deps.ts": "08972bc7edd45e9e57cfc9f9a8628957c58913dcc96273806d7c228edbb7711f", "https://deno.land/x/esbuild_deno_loader@0.9.0/mod.ts": "00decaf22c0fec5d80724f0bb48caeafe936f5f75e31bb1138a970961fac0bbd", "https://deno.land/x/esbuild_deno_loader@0.9.0/src/deno.ts": "bd423a6d8724152e9d6187adcb46139462b1328f81f92ae803733a7c0b202812", @@ -174,6 +180,10 @@ "https://deno.land/x/esbuild_deno_loader@0.9.0/src/shared.ts": "d717f56adafcee47834d20b77d603f646d36575273c766fcb34d6315e759392f", "https://deno.land/x/importmap@0.2.1/_util.ts": "ada9a9618b537e6c0316c048a898352396c882b9f2de38aba18fd3f2950ede89", "https://deno.land/x/importmap@0.2.1/mod.ts": "ae3d1cd7eabd18c01a4960d57db471126b020f23b37ef14e1359bbb949227ade", + "https://deno.land/x/jsonct@v0.1.0/mod.ts": "dba7e7f3529be6369f5c718e3a18b69f15ffa176006d2a7565073ce6c5bd9f3f", + "https://deno.land/x/jsonct@v0.1.0/src/_util/asserts.ts": "178dfc49a464aee693a7e285567b3d0b555dc805ff490505a8aae34f9cfb1462", + "https://deno.land/x/jsonct@v0.1.0/src/parse.ts": "a3a016822446b0584b40bae9098df480db5590a9915c9e3c623ba2801cf1b8df", + "https://esm.sh/@jspm/import-map@1.0.8": "61a89e4acc2b123bf9e97f65107a2a4cd9db4d939951e140e94bff3f1afa6c5f", "https://esm.sh/esbuild-plugin-import-map@2.1.0": "591fd6ee133417fba19ed9fa95fd2ddf74a43f96b840c16f2b8ff4b3d6e2da93", "https://esm.sh/esbuild-plugin-importmaps@1.0.0": "ab9e79660ff4d57d2ed7ef5e8516fbe0e79305267f22e1e7270d0a17ae0c2029", "https://esm.sh/preact@10.22.0/compat/jsx-runtime": "a2f6ddc2ce374813df1c13826a9ad010e90b5a70a989f1069a367ef60dd52eb0", diff --git a/dump.js b/dump.js deleted file mode 100644 index be5bd68..0000000 --- a/dump.js +++ /dev/null @@ -1,869 +0,0 @@ -// importmap-url:https://esm.sh/stable/preact@10.22.0/denonext/preact.mjs -var M; -var d; -var Q; -var re; -var C; -var G; -var X; -var A; -var V; -var R; -var $; -var Y; -var U = {}; -var Z = []; -var ie = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i; -var H = Array.isArray; -function b(_, e) { - for (var t in e) - _[t] = e[t]; - return _; -} -function ee(_) { - var e = _.parentNode; - e && e.removeChild(_); -} -function le(_, e, t) { - var i, n, r2, l2 = {}; - for (r2 in e) - r2 == "key" ? i = e[r2] : r2 == "ref" ? n = e[r2] : l2[r2] = e[r2]; - if (arguments.length > 2 && (l2.children = arguments.length > 3 ? M.call(arguments, 2) : t), typeof _ == "function" && _.defaultProps != null) - for (r2 in _.defaultProps) - l2[r2] === void 0 && (l2[r2] = _.defaultProps[r2]); - return S(_, l2, i, n, null); -} -function S(_, e, t, i, n) { - var r2 = { type: _, props: e, key: t, ref: i, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: n ?? ++Q, __i: -1, __u: 0 }; - return n == null && d.vnode != null && d.vnode(r2), r2; -} -function he() { - return { current: null }; -} -function I(_) { - return _.children; -} -function F(_, e) { - this.props = _, this.context = e; -} -function x(_, e) { - if (e == null) - return _.__ ? x(_.__, _.__i + 1) : null; - for (var t; e < _.__k.length; e++) - if ((t = _.__k[e]) != null && t.__e != null) - return t.__e; - return typeof _.type == "function" ? x(_) : null; -} -function _e(_) { - var e, t; - if ((_ = _.__) != null && _.__c != null) { - for (_.__e = _.__c.base = null, e = 0; e < _.__k.length; e++) - if ((t = _.__k[e]) != null && t.__e != null) { - _.__e = _.__c.base = t.__e; - break; - } - return _e(_); - } -} -function O(_) { - (!_.__d && (_.__d = true) && C.push(_) && !W.__r++ || G !== d.debounceRendering) && ((G = d.debounceRendering) || X)(W); -} -function W() { - var _, e, t, i, n, r2, l2, s; - for (C.sort(A); _ = C.shift(); ) - _.__d && (e = C.length, i = void 0, r2 = (n = (t = _).__v).__e, l2 = [], s = [], t.__P && ((i = b({}, n)).__v = n.__v + 1, d.vnode && d.vnode(i), j(t.__P, i, n, t.__n, t.__P.namespaceURI, 32 & n.__u ? [r2] : null, l2, r2 ?? x(n), !!(32 & n.__u), s), i.__v = n.__v, i.__.__k[i.__i] = i, oe(l2, i, s), i.__e != r2 && _e(i)), C.length > e && C.sort(A)); - W.__r = 0; -} -function te(_, e, t, i, n, r2, l2, s, f, u, p3) { - var o2, m, c2, h2, k3, v2 = i && i.__k || Z, a = e.length; - for (t.__d = f, se(t, e, v2), f = t.__d, o2 = 0; o2 < a; o2++) - (c2 = t.__k[o2]) != null && typeof c2 != "boolean" && typeof c2 != "function" && (m = c2.__i === -1 ? U : v2[c2.__i] || U, c2.__i = o2, j(_, c2, m, n, r2, l2, s, f, u, p3), h2 = c2.__e, c2.ref && m.ref != c2.ref && (m.ref && z(m.ref, null, c2), p3.push(c2.ref, c2.__c || h2, c2)), k3 == null && h2 != null && (k3 = h2), 65536 & c2.__u || m.__k === c2.__k ? (f && !f.isConnected && (f = x(m)), f = ne(c2, f, _)) : typeof c2.type == "function" && c2.__d !== void 0 ? f = c2.__d : h2 && (f = h2.nextSibling), c2.__d = void 0, c2.__u &= -196609); - t.__d = f, t.__e = k3; -} -function se(_, e, t) { - var i, n, r2, l2, s, f = e.length, u = t.length, p3 = u, o2 = 0; - for (_.__k = [], i = 0; i < f; i++) - l2 = i + o2, (n = _.__k[i] = (n = e[i]) == null || typeof n == "boolean" || typeof n == "function" ? null : typeof n == "string" || typeof n == "number" || typeof n == "bigint" || n.constructor == String ? S(null, n, null, null, null) : H(n) ? S(I, { children: n }, null, null, null) : n.constructor === void 0 && n.__b > 0 ? S(n.type, n.props, n.key, n.ref ? n.ref : null, n.__v) : n) != null ? (n.__ = _, n.__b = _.__b + 1, s = ce(n, t, l2, p3), n.__i = s, r2 = null, s !== -1 && (p3--, (r2 = t[s]) && (r2.__u |= 131072)), r2 == null || r2.__v === null ? (s == -1 && o2--, typeof n.type != "function" && (n.__u |= 65536)) : s !== l2 && (s === l2 + 1 ? o2++ : s > l2 ? p3 > f - l2 ? o2 += s - l2 : o2-- : s < l2 ? s == l2 - 1 && (o2 = s - l2) : o2 = 0, s !== i + o2 && (n.__u |= 65536))) : (r2 = t[l2]) && r2.key == null && r2.__e && !(131072 & r2.__u) && (r2.__e == _.__d && (_.__d = x(r2)), B(r2, r2, false), t[l2] = null, p3--); - if (p3) - for (i = 0; i < u; i++) - (r2 = t[i]) != null && !(131072 & r2.__u) && (r2.__e == _.__d && (_.__d = x(r2)), B(r2, r2)); -} -function ne(_, e, t) { - var i, n; - if (typeof _.type == "function") { - for (i = _.__k, n = 0; i && n < i.length; n++) - i[n] && (i[n].__ = _, e = ne(i[n], e, t)); - return e; - } - _.__e != e && (t.insertBefore(_.__e, e || null), e = _.__e); - do - e = e && e.nextSibling; - while (e != null && e.nodeType === 8); - return e; -} -function ue(_, e) { - return e = e || [], _ == null || typeof _ == "boolean" || (H(_) ? _.some(function(t) { - ue(t, e); - }) : e.push(_)), e; -} -function ce(_, e, t, i) { - var n = _.key, r2 = _.type, l2 = t - 1, s = t + 1, f = e[t]; - if (f === null || f && n == f.key && r2 === f.type && !(131072 & f.__u)) - return t; - if (i > (f != null && !(131072 & f.__u) ? 1 : 0)) - for (; l2 >= 0 || s < e.length; ) { - if (l2 >= 0) { - if ((f = e[l2]) && !(131072 & f.__u) && n == f.key && r2 === f.type) - return l2; - l2--; - } - if (s < e.length) { - if ((f = e[s]) && !(131072 & f.__u) && n == f.key && r2 === f.type) - return s; - s++; - } - } - return -1; -} -function J(_, e, t) { - e[0] === "-" ? _.setProperty(e, t ?? "") : _[e] = t == null ? "" : typeof t != "number" || ie.test(e) ? t : t + "px"; -} -function L(_, e, t, i, n) { - var r2; - e: - if (e === "style") - if (typeof t == "string") - _.style.cssText = t; - else { - if (typeof i == "string" && (_.style.cssText = i = ""), i) - for (e in i) - t && e in t || J(_.style, e, ""); - if (t) - for (e in t) - i && t[e] === i[e] || J(_.style, e, t[e]); - } - else if (e[0] === "o" && e[1] === "n") - r2 = e !== (e = e.replace(/(PointerCapture)$|Capture$/i, "$1")), e = e.toLowerCase() in _ || e === "onFocusOut" || e === "onFocusIn" ? e.toLowerCase().slice(2) : e.slice(2), _.l || (_.l = {}), _.l[e + r2] = t, t ? i ? t.u = i.u : (t.u = V, _.addEventListener(e, r2 ? $ : R, r2)) : _.removeEventListener(e, r2 ? $ : R, r2); - else { - if (n == "http://www.w3.org/2000/svg") - e = e.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s"); - else if (e != "width" && e != "height" && e != "href" && e != "list" && e != "form" && e != "tabIndex" && e != "download" && e != "rowSpan" && e != "colSpan" && e != "role" && e in _) - try { - _[e] = t ?? ""; - break e; - } catch { - } - typeof t == "function" || (t == null || t === false && e[4] !== "-" ? _.removeAttribute(e) : _.setAttribute(e, t)); - } -} -function K(_) { - return function(e) { - if (this.l) { - var t = this.l[e.type + _]; - if (e.t == null) - e.t = V++; - else if (e.t < t.u) - return; - return t(d.event ? d.event(e) : e); - } - }; -} -function j(_, e, t, i, n, r2, l2, s, f, u) { - var p3, o2, m, c2, h2, k3, v2, a, y3, w2, T2, P2, q3, D3, N2, g3 = e.type; - if (e.constructor !== void 0) - return null; - 128 & t.__u && (f = !!(32 & t.__u), r2 = [s = e.__e = t.__e]), (p3 = d.__b) && p3(e); - e: - if (typeof g3 == "function") - try { - if (a = e.props, y3 = (p3 = g3.contextType) && i[p3.__c], w2 = p3 ? y3 ? y3.props.value : p3.__ : i, t.__c ? v2 = (o2 = e.__c = t.__c).__ = o2.__E : ("prototype" in g3 && g3.prototype.render ? e.__c = o2 = new g3(a, w2) : (e.__c = o2 = new F(a, w2), o2.constructor = g3, o2.render = pe), y3 && y3.sub(o2), o2.props = a, o2.state || (o2.state = {}), o2.context = w2, o2.__n = i, m = o2.__d = true, o2.__h = [], o2._sb = []), o2.__s == null && (o2.__s = o2.state), g3.getDerivedStateFromProps != null && (o2.__s == o2.state && (o2.__s = b({}, o2.__s)), b(o2.__s, g3.getDerivedStateFromProps(a, o2.__s))), c2 = o2.props, h2 = o2.state, o2.__v = e, m) - g3.getDerivedStateFromProps == null && o2.componentWillMount != null && o2.componentWillMount(), o2.componentDidMount != null && o2.__h.push(o2.componentDidMount); - else { - if (g3.getDerivedStateFromProps == null && a !== c2 && o2.componentWillReceiveProps != null && o2.componentWillReceiveProps(a, w2), !o2.__e && (o2.shouldComponentUpdate != null && o2.shouldComponentUpdate(a, o2.__s, w2) === false || e.__v === t.__v)) { - for (e.__v !== t.__v && (o2.props = a, o2.state = o2.__s, o2.__d = false), e.__e = t.__e, e.__k = t.__k, e.__k.forEach(function(E3) { - E3 && (E3.__ = e); - }), T2 = 0; T2 < o2._sb.length; T2++) - o2.__h.push(o2._sb[T2]); - o2._sb = [], o2.__h.length && l2.push(o2); - break e; - } - o2.componentWillUpdate != null && o2.componentWillUpdate(a, o2.__s, w2), o2.componentDidUpdate != null && o2.__h.push(function() { - o2.componentDidUpdate(c2, h2, k3); - }); - } - if (o2.context = w2, o2.props = a, o2.__P = _, o2.__e = false, P2 = d.__r, q3 = 0, "prototype" in g3 && g3.prototype.render) { - for (o2.state = o2.__s, o2.__d = false, P2 && P2(e), p3 = o2.render(o2.props, o2.state, o2.context), D3 = 0; D3 < o2._sb.length; D3++) - o2.__h.push(o2._sb[D3]); - o2._sb = []; - } else - do - o2.__d = false, P2 && P2(e), p3 = o2.render(o2.props, o2.state, o2.context), o2.state = o2.__s; - while (o2.__d && ++q3 < 25); - o2.state = o2.__s, o2.getChildContext != null && (i = b(b({}, i), o2.getChildContext())), m || o2.getSnapshotBeforeUpdate == null || (k3 = o2.getSnapshotBeforeUpdate(c2, h2)), te(_, H(N2 = p3 != null && p3.type === I && p3.key == null ? p3.props.children : p3) ? N2 : [N2], e, t, i, n, r2, l2, s, f, u), o2.base = e.__e, e.__u &= -161, o2.__h.length && l2.push(o2), v2 && (o2.__E = o2.__ = null); - } catch (E3) { - e.__v = null, f || r2 != null ? (e.__e = s, e.__u |= f ? 160 : 32, r2[r2.indexOf(s)] = null) : (e.__e = t.__e, e.__k = t.__k), d.__e(E3, e, t); - } - else - r2 == null && e.__v === t.__v ? (e.__k = t.__k, e.__e = t.__e) : e.__e = fe(t.__e, e, t, i, n, r2, l2, f, u); - (p3 = d.diffed) && p3(e); -} -function oe(_, e, t) { - e.__d = void 0; - for (var i = 0; i < t.length; i++) - z(t[i], t[++i], t[++i]); - d.__c && d.__c(e, _), _.some(function(n) { - try { - _ = n.__h, n.__h = [], _.some(function(r2) { - r2.call(n); - }); - } catch (r2) { - d.__e(r2, n.__v); - } - }); -} -function fe(_, e, t, i, n, r2, l2, s, f) { - var u, p3, o2, m, c2, h2, k3, v2 = t.props, a = e.props, y3 = e.type; - if (y3 === "svg" ? n = "http://www.w3.org/2000/svg" : y3 === "math" ? n = "http://www.w3.org/1998/Math/MathML" : n || (n = "http://www.w3.org/1999/xhtml"), r2 != null) { - for (u = 0; u < r2.length; u++) - if ((c2 = r2[u]) && "setAttribute" in c2 == !!y3 && (y3 ? c2.localName === y3 : c2.nodeType === 3)) { - _ = c2, r2[u] = null; - break; - } - } - if (_ == null) { - if (y3 === null) - return document.createTextNode(a); - _ = document.createElementNS(n, y3, a.is && a), r2 = null, s = false; - } - if (y3 === null) - v2 === a || s && _.data === a || (_.data = a); - else { - if (r2 = r2 && M.call(_.childNodes), v2 = t.props || U, !s && r2 != null) - for (v2 = {}, u = 0; u < _.attributes.length; u++) - v2[(c2 = _.attributes[u]).name] = c2.value; - for (u in v2) - if (c2 = v2[u], u != "children") { - if (u == "dangerouslySetInnerHTML") - o2 = c2; - else if (u !== "key" && !(u in a)) { - if (u == "value" && "defaultValue" in a || u == "checked" && "defaultChecked" in a) - continue; - L(_, u, null, c2, n); - } - } - for (u in a) - c2 = a[u], u == "children" ? m = c2 : u == "dangerouslySetInnerHTML" ? p3 = c2 : u == "value" ? h2 = c2 : u == "checked" ? k3 = c2 : u === "key" || s && typeof c2 != "function" || v2[u] === c2 || L(_, u, c2, v2[u], n); - if (p3) - s || o2 && (p3.__html === o2.__html || p3.__html === _.innerHTML) || (_.innerHTML = p3.__html), e.__k = []; - else if (o2 && (_.innerHTML = ""), te(_, H(m) ? m : [m], e, t, i, y3 === "foreignObject" ? "http://www.w3.org/1999/xhtml" : n, r2, l2, r2 ? r2[0] : t.__k && x(t, 0), s, f), r2 != null) - for (u = r2.length; u--; ) - r2[u] != null && ee(r2[u]); - s || (u = "value", h2 !== void 0 && (h2 !== _[u] || y3 === "progress" && !h2 || y3 === "option" && h2 !== v2[u]) && L(_, u, h2, v2[u], n), u = "checked", k3 !== void 0 && k3 !== _[u] && L(_, u, k3, v2[u], n)); - } - return _; -} -function z(_, e, t) { - try { - typeof _ == "function" ? _(e) : _.current = e; - } catch (i) { - d.__e(i, t); - } -} -function B(_, e, t) { - var i, n; - if (d.unmount && d.unmount(_), (i = _.ref) && (i.current && i.current !== _.__e || z(i, null, e)), (i = _.__c) != null) { - if (i.componentWillUnmount) - try { - i.componentWillUnmount(); - } catch (r2) { - d.__e(r2, e); - } - i.base = i.__P = null; - } - if (i = _.__k) - for (n = 0; n < i.length; n++) - i[n] && B(i[n], e, t || typeof _.type != "function"); - t || _.__e == null || ee(_.__e), _.__c = _.__ = _.__e = _.__d = void 0; -} -function pe(_, e, t) { - return this.constructor(_, t); -} -function ae(_, e, t) { - var i, n, r2, l2; - d.__ && d.__(_, e), n = (i = typeof t == "function") ? null : t && t.__k || e.__k, r2 = [], l2 = [], j(e, _ = (!i && t || e).__k = le(I, null, [_]), n || U, U, e.namespaceURI, !i && t ? [t] : n ? null : e.firstChild ? M.call(e.childNodes) : null, r2, !i && t ? t : n ? n.__e : e.firstChild, i, l2), oe(r2, _, l2); -} -function de(_, e) { - ae(_, e, de); -} -function ve(_, e, t) { - var i, n, r2, l2, s = b({}, _.props); - for (r2 in _.type && _.type.defaultProps && (l2 = _.type.defaultProps), e) - r2 == "key" ? i = e[r2] : r2 == "ref" ? n = e[r2] : s[r2] = e[r2] === void 0 && l2 !== void 0 ? l2[r2] : e[r2]; - return arguments.length > 2 && (s.children = arguments.length > 3 ? M.call(arguments, 2) : t), S(_.type, s, i || _.key, n || _.ref, null); -} -function ye(_, e) { - var t = { __c: e = "__cC" + Y++, __: _, Consumer: function(i, n) { - return i.children(n); - }, Provider: function(i) { - var n, r2; - return this.getChildContext || (n = [], (r2 = {})[e] = this, this.getChildContext = function() { - return r2; - }, this.shouldComponentUpdate = function(l2) { - this.props.value !== l2.value && n.some(function(s) { - s.__e = true, O(s); - }); - }, this.sub = function(l2) { - n.push(l2); - var s = l2.componentWillUnmount; - l2.componentWillUnmount = function() { - n.splice(n.indexOf(l2), 1), s && s.call(l2); - }; - }), i.children; - } }; - return t.Provider.__ = t.Consumer.contextType = t; -} -M = Z.slice, d = { __e: function(_, e, t, i) { - for (var n, r2, l2; e = e.__; ) - if ((n = e.__c) && !n.__) - try { - if ((r2 = n.constructor) && r2.getDerivedStateFromError != null && (n.setState(r2.getDerivedStateFromError(_)), l2 = n.__d), n.componentDidCatch != null && (n.componentDidCatch(_, i || {}), l2 = n.__d), l2) - return n.__E = n; - } catch (s) { - _ = s; - } - throw _; -} }, Q = 0, re = function(_) { - return _ != null && _.constructor == null; -}, F.prototype.setState = function(_, e) { - var t; - t = this.__s != null && this.__s !== this.state ? this.__s : this.__s = b({}, this.state), typeof _ == "function" && (_ = _(b({}, t), this.props)), _ && b(t, _), _ != null && this.__v && (e && this._sb.push(e), O(this)); -}, F.prototype.forceUpdate = function(_) { - this.__v && (this.__e = true, _ && this.__h.push(_), O(this)); -}, F.prototype.render = I, C = [], X = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, A = function(_, e) { - return _.__v.__b - e.__v.__b; -}, W.__r = 0, V = 0, R = K(false), $ = K(true), Y = 0; - -// importmap-url:https://esm.sh/stable/preact@10.22.0/denonext/hooks.js -var c; -var r; -var H2; -var b2; -var v = 0; -var x2 = []; -var p = []; -var o = d; -var g = o.__b; -var C2 = o.__r; -var A2 = o.diffed; -var D = o.__c; -var F2 = o.unmount; -var k = o.__; -function l(t, _) { - o.__h && o.__h(r, t, v || _), v = 0; - var u = r.__H || (r.__H = { __: [], __h: [] }); - return t >= u.__.length && u.__.push({ __V: p }), u.__[t]; -} -function I2(t) { - return v = 1, R2(U2, t); -} -function R2(t, _, u) { - var n = l(c++, 2); - if (n.t = t, !n.__c && (n.__ = [u ? u(_) : U2(void 0, _), function(a) { - var f = n.__N ? n.__N[0] : n.__[0], s = n.t(f, a); - f !== s && (n.__N = [s, n.__[1]], n.__c.setState({})); - }], n.__c = r, !r.u)) { - var i = function(a, f, s) { - if (!n.__c.__H) - return true; - var m = n.__c.__H.__.filter(function(e) { - return !!e.__c; - }); - if (m.every(function(e) { - return !e.__N; - })) - return !h2 || h2.call(this, a, f, s); - var V2 = false; - return m.forEach(function(e) { - if (e.__N) { - var P2 = e.__[0]; - e.__ = e.__N, e.__N = void 0, P2 !== e.__[0] && (V2 = true); - } - }), !(!V2 && n.__c.props === a) && (!h2 || h2.call(this, a, f, s)); - }; - r.u = true; - var h2 = r.shouldComponentUpdate, N2 = r.componentWillUpdate; - r.componentWillUpdate = function(a, f, s) { - if (this.__e) { - var m = h2; - h2 = void 0, i(a, f, s), h2 = m; - } - N2 && N2.call(this, a, f, s); - }, r.shouldComponentUpdate = i; - } - return n.__N || n.__; -} -function z2(t, _) { - var u = l(c++, 3); - !o.__s && y(u.__H, _) && (u.__ = t, u.i = _, r.__H.__h.push(u)); -} -function S2(t, _) { - var u = l(c++, 4); - !o.__s && y(u.__H, _) && (u.__ = t, u.i = _, r.__h.push(u)); -} -function L2(t) { - return v = 5, T(function() { - return { current: t }; - }, []); -} -function M2(t, _, u) { - v = 6, S2(function() { - return typeof t == "function" ? (t(_()), function() { - return t(null); - }) : t ? (t.current = _(), function() { - return t.current = null; - }) : void 0; - }, u == null ? u : u.concat(t)); -} -function T(t, _) { - var u = l(c++, 7); - return y(u.__H, _) ? (u.__V = t(), u.i = _, u.__h = t, u.__V) : u.__; -} -function G2(t, _) { - return v = 8, T(function() { - return t; - }, _); -} -function J2(t) { - var _ = r.context[t.__c], u = l(c++, 9); - return u.c = t, _ ? (u.__ == null && (u.__ = true, _.sub(r)), _.props.value) : t.__; -} -function K2(t, _) { - o.useDebugValue && o.useDebugValue(_ ? _(t) : t); -} -function Q2() { - var t = l(c++, 11); - if (!t.__) { - for (var _ = r.__v; _ !== null && !_.__m && _.__ !== null; ) - _ = _.__; - var u = _.__m || (_.__m = [0, 0]); - t.__ = "P" + u[0] + "-" + u[1]++; - } - return t.__; -} -function W2() { - for (var t; t = x2.shift(); ) - if (t.__P && t.__H) - try { - t.__H.__h.forEach(d2), t.__H.__h.forEach(E), t.__H.__h = []; - } catch (_) { - t.__H.__h = [], o.__e(_, t.__v); - } -} -o.__b = function(t) { - r = null, g && g(t); -}, o.__ = function(t, _) { - t && _.__k && _.__k.__m && (t.__m = _.__k.__m), k && k(t, _); -}, o.__r = function(t) { - C2 && C2(t), c = 0; - var _ = (r = t.__c).__H; - _ && (H2 === r ? (_.__h = [], r.__h = [], _.__.forEach(function(u) { - u.__N && (u.__ = u.__N), u.__V = p, u.__N = u.i = void 0; - })) : (_.__h.forEach(d2), _.__h.forEach(E), _.__h = [], c = 0)), H2 = r; -}, o.diffed = function(t) { - A2 && A2(t); - var _ = t.__c; - _ && _.__H && (_.__H.__h.length && (x2.push(_) !== 1 && b2 === o.requestAnimationFrame || ((b2 = o.requestAnimationFrame) || j2)(W2)), _.__H.__.forEach(function(u) { - u.i && (u.__H = u.i), u.__V !== p && (u.__ = u.__V), u.i = void 0, u.__V = p; - })), H2 = r = null; -}, o.__c = function(t, _) { - _.some(function(u) { - try { - u.__h.forEach(d2), u.__h = u.__h.filter(function(n) { - return !n.__ || E(n); - }); - } catch (n) { - _.some(function(i) { - i.__h && (i.__h = []); - }), _ = [], o.__e(n, u.__v); - } - }), D && D(t, _); -}, o.unmount = function(t) { - F2 && F2(t); - var _, u = t.__c; - u && u.__H && (u.__H.__.forEach(function(n) { - try { - d2(n); - } catch (i) { - _ = i; - } - }), u.__H = void 0, _ && o.__e(_, u.__v)); -}; -var q = typeof requestAnimationFrame == "function"; -function j2(t) { - var _, u = function() { - clearTimeout(n), q && cancelAnimationFrame(_), setTimeout(t); - }, n = setTimeout(u, 100); - q && (_ = requestAnimationFrame(u)); -} -function d2(t) { - var _ = r, u = t.__c; - typeof u == "function" && (t.__c = void 0, u()), r = _; -} -function E(t) { - var _ = r; - t.__c = t.__(), r = _; -} -function y(t, _) { - return !t || t.length !== _.length || _.some(function(u, n) { - return u !== t[n]; - }); -} -function U2(t, _) { - return typeof _ == "function" ? _(t) : _; -} - -// importmap-url:https://esm.sh/stable/preact@10.22.0/denonext/compat.js -function $2(e, t) { - for (var n in t) - e[n] = t[n]; - return e; -} -function C3(e, t) { - for (var n in e) - if (n !== "__source" && !(n in t)) - return true; - for (var r2 in t) - if (r2 !== "__source" && e[r2] !== t[r2]) - return true; - return false; -} -function E2(e, t) { - this.props = e, this.context = t; -} -function ne2(e, t) { - function n(o2) { - var u = this.props.ref, a = u == o2.ref; - return !a && u && (u.call ? u(null) : u.current = null), t ? !t(this.props, o2) || !a : C3(this.props, o2); - } - function r2(o2) { - return this.shouldComponentUpdate = n, le(e, o2); - } - return r2.displayName = "Memo(" + (e.displayName || e.name) + ")", r2.prototype.isReactComponent = true, r2.__f = true, r2; -} -(E2.prototype = new F()).isPureReactComponent = true, E2.prototype.shouldComponentUpdate = function(e, t) { - return C3(this.props, e) || C3(this.state, t); -}; -var x3 = d.__b; -d.__b = function(e) { - e.type && e.type.__f && e.ref && (e.props.ref = e.ref, e.ref = null), x3 && x3(e); -}; -var re2 = typeof Symbol < "u" && Symbol.for && Symbol.for("react.forward_ref") || 3911; -function oe2(e) { - function t(n) { - var r2 = $2({}, n); - return delete r2.ref, e(r2, n.ref || null); - } - return t.$$typeof = re2, t.render = t, t.prototype.isReactComponent = t.__f = true, t.displayName = "ForwardRef(" + (e.displayName || e.name) + ")", t; -} -var k2 = function(e, t) { - return e == null ? null : ue(ue(e).map(t)); -}; -var ue2 = { map: k2, forEach: k2, count: function(e) { - return e ? ue(e).length : 0; -}, only: function(e) { - var t = ue(e); - if (t.length !== 1) - throw "Children.only"; - return t[0]; -}, toArray: ue }; -var ae2 = d.__e; -d.__e = function(e, t, n, r2) { - if (e.then) { - for (var o2, u = t; u = u.__; ) - if ((o2 = u.__c) && o2.__c) - return t.__e == null && (t.__e = n.__e, t.__k = n.__k), o2.__c(e, t); - } - ae2(e, t, n, r2); -}; -var O2 = d.unmount; -function z3(e, t, n) { - return e && (e.__c && e.__c.__H && (e.__c.__H.__.forEach(function(r2) { - typeof r2.__c == "function" && r2.__c(); - }), e.__c.__H = null), (e = $2({}, e)).__c != null && (e.__c.__P === n && (e.__c.__P = t), e.__c = null), e.__k = e.__k && e.__k.map(function(r2) { - return z3(r2, t, n); - })), e; -} -function B2(e, t, n) { - return e && n && (e.__v = null, e.__k = e.__k && e.__k.map(function(r2) { - return B2(r2, t, n); - }), e.__c && e.__c.__P === t && (e.__e && n.appendChild(e.__e), e.__c.__e = true, e.__c.__P = n)), e; -} -function h() { - this.__u = 0, this.t = null, this.__b = null; -} -function j3(e) { - var t = e.__.__c; - return t && t.__a && t.__a(e); -} -function ie2(e) { - var t, n, r2; - function o2(u) { - if (t || (t = e()).then(function(a) { - n = a.default || a; - }, function(a) { - r2 = a; - }), r2) - throw r2; - if (!n) - throw t; - return le(n, u); - } - return o2.displayName = "Lazy", o2.__f = true, o2; -} -function p2() { - this.u = null, this.o = null; -} -d.unmount = function(e) { - var t = e.__c; - t && t.__R && t.__R(), t && 32 & e.__u && (e.type = null), O2 && O2(e); -}, (h.prototype = new F()).__c = function(e, t) { - var n = t.__c, r2 = this; - r2.t == null && (r2.t = []), r2.t.push(n); - var o2 = j3(r2.__v), u = false, a = function() { - u || (u = true, n.__R = null, o2 ? o2(s) : s()); - }; - n.__R = a; - var s = function() { - if (!--r2.__u) { - if (r2.state.__a) { - var l2 = r2.state.__a; - r2.__v.__k[0] = B2(l2, l2.__c.__P, l2.__c.__O); - } - var R3; - for (r2.setState({ __a: r2.__b = null }); R3 = r2.t.pop(); ) - R3.forceUpdate(); - } - }; - r2.__u++ || 32 & t.__u || r2.setState({ __a: r2.__b = r2.__v.__k[0] }), e.then(a, a); -}, h.prototype.componentWillUnmount = function() { - this.t = []; -}, h.prototype.render = function(e, t) { - if (this.__b) { - if (this.__v.__k) { - var n = document.createElement("div"), r2 = this.__v.__k[0].__c; - this.__v.__k[0] = z3(this.__b, n, r2.__O = r2.__P); - } - this.__b = null; - } - var o2 = t.__a && le(I, null, e.fallback); - return o2 && (o2.__u &= -33), [le(I, null, t.__a ? null : e.children), o2]; -}; -var P = function(e, t, n) { - if (++n[1] === n[0] && e.o.delete(t), e.props.revealOrder && (e.props.revealOrder[0] !== "t" || !e.o.size)) - for (n = e.u; n; ) { - for (; n.length > 3; ) - n.pop()(); - if (n[1] < n[0]) - break; - e.u = n = n[2]; - } -}; -function se2(e) { - return this.getChildContext = function() { - return e.context; - }, e.children; -} -function le2(e) { - var t = this, n = e.i; - t.componentWillUnmount = function() { - ae(null, t.l), t.l = null, t.i = null; - }, t.i && t.i !== n && t.componentWillUnmount(), t.l || (t.i = n, t.l = { nodeType: 1, parentNode: n, childNodes: [], appendChild: function(r2) { - this.childNodes.push(r2), t.i.appendChild(r2); - }, insertBefore: function(r2, o2) { - this.childNodes.push(r2), t.i.appendChild(r2); - }, removeChild: function(r2) { - this.childNodes.splice(this.childNodes.indexOf(r2) >>> 1, 1), t.i.removeChild(r2); - } }), ae(le(se2, { context: t.context }, e.__v), t.l); -} -function ce2(e, t) { - var n = le(le2, { __v: e, i: t }); - return n.containerInfo = t, n; -} -(p2.prototype = new F()).__a = function(e) { - var t = this, n = j3(t.__v), r2 = t.o.get(e); - return r2[0]++, function(o2) { - var u = function() { - t.props.revealOrder ? (r2.push(o2), P(t, e, r2)) : o2(); - }; - n ? n(u) : u(); - }; -}, p2.prototype.render = function(e) { - this.u = null, this.o = /* @__PURE__ */ new Map(); - var t = ue(e.children); - e.revealOrder && e.revealOrder[0] === "b" && t.reverse(); - for (var n = t.length; n--; ) - this.o.set(t[n], this.u = [1, 0, this.u]); - return e.children; -}, p2.prototype.componentDidUpdate = p2.prototype.componentDidMount = function() { - var e = this; - this.o.forEach(function(t, n) { - P(e, n, t); - }); -}; -var Y2 = typeof Symbol < "u" && Symbol.for && Symbol.for("react.element") || 60103; -var _e2 = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/; -var fe2 = /^on(Ani|Tra|Tou|BeforeInp|Compo)/; -var pe2 = /[A-Z0-9]/g; -var de2 = typeof document < "u"; -var he2 = function(e) { - return (typeof Symbol < "u" && typeof Symbol() == "symbol" ? /fil|che|rad/ : /fil|che|ra/).test(e); -}; -function me(e, t, n) { - return t.__k == null && (t.textContent = ""), ae(e, t), typeof n == "function" && n(), e ? e.__c : null; -} -function ve2(e, t, n) { - return de(e, t), typeof n == "function" && n(), e ? e.__c : null; -} -F.prototype.isReactComponent = {}, ["componentWillMount", "componentWillReceiveProps", "componentWillUpdate"].forEach(function(e) { - Object.defineProperty(F.prototype, e, { configurable: true, get: function() { - return this["UNSAFE_" + e]; - }, set: function(t) { - Object.defineProperty(this, e, { configurable: true, writable: true, value: t }); - } }); -}); -var w = d.event; -function ye2() { -} -function be() { - return this.cancelBubble; -} -function Ce() { - return this.defaultPrevented; -} -d.event = function(e) { - return w && (e = w(e)), e.persist = ye2, e.isPropagationStopped = be, e.isDefaultPrevented = Ce, e.nativeEvent = e; -}; -var N; -var Ee = { enumerable: false, configurable: true, get: function() { - return this.class; -} }; -var I3 = d.vnode; -d.vnode = function(e) { - typeof e.type == "string" && function(t) { - var n = t.props, r2 = t.type, o2 = {}; - for (var u in n) { - var a = n[u]; - if (!(u === "value" && "defaultValue" in n && a == null || de2 && u === "children" && r2 === "noscript" || u === "class" || u === "className")) { - var s = u.toLowerCase(); - u === "defaultValue" && "value" in n && n.value == null ? u = "value" : u === "download" && a === true ? a = "" : s === "translate" && a === "no" ? a = false : s === "ondoubleclick" ? u = "ondblclick" : s !== "onchange" || r2 !== "input" && r2 !== "textarea" || he2(n.type) ? s === "onfocus" ? u = "onfocusin" : s === "onblur" ? u = "onfocusout" : fe2.test(u) ? u = s : r2.indexOf("-") === -1 && _e2.test(u) ? u = u.replace(pe2, "-$&").toLowerCase() : a === null && (a = void 0) : s = u = "oninput", s === "oninput" && o2[u = s] && (u = "oninputCapture"), o2[u] = a; - } - } - r2 == "select" && o2.multiple && Array.isArray(o2.value) && (o2.value = ue(n.children).forEach(function(l2) { - l2.props.selected = o2.value.indexOf(l2.props.value) != -1; - })), r2 == "select" && o2.defaultValue != null && (o2.value = ue(n.children).forEach(function(l2) { - l2.props.selected = o2.multiple ? o2.defaultValue.indexOf(l2.props.value) != -1 : o2.defaultValue == l2.props.value; - })), n.class && !n.className ? (o2.class = n.class, Object.defineProperty(o2, "className", Ee)) : (n.className && !n.class || n.class && n.className) && (o2.class = o2.className = n.className), t.props = o2; - }(e), e.$$typeof = Y2, I3 && I3(e); -}; -var U3 = d.__r; -d.__r = function(e) { - U3 && U3(e), N = e.__c; -}; -var D2 = d.diffed; -d.diffed = function(e) { - D2 && D2(e); - var t = e.props, n = e.__e; - n != null && e.type === "textarea" && "value" in t && t.value !== n.value && (n.value = t.value == null ? "" : t.value), N = null; -}; -var Se = { ReactCurrentDispatcher: { current: { readContext: function(e) { - return N.__n[e.__c].props.value; -}, useCallback: G2, useContext: J2, useDebugValue: K2, useDeferredValue: q2, useEffect: z2, useId: Q2, useImperativeHandle: M2, useInsertionEffect: J3, useLayoutEffect: S2, useMemo: T, useReducer: R2, useRef: L2, useState: I2, useSyncExternalStore: K3, useTransition: G3 } } }; -function ge(e) { - return le.bind(null, e); -} -function y2(e) { - return !!e && e.$$typeof === Y2; -} -function Ne(e) { - return y2(e) && e.type === I; -} -function Re(e) { - return !!e && !!e.displayName && (typeof e.displayName == "string" || e.displayName instanceof String) && e.displayName.startsWith("Memo("); -} -function xe(e) { - return y2(e) ? ve.apply(null, arguments) : e; -} -function ke(e) { - return !!e.__k && (ae(null, e), true); -} -function Oe(e) { - return e && (e.base || e.nodeType === 1 && e) || null; -} -var Pe = function(e, t) { - return e(t); -}; -var we = function(e, t) { - return e(t); -}; -var Ie = I; -function Z2(e) { - e(); -} -function q2(e) { - return e; -} -function G3() { - return [false, Z2]; -} -var J3 = S2; -var Ue = y2; -function K3(e, t) { - var n = t(), r2 = I2({ h: { __: n, v: t } }), o2 = r2[0].h, u = r2[1]; - return S2(function() { - o2.__ = n, o2.v = t, b3(o2) && u({ h: o2 }); - }, [e, n, t]), z2(function() { - return b3(o2) && u({ h: o2 }), e(function() { - b3(o2) && u({ h: o2 }); - }); - }, [e]), n; -} -function b3(e) { - var t, n, r2 = e.v, o2 = e.__; - try { - var u = r2(); - return !((t = o2) === (n = u) && (t !== 0 || 1 / t == 1 / n) || t != t && n != n); - } catch { - return true; - } -} -var Me = { useState: I2, useId: Q2, useReducer: R2, useEffect: z2, useLayoutEffect: S2, useInsertionEffect: J3, useTransition: G3, useDeferredValue: q2, useSyncExternalStore: K3, startTransition: Z2, useRef: L2, useImperativeHandle: M2, useMemo: T, useCallback: G2, useContext: J2, useDebugValue: K2, version: "17.0.2", Children: ue2, render: me, hydrate: ve2, unmountComponentAtNode: ke, createPortal: ce2, createElement: le, createContext: ye, createFactory: ge, cloneElement: xe, createRef: he, Fragment: I, isValidElement: y2, isElement: Ue, isFragment: Ne, isMemo: Re, findDOMNode: Oe, Component: F, PureComponent: E2, memo: ne2, forwardRef: oe2, flushSync: we, unstable_batchedUpdates: Pe, StrictMode: Ie, Suspense: h, SuspenseList: p2, lazy: ie2, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: Se }; - -// importmap-url:https://esm.sh/stable/preact@10.22.0/denonext/jsx-runtime.js -var d3 = 0; -var x4 = Array.isArray; -function g2(r2, t, e, a, o2, s) { - t || (t = {}); - var i, n, f = t; - if ("ref" in f) - for (n in f = {}, t) - n == "ref" ? i = t[n] : f[n] = t[n]; - var u = { type: r2, props: f, key: e, ref: i, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: --d3, __i: -1, __u: 0, __source: o2, __self: s }; - if (typeof r2 == "function" && (i = r2.defaultProps)) - for (n in i) - f[n] === void 0 && (f[n] = i[n]); - return d.vnode && d.vnode(u), u; -} - -// importmap-url:file:///C:/Local%20Web%20Projects/deno-esbuild-bundler/other.tsx -var other_default = "TEST STRING"; -var app = () => { - const [stateGet, stateSet] = I2(7); - return /* @__PURE__ */ g2("div", { children: /* @__PURE__ */ g2("h1", { children: [ - "lolidk ", - /* @__PURE__ */ g2("button", { onClick: (_) => stateSet(stateGet + 1), children: stateGet }) - ] }) }); -}; - -// importmap-url:file:///C:/Local%20Web%20Projects/deno-esbuild-bundler/app.tsx -console.log(other_default, app); -Me.render(Me.createElement(app, null), document.querySelector("#app")); diff --git a/introspect.tsx b/introspect.tsx new file mode 100644 index 0000000..2658851 --- /dev/null +++ b/introspect.tsx @@ -0,0 +1,78 @@ +import { parse as JSONC } from "https://deno.land/x/jsonct@v0.1.0/mod.ts"; + +type JsonBase = Record +type JsonDeep = Record +type JsonLike = JsonDeep + +type Configuration = {imports:JsonDeep, compilerOptions:JsonDeep}; + +export const Root = new URL(`file://${Deno.cwd().replaceAll("\\", "/")}`).toString(); +export default async function HuntConfig() +{ + let path:string, json:JsonLike|undefined; + + const loadJSON =async(inPath:string)=>{ + try{ + const resp = await fetch(Root + "/" + inPath); + if(inPath.endsWith(".jsonc")) + { + const text = await resp.text(); + json = JSONC(text) as JsonLike; + } + else + { + json = await resp.json(); + } + return json; + } + catch(_e) + { + return {}; + } + } + + try// look for `deno.json` + { + json = await loadJSON("deno.json"); + } + catch(_e) + { + + try // look for `deno.jsonc` + { + json = await loadJSON("deno.jsonc"); + } + catch(_e) + { + try // look in the vscode plugin settings + { + json = await loadJSON(".vscode/settings.json") + path = json ? json["deno.config"] as string : ""; + json = undefined; + if(path) + { + json = await loadJSON(path) + } + } + catch(_e) + { + // cant find a config using the vscode plugin + } + } + } + + if(!json) + { + json = {}; + } + + + path = json.importMap as string; + if(!json.imports && path) + { + json.imports = await loadJSON(path) as Record; + } + + return json as {imports:JsonDeep, compilerOptions:JsonLike}; + +} \ No newline at end of file diff --git a/mod.ts b/mod.ts new file mode 100644 index 0000000..3496468 --- /dev/null +++ b/mod.ts @@ -0,0 +1,70 @@ +import * as ESBuildWASM from "https://deno.land/x/esbuild@v0.21.4/wasm.js"; +import * as Mapper from "https://esm.sh/esbuild-plugin-importmaps@1.0.0"; // https://github.com/andstellar/esbuild-plugin-importmaps | https://github.com/jspm/import-map + +import { ImportMap, type IImportMap } from "https://esm.sh/@jspm/import-map"; + +export const Root = new URL(`file://${Deno.cwd().replaceAll("\\", "/")}`).toString(); + +function importmapPlugin(importmap:IImportMap):ESBuildWASM.Plugin { + const map = new ImportMap({ + map: importmap, + }); + + return { + name: "importmap-url", + setup(build) { + build.onResolve({ filter: /^[^.].*$/ }, (args) => { + let path; + try + { + path = map.resolve(args.path, args.importer); + console.log("resolved path:", path); + return { path, namespace: "importmap-url" }; + } + catch(e) + { + console.log("e r r o r:", args); + return { path: args.importer }; + } + + + }); + + build.onLoad( + { filter: /.*/, namespace: "importmap-url" }, + async (args) => { + const response = await fetch(args.path); + const contents = await response.text(); + const ext = args.path.split(".").pop(); + const loader = /** @type {import('esbuild').Loader} */ ( + ext?.match(/"j|tsx?$/) ? ext : "js" + ); + console.log("loaded", args); + return { contents, loader } as ESBuildWASM.OnLoadResult; + }, + ); + }, + }; +} + +export default async(importMap:IImportMap, buildOptions?:ESBuildWASM.BuildOptions)=> +{ + await ESBuildWASM.initialize({ worker: false }); + const result = await ESBuildWASM.build({ + entryPoints: ["entry"], + bundle: true, + minify: true, + format: "esm", + outfile:"bundle.js", + entryNames: `[dir][name]`, + jsx: "automatic", + jsxImportSource: "react", + ...buildOptions, + plugins:[ + ...buildOptions?.plugins??[], + importmapPlugin(importMap) as ESBuildWASM.Plugin + ] + }); + ESBuildWASM.stop(); + return result; +}; \ No newline at end of file diff --git a/serve.tsx b/serve.tsx new file mode 100644 index 0000000..6d46069 --- /dev/null +++ b/serve.tsx @@ -0,0 +1,30 @@ +import bundler from "./mod.ts"; +import Introspect, {Root} from "./introspect.tsx"; + +const Config = await Introspect(); + +console.log(Config.imports); + +const transpiled:Map = new Map(); + +Deno.serve(async(req)=>{ + const url = new URL(req.url); + const index = url.pathname.lastIndexOf("."); + if(index > -1) + { + const ext = url.pathname.substring(index+1, index+3); + if(ext === "ts") + { + const results = await bundler({imports:Config.imports}, { + entryPoints:[Root+url.pathname], + outfile:"bundle.js", + entryNames: `[dir][name]`, + }); + results.outputFiles?.forEach(output=>{ + transpiled.set(output.path, output.text); + }) + return new Response(results.outputFiles[0].text, {headers:{"content-type":"application/javascript"}}); + } + } + return new Response(Root+url.pathname); +}); \ No newline at end of file