@verajs/autoloader 0.1.3 → 0.2.1
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 +296 -3
- package/dist/development/vera-autoloader.d.ts +135 -19
- package/dist/development/vera-autoloader.d.ts.map +1 -1
- package/dist/development/vera-autoloader.js +592 -49
- 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 +4 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vera-autoloader.js","sources":["../../../../../../../shared-utils/src/utils.ts","../../../../../../src/autoloader.ts"],"sourcesContent":["import { GetResult, GetValueType } from '@verajs/shared-types';\n\n/**\n * Utility function for emulating .get chaining on Map prototypes for readability in the\n * signal handler function. This function checks for the existance of a key before getting it\n * and creates it if it doesn't exist.\n *\n * @param item The item to get the key for\n *\n * @returns An object with new get function to chain (g) or the items final value (v)\n */\nexport const get = <T>(item: T) => ({\n get: <K>(key: K, defaultValue: GetValueType<T>): GetResult<GetValueType<T>> => {\n if (isInstanceOf(item, Array)) {\n /** Compared against `undefined`, not truthiness — an existing `0`/`''`/`false` entry must\n * not be clobbered with the default (the falsy-check defect class from map-support). */\n if ((item as Array<GetValueType<T>>)[key as number] === undefined) {\n (item as Array<GetValueType<T>>)[key as number] = defaultValue;\n }\n return get<GetValueType<T>>((item as Array<GetValueType<T>>)[key as number]);\n } else if (isInstanceOf(item, Map) || isInstanceOf(item, WeakMap)) {\n if (!(item as Map<K, GetValueType<T>>).has(key)) {\n (item as Map<K, GetValueType<T>>).set(key, defaultValue);\n }\n return get<GetValueType<T>>((item as Map<K, GetValueType<T>>).get(key)!);\n }\n return throwError() as GetResult<GetValueType<T>>;\n },\n value: item,\n});\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 * Check if an item is an instance of a class type.\n *\n * @param item Item to check\n * @param classType Class type to check\n */\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nconst isInstanceOf = <I, C extends Function>(item: I, classType: C) => item instanceof classType;\n\n/**\n * Whether an item is a set or map\n *\n * @param item Item to check\n */\nconst KEYED_COLLECTIONS = ['map', 'set'];\nexport const isSetOrMap = <T>(item: T) => KEYED_COLLECTIONS.includes(getType(item));\n\n/**\n * Throws a minified error with an id number\n *\n * @param minifiedError Throws a minified error\n */\nexport const throwError = (minifiedError?: number): never => {\n throw new Error(minifiedError ? `Minified error: ${minifiedError}` : '');\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 * Finds the entry for `priority` in a dense, priority-sorted pair of arrays, creating one if it is\n * not there yet. `order` holds the priorities and `list` the values at matching indices.\n *\n * Priority is deliberately NOT used as an array index. Indexing by priority leaves holes — hooks at\n * 25/50/75 produce a 76-element array with 73 of them empty — and these arrays are walked on every\n * render and every write, so the holes dominated the cost.\n *\n * @param list Values, ordered by ascending priority\n * @param order Priorities, parallel to `list`\n * @param priority Priority to find or create\n * @param create Builds the value when the priority is not present yet\n * @return The existing or newly created value\n */\nexport const prioritySlot = <T>(list: T[], order: number[], priority: number, create: () => T): T => {\n let slot = 0;\n while (slot < order.length && order[slot] < priority) slot++;\n if (order[slot] === priority) return list[slot];\n\n order.splice(slot, 0, priority);\n const created = create();\n list.splice(slot, 0, created);\n return created;\n};\n","import { AutoloaderOptions } from './types.js';\nimport { Autoloader } from '@verajs/shared-types';\nimport { stripTrailingSlash } from '@verajs/shared-utils';\n\n/**\n * Inits an autoloader with the provided root directory, component directory and autoloader options.\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 \"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`\n * @return An autoloader function that should be run on desired elements each render (if lazy load elements are\n * conditionally rendered)\n */\nexport const initAutoloader = (\n rootDir: string,\n componentsDir?: string,\n options?: AutoloaderOptions\n): Autoloader => {\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 /** Normalized so callers may pass either `ts` or `.ts` */\n const extension = `.${(options?.extension ?? '.js').replace(/^\\./, '')}`;\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 `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 const base = new URL('.', rootDir).href;\n\n /**\n * One attempt per URL per page load. Without this, a file that fails to load was retried on\n * every render — console spam and a network request each time — and the same tag reached\n * through two different dirs raced to define twice.\n */\n const attempted = new Set<string>();\n\n /**\n * Creates the expected element url location to be appended to the root dir.\n *\n * The per-element override attribute is `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 * @param element The element the autoloader is discovering\n * @param tag The element's name\n * @return The element's expected location to be appended to the root dir\n */\n const elementURL = (element: Element, tag: string) => {\n const dir = stripTrailingSlash(element.getAttribute('autoload-dir') ?? componentsDir ?? '/');\n return `${dir}/${tag}${extension}`;\n };\n\n /**\n * Loads an element and then recursively calls discover on that element.\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 const src = new URL(elementURL(element, tag), rootDir).href;\n if (attempted.has(src)) return;\n attempted.add(src);\n\n if (!src.startsWith(base)) {\n console.error(`autoloader: refused ${src} for <${tag}> — resolves outside ${base}`);\n return;\n }\n\n try {\n await import(/* @vite-ignore */ src);\n await customElements.whenDefined(tag);\n discover(element);\n } catch (error) {\n console.error(`Failed to load custom element ${tag} from ${src}:`, error);\n }\n };\n\n /**\n * Finds all elements within a parent element that are not defined and attempts to load each of them\n *\n * @param element The element to look for undefined custom elements within\n */\n const discover = (element: Element) => {\n if (element.getAttribute('autoloader') == null) return;\n if (element.getAttribute('autoload-ignore') != null) return;\n const componentElement = element.shadowRoot ?? element;\n const elements = componentElement.querySelectorAll(':not(:defined)');\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n const tag = el.localName;\n if (tag?.includes('-') && !customElements.get(tag) && el.getAttribute('autoload-ignore') == null) {\n load(el, tag);\n }\n }\n };\n\n return discover;\n};\n"],"names":[],"mappings":"AAEA;;;;;;;;AAQG;AAuDH;;;;AAIG;AACI,MAAM,kBAAkB,GAAG,CAAC,GAAW,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC;;AClE9G;;;;;;;;;;;;AAYG;AACI,MAAM,cAAc,GAAG,CAC5B,OAAe,EACf,aAAsB,EACtB,OAA2B,KACb;;AAEd,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC;;AAG1F,IAAA,MAAM,SAAS,GAAG,CAAA,CAAA,EAAI,CAAC,OAAO,EAAE,SAAS,IAAI,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE;AAExE;;;;;;AAMG;IACH,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,IAAI;AAEvC;;;;AAIG;AACH,IAAA,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU;AAEnC;;;;;;;;;;AAUG;AACH,IAAA,MAAM,UAAU,GAAG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C,IAAI,IAAI;YAAE;AACrD,QAAA,MAAM,gBAAgB,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO;QACtD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,gBAAgB,CAAC;AACpE,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACxC,YAAA,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC;AACtB,YAAA,MAAM,GAAG,GAAG,EAAE,CAAC,SAAS;YACxB,IAAI,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,YAAY,CAAC,iBAAiB,CAAC,IAAI,IAAI,EAAE;AAChG,gBAAA,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC;YACf;QACF;AACF,IAAA,CAAC;AAED,IAAA,OAAO,QAAQ;AACjB;;;;"}
|
|
1
|
+
{"version":3,"file":"vera-autoloader.js","sources":["../../../shared-utils/src/diagnostic.ts","../../../shared-utils/src/diagnostics.ts","../../../shared-utils/src/utils.ts","../../src/diagnostics.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/** 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/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: `kind` is what the value was (dev-values' `attributeValueKind`); `property` is the\n * emitter's own spelling of a property binding — a template's `.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, 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","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 * **`@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 /** Three reasons, one fact — a URL this loader will not fetch (and no request is made). */\n /** The refused URL is the line's SUBJECT, so production — which prints no prose — still says which. */\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 type { AutoloaderInstance, AutoloaderOptions } from './types.js';\nimport { diagnostic, misuse, SHARED, thrownMessage } from '@verajs/shared-utils';\nimport { PROSE } from './diagnostics.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(misuse('autoloader', 'loader-root-required', __DEV__ && PROSE['loader-root-required']()));\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 * behavior, 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(diagnostic('autoloader', 'options', 'unknown-option', __DEV__ && SHARED.unknownOption(key, 'extension, resolve')));\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(misuse('autoloader', 'loader-root-not-absolute', __DEV__ && PROSE['loader-root-not-absolute'](rootDir)));\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 /**\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 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 diagnostic('autoloader', `<${tag}> ${href}`, 'loader-url-refused',\n __DEV__ && PROSE['loader-url-refused'](`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 (refusal as Error & { href: string }).href = href;\n refused.set(refusal, 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(diagnostic('autoloader', `<${tag}> ${href}`, 'loader-url-refused', __DEV__ && PROSE['loader-url-refused'](`an encoded path separator in \"${dir}\"`)));\n (refusal as Error & { href: string }).href = href;\n refused.set(refusal, 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(diagnostic('autoloader', `<${tag}> ${href}`, 'loader-url-refused', __DEV__ && PROSE['loader-url-refused'](`it resolves outside ${base}`)));\n (refusal as Error & { href: string }).href = href;\n refused.set(refusal, 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 = 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\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(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 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('%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 /**\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 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 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';\nimport { diagnostic, misuse, SHARED, thrownMessage } from '@verajs/shared-utils';\nimport { PROSE } from './diagnostics.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 if (!rootDir) throw new Error(misuse('directiveLoader', 'loader-root-required', __DEV__ && PROSE['loader-root-required']()));\n if (__DEV__) {\n try {\n new URL('.', rootDir);\n } catch {\n throw new Error(misuse('directiveLoader', '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 (key !== 'extension' && key !== 'alias' && key !== 'resolve')\n console.warn(diagnostic('directiveLoader', 'options', 'unknown-option', __DEV__ && SHARED.unknownOption(key, 'extension, alias, resolve')));\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 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 /** `url` runs the caller's `resolve`, which can throw any value at all: formatted by what never throws. */\n /** Ours (already coded) is forwarded as it is — routing; anything else is the caller's `resolve` throwing. */\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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K,EAAE;;;AAGd,YAAA,IAAI,IAAI,CAAC,GAAG,CAAC,KAAe,CAAC;AAAE,gBAAA,OAAO,CAAC,KAAK,CAAE,KAAe,CAAC,OAAO,CAAC;;gBACjE,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAA,CAAA,EAAI,IAAI,CAAA,GAAA,EAAM,aAAa,CAAC,KAAK,CAAC,CAAA,CAAE,EAAE,sBAAsB,EAAE,OAAO,IAAI,KAAK,CAAC,sBAAsB,CAAC,EAAE,CAAC,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=
|
|
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,a,n)=>{if(!e)throw new Error(t("autoloader","loader-root-required"));const s=`.${(n?.extension??".js").replace(/^\./,"")}`,l=n?.resolve,d=new URL(".",e).href,i=new Set,u=new Set,c=new Map,f=new WeakSet,w=new WeakMap,h=(t,o)=>{const n=(o?.getAttribute("data-autoload-dir")??a??".").replace(/\/+$/,"")||".",i=new URL(l?l(t,n):`${n}/${t}${s}`,e).href;if(!l&&/[?#]/.test(n)){new URL(i);const e=new Error(r("autoloader",`<${t}> ${i}`,"loader-url-refused"));throw e.href=i,w.set(e,i),e}if(!l&&/%2f|%5c/i.test(n)){const e=new Error(r("autoloader",`<${t}> ${i}`,"loader-url-refused"));throw e.href=i,w.set(e,i),e}if(!i.startsWith(d)){const e=new Error(r("autoloader",`<${t}> ${i}`,"loader-url-refused"));throw e.href=i,w.set(e,i),e}return i},$=async(e,t)=>{if(u.has(t))return;let a;try{a=h(t,e)}catch(e){const a=w.get(e);if(void 0===a)return void console.error(r("autoloader",`<${t}>: ${o(e)}`,"loader-resolve-threw"));if(i.has(a))return;return i.add(a),void console.error(e.message)}if(!i.has(a)){i.add(a),u.add(t),c.set(t,a);try{if(await import(a),await Promise.resolve(),await Promise.resolve(),!customElements.get(t))throw new Error(r("autoloader",`<${t}> from ${a}`,"autoloader-not-defined"));await customElements.whenDefined(t),c.delete(t),p(e)}catch(o){u.delete(t),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)}}},g=e=>{null==e.getAttribute("data-autoload-ignore")&&$(e,e.localName)},m=e=>{const t=e.querySelectorAll(":not(:defined)");for(let e=0;e<t.length;e++)g(t[e])};let v;const p=(e=document)=>{if(9===e.nodeType)return e.querySelectorAll("[data-autoload]").forEach((e=>p(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}f.has(t)||(f.add(t),(v??=new MutationObserver((e=>{for(const t of e){if("attributes"===t.type){const e=t.target;"data-autoload"===t.attributeName?p(e):g(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("-")&&g(o),m(o)}}}))).observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-autoload","data-autoload-dir","data-autoload-ignore"]}),m(t))};return Object.defineProperty(p,"name",{value:"@verajs/autoloader",configurable:!0}),Object.assign(p,{url:h,retry:e=>{const t=e.localName;u.delete(t);const r=c.get(t);r&&i.delete(r),c.delete(t),$(e,t)},on:"render",fn:(e,t)=>{p(t)},priority:75})},n=new WeakSet,s=e=>{const t=new Error(e);return n.add(t),t},l=/^[a-z][a-z0-9-]*$/,d=(e,a,d)=>{if(!e)throw new Error(t("directiveLoader","loader-root-required"));const i=new URL(".",e).href,u=`.${(d?.extension??".js").replace(/^\./,"")}`,c=d?.alias,f=d?.resolve,w=(a??".").replace(/\/+$/,"")||".",h=new Map,$=o=>{if(!l.test(o))throw s(t("directiveLoader","directive-loader-name"));const a=c?.[o]??(f?f(o,w):`${w}/${o}${u}`),n=new URL(a,e).href;if(!n.startsWith(i))throw s(r("directiveLoader",`"${o}" ${n}`,"loader-url-refused"));return n},g=e=>{if(!l.test(e))return!1;const t=h.get(e);if(t)return t;let a;try{a=$(e)}catch(t){return n.has(t)?console.error(t.message):console.error(r("directiveLoader",`"${e}": ${o(t)}`,"loader-resolve-threw")),!1}const s=import(a).catch((e=>{throw new Error(a,{cause:e})}));return h.set(e,s),s};return Object.defineProperty(g,"name",{value:"@verajs/autoloader directiveLoader",configurable:!0}),Object.assign(g,{url:$,on:"loader",fn:g,priority:75})};export{a as autoloader,d as directiveLoader};
|
|
2
2
|
//# sourceMappingURL=vera-autoloader.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vera-autoloader.min.js","sources":["../../../../../shared-utils/src/utils.ts","../../../../src/autoloader.ts"],"sourcesContent":["import { GetResult, GetValueType } from '@verajs/shared-types';\n\n/**\n * Utility function for emulating .get chaining on Map prototypes for readability in the\n * signal handler function. This function checks for the existance of a key before getting it\n * and creates it if it doesn't exist.\n *\n * @param item The item to get the key for\n *\n * @returns An object with new get function to chain (g) or the items final value (v)\n */\nexport const get = <T>(item: T) => ({\n get: <K>(key: K, defaultValue: GetValueType<T>): GetResult<GetValueType<T>> => {\n if (isInstanceOf(item, Array)) {\n /** Compared against `undefined`, not truthiness — an existing `0`/`''`/`false` entry must\n * not be clobbered with the default (the falsy-check defect class from map-support). */\n if ((item as Array<GetValueType<T>>)[key as number] === undefined) {\n (item as Array<GetValueType<T>>)[key as number] = defaultValue;\n }\n return get<GetValueType<T>>((item as Array<GetValueType<T>>)[key as number]);\n } else if (isInstanceOf(item, Map) || isInstanceOf(item, WeakMap)) {\n if (!(item as Map<K, GetValueType<T>>).has(key)) {\n (item as Map<K, GetValueType<T>>).set(key, defaultValue);\n }\n return get<GetValueType<T>>((item as Map<K, GetValueType<T>>).get(key)!);\n }\n return throwError() as GetResult<GetValueType<T>>;\n },\n value: item,\n});\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 * Check if an item is an instance of a class type.\n *\n * @param item Item to check\n * @param classType Class type to check\n */\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nconst isInstanceOf = <I, C extends Function>(item: I, classType: C) => item instanceof classType;\n\n/**\n * Whether an item is a set or map\n *\n * @param item Item to check\n */\nconst KEYED_COLLECTIONS = ['map', 'set'];\nexport const isSetOrMap = <T>(item: T) => KEYED_COLLECTIONS.includes(getType(item));\n\n/**\n * Throws a minified error with an id number\n *\n * @param minifiedError Throws a minified error\n */\nexport const throwError = (minifiedError?: number): never => {\n throw new Error(minifiedError ? `Minified error: ${minifiedError}` : '');\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 * Finds the entry for `priority` in a dense, priority-sorted pair of arrays, creating one if it is\n * not there yet. `order` holds the priorities and `list` the values at matching indices.\n *\n * Priority is deliberately NOT used as an array index. Indexing by priority leaves holes — hooks at\n * 25/50/75 produce a 76-element array with 73 of them empty — and these arrays are walked on every\n * render and every write, so the holes dominated the cost.\n *\n * @param list Values, ordered by ascending priority\n * @param order Priorities, parallel to `list`\n * @param priority Priority to find or create\n * @param create Builds the value when the priority is not present yet\n * @return The existing or newly created value\n */\nexport const prioritySlot = <T>(list: T[], order: number[], priority: number, create: () => T): T => {\n let slot = 0;\n while (slot < order.length && order[slot] < priority) slot++;\n if (order[slot] === priority) return list[slot];\n\n order.splice(slot, 0, priority);\n const created = create();\n list.splice(slot, 0, created);\n return created;\n};\n","import { AutoloaderOptions } from './types.js';\nimport { Autoloader } from '@verajs/shared-types';\nimport { stripTrailingSlash } from '@verajs/shared-utils';\n\n/**\n * Inits an autoloader with the provided root directory, component directory and autoloader options.\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 \"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`\n * @return An autoloader function that should be run on desired elements each render (if lazy load elements are\n * conditionally rendered)\n */\nexport const initAutoloader = (\n rootDir: string,\n componentsDir?: string,\n options?: AutoloaderOptions\n): Autoloader => {\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 /** Normalized so callers may pass either `ts` or `.ts` */\n const extension = `.${(options?.extension ?? '.js').replace(/^\\./, '')}`;\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 `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 const base = new URL('.', rootDir).href;\n\n /**\n * One attempt per URL per page load. Without this, a file that fails to load was retried on\n * every render — console spam and a network request each time — and the same tag reached\n * through two different dirs raced to define twice.\n */\n const attempted = new Set<string>();\n\n /**\n * Creates the expected element url location to be appended to the root dir.\n *\n * The per-element override attribute is `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 * @param element The element the autoloader is discovering\n * @param tag The element's name\n * @return The element's expected location to be appended to the root dir\n */\n const elementURL = (element: Element, tag: string) => {\n const dir = stripTrailingSlash(element.getAttribute('autoload-dir') ?? componentsDir ?? '/');\n return `${dir}/${tag}${extension}`;\n };\n\n /**\n * Loads an element and then recursively calls discover on that element.\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 const src = new URL(elementURL(element, tag), rootDir).href;\n if (attempted.has(src)) return;\n attempted.add(src);\n\n if (!src.startsWith(base)) {\n console.error(`autoloader: refused ${src} for <${tag}> — resolves outside ${base}`);\n return;\n }\n\n try {\n await import(/* @vite-ignore */ src);\n await customElements.whenDefined(tag);\n discover(element);\n } catch (error) {\n console.error(`Failed to load custom element ${tag} from ${src}:`, error);\n }\n };\n\n /**\n * Finds all elements within a parent element that are not defined and attempts to load each of them\n *\n * @param element The element to look for undefined custom elements within\n */\n const discover = (element: Element) => {\n if (element.getAttribute('autoloader') == null) return;\n if (element.getAttribute('autoload-ignore') != null) return;\n const componentElement = element.shadowRoot ?? element;\n const elements = componentElement.querySelectorAll(':not(:defined)');\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n const tag = el.localName;\n if (tag?.includes('-') && !customElements.get(tag) && el.getAttribute('autoload-ignore') == null) {\n load(el, tag);\n }\n }\n };\n\n return discover;\n};\n"],"names":["initAutoloader","rootDir","componentsDir","options","Error","extension","replace","base","URL","href","attempted","Set","load","async","element","tag","src","str","getAttribute","endsWith","slice","elementURL","has","add","startsWith","import","customElements","whenDefined","discover","error","console","elements","shadowRoot","querySelectorAll","i","length","el","localName","includes","get"],"mappings":"AAsEO,MCrDMA,EAAiB,CAC5BC,EACAC,EACAC,KAGA,IAAKF,EAAS,MAAM,IAAIG,MAAM,6DAG9B,MAAMC,EAAY,KAAKF,GAASE,WAAa,OAAOC,QAAQ,MAAO,MAS7DC,EAAO,IAAIC,IAAI,IAAKP,GAASQ,KAO7BC,EAAY,IAAIC,IAwBhBC,EAAOC,MAAOC,EAAkBC,KACpC,MAAMC,EAAM,IAAIR,IAZC,EAACM,EAAkBC,KDeN,IAACE,ECb/B,MAAO,GDaiD,OAAzBA,ECdAH,EAAQI,aAAa,iBAAmBhB,GAAiB,MDczBe,EAAIE,SAAS,KAAOF,EAAIG,MAAM,GAAG,GAAMH,KCbrFF,IAAMV,GAAW,EAUdgB,CAAWP,EAASC,GAAMd,GAASQ,KACvD,IAAIC,EAAUY,IAAIN,GAGlB,GAFAN,EAAUa,IAAIP,GAETA,EAAIQ,WAAWjB,GAKpB,UACQkB,OAA0BT,SAC1BU,eAAeC,YAAYZ,GACjCa,EAASd,EACX,CAAE,MAAOe,GACPC,QAAQD,MAAM,iCAAiCd,UAAYC,KAAQa,EACrE,MAVEC,QAAQD,MAAM,uBAAuBb,UAAYD,yBAA2BR,IAU9E,EAQIqB,EAAYd,IAChB,GAA0C,MAAtCA,EAAQI,aAAa,cAAuB,OAChD,GAA+C,MAA3CJ,EAAQI,aAAa,mBAA4B,OACrD,MACMa,GADmBjB,EAAQkB,YAAclB,GACbmB,iBAAiB,kBACnD,IAAK,IAAIC,EAAI,EAAGA,EAAIH,EAASI,OAAQD,IAAK,CACxC,MAAME,EAAKL,EAASG,GACdnB,EAAMqB,EAAGC,UACXtB,GAAKuB,SAAS,OAASZ,eAAea,IAAIxB,IAA8C,MAAtCqB,EAAGlB,aAAa,oBACpEN,EAAKwB,EAAIrB,EAEb,GAGF,OAAOa,CAAQ"}
|
|
1
|
+
{"version":3,"file":"vera-autoloader.min.js","sources":["../../shared-utils/src/diagnostic.ts","../../shared-utils/src/utils.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","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","import type { AutoloaderInstance, AutoloaderOptions } from './types.js';\nimport { diagnostic, misuse, SHARED, thrownMessage } from '@verajs/shared-utils';\nimport { PROSE } from './diagnostics.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(misuse('autoloader', 'loader-root-required', __DEV__ && PROSE['loader-root-required']()));\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 * behavior, 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(diagnostic('autoloader', 'options', 'unknown-option', __DEV__ && SHARED.unknownOption(key, 'extension, resolve')));\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(misuse('autoloader', 'loader-root-not-absolute', __DEV__ && PROSE['loader-root-not-absolute'](rootDir)));\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 /**\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 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 diagnostic('autoloader', `<${tag}> ${href}`, 'loader-url-refused',\n __DEV__ && PROSE['loader-url-refused'](`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 (refusal as Error & { href: string }).href = href;\n refused.set(refusal, 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(diagnostic('autoloader', `<${tag}> ${href}`, 'loader-url-refused', __DEV__ && PROSE['loader-url-refused'](`an encoded path separator in \"${dir}\"`)));\n (refusal as Error & { href: string }).href = href;\n refused.set(refusal, 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(diagnostic('autoloader', `<${tag}> ${href}`, 'loader-url-refused', __DEV__ && PROSE['loader-url-refused'](`it resolves outside ${base}`)));\n (refusal as Error & { href: string }).href = href;\n refused.set(refusal, 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 = 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\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(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 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('%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 /**\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 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 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';\nimport { diagnostic, misuse, SHARED, thrownMessage } from '@verajs/shared-utils';\nimport { PROSE } from './diagnostics.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 if (!rootDir) throw new Error(misuse('directiveLoader', 'loader-root-required', __DEV__ && PROSE['loader-root-required']()));\n if (__DEV__) {\n try {\n new URL('.', rootDir);\n } catch {\n throw new Error(misuse('directiveLoader', '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 (key !== 'extension' && key !== 'alias' && key !== 'resolve')\n console.warn(diagnostic('directiveLoader', 'options', 'unknown-option', __DEV__ && SHARED.unknownOption(key, 'extension, alias, resolve')));\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 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 /** `url` runs the caller's `resolve`, which can throw any value at all: formatted by what never throws. */\n /** Ours (already coded) is forwarded as it is — routing; anything else is the caller's `resolve` throwing. */\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":["DOCS","misuse","forName","withCode","andProse","diagnostic","inArea","bySubject","thrownMessage","error","Error","String","message","autoloader","rootDir","componentsDir","options","extension","replace","resolve","base","URL","href","attempted","Set","requested","failed","Map","watched","WeakSet","refused","WeakMap","url","tag","element","dir","getAttribute","test","refusal","set","startsWith","load","async","has","src","get","undefined","console","add","import","Promise","customElements","whenDefined","delete","watch","dispatchEvent","CustomEvent","bubbles","composed","detail","consider","localName","scan","root","elements","querySelectorAll","i","length","observer","target","document","nodeType","forEach","el","shadowRoot","MutationObserver","records","record","type","attributeName","added","addedNodes","node","includes","observe","childList","subtree","attributes","attributeFilter","Object","defineProperty","value","configurable","assign","retry","on","fn","_","container","priority","ours","refuse","SAFE_NAME","directiveLoader","directivesDir","alias","claimed","name","existing","request","catch","cause"],"mappings":"AAMO,MAAMA,EAAO,wBA0EPC,EAAS,CAACC,EAAiBC,EAAkBC,IAGpD,GAAGF,MAAYF,IAAOG,IAcfE,EAAa,CACxBC,EACAC,EACAJ,EACAC,IAKI,UAAUE,MAAWC,OAAeP,IAAOG,IC+BpCK,EAAiBC,IAC5B,IACE,GAAIA,aAAiBC,MAAO,OAAOC,OAAOF,EAAMG,SAChD,MAAMA,EAAWH,GAAwCG,QACzD,MAA0B,iBAAZA,EAAuBA,EAAUD,OAAOF,EACxD,CAAE,MACA,MAAO,4BACT,GChHWI,EAAa,CACxBC,EACAC,EACAC,KAGA,IAAKF,EAAS,MAAM,IAAIJ,MAAMT,EAAO,aAAc,yBAenD,MAAMgB,EAAY,KAAKD,GAASC,WAAa,OAAOC,QAAQ,MAAO,MAS7DC,EAAUH,GAASG,QAwBnBC,EAAO,IAAIC,IAAI,IAAKP,GAASQ,KAG7BC,EAAY,IAAIC,IAWhBC,EAAY,IAAID,IAGhBE,EAAS,IAAIC,IAUbC,EAAU,IAAIC,QAwBdC,EAAU,IAAIC,QACdC,EAAM,CAACC,EAAaC,KAUxB,MAAMC,GAAOD,GAASE,aAAa,sBAAwBrB,GAAiB,KAAKG,QAAQ,OAAQ,KAAO,IAClGI,EAAO,IAAID,I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UjE,KAAKsE,GAClB,MAAMN,EAAOpG,EAAO,kBAAmB,0BAEzC,MAAMoE,EAASoC,IAAQE,KAAUxF,EAAUA,EAAQwF,EAAMxE,GAAO,GAAGA,KAAOwE,IAAO1F,KAC3EK,EAAO,IAAID,IAAIgD,EAAQvD,GAASQ,KAQtC,IAAKA,EAAKkB,WAAWpB,GACnB,MAAMiF,EAAOhG,EAAW,kBAAmB,IAAIsG,MAASrF,IAAQ,uBAElE,OAAOA,CAAI,EAGPmB,EAAQkE,IACZ,IAAKL,EAAUjE,KAAKsE,GAAO,OAAO,EAClC,MAAMC,EAAWF,EAAQ7D,IAAI8D,GAC7B,GAAIC,EAAU,OAAOA,EACrB,IAAIhE,EACJ,IACEA,EAAMZ,EAAI2E,EACZ,CAAE,MAAOlG,GAKP,OAFI2F,EAAKzD,IAAIlC,GAAkBsC,QAAQtC,MAAOA,EAAgBG,SACzDmC,QAAQtC,MAAMJ,EAAW,kBAAmB,IAAIsG,OAAUnG,EAAcC,KAAU,0BAChF,CACT,CAWA,MAAMoG,EAAU5D,OAA0BL,GAAKkE,OAAOrG,IACpD,MAAM,IAAIC,MAAMkC,EAAK,CAAEmE,MAAOtG,GAAQ,IAGxC,OADAiG,EAAQnE,IAAIoE,EAAME,GACXA,CAAO,EAKhB,OADApB,OAAOC,eAAejD,EAAM,OAAQ,CAAEkD,MAAO,qCAAsCC,cAAc,IAC1FH,OAAOI,OAAOpD,EAAwE,CAC3FT,MACA+D,GAAI,SACJC,GAAIvD,EAEJ0D,SAAU,IACV"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verajs/autoloader",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"description": "A super small but powerful autoloader for web components that works great with VeraJs but can be used without.",
|
|
8
8
|
"license": "MIT",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=20"
|
|
11
|
+
},
|
|
9
12
|
"repository": {
|
|
10
13
|
"type": "git",
|
|
11
14
|
"url": "git+https://github.com/vera-js/vera.git",
|