jq79 0.3.27 → 0.3.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dev.cjs ADDED
@@ -0,0 +1,186 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // dev/dev.ts
20
+ var dev_exports = {};
21
+ __export(dev_exports, {
22
+ default: () => dev_default,
23
+ devServer: () => devServer
24
+ });
25
+ module.exports = __toCommonJS(dev_exports);
26
+ var import_node_http = require("http");
27
+ var import_promises = require("fs/promises");
28
+ var import_node_fs = require("fs");
29
+ var import_node_path = require("path");
30
+ var CONTENT_TYPES = {
31
+ ".html": "text/html; charset=utf-8",
32
+ ".js": "text/javascript; charset=utf-8",
33
+ ".mjs": "text/javascript; charset=utf-8",
34
+ ".json": "application/json; charset=utf-8",
35
+ ".css": "text/css; charset=utf-8",
36
+ ".svg": "image/svg+xml",
37
+ ".png": "image/png",
38
+ ".jpg": "image/jpeg",
39
+ ".jpeg": "image/jpeg",
40
+ ".gif": "image/gif",
41
+ ".webp": "image/webp",
42
+ ".avif": "image/avif",
43
+ ".ico": "image/x-icon",
44
+ ".woff": "font/woff",
45
+ ".woff2": "font/woff2",
46
+ ".map": "application/json; charset=utf-8"
47
+ };
48
+ var CLIENT_URL = "/__jq79/client.js";
49
+ var EVENTS_URL = "/__jq79/events";
50
+ var CLIENT = `(() => {
51
+ window.__JQ79_HMR_ENABLED__ = true
52
+
53
+ const events = new EventSource(${JSON.stringify(EVENTS_URL)})
54
+
55
+ events.addEventListener("update", event => {
56
+ const { url, src } = JSON.parse(event.data)
57
+ const runtime = window.__JQ79_HMR__
58
+ // no runtime (the page doesn't use jq79), or no live instance from this
59
+ // file (it isn't mounted, or it *is* the page) - nothing to swap into
60
+ const patched = runtime ? runtime.update(url, src) : 0
61
+ if (patched) console.log("[jq79] hot-updated " + url + " (" + patched + (patched === 1 ? " instance)" : " instances)"))
62
+ else location.reload()
63
+ })
64
+
65
+ events.addEventListener("reload", () => location.reload())
66
+ })()`;
67
+ var posix = (path) => path.split(import_node_path.sep).join("/");
68
+ var isDocument = (req) => req.headers["sec-fetch-dest"] === "document";
69
+ var injectClient = (html) => {
70
+ const tag = `<script src="${CLIENT_URL}"></script>`;
71
+ const open = /<head[^>]*>/i.exec(html) ?? /<body[^>]*>/i.exec(html);
72
+ if (!open) return tag + html;
73
+ const at = open.index + open[0].length;
74
+ return html.slice(0, at) + tag + html.slice(at);
75
+ };
76
+ var devServer = async (options = {}) => {
77
+ const root = await (0, import_promises.realpath)((0, import_node_path.resolve)(options.rootDir ?? "."));
78
+ const host = options.host ?? "localhost";
79
+ const clients = /* @__PURE__ */ new Set();
80
+ const send = (event, data) => {
81
+ const frame = `event: ${event}
82
+ data: ${JSON.stringify(data)}
83
+
84
+ `;
85
+ clients.forEach((client) => client.write(frame));
86
+ };
87
+ const serveStatic = async (req, res, pathname) => {
88
+ let file;
89
+ try {
90
+ file = (0, import_node_path.resolve)((0, import_node_path.join)(root, decodeURIComponent(pathname)));
91
+ } catch {
92
+ res.writeHead(400).end("bad request");
93
+ return;
94
+ }
95
+ if (file !== root && !file.startsWith(root + import_node_path.sep)) {
96
+ res.writeHead(403).end("forbidden");
97
+ return;
98
+ }
99
+ try {
100
+ if ((await (0, import_promises.stat)(file)).isDirectory()) file = (0, import_node_path.join)(file, "index.html");
101
+ const body = await (0, import_promises.readFile)(file);
102
+ const type = CONTENT_TYPES[(0, import_node_path.extname)(file).toLowerCase()] ?? "application/octet-stream";
103
+ const html = type.startsWith("text/html") && isDocument(req);
104
+ const payload = html ? Buffer.from(injectClient(body.toString("utf8"))) : body;
105
+ res.writeHead(200, {
106
+ "content-type": type,
107
+ "content-length": payload.byteLength,
108
+ "cache-control": "no-store"
109
+ // the file on disk is always the truth here
110
+ });
111
+ res.end(payload);
112
+ } catch {
113
+ res.writeHead(404, { "content-type": "text/plain; charset=utf-8" }).end("not found");
114
+ }
115
+ };
116
+ const server = (0, import_node_http.createServer)((req, res) => {
117
+ const pathname = (req.url ?? "/").split(/[?#]/)[0];
118
+ if (pathname === CLIENT_URL) {
119
+ res.writeHead(200, { "content-type": "text/javascript; charset=utf-8", "cache-control": "no-store" });
120
+ res.end(CLIENT);
121
+ return;
122
+ }
123
+ if (pathname === EVENTS_URL) {
124
+ res.writeHead(200, {
125
+ "content-type": "text/event-stream",
126
+ "cache-control": "no-store",
127
+ connection: "keep-alive"
128
+ });
129
+ res.write(": jq79\n\n");
130
+ clients.add(res);
131
+ req.on("close", () => clients.delete(res));
132
+ return;
133
+ }
134
+ void serveStatic(req, res, pathname);
135
+ });
136
+ const ignored = (rel) => rel.split(import_node_path.sep).some((part) => part.startsWith(".") || part === "node_modules");
137
+ const pending = /* @__PURE__ */ new Map();
138
+ const changed = async (rel) => {
139
+ const file = (0, import_node_path.join)(root, rel);
140
+ let src = null;
141
+ try {
142
+ if ((await (0, import_promises.stat)(file)).isDirectory()) return;
143
+ if (rel.endsWith(".html")) src = await (0, import_promises.readFile)(file, "utf8");
144
+ } catch {
145
+ if (rel === (0, import_node_path.basename)(root)) return;
146
+ }
147
+ const url = "/" + posix(rel);
148
+ if (src === null) send("reload", { url });
149
+ else send("update", { url, src });
150
+ };
151
+ const watcher = (0, import_node_fs.watch)(root, { recursive: true }, (_event, filename) => {
152
+ if (!filename) return;
153
+ const rel = (0, import_node_path.relative)(root, (0, import_node_path.resolve)(root, filename.toString()));
154
+ if (!rel || rel.startsWith("..") || ignored(rel)) return;
155
+ clearTimeout(pending.get(rel));
156
+ pending.set(rel, setTimeout(() => {
157
+ pending.delete(rel);
158
+ void changed(rel);
159
+ }, 30));
160
+ });
161
+ const heartbeat = setInterval(() => clients.forEach((client) => client.write(": ping\n\n")), 3e4);
162
+ heartbeat.unref();
163
+ await new Promise((done, fail) => {
164
+ server.once("error", fail);
165
+ server.listen(options.port ?? 4179, host, done);
166
+ });
167
+ const { port } = server.address();
168
+ return {
169
+ url: `http://${host}:${port}`,
170
+ port,
171
+ close: () => new Promise((done) => {
172
+ clearInterval(heartbeat);
173
+ watcher.close();
174
+ pending.forEach(clearTimeout);
175
+ clients.forEach((client) => client.end());
176
+ clients.clear();
177
+ server.close(() => done());
178
+ })
179
+ };
180
+ };
181
+ var dev_default = devServer;
182
+ // Annotate the CommonJS export names for ESM import in node:
183
+ 0 && (module.exports = {
184
+ devServer
185
+ });
186
+ //# sourceMappingURL=dev.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../dev/dev.ts"],"sourcesContent":["import { createServer, type Server, type IncomingMessage, type ServerResponse } from \"node:http\"\nimport { readFile, realpath, stat } from \"node:fs/promises\"\nimport { watch, type FSWatcher } from \"node:fs\"\nimport { basename, extname, join, relative, resolve, sep } from \"node:path\"\n\n// A dev server for the no-bundle path: serve a directory of .html components\n// over HTTP, watch it, and hot-reload the components that changed.\n//\n// npx jq79 dev // the CLI\n// import { devServer } from \"jq79/dev\" // or from a script\n// await devServer({ rootDir: \".\" })\n//\n// It is a static file server and nothing else - no transforms, no bundling, no\n// module graph. Which is the point: the files it serves are the files you would\n// deploy, so what you develop against and what a static host serves are the same\n// bytes. The one thing it adds is the hot-reload channel, and it adds it to\n// *documents* only (a component fetched by the runtime is served verbatim).\n//\n// The reload is fine-grained. On a change the server pushes the new source down\n// an SSE channel and the runtime swaps it into every live instance of that file,\n// keeping its data - see hotUpdate in jq79.ts. Anything the runtime can't place\n// (a page, a stylesheet, a component nothing has mounted yet) falls back to a\n// full page reload.\n\nexport interface DevServerOptions {\n // the directory to serve, and to watch (default: the current directory)\n rootDir?: string\n // default: 4179, or the first free port after it\n port?: number\n // default: localhost\n host?: string\n}\n\nexport interface DevServer {\n url: string\n port: number\n close: () => Promise<void>\n}\n\nconst CONTENT_TYPES: Record<string, string> = {\n \".html\": \"text/html; charset=utf-8\",\n \".js\": \"text/javascript; charset=utf-8\",\n \".mjs\": \"text/javascript; charset=utf-8\",\n \".json\": \"application/json; charset=utf-8\",\n \".css\": \"text/css; charset=utf-8\",\n \".svg\": \"image/svg+xml\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".webp\": \"image/webp\",\n \".avif\": \"image/avif\",\n \".ico\": \"image/x-icon\",\n \".woff\": \"font/woff\",\n \".woff2\": \"font/woff2\",\n \".map\": \"application/json; charset=utf-8\",\n}\n\nconst CLIENT_URL = \"/__jq79/client.js\"\nconst EVENTS_URL = \"/__jq79/events\"\n\n// Served as a *classic* script, and injected into the <head>: classic scripts\n// run at parse time and module scripts are deferred, so the flag is set before\n// the page's `import ... from \"jq79\"` evaluates - which is what the runtime\n// waits for before it starts tracking instances. The client can't import the\n// runtime itself: the page's copy may come from a CDN or an import map, and a\n// second copy would have a second, empty registry.\nconst CLIENT = `(() => {\n window.__JQ79_HMR_ENABLED__ = true\n\n const events = new EventSource(${JSON.stringify(EVENTS_URL)})\n\n events.addEventListener(\"update\", event => {\n const { url, src } = JSON.parse(event.data)\n const runtime = window.__JQ79_HMR__\n // no runtime (the page doesn't use jq79), or no live instance from this\n // file (it isn't mounted, or it *is* the page) - nothing to swap into\n const patched = runtime ? runtime.update(url, src) : 0\n if (patched) console.log(\"[jq79] hot-updated \" + url + \" (\" + patched + (patched === 1 ? \" instance)\" : \" instances)\"))\n else location.reload()\n })\n\n events.addEventListener(\"reload\", () => location.reload())\n})()`\n\nconst posix = (path: string) => path.split(sep).join(\"/\")\n\nconst isDocument = (req: IncomingMessage) => req.headers[\"sec-fetch-dest\"] === \"document\"\n\n// the client goes in the <head> so it is the first thing the page runs. A file\n// with neither <head> nor <body> is still a document a browser will render, so\n// fall back to the top of it rather than skipping the injection\nconst injectClient = (html: string): string => {\n const tag = `<script src=\"${CLIENT_URL}\"></script>`\n const open = /<head[^>]*>/i.exec(html) ?? /<body[^>]*>/i.exec(html)\n if (!open) return tag + html\n const at = open.index + open[0].length\n return html.slice(0, at) + tag + html.slice(at)\n}\n\nexport const devServer = async (options: DevServerOptions = {}): Promise<DevServer> => {\n // the *real* path: the watcher reports what changed relative to the directory\n // it actually opened, so a root reached through a symlink (/tmp and /var are\n // symlinks on macOS) would hand back paths that don't line up with it\n const root = await realpath(resolve(options.rootDir ?? \".\"))\n const host = options.host ?? \"localhost\"\n\n const clients = new Set<ServerResponse>()\n\n const send = (event: string, data: unknown) => {\n const frame = `event: ${event}\\ndata: ${JSON.stringify(data)}\\n\\n`\n clients.forEach(client => client.write(frame))\n }\n\n // --- serving ---------------------------------------------------------------\n\n const serveStatic = async (req: IncomingMessage, res: ServerResponse, pathname: string) => {\n // a URL path is not a file path: decode it, then keep the result inside the\n // root (\"..\" in a request must not walk out of the served directory)\n let file: string\n try {\n file = resolve(join(root, decodeURIComponent(pathname)))\n } catch {\n res.writeHead(400).end(\"bad request\")\n return\n }\n if (file !== root && !file.startsWith(root + sep)) {\n res.writeHead(403).end(\"forbidden\")\n return\n }\n\n try {\n if ((await stat(file)).isDirectory()) file = join(file, \"index.html\")\n const body = await readFile(file)\n const type = CONTENT_TYPES[extname(file).toLowerCase()] ?? \"application/octet-stream\"\n\n // only a navigation gets the hot-reload client. A component is fetched by\n // the runtime (sec-fetch-dest: empty), and it must arrive as written -\n // injecting a <script> into it would make the runtime parse and run it\n const html = type.startsWith(\"text/html\") && isDocument(req)\n const payload = html ? Buffer.from(injectClient(body.toString(\"utf8\"))) : body\n\n res.writeHead(200, {\n \"content-type\": type,\n \"content-length\": payload.byteLength,\n \"cache-control\": \"no-store\", // the file on disk is always the truth here\n })\n res.end(payload)\n } catch {\n res.writeHead(404, { \"content-type\": \"text/plain; charset=utf-8\" }).end(\"not found\")\n }\n }\n\n const server: Server = createServer((req, res) => {\n const pathname = (req.url ?? \"/\").split(/[?#]/)[0]\n\n if (pathname === CLIENT_URL) {\n res.writeHead(200, { \"content-type\": \"text/javascript; charset=utf-8\", \"cache-control\": \"no-store\" })\n res.end(CLIENT)\n return\n }\n\n if (pathname === EVENTS_URL) {\n res.writeHead(200, {\n \"content-type\": \"text/event-stream\",\n \"cache-control\": \"no-store\",\n connection: \"keep-alive\",\n })\n res.write(\": jq79\\n\\n\") // opens the stream, so the browser fires onopen\n clients.add(res)\n req.on(\"close\", () => clients.delete(res))\n return\n }\n\n void serveStatic(req, res, pathname)\n })\n\n // --- watching --------------------------------------------------------------\n\n const ignored = (rel: string) =>\n rel.split(sep).some(part => part.startsWith(\".\") || part === \"node_modules\")\n\n // one save can arrive as several events (a rename plus a change, an editor's\n // atomic write); collapsing per file keeps that down to one push\n const pending = new Map<string, NodeJS.Timeout>()\n\n const changed = async (rel: string) => {\n const file = join(root, rel)\n\n let src: string | null = null\n try {\n // a directory changes whenever anything inside it does, and the event for\n // the file itself is already on its way - acting on both would reload the\n // page every time a component is saved\n if ((await stat(file)).isDirectory()) return\n if (rel.endsWith(\".html\")) src = await readFile(file, \"utf8\")\n } catch {\n // gone: deleted, or renamed away - and there is nothing to swap in, so the\n // page has to reload. Unless it was never there: macOS reports a change to\n // the watched directory *itself* under its own basename, which resolves to\n // a path inside it that does not exist\n if (rel === basename(root)) return\n }\n\n // the url is the one the component was served from, because that is what the\n // runtime resolves its instances' filenames against\n const url = \"/\" + posix(rel)\n if (src === null) send(\"reload\", { url })\n else send(\"update\", { url, src })\n }\n\n const watcher: FSWatcher = watch(root, { recursive: true }, (_event, filename) => {\n if (!filename) return\n const rel = relative(root, resolve(root, filename.toString()))\n if (!rel || rel.startsWith(\"..\") || ignored(rel)) return\n\n clearTimeout(pending.get(rel))\n pending.set(rel, setTimeout(() => {\n pending.delete(rel)\n void changed(rel)\n }, 30))\n })\n\n // proxies and load balancers cut an idle stream; a comment every 30s is the\n // conventional way to keep it open. unref'd, so it never holds the process up\n const heartbeat = setInterval(() => clients.forEach(client => client.write(\": ping\\n\\n\")), 30_000)\n heartbeat.unref()\n\n // --- go --------------------------------------------------------------------\n\n await new Promise<void>((done, fail) => {\n server.once(\"error\", fail)\n server.listen(options.port ?? 4179, host, done)\n })\n const { port } = server.address() as { port: number }\n\n return {\n url: `http://${host}:${port}`,\n port,\n close: () =>\n new Promise(done => {\n clearInterval(heartbeat)\n watcher.close()\n pending.forEach(clearTimeout)\n clients.forEach(client => client.end())\n clients.clear()\n server.close(() => done())\n }),\n }\n}\n\nexport default devServer\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAqF;AACrF,sBAAyC;AACzC,qBAAsC;AACtC,uBAAgE;AAoChE,IAAM,gBAAwC;AAAA,EAC5C,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,QAAQ;AACV;AAEA,IAAM,aAAa;AACnB,IAAM,aAAa;AAQnB,IAAM,SAAS;AAAA;AAAA;AAAA,mCAGoB,KAAK,UAAU,UAAU,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAe7D,I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IAAI,CAAC;AACtC,cAAQ,MAAM;AACd,aAAO,MAAM,MAAM,KAAK,CAAC;AAAA,IAC3B,CAAC;AAAA,EACL;AACF;AAEA,IAAO,cAAQ;","names":[]}
package/dist/dev.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ export interface DevServerOptions {
2
+ rootDir?: string;
3
+ port?: number;
4
+ host?: string;
5
+ }
6
+ export interface DevServer {
7
+ url: string;
8
+ port: number;
9
+ close: () => Promise<void>;
10
+ }
11
+ export declare const devServer: (options?: DevServerOptions) => Promise<DevServer>;
12
+ export default devServer;
package/dist/dev.js ADDED
@@ -0,0 +1,162 @@
1
+ // dev/dev.ts
2
+ import { createServer } from "http";
3
+ import { readFile, realpath, stat } from "fs/promises";
4
+ import { watch } from "fs";
5
+ import { basename, extname, join, relative, resolve, sep } from "path";
6
+ var CONTENT_TYPES = {
7
+ ".html": "text/html; charset=utf-8",
8
+ ".js": "text/javascript; charset=utf-8",
9
+ ".mjs": "text/javascript; charset=utf-8",
10
+ ".json": "application/json; charset=utf-8",
11
+ ".css": "text/css; charset=utf-8",
12
+ ".svg": "image/svg+xml",
13
+ ".png": "image/png",
14
+ ".jpg": "image/jpeg",
15
+ ".jpeg": "image/jpeg",
16
+ ".gif": "image/gif",
17
+ ".webp": "image/webp",
18
+ ".avif": "image/avif",
19
+ ".ico": "image/x-icon",
20
+ ".woff": "font/woff",
21
+ ".woff2": "font/woff2",
22
+ ".map": "application/json; charset=utf-8"
23
+ };
24
+ var CLIENT_URL = "/__jq79/client.js";
25
+ var EVENTS_URL = "/__jq79/events";
26
+ var CLIENT = `(() => {
27
+ window.__JQ79_HMR_ENABLED__ = true
28
+
29
+ const events = new EventSource(${JSON.stringify(EVENTS_URL)})
30
+
31
+ events.addEventListener("update", event => {
32
+ const { url, src } = JSON.parse(event.data)
33
+ const runtime = window.__JQ79_HMR__
34
+ // no runtime (the page doesn't use jq79), or no live instance from this
35
+ // file (it isn't mounted, or it *is* the page) - nothing to swap into
36
+ const patched = runtime ? runtime.update(url, src) : 0
37
+ if (patched) console.log("[jq79] hot-updated " + url + " (" + patched + (patched === 1 ? " instance)" : " instances)"))
38
+ else location.reload()
39
+ })
40
+
41
+ events.addEventListener("reload", () => location.reload())
42
+ })()`;
43
+ var posix = (path) => path.split(sep).join("/");
44
+ var isDocument = (req) => req.headers["sec-fetch-dest"] === "document";
45
+ var injectClient = (html) => {
46
+ const tag = `<script src="${CLIENT_URL}"></script>`;
47
+ const open = /<head[^>]*>/i.exec(html) ?? /<body[^>]*>/i.exec(html);
48
+ if (!open) return tag + html;
49
+ const at = open.index + open[0].length;
50
+ return html.slice(0, at) + tag + html.slice(at);
51
+ };
52
+ var devServer = async (options = {}) => {
53
+ const root = await realpath(resolve(options.rootDir ?? "."));
54
+ const host = options.host ?? "localhost";
55
+ const clients = /* @__PURE__ */ new Set();
56
+ const send = (event, data) => {
57
+ const frame = `event: ${event}
58
+ data: ${JSON.stringify(data)}
59
+
60
+ `;
61
+ clients.forEach((client) => client.write(frame));
62
+ };
63
+ const serveStatic = async (req, res, pathname) => {
64
+ let file;
65
+ try {
66
+ file = resolve(join(root, decodeURIComponent(pathname)));
67
+ } catch {
68
+ res.writeHead(400).end("bad request");
69
+ return;
70
+ }
71
+ if (file !== root && !file.startsWith(root + sep)) {
72
+ res.writeHead(403).end("forbidden");
73
+ return;
74
+ }
75
+ try {
76
+ if ((await stat(file)).isDirectory()) file = join(file, "index.html");
77
+ const body = await readFile(file);
78
+ const type = CONTENT_TYPES[extname(file).toLowerCase()] ?? "application/octet-stream";
79
+ const html = type.startsWith("text/html") && isDocument(req);
80
+ const payload = html ? Buffer.from(injectClient(body.toString("utf8"))) : body;
81
+ res.writeHead(200, {
82
+ "content-type": type,
83
+ "content-length": payload.byteLength,
84
+ "cache-control": "no-store"
85
+ // the file on disk is always the truth here
86
+ });
87
+ res.end(payload);
88
+ } catch {
89
+ res.writeHead(404, { "content-type": "text/plain; charset=utf-8" }).end("not found");
90
+ }
91
+ };
92
+ const server = createServer((req, res) => {
93
+ const pathname = (req.url ?? "/").split(/[?#]/)[0];
94
+ if (pathname === CLIENT_URL) {
95
+ res.writeHead(200, { "content-type": "text/javascript; charset=utf-8", "cache-control": "no-store" });
96
+ res.end(CLIENT);
97
+ return;
98
+ }
99
+ if (pathname === EVENTS_URL) {
100
+ res.writeHead(200, {
101
+ "content-type": "text/event-stream",
102
+ "cache-control": "no-store",
103
+ connection: "keep-alive"
104
+ });
105
+ res.write(": jq79\n\n");
106
+ clients.add(res);
107
+ req.on("close", () => clients.delete(res));
108
+ return;
109
+ }
110
+ void serveStatic(req, res, pathname);
111
+ });
112
+ const ignored = (rel) => rel.split(sep).some((part) => part.startsWith(".") || part === "node_modules");
113
+ const pending = /* @__PURE__ */ new Map();
114
+ const changed = async (rel) => {
115
+ const file = join(root, rel);
116
+ let src = null;
117
+ try {
118
+ if ((await stat(file)).isDirectory()) return;
119
+ if (rel.endsWith(".html")) src = await readFile(file, "utf8");
120
+ } catch {
121
+ if (rel === basename(root)) return;
122
+ }
123
+ const url = "/" + posix(rel);
124
+ if (src === null) send("reload", { url });
125
+ else send("update", { url, src });
126
+ };
127
+ const watcher = watch(root, { recursive: true }, (_event, filename) => {
128
+ if (!filename) return;
129
+ const rel = relative(root, resolve(root, filename.toString()));
130
+ if (!rel || rel.startsWith("..") || ignored(rel)) return;
131
+ clearTimeout(pending.get(rel));
132
+ pending.set(rel, setTimeout(() => {
133
+ pending.delete(rel);
134
+ void changed(rel);
135
+ }, 30));
136
+ });
137
+ const heartbeat = setInterval(() => clients.forEach((client) => client.write(": ping\n\n")), 3e4);
138
+ heartbeat.unref();
139
+ await new Promise((done, fail) => {
140
+ server.once("error", fail);
141
+ server.listen(options.port ?? 4179, host, done);
142
+ });
143
+ const { port } = server.address();
144
+ return {
145
+ url: `http://${host}:${port}`,
146
+ port,
147
+ close: () => new Promise((done) => {
148
+ clearInterval(heartbeat);
149
+ watcher.close();
150
+ pending.forEach(clearTimeout);
151
+ clients.forEach((client) => client.end());
152
+ clients.clear();
153
+ server.close(() => done());
154
+ })
155
+ };
156
+ };
157
+ var dev_default = devServer;
158
+ export {
159
+ dev_default as default,
160
+ devServer
161
+ };
162
+ //# sourceMappingURL=dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../dev/dev.ts"],"sourcesContent":["import { createServer, type Server, type IncomingMessage, type ServerResponse } from \"node:http\"\nimport { readFile, realpath, stat } from \"node:fs/promises\"\nimport { watch, type FSWatcher } from \"node:fs\"\nimport { basename, extname, join, relative, resolve, sep } from \"node:path\"\n\n// A dev server for the no-bundle path: serve a directory of .html components\n// over HTTP, watch it, and hot-reload the components that changed.\n//\n// npx jq79 dev // the CLI\n// import { devServer } from \"jq79/dev\" // or from a script\n// await devServer({ rootDir: \".\" })\n//\n// It is a static file server and nothing else - no transforms, no bundling, no\n// module graph. Which is the point: the files it serves are the files you would\n// deploy, so what you develop against and what a static host serves are the same\n// bytes. The one thing it adds is the hot-reload channel, and it adds it to\n// *documents* only (a component fetched by the runtime is served verbatim).\n//\n// The reload is fine-grained. On a change the server pushes the new source down\n// an SSE channel and the runtime swaps it into every live instance of that file,\n// keeping its data - see hotUpdate in jq79.ts. Anything the runtime can't place\n// (a page, a stylesheet, a component nothing has mounted yet) falls back to a\n// full page reload.\n\nexport interface DevServerOptions {\n // the directory to serve, and to watch (default: the current directory)\n rootDir?: string\n // default: 4179, or the first free port after it\n port?: number\n // default: localhost\n host?: string\n}\n\nexport interface DevServer {\n url: string\n port: number\n close: () => Promise<void>\n}\n\nconst CONTENT_TYPES: Record<string, string> = {\n \".html\": \"text/html; charset=utf-8\",\n \".js\": \"text/javascript; charset=utf-8\",\n \".mjs\": \"text/javascript; charset=utf-8\",\n \".json\": \"application/json; charset=utf-8\",\n \".css\": \"text/css; charset=utf-8\",\n \".svg\": \"image/svg+xml\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".webp\": \"image/webp\",\n \".avif\": \"image/avif\",\n \".ico\": \"image/x-icon\",\n \".woff\": \"font/woff\",\n \".woff2\": \"font/woff2\",\n \".map\": \"application/json; charset=utf-8\",\n}\n\nconst CLIENT_URL = \"/__jq79/client.js\"\nconst EVENTS_URL = \"/__jq79/events\"\n\n// Served as a *classic* script, and injected into the <head>: classic scripts\n// run at parse time and module scripts are deferred, so the flag is set before\n// the page's `import ... from \"jq79\"` evaluates - which is what the runtime\n// waits for before it starts tracking instances. The client can't import the\n// runtime itself: the page's copy may come from a CDN or an import map, and a\n// second copy would have a second, empty registry.\nconst CLIENT = `(() => {\n window.__JQ79_HMR_ENABLED__ = true\n\n const events = new EventSource(${JSON.stringify(EVENTS_URL)})\n\n events.addEventListener(\"update\", event => {\n const { url, src } = JSON.parse(event.data)\n const runtime = window.__JQ79_HMR__\n // no runtime (the page doesn't use jq79), or no live instance from this\n // file (it isn't mounted, or it *is* the page) - nothing to swap into\n const patched = runtime ? runtime.update(url, src) : 0\n if (patched) console.log(\"[jq79] hot-updated \" + url + \" (\" + patched + (patched === 1 ? \" instance)\" : \" instances)\"))\n else location.reload()\n })\n\n events.addEventListener(\"reload\", () => location.reload())\n})()`\n\nconst posix = (path: string) => path.split(sep).join(\"/\")\n\nconst isDocument = (req: IncomingMessage) => req.headers[\"sec-fetch-dest\"] === \"document\"\n\n// the client goes in the <head> so it is the first thing the page runs. A file\n// with neither <head> nor <body> is still a document a browser will render, so\n// fall back to the top of it rather than skipping the injection\nconst injectClient = (html: string): string => {\n const tag = `<script src=\"${CLIENT_URL}\"></script>`\n const open = /<head[^>]*>/i.exec(html) ?? /<body[^>]*>/i.exec(html)\n if (!open) return tag + html\n const at = open.index + open[0].length\n return html.slice(0, at) + tag + html.slice(at)\n}\n\nexport const devServer = async (options: DevServerOptions = {}): Promise<DevServer> => {\n // the *real* path: the watcher reports what changed relative to the directory\n // it actually opened, so a root reached through a symlink (/tmp and /var are\n // symlinks on macOS) would hand back paths that don't line up with it\n const root = await realpath(resolve(options.rootDir ?? \".\"))\n const host = options.host ?? \"localhost\"\n\n const clients = new Set<ServerResponse>()\n\n const send = (event: string, data: unknown) => {\n const frame = `event: ${event}\\ndata: ${JSON.stringify(data)}\\n\\n`\n clients.forEach(client => client.write(frame))\n }\n\n // --- serving ---------------------------------------------------------------\n\n const serveStatic = async (req: IncomingMessage, res: ServerResponse, pathname: string) => {\n // a URL path is not a file path: decode it, then keep the result inside the\n // root (\"..\" in a request must not walk out of the served directory)\n let file: string\n try {\n file = resolve(join(root, decodeURIComponent(pathname)))\n } catch {\n res.writeHead(400).end(\"bad request\")\n return\n }\n if (file !== root && !file.startsWith(root + sep)) {\n res.writeHead(403).end(\"forbidden\")\n return\n }\n\n try {\n if ((await stat(file)).isDirectory()) file = join(file, \"index.html\")\n const body = await readFile(file)\n const type = CONTENT_TYPES[extname(file).toLowerCase()] ?? \"application/octet-stream\"\n\n // only a navigation gets the hot-reload client. A component is fetched by\n // the runtime (sec-fetch-dest: empty), and it must arrive as written -\n // injecting a <script> into it would make the runtime parse and run it\n const html = type.startsWith(\"text/html\") && isDocument(req)\n const payload = html ? Buffer.from(injectClient(body.toString(\"utf8\"))) : body\n\n res.writeHead(200, {\n \"content-type\": type,\n \"content-length\": payload.byteLength,\n \"cache-control\": \"no-store\", // the file on disk is always the truth here\n })\n res.end(payload)\n } catch {\n res.writeHead(404, { \"content-type\": \"text/plain; charset=utf-8\" }).end(\"not found\")\n }\n }\n\n const server: Server = createServer((req, res) => {\n const pathname = (req.url ?? \"/\").split(/[?#]/)[0]\n\n if (pathname === CLIENT_URL) {\n res.writeHead(200, { \"content-type\": \"text/javascript; charset=utf-8\", \"cache-control\": \"no-store\" })\n res.end(CLIENT)\n return\n }\n\n if (pathname === EVENTS_URL) {\n res.writeHead(200, {\n \"content-type\": \"text/event-stream\",\n \"cache-control\": \"no-store\",\n connection: \"keep-alive\",\n })\n res.write(\": jq79\\n\\n\") // opens the stream, so the browser fires onopen\n clients.add(res)\n req.on(\"close\", () => clients.delete(res))\n return\n }\n\n void serveStatic(req, res, pathname)\n })\n\n // --- watching --------------------------------------------------------------\n\n const ignored = (rel: string) =>\n rel.split(sep).some(part => part.startsWith(\".\") || part === \"node_modules\")\n\n // one save can arrive as several events (a rename plus a change, an editor's\n // atomic write); collapsing per file keeps that down to one push\n const pending = new Map<string, NodeJS.Timeout>()\n\n const changed = async (rel: string) => {\n const file = join(root, rel)\n\n let src: string | null = null\n try {\n // a directory changes whenever anything inside it does, and the event for\n // the file itself is already on its way - acting on both would reload the\n // page every time a component is saved\n if ((await stat(file)).isDirectory()) return\n if (rel.endsWith(\".html\")) src = await readFile(file, \"utf8\")\n } catch {\n // gone: deleted, or renamed away - and there is nothing to swap in, so the\n // page has to reload. Unless it was never there: macOS reports a change to\n // the watched directory *itself* under its own basename, which resolves to\n // a path inside it that does not exist\n if (rel === basename(root)) return\n }\n\n // the url is the one the component was served from, because that is what the\n // runtime resolves its instances' filenames against\n const url = \"/\" + posix(rel)\n if (src === null) send(\"reload\", { url })\n else send(\"update\", { url, src })\n }\n\n const watcher: FSWatcher = watch(root, { recursive: true }, (_event, filename) => {\n if (!filename) return\n const rel = relative(root, resolve(root, filename.toString()))\n if (!rel || rel.startsWith(\"..\") || ignored(rel)) return\n\n clearTimeout(pending.get(rel))\n pending.set(rel, setTimeout(() => {\n pending.delete(rel)\n void changed(rel)\n }, 30))\n })\n\n // proxies and load balancers cut an idle stream; a comment every 30s is the\n // conventional way to keep it open. unref'd, so it never holds the process up\n const heartbeat = setInterval(() => clients.forEach(client => client.write(\": ping\\n\\n\")), 30_000)\n heartbeat.unref()\n\n // --- go --------------------------------------------------------------------\n\n await new Promise<void>((done, fail) => {\n server.once(\"error\", fail)\n server.listen(options.port ?? 4179, host, done)\n })\n const { port } = server.address() as { port: number }\n\n return {\n url: `http://${host}:${port}`,\n port,\n close: () =>\n new Promise(done => {\n clearInterval(heartbeat)\n watcher.close()\n pending.forEach(clearTimeout)\n clients.forEach(client => client.end())\n clients.cl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,GAAG,CAAC;AAC7B,YAAQ,IAAI,KAAK,WAAW,MAAM;AAChC,cAAQ,OAAO,GAAG;AAClB,WAAK,QAAQ,GAAG;AAAA,IAClB,GAAG,EAAE,CAAC;AAAA,EACR,CAAC;AAID,QAAM,YAAY,YAAY,MAAM,QAAQ,QAAQ,YAAU,OAAO,MAAM,YAAY,CAAC,GAAG,GAAM;AACjG,YAAU,MAAM;AAIhB,QAAM,IAAI,QAAc,CAAC,MAAM,SAAS;AACtC,WAAO,KAAK,SAAS,IAAI;AACzB,WAAO,OAAO,QAAQ,QAAQ,MAAM,MAAM,IAAI;AAAA,EAChD,CAAC;AACD,QAAM,EAAE,KAAK,IAAI,OAAO,QAAQ;AAEhC,SAAO;AAAA,IACL,KAAK,UAAU,IAAI,IAAI,IAAI;AAAA,IAC3B;AAAA,IACA,OAAO,MACL,IAAI,QAAQ,UAAQ;AAClB,oBAAc,SAAS;AACvB,cAAQ,MAAM;AACd,cAAQ,QAAQ,YAAY;AAC5B,cAAQ,QAAQ,YAAU,OAAO,IAAI,CAAC;AACtC,cAAQ,MAAM;AACd,aAAO,MAAM,MAAM,KAAK,CAAC;AAAA,IAC3B,CAAC;AAAA,EACL;AACF;AAEA,IAAO,cAAQ;","names":[]}
package/dist/jq79.cjs CHANGED
@@ -1,10 +1,10 @@
1
- var j=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var we=Object.prototype.hasOwnProperty;var xe=(e,t,n)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Te=(e,t)=>{for(var n in t)j(e,n,{get:t[n],enumerable:!0})},Ce=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Re(t))!we.call(e,r)&&r!==n&&j(e,r,{get:()=>t[r],enumerable:!(s=$e(t,r))||s.enumerable});return e};var Le=e=>Ce(j({},"__esModule",{value:!0}),e);var $=(e,t,n)=>xe(e,typeof t!="symbol"?t+"":t,n);var it={};Te(it,{$:()=>N,$$:()=>M,$create:()=>D,$reactive:()=>O,Component79:()=>L,parseComponent:()=>ot,renderComponent:()=>ze});module.exports=Le(it);function N(e,t){return typeof e=="string"?document.querySelector(e):e.querySelector(t)}function M(e,t){return Array.from(typeof e=="string"?document.querySelectorAll(e):e.querySelectorAll(t))}var D=(e,t={})=>{let n=document.createElement(e);for(let[s,r]of Object.entries(t))if(s==="className")n.className=Array.isArray(r)?r.join(" "):r;else if(s==="textContent")n.textContent=r;else if(s==="children")for(let o of r)n.appendChild(o);else n.setAttribute(s,r);return n},ve=new Set(["a","b","i","em","strong","p","br","ul","ol","li","blockquote","code","pre","span","div","h1","h2","h3","h4","h5","h6","img"]),X={a:new Set(["href","title"]),img:new Set(["src","alt"]),"*":new Set(["class"])},Ne=new Set(["http:","https:","mailto:"]);function _e(e){try{let t=new URL(e,"https://example.com");return Ne.has(t.protocol)}catch{return!1}}function J(e,t){for(let n of Array.from(e.childNodes))if(n.nodeType===Node.ELEMENT_NODE){let s=Ae(n);s&&t.appendChild(s)}else n.nodeType===Node.TEXT_NODE&&t.appendChild(n.cloneNode())}function Ae(e){let t=e.tagName.toLowerCase();if(!ve.has(t))return null;let n=document.createElement(t);for(let s of Array.from(e.attributes)){let r=s.name.toLowerCase(),o=X[t]?.has(r),c=X["*"]?.has(r);!o&&!c||(r==="href"||r==="src")&&!_e(s.value)||n.setAttribute(r,s.value)}return t==="a"&&n.setAttribute("rel","noopener noreferrer"),J(e,n),n}function Y(e){let t=new DOMParser().parseFromString(e,"text/html"),n=document.createElement("div");return J(t.body,n),n.innerHTML}var Oe=(e,t)=>t.split(".").reduce((n,s)=>n?.[s],e),Q=e=>{if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},ee=(e,t,n)=>{Object.entries(e).forEach(([s,r])=>{let o=t?`${t}.${s}`:s;r&&typeof r=="object"&&Q(r)?ee(r,o,n):n(o,r)})},je=(e,t)=>e===t||e.startsWith(`${t}.`)||t.startsWith(`${e}.`),q=Symbol("jq79.raw"),I=e=>{let t=e;for(;t!==null&&typeof t=="object"&&t[q];)t=t[q];return t},te=Symbol("jq79.store"),W=e=>e!==null&&typeof e=="object"&&e[te]===!0,_=[],ne=e=>{_.push(new Set);try{return e()}finally{_.pop()}},O=e=>{let t=new Map,n=new Set,s=new Set,r=new WeakMap,o=Object.create(null),c=(f,u,S=!1)=>{t.get(f)?.forEach(b=>b(u,f)),n.forEach(b=>b(f,u)),s.forEach(b=>{(S||Array.from(b.deps).some(m=>je(m,f)))&&b.run()})},i=f=>f!==null&&typeof f=="object"&&Q(f),a=(f,u)=>{let S=r.get(f);if(S)return S;let b=new Proxy(f,{get(m,h,E){if(h===q)return m;if(h===te)return u==="";if(typeof h!="string")return Reflect.get(m,h,E);if(u===""&&h in o)return o[h];let w=u?`${u}.${h}`:h;_[_.length-1]?.add(w);let y=Reflect.get(m,h,E);if(W(y))return y;let R=I(y);return i(R)?a(R,w):R},set(m,h,E,w){if(w!==b&&!Object.prototype.hasOwnProperty.call(m,h))return Reflect.set(m,h,E,w);let y=u?`${u}.${h}`:h,R=W(E)?E:I(E),C=!Object.prototype.hasOwnProperty.call(m,h);m[h]=R;let v=W(R)||!i(R)?R:a(R,y);return c(y,v,C),!0}});return r.set(f,b),b},g=a(I(e),""),l=(f,u,{immediate:S=!1}={})=>(t.has(f)||t.set(f,new Set),t.get(f).add(u),S&&u(Oe(g,f),f),()=>t.get(f)?.delete(u)),p=(f,{immediate:u=!1}={})=>(n.add(f),u&&ee(g,"",(S,b)=>f(S,b)),()=>n.delete(f)),d=f=>{let u={deps:new Set,run:()=>{let S=new Set;_.push(S);try{f()}finally{_.pop(),u.deps=S}}};return s.add(u),u.run(),()=>{s.delete(u)}};return o.$on=l,o.$onAny=p,o.$effect=d,g},A=e=>{let t=[];return{effect:n=>{t.push(e.$effect(n))},onDispose:n=>{t.push(n)},dispose:()=>{t.splice(0).forEach(n=>n())}}};var se=/(?:let|var|const)\s+([A-Za-z_$][\w$]*)/y,re=/\$:\s*/y,k=/import(?=\s*\()/y,oe=/\$:\s*([A-Za-z_$][\w$]*)\s*=(?!=)/y,U=(e,t)=>{let n=e[t],s=t+1;for(;s<e.length;){if(e[s]==="\\"){s+=2;continue}if(e[s]===n)return s+1;s++}return e.length},P=(e,t)=>{let n=e.indexOf(`
2
- `,t);return n===-1?e.length:n},F=(e,t)=>{let n=e.indexOf("*/",t+2);return n===-1?e.length:n+2},Me=(e,t)=>{let n=t;for(;n<e.length;){if(/\s/.test(e[n])){n++;continue}if(e[n]==="/"&&e[n+1]==="/"){n=P(e,n);continue}if(e[n]==="/"&&e[n+1]==="*"){n=F(e,n);continue}break}return n},De=/^(\?\.|\?\?|&&|\|\||\*\*|[.,+\-*/%&|^<>=?:([])/,ke=(e,t)=>{let n=0,s=t;for(;s<e.length;){let r=e[s];if(r==="'"||r==='"'||r==="`"){s=U(e,s);continue}if(r==="/"&&e[s+1]==="/"){s=P(e,s);continue}if(r==="/"&&e[s+1]==="*"){s=F(e,s);continue}if("([{".includes(r))n++;else if(")]}".includes(r))n--;else{if(n<=0&&r===";")return s;if(n<=0&&r===`
3
- `){let o=Me(e,s+1);if(o>=e.length||!De.test(e.slice(o,o+2)))return s;s=o;continue}}s++}return e.length},ae=e=>{let t=[],n="",s=0,r=0,o=!0;for(;s<e.length;){let c=e[s],i=e[s+1];if(c==="'"||c==='"'||c==="`"){let a=U(e,s);n+=e.slice(s,a),s=a,o=!1;continue}if(c==="/"&&(i==="/"||i==="*")){let a=i==="/"?P(e,s):F(e,s);n+=e.slice(s,a),s=a;continue}if(c==="i"&&(s===0||!/[\w$.]/.test(e[s-1]))&&(k.lastIndex=s,k.test(e))){n+="$__import",s+=6,o=!1;continue}if(r===0&&o){se.lastIndex=s;let a=se.exec(e);if(a){t.push(a[1]),n+=a[1],s+=a[0].length,o=!1;continue}re.lastIndex=s;let g=re.exec(e);if(g){oe.lastIndex=s;let l=oe.exec(e);l&&t.push(l[1]);let p=s+g[0].length,d=ke(e,p);n+=`$__effect(() => { ${e.slice(p,d)} });`,s=d;continue}}"([{".includes(c)?r++:")]}".includes(c)&&(r=Math.max(0,r-1)),c===`
4
- `||c===";"||c==="}"?o=!0:/\s/.test(c)||(o=!1),n+=c,s++}return{vars:t,code:n}},ie=/export\s+default(?![\w$])/y,ce=/import\s*(?:([\w$\s,{}*]+?)\s*from\s*)?(["'])([^"'\n]+)\2/y,Pe=e=>{let t=[],n=0,s=0;for(let r=0;r<=e.length;r++){let o=e[r];if(o==="{")n++;else if(o==="}")n--;else if(r===e.length||o===","&&n===0){let c=e.slice(s,r).trim();c&&t.push(c),s=r+1}}return t},Fe=(e,t,n)=>{let s=`await $__import(${JSON.stringify(t)})`;if(e===void 0)return s;let r=Pe(e),o=[],c=s;if(r.length>1){let i=`$__mod${n}`;o.push(`${i} = ${s}`),c=i}for(let i of r)i.startsWith("{")?o.push(`${i.replace(/\s+as\s+/g,": ")} = ${c}`):i.startsWith("*")?o.push(`${i.replace(/^\*\s*as\s+/,"")} = ${c}`):o.push(`${i} = $__default(${c})`);return`const ${o.join(", ")}`},le=e=>{let t="",n=0,s=0,r=!0,o=!1,c=0;for(;n<e.length;){let i=e[n],a=e[n+1],g=n===0||!/[\w$.]/.test(e[n-1]);if(i==="'"||i==='"'||i==="`"){let l=U(e,n);t+=e.slice(n,l),n=l,r=!1;continue}if(i==="/"&&(a==="/"||a==="*")){let l=a==="/"?P(e,n):F(e,n);t+=e.slice(n,l),n=l;continue}if(i==="i"&&g){if(k.lastIndex=n,k.test(e)){t+="$__import",n+=6,r=!1;continue}if(s===0&&r){ce.lastIndex=n;let l=ce.exec(e);if(l){t+=Fe(l[1],l[3],c++),n+=l[0].length,r=!1;continue}}}if(i==="e"&&g&&s===0&&r){ie.lastIndex=n;let l=ie.exec(e);if(l){o=!0,t+="$__exports.default =",n+=l[0].length,r=!1;continue}}"([{".includes(i)?s++:")]}".includes(i)&&(s=Math.max(0,s-1)),i===`
5
- `||i===";"||i==="}"?r=!0:/\s/.test(i)||(r=!1),t+=i,n++}return o?t:null};var me=e=>Object.fromEntries(Array.from(e.attributes).map(t=>[t.name,t.value])),he=e=>({tag:e.tagName.toLowerCase(),attrs:me(e),children:Array.from(e.childNodes).flatMap(t=>{if(t.nodeType===Node.TEXT_NODE){let n=t.textContent??"";return n?[n]:[]}return t.nodeType===Node.ELEMENT_NODE?[he(t)]:[]})}),T=(e,t,n)=>{try{return new Function("$scope",...Object.keys(n??{}),`with ($scope) { return (${e}); }`)(t,...Object.values(n??{}))}catch{return}},Be=(e,t)=>e.replace(/{{\s*([\s\S]+?)\s*}}/g,(n,s)=>T(s,t)??""),ge=new Set([":attrs",":if",":elseif",":else",":each",":key",":with",":text",":html"]),Ie=/^\s*(\w+)\s+in\s+([\s\S]+)$/,We=(e,t,n,s)=>{let[r,...o]=t.slice(1).split("."),c=new Set(o);e.addEventListener(r,i=>{if(c.has("self")&&i.target!==e)return;c.has("prevent")&&i.preventDefault(),c.has("stop")&&i.stopPropagation();let a=T(n,s,{$event:i});typeof a=="function"&&a.call(e,i)},{once:c.has("once"),capture:c.has("capture")})},fe=e=>e.replace(/-(\w)/g,(t,n)=>n.toUpperCase()),ue=(e,t)=>{let n=t.replace(/-/g,"").toLowerCase();for(let s=e;s&&s!==Object.prototype;s=Object.getPrototypeOf(s))for(let r of Object.keys(s))if(/^[A-Z]/.test(r)&&r.replace(/-/g,"").toLowerCase()===n)return r;return null},de=(e,t,n,s,r)=>{let o=document.createComment(e),c=document.createDocumentFragment();c.appendChild(o);let i={};Object.entries(t.attrs).forEach(([p,d])=>{if(!(p===K||ge.has(p)||p.startsWith("@")))if(p.startsWith(":")){let f=fe(p.slice(1));i[f]=d||f}else i[fe(p)]=JSON.stringify(d)});let a=null,g=null,l=null;return s.effect(()=>{let p=T(e,n),d=p instanceof L?p:null;if(d===g||(l?.dispose(),l=null,a?.destroy(),a=null,g=d,!d))return;let f=new L({template:d.template,scripts:d.scripts,styles:d.styles,modules:d.modules,filename:d.filename}),u=ne(()=>Object.fromEntries(Object.entries(i).map(([m,h])=>[m,T(h,n)]))),S=document.createDocumentFragment();(r?f.renderShadow(u):f.render(u)).mount(S),o.parentNode.insertBefore(S,o.nextSibling);let b=A(n);Object.entries(i).forEach(([m,h])=>{b.effect(()=>{f.data[m]=T(h,n)})}),l=b,a=f}),s.onDispose(()=>{l?.dispose(),a?.destroy()}),c},qe=(e,t)=>{let n=()=>{let s=T(e,t);return s!==null&&typeof s=="object"?s:null};return new Proxy(t,{has(s,r){let o=n();return o!==null&&Reflect.has(o,r)||Reflect.has(s,r)},get(s,r){let o=n();return o!==null&&Reflect.has(o,r)?o[r]:Reflect.get(s,r)},set(s,r,o){let c=n();return c!==null&&Reflect.has(c,r)?(c[r]=o,!0):Reflect.set(s,r,o)}})},z=(e,t,n,s)=>{let r=e.attrs[":with"],o=r!==void 0?qe(r,t):t,c=ue(o,e.tag);if(c)return de(c,e,o,n,s);let i=document.createElement(e.tag);if(i instanceof HTMLUnknownElement||e.tag.includes("-")){let p=!1;n.effect(()=>{if(p)return;let d=ue(o,e.tag);d&&(p=!0,i.replaceWith(de(d,e,o,n,s)))})}Object.entries(e.attrs).forEach(([p,d])=>{p.startsWith("@")?We(i,p,d,o):ge.has(p)||i.setAttribute(p,d)});let a=e.attrs[":attrs"];if(a!==void 0){let p=[];n.effect(()=>{p.forEach(f=>i.removeAttribute(f));let d=T(a,o);p=d&&typeof d=="object"?Object.keys(d):[],p.forEach(f=>{let u=d[f];u!=null&&u!==!1&&i.setAttribute(f,String(u))})})}let g=e.attrs[":text"],l=e.attrs[":html"];return g!==void 0?n.effect(()=>{i.textContent=String(T(g,o)??"")}):l!==void 0?n.effect(()=>{i.innerHTML=Y(String(T(l,o)??""))}):i.appendChild(G(e.children,o,n,s)),i},Ue=(e,t,n,s)=>{let r=document.createComment("if"),o=document.createDocumentFragment();o.appendChild(r);let c=null,i=null,a=null;return n.effect(()=>{let g=e.find(l=>l.expr===void 0||T(l.expr,t))??null;g!==i&&(a?.dispose(),c&&c.parentNode?.removeChild(c),c=null,i=g,g&&(a=A(t),c=z(g.node,t,a,s),r.parentNode.insertBefore(c,r.nextSibling)))}),o},H=(e,t,n)=>{Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})},He=(e,t,n,s)=>{let r=e.attrs[":each"].match(Ie);if(!r)return document.createComment(`invalid :each expression "${e.attrs[":each"]}"`);let[,o,c]=r,i=e.attrs[":key"],{[":each"]:a,[":key"]:g,...l}=e.attrs,p={...e,attrs:l},d=document.createComment("each"),f=document.createDocumentFragment();f.appendChild(d);let u=[];return n.effect(()=>{let S=T(c,t),b=Array.isArray(S)?S:[],m=new Map(u.map(y=>[y.key,y])),h=b.map((y,R)=>{let C=Object.create(t);H(C,o,y),H(C,"$index",R);let v=i!==void 0?T(i,C):R,x=m.get(v);if(x&&Object.is(x.item,y))return H(x.scope,"$index",R),x;x?.fx.dispose(),x?.node.parentNode?.removeChild(x.node);let Z=A(t);return{key:v,item:y,scope:C,fx:Z,node:z(p,C,Z,s)}}),E=new Set(h.map(y=>y.key));u.forEach(y=>{E.has(y.key)||(y.fx.dispose(),y.node.parentNode?.removeChild(y.node))});let w=d;h.forEach(y=>{w.nextSibling!==y.node&&d.parentNode.insertBefore(y.node,w.nextSibling),w=y.node}),u=h}),f},G=(e,t,n,s=!1)=>{let r=document.createDocumentFragment(),o=0;for(;o<e.length;){let c=e[o];if(typeof c=="string"){let i=document.createTextNode(c);c.includes("{{")&&n.effect(()=>{i.textContent=Be(c,t)}),r.appendChild(i),o++;continue}if(":each"in c.attrs){r.appendChild(He(c,t,n,s)),o++;continue}if(":if"in c.attrs){let i=[{expr:c.attrs[":if"],node:c}];o++;let a=l=>{let p=o;for(;p<e.length&&typeof e[p]=="string"&&!e[p].trim();)p++;let d=e[p];if(typeof d=="object"&&l in d.attrs)return o=p+1,d};for(let l=a(":elseif");l;l=a(":elseif"))i.push({expr:l.attrs[":elseif"],node:l});let g=a(":else");g&&i.push({node:g}),r.appendChild(Ue(i,t,n,s));continue}r.appendChild(z(c,t,n,s)),o++}return r},ze=(e,t,n=!1)=>G(e.template,t,A(t),n),Ge=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ke=/<([A-Za-z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)\/>/g,Ve=/(<script[\s\S]*?<\/script\s*>|<style[\s\S]*?<\/style\s*>)/gi,Ze=e=>e.split(Ve).map((t,n)=>n%2===1?t:t.replace(Ke,(s,r,o)=>Ge.has(r.toLowerCase())?s:`<${r}${o}></${r}>`)).join(""),K="data-jq79",Xe=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0).toString(36)},ye=(e,t)=>{e.forEach(n=>{typeof n!="string"&&(n.attrs[K]=t,ye(n.children,t))})},Je=(e,t)=>e.split(",").map(n=>{let s=n.trim(),r=s.indexOf("::"),o=r===-1?s:s.slice(0,r),c=r===-1?"":s.slice(r);return`${o}[${K}="${t}"]${c}`}).join(", "),Ee=(e,t)=>{Array.from(e).forEach(n=>{n instanceof CSSStyleRule?n.selectorText=Je(n.selectorText,t):n instanceof CSSGroupingRule&&Ee(n.cssRules,t)})},Ye=(e,t)=>{/:deep\(|::v-deep|>>>/.test(e)&&console.warn("jq79: :deep()/::v-deep/>>> are not supported in <style scoped>; the rule will be dropped by the browser");let n=new CSSStyleSheet;return n.replaceSync(e),Ee(n.cssRules,t),Array.from(n.cssRules).map(s=>s.cssText).join(`
6
- `)},Qe=e=>{let n=new DOMParser().parseFromString(`<template>${Ze(e)}</template>`,"text/html").querySelector("template"),s=[],r=[],o=[];Array.from(n.content.children).forEach(i=>{let a={attrs:me(i),content:i.textContent??""};i.tagName==="SCRIPT"?s.push(a):i.tagName==="STYLE"?r.push(a):o.push(he(i))}),r.forEach(i=>{"lang"in i.attrs&&console.warn(`jq79: <style lang="${i.attrs.lang}"> needs the jq79/vite plugin to compile it. This component didn't go through the bundler, so its styles were left uncompiled and the browser will ignore them.`)});let c=i=>"scoped"in i.attrs&&!("lang"in i.attrs);if(r.some(c)){let i=Xe(e);ye(o,i),r.forEach(a=>{c(a)&&(a.scoped=Ye(a.content,i))})}return{template:o,scripts:s,styles:r}},V=e=>/\.html?([?#]|$)/.test(e)?L.fetch(e):import(e),Se=(e,t)=>e?`
7
- //# sourceURL=${e}?jq79-script=${t}`:"",pe=e=>e.scoped??e.content,B=new Map,et=e=>{let t=B.get(e);if(!t){let n=document.createElement("style");n.textContent=e,document.head.appendChild(n),t={el:n,count:0},B.set(e,t)}t.count++},tt=e=>{let t=B.get(e);t&&--t.count<=0&&(t.el.remove(),B.delete(e))},be={$:N,$$:M,$create:D,$reactive:O},nt=(e,t,n,s={},r=V,o={})=>{let c={...be,...s},i=new Proxy(t,{has:(g,l)=>l!=="$__effect"&&l!=="$__import"&&(Reflect.has(g,l)||!(l in globalThis)&&!(l in c))});new Function("$scope","$__effect","$__import",...Object.keys(c),`return (async () => { with ($scope) { ${e} } })()${Se(o.filename,o.index??0)}`)(i,n,r,...Object.values(c)).catch(g=>console.error("jq79: error in :setup script",g))},st=e=>e&&e.default!==void 0?e.default:e,rt=(e,t,n,s={},r=V,o={})=>{let c={...be,...s},i={},a=new Function("$__exports","$__default","$__import",...Object.keys(c),`return (async () => { "use strict";
1
+ var k=Object.defineProperty;var Le=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var Ae=(e,t,n)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Oe=(e,t)=>{for(var n in t)k(e,n,{get:t[n],enumerable:!0})},Me=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ve(t))!Ne.call(e,r)&&r!==n&&k(e,r,{get:()=>t[r],enumerable:!(s=Le(t,r))||s.enumerable});return e};var je=e=>Me(k({},"__esModule",{value:!0}),e);var $=(e,t,n)=>Ae(e,typeof t!="symbol"?t+"":t,n);var mt={};Oe(mt,{$:()=>A,$$:()=>P,$create:()=>F,$reactive:()=>D,Component79:()=>N,enableHotReload:()=>Te,hotUpdate:()=>xe,parseComponent:()=>ht,renderComponent:()=>Qe});module.exports=je(mt);function A(e,t){return typeof e=="string"?document.querySelector(e):e.querySelector(t)}function P(e,t){return Array.from(typeof e=="string"?document.querySelectorAll(e):e.querySelectorAll(t))}var F=(e,t={})=>{let n=document.createElement(e);for(let[s,r]of Object.entries(t))if(s==="className")n.className=Array.isArray(r)?r.join(" "):r;else if(s==="textContent")n.textContent=r;else if(s==="children")for(let o of r)n.appendChild(o);else n.setAttribute(s,r);return n},De=new Set(["a","b","i","em","strong","p","br","ul","ol","li","blockquote","code","pre","span","div","h1","h2","h3","h4","h5","h6","img"]),Q={a:new Set(["href","title"]),img:new Set(["src","alt"]),"*":new Set(["class"])},ke=new Set(["http:","https:","mailto:"]);function Pe(e){try{let t=new URL(e,"https://example.com");return ke.has(t.protocol)}catch{return!1}}function Y(e,t){for(let n of Array.from(e.childNodes))if(n.nodeType===Node.ELEMENT_NODE){let s=Fe(n);s&&t.appendChild(s)}else n.nodeType===Node.TEXT_NODE&&t.appendChild(n.cloneNode())}function Fe(e){let t=e.tagName.toLowerCase();if(!De.has(t))return null;let n=document.createElement(t);for(let s of Array.from(e.attributes)){let r=s.name.toLowerCase(),o=Q[t]?.has(r),c=Q["*"]?.has(r);!o&&!c||(r==="href"||r==="src")&&!Pe(s.value)||n.setAttribute(r,s.value)}return t==="a"&&n.setAttribute("rel","noopener noreferrer"),Y(e,n),n}function ee(e){let t=new DOMParser().parseFromString(e,"text/html"),n=document.createElement("div");return Y(t.body,n),n.innerHTML}var Be=(e,t)=>t.split(".").reduce((n,s)=>n?.[s],e),te=e=>{if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},ne=(e,t,n)=>{Object.entries(e).forEach(([s,r])=>{let o=t?`${t}.${s}`:s;r&&typeof r=="object"&&te(r)?ne(r,o,n):n(o,r)})},Ie=(e,t)=>e===t||e.startsWith(`${t}.`)||t.startsWith(`${e}.`),q=Symbol("jq79.raw"),B=e=>{let t=e;for(;t!==null&&typeof t=="object"&&t[q];)t=t[q];return t},se=Symbol("jq79.store"),j=e=>e!==null&&typeof e=="object"&&e[se]===!0,O=[],re=e=>{O.push(new Set);try{return e()}finally{O.pop()}},D=e=>{let t=new Map,n=new Set,s=new Set,r=new WeakMap,o=Object.create(null),c=(a,d,g=!1)=>{t.get(a)?.forEach(b=>b(d,a)),n.forEach(b=>b(a,d)),s.forEach(b=>{(g||Array.from(b.deps).some(m=>Ie(m,a)))&&b.run()})},i=a=>a!==null&&typeof a=="object"&&te(a),l=new Map,h=(a,d)=>{let g=l.get(d);g?.store!==a&&(g?.unsubscribe(),l.set(d,{store:a,unsubscribe:a.$onAny((b,m)=>c(`${d}.${b}`,m))}))},f=a=>{l.get(a)?.unsubscribe(),l.delete(a)},p=(a,d)=>{let g=r.get(a);if(g)return g;let b=new Proxy(a,{get(m,S,w){if(S===q)return m;if(S===se)return d==="";if(typeof S!="string")return Reflect.get(m,S,w);if(d===""&&S in o)return o[S];let C=d?`${d}.${S}`:S;O[O.length-1]?.add(C);let R=Reflect.get(m,S,w);if(j(R))return h(R,C),R;let x=B(R);return i(x)?p(x,C):x},set(m,S,w,C){if(C!==b&&!Object.prototype.hasOwnProperty.call(m,S))return Reflect.set(m,S,w,C);let R=d?`${d}.${S}`:S,x=j(w)?w:B(w),Ce=!Object.prototype.hasOwnProperty.call(m,S);m[S]=x,j(x)?h(x,R):f(R);let _e=j(x)||!i(x)?x:p(x,R);return c(R,_e,Ce),!0}});return r.set(a,b),b},u=p(B(e),"");Object.entries(B(e)).forEach(([a,d])=>{j(d)&&h(d,a)});let E=(a,d,{immediate:g=!1}={})=>(t.has(a)||t.set(a,new Set),t.get(a).add(d),g&&d(Be(u,a),a),()=>t.get(a)?.delete(d)),y=(a,{immediate:d=!1}={})=>(n.add(a),d&&ne(u,"",(g,b)=>a(g,b)),()=>n.delete(a)),_=a=>{let d={deps:new Set,run:()=>{let g=new Set;O.push(g);try{a()}finally{O.pop(),d.deps=g}}};return s.add(d),d.run(),()=>{s.delete(d)}},L=()=>{l.forEach(({unsubscribe:a})=>a()),l.clear()};return o.$on=E,o.$onAny=y,o.$effect=_,o.$dispose=L,u},M=e=>{let t=[];return{effect:n=>{t.push(e.$effect(n))},onDispose:n=>{t.push(n)},dispose:()=>{t.splice(0).forEach(n=>n())}}};var oe=/(?:let|var|const)\s+([A-Za-z_$][\w$]*)/y,ie=/\$:\s*/y,I=/import(?=\s*\()/y,ce=/\$:\s*([A-Za-z_$][\w$]*)\s*=(?!=)/y,z=(e,t)=>{let n=e[t],s=t+1;for(;s<e.length;){if(e[s]==="\\"){s+=2;continue}if(e[s]===n)return s+1;s++}return e.length},U=(e,t)=>{let n=e.indexOf(`
2
+ `,t);return n===-1?e.length:n},W=(e,t)=>{let n=e.indexOf("*/",t+2);return n===-1?e.length:n+2},Ue=(e,t)=>{let n=t;for(;n<e.length;){if(/\s/.test(e[n])){n++;continue}if(e[n]==="/"&&e[n+1]==="/"){n=U(e,n);continue}if(e[n]==="/"&&e[n+1]==="*"){n=W(e,n);continue}break}return n},We=/^(\?\.|\?\?|&&|\|\||\*\*|[.,+\-*/%&|^<>=?:([])/,He=(e,t)=>{let n=0,s=t;for(;s<e.length;){let r=e[s];if(r==="'"||r==='"'||r==="`"){s=z(e,s);continue}if(r==="/"&&e[s+1]==="/"){s=U(e,s);continue}if(r==="/"&&e[s+1]==="*"){s=W(e,s);continue}if("([{".includes(r))n++;else if(")]}".includes(r))n--;else{if(n<=0&&r===";")return s;if(n<=0&&r===`
3
+ `){let o=Ue(e,s+1);if(o>=e.length||!We.test(e.slice(o,o+2)))return s;s=o;continue}}s++}return e.length},fe=e=>{let t=[],n="",s=0,r=0,o=!0;for(;s<e.length;){let c=e[s],i=e[s+1];if(c==="'"||c==='"'||c==="`"){let l=z(e,s);n+=e.slice(s,l),s=l,o=!1;continue}if(c==="/"&&(i==="/"||i==="*")){let l=i==="/"?U(e,s):W(e,s);n+=e.slice(s,l),s=l;continue}if(c==="i"&&(s===0||!/[\w$.]/.test(e[s-1]))&&(I.lastIndex=s,I.test(e))){n+="$__import",s+=6,o=!1;continue}if(r===0&&o){oe.lastIndex=s;let l=oe.exec(e);if(l){t.push(l[1]),n+=l[1],s+=l[0].length,o=!1;continue}ie.lastIndex=s;let h=ie.exec(e);if(h){ce.lastIndex=s;let f=ce.exec(e);f&&t.push(f[1]);let p=s+h[0].length,u=He(e,p);n+=`$__effect(() => { ${e.slice(p,u)} });`,s=u;continue}}"([{".includes(c)?r++:")]}".includes(c)&&(r=Math.max(0,r-1)),c===`
4
+ `||c===";"||c==="}"?o=!0:/\s/.test(c)||(o=!1),n+=c,s++}return{vars:t,code:n}},ae=/export\s+default(?![\w$])/y,le=/import\s*(?:([\w$\s,{}*]+?)\s*from\s*)?(["'])([^"'\n]+)\2/y,qe=e=>{let t=[],n=0,s=0;for(let r=0;r<=e.length;r++){let o=e[r];if(o==="{")n++;else if(o==="}")n--;else if(r===e.length||o===","&&n===0){let c=e.slice(s,r).trim();c&&t.push(c),s=r+1}}return t},ze=(e,t,n)=>{let s=`await $__import(${JSON.stringify(t)})`;if(e===void 0)return s;let r=qe(e),o=[],c=s;if(r.length>1){let i=`$__mod${n}`;o.push(`${i} = ${s}`),c=i}for(let i of r)i.startsWith("{")?o.push(`${i.replace(/\s+as\s+/g,": ")} = ${c}`):i.startsWith("*")?o.push(`${i.replace(/^\*\s*as\s+/,"")} = ${c}`):o.push(`${i} = $__default(${c})`);return`const ${o.join(", ")}`},de=e=>{let t="",n=0,s=0,r=!0,o=!1,c=0;for(;n<e.length;){let i=e[n],l=e[n+1],h=n===0||!/[\w$.]/.test(e[n-1]);if(i==="'"||i==='"'||i==="`"){let f=z(e,n);t+=e.slice(n,f),n=f,r=!1;continue}if(i==="/"&&(l==="/"||l==="*")){let f=l==="/"?U(e,n):W(e,n);t+=e.slice(n,f),n=f;continue}if(i==="i"&&h){if(I.lastIndex=n,I.test(e)){t+="$__import",n+=6,r=!1;continue}if(s===0&&r){le.lastIndex=n;let f=le.exec(e);if(f){t+=ze(f[1],f[3],c++),n+=f[0].length,r=!1;continue}}}if(i==="e"&&h&&s===0&&r){ae.lastIndex=n;let f=ae.exec(e);if(f){o=!0,t+="$__exports.default =",n+=f[0].length,r=!1;continue}}"([{".includes(i)?s++:")]}".includes(i)&&(s=Math.max(0,s-1)),i===`
5
+ `||i===";"||i==="}"?r=!0:/\s/.test(i)||(r=!1),t+=i,n++}return o?t:null};var ye=e=>Object.fromEntries(Array.from(e.attributes).map(t=>[t.name,t.value])),Ee=e=>({tag:e.tagName.toLowerCase(),attrs:ye(e),children:Array.from(e.childNodes).flatMap(t=>{if(t.nodeType===Node.TEXT_NODE){let n=t.textContent??"";return n?[n]:[]}return t.nodeType===Node.ELEMENT_NODE?[Ee(t)]:[]})}),T=(e,t,n)=>{try{return new Function("$scope",...Object.keys(n??{}),`with ($scope) { return (${e}); }`)(t,...Object.values(n??{}))}catch{return}},Ge=(e,t)=>e.replace(/{{\s*([\s\S]+?)\s*}}/g,(n,s)=>T(s,t)??""),be=new Set([":attrs",":if",":elseif",":else",":each",":key",":with",":text",":html"]),Ke=/^\s*(\w+)\s+in\s+([\s\S]+)$/,Je=(e,t,n,s)=>{let[r,...o]=t.slice(1).split("."),c=new Set(o);e.addEventListener(r,i=>{if(c.has("self")&&i.target!==e)return;c.has("prevent")&&i.preventDefault(),c.has("stop")&&i.stopPropagation();let l=T(n,s,{$event:i});typeof l=="function"&&l.call(e,i)},{once:c.has("once"),capture:c.has("capture")})},ue=e=>e.replace(/-(\w)/g,(t,n)=>n.toUpperCase()),pe=(e,t)=>{let n=t.replace(/-/g,"").toLowerCase();for(let s=e;s&&s!==Object.prototype;s=Object.getPrototypeOf(s))for(let r of Object.keys(s))if(/^[A-Z]/.test(r)&&r.replace(/-/g,"").toLowerCase()===n)return r;return null},he=(e,t,n,s,r)=>{let o=document.createComment(e),c=document.createDocumentFragment();c.appendChild(o);let i={};Object.entries(t.attrs).forEach(([p,u])=>{if(!(p===Z||be.has(p)||p.startsWith("@")))if(p.startsWith(":")){let E=ue(p.slice(1));i[E]=u||E}else i[ue(p)]=JSON.stringify(u)});let l=null,h=null,f=null;return s.effect(()=>{let p=T(e,n),u=p instanceof N?p:null;if(u===h||(f?.dispose(),f=null,l?.destroy(),l=null,h=u,!u))return;let E=new N({template:u.template,scripts:u.scripts,styles:u.styles,modules:u.modules,filename:u.filename}),y=re(()=>Object.fromEntries(Object.entries(i).map(([a,d])=>[a,T(d,n)]))),_=document.createDocumentFragment();(r?E.renderShadow(y):E.render(y)).mount(_),o.parentNode.insertBefore(_,o.nextSibling);let L=M(n);Object.entries(i).forEach(([a,d])=>{L.effect(()=>{E.data[a]=T(d,n)})}),f=L,l=E}),s.onDispose(()=>{f?.dispose(),l?.destroy()}),c},Ve=(e,t)=>{let n=()=>{let s=T(e,t);return s!==null&&typeof s=="object"?s:null};return new Proxy(t,{has(s,r){let o=n();return o!==null&&Reflect.has(o,r)||Reflect.has(s,r)},get(s,r){let o=n();return o!==null&&Reflect.has(o,r)?o[r]:Reflect.get(s,r)},set(s,r,o){let c=n();return c!==null&&Reflect.has(c,r)?(c[r]=o,!0):Reflect.set(s,r,o)}})},J=(e,t,n,s)=>{let r=e.attrs[":with"],o=r!==void 0?Ve(r,t):t,c=pe(o,e.tag);if(c)return he(c,e,o,n,s);let i=document.createElement(e.tag);if(i instanceof HTMLUnknownElement||e.tag.includes("-")){let p=!1;n.effect(()=>{if(p)return;let u=pe(o,e.tag);u&&(p=!0,i.replaceWith(he(u,e,o,n,s)))})}Object.entries(e.attrs).forEach(([p,u])=>{p.startsWith("@")?Je(i,p,u,o):be.has(p)||i.setAttribute(p,u)});let l=e.attrs[":attrs"];if(l!==void 0){let p=[];n.effect(()=>{p.forEach(E=>i.removeAttribute(E));let u=T(l,o);p=u&&typeof u=="object"?Object.keys(u):[],p.forEach(E=>{let y=u[E];y!=null&&y!==!1&&i.setAttribute(E,String(y))})})}let h=e.attrs[":text"],f=e.attrs[":html"];return h!==void 0?n.effect(()=>{i.textContent=String(T(h,o)??"")}):f!==void 0?n.effect(()=>{i.innerHTML=ee(String(T(f,o)??""))}):i.appendChild(V(e.children,o,n,s)),i},Ze=(e,t,n,s)=>{let r=document.createComment("if"),o=document.createDocumentFragment();o.appendChild(r);let c=null,i=null,l=null;return n.effect(()=>{let h=e.find(f=>f.expr===void 0||T(f.expr,t))??null;h!==i&&(l?.dispose(),c&&c.parentNode?.removeChild(c),c=null,i=h,h&&(l=M(t),c=J(h.node,t,l,s),r.parentNode.insertBefore(c,r.nextSibling)))}),o},G=(e,t,n)=>{Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})},Xe=(e,t,n,s)=>{let r=e.attrs[":each"].match(Ke);if(!r)return document.createComment(`invalid :each expression "${e.attrs[":each"]}"`);let[,o,c]=r,i=e.attrs[":key"],{[":each"]:l,[":key"]:h,...f}=e.attrs,p={...e,attrs:f},u=document.createComment("each"),E=document.createDocumentFragment();E.appendChild(u);let y=[];return n.effect(()=>{let _=T(c,t),L=Array.isArray(_)?_:[],a=new Map(y.map(m=>[m.key,m])),d=L.map((m,S)=>{let w=Object.create(t);G(w,o,m),G(w,"$index",S);let C=i!==void 0?T(i,w):S,R=a.get(C);if(R&&Object.is(R.item,m))return G(R.scope,"$index",S),R;R?.fx.dispose(),R?.node.parentNode?.removeChild(R.node);let x=M(t);return{key:C,item:m,scope:w,fx:x,node:J(p,w,x,s)}}),g=new Set(d.map(m=>m.key));y.forEach(m=>{g.has(m.key)||(m.fx.dispose(),m.node.parentNode?.removeChild(m.node))});let b=u;d.forEach(m=>{b.nextSibling!==m.node&&u.parentNode.insertBefore(m.node,b.nextSibling),b=m.node}),y=d}),E},V=(e,t,n,s=!1)=>{let r=document.createDocumentFragment(),o=0;for(;o<e.length;){let c=e[o];if(typeof c=="string"){let i=document.createTextNode(c);c.includes("{{")&&n.effect(()=>{i.textContent=Ge(c,t)}),r.appendChild(i),o++;continue}if(":each"in c.attrs){r.appendChild(Xe(c,t,n,s)),o++;continue}if(":if"in c.attrs){let i=[{expr:c.attrs[":if"],node:c}];o++;let l=f=>{let p=o;for(;p<e.length&&typeof e[p]=="string"&&!e[p].trim();)p++;let u=e[p];if(typeof u=="object"&&f in u.attrs)return o=p+1,u};for(let f=l(":elseif");f;f=l(":elseif"))i.push({expr:f.attrs[":elseif"],node:f});let h=l(":else");h&&i.push({node:h}),r.appendChild(Ze(i,t,n,s));continue}r.appendChild(J(c,t,n,s)),o++}return r},Qe=(e,t,n=!1)=>V(e.template,t,M(t),n),Ye=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),et=/<([A-Za-z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)\/>/g,tt=/(<script[\s\S]*?<\/script\s*>|<style[\s\S]*?<\/style\s*>)/gi,nt=e=>e.split(tt).map((t,n)=>n%2===1?t:t.replace(et,(s,r,o)=>Ye.has(r.toLowerCase())?s:`<${r}${o}></${r}>`)).join(""),Z="data-jq79",st=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0).toString(36)},Se=(e,t)=>{e.forEach(n=>{typeof n!="string"&&(n.attrs[Z]=t,Se(n.children,t))})},rt=(e,t)=>e.split(",").map(n=>{let s=n.trim(),r=s.indexOf("::"),o=r===-1?s:s.slice(0,r),c=r===-1?"":s.slice(r);return`${o}[${Z}="${t}"]${c}`}).join(", "),Re=(e,t)=>{Array.from(e).forEach(n=>{n instanceof CSSStyleRule?n.selectorText=rt(n.selectorText,t):n instanceof CSSGroupingRule&&Re(n.cssRules,t)})},ot=(e,t)=>{/:deep\(|::v-deep|>>>/.test(e)&&console.warn("jq79: :deep()/::v-deep/>>> are not supported in <style scoped>; the rule will be dropped by the browser");let n=new CSSStyleSheet;return n.replaceSync(e),Re(n.cssRules,t),Array.from(n.cssRules).map(s=>s.cssText).join(`
6
+ `)},K=e=>{let n=new DOMParser().parseFromString(`<template>${nt(e)}</template>`,"text/html").querySelector("template"),s=[],r=[],o=[];Array.from(n.content.children).forEach(i=>{let l={attrs:ye(i),content:i.textContent??""};i.tagName==="SCRIPT"?s.push(l):i.tagName==="STYLE"?r.push(l):o.push(Ee(i))}),r.forEach(i=>{"lang"in i.attrs&&console.warn(`jq79: <style lang="${i.attrs.lang}"> needs the jq79/vite plugin to compile it. This component didn't go through the bundler, so its styles were left uncompiled and the browser will ignore them.`)});let c=i=>"scoped"in i.attrs&&!("lang"in i.attrs);if(r.some(c)){let i=st(e);Se(o,i),r.forEach(l=>{c(l)&&(l.scoped=ot(l.content,i))})}return{template:o,scripts:s,styles:r}},X=e=>/\.html?([?#]|$)/.test(e)?N.fetch(e):import(e),$e=(e,t)=>e?`
7
+ //# sourceURL=${e}?jq79-script=${t}`:"",me=e=>e.scoped??e.content,H=new Map,it=e=>{let t=H.get(e);if(!t){let n=document.createElement("style");n.textContent=e,document.head.appendChild(n),t={el:n,count:0},H.set(e,t)}t.count++},ct=e=>{let t=H.get(e);t&&--t.count<=0&&(t.el.remove(),H.delete(e))},we={$:A,$$:P,$create:F,$reactive:D},at=(e,t,n,s={},r=X,o={})=>{let c={...we,...s},i=new Proxy(t,{has:(h,f)=>f!=="$__effect"&&f!=="$__import"&&(Reflect.has(h,f)||!(f in globalThis)&&!(f in c))});new Function("$scope","$__effect","$__import",...Object.keys(c),`return (async () => { with ($scope) { ${e} } })()${$e(o.filename,o.index??0)}`)(i,n,r,...Object.values(c)).catch(h=>console.error("jq79: error in :setup script",h))},lt=e=>e&&e.default!==void 0?e.default:e,ft=(e,t,n,s={},r=X,o={})=>{let c={...we,...s},i={},l=new Function("$__exports","$__default","$__import",...Object.keys(c),`return (async () => { "use strict";
8
8
  ${e}
9
- ;$__exports.done = true })()${Se(o.filename,o.index??0)}`)(i,st,r,...Object.values(c)),g=d=>console.error("jq79: error in factory script",d),l=!1,p=()=>{if(l)return;l=!0;let d=i.default;if(typeof d!="function")return;let f=u=>{u&&typeof u=="object"&&Object.assign(t,u)};try{let u=d({$data:t,$effect:n,...s});u instanceof Promise?u.then(f).catch(g):f(u)}catch(u){g(u)}};a.then(p,g),i.done&&p()},L=class e{constructor(t,n={}){$(this,"template");$(this,"scripts");$(this,"styles");$(this,"modules");$(this,"filename");$(this,"data",null);$(this,"fx",null);$(this,"content",null);$(this,"startMarker",null);$(this,"endMarker",null);$(this,"styleEls",[]);$(this,"ownsSharedStyles",!1);$(this,"useShadow",!1);$(this,"mountRoot",null);$(this,"resolveMounted",null);$(this,"emitListeners",new Map);let s=typeof t=="string"?Qe(t):t;this.template=s.template,this.scripts=s.scripts,this.styles=s.styles,this.modules=n.modules??(typeof t=="string"?void 0:t.modules),this.filename=n.filename??(typeof t=="string"?void 0:t.filename)}static async fetch(t){let n=await fetch(t);if(!n.ok)throw new Error(`failed to fetch component from ${t}: ${n.status}`);return new e(await n.text(),{filename:t})}on(t,n){return this.emitListeners.has(t)||this.emitListeners.set(t,new Set),this.emitListeners.get(t).add(n),this}off(t,n){return this.emitListeners.get(t)?.delete(n),this}render(t={}){return this.renderWith(t,!1)}renderShadow(t={}){return this.renderWith(t,!0)}renderWith(t,n){this.destroy();let s=O({...t}),r=A(s);this.data=s,this.fx=r,this.useShadow=n,this.startMarker=document.createComment("jq79"),this.endMarker=document.createComment("/jq79");let o=this.startMarker,c=(m,h)=>{let E=new CustomEvent(m,{detail:h,bubbles:!0,composed:!0}),w=o.dispatchEvent(E);return o===this.startMarker&&this.emitListeners.get(m)?.forEach(y=>y(E,h)),w},i,a=new Promise(m=>{i=m});this.resolveMounted=i;let g=()=>a,l=this.endMarker,p=m=>{let h=[];for(let E=o.nextSibling;E&&E!==l;E=E.nextSibling)E instanceof Element&&(E.matches(m)&&h.push(E),h.push(...Array.from(E.querySelectorAll(m))));return h},d=m=>p(m)[0]??null,f=this.modules,u=m=>f&&m in f?Promise.resolve(f[m]):V(m),S=m=>`await $mounted();${m}`;this.scripts.forEach((m,h)=>{let E={$emit:c,$mounted:g,$self:d,$$self:p},w={filename:this.filename,index:h},y=le(m.content);if(y!==null){let x=":mounted"in m.attrs?S(y):y;rt(x,s,r.effect,E,u,w);return}let{vars:R,code:C}=ae(m.content);R.forEach(x=>{x in s||(s[x]=void 0)});let v=":mounted"in m.attrs?S(C):C;nt(v,s,r.effect,E,u,w)});let b=document.createDocumentFragment();return b.append(this.startMarker,G(this.template,s,r,n),this.endMarker),this.content=b,n?this.styleEls=this.styles.map(m=>{let h=document.createElement("style");return h.textContent=m.content,h}):(this.styles.forEach(m=>et(pe(m))),this.ownsSharedStyles=!0),this}mount(t,n){let s=typeof t=="string"?N(t):t;if(!s)throw new Error(`mount target not found: ${t}`);return(!this.content||n!==void 0)&&this.renderWith(n??{},this.useShadow),this.attach(s)}mountShadow(t,n){let s=typeof t=="string"?N(t):t;if(!s)throw new Error(`mount target not found: ${t}`);return(!this.content||n!==void 0||!this.useShadow)&&this.renderWith(n??{},!0),this.attach(s)}attach(t){this.mountRoot&&this.detach();let n=this.useShadow&&t instanceof Element?t.shadowRoot??t.attachShadow({mode:"open"}):t;return this.useShadow&&this.styleEls.forEach(s=>n.appendChild(s)),n.appendChild(this.content),this.mountRoot=n,this.resolveMounted?.(),this}detach(){if(!this.mountRoot||!this.content||!this.startMarker||!this.endMarker)return this;let t=this.startMarker;for(;t;){let n=t.nextSibling;if(this.content.appendChild(t),t===this.endMarker)break;t=n}return this.mountRoot=null,this}destroy(){return this.detach(),this.fx?.dispose(),this.fx=null,this.styleEls.forEach(t=>t.parentNode?.removeChild(t)),this.styleEls=[],this.ownsSharedStyles&&(this.styles.forEach(t=>tt(pe(t))),this.ownsSharedStyles=!1),this.content=null,this.startMarker=null,this.endMarker=null,this.data=null,this.resolveMounted=null,this}},ot=e=>new L(e);0&&(module.exports={$,$$,$create,$reactive,Component79,parseComponent,renderComponent});
9
+ ;$__exports.done = true })()${$e(o.filename,o.index??0)}`)(i,lt,r,...Object.values(c)),h=u=>console.error("jq79: error in factory script",u),f=!1,p=()=>{if(f)return;f=!0;let u=i.default;if(typeof u!="function")return;let E=y=>{y&&typeof y=="object"&&Object.assign(t,y)};try{let y=u({$data:t,$effect:n,...s});y instanceof Promise?y.then(E).catch(h):E(y)}catch(y){h(y)}};l.then(p,h),i.done&&p()},dt="__JQ79_HMR_ENABLED__",ut="__JQ79_HMR__",v=null,pt=e=>{if(!v||!e.filename)return;let t=v.get(e.filename);t||v.set(e.filename,t=new Set),t.add(new WeakRef(e))},ge=e=>{try{return new URL(e,document.baseURI).pathname}catch{return e}},xe=(e,t)=>{if(!v)return 0;let n=ge(e),s=K(t),r=0;for(let[o,c]of v)if(ge(o)===n){for(let i of c){let l=i.deref();if(!l){c.delete(i);continue}l.hotReplace(s)&&r++}c.size||v.delete(o)}return r},Te=()=>{v??(v=new Map),globalThis[ut]={update:xe}},N=class e{constructor(t,n={}){$(this,"template");$(this,"scripts");$(this,"styles");$(this,"modules");$(this,"filename");$(this,"data",null);$(this,"fx",null);$(this,"content",null);$(this,"startMarker",null);$(this,"endMarker",null);$(this,"styleEls",[]);$(this,"ownsSharedStyles",!1);$(this,"useShadow",!1);$(this,"mountRoot",null);$(this,"resolveMounted",null);$(this,"emitListeners",new Map);let s=typeof t=="string"?K(t):t;this.template=s.template,this.scripts=s.scripts,this.styles=s.styles,this.modules=n.modules??(typeof t=="string"?void 0:t.modules),this.filename=n.filename??(typeof t=="string"?void 0:t.filename),pt(this)}hotReplace(t){let n=typeof t=="string"?K(t):t,s=this.startMarker,r=!!(s&&this.content),o=r&&s.isConnected,c=o?s.parentNode:null,i=o?this.endMarker.nextSibling:null,l={...this.data},h=this.useShadow;return r&&this.destroy(),this.template=n.template,this.scripts=n.scripts,this.styles=n.styles,!r||(this.renderWith(l,h),!c)?!1:(h&&this.styleEls.forEach(f=>c.insertBefore(f,i)),c.insertBefore(this.content,i),this.mountRoot=c,this.resolveMounted?.(),!0)}static async fetch(t){let n=await fetch(t);if(!n.ok)throw new Error(`failed to fetch component from ${t}: ${n.status}`);return new e(await n.text(),{filename:t})}on(t,n){return this.emitListeners.has(t)||this.emitListeners.set(t,new Set),this.emitListeners.get(t).add(n),this}off(t,n){return this.emitListeners.get(t)?.delete(n),this}render(t={}){return this.renderWith(t,!1)}renderShadow(t={}){return this.renderWith(t,!0)}renderWith(t,n){this.destroy();let s=D({...t}),r=M(s);this.data=s,this.fx=r,this.useShadow=n,this.startMarker=document.createComment("jq79"),this.endMarker=document.createComment("/jq79");let o=this.startMarker,c=(a,d)=>{let g=new CustomEvent(a,{detail:d,bubbles:!0,composed:!0}),b=o.dispatchEvent(g);return o===this.startMarker&&this.emitListeners.get(a)?.forEach(m=>m(g,d)),b},i,l=new Promise(a=>{i=a});this.resolveMounted=i;let h=()=>l,f=this.endMarker,p=a=>{let d=[];for(let g=o.nextSibling;g&&g!==f;g=g.nextSibling)g instanceof Element&&(g.matches(a)&&d.push(g),d.push(...Array.from(g.querySelectorAll(a))));return d},u=a=>p(a)[0]??null,E=this.modules,y=a=>E&&a in E?Promise.resolve(E[a]):X(a),_=a=>`await $mounted();${a}`;this.scripts.forEach((a,d)=>{let g={$emit:c,$mounted:h,$self:u,$$self:p},b={filename:this.filename,index:d},m=de(a.content);if(m!==null){let R=":mounted"in a.attrs?_(m):m;ft(R,s,r.effect,g,y,b);return}let{vars:S,code:w}=fe(a.content);S.forEach(R=>{R in s||(s[R]=void 0)});let C=":mounted"in a.attrs?_(w):w;at(C,s,r.effect,g,y,b)});let L=document.createDocumentFragment();return L.append(this.startMarker,V(this.template,s,r,n),this.endMarker),this.content=L,n?this.styleEls=this.styles.map(a=>{let d=document.createElement("style");return d.textContent=a.content,d}):(this.styles.forEach(a=>it(me(a))),this.ownsSharedStyles=!0),this}mount(t,n){let s=typeof t=="string"?A(t):t;if(!s)throw new Error(`mount target not found: ${t}`);return(!this.content||n!==void 0)&&this.renderWith(n??{},this.useShadow),this.attach(s)}mountShadow(t,n){let s=typeof t=="string"?A(t):t;if(!s)throw new Error(`mount target not found: ${t}`);return(!this.content||n!==void 0||!this.useShadow)&&this.renderWith(n??{},!0),this.attach(s)}attach(t){this.mountRoot&&this.detach();let n=this.useShadow&&t instanceof Element?t.shadowRoot??t.attachShadow({mode:"open"}):t;return this.useShadow&&this.styleEls.forEach(s=>n.appendChild(s)),n.appendChild(this.content),this.mountRoot=n,this.resolveMounted?.(),this}detach(){if(!this.mountRoot||!this.content||!this.startMarker||!this.endMarker)return this;let t=this.startMarker;for(;t;){let n=t.nextSibling;if(this.content.appendChild(t),t===this.endMarker)break;t=n}return this.mountRoot=null,this}destroy(){return this.detach(),this.fx?.dispose(),this.fx=null,this.data?.$dispose(),this.styleEls.forEach(t=>t.parentNode?.removeChild(t)),this.styleEls=[],this.ownsSharedStyles&&(this.styles.forEach(t=>ct(me(t))),this.ownsSharedStyles=!1),this.content=null,this.startMarker=null,this.endMarker=null,this.data=null,this.resolveMounted=null,this}},ht=e=>new N(e);typeof globalThis<"u"&&globalThis[dt]&&Te();0&&(module.exports={$,$$,$create,$reactive,Component79,enableHotReload,hotUpdate,parseComponent,renderComponent});
10
10
  //# sourceMappingURL=jq79.cjs.map