@verajs/autoloader 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -3
- package/dist/development/vera-autoloader.d.ts +17 -0
- package/dist/development/vera-autoloader.d.ts.map +1 -1
- package/dist/development/vera-autoloader.js +293 -115
- package/dist/development/vera-autoloader.js.map +1 -1
- package/dist/vera-autoloader.min.js +1 -1
- package/dist/vera-autoloader.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vera-autoloader.js","sources":["../../src/autoloader.ts","../../src/loader.ts"],"sourcesContent":["import type { AutoloaderInstance, AutoloaderOptions } from './types.js';\n\n/**\n * Inits an autoloader with the provided root directory, component directory and autoloader options.\n *\n * Discovery is **observed, not polled**. Each `autoloader`-marked component is watched once with a\n * `MutationObserver`, so an undefined element is found whenever it enters the DOM — by a render, by\n * `innerHTML`, by a third-party widget, or by having been in the HTML file all along. The previous\n * model re-scanned a marked component's whole tree on every render, which saw only what a Vera\n * render put there and cost more the larger the component got (measured in Chromium: 0.46 µs for a\n * 10-node component, 32.5 µs for a 1 000-node one, on every render, forever). An observation costs\n * ~0.6 µs per mutation batch and does not care how big the component is.\n *\n * One observer object watches every marked root — `observe()` takes many targets — and a mutation\n * only notifies observers on its own ancestor chain, so watched subtrees that are not the ones\n * changing cost nothing. Measured: 1 000 registrations left unrelated DOM work at 0.900 µs against\n * 0.933 µs with none. Watching `document` instead would have been the expensive shape, taxing every\n * mutation in the app by ~47%.\n *\n * @param rootDir The root directory of all components. Should almost always be import.meta.url unless you are using\n * absolute paths\n * @param componentsDir The relative directory from the root directory. If element has an \"data-autoload-dir\" attribute, the\n * autoloader will read from that first\n * @param options Autoloader options. `extension` sets the file extension appended to the tag name, which lets\n * TypeScript projects autoload `.ts` sources during dev (a dev server will not serve `foo.js` when only `foo.ts`\n * exists). Defaults to `.js`. `resolve` replaces URL building entirely.\n * @return `autoload` — call it with nothing to scan the page, with an element to watch that\n * component, or with a shadow root to watch that root. Safe to call repeatedly; a root is attached\n * once. Carries `url(tag)` and `retry(element)`.\n */\nexport const autoloader = (\n rootDir: string,\n componentsDir?: string,\n options?: AutoloaderOptions\n): AutoloaderInstance => {\n /** A configuration error fails at the misconfiguration, not once per element per render. */\n if (!rootDir) throw new Error('autoloader: rootDir is required (usually import.meta.url)');\n\n /**\n * An option this autoloader does not have does nothing, and did so in silence — `extensions` or\n * `resolver` reads exactly like the real thing at a glance, and the symptom is the *default*\n * behaviour, which looks like the option was never needed rather than never seen.\n *\n * `__DEV__`-only, so a production bundle carries neither the list nor the text.\n */\n if (__DEV__ && options)\n for (const key of Object.keys(options))\n if (key !== 'extension' && key !== 'resolve')\n console.warn(\n `[vera] autoloader: \\`${key}\\` is not an option, so it was ignored. ` +\n `The options are extension and resolve.`\n );\n\n /** Normalized so callers may pass either `ts` or `.ts` */\n const extension = `.${(options?.extension ?? '.js').replace(/^\\./, '')}`;\n\n /**\n * `dir/tag.ext` is one layout, and a component library is as likely to use `tag/tag.js`,\n * `tag/index.js`, or a flat manifest. `resolve` replaces the URL-building step entirely while\n * leaving the containment check below untouched — so a custom layout cannot be used to escape\n * the entry's directory. Principle #6 names this module's hard-coded `.js` as the example of the\n * shape to avoid; the path around it is the same problem one level out.\n */\n const resolve = options?.resolve;\n\n /**\n * Every resolved URL must stay inside the entry's own directory. Tag names cannot carry `/`\n * (the HTML parser won't produce one), but the `data-autoload-dir` override is free text — and\n * CODE-PRINCIPLES #8 requires bounding anything that turns markup into a module URL. An\n * absolute, protocol-relative, or upward-traversing value resolves outside this prefix and is\n * refused.\n */\n /**\n * A **relative** `rootDir` throws either way; development says why.\n *\n * The platform's own message — `Failed to construct 'URL': Invalid base URL` — names neither the\n * argument nor the fix. The value has to be absolute because every component URL resolves against\n * it, which is why `import.meta.url` is the documented answer. Behind `__DEV__`, so the build\n * folds it away and a production bundle carries neither the check nor the text.\n */\n if (__DEV__) {\n try {\n new URL('.', rootDir);\n } catch {\n throw new Error(\n `autoloader: rootDir must be an absolute URL, and \"${rootDir}\" is not. ` +\n `Pass import.meta.url — a relative path has nothing to resolve against.`\n );\n }\n }\n const base = new URL('.', rootDir).href;\n\n /** One attempt per URL per page load, so a 404 costs one request and one console line. */\n const attempted = new Set<string>();\n\n /**\n * Tags already being loaded, which is a different question from URLs already fetched.\n *\n * `<x-y>` and `<x-y data-autoload-dir=\"alt\">` are two URLs for one tag. Both used to import, and the\n * second module's `customElements.define('x-y')` threw `NotSupportedError` — surfacing as a\n * \"Failed to load\" for a component that had in fact loaded. A tag can only be defined once, so\n * the second URL could never have helped. It is released again if the first attempt fails, so a\n * second location is still allowed to try.\n */\n const requested = new Set<string>();\n\n /** The URL last tried for a tag, so `retry` knows which memo to clear. Dropped once it loads. */\n const failed = new Map<string, string>();\n\n /**\n * Roots under observation, so attaching is idempotent and cheap to re-attempt.\n *\n * Nothing prunes it, and nothing needs to: an observed node is collectable as soon as the page\n * drops it — measured in Chromium, where a removed node observed by a live observer is collected.\n * (jsdom reports otherwise, and reports it even after `disconnect()`, which is its own\n * bookkeeping rather than the observer contract.)\n */\n const watched = new WeakSet<Element | ShadowRoot>();\n\n /**\n * Creates the expected element url location to be appended to the root dir.\n *\n * The per-element override attribute is `data-autoload-dir` — NOT `dir`, which is HTML's global\n * text-direction attribute (`dir=\"rtl\"` on any i18n page would have silently redirected\n * component loading).\n *\n * Exposed as `autoload.url(tag)`, which is the whole of what a `preload` helper used to wrap:\n * with the URL in hand a caller can warm it with `<link rel=\"modulepreload\">`, prefetch it at a\n * lower priority, prime a service worker, or simply print it to answer \"why is it fetching\n * *that*?\" — the question this module gets asked most.\n *\n * @param tag The element's name\n * @param element The element being discovered, when there is one — only it can carry `data-autoload-dir`\n * @return The absolute URL this autoloader would fetch\n */\n const url = (tag: string, element?: Element) => {\n /**\n * Trailing slashes come off, and an empty or root-only directory becomes `.` — the entry file's\n * own directory, which is the only place a bounded URL can be anyway.\n *\n * The default used to be `/`, which built `//tag.js`: a **protocol-relative** URL, so\n * `new URL` read `tag.js` as a *host*. `autoloader(import.meta.url)` — the documented call\n * for components sitting beside the entry, since `componentsDir` is optional — therefore\n * refused every component it was asked for. `data-autoload-dir=\"/\"` did the same.\n */\n const dir = (element?.getAttribute('data-autoload-dir') ?? componentsDir ?? '.').replace(/\\/+$/, '') || '.';\n const href = new URL(resolve ? resolve(tag, dir) : `${dir}/${tag}${extension}`, rootDir).href;\n /**\n * **`?` and `#` end the path, so a directory cannot contain either.**\n *\n * The default layout builds `${dir}/${tag}${extension}` as text, and URL syntax then reads the\n * result rather than the intent. `data-autoload-dir=\"components?v=2\"` — an ordinary cache-buster, and\n * the reason this is a mistake someone makes rather than an attack — resolves to\n * `site/components?v=2/my-widget.js`, so the request goes to `site/components` with the **tag\n * name inside the query string**. The component file is never asked for. `#` is worse: the\n * fragment never reaches the network, so `site/components` is fetched outright.\n *\n * That is a wrong module, not a missing one, which is why it is refused rather than left to\n * 404. Containment does not catch it — the URL is genuinely inside the entry's directory, and\n * `data-autoload-dir=\"?\"` resolves to the entry file itself, re-importing the whole application under\n * a URL distinct enough to evaluate a second time.\n *\n * Only the default path is checked. `resolve` replaces URL building entirely and is documented\n * that way, so a query it adds is the caller's own — `components/tag.js?v=2` is exactly the\n * cache-buster the attribute cannot express, and it keeps working.\n */\n if (!resolve && /[?#]/.test(dir)) {\n const url = new URL(href);\n const refusal = new Error(\n `[vera] autoloader: refused ${href} for <${tag}> — data-autoload-dir \"${dir}\" contains ? or #, ` +\n `which ends the path, so <${tag}> lands in the query or fragment and ` +\n `${url.origin}${url.pathname} would be fetched instead. Use \\`resolve\\` to add a query.`\n );\n (refusal as Error & { href: string }).href = href;\n throw refusal;\n }\n /**\n * **An encoded separator is refused the way a real one is caught.**\n *\n * The URL parser handles every literal form: `..`, `..\\\\` and `%2e%2e/` all normalize into\n * genuine traversals that resolve outside `base` and fail the prefix test below — measured,\n * all three. But `%2F` and `%5C` survive resolution as DATA inside one path segment, so\n * `data-autoload-dir=\"..%2F..%2Fuploads\"` is textually inside the prefix while naming the exact\n * traversal a decode-then-resolve server turns real — and on a page whose markup is partly\n * authored elsewhere, that is an attacker importing an uploaded file as a same-origin module.\n * The URL standard is on the server's side here; principle #8 is not interested — this module\n * bounds what markup can turn into a module URL, and a directory whose name needs an encoded\n * slash has no honest reading. Same family as the `?`/`#` refusal above, same scope: the\n * default path only, since `resolve` owns its own URL building and a `%2F` in a query it adds\n * is legitimately its business.\n */\n if (!resolve && /%2f|%5c/i.test(dir)) {\n const refusal = new Error(`[vera] autoloader: refused ${href} for <${tag}> — encoded path separator in \"${dir}\"`);\n (refusal as Error & { href: string }).href = href;\n throw refusal;\n }\n /**\n * **Containment belongs here, not only at the fetch.**\n *\n * `data-autoload-dir` is an ordinary HTML attribute, so on any page whose markup is partly authored\n * elsewhere — a CMS, a sanitizer that keeps attributes, a template someone else fills — it is\n * an input. `data-autoload-dir=\"//evil.test\"` resolves to a different **origin** entirely, and\n * `..` walks out of the app.\n *\n * `load` always checked. This function is public and documented for preloading — warming a URL\n * with `<link rel=\"modulepreload\">` is its whole reason to exist — so returning a URL the loader\n * would refuse handed the caller the fetch this module declines to make. One check, at the one\n * place URLs are built, also covers a custom `resolve` returning something unbounded.\n *\n * `base` is `new URL('.', rootDir)`, which always ends in `/`, so the prefix test cannot be\n * satisfied by a sibling directory whose name merely starts the same way.\n */\n if (!href.startsWith(base)) {\n /**\n * The refused URL rides on the error, so discovery can dedupe on it exactly as it dedupes a\n * fetch. Keying the refusal on the *tag* instead would be wrong: `data-autoload-dir` is watched\n * precisely so it can be pointed somewhere else after a first attempt failed, and a tag\n * marked spent never looks again.\n */\n const refusal = new Error(`[vera] autoloader: refused ${href} for <${tag}> — resolves outside ${base}`);\n (refusal as Error & { href: string }).href = href;\n throw refusal;\n }\n return href;\n };\n\n /**\n * Loads an element's module and, once it has upgraded, starts watching it in turn.\n *\n * @param element The element to load\n * @param tag The tag to build the expected url from\n */\n const load = async (element: Element, tag: string): Promise<void> => {\n if (requested.has(tag)) return;\n let src;\n try {\n src = url(tag, element);\n } catch (error) {\n /**\n * Deduped on the refused URL, so it is reported once rather than on every scan — and so\n * pointing `data-autoload-dir` at a valid directory afterwards is a different URL and tries.\n */\n const href = (error as Error & { href?: string }).href;\n if (href !== undefined) {\n if (attempted.has(href)) return;\n attempted.add(href);\n }\n console.error((error as Error).message);\n return;\n }\n if (attempted.has(src)) return;\n attempted.add(src);\n requested.add(tag);\n failed.set(tag, src);\n\n try {\n await import(/* @vite-ignore */ src);\n /**\n * **A module can import cleanly and still not define the tag**, and that used to be silent\n * forever: `whenDefined` never settles, so the `catch` below never runs, no event is\n * dispatched, no line is logged, and the element sits unupgraded for the life of the page.\n * The everyday cause is a typo — markup says `<my-widget>`, the file defines `my-wdiget` — and\n * the everyday symptom is a blank space with a clean console.\n *\n * A dynamic `import()` resolves only after the module has fully evaluated, top-level `await`\n * included, so by here every `customElements.define` the module was going to run has run.\n * Two microtask turns are drained first anyway, which covers a define deferred by a resolved\n * promise; anything later than that is a floating promise the module never awaited.\n *\n * The wait is *not* abandoned — `whenDefined` is still awaited afterwards, so a definition\n * that does arrive late still upgrades and still gets watched. The error is a report, not a\n * refusal.\n */\n await Promise.resolve();\n await Promise.resolve();\n if (!customElements.get(tag)) {\n throw new Error(\n `imported ${src} but nothing defined <${tag}>. Check the tag name in that file matches ` +\n `the one in the markup, and that its \\`customElements.define\\` actually runs.`\n );\n }\n await customElements.whenDefined(tag);\n failed.delete(tag);\n watch(element);\n } catch (error) {\n requested.delete(tag);\n /**\n * Reported as a DOM event as well as a console line, because a component that never arrives\n * is something an app may want to render around — a placeholder, a retry button, a report to\n * an error tracker. An event rather than core's `'error'` insert: this package deliberately\n * does not depend on core, and reaching for `insert` from `@verajs/inserts` instead would\n * write to a registry core never reads in a production build.\n */\n element.dispatchEvent(\n new CustomEvent('vera:autoload-error', {\n bubbles: true,\n composed: true,\n detail: { tag, src, error, element },\n })\n );\n console.error(`[vera] autoloader: failed to load <${tag}> from ${src}:`, error);\n }\n };\n\n /** Loads one candidate, unless it has opted out. */\n const consider = (element: Element) => {\n if (element.getAttribute('data-autoload-ignore') == null) load(element, element.localName);\n };\n\n /**\n * `:not(:defined)` already means \"a custom element awaiting its definition\" — a dashless unknown\n * tag like `<madeupelement>` is defined, and an element leaves the set the moment its definition\n * lands. `tests/browser/autoloader.test.js` pins those semantics in a real engine, which is what\n * lets this trust the selector rather than re-checking the tag by hand.\n */\n const scan = (root: Element | ShadowRoot) => {\n const elements = root.querySelectorAll(':not(:defined)');\n for (let i = 0; i < elements.length; i++) consider(elements[i]);\n };\n\n /**\n * One observer for every watched root. A node added anywhere inside one is examined itself and\n * then scanned, because a subtree may arrive whole — `innerHTML` on a container delivers one\n * added node holding any number of undefined elements.\n */\n /**\n * Created on first use, not at construction.\n *\n * `new MutationObserver(...)` in the constructor made `autoloader` throw in Node —\n * `MutationObserver is not defined` — so an app entry that wires the autoloader could not be\n * imported server-side at all. `@verajs/router` attaches its window listeners lazily for exactly\n * this reason and says so; the observed-discovery rewrite reintroduced the problem here.\n */\n let observer;\n const observing = () =>\n (observer ??= new MutationObserver((records) => {\n for (const record of records) {\n /**\n * The three attributes are as much a part of discovery as insertion is. `autoloader` can be\n * put on a component that only becomes a lazy host once some state flips; `data-autoload-dir` can\n * be pointed somewhere else after a first attempt failed; `data-autoload-ignore` can be lifted.\n * Without watching them, all three needed the element to be inserted again before anything\n * noticed, which is not a thing that happens.\n */\n if (record.type === 'attributes') {\n const target = record.target as Element;\n if (record.attributeName === 'data-autoload') watch(target);\n else consider(target);\n continue;\n }\n\n const added = record.addedNodes;\n for (let i = 0; i < added.length; i++) {\n const node = added[i];\n if (node.nodeType !== 1) continue;\n const element = node as Element;\n if (!customElements.get(element.localName) && element.localName.includes('-')) consider(element);\n scan(element);\n }\n }\n }));\n\n /**\n * Starts watching a component, and takes stock of what is already inside it.\n *\n * This is what the `'render'` insert calls, so it runs on every render of every component and has\n * to be cheap when there is nothing to do: an attribute read, then a `WeakSet` check. The scan\n * happens once, when the observation starts — everything after that arrives as a mutation.\n *\n * @param element The element to watch for undefined custom elements within\n */\n const watch = (target: Element | ShadowRoot | Document = document) => {\n /**\n * `autoload()` with nothing to point at means \"every marked host on the page, right now\".\n *\n * This used to happen by itself as the autoloader was created, which was wrong twice over: it\n * fired once, so markup arriving later — fetched, stamped from a template — was never seen and\n * said nothing about it; and two autoloaders on a page each adopted every marked host and raced\n * to load the same tags from their own directories, which needed an option to switch off. As a\n * shape of a function that already exists it costs almost nothing, can be called again whenever\n * new markup lands, and leaves `autoloader` free of side effects.\n *\n * A document is recognised by `nodeType`, not by having a `body`. `document.body` is null until\n * the parser reaches it, so an `autoload()` from a classic or `async` module script in `<head>`\n * fell straight through this branch and the document was treated as a root to watch — observing\n * `document` itself, `subtree: true`. That is precisely the shape this module exists to avoid\n * (~47% on every mutation in the app, measured), it was permanent once `watched` held the\n * document, and nothing said it had happened. `nodeType` is 9 from the moment the document is.\n */\n if ((target as Document).nodeType === 9)\n return (target as Document).querySelectorAll('[data-autoload]').forEach((el) => watch(el));\n let root = target as Element | ShadowRoot;\n /**\n * An `Element` has to opt in; a `ShadowRoot` handed over directly does not, because handing it\n * over *is* the opt-in. That is the way into a third-party component whose shadow root holds\n * tags of yours — nothing else can reach it, since an observer cannot cross a shadow boundary.\n */\n if ((target as Element).getAttribute) {\n const element = target as Element;\n if (element.getAttribute('data-autoload') == null) return;\n if (element.getAttribute('data-autoload-ignore') != null) return;\n root = element.shadowRoot ?? element;\n }\n if (watched.has(root)) return;\n watched.add(root);\n observing().observe(root, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['data-autoload', 'data-autoload-dir', 'data-autoload-ignore'],\n });\n scan(root);\n };\n\n /**\n * Forgets that this element's tag failed, and tries it again.\n *\n * A failed load is otherwise permanent for the page — right for a component that does not exist,\n * wrong for one lost to a dropped connection. `vera:autoload-error` hands you the element, which\n * is what makes retrying one thing rather than re-scanning every watched root possible.\n */\n const retry = (element: Element) => {\n const tag = element.localName;\n requested.delete(tag);\n const src = failed.get(tag);\n if (src) attempted.delete(src);\n failed.delete(tag);\n load(element, tag);\n };\n\n /**\n * The instance is also its own `wire` descriptor, so configuring the autoloader and installing it\n * are one call:\n *\n * ```js\n * wire([renderer, router, autoloader(import.meta.url, 'components')]);\n * ```\n *\n * This replaced `setAutoloader`, a bespoke registrar that lived in `@verajs/inserts` — the\n * registry package knowing about one specific consumer, which is the coupling `wire` exists to\n * remove. Every other module hands `wire` a descriptor; this one now does too.\n *\n * Priority 75 runs it *after* the renderer at 50, because it scans what the render just produced.\n */\n /**\n * `name` goes through `defineProperty` because a function's own `name` is non-writable, so\n * `Object.assign` throws in strict mode — and the descriptor's `name` is what the duplicate-\n * priority warning quotes, so leaving it as `\"watch\"` would name the wrong thing.\n */\n Object.defineProperty(watch, 'name', { value: '@verajs/autoloader', configurable: true });\n return Object.assign(watch, {\n url,\n retry,\n on: 'render' as const,\n fn: ((_: unknown, container: Element | ShadowRoot | Document) => {\n watch(container);\n }) as never,\n priority: 75,\n });\n};\n","/**\n * `directiveLoader` — the autoloader's answer on core's `'loader'` insert: a DIRECTIVE NAME\n * nobody has wired resolves by convention to one module URL, `{base}/{dir}/{name}.js`, exactly\n * as component tags resolve. The engine asks (design §7: directives DISCOVERS, autoloader\n * LOADS); this claims and imports; **the module registers itself** by importing\n * `wireDirectives` from the same specifier the page used — module caching makes that the same\n * registry, the precise symmetry of an autoloaded component calling `customElements.define`.\n *\n * ```js\n * import { wire } from '@verajs/core';\n * import { directiveLoader } from '@verajs/autoloader';\n * wire([directiveLoader(import.meta.url, 'directives')]);\n * ```\n *\n * A lazy module looks like:\n *\n * ```js\n * // directives/sparkle.js\n * import { wireDirectives } from '@verajs/directives';\n * wireDirectives({ name: 'sparkle', value: 'none', setup(el) { … } });\n * ```\n *\n * **The name is markup input** — it is the tail of an attribute an author (or a CMS, or an\n * attacker who can write attributes) chose — so it is allowlisted to the directive-name grammar\n * (`[a-z][a-z0-9-]*`) BEFORE any URL exists. That single gate closes the traversal and\n * encoded-separator families the component path has to police character by character, because a\n * tag name passes through the HTML parser and this does not. Containment against the entry's\n * directory is still enforced on the final URL, so an `alias` or `resolve` mistake cannot\n * escape either.\n *\n * The `alias` map is FACTORY-ONLY JavaScript (never markup — same rule as every policy option\n * in this codebase): it redirects names for grouped layouts, so `alias: { paint: 'motion.js',\n * split: 'motion.js' }` serves one bundle for a family. One attempt per name per page load,\n * exactly the autoloader's posture with URLs; the ASKER memoizes refusals, this memoizes loads.\n */\nimport type { DirectiveLoaderInstance, DirectiveLoaderOptions } from './types.js';\n\n/** The name grammar. An attribute tail that is not a plausible directive name is declined —\n * which also means it never becomes a URL. */\nconst SAFE_NAME = /^[a-z][a-z0-9-]*$/;\n\nexport const directiveLoader = (\n rootDir: string,\n directivesDir?: string,\n options?: DirectiveLoaderOptions\n): DirectiveLoaderInstance => {\n if (!rootDir) throw new Error('directiveLoader: rootDir is required (usually import.meta.url)');\n if (__DEV__) {\n try {\n new URL('.', rootDir);\n } catch {\n throw new Error(\n `directiveLoader: rootDir must be an absolute URL, and \"${rootDir}\" is not. ` +\n `Pass import.meta.url — a relative path has nothing to resolve against.`\n );\n }\n if (options)\n for (const key of Object.keys(options))\n if (key !== 'extension' && key !== 'alias' && key !== 'resolve')\n console.warn(\n `[vera] directiveLoader: \\`${key}\\` is not an option, so it was ignored. ` +\n `The options are extension, alias and resolve.`\n );\n }\n const base = new URL('.', rootDir).href;\n const extension = `.${(options?.extension ?? '.js').replace(/^\\./, '')}`;\n const alias = options?.alias;\n const resolve = options?.resolve;\n const dir = (directivesDir ?? '.').replace(/\\/+$/, '') || '.';\n\n /** One import per name per page load; the promise is the memo, so N elements share one fetch. */\n const claimed = new Map<string, Promise<unknown>>();\n\n /**\n * The URL this loader would fetch for a name — public for the same reason the autoloader's\n * `url` is: warming with `<link rel=\"modulepreload\">` is the whole preload story, and printing\n * it answers \"why is it fetching THAT\". Throws on a name outside the grammar or a resolution\n * outside the entry's directory, exactly as `load` refuses them.\n */\n const url = (name: string): string => {\n if (!SAFE_NAME.test(name)) {\n throw new Error(`directiveLoader: \"${name}\" is not a directive name this will resolve.`);\n }\n const target = alias?.[name] ?? (resolve ? resolve(name, dir) : `${dir}/${name}${extension}`);\n const href = new URL(target, rootDir).href;\n /**\n * Containment on the FINAL url, whichever path built it. The name grammar already forbids\n * every traversal spelling markup could carry; this is the backstop for a factory mistake —\n * an `alias` of `../../evil.js`, a `resolve` returning an absolute URL — refused rather\n * than fetched, because a loader is a thing that turns strings into same-origin module\n * execution and the entry's directory is the stated bound.\n */\n if (!href.startsWith(base)) {\n throw new Error(`directiveLoader: refused ${href} for \"${name}\" — resolves outside ${base}`);\n }\n return href;\n };\n\n const load = (name: string): boolean | Promise<unknown> => {\n if (!SAFE_NAME.test(name)) return false;\n const existing = claimed.get(name);\n if (existing) return existing;\n let src: string;\n try {\n src = url(name);\n } catch (error) {\n console.error(`[vera] ${(error as Error).message}`);\n return false;\n }\n /**\n * The import IS the claim. Success means \"the module ran\" — whether it registered the name\n * is the ASKER's check, because only the asker owns the registry; a module that loads and\n * registers nothing earns `loader-loaded-nothing` there, with this URL in the story via the\n * console line below.\n */\n const request = import(/* @vite-ignore */ src).catch((error) => {\n console.error(`[vera] directiveLoader: failed to load \"${name}\" from ${src}:`, error);\n throw error;\n });\n claimed.set(name, request);\n return request;\n };\n\n /** The instance is its own wire descriptor — configuring and installing are one call. */\n Object.defineProperty(load, 'name', { value: '@verajs/autoloader directiveLoader', configurable: true });\n return Object.assign(load as (name: string, element: Element) => boolean | Promise<unknown>, {\n url,\n on: 'loader' as const,\n fn: load as never,\n /** Convention answers LAST: an app's own loader (an alias shim, a manifest) registers lower. */\n priority: 75,\n });\n};\n"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACI,MAAM,UAAU,GAAG,CACxB,OAAe,EACf,aAAsB,EACtB,OAA2B,KACL;;AAE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-utils/src/utils.ts","../../src/diagnostics.ts","../../src/entry.ts","../../src/autoloader.ts","../../src/loader.ts"],"sourcesContent":["/**\n * **Where every diagnostic code is explained.** The URL is permanent: a released bundle is immutable, so every version\n * published points here for ever — the domain cannot lapse and `/e/` cannot be reorganized without breaking links in\n * code nobody can edit; the docs site redirects instead. `scripts/sync-diagnostics.mjs` imports this constant, so the\n * pages and the bundles can never disagree about where they are.\n */\nexport const DOCS = 'https://verajs.dev/e/';\n\n/**\n * **What this copy of the framework has already said** (Brian's ruling, 2026-11-12): the ONE memory behind `warnOnce`, `errorOnce`\n * and `hasWarned`, for DEVELOPMENT-ONLY warnings. It replaced the hand-written once-flags every package kept\n * (`saidLists`, `warnedDrop`, per-element WeakSets, per-key Sets: two naming styles, Brian: no names). **A warning that\n * ships to production keeps its memory at its site** (bytes, measured 2026-11-12: the shared memory costs +80–145 B gz\n * per bundle); development-only warnings use warnOnce. Module state by necessity, since \"once\" spans every call on the\n * page. One per BUNDLE COPY, exactly the scope each flag had, because this package is inlined into every bundle.\n * A code, or `code key` for a string key, in a Set. An object key (an element, a setup function) in a WeakMap, so its\n * entry goes with the object. Marked pure, so a bundle that never prints once drops both.\n */\nconst printed = /* @__PURE__ */ new Set<string>();\nconst printedOn = /* @__PURE__ */ new WeakMap<object, Map<string, Set<unknown>>>();\n/**\n * A once's KEY: none (once per page), a string (once per that string), an object (once per that object: an element, a\n * class, a setup function), or the PAIR `[object, value]`, a value key on that object (a store write: the object and its\n * property; a keyed list: the list and the duplicate key, compared as the list compares them, by value, so `1` and `'1'`\n * stay apart). A pair is the only array a key may be.\n */\ntype OnceKey = string | object | readonly [object, unknown];\n/** Where an object key's (code, value) lives: the value set for that code on that object, made on demand. */\nconst valuesOn = (on: object, code: string, make: boolean): Set<unknown> | undefined => {\n let codes = printedOn.get(on);\n if (codes === undefined) {\n if (!make) return undefined;\n printedOn.set(on, (codes = new Map()));\n }\n let values = codes.get(code);\n if (values === undefined && make) codes.set(code, (values = new Set()));\n return values;\n};\n/** The object and value of an object or pair key. */\nconst split = (key: object): readonly [object, unknown] => (Array.isArray(key) ? (key as unknown as readonly [object, unknown]) : [key, undefined]);\n/** Whether (code, key) is new, recording it if so. */\nconst firstTime = (code: string, key?: OnceKey): boolean => {\n if (key === undefined || typeof key === 'string') {\n const entry = key === undefined ? code : `${code} ${key}`;\n if (printed.has(entry)) return false;\n printed.add(entry);\n return true;\n }\n const [on, sub] = split(key);\n const values = valuesOn(on, code, true)!;\n if (values.has(sub)) return false;\n values.add(sub);\n return true;\n};\n\n/**\n * **One shape for every diagnostic the framework prints** — the short line production keeps, the whole sentence\n * development adds — so a package converting its messages writes a table and a call, never its own format.\n *\n * production `[vera] hydration: element: found <i> — https://verajs.dev/e/hydration-fallback`\n * development `[vera] hydration: element: found <i> — fell back to a client render: … (hydration-fallback)`\n *\n * `subject` is the free information — what the code already has at hand, naming the problem area — the same in both\n * builds. `prose` is development only: the package's table entry (`Prose`), called behind `__DEV__` at the call site so\n * the table goes unreferenced in production and rollup drops it whole. Production prints the code inside the link, so\n * the reader is one click from the explanation, which `scripts/sync-diagnostics.mjs` publishes from the same tables.\n *\n * **Every production message is coded** (Brian, 2026-11-11; this supersedes \"convert where smaller\", 2026-10-02):\n * consistency over a few bytes, so no package keeps a hand-written production line beside its table.\n */\n/*\n * The parameter names are deliberately unlike anything a caller holds: terser will not inline a function whose\n * parameter shadows a name at the call site (measured 2026-10-02 — directives passes its own `code`, and a parameter\n * called `code` left `((e,t,n)=>`…`)(0,t,n)` in its bundle, +8 B; renamed, the call folds to the bare template).\n */\n/**\n * **A misused API, named by its function** — the thrown-error twin of `diagnostic()`: `untrack: expected a function …\n * (untrack-not-function)`, function-first because a stack already names the source and the sweep reads that shape. The\n * prose comes from a package's table, behind `__DEV__`, so a development-only guard costs production nothing.\n */\nexport const misuse = (forName: string, withCode: string, andProse?: false | readonly [string, string?]) =>\n __DEV__ && andProse\n ? `${forName}: ${andProse[0]}${andProse[1] ? ` ${andProse[1]}` : ''} (${withCode})`\n : `${forName}: ${DOCS}${withCode}`;\n\n/**\n * **A misused API and what it was misused ABOUT** — `misuse()` with a subject, in `diagnostic()`'s ` — ` separator:\n * `parseFrontmatter: line 3 — https://verajs.dev/e/cms-frontmatter-unsupported`. The subject is the free information\n * (a line, a URL and its status) and prints in both builds. A sibling rather than an optional parameter on `misuse()`,\n * because `misuse()` is inlined into every bundle that throws and a conditional subject would tax all of them for a\n * shape few need; a sibling is tree-shaken where unused.\n */\nexport const misuseAbout = (forName: string, aboutSubject: string, withCode: string, andProse?: false | readonly [string, string?]) =>\n __DEV__ && andProse\n ? `${forName}: ${aboutSubject} — ${andProse[0]}${andProse[1] ? ` ${andProse[1]}` : ''} (${withCode})`\n : `${forName}: ${aboutSubject} — ${DOCS}${withCode}`;\n\nexport const diagnostic = (\n inArea: string,\n bySubject: string,\n withCode: string,\n andProse?: false | readonly [string, string?]\n) =>\n /** `__DEV__` HERE as well as at the call: production folds this to the one-line form, branch and all. */\n __DEV__ && andProse\n ? `[vera] ${inArea}: ${bySubject} — ${andProse[0]}${andProse[1] ? ` ${andProse[1]}` : ''} (${withCode})`\n : `[vera] ${inArea}: ${bySubject} — ${DOCS}${withCode}`;\n\n/**\n * **Text from outside — a file path, a YAML key, a URL, an error's message — quoted before it reaches a line.** A log is a\n * pipeline, and such text can be shaped by an author or a request: a newline in it forges a line, an ESC sequence hides\n * one (log injection). `JSON.stringify` escapes both; cut to 80 characters so one value cannot fill the log. @verajs/ssr\n * keeps a twin (it cannot import this), held equal by tests/ssr-coded-diagnostics.\n */\n/**\n * `max` caps the length (80 by default); `Infinity` keeps the whole text for a value worth reading in full — a site\n * owner's own path — which is still ESCAPED: truncation and escaping are separate jobs, and a path is not free of control\n * characters just because its owner wrote it (2026-10-09).\n */\nexport const quoted = (text: string, max = 80): string => JSON.stringify(text.length > max ? `${text.slice(0, max)}…` : text);\n\n/**\n * **The errors a package constructs, marked as its own** — so a wrapper that reports an inner refusal (cms's\n * `generateManifest` around a frontmatter line) carries it as it is: already formatted, its outside text already\n * quoted. Anything else is foreign, and quoted. Identity, never a shape test: a message can imitate ours, an identity\n * cannot. @verajs/ssr keeps a twin (it cannot import this).\n */\nconst ours = /* @__PURE__ */ new WeakSet<object>();\nexport const own = <E extends Error>(error: E): E => {\n ours.add(error);\n return error;\n};\nexport const isOwn = (error: unknown): boolean => typeof error === 'object' && error !== null && ours.has(error);\n\n/**\n * **Whether this copy has already said `code` (for `key`)**: for a GUARD only, where deciding to warn costs work worth\n * skipping once the warning is out (development's whole-tree walk for unwired directive attributes, an event-name\n * guess over every property of an element). A site that only prints calls `warnOnce`. Asks, never records.\n */\nexport const hasWarned = (code: string, key?: OnceKey): boolean => {\n if (key === undefined || typeof key === 'string') return printed.has(key === undefined ? code : `${code} ${key}`);\n const [on, sub] = split(key);\n return valuesOn(on, code, false)?.has(sub) === true;\n};\n\ntype Detail = false | readonly [string, string?] | (() => readonly [string, string?] | undefined);\n/**\n * The printer behind both, on one level. `andDetail` is `diagnostic()`'s prose, or a function returning it where building\n * the sentence costs something: it is called only the first time. `...andMore` rides beside the line behind '%s' (an\n * element, a thrown error), never inside it, so text from outside cannot forge a line. The console method is read at the\n * call, so a test that replaces `console.warn` sees it.\n */\nconst sayOnce =\n (level: 'warn' | 'error') =>\n (inArea: string, bySubject: string, withCode: string, andDetail?: Detail, forKey?: OnceKey, ...andMore: unknown[]): void => {\n if (!firstTime(withCode, forKey)) return;\n const line = diagnostic(inArea, bySubject, withCode, typeof andDetail === 'function' ? andDetail() : andDetail);\n if (andMore.length) console[level]('%s', line, ...andMore);\n else console[level](line);\n };\n/**\n * **A diagnostic said once per page** (per key, where one is given: a string, or an object such as the element it is\n * about): `diagnostic()`'s arguments, then the key, then what rides beside the line. Coded in production exactly as\n * `diagnostic()` is, because it IS `diagnostic()`. `errorOnce` is its twin on `console.error`, for a refusal a page should\n * not miss.\n */\nexport const warnOnce = /* @__PURE__ */ sayOnce('warn');\nexport const errorOnce = /* @__PURE__ */ sayOnce('error');\n","/**\n * **The codes more than one package prints — DEVELOPMENT ONLY, except to the jsx compiler** (2026-10-09). A\n * fact said by two emitters has\n * ONE docs page and ONE text, so its prose lives here, in the lowest dependency every emitter shares, and each raises\n * it as `SHARED['code']` — never a second sentence in a second table (the dev line would stop being the docs page's\n * text). Referenced only behind `__DEV__`, so production drops it whole — but the jsx COMPILER raises `voidChildren`\n * and `styleObject` in every build: a compile error is a build tool's only output, and Vite loads the production one. `scripts/sync-diagnostics.mjs` publishes it\n * as `packages/shared-utils/diagnostics.json`; the uniqueness check sees each code here once.\n *\n * Also the home of messages shared-utils' OWN code prints on a renderer's behalf (adopt-property, markup-grammar,\n * isSelection) — the same rule: the emitter is shared, so the text is.\n *\n * **One named export per code, never one object** (measured 2026-10-09): rollup cannot drop an unused KEY of\n * an object literal, so a shared `PROSE` object put every shared message into every importer's development bundle.\n * A named export is dropped per function. **The export's name IS the code** — `tagCalled` is `tag-called` — so the\n * map sync and the tests read is derived (`proseOf`, scripts/diagnostic-tables.mjs), never kept by hand, and a call\n * `SHARED.tagCalled(…)` names its code exactly once.\n */\nimport type { Prose } from './types.js';\n\n/**\n * core's `html`/`svg`/`mathml` and the renderer's `tag` — a tagged template called as a function. The FACT is shared;\n * the EXAMPLE is each emitter's: `html` writes markup, `tag` an element name — so the emitter passes it.\n */\nexport const tagCalled: Prose = (tag, received, example) => [\n `expected a template literal and received ${received}.`,\n `It is a tagged template — write ${tag}\\`${example}\\`, not ${tag}('${example}').`,\n];\n/**\n * A template in a text-only element (`<style>`, a JSON data block, `<title>`, `<textarea>`): its content is text. Lite\n * refuses it, and so does the renderer in a style or JSON block (the server: `ssr-template-in-text`); in a `<title>` or\n * `<textarea>` the renderer places it, as it always has, and says so in development only. A list there is joined.\n */\nexport const templateInText: Prose = () => [\n 'a template inside a text-only element (`<style>`, a JSON `<script>`, `<title>`, `<textarea>`, or never-shown content: `<noscript>`, `<iframe>`) is never shown as markup — its content is text.',\n 'Render a string there; a list of strings is joined.',\n];\n/** A template that ends inside a tag: the renderer refuses it in development, the lite tier in every build. */\nexport const unfinishedTag: Prose = () => [\n 'a template cannot end inside a tag — the parser drops an unfinished tag.',\n 'Close the tag inside the template.',\n];\n/** core's props adoption on an `init()` element, and the renderer's on any other element. */\nexport const getterOnlyProp: Prose = (key) => [\n `received a bound property \\`.${key}\\` (or \\`!${key}\\`), but its class declares \\`${key}\\` as a getter with no setter — the value cannot be delivered and the binding is ignored.`,\n 'Add a setter, or stop binding it.',\n];\n/** shared-utils' `adoptProperty` (renderer, spread): an element that never drains the record loses it at upgrade. */\nexport const upgradeClobber: Prose = (name) => [\n `the value bound to \\`${name}\\` was replaced while the element upgraded. A class field is the usual cause: at ES2022 \\`${name}?: …\\` emits \\`${name};\\`, which runs during upgrade and overwrites whatever was set beforehand.`,\n `Write it \\`declare ${name}?: …\\` instead. A component that calls init() adopts bound properties automatically and never sees this; this element did not. Ignore this if the component replaced the value on purpose.`,\n];\n/** shared-utils' `isSelection` (renderer, spread). */\nexport const selectMultiple: Prose = (name) => [\n `\\`${name}\\` controls only ONE selection here, and a selection the user adds is kept — it is not controlled.`,\n 'Bind `?selected=${…}` on each <option> to control every selection.',\n];\n/** shared-utils' `contentClash` (renderer, spread): a content-replacing property beside content of the element's own. */\nexport const contentClash: Prose = (tag, name, alone) => [\n `<${tag}> binds \\`.${name}\\`, which replaces the element's content, and also has content of its own — markup or a child binding, which the write would strand.`,\n `Bind one or the other: the property alone (\\`${alone}\\`), or the content alone.`,\n];\n/** shared-utils' `tagHole` (renderer; @verajs/ssr keeps a twin). */\nexport const tagHole: Prose = () => [\n 'an expression in tag position (`<${…}>`) cannot be a tag name — a tag name must be a tag value.',\n \"Use `tag`h1`` from @verajs/renderer/tag, with that entry's `html`.\",\n];\n/** core's `wire` (at wire time) and the renderer (a template built before slots was wired, at render). */\nexport const lateTemplateModule: Prose = () => [\n \"a 'template' or 'element' module (namespaces, elements, slots) was wired after the renderer had already built templates — those never ask it, and keep rendering without it.\",\n 'Wire it beside the renderer, before the first render.',\n];\n/** The renderer and spread (two bundles), `@verajs/lite` and `@verajs/static`; @verajs/ssr refuses the same URLs silently today. */\nexport const scriptUrl: Prose = (name) => [\n `\\`${name}\\` was given a javascript: URL — refused, and the attribute removed.`,\n 'A bound URL is data, and data must never become code.',\n];\n/**\n * The renderer and spread, `@verajs/lite` and `@verajs/static`: `kind` is what the value was (dev-values'\n * `attributeValueKind`); `property` is the emitter's own spelling of a property binding — a template's\n * `.name=${value}`, a spread's `'.name': value`.\n */\nexport const attributeValue: Prose = (name, kind, property) => [\n `the attribute \\`${name}\\` was given ${kind}. An attribute value is a string and nothing else.`,\n `If the element is meant to RECEIVE this value, bind a property instead — \\`${property}\\` — which is how a custom element takes anything that is not text. If it is meant to be read as text, convert it where you know what it means: \\`date.toISOString()\\`, \\`list.join(' ')\\`. A Date in particular serializes with the SERVER's timezone on one side and the browser's on the other, so it will not survive hydration.`,\n];\n/** The renderer and spread: `type` is the value's `typeof`. */\nexport const notAListener: Prose = (name, type) => [\n `@${name} was given ${type === 'object' ? 'an object with no handleEvent method' : `a ${type}`}, which cannot listen — the event will do nothing.`,\n 'Pass a function, or an object with a handleEvent method. A missing handler is `undefined` or `false`, both of which are fine; this is neither.',\n];\n/** The renderer (and @verajs/ssr's twin): an expression inside an attribute NAME. */\nexport const nameExpression: Prose = (written, given) => [\n `an attribute name cannot be an expression — \\`${written}\\` is read by the parser before any value exists.`,\n `A name known only at runtime is a spread: \\`\\${spread({ [\\`${written}\\`]: ${given} })}\\` (from @verajs/renderer/spread).`,\n];\n/** The renderer and lite (`namespaces.ts`): an element placed where its namespace does not render. `advice` is built there. */\nexport const wrongNamespace: Prose = (tag, built, host, advice) => [\n `<${tag}> was built as ${built} and placed inside <${host}>, where it will not render.`,\n advice,\n];\n/** The renderer (and, ruled 2026-10-09, @verajs/ssr): data shaped like a template, not made by `html`. */\nexport const forgedTemplate: Prose = () => [\n 'is shaped like a template but was not made by html`` — rendered as text.',\n 'A template from data (JSON, or html([markup])) is never markup; for trusted markup, bind it: <div .innerHTML=${markup}>.',\n];\n/** The renderer and spread (two bundles; @verajs/ssr refuses the same): binding `__proto__`. */\nexport const protoBinding: Prose = (written) => [\n `binds \\`${written}\\`, which would replace the element's own prototype and destroy it — no property write does this, and no use of it is legitimate.`,\n 'The binding is ignored.',\n];\n/** The renderer and spread: a bound `srcdoc` ATTRIBUTE. `property` is the emitter's spelling of the property binding. */\nexport const srcdocAttribute: Prose = (property) => [\n 'binds the `srcdoc` attribute, which renders its value as an HTML document — refused.',\n `If the markup is trusted and sanitized, bind the property: \\`${property}\\`.`,\n];\n/** The renderer and spread: a bound inline-handler attribute (`onclick`). `event` is the emitter's event spelling(s). */\nexport const handlerAttribute: Prose = (name, event) => [\n `binds the \\`${name}\\` attribute, which runs its value as code — refused.`,\n `Bind a function as an event instead: ${event}.`,\n];\n/**\n * The jsx compiler and the renderer's `tag` — children given to a void element. Both refuse; the FATE the refusal\n * prevents is each emitter's: compiled, they would land after the element; through `tag`, vanish.\n */\nexport const voidChildren: Prose = (tag, fate) => [\n `<${tag}> is a void element — it has no end tag and takes no children, so ${fate}; refused.`,\n 'Move the children out, or use an element that takes content.',\n];\n/** The jsx compiler and the renderer's `tag` — an object `style`. The EXAMPLE is each emitter's spelling. */\nexport const styleObject: Prose = (example) => [\n 'style expects a STRING, not an object.',\n `Build the string: ${example}.`,\n];\n/**\n * An option a module or loader does not have — autoloader(), directiveLoader(), router(), and the directives packs\n * remote(), sensors(), motion(). One fact and one fix; the module is the line's SUBJECT and the list is its own.\n */\nexport const unknownOption: Prose = (key, list) => [\n `\\`${key}\\` is not an option, so it was ignored.`,\n `The options are ${list}.`,\n];\n\n/* ── `define`'s checks (define-checks.ts) and the setup's result: said by `@verajs/core` and `@verajs/lite` (moved from core's table, 2026-11-17) ── */\nexport const defineAttributeReflected: Prose = (prop) => [\n `observes an attribute whose prop, \\`${prop}\\`, is one the platform's element already REFLECTS — this tag's accessor replaces it, so setting \\`el.${prop}\\` no longer does what the platform's does (it no longer writes the attribute).`,\n 'Observe it only if the component owns that attribute; otherwise read it in the render with `host.getAttribute(…)`.',\n];\nexport const defineAttributeType: Prose = (prop, type) => [\n `shares the prop \\`${prop}\\`, whose default is a ${type} — and the attribute arrives as a STRING, so the prop changes type the moment it appears.`,\n 'Give the prop a string (or null) default, and convert in the render; or keep the attribute and the prop under different names.',\n];\nexport const defineAttributes: Prose = (received) => [\n `expected an array of attribute names and received ${received}.`,\n \"List them: `attributes: ['label', 'data-count']` — each arrives as a prop (`label`, `dataCount`).\",\n];\nexport const defineMethodAdopted: Prose = () => [\n 'an `adoptedCallback` costs every element of this tag its creation (measured +7.4% on create10k), and it is installed.',\n 'Keep it only if moving elements between documents needs it.',\n];\nexport const defineMethodIgnored: Prose = (name) => [\n `\\`${name}\\` is core's own on a define-made class, so this one is never installed (in any build).`,\n name === 'constructor'\n ? 'A setup is where per-instance work goes: `define(tag, (host) => { … })`.'\n : 'Put connect-time work in the setup; for work on removal, a `disconnectedCallback` in methods runs as the teardown hook.',\n];\nexport const defineMethodNotFunction: Prose = () => [\n 'is not a function, so it is installed as a plain value shared by every instance — and a getter ran ONCE, here.',\n 'Methods are functions; a value that changes per element is a prop (`props: { name: default }`).',\n];\nexport const defineMethodUnobserved: Prose = () => [\n 'never fires: the class observes no attributes, and it is installed anyway.',\n \"Declare them: `define({ tag, attributes: ['label'] }, …)` — each then arrives as a prop.\",\n];\nexport const definePropMethod: Prose = (name) => [\n `\\`${name}\\` is also a method, and the prop wins (it is installed after the methods), in every build.`,\n 'Give the method or the prop another name.',\n];\nexport const definePropSharedDefault: Prose = () => [\n 'this default is an object that cannot be copied per element (a Set, a Map, a class instance), so EVERY element of the tag shares this one — a change through one shows in all.',\n 'Declare it `null` and create it in the setup (`props: { selected: null }`, then `host.selected = new Set()`), or pass it in; arrays and plain objects are copied per element.',\n];\nexport const definePropsNotObject: Prose = (received) => [\n `expected an object of names and their defaults and received ${received}, so no prop is declared.`,\n \"Name each prop with its default: `props: { heading: '', items: [] }`.\",\n];\nexport const defineProtoKey: Prose = (kind) => [\n `is skipped, in every build: written onto the ${kind === 'prop' ? 'props record' : 'class prototype'} it would replace a prototype instead of adding a ${kind}.`,\n 'Rename the key. An own `__proto__` comes from `JSON.parse` or `Object.defineProperty`, never from an object literal.',\n];\nexport const defineSetup: Prose = (received) => [\n `the second argument is the SETUP, a function, and received ${received}.`,\n 'Pass the setup after the tag or the options: `define(\\'x-card\\', (host) => () => html`…`)`.',\n];\nexport const defineShadows: Prose = (name) => [\n `replaces the platform's \\`${name}\\` for every user of these elements — scripts, libraries and the browser's own callers — and it is installed.`,\n 'Give it a name of its own, unless replacing the platform member is the point.',\n];\nexport const defineTag: Prose = (received) => [\n `expected a custom element name — a string with a hyphen, not at the start — and received ${received}.`,\n \"Name it the way the platform requires: `define('x-card', setup)` or `define({ tag: 'x-card' }, setup)`.\",\n];\nexport const tagDefinedAgain: Prose = (tag) => [\n `<${tag}> is already defined; the platform refuses a second definition of a tag and throws next.`,\n 'Define each tag once, at module level. A live swap of a component while developing needs the development swap module, wired before the first define.',\n];\n/**\n * **A second copy of a component package stands down** — said in development by every `@vera-components/*` package's\n * `register` when its tag is already defined (by another copy or version of the same package): the first definition is\n * kept. One text for every component (2026-11-20; codes are one namespace). The tag is the diagnostic's subject, printed\n * before the message; `pkg` is the package's name and `entry` its element entry (`element` or `elements`).\n */\nexport const definedTwice: Prose = (pkg, entry) => [\n `is already defined by another copy or version of ${pkg}, so the first is kept.`,\n `Align the versions, or import ${pkg}/${entry} and define it under your own tag.`,\n];\nexport const setupReturnedValue: Prose = (kind) => [\n `its setup returned ${kind}, not a render function, so it rendered once and will never update.`,\n 'Return a render function — `return () => html`…`;` — the setup runs once, the render on every change.',\n];\n/**\n * **A boolean at a child position renders as the WORD** — said in development by `@verajs/renderer`, `@verajs/lite` and\n * `@verajs/static` (moved from the renderer's table, 2026-11-19: the small tiers say core's development diagnostics too).\n */\nexport const booleanChild: Prose = (value) => [\n `a child position was given \\`${value}\\`, which renders as the word \"${value}\" — the usual cause is \\`\\${cond && …}\\` with a false \\`cond\\`.`,\n 'Write `${cond ? … : null}`, or `${(cond && …) || null}`; `null` and `undefined` are the values that render nothing. If you meant to display the boolean, say so with `${String(value)}` and this goes quiet.',\n];\n/** **A misspelled event name** (`@clik`) — said in development by `@verajs/renderer` and `@verajs/lite` (moved 2026-11-19). */\nexport const eventNameTypo: Prose = (name, tag, best) => [\n `@${name} is not an event <${tag}> fires — did you mean @${best}? (In JSX, on${name.slice(0, 1).toUpperCase()}${name.slice(1)} compiles to @${name}.)`,\n 'A custom event by this name is fine, and this is said only in development.',\n];\n/**\n * **A wrapper around a real template literal's strings is no template in the small tiers** — `{ strings, values }` without\n * `_$litType$`, which only `@verajs/core`'s `hold` or `tag` build: a template to core, the text `[object Object]` in\n * `@verajs/lite` and `@verajs/static` (Brian, 2026-11-19: a recorded difference, said in development by both).\n */\nexport const templateWrapper: Prose = () => [\n \"an object holding a real template literal's `strings` but no `_$litType$` — a wrapper only `@verajs/core`'s `hold` or `tag` builds — is no template here: it renders as the text any object renders as, `[object Object]`.\",\n 'Render the `html` result itself; `@verajs/core` renders such a wrapper as its template.',\n];\n","import type { HandlerHolder, Untracked } from './types.js';\nimport { diagnostic } from './diagnostic.js';\nimport * as SHARED from './diagnostics.js';\n\n/**\n * Get an object's type.\n *\n * @param obj The object\n * @return The type\n */\nexport const getType = (obj: unknown) => Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();\n\n/**\n * Weak collections need their per-key dependencies stored weakly, or tracking `weakMap.get(obj)`\n * holds `obj` and defeats the whole point of the type. Checked by type string rather than\n * `instanceof`, which fails across realms (iframes, `vm`).\n */\n/**\n * A WeakMap or WeakSet (or WeakRef) — read from `Symbol.toStringTag`, the tag `Object.prototype.toString` itself reads, so\n * the answer is the same (another realm's collections included) without building and lower-casing a string on every first\n * tracked read of every object.\n */\nexport const isWeakCollection = (item: unknown) => {\n const tag = (item as { [Symbol.toStringTag]?: unknown } | null)?.[Symbol.toStringTag];\n return typeof tag === 'string' && (tag[0] === 'W' || tag[0] === 'w');\n};\n\n/**\n * Remove a trailing slash from an url if its not root url (`/`).\n *\n * @param str String to remove trailing slash from\n */\nexport const stripTrailingSlash = (str: string) => (str !== '/' && str.endsWith('/') ? str.slice(0, -1) : str);\n\n/**\n * **Reports an error nothing else handled, the way the platform reports one.** `reportError` fires\n * the window's `error` event — what `window.onerror`, error trackers and test runners listen for —\n * without unwinding the caller, so one failing hook or ref never stops its siblings. A bare\n * `console.error` reached none of those: a component could stop updating while every page-error\n * listener stayed silent. Off-browser (Node has no `reportError`) the console is all there is.\n * `line` is the framework's own line, printed beside the error — a CODED one (2026-10-09):\n * each caller passes `'[vera] <code>'` in production and its table's `diagnostic()` sentence in development, both\n * literal codes at the call site, so the static checks read them. The subject is fixed wording too (`a hook`, `an\n * element ref`), never a tag name: this line is the console's FORMAT (no `'%s'`, which measured +2–3 B on the renderer\n * bundles), so nothing from outside may reach it — the element goes to the `'error'` handlers instead. Production prints it only where the platform has no\n * `reportError` (Node); in a browser, `reportError` alone reports.\n *\n * Shared by core (a hook threw) and the renderer (a ref threw) so the fallback is one rule.\n */\nexport const reportUncaught = (error: unknown, line: string) => {\n if (typeof reportError !== 'function') console.error(line, error);\n else {\n if (__DEV__) console.error(line, error);\n reportError(error);\n }\n};\n\n/**\n * **Reports what user code a render called threw — to the app's `'error'` chain, else as uncaught.** One rule for\n * every callback the framework runs on the user's behalf and survives: a hook (core), an element ref, and an element\n * claim's `create`/`mount`/`unmount` (the renderer). The caller catches at the call site and carries on, so one\n * failing callback never stops its siblings or leaves a commit half applied. `element` is the component the error\n * belongs to, handed to each handler. Every throw is reported — nothing is deduped, as a hook's never was.\n * **Core keeps a deliberate twin** (`reportHookError`, the same rule as a `forEach`): routed through here it measured\n * +11 B gzip on `vera.min.js` (2026-10-09). A change to the rule changes both.\n */\nexport const reportTo = (handlers: readonly unknown[] | undefined, error: unknown, element: Element | undefined, line: string) => {\n if (handlers?.length) for (const handler of handlers) (handler as (error: unknown, element?: Element) => void)(error, element);\n else reportUncaught(error, line);\n};\n\n/** The component a render root belongs to: a shadow root's host, or a light root itself. */\nexport const hostOf = (root: Node | null | undefined): Element | undefined =>\n root == null ? undefined : root.nodeType === 11 ? (root as ShadowRoot).host : (root as Element);\n\n/** `fn(a, b, c)`, tracked as the caller is — the stand-in for core's `untracked` when no core was wired. */\nexport const call: Untracked = (fn, a, b, c) => fn(a!, b!, c!);\n\n/**\n * **Runs a bound handler, and its callers run it UNTRACKED**: the renderer's template `@event` and spread's event key,\n * each through `untracked(dispatch, holder, event)` (2026-10-09). An effect that fires an event synchronously\n * (`el.click()`, `focus()`, `dispatchEvent`) runs the handler INSIDE itself, and the handler's reads subscribed the\n * effect: a handler doing `state.n++` made the effect re-run on every click, a self-feeding loop held to one round per\n * frame, forever (measured). A handler's reads are event-time decisions, never a hook's inputs. The directives engine's\n * delegated `listen` makes the same choice its own way. A function is called with the element as `this`; an object\n * through its `handleEvent`. One function for both callers (Brian's size-audit ruling, 2026-11-13): it was two\n * identical copies, so a fix had two addresses; each bundle still inlines its own.\n */\nexport const dispatch = (holder: HandlerHolder, event: Event) => {\n const handler = holder._handler as EventListener | EventListenerObject | null;\n if (typeof handler === 'function') handler.call(holder._element as never, event);\n else if (typeof handler?.handleEvent === 'function') handler.handleEvent(event);\n};\n\n/**\n * **Whether a property binding is a `<select>`'s SELECTION** — `value` or `selectedIndex` — which the renderer and\n * `spread` both treat as live: re-asserted every render and compared against the live value (as `!value` is), because\n * a select's options can be replaced under an unchanged value, which drops the selection. One rule, asked once per\n * binding by both, so a template and a spread key cannot disagree about it.\n *\n * In development it names the one shape it cannot serve: on a `<select multiple>` both properties read and set a\n * SINGLE selection, so a selection the user adds is kept rather than controlled. Always writing there was measured\n * 2–3% slower on every table with a select per row, to serve an API that does not fit — hence a warning, not a cost.\n */\nexport const isSelection = (element: Element, name: unknown) => {\n if ((name !== 'value' && name !== 'selectedIndex') || element.localName !== 'select') return false;\n return true;\n};\n\n/**\n * Development: the one shape a selection binding cannot serve, named by the module the user wired (`side`). Called only\n * behind `__DEV__` at each call site, so production keeps `isSelection` exactly as small as it was (a `side` argument on\n * it measured +1 B, a default +9 B on vera-renderer.min.js — 2026-10-09).\n */\nexport const saySelectMultiple = (element: Element, name: unknown, side: string) => {\n if (element.hasAttribute('multiple'))\n console.warn(diagnostic(side, '<select multiple>', 'select-multiple', __DEV__ && SHARED.selectMultiple(String(name))));\n};\n\n/**\n * `target[key]`, as a function — how a component's GETTER is read through `untracked`. Not `Reflect.get`: `untracked`\n * passes three arguments, and `Reflect.get`'s third is the RECEIVER — `undefined` there runs the getter with no `this`.\n */\nexport const read = (target: object, key: string) => (target as Record<string, unknown>)[key];\n\n/**\n * **What a thrown value says, whatever was thrown — and it never throws itself.** A caught value comes from author\n * code (a `resolve` option, a motion tick or vocabulary function), and JavaScript can throw anything: `null`, an object\n * with no prototype (`String()` finds no `toString`), one whose `toString` or `message` getter throws, a Proxy whose\n * traps throw. Formatting it naively replaced the real failure with an unrelated TypeError from inside the framework.\n * Anything unreadable becomes a fixed phrase; `Object.prototype.toString` is no fallback, since it reads\n * `Symbol.toStringTag` through a Proxy's trap too.\n *\n * **A deliberate duplicate of `thrownMessage` in `packages/ssr/src/vera/escaping.ts` — fix both copies.** `@verajs/ssr`\n * is compiled per file with no bundling, so it cannot import this private, unpublished package at run time;\n * `tests/thrown-message-copies.test.mjs` runs one table of thrown values against both, so they cannot drift.\n */\nexport const thrownMessage = (error: unknown): string => {\n try {\n if (error instanceof Error) return String(error.message);\n const message = (error as { message?: unknown } | null)?.message;\n return typeof message === 'string' ? message : String(error);\n } catch {\n return '[unprintable value thrown]';\n }\n};\n\n/** `data-tone` → `dataTone`: the prop an observed attribute arrives as, in every package that defines components (`@verajs/core`'s `define`, its checks, `@verajs/lite`). */\nexport const camel = (name: string) => name.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase());\n","/**\n * **`@verajs/autoloader`'s diagnostics — DEVELOPMENT ONLY prose.** Two loaders live here — `autoloader` (components) and\n * `directiveLoader` (directives) — and where they say one fact it is ONE code (the loader is the line's area). Published\n * as `packages/autoloader/diagnostics.json`.\n */\nimport type { Prose } from '@verajs/shared-utils';\n\nexport const PROSE: Record<string, Prose> = {\n 'loader-root-required': () => ['rootDir is required — the directory every path resolves against.', 'Pass import.meta.url.'],\n 'loader-root-not-absolute': (rootDir) => [\n `rootDir must be an absolute URL, and \"${rootDir}\" is not.`,\n 'Pass import.meta.url — a relative path has nothing to resolve against.',\n ],\n /**\n * Three reasons, one fact — a URL this loader will not fetch (and no request is made). The refused URL is the line's\n * SUBJECT, so production — which prints no prose — still says which.\n */\n 'loader-url-refused': (why) => [`refused — ${why}.`, 'Nothing was requested. Point the directory, or `resolve`, at a path inside rootDir.'],\n /** What it threw is the SUBJECT (printed in every build); this explains it. */\n 'loader-resolve-threw': () => [\n 'the `resolve` option threw.',\n 'The element was left unloaded; `resolve(name, dir)` must return a path and never throw.',\n ],\n 'loader-import-failed': (what, src) => [`failed to load ${what} from ${src}.`, 'The error is printed beside this line; the import itself failed.'],\n 'autoloader-not-defined': (tag) => [\n `the module loaded but nothing defined <${tag}>.`,\n 'Check the tag name in that file matches the one in the markup, and that its `customElements.define` actually runs.',\n ],\n 'directive-loader-name': (name) => [`\"${name}\" is not a directive name this will resolve.`, 'A directive name is lowercase letters, digits and dashes, starting with a letter.'],\n};\n","import { diagnostic, misuse, SHARED } from '@verajs/shared-utils';\nimport { PROSE } from './diagnostics.js';\n\n/**\n * **The checks both loaders make on their entry, in one home** (`autoloader` and `directiveLoader` each held a copy):\n * the root is required and absolute, an unknown option warns, and the extension is normalized. Answers the directory\n * every URL must stay inside, and the extension.\n *\n * A configuration error fails at the misconfiguration, not once per element per render.\n *\n * A **relative** `rootDir` throws either way; development says why. The platform's own message (`Failed to construct\n * 'URL': Invalid base URL`) names neither the argument nor the fix. The value has to be absolute because every URL\n * resolves against it, which is why `import.meta.url` is the documented answer.\n *\n * An option a loader does not have does nothing, and did so in silence: `extensions` or `resolver` reads exactly like\n * the real thing at a glance, and the symptom is the *default* behavior, which looks like the option was never needed\n * rather than never seen.\n *\n * Both of those are `__DEV__`-only, so a production bundle carries neither the checks nor their text.\n *\n * @param owner The loader's name, the area every line it prints is filed under\n * @param known The option names that loader reads\n * @return `[base, extension]`: `base` is `new URL('.', rootDir)`, which always ends in `/`, so a prefix test against it\n * cannot be satisfied by a sibling directory whose name merely starts the same way. Every resolved URL must stay inside\n * it: the per-element directory override is free text, and CODE-PRINCIPLES #8 requires bounding anything that turns\n * markup into a module URL. The extension may be given as `ts` or `.ts`.\n */\nexport const entry = (\n owner: string,\n rootDir: string,\n options: { readonly extension?: string } | undefined,\n known: readonly string[]\n): [base: string, extension: string] => {\n if (!rootDir) throw new Error(misuse(owner, 'loader-root-required', __DEV__ && PROSE['loader-root-required']()));\n if (__DEV__) {\n try {\n new URL('.', rootDir);\n } catch {\n throw new Error(misuse(owner, 'loader-root-not-absolute', __DEV__ && PROSE['loader-root-not-absolute'](rootDir)));\n }\n if (options)\n for (const key of Object.keys(options))\n if (!known.includes(key))\n console.warn(diagnostic(owner, 'options', 'unknown-option', __DEV__ && SHARED.unknownOption(key, known.join(', '))));\n }\n return [new URL('.', rootDir).href, `.${(options?.extension ?? '.js').replace(/^\\./, '')}`];\n};\n","import type { AutoloaderInstance, AutoloaderOptions } from './types.js';\nimport { diagnostic, thrownMessage } from '@verajs/shared-utils';\nimport { PROSE } from './diagnostics.js';\nimport { entry } from './entry.js';\n\n/**\n * `src` with `vera-retry=<n>` added to its query (a hash kept where it was): a URL the engine has not seen, for a retry\n * of an import it rejected (see `retries`). A server ignores a query it does not read, so it is the same file. Only a\n * URL a server answers (`http:`, `https:`, `file:`): a query would change a `data:` URL's content, and a `blob:` that\n * failed cannot come back, so those are imported as they are.\n */\nconst retried = (src: string, tries: number, document: Document): string => {\n const url = new URL(src);\n const served = url.protocol === 'http:' || url.protocol === 'https:' || url.protocol === 'file:';\n if (!served || /*@__NOINLINE__*/ pins(document)) return src;\n url.searchParams.set('vera-retry', String(tries));\n return url.href;\n};\n\n/**\n * **Whether an import map on the page pins anything with `integrity`**: a hash is keyed by URL, so the same file under\n * `vera-retry=<n>` loads unchecked (measured on Chromium, Firefox and WebKit), and a file that failed its check would\n * load on the retry. On such a page every retry imports as it is. Not a match against `src`: a hash is keyed by the URL\n * the map RESOLVES to, after its `imports` and `scopes` remap `src`, so a match on `src` misses a remapped pin.\n */\nconst pins = (document: Document): boolean => {\n for (const script of document.querySelectorAll('script[type=\"importmap\"]')) {\n try {\n const integrity = (JSON.parse(script.textContent ?? '') as { integrity?: unknown }).integrity;\n if (typeof integrity === 'object' && integrity !== null && Object.keys(integrity).length > 0) return true;\n } catch {\n /** Not JSON: the engine refused that map as well, so it pins nothing. */\n }\n }\n return false;\n};\n\n/**\n * Inits an autoloader with the provided root directory, component directory and autoloader options.\n *\n * Discovery is **observed, not polled**. Each `autoloader`-marked component is watched once with a\n * `MutationObserver`, so an undefined element is found whenever it enters the DOM — by a render, by\n * `innerHTML`, by a third-party widget, or by having been in the HTML file all along. The previous\n * model re-scanned a marked component's whole tree on every render, which saw only what a Vera\n * render put there and cost more the larger the component got (measured in Chromium: 0.46 µs for a\n * 10-node component, 32.5 µs for a 1 000-node one, on every render, forever). An observation costs\n * ~0.6 µs per mutation batch and does not care how big the component is.\n *\n * One observer object watches every marked root — `observe()` takes many targets — and a mutation\n * only notifies observers on its own ancestor chain, so watched subtrees that are not the ones\n * changing cost nothing. Measured: 1 000 registrations left unrelated DOM work at 0.900 µs against\n * 0.933 µs with none. Watching `document` instead would have been the expensive shape, taxing every\n * mutation in the app by ~47%.\n *\n * @param rootDir The root directory of all components. Should almost always be import.meta.url unless you are using\n * absolute paths\n * @param componentsDir The relative directory from the root directory. If element has an \"data-autoload-dir\" attribute, the\n * autoloader will read from that first\n * @param options Autoloader options. `extension` sets the file extension appended to the tag name, which lets\n * TypeScript projects autoload `.ts` sources during dev (a dev server will not serve `foo.js` when only `foo.ts`\n * exists). Defaults to `.js`. `resolve` replaces URL building entirely.\n * @return `autoload` — call it with nothing to scan the page, with an element to watch that\n * component, or with a shadow root to watch that root. Safe to call repeatedly; a root is attached\n * once. Carries `url(tag)` and `retry(element)`.\n */\nexport const autoloader = (\n rootDir: string,\n componentsDir?: string,\n options?: AutoloaderOptions\n): AutoloaderInstance => {\n const [base, extension] = entry('autoloader', rootDir, options, ['extension', 'resolve']);\n\n /**\n * `dir/tag.ext` is one layout, and a component library is as likely to use `tag/tag.js`,\n * `tag/index.js`, or a flat manifest. `resolve` replaces the URL-building step entirely while\n * leaving the containment check below untouched — so a custom layout cannot be used to escape\n * the entry's directory. Principle #6 names this module's hard-coded `.js` as the example of the\n * shape to avoid; the path around it is the same problem one level out.\n */\n const resolve = options?.resolve;\n\n /** One attempt per URL per page load, so a 404 costs one request and one console line. */\n const attempted = new Set<string>();\n\n /**\n * Tags already being loaded, which is a different question from URLs already fetched.\n *\n * `<x-y>` and `<x-y data-autoload-dir=\"alt\">` are two URLs for one tag. Both used to import, and the\n * second module's `customElements.define('x-y')` threw `NotSupportedError` — surfacing as a\n * \"Failed to load\" for a component that had in fact loaded. A tag can only be defined once, so\n * the second URL could never have helped. It is released again if the first attempt fails, so a\n * second location is still allowed to try.\n */\n const requested = new Set<string>();\n\n /** The URL last tried for a tag, so `retry` knows which memo to clear. Dropped once it loads. */\n const failed = new Map<string, string>();\n /**\n * **How many times `retry` has asked again for a tag whose import REJECTED** (2026-11-21): an engine keeps a failed\n * module import, keyed by its URL — Chromium 159 and Firefox and WebKit before 159 and 27 answer the same URL from that\n * record without asking the server (`tests/browser/autoloader.test.js` measures it) — so a retry imports the URL with\n * `vera-retry=<n>` added, which the engine has not seen. A fragment would not do: Chromium keeps the failure under\n * `#…` too. Only for a rejected import: a module that loaded and did not define its tag is retried from its own URL,\n * since running it again could not define the tag and would run its code twice. Dropped once the tag loads. (One map\n * of `{ src, tries }` for both was measured at +8 B gz, for one delete fewer in three places.)\n */\n const retries = new Map<string, number>();\n\n /**\n * Roots under observation, so attaching is idempotent and cheap to re-attempt.\n *\n * Nothing prunes it, and nothing needs to: an observed node is collectable as soon as the page\n * drops it — measured in Chromium, where a removed node observed by a live observer is collected.\n * (jsdom reports otherwise, and reports it even after `disconnect()`, which is its own\n * bookkeeping rather than the observer contract.)\n */\n const watched = new WeakSet<Element | ShadowRoot>();\n\n /**\n * The URLs this loader refused, by the refusal it threw — read back in `load` to report each once. The refusal still\n * carries `href` for a caller of `url()`; `load` reads this map instead, because whatever reaches its `catch` may be\n * the caller's own throw, and reading a property off `null` (or a Proxy that throws) crashed the error path, where\n * `WeakMap#get` answers `undefined` for anything.\n */\n const refused = new WeakMap<object, string>();\n /**\n * One refusal of a URL, recorded as it is made. The refused URL rides on the error, so discovery can dedupe on it\n * exactly as it dedupes a fetch. Keying the refusal on the *tag* instead would be wrong: `data-autoload-dir` is\n * watched precisely so it can be pointed somewhere else after a first attempt failed, and a tag marked spent never\n * looks again.\n */\n const refuse = (tag: string, href: string, why: string): Error => {\n const refusal = new Error(diagnostic('autoloader', `<${tag}> ${href}`, 'loader-url-refused', __DEV__ && PROSE['loader-url-refused'](why)));\n (refusal as Error & { href: string }).href = href;\n refused.set(refusal, href);\n return refusal;\n };\n\n /**\n * Creates the expected element url location to be appended to the root dir.\n *\n * The per-element override attribute is `data-autoload-dir` — NOT `dir`, which is HTML's global\n * text-direction attribute (`dir=\"rtl\"` on any i18n page would have silently redirected\n * component loading).\n *\n * Exposed as `autoload.url(tag)`, which is the whole of what a `preload` helper used to wrap:\n * with the URL in hand a caller can warm it with `<link rel=\"modulepreload\">`, prefetch it at a\n * lower priority, prime a service worker, or simply print it to answer \"why is it fetching\n * *that*?\" — the question this module gets asked most.\n *\n * @param tag The element's name\n * @param element The element being discovered, when there is one — only it can carry `data-autoload-dir`\n * @return The absolute URL this autoloader would fetch\n */\n const url = (tag: string, element?: Element) => {\n /**\n * Trailing slashes come off, and an empty or root-only directory becomes `.` — the entry file's\n * own directory, which is the only place a bounded URL can be anyway.\n *\n * The default used to be `/`, which built `//tag.js`: a **protocol-relative** URL, so\n * `new URL` read `tag.js` as a *host*. `autoloader(import.meta.url)` — the documented call\n * for components sitting beside the entry, since `componentsDir` is optional — therefore\n * refused every component it was asked for. `data-autoload-dir=\"/\"` did the same.\n */\n const dir = (element?.getAttribute('data-autoload-dir') ?? componentsDir ?? '.').replace(/\\/+$/, '') || '.';\n const href = new URL(resolve ? resolve(tag, dir) : `${dir}/${tag}${extension}`, rootDir).href;\n /**\n * **`?` and `#` end the path, so a directory cannot contain either.**\n *\n * The default layout builds `${dir}/${tag}${extension}` as text, and URL syntax then reads the\n * result rather than the intent. `data-autoload-dir=\"components?v=2\"` — an ordinary cache-buster, and\n * the reason this is a mistake someone makes rather than an attack — resolves to\n * `site/components?v=2/my-widget.js`, so the request goes to `site/components` with the **tag\n * name inside the query string**. The component file is never asked for. `#` is worse: the\n * fragment never reaches the network, so `site/components` is fetched outright.\n *\n * That is a wrong module, not a missing one, which is why it is refused rather than left to\n * 404. Containment does not catch it — the URL is genuinely inside the entry's directory, and\n * `data-autoload-dir=\"?\"` resolves to the entry file itself, re-importing the whole application under\n * a URL distinct enough to evaluate a second time.\n *\n * Only the default path is checked. `resolve` replaces URL building entirely and is documented\n * that way, so a query it adds is the caller's own — `components/tag.js?v=2` is exactly the\n * cache-buster the attribute cannot express, and it keeps working.\n */\n if (!resolve && /[?#]/.test(dir)) {\n const url = new URL(href);\n throw refuse(tag, href, `data-autoload-dir \"${dir}\" contains ? or #, which ends the path, so <${tag}> lands in the query or fragment and ${url.origin}${url.pathname} would be fetched instead; use \\`resolve\\` to add a query`);\n }\n /**\n * **An encoded separator is refused the way a real one is caught.**\n *\n * The URL parser handles every literal form: `..`, `..\\\\` and `%2e%2e/` all normalize into\n * genuine traversals that resolve outside `base` and fail the prefix test below — measured,\n * all three. But `%2F` and `%5C` survive resolution as DATA inside one path segment, so\n * `data-autoload-dir=\"..%2F..%2Fuploads\"` is textually inside the prefix while naming the exact\n * traversal a decode-then-resolve server turns real — and on a page whose markup is partly\n * authored elsewhere, that is an attacker importing an uploaded file as a same-origin module.\n * The URL standard is on the server's side here; principle #8 is not interested — this module\n * bounds what markup can turn into a module URL, and a directory whose name needs an encoded\n * slash has no honest reading. Same family as the `?`/`#` refusal above, same scope: the\n * default path only, since `resolve` owns its own URL building and a `%2F` in a query it adds\n * is legitimately its business.\n */\n if (!resolve && /%2f|%5c/i.test(dir)) throw refuse(tag, href, `an encoded path separator in \"${dir}\"`);\n /**\n * **Containment belongs here, not only at the fetch.**\n *\n * `data-autoload-dir` is an ordinary HTML attribute, so on any page whose markup is partly authored\n * elsewhere — a CMS, a sanitizer that keeps attributes, a template someone else fills — it is\n * an input. `data-autoload-dir=\"//evil.test\"` resolves to a different **origin** entirely, and\n * `..` walks out of the app.\n *\n * `load` always checked. This function is public and documented for preloading — warming a URL\n * with `<link rel=\"modulepreload\">` is its whole reason to exist — so returning a URL the loader\n * would refuse handed the caller the fetch this module declines to make. One check, at the one\n * place URLs are built, also covers a custom `resolve` returning something unbounded.\n *\n * Tag names cannot carry `/` (the HTML parser won't produce one), but `data-autoload-dir` is free text: an\n * absolute, protocol-relative or upward-traversing value resolves outside `base` (see `entry`) and is refused.\n */\n if (!href.startsWith(base)) throw refuse(tag, href, `it resolves outside ${base}`);\n return href;\n };\n\n /**\n * Loads an element's module and, once it has upgraded, starts watching it in turn.\n *\n * @param element The element to load\n * @param tag The tag to build the expected url from\n */\n const load = async (element: Element, tag: string): Promise<void> => {\n if (requested.has(tag)) return;\n let src;\n try {\n src = url(tag, element);\n } catch (error) {\n /**\n * Deduped on the refused URL, so it is reported once rather than on every scan — and so\n * pointing `data-autoload-dir` at a valid directory afterwards is a different URL and tries.\n */\n const href = refused.get(error as object);\n if (href === undefined) {\n /** Not a refusal of ours: the caller's `resolve` threw, and it can throw any value at all. */\n console.error(diagnostic('autoloader', `<${tag}>: ${thrownMessage(error)}`, 'loader-resolve-threw', __DEV__ && PROSE['loader-resolve-threw']()));\n return;\n }\n if (attempted.has(href)) return;\n attempted.add(href);\n /** Routing: a refusal of ours, already carrying its code (`loader-url-refused`). */\n console.error((error as Error).message);\n return;\n }\n if (attempted.has(src)) return;\n attempted.add(src);\n requested.add(tag);\n failed.set(tag, src);\n const tries = retries.get(tag);\n\n let imported = false;\n try {\n await import(/* @vite-ignore */ tries === undefined ? src : /*@__NOINLINE__*/ retried(src, tries, element.ownerDocument));\n imported = true;\n /**\n * **A module can import cleanly and still not define the tag**, and that used to be silent\n * forever: `whenDefined` never settles, so the `catch` below never runs, no event is\n * dispatched, no line is logged, and the element sits unupgraded for the life of the page.\n * The everyday cause is a typo — markup says `<my-widget>`, the file defines `my-wdiget` — and\n * the everyday symptom is a blank space with a clean console.\n *\n * A dynamic `import()` resolves only after the module has fully evaluated, top-level `await`\n * included, so by here every `customElements.define` the module was going to run has run.\n * Two microtask turns are drained first anyway, which covers a define deferred by a resolved\n * promise; anything later than that is a floating promise the module never awaited.\n *\n * The wait is *not* abandoned — `whenDefined` is still awaited afterwards, so a definition\n * that does arrive late still upgrades and still gets watched. The error is a report, not a\n * refusal.\n */\n await Promise.resolve();\n await Promise.resolve();\n if (!customElements.get(tag)) {\n throw new Error(diagnostic('autoloader', `<${tag}> from ${src}`, 'autoloader-not-defined', __DEV__ && PROSE['autoloader-not-defined'](tag)));\n }\n await customElements.whenDefined(tag);\n failed.delete(tag);\n retries.delete(tag);\n watch(element);\n } catch (error) {\n requested.delete(tag);\n /**\n * A rejected import is retried from a fresh URL; one that loaded, or that defined its tag before its code threw,\n * keeps its own, so its code never runs twice (see `retries`).\n */\n if (!imported && !customElements.get(tag)) retries.set(tag, retries.get(tag) ?? 0);\n else retries.delete(tag);\n /**\n * Reported as a DOM event as well as a console line, because a component that never arrives\n * is something an app may want to render around — a placeholder, a retry button, a report to\n * an error tracker. An event rather than core's `'error'` insert: this package deliberately\n * does not depend on core, and reaching for `insert` from `@verajs/inserts` instead would\n * write to a registry core never reads in a production build.\n */\n element.dispatchEvent(\n new CustomEvent('vera:autoload-error', {\n bubbles: true,\n composed: true,\n detail: { tag, src, error, element },\n })\n );\n console.error('%s', diagnostic('autoloader', `<${tag}>`, 'loader-import-failed', __DEV__ && PROSE['loader-import-failed'](`<${tag}>`, src)), error);\n }\n };\n\n /** Loads one candidate, unless it has opted out. */\n const consider = (element: Element) => {\n if (element.getAttribute('data-autoload-ignore') == null) load(element, element.localName);\n };\n\n /**\n * `:not(:defined)` already means \"a custom element awaiting its definition\" — a dashless unknown\n * tag like `<madeupelement>` is defined, and an element leaves the set the moment its definition\n * lands. `tests/browser/autoloader.test.js` pins those semantics in a real engine, which is what\n * lets this trust the selector rather than re-checking the tag by hand.\n */\n const scan = (root: Element | ShadowRoot) => {\n const elements = root.querySelectorAll(':not(:defined)');\n for (let i = 0; i < elements.length; i++) consider(elements[i]);\n };\n\n /**\n * One observer for every watched root. A node added anywhere inside one is examined itself and\n * then scanned, because a subtree may arrive whole — `innerHTML` on a container delivers one\n * added node holding any number of undefined elements.\n *\n * Created on first use, not at construction. `new MutationObserver(...)` in the constructor made\n * `autoloader` throw in Node — `MutationObserver is not defined` — so an app entry that wires the\n * autoloader could not be imported server-side at all. `@verajs/router` attaches its window\n * listeners lazily for exactly this reason and says so; the observed-discovery rewrite\n * reintroduced the problem here.\n */\n let observer: MutationObserver | undefined;\n const observing = () =>\n (observer ??= new MutationObserver((records) => {\n for (const record of records) {\n /**\n * The three attributes are as much a part of discovery as insertion is. `autoloader` can be\n * put on a component that only becomes a lazy host once some state flips; `data-autoload-dir` can\n * be pointed somewhere else after a first attempt failed; `data-autoload-ignore` can be lifted.\n * Without watching them, all three needed the element to be inserted again before anything\n * noticed, which is not a thing that happens.\n */\n if (record.type === 'attributes') {\n const target = record.target as Element;\n if (record.attributeName === 'data-autoload') watch(target);\n else consider(target);\n continue;\n }\n\n const added = record.addedNodes;\n for (let i = 0; i < added.length; i++) {\n const node = added[i];\n if (node.nodeType !== 1) continue;\n const element = node as Element;\n if (!customElements.get(element.localName) && element.localName.includes('-')) consider(element);\n scan(element);\n }\n }\n }));\n\n /**\n * Starts watching a component, and takes stock of what is already inside it.\n *\n * This is what the `'render'` insert calls, so it runs on every render of every component and has\n * to be cheap when there is nothing to do: an attribute read, then a `WeakSet` check. The scan\n * happens once, when the observation starts — everything after that arrives as a mutation.\n *\n * @param target The element or shadow root to watch for undefined custom elements within, or the document for\n * every marked host on the page\n */\n const watch = (target: Element | ShadowRoot | Document = document) => {\n /**\n * `autoload()` with nothing to point at means \"every marked host on the page, right now\".\n *\n * This used to happen by itself as the autoloader was created, which was wrong twice over: it\n * fired once, so markup arriving later — fetched, stamped from a template — was never seen and\n * said nothing about it; and two autoloaders on a page each adopted every marked host and raced\n * to load the same tags from their own directories, which needed an option to switch off. As a\n * shape of a function that already exists it costs almost nothing, can be called again whenever\n * new markup lands, and leaves `autoloader` free of side effects.\n *\n * A document is recognized by `nodeType`, not by having a `body`. `document.body` is null until\n * the parser reaches it, so an `autoload()` from a classic or `async` module script in `<head>`\n * fell straight through this branch and the document was treated as a root to watch — observing\n * `document` itself, `subtree: true`. That is precisely the shape this module exists to avoid\n * (~47% on every mutation in the app, measured), it was permanent once `watched` held the\n * document, and nothing said it had happened. `nodeType` is 9 from the moment the document is.\n */\n if ((target as Document).nodeType === 9)\n return (target as Document).querySelectorAll('[data-autoload]').forEach((el) => watch(el));\n let root = target as Element | ShadowRoot;\n /**\n * An `Element` has to opt in; a `ShadowRoot` handed over directly does not, because handing it\n * over *is* the opt-in. That is the way into a third-party component whose shadow root holds\n * tags of yours — nothing else can reach it, since an observer cannot cross a shadow boundary.\n */\n if ((target as Element).getAttribute) {\n const element = target as Element;\n if (element.getAttribute('data-autoload') == null) return;\n if (element.getAttribute('data-autoload-ignore') != null) return;\n root = element.shadowRoot ?? element;\n }\n if (watched.has(root)) return;\n watched.add(root);\n observing().observe(root, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['data-autoload', 'data-autoload-dir', 'data-autoload-ignore'],\n });\n scan(root);\n };\n\n /**\n * Forgets that this element's tag failed, and tries it again.\n *\n * A failed load is otherwise permanent for the page — right for a component that does not exist,\n * wrong for one lost to a dropped connection. `vera:autoload-error` hands you the element, which\n * is what makes retrying one thing rather than re-scanning every watched root possible.\n */\n const retry = (element: Element) => {\n const tag = element.localName;\n /** Defined after all (a module that defined its tag, then threw): the element has upgraded, so watch it instead. */\n if (customElements.get(tag)) {\n failed.delete(tag);\n retries.delete(tag);\n watch(element);\n return;\n }\n /**\n * Still loading (a retry button pressed twice): the import in flight answers for both presses. Clearing its guards\n * here would import a second fresh URL, run the module twice and throw at its second `define`.\n */\n if (requested.has(tag)) return;\n const src = failed.get(tag);\n if (src) attempted.delete(src);\n failed.delete(tag);\n const tries = retries.get(tag);\n if (tries !== undefined) retries.set(tag, tries + 1);\n load(element, tag);\n };\n\n /**\n * `name` goes through `defineProperty` because a function's own `name` is non-writable, so\n * `Object.assign` throws in strict mode — and the descriptor's `name` is what the duplicate-\n * priority warning quotes, so leaving it as `\"watch\"` would name the wrong thing.\n */\n Object.defineProperty(watch, 'name', { value: '@verajs/autoloader', configurable: true });\n /**\n * The instance is also its own `wire` descriptor, so configuring the autoloader and installing it\n * are one call:\n *\n * ```js\n * wire([renderer, router, autoloader(import.meta.url, 'components')]);\n * ```\n *\n * This replaced `setAutoloader`, a bespoke registrar that lived in `@verajs/inserts` — the\n * registry package knowing about one specific consumer, which is the coupling `wire` exists to\n * remove. Every other module hands `wire` a descriptor; this one now does too.\n *\n * Priority 75 runs it *after* the renderer at 50, because it scans what the render just produced.\n */\n return Object.assign(watch, {\n url,\n retry,\n on: 'render' as const,\n fn: ((_: unknown, container: Element | ShadowRoot | Document) => {\n watch(container);\n }) as never,\n priority: 75,\n });\n};\n","/**\n * `directiveLoader` — the autoloader's answer on core's `'loader'` insert: a DIRECTIVE NAME\n * nobody has wired resolves by convention to one module URL, `{base}/{dir}/{name}.js`, exactly\n * as component tags resolve. The engine asks (design §7: directives DISCOVERS, autoloader\n * LOADS); this claims and imports; **the module registers itself** by importing\n * `wireDirectives` from the same specifier the page used — module caching makes that the same\n * registry, the precise symmetry of an autoloaded component calling `customElements.define`.\n *\n * ```js\n * import { wire } from '@verajs/core';\n * import { directiveLoader } from '@verajs/autoloader';\n * wire([directiveLoader(import.meta.url, 'directives')]);\n * ```\n *\n * A lazy module looks like:\n *\n * ```js\n * // directives/sparkle.js\n * import { wireDirectives } from '@verajs/directives';\n * wireDirectives({ name: 'sparkle', value: 'none', setup(el) { … } });\n * ```\n *\n * **The name is markup input** — it is the tail of an attribute an author (or a CMS, or an\n * attacker who can write attributes) chose — so it is allowlisted to the directive-name grammar\n * (`[a-z][a-z0-9-]*`) BEFORE any URL exists. That single gate closes the traversal and\n * encoded-separator families the component path has to police character by character, because a\n * tag name passes through the HTML parser and this does not. Containment against the entry's\n * directory is still enforced on the final URL, so an `alias` or `resolve` mistake cannot\n * escape either.\n *\n * The `alias` map is FACTORY-ONLY JavaScript (never markup — same rule as every policy option\n * in this codebase): it redirects names for grouped layouts, so `alias: { paint: 'motion.js',\n * split: 'motion.js' }` serves one bundle for a family. One attempt per name per page load,\n * exactly the autoloader's posture with URLs; the ASKER memoizes refusals, this memoizes loads.\n */\nimport type { DirectiveLoaderInstance, DirectiveLoaderOptions } from './types.js';\nimport { diagnostic, misuse, thrownMessage } from '@verajs/shared-utils';\nimport { PROSE } from './diagnostics.js';\nimport { entry } from './entry.js';\n\n/** The refusals this loader throws itself — already coded, so `load` forwards them as they are (routing). */\nconst ours = new WeakSet<object>();\nconst refuse = (message: string) => {\n const error = new Error(message);\n ours.add(error);\n return error;\n};\n\n/** The name grammar. An attribute tail that is not a plausible directive name is declined —\n * which also means it never becomes a URL. */\nconst SAFE_NAME = /^[a-z][a-z0-9-]*$/;\n\nexport const directiveLoader = (\n rootDir: string,\n directivesDir?: string,\n options?: DirectiveLoaderOptions\n): DirectiveLoaderInstance => {\n const [base, extension] = entry('directiveLoader', rootDir, options, ['extension', 'alias', 'resolve']);\n const alias = options?.alias;\n const resolve = options?.resolve;\n const dir = (directivesDir ?? '.').replace(/\\/+$/, '') || '.';\n\n /** One import per name per page load; the promise is the memo, so N elements share one fetch. */\n const claimed = new Map<string, Promise<unknown>>();\n\n /**\n * The URL this loader would fetch for a name — public for the same reason the autoloader's\n * `url` is: warming with `<link rel=\"modulepreload\">` is the whole preload story, and printing\n * it answers \"why is it fetching THAT\". Throws on a name outside the grammar or a resolution\n * outside the entry's directory, exactly as `load` refuses them.\n */\n const url = (name: string): string => {\n if (!SAFE_NAME.test(name)) {\n throw refuse(misuse('directiveLoader', 'directive-loader-name', __DEV__ && PROSE['directive-loader-name'](name)));\n }\n const target = alias?.[name] ?? (resolve ? resolve(name, dir) : `${dir}/${name}${extension}`);\n const href = new URL(target, rootDir).href;\n /**\n * Containment on the FINAL url, whichever path built it. The name grammar already forbids\n * every traversal spelling markup could carry; this is the backstop for a factory mistake —\n * an `alias` of `../../evil.js`, a `resolve` returning an absolute URL — refused rather\n * than fetched, because a loader is a thing that turns strings into same-origin module\n * execution and the entry's directory is the stated bound.\n */\n if (!href.startsWith(base)) {\n throw refuse(diagnostic('directiveLoader', `\"${name}\" ${href}`, 'loader-url-refused', __DEV__ && PROSE['loader-url-refused'](`it resolves outside ${base}`)));\n }\n return href;\n };\n\n const load = (name: string): boolean | Promise<unknown> => {\n if (!SAFE_NAME.test(name)) return false;\n const existing = claimed.get(name);\n if (existing) return existing;\n let src: string;\n try {\n src = url(name);\n } catch (error) {\n /**\n * Ours (already coded) is forwarded as it is — routing; anything else is the caller's `resolve` throwing, which\n * can throw any value at all, so it is formatted by what never throws.\n */\n if (ours.has(error as object)) console.error((error as Error).message);\n else console.error(diagnostic('directiveLoader', `\"${name}\": ${thrownMessage(error)}`, 'loader-resolve-threw', __DEV__ && PROSE['loader-resolve-threw']()));\n return false;\n }\n /**\n * The import IS the claim. Success means \"the module ran\" — whether it registered the name\n * is the ASKER's check, because only the asker owns the registry; a module that loads and\n * registers nothing earns `loader-loaded-nothing` there.\n *\n * A failure is the ASKER's to report too, and this prints nothing (2026-10-09): one failed import used to say two\n * lines — this one with the URL and the error, the engine's with the directive and its elements. The engine now\n * says one, asking `url` for the address and forwarding the import's error; a direct caller reads the address in\n * the rejection's message and the import's own error as its `cause` — the standard shape.\n */\n const request = import(/* @vite-ignore */ src).catch((error: unknown) => {\n throw new Error(src, { cause: error });\n });\n claimed.set(name, request);\n return request;\n };\n\n /** The instance is its own wire descriptor — configuring and installing are one call. */\n Object.defineProperty(load, 'name', { value: '@verajs/autoloader directiveLoader', configurable: true });\n return Object.assign(load as (name: string, element: Element) => boolean | Promise<unknown>, {\n url,\n on: 'loader' as const,\n fn: load as never,\n /** Convention answers LAST: an app's own loader (an alias shim, a manifest) registers lower. */\n priority: 75,\n });\n};\n"],"names":["SHARED.unknownOption"],"mappings":"AAAA;;;;;AAKG;AACI,MAAM,IAAI,GAAG,uBAAuB;AAiD3C;;;;;;;;;;;;;;AAcG;AACH;;;;AAIG;AACH;;;;AAIG;AACI,MAAM,MAAM,GAAG,CAAC,OAAe,EAAE,QAAgB,EAAE,QAA6C,KACrG,OAAO,IAAI;AACT,MAAE,CAAA,EAAG,OAAO,CAAA,EAAA,EAAK,QAAQ,CAAC,CAAC,CAAC,CAAA,EAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAA,CAAA,EAAI,QAAQ,CAAC,CAAC,CAAC,CAAA,CAAE,GAAG,EAAE,CAAA,EAAA,EAAK,QAAQ,CAAA,CAAA;MAC9E,GAAG,OAAO,CAAA,EAAA,EAAK,IAAI,CAAA,EAAG,QAAQ,EAAE;AAc/B,MAAM,UAAU,GAAG,CACxB,MAAc,EACd,SAAiB,EACjB,QAAgB,EAChB,QAA6C;AAE7C;AACA,OAAO,IAAI;AACT,MAAE,CAAA,OAAA,EAAU,MAAM,CAAA,EAAA,EAAK,SAAS,CAAA,GAAA,EAAM,QAAQ,CAAC,C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C,CAAC;AAC3J,YAAA,OAAO,KAAK;QACd;AACA;;;;;;;;;AASG;AACH,QAAA,MAAM,OAAO,GAAG,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,KAAI;YACtE,MAAM,IAAI,KAAK,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AACxC,QAAA,CAAC,CAAC;AACF,QAAA,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC;AAC1B,QAAA,OAAO,OAAO;AAChB,IAAA,CAAC;;AAGD,IAAA,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,oCAAoC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;AACxG,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,IAAsE,EAAE;QAC3F,GAAG;AACH,QAAA,EAAE,EAAE,QAAiB;AACrB,QAAA,EAAE,EAAE,IAAa;;AAEjB,QAAA,QAAQ,EAAE,EAAE;AACb,KAAA,CAAC;AACJ;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=(e,t,r)=>{if(!
|
|
1
|
+
const e="https://verajs.dev/e/",t=(t,r,o)=>`${t}: ${e}${r}`,r=(t,r,o,a)=>`[vera] ${t}: ${r} — ${e}${o}`,o=e=>{try{if(e instanceof Error)return String(e.message);const t=e?.message;return"string"==typeof t?t:String(e)}catch{return"[unprintable value thrown]"}},a=(e,r,o,a)=>{if(!r)throw new Error(t(e,"loader-root-required"));return[new URL(".",r).href,`.${(o?.extension??".js").replace(/^\./,"")}`]},n=(e,t,r)=>{const o=new URL(e);return"http:"!==o.protocol&&"https:"!==o.protocol&&"file:"!==o.protocol||/*@__NOINLINE__*/s(r)?e:(o.searchParams.set("vera-retry",String(t)),o.href)},s=e=>{for(const t of e.querySelectorAll('script[type="importmap"]'))try{const e=JSON.parse(t.textContent??"").integrity;if("object"==typeof e&&null!==e&&Object.keys(e).length>0)return!0}catch{}return!1},l=(e,t,s)=>{const[l,i]=a("autoloader",e,s),d=s?.resolve,c=new Set,u=new Set,f=new Map,h=new Map,w=new WeakSet,g=new WeakMap,m=(e,t,o)=>{const a=new Error(r("autoloader",`<${e}> ${t}`,"loader-url-refused"));return a.href=t,g.set(a,t),a},p=(r,o)=>{const a=(o?.getAttribute("data-autoload-dir")??t??".").replace(/\/+$/,"")||".",n=new URL(d?d(r,a):`${a}/${r}${i}`,e).href;if(!d&&/[?#]/.test(a))throw new URL(n),m(r,n);if(!d&&/%2f|%5c/i.test(a))throw m(r,n);if(!n.startsWith(l))throw m(r,n);return n},v=async(e,t)=>{if(u.has(t))return;let a;try{a=p(t,e)}catch(e){const a=g.get(e);if(void 0===a)return void console.error(r("autoloader",`<${t}>: ${o(e)}`,"loader-resolve-threw"));if(c.has(a))return;return c.add(a),void console.error(e.message)}if(c.has(a))return;c.add(a),u.add(t),f.set(t,a);const s=h.get(t);let l=!1;try{if(await import(void 0===s?a:/*@__NOINLINE__*/n(a,s,e.ownerDocument)),l=!0,await Promise.resolve(),await Promise.resolve(),!customElements.get(t))throw new Error(r("autoloader",`<${t}> from ${a}`,"autoloader-not-defined"));await customElements.whenDefined(t),f.delete(t),h.delete(t),E(e)}catch(o){u.delete(t),l||customElements.get(t)?h.delete(t):h.set(t,h.get(t)??0),e.dispatchEvent(new CustomEvent("vera:autoload-error",{bubbles:!0,composed:!0,detail:{tag:t,src:a,error:o,element:e}})),console.error("%s",r("autoloader",`<${t}>`,"loader-import-failed"),o)}},$=e=>{null==e.getAttribute("data-autoload-ignore")&&v(e,e.localName)},b=e=>{const t=e.querySelectorAll(":not(:defined)");for(let e=0;e<t.length;e++)$(t[e])};let y;const E=(e=document)=>{if(9===e.nodeType)return e.querySelectorAll("[data-autoload]").forEach((e=>E(e)));let t=e;if(e.getAttribute){const r=e;if(null==r.getAttribute("data-autoload"))return;if(null!=r.getAttribute("data-autoload-ignore"))return;t=r.shadowRoot??r}w.has(t)||(w.add(t),(y??=new MutationObserver((e=>{for(const t of e){if("attributes"===t.type){const e=t.target;"data-autoload"===t.attributeName?E(e):$(e);continue}const e=t.addedNodes;for(let t=0;t<e.length;t++){const r=e[t];if(1!==r.nodeType)continue;const o=r;!customElements.get(o.localName)&&o.localName.includes("-")&&$(o),b(o)}}}))).observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-autoload","data-autoload-dir","data-autoload-ignore"]}),b(t))};return Object.defineProperty(E,"name",{value:"@verajs/autoloader",configurable:!0}),Object.assign(E,{url:p,retry:e=>{const t=e.localName;if(customElements.get(t))return f.delete(t),h.delete(t),void E(e);if(u.has(t))return;const r=f.get(t);r&&c.delete(r),f.delete(t);const o=h.get(t);void 0!==o&&h.set(t,o+1),v(e,t)},on:"render",fn:(e,t)=>{E(t)},priority:75})},i=new WeakSet,d=e=>{const t=new Error(e);return i.add(t),t},c=/^[a-z][a-z0-9-]*$/,u=(e,n,s)=>{const[l,u]=a("directiveLoader",e,s),f=s?.alias,h=s?.resolve,w=(n??".").replace(/\/+$/,"")||".",g=new Map,m=o=>{if(!c.test(o))throw d(t("directiveLoader","directive-loader-name"));const a=f?.[o]??(h?h(o,w):`${w}/${o}${u}`),n=new URL(a,e).href;if(!n.startsWith(l))throw d(r("directiveLoader",`"${o}" ${n}`,"loader-url-refused"));return n},p=e=>{if(!c.test(e))return!1;const t=g.get(e);if(t)return t;let a;try{a=m(e)}catch(t){return i.has(t)?console.error(t.message):console.error(r("directiveLoader",`"${e}": ${o(t)}`,"loader-resolve-threw")),!1}const n=import(a).catch((e=>{throw new Error(a,{cause:e})}));return g.set(e,n),n};return Object.defineProperty(p,"name",{value:"@verajs/autoloader directiveLoader",configurable:!0}),Object.assign(p,{url:m,on:"loader",fn:p,priority:75})};export{l as autoloader,u as directiveLoader};
|
|
2
2
|
//# sourceMappingURL=vera-autoloader.min.js.map
|