jq79 0.7.9 → 0.7.11

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/vite.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../dev/vite.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\"\nimport { posix, relative } from \"node:path\"\nimport { preprocessCSS, transformWithEsbuild } from \"vite\"\nimport type { Plugin, ResolvedConfig } from \"vite\"\n// by package name rather than ../src: this file's types are emitted with dev/\n// as their root, and the generator is the runtime's own code - resolved through\n// the package's exports (external in the build, aliased to src in the tests)\nimport { precompile, precompiledScript } from \"jq79/precompile\"\n\n// Vite plugin: import .html single-file components as modules.\n//\n// import { jq79 } from \"jq79/vite\" // vite.config\n// import UserCard from \"./UserCard.html\" // app code\n//\n// The imported value is a Component79 built from the file's source - the same\n// thing `await Component79.fetch(url)` resolves to, but bundled at build time\n// instead of fetched at runtime. The component source is inlined verbatim, so\n// a file keeps working unchanged if it's ever served from public/ and loaded\n// with fetch instead - with one deliberate exception, a block that says it is\n// written in something else: <style lang=\"scss\"> (or less/stylus/sass) is\n// compiled to plain CSS here, and a TypeScript script - <script lang=\"ts\">, or\n// the same mark spelled <script type=\"text/typescript\"> - to plain JS. Such a\n// component only works through the bundler; loaded with fetch() it would reach\n// the runtime uncompiled, which the runtime warns about.\n//\n// Only .html files imported from other modules are claimed; entry points\n// (index.html) have no importer and imports carrying an explicit query\n// (?raw, ?url) keep their built-in Vite meaning.\n\nexport interface Jq79PluginOptions {\n // which import specifiers are treated as components (default: any .html)\n include?: RegExp\n // resolved absolute paths to skip even when `include` matches\n exclude?: RegExp\n // run the app without eval, for a CSP with no 'unsafe-eval' - the value\n // Component79.safeEval() takes, and meaning the same thing\n // (RECORD/2026-09-23.no-unsafe-eval.md). Every component is precompiled, and\n // their functions ship as one script beside the bundle. `true`: those and\n // nothing else - whatever the build couldn't see is reported, never evaluated.\n // `{ nonce: true }`: whatever it couldn't see (a component built from a\n // string, an edit during HMR) is built as a <script> carrying the page's nonce\n safeEval?: boolean | { nonce?: boolean }\n}\n\n// claimed modules get this suffix so their id no longer ends in \".html\" and\n// Vite's own html handling (entries, asset pipeline) leaves them alone\nconst COMPONENT_QUERY = \"?jq79\"\n\n// safeEval. Precompiled functions travel as a classic script, and not inside\n// a module: they compile under `with`, which is a SyntaxError in strict code,\n// and every module is strict. In a build it is one script for every component\n// - jq79-precompiled-[hash].js, an asset beside the chunks - and the pages that\n// need it preload it (RECORD/2026-11-04.one-precompiled-script.md); in dev each\n// component has its own, which the server hands out (PRECOMPILED_PATH). Either\n// way it pushes its functions onto the queue the runtime drains (see \"safe\n// eval\" in src/jq79.ts).\n//\n// The component's module waits for it - a top-level await - before it builds\n// anything, through a module every component module imports. That module\n// evaluates once, so safe mode is turned on once per app, and a page with no\n// nonce is reported once rather than once per component; and it loads each\n// script once, however many modules ask - in a build they all ask for the\n// same one, so the first await downloads it and the rest resolve at once. The\n// <script> carries the page's nonce when there is one, so a CSP that works by\n// nonce admits it; under `script-src 'self'` the URL is what admits it.\n//\n// Component79 is passed in rather than imported, so the module resolves\n// nothing: a bare \"jq79\" from a virtual importer is the one resolution that\n// would depend on how the app is laid out.\n//\n// A component built from a string *before* any .html module is imported runs\n// in the default mode; such an app calls Component79.safeEval itself. The\n// await needs a build target with top-level await in it - Vite 7 and later\n// have one by default; on Vite 5 or 6, raise build.target to es2022\nconst SAFE_EVAL_ID = \"virtual:jq79/safe-eval\"\nconst RESOLVED_SAFE_EVAL_ID = `\\0${SAFE_EVAL_ID}`\nconst safeEvalModule = (options: { nonce?: boolean; worker: false }) => `\nlet started = null\nconst loading = new Map()\nconst pageNonce = () => {\n for (const script of document.querySelectorAll(\"script[nonce]\")) {\n const nonce = script.nonce || script.getAttribute(\"nonce\")\n if (nonce) return nonce\n }\n}\nexport const safeEval = (Component79, url) => {\n if (!started) started = Component79.safeEval(${JSON.stringify(options)}).catch(error => console.error(error))\n let loaded = loading.get(url)\n if (!loaded) {\n loaded = new Promise((resolve, reject) => {\n const script = document.createElement(\"script\")\n const nonce = pageNonce()\n if (nonce) script.setAttribute(\"nonce\", nonce)\n script.src = url\n script.onload = () => { script.remove(); resolve() }\n script.onerror = () => {\n script.remove()\n reject(new Error(\"jq79: the precompiled functions at \" + url + \" did not load, and safeEval can't render without them\"))\n }\n document.head.append(script)\n })\n loading.set(url, loaded)\n }\n return loaded\n}\n`\n\n// where the dev server hands out a component's precompiled script\nconst PRECOMPILED_PATH = \"/@jq79/precompiled.js\"\n\n// a build's one precompiled script, named as an asset: assets/jq79-precompiled-[hash].js\nconst PRECOMPILED_ASSET = \"jq79-precompiled.js\"\n// what a component's module passes for that script's URL in a build. The asset\n// is emitted in buildEnd, once every component is known - Rolldown has no\n// setAssetSource to fill it in later, and a module is loaded before the build\n// knows the rest - so a module can't name it by reference when it's loaded;\n// renderChunk writes the URL over this\nconst PRECOMPILED_URL_PLACEHOLDER = \"__JQ79_PRECOMPILED_URL__\"\nconst PRECOMPILED_URL_PLACEHOLDER_RE = /([\"'`])__JQ79_PRECOMPILED_URL__\\1/g\n\n// the plugin's safeEval option, as what the modules pass the runtime: null\n// for off, or Component79.safeEval's own options\nconst safeEvalOptions = (option: Jq79PluginOptions[\"safeEval\"]): { nonce?: boolean } | null => {\n if (option === undefined || option === false) return null\n return typeof option === \"object\" && option !== null && option.nonce === true ? { nonce: true } : {}\n}\n\n// a scoped-form body: the runtime falls back to the `with` form when one\n// doesn't compile, so only the `with` form's failure is worth a word\nconst SCOPED_BODY_RE = /^(?:let \\$t;| return \\()/\n\n// one precompiled function, and whether it parses\ntype CheckedFunction = [params: string[], body: string, parses: boolean]\n\n// a component's precompiled functions, each compiled here first - node can,\n// where the page may not - so a script holds only functions that parse; one\n// that doesn't ships as null, and the build says so, once, with its file\nconst componentFunctions = (source: string, warn: (message: string) => void): CheckedFunction[] =>\n precompile(source).map(([params, body]) => {\n try {\n new Function(...params, body)\n return [params, body, true]\n } catch (error) {\n if (!SCOPED_BODY_RE.test(body)) warn(`${(error as Error).message}, in: ${body.length > 120 ? `${body.slice(0, 120)}…` : body}`)\n return [params, body, false]\n }\n })\n\n// the classic script that registers functions (precompiledScript, in\n// jq79/precompile): one component's in dev, every component's in a build. One\n// push, each function once - the runtime keys them by (params, body), so\n// `{{ name }}` written in ten components is one function, and a second entry\n// would only replace the first with itself\nconst registeringScript = (functions: CheckedFunction[]): string => {\n const unique = new Map<string, CheckedFunction>()\n for (const fn of functions) {\n const key = JSON.stringify([fn[0], fn[1]])\n if (!unique.has(key)) unique.set(key, fn)\n }\n return precompiledScript(\n [...unique.values()].map(([params, body]) => [params, body]),\n (params, body) => unique.get(JSON.stringify([params, body]))?.[2] ?? false\n )\n}\n\ntype BundleFile = { type: string; fileName: string; moduleIds?: string[]; imports?: string[] }\n\n// whether a page's entry chunk waits for the precompiled script as it loads:\n// it, or a chunk it imports statically, holds a component module. A component\n// behind import() asks for the script when it is imported, and a preload the\n// page doesn't use straight away only earns a warning in the console\nconst reachesComponent = (entry: BundleFile, bundle: Record<string, BundleFile>): boolean => {\n const seen = new Set<string>()\n const visit = (chunk: BundleFile | undefined): boolean => {\n if (!chunk || chunk.type !== \"chunk\" || seen.has(chunk.fileName)) return false\n seen.add(chunk.fileName)\n return (chunk.moduleIds ?? []).some(id => id.endsWith(COMPONENT_QUERY)) || (chunk.imports ?? []).some(file => visit(bundle[file]))\n }\n return visit(entry)\n}\n\n// a <script src>, quote-aware, and not a data-src\nconst SCRIPT_SRC_RE = /<script\\b(?:\"[^\"]*\"|'[^']*'|[^>\"'])*?\\ssrc\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]+))/gi\n\n// `file` as the page has to write it to get the URL a module asks for: the\n// file relative to the module's chunk, against that chunk's own URL - which\n// is what new URL(..., import.meta.url) resolves. The chunk's URL is read off\n// the page, from the <script src> Vite wrote for it, so `base`, a relative\n// base and renderBuiltUrl are already in it. Any of the bundle's chunks will\n// do, because chunks import each other by relative path - and it has to be\n// any: an entry that is nothing but imports gets no <script> of its own, only\n// its imports do. null when no script on the page loads one of them: no\n// preload is better than one at the wrong URL, which downloads twice\nconst precompiledHref = (html: string, bundle: Record<string, BundleFile>, file: string): string | null => {\n const chunks = Object.values(bundle).filter(out => out.type === \"chunk\").map(out => out.fileName)\n for (const match of html.matchAll(SCRIPT_SRC_RE)) {\n const src = (match[1] ?? match[2] ?? match[3]).replace(/[?#].*$/, \"\")\n const chunk = chunks.find(name => src === name || src.endsWith(`/${name}`))\n if (chunk === undefined) continue\n const path = posix.relative(posix.dirname(chunk), file)\n // a full URL, or a protocol-relative one\n if (/^(?:[a-z][a-z\\d+.-]*:)?\\/\\//i.test(src)) {\n const scheme = src.startsWith(\"//\") ? \"https:\" : \"\"\n return new URL(path, scheme + src).href.slice(scheme.length)\n }\n const href = posix.join(posix.dirname(src), path)\n return src.startsWith(\"/\") || href.startsWith(\".\") ? href : `./${href}`\n }\n return null\n}\n\n// a <script> block with its attribute string, so `lang` can be read and the\n// body replaced - the same shape as STYLE_BLOCK_RE below, quote-aware so a\n// \">\" inside an attribute value (`:setup=\"{ n = a > 1 }\"`) doesn't end the tag\nconst SCRIPT_BLOCK_RE = /<script((?:\"[^\"]*\"|'[^']*'|[^>\"'])*)>([\\s\\S]*?)<\\/script\\s*>/gi\n// import(\"...\") with a literal specifier, tried at word boundaries the\n// scanner below reaches (which is what skips $__import and foo.import(...))\nconst IMPORT_CALL_RE = /import\\s*\\(\\s*([\"'])([^\"'\\n]+?)\\1\\s*\\)/y\n// static import statements (factory scripts): optional clause + literal\n// specifier. The clause can't contain parens/quotes, so dynamic import()\n// and import.meta never match\nconst STATIC_IMPORT_RE = /import\\s*(?:[\\w$\\s,{}*]+?\\s*from\\s*)?([\"'])([^\"'\\n]+)\\1/y\n\nconst skipString = (src: string, start: number): number => {\n const quote = src[start]\n let i = start + 1\n while (i < src.length) {\n if (src[i] === \"\\\\\") { i += 2; continue }\n if (src[i] === quote) return i + 1\n i++\n }\n return src.length\n}\n\n// the literal import specifiers in one script body. A scanner rather than a\n// bare matchAll, because a specifier mentioned in a comment or a string is\n// not an import: hoisting a commented-out `import(\"./old.html\")` would pull\n// dead files into the bundle - or break the build once the file is gone\nconst importSpecifiers = (script: string): string[] => {\n const specs: string[] = []\n let i = 0\n while (i < script.length) {\n const ch = script[i]\n if (ch === \"'\" || ch === '\"' || ch === \"`\") { i = skipString(script, i); continue }\n if (ch === \"/\" && script[i + 1] === \"/\") {\n const end = script.indexOf(\"\\n\", i)\n i = end === -1 ? script.length : end + 1\n continue\n }\n if (ch === \"/\" && script[i + 1] === \"*\") {\n const end = script.indexOf(\"*/\", i + 2)\n i = end === -1 ? script.length : end + 2\n continue\n }\n if (ch === \"i\" && (i === 0 || !/[\\w$.]/.test(script[i - 1]))) {\n IMPORT_CALL_RE.lastIndex = i\n const call = IMPORT_CALL_RE.exec(script)\n if (call) { specs.push(call[2]); i = IMPORT_CALL_RE.lastIndex; continue }\n STATIC_IMPORT_RE.lastIndex = i\n const staticImport = STATIC_IMPORT_RE.exec(script)\n if (staticImport) { specs.push(staticImport[2]); i = STATIC_IMPORT_RE.lastIndex; continue }\n }\n i++\n }\n return specs\n}\n\nconst isHtmlUrl = (spec: string) => /\\.html?([?#]|$)/.test(spec)\nconst isExternalUrl = (spec: string) => /^[a-z][a-z0-9+.-]*:/i.test(spec) || spec.startsWith(\"/\")\n\n// literal import specifiers in the component's script blocks - dynamic\n// `import(\"...\")` calls and static factory-script imports - that should\n// resolve from the bundle instead of at runtime. Absolute paths and full\n// URLs are left alone (they point at served files, e.g. public/), and so\n// are .html specifiers the plugin wouldn't claim as components\nconst hoistableImports = (source: string, include: RegExp): string[] => {\n const specifiers = new Set<string>()\n for (const [, , script] of source.matchAll(SCRIPT_BLOCK_RE)) {\n for (const spec of importSpecifiers(script)) {\n if (isExternalUrl(spec)) continue\n if (isHtmlUrl(spec) && !include.test(spec)) continue // html left to runtime fetch\n specifiers.add(spec) // a claimed component, a source file or an npm package\n }\n }\n return [...specifiers]\n}\n\n// any start or end tag, quote-aware so a \">\" inside an attribute value doesn't\n// end it early\nconst TAG_RE = /<(\\/?)([A-Za-z][\\w-]*)((?:\"[^\"]*\"|'[^']*'|[^>\"'])*)>/g\nconst NAME_ATTR_RE = /\\bname\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)')/i\nconst COMPONENT_NAME_RE = /^[A-Z][A-Za-z0-9]*$/\nconst VOID_ELEMENTS = new Set([\n \"area\", \"base\", \"br\", \"col\", \"embed\", \"hr\", \"img\", \"input\",\n \"link\", \"meta\", \"param\", \"source\", \"track\", \"wbr\",\n])\n\n// the components a file declares: its *top-level* <template name=\"…\"> blocks,\n// which the emitted module re-exports by name. Depth is tracked because only\n// the top level declares - a <template> nested in the markup is a plain inert\n// element the runtime leaves alone, and exporting it would name something that\n// never exists. Script and style bodies are cut out first, so a \"<\" in JS or a\n// selector can't be read as a tag\nconst declaredComponents = (source: string): string[] => {\n const markup = source.replace(SCRIPT_BLOCK_RE, \"\").replace(STYLE_BLOCK_RE, \"\")\n const names: string[] = []\n let depth = 0\n\n for (const [, closing, tag, attrs] of markup.matchAll(TAG_RE)) {\n if (closing) {\n depth = Math.max(0, depth - 1)\n continue\n }\n const selfClosing = /\\/\\s*$/.test(attrs) || VOID_ELEMENTS.has(tag.toLowerCase())\n if (depth === 0 && !selfClosing && tag.toLowerCase() === \"template\") {\n const declared = attrs.match(NAME_ATTR_RE)\n const name = declared?.[1] ?? declared?.[2]\n // the runtime warns about the ones this skips (nameless, not PascalCase)\n if (name && COMPONENT_NAME_RE.test(name)) names.push(name)\n }\n if (!selfClosing) depth++\n }\n return names\n}\n\n// a <style> block with its attribute string, so `lang` can be read and the\n// content replaced. Attribute values are matched as quoted chunks so a \">\"\n// inside one doesn't end the tag early\nconst STYLE_BLOCK_RE = /<style((?:\"[^\"]*\"|'[^']*'|[^>\"'])*)>([\\s\\S]*?)<\\/style\\s*>/gi\nconst LANG_ATTR_RE = /\\blang\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]+))/i\nconst TYPE_ATTR_RE = /\\btype\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]+))/i\n\n// one attribute's value out of a tag's attribute string, whichever way it was\n// quoted - null when the attribute isn't there at all\nconst attrValue = (attrs: string, re: RegExp): string | null => {\n const found = attrs.match(re)\n return found ? found[1] ?? found[2] ?? found[3] : null\n}\n\n// compiles <style lang=\"scss|less|styl|sass\"> blocks to plain CSS with Vite's\n// own preprocessing (the same call @vitejs/plugin-vue makes), so the runtime\n// only ever sees CSS. The preprocessor picks its parser from the extension,\n// and resolving relative @use/@import against a filename in the component's\n// own directory is what makes `@use \"./vars\"` work. Files the preprocessor\n// pulls in are registered as watch deps, so editing a partial re-runs HMR for\n// every component that uses it. `lang` is dropped from the emitted tag: what\n// the runtime parses is a plain <style> (with `scoped` and the rest intact)\nconst compileStyleBlocks = async (\n source: string,\n file: string,\n config: ResolvedConfig,\n addWatchFile: (id: string) => void\n): Promise<string> => {\n const blocks = [...source.matchAll(STYLE_BLOCK_RE)]\n const compiled = await Promise.all(\n blocks.map(async ([, attrs, content]) => {\n const extension = attrValue(attrs, LANG_ATTR_RE)\n if (extension === null) return null\n const result = await preprocessCSS(content, `${file}.${extension}`, config)\n result.deps?.forEach(addWatchFile)\n return { attrs: attrs.replace(LANG_ATTR_RE, \"\").trimEnd(), css: result.code }\n })\n )\n\n let out = \"\"\n let last = 0\n blocks.forEach((block, i) => {\n const done = compiled[i]\n if (!done) return\n out += source.slice(last, block.index) + `<style${done.attrs}>${done.css}</style>`\n last = block.index + block[0].length\n })\n return out + source.slice(last)\n}\n\n// languages a <script lang> is compiled from. Anything else is left as written\n// for the runtime to warn about, rather than guessed at\nconst TS_LANGS = new Set([\"ts\", \"typescript\"])\n// the other spelling of the same mark. A component is a plain .html file, not\n// an SFC, so nothing in an editor knows what `lang` means there, and each mark\n// gets half of one: VS Code's HTML language service checks a `type` of\n// text/typescript as TypeScript (and `lang=\"ts\"` as JavaScript), while its\n// grammar colors that `type` not at all (and `lang=\"ts\"` as JavaScript). See\n// docs/vite-plugin.md#which-mark-in-vs-code. The `x-` forms are the historical\n// spelling of the same two media types\nconst TS_TYPE_RE = /^(?:text|application)\\/(?:x-)?typescript$/\n\n// what marks a script block as TypeScript, given back as the attribute to drop\n// from the emitted tag - the block is compiled to JS, so the mark goes with the\n// types whichever one carried it. A `lang` answers on its own: `lang=\"coffee\"`\n// is a language this plugin doesn't compile, and reading `type` past it would\n// compile a block the author said was something else\nconst typescriptAttr = (attrs: string): RegExp | null => {\n const lang = attrValue(attrs, LANG_ATTR_RE)\n if (lang !== null) return TS_LANGS.has(lang.trim().toLowerCase()) ? LANG_ATTR_RE : null\n const type = attrValue(attrs, TYPE_ATTR_RE)\n return type !== null && TS_TYPE_RE.test(type.trim().toLowerCase()) ? TYPE_ATTR_RE : null\n}\n\ntype ViteTransform = (code: string, id: string, options?: unknown) => Promise<{ code: string }>\n\n// what strips the types: vite's own transform, so the plugin carries no\n// compiler of its own. *Which* transform is a version question, and neither\n// answer covers the peer range (vite >= 5) alone - transformWithOxc is the one\n// vite is moving to but only exists from vite 7, while transformWithEsbuild is\n// deprecated under vite 8 and throws there unless esbuild is installed\n// separately. So it is looked up at call time: oxc where it exists, esbuild on\n// the older versions that ship it.\n//\n// Both drop unused value imports by default, because a TS transform can't tell\n// a type-only import from an unused one. That would be silent damage here: a\n// factory script's `import Row from \"./row.html\"` would vanish, taking with it\n// the specifier hoistableImports needs to pull the child into the bundle. The\n// flags below are what keep it - only `import type` is erased\nconst stripTypes = async (ts: string, file: string): Promise<string> => {\n const vite = (await import(\"vite\")) as unknown as { transformWithOxc?: ViteTransform }\n const { code } = vite.transformWithOxc\n ? await vite.transformWithOxc(ts, file, { lang: \"ts\", typescript: { onlyRemoveTypeImports: true } })\n : await transformWithEsbuild(ts, file, {\n loader: \"ts\",\n tsconfigRaw: { compilerOptions: { verbatimModuleSyntax: true } },\n })\n // a script whose only imports were `import type` comes back marked as a\n // module. `export {}` exports nothing, and it is a SyntaxError inside the\n // Function body the runtime compiles a script into\n return code.replace(/^[ \\t]*export\\s*\\{\\s*\\}\\s*;?[ \\t]*$/m, \"\")\n}\n\n// the `:setup` attribute, when it carries a value (a bare `:setup` is the\n// closed signature and can't be typed)\nconst SETUP_ATTR_RE = /(:setup\\s*=\\s*)(?:\"([^\"]*)\"|'([^']*)')/i\n// the arrow body the signature is wrapped in, so the parameter list can be\n// found again in the output without matching brackets\nconst SIGNATURE_MARKER = \"__jq79_signature__\"\n\n// a component's props signature lives in the `:setup` *attribute*, not in the\n// script body, so the body's transform never sees it - and the TypeScript mark\n// has to mean the same thing on both halves of the block, or a typed signature\n// either survives into a component the plugin just promised was JS or, for\n// `_: Props`, stops reading as a signature at all.\n//\n// It goes through the same transform as everything else, wrapped as a\n// parameter list, rather than being cut with a scanner of its own: the\n// annotation can sit on the pattern (`{ a }: Props`), on the permissive `_`, or\n// inside a default (`{ step = 1 as number }`, which the runtime would evaluate\n// and silently drop), and telling those apart is a parser's job. Both transforms\n// hand back `(<params>) => <marker>` on one line, parens intact\nconst stripSignatureTypes = async (value: string, file: string): Promise<string> => {\n const compiled = await stripTypes(`(${value}) => ${SIGNATURE_MARKER}`, file)\n const marker = compiled.indexOf(SIGNATURE_MARKER)\n if (marker === -1) return value // not the shape expected: leave it as written\n const head = compiled.slice(0, marker).trimEnd()\n const params = (head.endsWith(\"=>\") ? head.slice(0, -2) : head).trim()\n return params.startsWith(\"(\") && params.endsWith(\")\") ? params.slice(1, -1).trim() : params\n}\n\n// the signature back into a double-quoted attribute. Only `\"` needs escaping:\n// the transforms normalize string literals to double quotes, so a default the\n// author wrote as `'x'` comes back as `\"x\"` and would end the attribute early.\n// `&` is deliberately left alone - `&&` in a default is not an entity and\n// survives the parse, while escaping it would double-encode a source that\n// already wrote `&quot;`\nconst quoteAttrValue = (value: string) => value.replace(/\"/g, \"&quot;\")\n\n// compiles TypeScript script blocks to plain JS, so the runtime only ever sees\n// JS - the same deal <style lang=\"scss\"> gets, for a sharper reason. The setup\n// scanner is not a parser: `let count: number = 0` reaching it is not a syntax\n// error but a labeled statement that assigns to `number`, so it runs and leaves\n// `count` undeclared. Whichever attribute marked the block (`lang=\"ts\"` or\n// `type=\"text/typescript\"`) is dropped from the emitted tag and every other one\n// (`:setup`, `:mounted`) is left as written.\n//\n// This runs before hoistableImports reads the source, so an `import type`\n// specifier is already gone by the time the plugin decides what to bundle\nconst compileScriptBlocks = async (source: string, file: string): Promise<string> => {\n const blocks = [...source.matchAll(SCRIPT_BLOCK_RE)]\n const compiled = await Promise.all(\n blocks.map(async ([, attrs, content]) => {\n const marker = typescriptAttr(attrs)\n if (!marker) return null\n\n let rest = attrs.replace(marker, \"\").trimEnd()\n const setup = rest.match(SETUP_ATTR_RE)\n if (setup) {\n const signature = await stripSignatureTypes(setup[2] ?? setup[3], `${file}.signature.ts`)\n // a function replacement, not a string: `$&` and friends are live in a\n // replacement string and a default value is arbitrary source\n rest = rest.replace(SETUP_ATTR_RE, () => `${setup[1]}\"${quoteAttrValue(signature)}\"`)\n }\n\n return { attrs: rest, js: await stripTypes(content, `${file}.ts`) }\n })\n )\n\n let out = \"\"\n let last = 0\n blocks.forEach((block, i) => {\n const done = compiled[i]\n if (!done) return\n out += source.slice(last, block.index) + `<script${done.attrs}>${done.js}</script>`\n last = block.index + block[0].length\n })\n return out + source.slice(last)\n}\n\n// the emitted module. Literal import(\"...\") specifiers found in the\n// component's scripts become real module imports, handed to Component79 as a\n// resolution map: at runtime $__import checks the map before falling back to\n// fetch, so bundled components ship with their imports and nothing changes\n// for unbundled ones. Claimed components import as their default (a\n// Component79, matching what runtime fetch resolves to); everything else as\n// a namespace (matching native import()).\n//\n// A file's <template name=\"…\"> components are re-exported by name, so the\n// module shape is the one the file already has: default plus named. They read\n// off the instance, which is where the runtime hangs them - so in dev they are\n// bound to the *first* evaluation's definitions and a module that imports one\n// by name keeps the pre-edit child until the page reloads. The file's own\n// component patches in place, and its rendered children come from the reparse,\n// so this only shows in a component imported by name from another file.\n//\n// In dev, `hot.data` carries the exported instance across updates: importers\n// hold a reference to the *first* module evaluation's instance, so later\n// evaluations patch that same instance in place instead of exporting a new one\n// nobody sees. The patching itself is the runtime's `hotReplace` - the same\n// swap the jq79/dev server drives, from the one place that can reach a\n// component's markers. An instance only used as a definition has nothing to\n// re-render (nested clones can't be reached from this module), so it falls\n// back to a full reload.\n// `precompiled` is the precompiled script's URL, as a JS expression - present\n// only in safeEval mode\nconst componentModule = (source: string, include: RegExp, filename: string, precompiled?: string): string => {\n const hoisted = hoistableImports(source, include)\n const imports = hoisted\n .map((spec, i) =>\n include.test(spec)\n ? `import __jq79_${i} from ${JSON.stringify(spec)}`\n : `import * as __jq79_${i} from ${JSON.stringify(spec)}`\n )\n .join(\"\\n\")\n const modulesMap = `{ ${hoisted.map((spec, i) => `${JSON.stringify(spec)}: __jq79_${i}`).join(\", \")} }`\n\n // without safeEval, the module is exactly what it always was\n const safeEvalImport = precompiled ? `\\nimport { safeEval } from \"${SAFE_EVAL_ID}\"` : \"\"\n const safeEvalCall = precompiled ? `\\nawait safeEval(Component79, ${precompiled})` : \"\"\n\n return `\nimport { Component79 } from \"jq79\"${safeEvalImport}\n${imports}${safeEvalCall}\n\nconst src = ${JSON.stringify(source)}\nconst modules = ${modulesMap}\nconst filename = ${JSON.stringify(filename)}\n\nlet component\n\nif (import.meta.hot && import.meta.hot.data.component) {\n const prior = import.meta.hot.data.component\n prior.modules = modules\n prior.filename = filename\n // re-renders it where it stands, keeping its data. false means it was never\n // rendered - a definition used only as a nested component - and a reload is\n // the only way to reach the clones made from it\n if (!prior.hotReplace(src) && !prior.data) import.meta.hot.invalidate()\n component = prior\n} else {\n component = new Component79(src, { modules, filename })\n}\n\nif (import.meta.hot) {\n import.meta.hot.data.component = component\n import.meta.hot.accept()\n}\n\nexport default component\n${declaredComponents(source).map(name => `export const ${name} = component.${name}`).join(\"\\n\")}\n`\n}\n\nexport function jq79(options: Jq79PluginOptions = {}): Plugin {\n const include = options.include ?? /\\.html$/\n const { exclude } = options\n const safeEval = safeEvalOptions(options.safeEval)\n // dev only: each component's precompiled script, by the id its module asks\n // for - so the server hands out what the plugin compiled and nothing else\n const devScripts = new Map<string, string>()\n const devIds = new Map<string, number>()\n // build only: each component's functions, by file, for the one script\n // buildEnd emits - its reference, and the file name renderChunk resolves it to\n const buildFunctions = new Map<string, CheckedFunction[]>()\n let precompiledRef: string | undefined\n let precompiledFile: string | undefined\n\n let config: ResolvedConfig | null = null\n\n return {\n name: \"jq79\",\n enforce: \"pre\",\n\n configResolved(resolved) {\n config = resolved\n },\n\n configureServer(server) {\n if (!safeEval) return\n server.middlewares.use((req, res, next) => {\n const url = new URL(req.url ?? \"/\", \"http://localhost\")\n if (!url.pathname.endsWith(PRECOMPILED_PATH)) return next()\n const script = devScripts.get(url.searchParams.get(\"id\") ?? \"\")\n if (script === undefined) return next()\n res.setHeader(\"Content-Type\", \"text/javascript\")\n res.setHeader(\"Cache-Control\", \"no-cache\")\n res.end(script)\n })\n },\n\n async resolveId(source, importer) {\n if (source === SAFE_EVAL_ID) return RESOLVED_SAFE_EVAL_ID\n if (!importer) return null // entry points are never components\n if (source.includes(\"?\")) return null // ?raw, ?url, ... keep their meaning\n if (!include.test(source)) return null\n\n const resolved = await this.resolve(source, importer, { skipSelf: true })\n if (!resolved || resolved.external) return null\n if (exclude?.test(resolved.id)) return null\n return resolved.id + COMPONENT_QUERY\n },\n\n async load(id) {\n // a Vite page's functions come from the build, so it never registers the worker\n if (id === RESOLVED_SAFE_EVAL_ID) return safeEvalModule({ ...safeEval, worker: false })\n if (!id.endsWith(COMPONENT_QUERY)) return null\n const file = id.slice(0, -COMPONENT_QUERY.length)\n\n let source = await readFile(file, \"utf8\")\n source = await compileScriptBlocks(source, file)\n if (config) source = await compileStyleBlocks(source, file, config, dep => this.addWatchFile(dep))\n\n // the runtime names the component's setup scripts after this, so devtools\n // shows a path the user recognizes instead of an anonymous VM script\n const filename = config ? relative(config.root, file) : file\n\n if (!safeEval) return { code: componentModule(source, include, filename), map: null }\n\n // the component's functions, compiled after its TypeScript and styles are:\n // the runtime compiles what reaches it, and this is what reaches it\n const functions = componentFunctions(source, message => this.warn(`jq79: ${filename}: ${message}`))\n let url: string\n if (config?.command === \"serve\") {\n let devId = devIds.get(file)\n if (devId === undefined) devIds.set(file, devId = devIds.size)\n devScripts.set(String(devId), registeringScript(functions))\n // versioned, so an edit loads the new functions rather than a cached copy\n url = JSON.stringify(`${config.base}${PRECOMPILED_PATH.slice(1)}?id=${devId}&v=${Date.now()}`)\n } else {\n buildFunctions.set(file, functions)\n url = JSON.stringify(PRECOMPILED_URL_PLACEHOLDER)\n }\n return { code: componentModule(source, include, filename, url), map: null }\n },\n\n buildStart() {\n precompiledRef = undefined\n precompiledFile = undefined\n },\n\n // the build's one precompiled script, from every component still in the\n // module graph. What earlier builds recorded is kept and pruned rather than\n // cleared in buildStart, so a watch rebuild that doesn't load a module again\n // keeps its functions. Sorted by file, so the same sources make the same\n // bytes, and the same hash\n buildEnd(error) {\n if (!safeEval || error || config?.command === \"serve\") return\n const inGraph = new Set<string>()\n for (const id of this.getModuleIds()) if (id.endsWith(COMPONENT_QUERY)) inGraph.add(id.slice(0, -COMPONENT_QUERY.length))\n for (const file of buildFunctions.keys()) if (!inGraph.has(file)) buildFunctions.delete(file)\n if (buildFunctions.size === 0) return\n const functions = [...buildFunctions.keys()].sort().flatMap(file => buildFunctions.get(file)!)\n precompiledRef = this.emitFile({ type: \"asset\", name: PRECOMPILED_ASSET, source: registeringScript(functions) })\n },\n\n // the placeholder, as what import.meta.ROLLUP_FILE_URL_<ref> renders to:\n // the asset's path relative to the chunk, against the chunk's own URL - so\n // `base` doesn't matter. Before minification, and part of the chunk's hash.\n // The source map is left as it is: the placeholder sits on a line of its\n // own with only `)` after it\n renderChunk(code, chunk) {\n if (precompiledRef === undefined || !code.includes(PRECOMPILED_URL_PLACEHOLDER)) return null\n precompiledFile = this.getFileName(precompiledRef)\n const path = JSON.stringify(posix.relative(posix.dirname(chunk.fileName), precompiledFile))\n return { code: code.replace(PRECOMPILED_URL_PLACEHOLDER_RE, () => `new URL(${path}, import.meta.url).href`), map: null }\n },\n\n // a page that waits for the script asks for it as it parses, rather than\n // once its entry has loaded and run. Same URL as the module's\n // (precompiledHref), and no crossorigin, as the <script> has none: a\n // preload is only reused by a request that matches it. Vite's html.cspNonce\n // stamps it with the nonce, after this hook - without it,\n // `script-src 'nonce-…'` refuses a preload. Build only: dev has one script\n // per component, versioned per edit. Vite writes the page's <script> tags\n // before it runs this hook, in every version the plugin supports\n transformIndexHtml(html, ctx) {\n if (!safeEval || !precompiledFile || !ctx.bundle || !ctx.chunk) return\n const bundle = ctx.bundle as Record<string, BundleFile>\n if (!reachesComponent(ctx.chunk as BundleFile, bundle)) return\n const href = precompiledHref(html, bundle, precompiledFile)\n if (href === null) return\n return [{ tag: \"link\", attrs: { rel: \"preload\", as: \"script\", href }, injectTo: \"head\" }]\n },\n }\n}\n\nexport default jq79\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,OAAO,gBAAgB;AAChC,SAAS,eAAe,4BAA4B;AAKpD,SAAS,YAAY,yBAAyB;AAuC9C,IAAM,kBAAkB;AA4BxB,IAAM,eAAe;AACrB,IAAM,wBAAwB,KAAK,YAAY;AAC/C,IAAM,iBAAiB,CAAC,YAAgD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAUvB,KAAK,UAAU,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBxE,IAAM,mBAAmB;AAGzB,IAAM,oBAAoB;AAM1B,IAAM,8BAA8B;AACpC,IAAM,iCAAiC;AAIvC,IAAM,kBAAkB,CAAC,WAAsE;AAC7F,MAAI,WAAW,UAAa,WAAW,MAAO,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G,QAAO;AACxF,wBAAkB,KAAK,YAAY,cAAc;AACjD,YAAM,OAAO,KAAK,UAAU,MAAM,SAAS,MAAM,QAAQ,MAAM,QAAQ,GAAG,eAAe,CAAC;AAC1F,aAAO,EAAE,MAAM,KAAK,QAAQ,gCAAgC,MAAM,WAAW,IAAI,yBAAyB,GAAG,KAAK,KAAK;AAAA,IACzH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAUA,mBAAmB,MAAM,KAAK;AAC5B,UAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC,IAAI,UAAU,CAAC,IAAI,MAAO;AAChE,YAAM,SAAS,IAAI;AACnB,UAAI,CAAC,iBAAiB,IAAI,OAAqB,MAAM,EAAG;AACxD,YAAM,OAAO,gBAAgB,MAAM,QAAQ,eAAe;AAC1D,UAAI,SAAS,KAAM;AACnB,aAAO,CAAC,EAAE,KAAK,QAAQ,OAAO,EAAE,KAAK,WAAW,IAAI,UAAU,KAAK,GAAG,UAAU,OAAO,CAAC;AAAA,IAC1F;AAAA,EACF;AACF;AAEA,IAAO,eAAQ;","names":[]}
1
+ {"version":3,"sources":["../dev/vite.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\"\nimport { posix, relative } from \"node:path\"\nimport { preprocessCSS, transformWithEsbuild } from \"vite\"\nimport type { Plugin, ResolvedConfig } from \"vite\"\n// by package name rather than ../src: this file's types are emitted with dev/\n// as their root, and the generator is the runtime's own code - resolved through\n// the package's exports (external in the build, aliased to src in the tests)\nimport { precompile, precompiledScript } from \"jq79/precompile\"\n\n// Vite plugin: import .html single-file components as modules.\n//\n// import { jq79 } from \"jq79/vite\" // vite.config\n// import UserCard from \"./UserCard.html\" // app code\n//\n// The imported value is a Component79 built from the file's source - the same\n// thing `await Component79.fetch(url)` resolves to, but bundled at build time\n// instead of fetched at runtime. The component source is inlined verbatim, so\n// a file keeps working unchanged if it's ever served from public/ and loaded\n// with fetch instead - with one deliberate exception, a block that says it is\n// written in something else: <style lang=\"scss\"> (or less/stylus/sass) is\n// compiled to plain CSS here, and a TypeScript script - <script lang=\"ts\">, or\n// the same mark spelled <script type=\"text/typescript\"> - to plain JS. Such a\n// component only works through the bundler; loaded with fetch() it would reach\n// the runtime uncompiled, which the runtime warns about.\n//\n// Only .html files imported from other modules are claimed; entry points\n// (index.html) have no importer and imports carrying an explicit query\n// (?raw, ?url) keep their built-in Vite meaning.\n\nexport interface Jq79PluginOptions {\n // which import specifiers are treated as components (default: any .html)\n include?: RegExp\n // resolved absolute paths to skip even when `include` matches\n exclude?: RegExp\n // run the app without eval, for a CSP with no 'unsafe-eval' - the value\n // Component79.safeEval() takes, and meaning the same thing\n // (RECORD/2026-09-23.no-unsafe-eval.md). Every component is precompiled, and\n // their functions ship as one script beside the bundle. `true`: those and\n // nothing else - whatever the build couldn't see is reported, never evaluated.\n // `{ nonce: true }`: whatever it couldn't see (a component built from a\n // string, an edit during HMR) is built as a <script> carrying the page's nonce\n safeEval?: boolean | { nonce?: boolean }\n}\n\n// claimed modules get this suffix so their id no longer ends in \".html\" and\n// Vite's own html handling (entries, asset pipeline) leaves them alone\nconst COMPONENT_QUERY = \"?jq79\"\n\n// safeEval. Precompiled functions travel as a classic script, and not inside\n// a module: they compile under `with`, which is a SyntaxError in strict code,\n// and every module is strict. In a build it is one script for every component\n// - jq79-precompiled-[hash].js, an asset beside the chunks - and the pages that\n// need it preload it (RECORD/2026-11-04.one-precompiled-script.md); in dev each\n// component has its own, which the server hands out (PRECOMPILED_PATH). Either\n// way it pushes its functions onto the queue the runtime drains (see \"safe\n// eval\" in src/jq79.ts).\n//\n// The component's module waits for it - a top-level await - before it builds\n// anything, through a module every component module imports. That module\n// evaluates once, so safe mode is turned on once per app, and a page with no\n// nonce is reported once rather than once per component; and it loads each\n// script once, however many modules ask - in a build they all ask for the\n// same one, so the first await downloads it and the rest resolve at once. The\n// <script> carries the page's nonce when there is one, so a CSP that works by\n// nonce admits it; under `script-src 'self'` the URL is what admits it.\n//\n// Component79 is passed in rather than imported, so the module resolves\n// nothing: a bare \"jq79\" from a virtual importer is the one resolution that\n// would depend on how the app is laid out.\n//\n// A component built from a string *before* any .html module is imported runs\n// in the default mode; such an app calls Component79.safeEval itself. The\n// await needs a build target with top-level await in it - Vite 7 and later\n// have one by default; on Vite 5 or 6, raise build.target to es2022\nconst SAFE_EVAL_ID = \"virtual:jq79/safe-eval\"\nconst RESOLVED_SAFE_EVAL_ID = `\\0${SAFE_EVAL_ID}`\nconst safeEvalModule = (options: { nonce?: boolean; worker: false }) => `\nlet started = null\nconst loading = new Map()\nconst pageNonce = () => {\n for (const script of document.querySelectorAll(\"script[nonce]\")) {\n const nonce = script.nonce || script.getAttribute(\"nonce\")\n if (nonce) return nonce\n }\n}\nexport const safeEval = (Component79, url) => {\n if (!started) started = Component79.safeEval(${JSON.stringify(options)}).catch(error => console.error(error))\n let loaded = loading.get(url)\n if (!loaded) {\n loaded = new Promise((resolve, reject) => {\n const script = document.createElement(\"script\")\n const nonce = pageNonce()\n if (nonce) script.setAttribute(\"nonce\", nonce)\n script.src = url\n script.onload = () => { script.remove(); resolve() }\n script.onerror = () => {\n script.remove()\n reject(new Error(\"jq79: the precompiled functions at \" + url + \" did not load, and safeEval can't render without them\"))\n }\n document.head.append(script)\n })\n loading.set(url, loaded)\n }\n return loaded\n}\n`\n\n// where the dev server hands out a component's precompiled script\nconst PRECOMPILED_PATH = \"/@jq79/precompiled.js\"\n\n// a build's one precompiled script, named as an asset: assets/jq79-precompiled-[hash].js\nconst PRECOMPILED_ASSET = \"jq79-precompiled.js\"\n// what a component's module passes for that script's URL in a build. The asset\n// is emitted in buildEnd, once every component is known - Rolldown has no\n// setAssetSource to fill it in later, and a module is loaded before the build\n// knows the rest - so a module can't name it by reference when it's loaded;\n// renderChunk writes the URL over this\nconst PRECOMPILED_URL_PLACEHOLDER = \"__JQ79_PRECOMPILED_URL__\"\nconst PRECOMPILED_URL_PLACEHOLDER_RE = /([\"'`])__JQ79_PRECOMPILED_URL__\\1/g\n\n// the plugin's safeEval option, as what the modules pass the runtime: null\n// for off, or Component79.safeEval's own options\nconst safeEvalOptions = (option: Jq79PluginOptions[\"safeEval\"]): { nonce?: boolean } | null => {\n if (option === undefined || option === false) return null\n return typeof option === \"object\" && option !== null && option.nonce === true ? { nonce: true } : {}\n}\n\n// a scoped-form body: the runtime falls back to the `with` form when one\n// doesn't compile, so only the `with` form's failure is worth a word\nconst SCOPED_BODY_RE = /^(?:let \\$t;| return \\()/\n\n// one precompiled function, and whether it parses\ntype CheckedFunction = [params: string[], body: string, parses: boolean]\n\n// a component's precompiled functions, each compiled here first - node can,\n// where the page may not - so a script holds only functions that parse; one\n// that doesn't ships as null, and the build says so, once, with its file\nconst componentFunctions = (source: string, warn: (message: string) => void): CheckedFunction[] =>\n precompile(source).map(([params, body]) => {\n try {\n new Function(...params, body)\n return [params, body, true]\n } catch (error) {\n if (!SCOPED_BODY_RE.test(body)) warn(`${(error as Error).message}, in: ${body.length > 120 ? `${body.slice(0, 120)}…` : body}`)\n return [params, body, false]\n }\n })\n\n// the classic script that registers functions (precompiledScript, in\n// jq79/precompile): one component's in dev, every component's in a build. One\n// push, each function once - the runtime keys them by (params, body), so\n// `{{ name }}` written in ten components is one function, and a second entry\n// would only replace the first with itself\nconst registeringScript = (functions: CheckedFunction[]): string => {\n const unique = new Map<string, CheckedFunction>()\n for (const fn of functions) {\n const key = JSON.stringify([fn[0], fn[1]])\n if (!unique.has(key)) unique.set(key, fn)\n }\n return precompiledScript(\n [...unique.values()].map(([params, body]) => [params, body]),\n (params, body) => unique.get(JSON.stringify([params, body]))?.[2] ?? false\n )\n}\n\ntype BundleFile = { type: string; fileName: string; moduleIds?: string[]; imports?: string[] }\n\n// whether a page's entry chunk waits for the precompiled script as it loads:\n// it, or a chunk it imports statically, holds a component module. A component\n// behind import() asks for the script when it is imported, and a preload the\n// page doesn't use straight away only earns a warning in the console\nconst reachesComponent = (entry: BundleFile, bundle: Record<string, BundleFile>): boolean => {\n const seen = new Set<string>()\n const visit = (chunk: BundleFile | undefined): boolean => {\n if (!chunk || chunk.type !== \"chunk\" || seen.has(chunk.fileName)) return false\n seen.add(chunk.fileName)\n return (chunk.moduleIds ?? []).some(id => id.endsWith(COMPONENT_QUERY)) || (chunk.imports ?? []).some(file => visit(bundle[file]))\n }\n return visit(entry)\n}\n\n// a <script src>, quote-aware, and not a data-src\nconst SCRIPT_SRC_RE = /<script\\b(?:\"[^\"]*\"|'[^']*'|[^>\"'])*?\\ssrc\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]+))/gi\n\n// `file` as the page has to write it to get the URL a module asks for: the\n// file relative to the module's chunk, against that chunk's own URL - which\n// is what new URL(..., import.meta.url) resolves. The chunk's URL is read off\n// the page, from the <script src> Vite wrote for it, so `base`, a relative\n// base and renderBuiltUrl are already in it. Any of the bundle's chunks will\n// do, because chunks import each other by relative path - and it has to be\n// any: an entry that is nothing but imports gets no <script> of its own, only\n// its imports do. null when no script on the page loads one of them: no\n// preload is better than one at the wrong URL, which downloads twice\nconst precompiledHref = (html: string, bundle: Record<string, BundleFile>, file: string): string | null => {\n const chunks = Object.values(bundle).filter(out => out.type === \"chunk\").map(out => out.fileName)\n for (const match of html.matchAll(SCRIPT_SRC_RE)) {\n const src = (match[1] ?? match[2] ?? match[3]).replace(/[?#].*$/, \"\")\n const chunk = chunks.find(name => src === name || src.endsWith(`/${name}`))\n if (chunk === undefined) continue\n const path = posix.relative(posix.dirname(chunk), file)\n // a full URL, or a protocol-relative one\n if (/^(?:[a-z][a-z\\d+.-]*:)?\\/\\//i.test(src)) {\n const scheme = src.startsWith(\"//\") ? \"https:\" : \"\"\n return new URL(path, scheme + src).href.slice(scheme.length)\n }\n const href = posix.join(posix.dirname(src), path)\n return src.startsWith(\"/\") || href.startsWith(\".\") ? href : `./${href}`\n }\n return null\n}\n\n// a <script> block with its attribute string, so `lang` can be read and the\n// body replaced - the same shape as STYLE_BLOCK_RE below, quote-aware so a\n// \">\" inside an attribute value (`:setup=\"{ n = a > 1 }\"`) doesn't end the tag\nconst SCRIPT_BLOCK_RE = /<script((?:\"[^\"]*\"|'[^']*'|[^>\"'])*)>([\\s\\S]*?)<\\/script\\s*>/gi\n// import(\"...\") with a literal specifier, tried at word boundaries the\n// scanner below reaches (which is what skips $__import and foo.import(...))\nconst IMPORT_CALL_RE = /import\\s*\\(\\s*([\"'])([^\"'\\n]+?)\\1\\s*\\)/y\n// static import statements (factory scripts): optional clause + literal\n// specifier. The clause can't contain parens/quotes, so dynamic import()\n// and import.meta never match\nconst STATIC_IMPORT_RE = /import\\s*(?:[\\w$\\s,{}*]+?\\s*from\\s*)?([\"'])([^\"'\\n]+)\\1/y\n// the opening of $importAll([...]), the plural of import(): its string\n// entries are import()'s specifiers, one by one (importAllSpecifiers)\nconst IMPORT_ALL_RE = /\\$importAll\\s*\\(\\s*\\[/y\n// what may sit between the entries of that array (whitespace, comments), and\n// an entry the bundle can answer: a string literal\nconst ARRAY_GAP_RE = /(?:\\s|\\/\\/[^\\n]*|\\/\\*[\\s\\S]*?\\*\\/)*/y\nconst ARRAY_ENTRY_RE = /([\"'])([^\"'\\n]+?)\\1/y\n\nconst skipString = (src: string, start: number): number => {\n const quote = src[start]\n let i = start + 1\n while (i < src.length) {\n if (src[i] === \"\\\\\") { i += 2; continue }\n if (src[i] === quote) return i + 1\n i++\n }\n return src.length\n}\n\n// the literal import specifiers in one script body. A scanner rather than a\n// bare matchAll, because a specifier mentioned in a comment or a string is\n// not an import: hoisting a commented-out `import(\"./old.html\")` would pull\n// dead files into the bundle - or break the build once the file is gone\n// the literal entries of a $importAll([...]) whose \"[\" ends at `at`, and\n// where the scan goes on from. A literal is hoisted until the first entry that\n// isn't one: from there the array is the runtime's, as a computed import() is\nconst importAllSpecifiers = (script: string, at: number): { specs: string[]; end: number } => {\n const specs: string[] = []\n const gap = (i: number) => { ARRAY_GAP_RE.lastIndex = i; ARRAY_GAP_RE.exec(script); return ARRAY_GAP_RE.lastIndex }\n let i = gap(at)\n for (;;) {\n ARRAY_ENTRY_RE.lastIndex = i\n const entry = ARRAY_ENTRY_RE.exec(script)\n if (!entry) return { specs, end: i }\n const next = gap(ARRAY_ENTRY_RE.lastIndex)\n // a literal is an entry only when it's all of one: `\"./a\" + x` isn't\n if (script[next] !== \",\" && script[next] !== \"]\") return { specs, end: i }\n specs.push(entry[2])\n if (script[next] === \"]\") return { specs, end: next + 1 }\n i = gap(next + 1)\n }\n}\n\nconst importSpecifiers = (script: string): string[] => {\n const specs: string[] = []\n let i = 0\n while (i < script.length) {\n const ch = script[i]\n if (ch === \"'\" || ch === '\"' || ch === \"`\") { i = skipString(script, i); continue }\n if (ch === \"/\" && script[i + 1] === \"/\") {\n const end = script.indexOf(\"\\n\", i)\n i = end === -1 ? script.length : end + 1\n continue\n }\n if (ch === \"/\" && script[i + 1] === \"*\") {\n const end = script.indexOf(\"*/\", i + 2)\n i = end === -1 ? script.length : end + 2\n continue\n }\n if (ch === \"i\" && (i === 0 || !/[\\w$.]/.test(script[i - 1]))) {\n IMPORT_CALL_RE.lastIndex = i\n const call = IMPORT_CALL_RE.exec(script)\n if (call) { specs.push(call[2]); i = IMPORT_CALL_RE.lastIndex; continue }\n STATIC_IMPORT_RE.lastIndex = i\n const staticImport = STATIC_IMPORT_RE.exec(script)\n if (staticImport) { specs.push(staticImport[2]); i = STATIC_IMPORT_RE.lastIndex; continue }\n }\n // $importAll, not C79.importAll: the static one means the page, so it\n // stays the runtime's (the \".\" before it is what the guard skips)\n if (ch === \"$\" && (i === 0 || !/[\\w$.]/.test(script[i - 1]))) {\n IMPORT_ALL_RE.lastIndex = i\n if (IMPORT_ALL_RE.exec(script)) {\n const { specs: entries, end } = importAllSpecifiers(script, IMPORT_ALL_RE.lastIndex)\n specs.push(...entries)\n i = end\n continue\n }\n }\n i++\n }\n return specs\n}\n\nconst isHtmlUrl = (spec: string) => /\\.html?([?#]|$)/.test(spec)\nconst isExternalUrl = (spec: string) => /^[a-z][a-z0-9+.-]*:/i.test(spec) || spec.startsWith(\"/\")\n\n// literal import specifiers in the component's script blocks - dynamic\n// `import(\"...\")` calls, the entries of `$importAll([...])` and static\n// factory-script imports - that should\n// resolve from the bundle instead of at runtime. Absolute paths and full\n// URLs are left alone (they point at served files, e.g. public/), and so\n// are .html specifiers the plugin wouldn't claim as components\nconst hoistableImports = (source: string, include: RegExp): string[] => {\n const specifiers = new Set<string>()\n for (const [, , script] of source.matchAll(SCRIPT_BLOCK_RE)) {\n for (const spec of importSpecifiers(script)) {\n if (isExternalUrl(spec)) continue\n if (isHtmlUrl(spec) && !include.test(spec)) continue // html left to runtime fetch\n specifiers.add(spec) // a claimed component, a source file or an npm package\n }\n }\n return [...specifiers]\n}\n\n// any start or end tag, quote-aware so a \">\" inside an attribute value doesn't\n// end it early\nconst TAG_RE = /<(\\/?)([A-Za-z][\\w-]*)((?:\"[^\"]*\"|'[^']*'|[^>\"'])*)>/g\nconst NAME_ATTR_RE = /\\bname\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)')/i\nconst COMPONENT_NAME_RE = /^[A-Z][A-Za-z0-9]*$/\nconst VOID_ELEMENTS = new Set([\n \"area\", \"base\", \"br\", \"col\", \"embed\", \"hr\", \"img\", \"input\",\n \"link\", \"meta\", \"param\", \"source\", \"track\", \"wbr\",\n])\n\n// the components a file declares: its *top-level* <template name=\"…\"> blocks,\n// which the emitted module re-exports by name. Depth is tracked because only\n// the top level declares - a <template> nested in the markup is a plain inert\n// element the runtime leaves alone, and exporting it would name something that\n// never exists. Script and style bodies are cut out first, so a \"<\" in JS or a\n// selector can't be read as a tag\nconst declaredComponents = (source: string): string[] => {\n const markup = source.replace(SCRIPT_BLOCK_RE, \"\").replace(STYLE_BLOCK_RE, \"\")\n const names: string[] = []\n let depth = 0\n\n for (const [, closing, tag, attrs] of markup.matchAll(TAG_RE)) {\n if (closing) {\n depth = Math.max(0, depth - 1)\n continue\n }\n const selfClosing = /\\/\\s*$/.test(attrs) || VOID_ELEMENTS.has(tag.toLowerCase())\n if (depth === 0 && !selfClosing && tag.toLowerCase() === \"template\") {\n const declared = attrs.match(NAME_ATTR_RE)\n const name = declared?.[1] ?? declared?.[2]\n // the runtime warns about the ones this skips (nameless, not PascalCase)\n if (name && COMPONENT_NAME_RE.test(name)) names.push(name)\n }\n if (!selfClosing) depth++\n }\n return names\n}\n\n// a <style> block with its attribute string, so `lang` can be read and the\n// content replaced. Attribute values are matched as quoted chunks so a \">\"\n// inside one doesn't end the tag early\nconst STYLE_BLOCK_RE = /<style((?:\"[^\"]*\"|'[^']*'|[^>\"'])*)>([\\s\\S]*?)<\\/style\\s*>/gi\nconst LANG_ATTR_RE = /\\blang\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]+))/i\nconst TYPE_ATTR_RE = /\\btype\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]+))/i\n\n// one attribute's value out of a tag's attribute string, whichever way it was\n// quoted - null when the attribute isn't there at all\nconst attrValue = (attrs: string, re: RegExp): string | null => {\n const found = attrs.match(re)\n return found ? found[1] ?? found[2] ?? found[3] : null\n}\n\n// compiles <style lang=\"scss|less|styl|sass\"> blocks to plain CSS with Vite's\n// own preprocessing (the same call @vitejs/plugin-vue makes), so the runtime\n// only ever sees CSS. The preprocessor picks its parser from the extension,\n// and resolving relative @use/@import against a filename in the component's\n// own directory is what makes `@use \"./vars\"` work. Files the preprocessor\n// pulls in are registered as watch deps, so editing a partial re-runs HMR for\n// every component that uses it. `lang` is dropped from the emitted tag: what\n// the runtime parses is a plain <style> (with `scoped` and the rest intact)\nconst compileStyleBlocks = async (\n source: string,\n file: string,\n config: ResolvedConfig,\n addWatchFile: (id: string) => void\n): Promise<string> => {\n const blocks = [...source.matchAll(STYLE_BLOCK_RE)]\n const compiled = await Promise.all(\n blocks.map(async ([, attrs, content]) => {\n const extension = attrValue(attrs, LANG_ATTR_RE)\n if (extension === null) return null\n const result = await preprocessCSS(content, `${file}.${extension}`, config)\n result.deps?.forEach(addWatchFile)\n return { attrs: attrs.replace(LANG_ATTR_RE, \"\").trimEnd(), css: result.code }\n })\n )\n\n let out = \"\"\n let last = 0\n blocks.forEach((block, i) => {\n const done = compiled[i]\n if (!done) return\n out += source.slice(last, block.index) + `<style${done.attrs}>${done.css}</style>`\n last = block.index + block[0].length\n })\n return out + source.slice(last)\n}\n\n// languages a <script lang> is compiled from. Anything else is left as written\n// for the runtime to warn about, rather than guessed at\nconst TS_LANGS = new Set([\"ts\", \"typescript\"])\n// the other spelling of the same mark. A component is a plain .html file, not\n// an SFC, so nothing in an editor knows what `lang` means there, and each mark\n// gets half of one: VS Code's HTML language service checks a `type` of\n// text/typescript as TypeScript (and `lang=\"ts\"` as JavaScript), while its\n// grammar colors that `type` not at all (and `lang=\"ts\"` as JavaScript). See\n// docs/vite-plugin.md#which-mark-in-vs-code. The `x-` forms are the historical\n// spelling of the same two media types\nconst TS_TYPE_RE = /^(?:text|application)\\/(?:x-)?typescript$/\n\n// what marks a script block as TypeScript, given back as the attribute to drop\n// from the emitted tag - the block is compiled to JS, so the mark goes with the\n// types whichever one carried it. A `lang` answers on its own: `lang=\"coffee\"`\n// is a language this plugin doesn't compile, and reading `type` past it would\n// compile a block the author said was something else\nconst typescriptAttr = (attrs: string): RegExp | null => {\n const lang = attrValue(attrs, LANG_ATTR_RE)\n if (lang !== null) return TS_LANGS.has(lang.trim().toLowerCase()) ? LANG_ATTR_RE : null\n const type = attrValue(attrs, TYPE_ATTR_RE)\n return type !== null && TS_TYPE_RE.test(type.trim().toLowerCase()) ? TYPE_ATTR_RE : null\n}\n\ntype ViteTransform = (code: string, id: string, options?: unknown) => Promise<{ code: string }>\n\n// what strips the types: vite's own transform, so the plugin carries no\n// compiler of its own. *Which* transform is a version question, and neither\n// answer covers the peer range (vite >= 5) alone - transformWithOxc is the one\n// vite is moving to but only exists from vite 7, while transformWithEsbuild is\n// deprecated under vite 8 and throws there unless esbuild is installed\n// separately. So it is looked up at call time: oxc where it exists, esbuild on\n// the older versions that ship it.\n//\n// Both drop unused value imports by default, because a TS transform can't tell\n// a type-only import from an unused one. That would be silent damage here: a\n// factory script's `import Row from \"./row.html\"` would vanish, taking with it\n// the specifier hoistableImports needs to pull the child into the bundle. The\n// flags below are what keep it - only `import type` is erased\nconst stripTypes = async (ts: string, file: string): Promise<string> => {\n const vite = (await import(\"vite\")) as unknown as { transformWithOxc?: ViteTransform }\n const { code } = vite.transformWithOxc\n ? await vite.transformWithOxc(ts, file, { lang: \"ts\", typescript: { onlyRemoveTypeImports: true } })\n : await transformWithEsbuild(ts, file, {\n loader: \"ts\",\n tsconfigRaw: { compilerOptions: { verbatimModuleSyntax: true } },\n })\n // a script whose only imports were `import type` comes back marked as a\n // module. `export {}` exports nothing, and it is a SyntaxError inside the\n // Function body the runtime compiles a script into\n return code.replace(/^[ \\t]*export\\s*\\{\\s*\\}\\s*;?[ \\t]*$/m, \"\")\n}\n\n// the `:setup` attribute, when it carries a value (a bare `:setup` is the\n// closed signature and can't be typed)\nconst SETUP_ATTR_RE = /(:setup\\s*=\\s*)(?:\"([^\"]*)\"|'([^']*)')/i\n// the arrow body the signature is wrapped in, so the parameter list can be\n// found again in the output without matching brackets\nconst SIGNATURE_MARKER = \"__jq79_signature__\"\n\n// a component's props signature lives in the `:setup` *attribute*, not in the\n// script body, so the body's transform never sees it - and the TypeScript mark\n// has to mean the same thing on both halves of the block, or a typed signature\n// either survives into a component the plugin just promised was JS or, for\n// `_: Props`, stops reading as a signature at all.\n//\n// It goes through the same transform as everything else, wrapped as a\n// parameter list, rather than being cut with a scanner of its own: the\n// annotation can sit on the pattern (`{ a }: Props`), on the permissive `_`, or\n// inside a default (`{ step = 1 as number }`, which the runtime would evaluate\n// and silently drop), and telling those apart is a parser's job. Both transforms\n// hand back `(<params>) => <marker>` on one line, parens intact\nconst stripSignatureTypes = async (value: string, file: string): Promise<string> => {\n const compiled = await stripTypes(`(${value}) => ${SIGNATURE_MARKER}`, file)\n const marker = compiled.indexOf(SIGNATURE_MARKER)\n if (marker === -1) return value // not the shape expected: leave it as written\n const head = compiled.slice(0, marker).trimEnd()\n const params = (head.endsWith(\"=>\") ? head.slice(0, -2) : head).trim()\n return params.startsWith(\"(\") && params.endsWith(\")\") ? params.slice(1, -1).trim() : params\n}\n\n// the signature back into a double-quoted attribute. Only `\"` needs escaping:\n// the transforms normalize string literals to double quotes, so a default the\n// author wrote as `'x'` comes back as `\"x\"` and would end the attribute early.\n// `&` is deliberately left alone - `&&` in a default is not an entity and\n// survives the parse, while escaping it would double-encode a source that\n// already wrote `&quot;`\nconst quoteAttrValue = (value: string) => value.replace(/\"/g, \"&quot;\")\n\n// compiles TypeScript script blocks to plain JS, so the runtime only ever sees\n// JS - the same deal <style lang=\"scss\"> gets, for a sharper reason. The setup\n// scanner is not a parser: `let count: number = 0` reaching it is not a syntax\n// error but a labeled statement that assigns to `number`, so it runs and leaves\n// `count` undeclared. Whichever attribute marked the block (`lang=\"ts\"` or\n// `type=\"text/typescript\"`) is dropped from the emitted tag and every other one\n// (`:setup`, `:mounted`) is left as written.\n//\n// This runs before hoistableImports reads the source, so an `import type`\n// specifier is already gone by the time the plugin decides what to bundle\nconst compileScriptBlocks = async (source: string, file: string): Promise<string> => {\n const blocks = [...source.matchAll(SCRIPT_BLOCK_RE)]\n const compiled = await Promise.all(\n blocks.map(async ([, attrs, content]) => {\n const marker = typescriptAttr(attrs)\n if (!marker) return null\n\n let rest = attrs.replace(marker, \"\").trimEnd()\n const setup = rest.match(SETUP_ATTR_RE)\n if (setup) {\n const signature = await stripSignatureTypes(setup[2] ?? setup[3], `${file}.signature.ts`)\n // a function replacement, not a string: `$&` and friends are live in a\n // replacement string and a default value is arbitrary source\n rest = rest.replace(SETUP_ATTR_RE, () => `${setup[1]}\"${quoteAttrValue(signature)}\"`)\n }\n\n return { attrs: rest, js: await stripTypes(content, `${file}.ts`) }\n })\n )\n\n let out = \"\"\n let last = 0\n blocks.forEach((block, i) => {\n const done = compiled[i]\n if (!done) return\n out += source.slice(last, block.index) + `<script${done.attrs}>${done.js}</script>`\n last = block.index + block[0].length\n })\n return out + source.slice(last)\n}\n\n// the emitted module. Literal import(\"...\") specifiers found in the\n// component's scripts become real module imports, handed to Component79 as a\n// resolution map: at runtime $__import checks the map before falling back to\n// fetch, so bundled components ship with their imports and nothing changes\n// for unbundled ones. Claimed components import as their default (a\n// Component79, matching what runtime fetch resolves to); everything else as\n// a namespace (matching native import()).\n//\n// A file's <template name=\"…\"> components are re-exported by name, so the\n// module shape is the one the file already has: default plus named. They read\n// off the instance, which is where the runtime hangs them - so in dev they are\n// bound to the *first* evaluation's definitions and a module that imports one\n// by name keeps the pre-edit child until the page reloads. The file's own\n// component patches in place, and its rendered children come from the reparse,\n// so this only shows in a component imported by name from another file.\n//\n// In dev, `hot.data` carries the exported instance across updates: importers\n// hold a reference to the *first* module evaluation's instance, so later\n// evaluations patch that same instance in place instead of exporting a new one\n// nobody sees. The patching itself is the runtime's `hotReplace` - the same\n// swap the jq79/dev server drives, from the one place that can reach a\n// component's markers. An instance only used as a definition has nothing to\n// re-render (nested clones can't be reached from this module), so it falls\n// back to a full reload.\n// `precompiled` is the precompiled script's URL, as a JS expression - present\n// only in safeEval mode\nconst componentModule = (source: string, include: RegExp, filename: string, precompiled?: string): string => {\n const hoisted = hoistableImports(source, include)\n const imports = hoisted\n .map((spec, i) =>\n include.test(spec)\n ? `import __jq79_${i} from ${JSON.stringify(spec)}`\n : `import * as __jq79_${i} from ${JSON.stringify(spec)}`\n )\n .join(\"\\n\")\n const modulesMap = `{ ${hoisted.map((spec, i) => `${JSON.stringify(spec)}: __jq79_${i}`).join(\", \")} }`\n\n // without safeEval, the module is exactly what it always was\n const safeEvalImport = precompiled ? `\\nimport { safeEval } from \"${SAFE_EVAL_ID}\"` : \"\"\n const safeEvalCall = precompiled ? `\\nawait safeEval(Component79, ${precompiled})` : \"\"\n\n return `\nimport { Component79 } from \"jq79\"${safeEvalImport}\n${imports}${safeEvalCall}\n\nconst src = ${JSON.stringify(source)}\nconst modules = ${modulesMap}\nconst filename = ${JSON.stringify(filename)}\n\nlet component\n\nif (import.meta.hot && import.meta.hot.data.component) {\n const prior = import.meta.hot.data.component\n prior.modules = modules\n prior.filename = filename\n // re-renders it where it stands, keeping its data. false means it was never\n // rendered - a definition used only as a nested component - and a reload is\n // the only way to reach the clones made from it\n if (!prior.hotReplace(src) && !prior.data) import.meta.hot.invalidate()\n component = prior\n} else {\n component = new Component79(src, { modules, filename })\n}\n\nif (import.meta.hot) {\n import.meta.hot.data.component = component\n import.meta.hot.accept()\n}\n\nexport default component\n${declaredComponents(source).map(name => `export const ${name} = component.${name}`).join(\"\\n\")}\n`\n}\n\nexport function jq79(options: Jq79PluginOptions = {}): Plugin {\n const include = options.include ?? /\\.html$/\n const { exclude } = options\n const safeEval = safeEvalOptions(options.safeEval)\n // dev only: each component's precompiled script, by the id its module asks\n // for - so the server hands out what the plugin compiled and nothing else\n const devScripts = new Map<string, string>()\n const devIds = new Map<string, number>()\n // build only: each component's functions, by file, for the one script\n // buildEnd emits - its reference, and the file name renderChunk resolves it to\n const buildFunctions = new Map<string, CheckedFunction[]>()\n let precompiledRef: string | undefined\n let precompiledFile: string | undefined\n\n let config: ResolvedConfig | null = null\n\n return {\n name: \"jq79\",\n enforce: \"pre\",\n\n configResolved(resolved) {\n config = resolved\n },\n\n configureServer(server) {\n if (!safeEval) return\n server.middlewares.use((req, res, next) => {\n const url = new URL(req.url ?? \"/\", \"http://localhost\")\n if (!url.pathname.endsWith(PRECOMPILED_PATH)) return next()\n const script = devScripts.get(url.searchParams.get(\"id\") ?? \"\")\n if (script === undefined) return next()\n res.setHeader(\"Content-Type\", \"text/javascript\")\n res.setHeader(\"Cache-Control\", \"no-cache\")\n res.end(script)\n })\n },\n\n async resolveId(source, importer) {\n if (source === SAFE_EVAL_ID) return RESOLVED_SAFE_EVAL_ID\n if (!importer) return null // entry points are never components\n if (source.includes(\"?\")) return null // ?raw, ?url, ... keep their meaning\n if (!include.test(source)) return null\n\n const resolved = await this.resolve(source, importer, { skipSelf: true })\n if (!resolved || resolved.external) return null\n if (exclude?.test(resolved.id)) return null\n return resolved.id + COMPONENT_QUERY\n },\n\n async load(id) {\n // a Vite page's functions come from the build, so it never registers the worker\n if (id === RESOLVED_SAFE_EVAL_ID) return safeEvalModule({ ...safeEval, worker: false })\n if (!id.endsWith(COMPONENT_QUERY)) return null\n const file = id.slice(0, -COMPONENT_QUERY.length)\n\n let source = await readFile(file, \"utf8\")\n source = await compileScriptBlocks(source, file)\n if (config) source = await compileStyleBlocks(source, file, config, dep => this.addWatchFile(dep))\n\n // the runtime names the component's setup scripts after this, so devtools\n // shows a path the user recognizes instead of an anonymous VM script\n const filename = config ? relative(config.root, file) : file\n\n if (!safeEval) return { code: componentModule(source, include, filename), map: null }\n\n // the component's functions, compiled after its TypeScript and styles are:\n // the runtime compiles what reaches it, and this is what reaches it\n const functions = componentFunctions(source, message => this.warn(`jq79: ${filename}: ${message}`))\n let url: string\n if (config?.command === \"serve\") {\n let devId = devIds.get(file)\n if (devId === undefined) devIds.set(file, devId = devIds.size)\n devScripts.set(String(devId), registeringScript(functions))\n // versioned, so an edit loads the new functions rather than a cached copy\n url = JSON.stringify(`${config.base}${PRECOMPILED_PATH.slice(1)}?id=${devId}&v=${Date.now()}`)\n } else {\n buildFunctions.set(file, functions)\n url = JSON.stringify(PRECOMPILED_URL_PLACEHOLDER)\n }\n return { code: componentModule(source, include, filename, url), map: null }\n },\n\n buildStart() {\n precompiledRef = undefined\n precompiledFile = undefined\n },\n\n // the build's one precompiled script, from every component still in the\n // module graph. What earlier builds recorded is kept and pruned rather than\n // cleared in buildStart, so a watch rebuild that doesn't load a module again\n // keeps its functions. Sorted by file, so the same sources make the same\n // bytes, and the same hash\n buildEnd(error) {\n if (!safeEval || error || config?.command === \"serve\") return\n const inGraph = new Set<string>()\n for (const id of this.getModuleIds()) if (id.endsWith(COMPONENT_QUERY)) inGraph.add(id.slice(0, -COMPONENT_QUERY.length))\n for (const file of buildFunctions.keys()) if (!inGraph.has(file)) buildFunctions.delete(file)\n if (buildFunctions.size === 0) return\n const functions = [...buildFunctions.keys()].sort().flatMap(file => buildFunctions.get(file)!)\n precompiledRef = this.emitFile({ type: \"asset\", name: PRECOMPILED_ASSET, source: registeringScript(functions) })\n },\n\n // the placeholder, as what import.meta.ROLLUP_FILE_URL_<ref> renders to:\n // the asset's path relative to the chunk, against the chunk's own URL - so\n // `base` doesn't matter. Before minification, and part of the chunk's hash.\n // The source map is left as it is: the placeholder sits on a line of its\n // own with only `)` after it\n renderChunk(code, chunk) {\n if (precompiledRef === undefined || !code.includes(PRECOMPILED_URL_PLACEHOLDER)) return null\n precompiledFile = this.getFileName(precompiledRef)\n const path = JSON.stringify(posix.relative(posix.dirname(chunk.fileName), precompiledFile))\n return { code: code.replace(PRECOMPILED_URL_PLACEHOLDER_RE, () => `new URL(${path}, import.meta.url).href`), map: null }\n },\n\n // a page that waits for the script asks for it as it parses, rather than\n // once its entry has loaded and run. Same URL as the module's\n // (precompiledHref), and no crossorigin, as the <script> has none: a\n // preload is only reused by a request that matches it. Vite's html.cspNonce\n // stamps it with the nonce, after this hook - without it,\n // `script-src 'nonce-…'` refuses a preload. Build only: dev has one script\n // per component, versioned per edit. Vite writes the page's <script> tags\n // before it runs this hook, in every version the plugin supports\n transformIndexHtml(html, ctx) {\n if (!safeEval || !precompiledFile || !ctx.bundle || !ctx.chunk) return\n const bundle = ctx.bundle as Record<string, BundleFile>\n if (!reachesComponent(ctx.chunk as BundleFile, bundle)) return\n const href = precompiledHref(html, bundle, precompiledFile)\n if (href === null) return\n return [{ tag: \"link\", attrs: { rel: \"preload\", as: \"script\", href }, injectTo: \"head\" }]\n },\n }\n}\n\nexport default jq79\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,OAAO,gBAAgB;AAChC,SAAS,eAAe,4BAA4B;AAKpD,SAAS,YAAY,yBAAyB;AAuC9C,IAAM,kBAAkB;AA4BxB,IAAM,eAAe;AACrB,IAAM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,EAAE,CAAC;AAAA,IACjH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,YAAY,MAAM,OAAO;AACvB,UAAI,mBAAmB,UAAa,CAAC,KAAK,SAAS,2BAA2B,EAAG,QAAO;AACxF,wBAAkB,KAAK,YAAY,cAAc;AACjD,YAAM,OAAO,KAAK,UAAU,MAAM,SAAS,MAAM,QAAQ,MAAM,QAAQ,GAAG,eAAe,CAAC;AAC1F,aAAO,EAAE,MAAM,KAAK,QAAQ,gCAAgC,MAAM,WAAW,IAAI,yBAAyB,GAAG,KAAK,KAAK;AAAA,IACzH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAUA,mBAAmB,MAAM,KAAK;AAC5B,UAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC,IAAI,UAAU,CAAC,IAAI,MAAO;AAChE,YAAM,SAAS,IAAI;AACnB,UAAI,CAAC,iBAAiB,IAAI,OAAqB,MAAM,EAAG;AACxD,YAAM,OAAO,gBAAgB,MAAM,QAAQ,eAAe;AAC1D,UAAI,SAAS,KAAM;AACnB,aAAO,CAAC,EAAE,KAAK,QAAQ,OAAO,EAAE,KAAK,WAAW,IAAI,UAAU,KAAK,GAAG,UAAU,OAAO,CAAC;AAAA,IAC1F;AAAA,EACF;AACF;AAEA,IAAO,eAAQ;","names":["i"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jq79",
3
- "version": "0.7.9",
3
+ "version": "0.7.11",
4
4
  "description": "Mini reactive component library: single-file .html components, Svelte-style setup scripts, fine-grained proxy reactivity. No compiler, no bundler, no dependencies — works from any static host.",
5
5
  "keywords": [
6
6
  "reactive",
package/src/jq79.ts CHANGED
@@ -3,7 +3,7 @@ import { $, $$, $create, sanitizeHTML, allowedHosts } from "./dom"
3
3
  import type { AllowUrl, QueryAll, QueryOne } from "./dom"
4
4
  import { $reactive, $toRaw, $computed, untracked, createEffectScope, ALSO_WAKEN_BY, OWNER } from "./reactive"
5
5
  import type { ReactiveDeepData, EffectScope } from "./reactive"
6
- import { transformSetupScript, transformFactoryScript, parsePropsPattern, parseFactoryProps, type PropDecl } from "./transform"
6
+ import { transformSetupScript, transformFactoryScript, parsePropsPattern, parseFactoryProps, preloadSpecifiers, type PropDecl } from "./transform"
7
7
  import {
8
8
  COMPONENT_NAME_RE, COMPONENT_TAG_ATTR, CONTROL_ATTRS, EACH_PATTERN, EXPR_PARAMS, PRECOMPILED_PARAM, PRECOMPILED_QUEUE,
9
9
  componentTagName, functionText,
@@ -3332,8 +3332,10 @@ const componentPartsFrom = (elements: Element[], hashSource: string): ComponentP
3332
3332
  // loads .html URLs as components, delegating anything else to native import().
3333
3333
  // Goes to fetchComponent rather than Component79.fetch because an import wants
3334
3334
  // the component, not the chainable handle the public entry point returns
3335
+ const HTML_URL_RE = /\.html?([?#]|$)/
3336
+
3335
3337
  const importResource = (url: string): Promise<any> =>
3336
- /\.html?([?#]|$)/.test(url) ? fetchComponent(url) : import(url)
3338
+ HTML_URL_RE.test(url) ? fetchComponent(url) : import(url)
3337
3339
 
3338
3340
  // a relative specifier means "next to the file that wrote it", so it is
3339
3341
  // resolved against the component's own URL before importResource sees it -
@@ -3995,6 +3997,74 @@ const fetchComponent = async (rawUrl: string): Promise<Component79> => {
3995
3997
  return new Component79(text, { filename: url })
3996
3998
  }
3997
3999
 
4000
+ // ---------------------------------------------------------------------------
4001
+ // preloading (RECORD/2026-11-05.a-preload-scanner.md)
4002
+ //
4003
+ // Before a definition's scripts first run, every download their top level is
4004
+ // sure to ask for starts at once - so `await import("./a.html")` on one line
4005
+ // and `await import("./b.html")` on the next are one round trip, not two, and
4006
+ // still run in that order. Each specifier resolves as its call would, and
4007
+ // lands where that call will look: a component in the cache, a module in the
4008
+ // browser's module map (modulepreload fetches and parses, never evaluates)
4009
+ // ---------------------------------------------------------------------------
4010
+
4011
+ // the script blocks already preloaded: one scan per definition, however many
4012
+ // instances render it
4013
+ const preloadedScripts = new WeakSet<TagBlock>()
4014
+ const preloadedModules = new Set<string>()
4015
+
4016
+ const preloadModule = (url: string) => {
4017
+ if (preloadedModules.has(url)) return
4018
+ preloadedModules.add(url)
4019
+ const link = document.createElement("link")
4020
+ link.rel = "modulepreload"
4021
+ const nonce = pageNonce()
4022
+ if (nonce) link.setAttribute("nonce", nonce)
4023
+ link.href = url
4024
+ document.head.append(link)
4025
+ }
4026
+
4027
+ // a script block's body, quote-aware in its attributes, for a file that is
4028
+ // text and not yet a component: what a preloaded child is when it arrives
4029
+ const SCRIPT_BODY_RE = /<script\b(?:"[^"]*"|'[^']*'|[^>"'])*>([\s\S]*?)<\/script\s*>/gi
4030
+ // the files whose scripts were read for preloads as they arrived: each once,
4031
+ // so two components importing each other end there
4032
+ const preloadedFiles = new Set<string>()
4033
+
4034
+ // one script's preloads, resolved as its calls will be. A component it
4035
+ // preloads is read in turn when it arrives - its imports start before it
4036
+ // renders, and so on down - against its own URL, and with no modules map:
4037
+ // a fetched component has none
4038
+ const preloadSource = (source: string, filename: string | undefined, modules: Record<string, any> | undefined) => {
4039
+ for (const { spec, kind } of preloadSpecifiers(source)) {
4040
+ // the bundle already holds it
4041
+ if (kind === "component" && modules && spec in modules) continue
4042
+ // fetch() goes to the cache as written; the imports resolve first, as
4043
+ // importResource is handed them
4044
+ const url = resolveBare(kind === "fetch" ? spec : resolveSpecifier(spec, kind === "component" ? filename : undefined))
4045
+ if (kind === "fetch" || HTML_URL_RE.test(url)) {
4046
+ // with the cache off there is nowhere to keep it, and the real request
4047
+ // would download it again. A failure is the real request's to report
4048
+ if (componentCache) componentSource(url).then(text => preloadFile(text, url), () => {})
4049
+ } else if (RESOLVABLE_SPECIFIER_RE.test(url)) preloadModule(url)
4050
+ }
4051
+ }
4052
+
4053
+ const preloadFile = (text: string, url: string) => {
4054
+ const key = cacheKey(url)
4055
+ if (preloadedFiles.has(key)) return
4056
+ preloadedFiles.add(key)
4057
+ for (const [, body] of text.matchAll(SCRIPT_BODY_RE)) preloadSource(body, url, undefined)
4058
+ }
4059
+
4060
+ const preloadScripts = (scripts: TagBlock[], filename: string | undefined, modules: Record<string, any> | undefined) => {
4061
+ for (const script of scripts) {
4062
+ if (preloadedScripts.has(script)) continue
4063
+ preloadedScripts.add(script)
4064
+ preloadSource(script.content, filename, modules)
4065
+ }
4066
+ }
4067
+
3998
4068
  // ---------------------------------------------------------------------------
3999
4069
  // safe eval's worker
4000
4070
  //
@@ -4339,13 +4409,14 @@ export class Component79 {
4339
4409
  //
4340
4410
  // Returns the setting as it stands after the call
4341
4411
  static cache(enabled?: boolean): boolean {
4342
- if (enabled === false) componentCache = null
4412
+ if (enabled === false) { componentCache = null; preloadedFiles.clear() }
4343
4413
  else if (enabled === true) componentCache ??= new Map()
4344
4414
  return !!componentCache
4345
4415
  }
4346
4416
 
4347
4417
  static clearCache(): void {
4348
4418
  componentCache?.clear()
4419
+ preloadedFiles.clear()
4349
4420
  }
4350
4421
 
4351
4422
  static fetch(url: string): PendingComponent79 {
@@ -4558,6 +4629,13 @@ export class Component79 {
4558
4629
  modules && url in modules
4559
4630
  ? Promise.resolve(modules[url])
4560
4631
  : importResource(resolveSpecifier(url, this.filename))
4632
+ // the plural, as Promise.all of the script's own import()s: relative to
4633
+ // this component and through its modules map, which Component79.importAll
4634
+ // - a page's, static - can't know
4635
+ const $importAll = (specifiers: readonly string[]): Promise<any[]> => {
4636
+ if (!Array.isArray(specifiers)) throw new TypeError("$importAll takes an array; use import() for one")
4637
+ return Promise.all(specifiers.map($import))
4638
+ }
4561
4639
 
4562
4640
  // the writeback half of :model, from the child's side: one argument is the
4563
4641
  // value for the default model (the bare :model), two are a name and a
@@ -4607,6 +4685,7 @@ export class Component79 {
4607
4685
  const gates: Promise<void>[] = []
4608
4686
  let allSync = true
4609
4687
 
4688
+ preloadScripts(this.scripts, this.filename, this.modules)
4610
4689
  this.scripts.forEach((script, index) => {
4611
4690
  let resolveGate!: () => void
4612
4691
  gates.push(new Promise<void>(resolve => { resolveGate = resolve }))
@@ -4627,7 +4706,7 @@ export class Component79 {
4627
4706
  // resolve to nothing at all. In setup mode this composes with `with` -
4628
4707
  // scriptScope's `has` declines any name that is a helper, so the
4629
4708
  // parameter is what the name resolves to
4630
- const instanceHelpers = { $mounted, $destroyed, $attached, $detached, $computed: $instanceComputed, $self, $$self, ...injected, ...siblingScope }
4709
+ const instanceHelpers = { $mounted, $destroyed, $attached, $detached, $computed: $instanceComputed, $self, $$self, ...injected, $importAll, ...siblingScope }
4631
4710
  const at: ScriptLocation = { filename: this.filename, index }
4632
4711
  const deferred = ":mounted" in script.attrs
4633
4712
  const factoryCode = transformFactoryScript(script.content)
package/src/precompile.ts CHANGED
@@ -176,7 +176,7 @@ const precompileComponent = (
176
176
  // the helper names a script is compiled with: renderWith's
177
177
  // { ...SETUP_HELPERS, ...instanceHelpers }, where instanceHelpers is
178
178
  // { $mounted, $destroyed, $attached, $detached, $computed, $self, $$self,
179
- // ...injected, ...siblingScope } - key order included, because the
179
+ // ...injected, $importAll, ...siblingScope } - key order included, because the
180
180
  // parameters are positional (built as objects, so a sibling named like a
181
181
  // helper keeps the helper's place, as it does there)
182
182
  //
package/src/source.ts CHANGED
@@ -366,11 +366,11 @@ export const declaredPropNames = (scripts: TagBlock[], signature: (script: TagBl
366
366
  // the functions they are) and then the per-instance ones it builds -
367
367
  // $mounted, $destroyed, $attached, $detached, $computed, $self and $$self,
368
368
  // then the injected
369
- // $emit, $updateModel and $slots. They are positional parameters, so the order is part of what
369
+ // $emit, $updateModel and $slots, then $importAll. They are positional parameters, so the order is part of what
370
370
  // precompile has to reproduce; change one side and precompiled scripts stop
371
371
  // matching, which tests/precompile.test.ts and `npm run check:precompile` catch
372
372
  export const SETUP_HELPER_NAMES = ["$", "$$", "$create", "$reactive", "$toRaw", "Component79", "C79"]
373
- export const INSTANCE_HELPER_NAMES = ["$mounted", "$destroyed", "$attached", "$detached", "$computed", "$self", "$$self", "$emit", "$updateModel", "$slots"]
373
+ export const INSTANCE_HELPER_NAMES = ["$mounted", "$destroyed", "$attached", "$detached", "$computed", "$self", "$$self", "$emit", "$updateModel", "$slots", "$importAll"]
374
374
 
375
375
  // the global a precompiled script leaves its functions on, for the runtime to
376
376
  // drain: (self.__jq79precompiled = self.__jq79precompiled || []).push([params,
package/src/transform.ts CHANGED
@@ -899,3 +899,103 @@ export const freeIdentifiers = (expr: string): string[] | null => {
899
899
  if (shortCircuits && names.size > 1) return null
900
900
  return [...names]
901
901
  }
902
+
903
+ // ---------------------------------------------------------------------------
904
+ // the preload scanner (RECORD/2026-11-05.a-preload-scanner.md): the literal
905
+ // specifiers a script asks for in top-level statements that run whatever
906
+ // happens, so the runtime can start every download before the script's first
907
+ // line and let the script take them in its own order. What might not run is
908
+ // left alone - a function's body, a block, a branch, a loop, a handler - and
909
+ // so is anything the scanner can't read whole: a missed preload costs what it
910
+ // costs today, a wrong one an extra download of a file
911
+ // ---------------------------------------------------------------------------
912
+
913
+ // how a specifier resolves - the way the call that names it does:
914
+ // - "component": import(), $importAll and a static import, against the
915
+ // component's file and through its modules map; .html is a component,
916
+ // anything else a module
917
+ // - "page": C79.importAll, the same against the page
918
+ // - "fetch": C79.fetch / fetchAll, always a component, against the page
919
+ // (no kind is spelled "import": dist/jq79.js is held to having no import
920
+ // statement in it, and the test can't tell one from a string that ends so)
921
+ export type Preload = { spec: string; kind: "component" | "page" | "fetch" }
922
+
923
+ // where a statement or an initializer starts with a call that downloads:
924
+ // an optional await, then the call up to its opening bracket(s)
925
+ const PRELOAD_CALL_RE = /(?:await\s+)?(?:import\s*\(|(\$importAll)\s*\(\s*\[|(C79|Component79)\s*\.\s*(fetch|fetchAll|importAll)\s*\(\s*(\[)?)/y
926
+ const PRELOAD_LITERAL_RE = /(["'])([^"'\n\\]+)\1/y
927
+ // a statement that guards the next one without braces - `if (x)`, a loop's
928
+ // header, `else`, `do` - so that one may not run
929
+ const GUARD_RE = /^(?:(?:if|for|while|with)\b[\s\S]*\)|[\s\S]*\b(?:else|do))$/
930
+
931
+ // the literal specifiers of the call `text` starts with: an array's entries
932
+ // up to the first that isn't a literal on its own (`"./a" + x` is not one)
933
+ const preloadCall = (text: string, own: Set<string>): Preload[] => {
934
+ PRELOAD_CALL_RE.lastIndex = 0
935
+ const call = PRELOAD_CALL_RE.exec(text)
936
+ if (!call) return []
937
+ const [, importAll, library, method, bracket] = call
938
+ if (own.has(importAll ?? library ?? "")) return [] // the script's own, not jq79's
939
+ const list = importAll !== undefined || bracket !== undefined
940
+ // fetch takes one URL, its plurals an array: anything else throws
941
+ if (method !== undefined && (method === "fetch") === list) return []
942
+ const kind: Preload["kind"] = library === undefined ? "component" : method === "importAll" ? "page" : "fetch"
943
+
944
+ const found: Preload[] = []
945
+ let i = skipToToken(text, PRELOAD_CALL_RE.lastIndex)
946
+ for (;;) {
947
+ PRELOAD_LITERAL_RE.lastIndex = i
948
+ const literal = PRELOAD_LITERAL_RE.exec(text)
949
+ if (!literal) return found
950
+ const end = skipToToken(text, PRELOAD_LITERAL_RE.lastIndex)
951
+ const next = text[end]
952
+ if (!list) return next === ")" || next === "," ? [{ spec: literal[2], kind }] : []
953
+ if (next !== "," && next !== "]") return found
954
+ found.push({ spec: literal[2], kind })
955
+ if (next === "]") return found
956
+ i = skipToToken(text, end + 1)
957
+ }
958
+ }
959
+
960
+ export const preloadSpecifiers = (src: string): Preload[] => {
961
+ const statements: string[] = []
962
+ for (let i = skipToToken(src, 0); i < src.length; i = skipToToken(src, i + 1)) {
963
+ const end = findStatementEnd(src, i)
964
+ statements.push(src.slice(i, end).trim().replace(/^export\s+(?!default\b)/, ""))
965
+ i = end
966
+ }
967
+
968
+ // a declaration's initializers, or null for a statement that isn't one
969
+ const initializers = (statement: string): { target: string; init: string }[] | null => {
970
+ DECLARATION_START_RE.lastIndex = 0
971
+ const declaration = DECLARATION_START_RE.exec(statement)
972
+ if (!declaration) return null
973
+ return splitDeclarators(statement.slice(declaration[0].length)).map(({ raw }) => {
974
+ const body = raw.trim()
975
+ const assign = defaultAssignIndex(body)
976
+ return assign === -1 ? { target: body, init: "" } : { target: body.slice(0, assign).trim(), init: body.slice(assign + 1).trim() }
977
+ })
978
+ }
979
+
980
+ // a script that declares its own C79, Component79 or $importAll calls
981
+ // that, not the library's
982
+ const own = new Set<string>()
983
+ statements.forEach(statement => initializers(statement)?.forEach(({ target }) => patternBindings(target).forEach(name => own.add(name))))
984
+
985
+ const found: Preload[] = []
986
+ let guarded = false
987
+ for (const statement of statements) {
988
+ if (!guarded) {
989
+ STATIC_IMPORT_RE.lastIndex = 0
990
+ const staticImport = STATIC_IMPORT_RE.exec(statement)
991
+ if (staticImport) {
992
+ if (!/^type\s/.test(staticImport[1] ?? "")) found.push({ spec: staticImport[3], kind: "component" })
993
+ } else {
994
+ const declared = initializers(statement)
995
+ for (const text of declared ? declared.map(({ init }) => init) : [statement]) found.push(...preloadCall(text, own))
996
+ }
997
+ }
998
+ guarded = GUARD_RE.test(statement)
999
+ }
1000
+ return found
1001
+ }