kerfjs 5.0.0-beta.124 → 5.0.0-beta.125
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/CHANGELOG.md +4 -0
- package/ai/manifest.json +1 -1
- package/dist/actions.js +1 -1
- package/dist/{chunk-XL35DIZ2.js → chunk-4P6Z33YK.js} +2 -2
- package/dist/{chunk-XL35DIZ2.js.map → chunk-4P6Z33YK.js.map} +1 -1
- package/dist/{chunk-ZZI5NJIV.js → chunk-AP2FT33F.js} +6 -5
- package/dist/chunk-AP2FT33F.js.map +1 -0
- package/dist/{chunk-MFRXN2G4.js → chunk-LE324N5S.js} +51 -131
- package/dist/chunk-LE324N5S.js.map +1 -0
- package/dist/{chunk-6LXUC4ZY.js → chunk-NRPLVJVR.js} +16 -14
- package/dist/chunk-NRPLVJVR.js.map +1 -0
- package/dist/dev.js +1 -1
- package/dist/html.js +1 -1
- package/dist/index.js +3 -3
- package/dist/jsx-runtime.js +1 -1
- package/dist/list.js +1 -1
- package/dist/overlay.js +3 -3
- package/dist/remount.js +1 -1
- package/dist/router.js +2 -2
- package/dist/scope.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-6LXUC4ZY.js.map +0 -1
- package/dist/chunk-MFRXN2G4.js.map +0 -1
- package/dist/chunk-ZZI5NJIV.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
12
12
|
|
|
13
13
|
### Added
|
|
14
14
|
|
|
15
|
+
- **Kerf UI `Gauge` (KF-Y0XT2R).** `@kerfjs/ui/gauge` is a speedometer-style dial for a live rate or level read at a glance: a 240-degree track, a fill, and a needle scaled to `max`, as a named `role="meter"`. `variant="full"` (88px by default) adds ticks and the value and `unit` inside the dial; `variant="bare"` (40px) is the arc, fill, and needle at chip height with a hover title. Values above `max` pin the needle while the text shows the real value. `tone` colors the fill, `size` takes a `CssLength`, and `colors` takes typed `CssColor` values for a consumer palette. The needle and fill animate only on a value change and hold still under reduced motion.
|
|
16
|
+
- **Kerf UI `SegmentedControl` choice count badges (KF-170258).** A `SegmentedControlChoice` takes `badge` (a count, short text, or `true` for a dot), `badgeTone` (default `danger`), and `badgeMax` (default 99, so 128 shows "99+"), the same contract as `ToolbarButton`, so a toolbar view switcher can show a live count without app CSS or giving up its exclusive selection. A count of 0 or empty text shows nothing, and a loading `placeholder` shows no badge. The badge is `aria-hidden`; name the count in the choice's `label` and `title`. Kerf seats it on the segment's top edge over its icon and rings it in the segment's current fill (at rest, hover, or selected), and it never leaves the segment, so neither a toolbar nor a filled track clips it.
|
|
15
17
|
- **Kerf UI `ToolbarButton` count badges (KF-HDQTVV).** A ToolbarControlGroup button takes `badge` (a count, short text, or `true` for a dot), `badgeTone` (default `danger`), and `badgeMax` (default 99, so 128 shows "99+"). A count of 0 or empty text shows no badge. Kerf owns the pill's placement just over the icon's top-trailing corner, a 2px ring against the group's surface (the page surface for a borderless group), and 16px sizing at both group sizes, so apps no longer position a `Badge` with their own CSS. A Toolbar zone holding one stops clipping it, because WebKit cut its top off flat. The badge is `aria-hidden`, so the caller names the count in `ariaLabel` and `title` ("Workers, 2 live"). It is plain data, so the Kerf UI editor can author it. The ToolbarControlGroup demo's Corner Count example shows 0, 2, 99+, and a dot at default and compact sizes.
|
|
16
18
|
- **Kerf UI `SummaryRow` `action` (KF-YT6A0N).** A SummaryRow option takes an `action` prop, rendered as `data-action`, as ContentItem and ListItem do. A view document can now name the action a row fires, so the editor's play mode logs it (and hands it to the app's play handler) when the row is clicked or chosen with Enter or Space. A `data-action` in `rootAttributes` still works; `action` wins when both are set. Group rows (`semanticRole="group"`) take no `action`.
|
|
17
19
|
- **The Kerf UI editor's New starts with no root; the root can be deleted (KF-PK3GVY).** New, and the editor's first draft when the host passes no document, no longer seed a Pane. The canvas shows "Start with a component" with a component picker (Pane first) and Add, and the Outline says "No components yet". The chosen component becomes the root, seeded as Replace the root seeds it (a Pane starts with `fill`), and a component dragged from Components onto the empty canvas, or a pasted copy, becomes the root the same way. The root can now be deleted from the Inspector, the context menu, or the Delete key: the document goes back to having no root, keeps its params, slots, and name, and one Undo restores the tree. Replace the root stays as a shortcut. **File format:** `root` is now optional in `kerf-ui-document/v1` (`ui/ai/view-document.schema.json`, `ViewDocument.root?`), so an empty draft autosaves and saves as a document with no `root` field. `validateView` reports it as the new `KUI-V017` ("the document has no root"), so `generateView`, `interpretView`, and `kerf-ui-view` refuse it with that diagnostic, and `previewView` renders nothing.
|
|
@@ -257,6 +259,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
257
259
|
|
|
258
260
|
### Changed
|
|
259
261
|
|
|
262
|
+
- **A smaller kerf core (KF-DK0B7T).** Both list reconcilers share one bulk row parse and row-contract diagnosis, `each()` renders rows through one helper, and `mount()` walks for nested mounts more briefly. The main entry drops from 15.30 to 15.11 KB min+gzip with no behavior change, and the size budgets ratchet down to hold the gain.
|
|
260
263
|
- **Kerf UI `TabNavigator` tab badges hide a zero count and cap at `badgeMax` (KF-0V773N).** A tab `badge` of 0 or less now renders no badge (and adds nothing to the tab's name), and a count past the new per-tab `badgeMax` (default 99) shows `99+`, using the same helper as `Button` and `ToolbarButton`. Text is still trimmed and shown as written, and non-finite numbers still render nothing. **Behavior change:** a tab that passed `badge: 0` to show a "0" now shows no badge; pass the text `"0"` to keep it.
|
|
261
264
|
- **Kerf UI `Button` badges hide a zero count and cap at `badgeMax` (KF-78EZ8Q).** A `Button` `badge` of 0 or less, or empty text, now renders no badge, and a count past the new `badgeMax` (default 99) shows `99+`, the same rules as `ToolbarButton` (one shared helper, so they cannot drift). `badgeLabel` joins the button's accessible name only while the badge shows. **Behavior change:** a caller that passes `badge={0}` on purpose to show a "0" now gets no badge; pass the text `"0"` to keep it.
|
|
262
265
|
- **AI guidance stops steering toward Web Awesome.** The Kerf skill and Cursor rules (`kerf-skill-version` 1.29.0 / 1.25.0) name the `scheme` prop and `.kui-*` scopes, scope the `webawesome.css` paragraph to the optional integration, and no longer describe `Select` as Web Awesome markup. The `@kerfjs/ui` catalog guidance sends a plain action to `Button` and an ordinary form field to a multiline `TextField` instead of `wa-button` / `wa-textarea`, and the UI skill (1.71.0) labels its `--wa-*` tips as integration-only (`KF-XNKQPX`).
|
|
@@ -323,6 +326,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
323
326
|
|
|
324
327
|
### Fixed
|
|
325
328
|
|
|
329
|
+
- **`delegate()` re-resolves a stopped event object re-dispatched on another path (KF-50DWVS).** The dispatch snapshot now records the propagation path it was taken on. When code stops a dispatch and then re-dispatches the same `Event` object on another target, or after its target moved, later kerf listeners resolve against the new path instead of consuming entries resolved against the first dispatch's DOM. Cost: about 0.03 KB min+gzip.
|
|
326
330
|
- **Kerf UI `TabBar`: intrinsic tabs shrink with an ellipsized name before the strip scrolls (KF-VQ1Z8H).** Each `TabBarItem` in an intrinsic strip used to stay at its full width (`min-width: max-content`), so a narrowing bar only narrowed the tab scroller and cut a tab off mid-word at its edge, with no ellipsis. A tab now gives up width by ellipsizing its name down to a minimum of its chrome plus a few characters, and the strip scrolls only once every tab is at that minimum. Leading, trailing, and end zones still never shrink, and a wide bar where everything fits lays out exactly as before: a name shorter than the minimum never widens. The name now sits in a new `kui-tab-bar-item__label`, which sizes it from a hidden generated copy, so the visible name is still the only accessible name. `wireTabBars` gives a truncated tab its full name as a `title` on hover. `nameOverflow="visible"`, placeholder, icon-only, and fill-allocation tabs keep their previous geometry.
|
|
327
331
|
- **Kerf UI `PagedView` keeps its page when its region resizes (KF-W093WV).** `wirePagedViews` now realigns each viewport to its rendered page whenever the viewport resizes, instead of relying on the browser to re-snap. Before, Firefox could be left between pages after a resizable sidebar widened again, and the offset a resize left could be reported to `onPageChange` as if the person had chosen another page.
|
|
328
332
|
- **Kerf UI editor play mode runs the ContentItem and SummaryRow keyboard (KF-963DMT).** Play now installs `wireContentItems` and `wireSummaryRows`, so a played `List selectionMode` listbox or grid is one Tab stop, the arrows and Home/End move focus, and Enter/Space activate the focused option, sending a ContentItem's `action` to the action log as a shipped app does. Media cards also get their load and tint state. `wireContentItems` is now in the component catalog as optional ContentItem wiring, so catalog tooling knows about it.
|
package/ai/manifest.json
CHANGED
package/dist/actions.js
CHANGED
|
@@ -615,6 +615,6 @@ function _renderAttrVerbatim(name, value, tag) {
|
|
|
615
615
|
return renderAttrNamed(name, name, value, tag);
|
|
616
616
|
}
|
|
617
617
|
|
|
618
|
-
export { Fragment, ROW_TEXT_PREFIX, SafeHtml, TEXT_MARKER_PREFIX, _renderAttrVerbatim, _setBindingContext, _toSegment, assertEmittableAttrName, bindAttr, bindMarkerAttr, boundTextNodeOf, captureRowBindings, carryOrRewireRowBindings, disposeRowBindings, escapeHtml, granularListSafeHtml, isSafeHtml, jsx, listSafeHtml, newBindingContext, raw, syncFormProp, wireBindings, wireRowBindings };
|
|
618
|
+
export { Fragment, ROW_TEXT_PREFIX, SafeHtml, TEXT_MARKER_PREFIX, _renderAttrVerbatim, _setBindingContext, _toSegment, assertEmittableAttrName, bindAttr, bindMarkerAttr, boundTextNodeOf, captureRowBindings, carryOrRewireRowBindings, coerceText, disposeRowBindings, escapeHtml, granularListSafeHtml, isSafeHtml, jsx, listSafeHtml, newBindingContext, raw, syncFormProp, wireBindings, wireRowBindings };
|
|
619
619
|
|
|
620
|
-
//# sourceMappingURL=chunk-
|
|
620
|
+
//# sourceMappingURL=chunk-4P6Z33YK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/syncFormProp.ts","../src/utils/url-screen.ts","../src/bindings.ts","../src/utils/escapeHtml.ts","../src/utils/jsx-attr-aliases.ts","../src/jsx-runtime.ts"],"names":["context","SAFE_HTML_BRAND"],"mappings":";;;;;AAgCO,SAAS,YAAA,CACd,EAAA,EACA,IAAA,EACA,KAAA,EACA,OAAA,EACM;AACN,EAAA,MAAM,MAAM,EAAA,CAAG,OAAA;A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gB,KAAK,OAAA,CAAQ,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA,CAAA;AAEvD,EAAA,IAAI,SAAA,CAAU,GAAA,CAAI,GAAG,CAAA,EAAG,OAAO,IAAI,QAAA,CAAS,CAAA,CAAA,EAAI,GAAG,CAAA,EAAG,OAAO,CAAA,CAAA,CAAG,CAAA;AAEhE,EAAA,MAAM,YAAA,GACJ,QAAA,IAAY,IAAA,GAAO,SAAA,CAAU,QAAQ,IAAI,EAAE,IAAA,EAAM,QAAA,EAAU,IAAA,EAAM,EAAA,EAAG;AACtE,EAAA,OAAO,IAAI,QAAA;AAAA,IACT,YAAA,CAAa,cAAc,CAAA,CAAA,EAAI,GAAG,GAAG,OAAO,CAAA,CAAA,CAAA,EAAK,CAAA,EAAA,EAAK,GAAG,CAAA,CAAA,CAAG;AAAA,GAC9D;AACF;AAQO,SAAS,QAAA,CAAS,EAAE,QAAA,EAAS,EAAyC;AAC3E,EAAA,OAAO,IAAI,QAAA;AAAA,IACT,QAAA,IAAY,OAAO,SAAA,CAAU,QAAQ,IAAI,EAAE,IAAA,EAAM,QAAA,EAAU,IAAA,EAAM,EAAA;AAAG,GACtE;AACF;AAyCO,SAAS,WAAW,KAAA,EAAyB;AAClD,EAAA,OAAO,UAAU,KAAoB,CAAA;AACvC;AAEO,SAAS,mBAAA,CACd,IAAA,EACA,KAAA,EACA,GAAA,EACQ;AACR,EAAA,OAAO,eAAA,CAAgB,IAAA,EAAM,IAAA,EAAM,KAAA,EAAO,GAAG,CAAA;AAC/C","file":"chunk-XL35DIZ2.js","sourcesContent":["/**\n * Form-state property sync — shared by the morph's attribute writer and the\n * fine-grained binding writer (KF-335: controlled checked/value/selected went\n * stale after user interaction).\n *\n * Browsers detach a form control's live property from its attribute once the\n * control is \"dirty\" (the user — or script — has touched it): the attribute\n * becomes only the *default*. An attribute-only reconciler therefore updates\n * `checked=\"\"` / `value=\"…\"` / `selected=\"\"` while the visible state stays\n * stale.\n *\n * The rule: callers invoke this ONLY at the moment they actually MUTATE one of\n * these attributes (set, change, or remove). The property then follows the\n * attribute. Attribute-unchanged elements are never touched, so uncontrolled\n * usage — JSX that never mentions the attribute — keeps user-driven state\n * exactly as before. This is the same philosophy as the user-agent-owned\n * `open` carve-out on `<details>`/`<dialog>`: kerf only touches what the\n * template expressed an opinion about.\n *\n * The focused-element exception: a focused text-entry control's `value` is the\n * user's in-progress edit — the morph's preservation rule owns it, so `value`\n * sync is skipped for `document.activeElement`.\n *\n * Callers write the property BEFORE the attribute (KF-FMGEJ6). WebKit keeps a\n * clean input's change-event baseline at the value it was parsed with when only\n * its `value` attribute changes, and an attribute-first write leaves the\n * property already equal, so the property setter is a no-op there too. An input\n * parsed as `value=\"A\"` and re-pointed to `B` then fires no `change` when the\n * user types `A` back. Writing the property first really changes the value,\n * which resets the baseline; the attribute then sets only the default. The end\n * state is the same in every engine.\n */\nexport function syncFormProp(\n el: Element,\n name: string,\n value: string,\n present: boolean,\n): void {\n const tag = el.tagName;\n if (name === 'checked') {\n if (tag === 'INPUT') (el as HTMLInputElement).checked = present;\n } else if (name === 'value') {\n if (tag === 'INPUT' && el !== document.activeElement) {\n (el as HTMLInputElement).value = present ? value : '';\n }\n } else if (name === 'selected') {\n if (tag === 'OPTION') (el as HTMLOptionElement).selected = present;\n }\n}\n","/**\n * URL-attribute screening, shared by the JSX runtime's static-attribute\n * serializer (`renderAttr` in `jsx-runtime.ts`) and the fine-grained binding's\n * live-attribute writer (`setBoundAttr` in `bindings.ts`) — KF-297.\n *\n * A stored-XSS payload like `href={userInput}` with `javascript:alert(1)` is\n * dropped (attribute omitted from the string / removed from the live node)\n * rather than written. `raw(...)` / `SafeHtml` values bypass this — the\n * documented opt-out for legitimate cases (bookmarklet builders, values\n * sanitized by a separate trust layer).\n *\n * The screen is a scheme allow/deny check, not a full URL sanitizer, but it is\n * hardened against the obfuscations a real browser sees through:\n *\n * - **Control-character / whitespace obfuscation of the scheme.** Browsers\n * strip leading C0 controls + spaces and remove TAB/LF/CR from anywhere in\n * a URL before resolving the scheme, so `java\\tscript:`, `\\x01javascript:`,\n * and `javascript\\x00:` all resolve to `javascript:`. We normalize the same\n * way (strip every C0 control 0x00-0x1F + DEL, trim leading whitespace)\n * BEFORE extracting the scheme, so none of those slip past.\n *\n * - **The `javascript:` no-op placeholders are allowed.** `javascript:void(0)`\n * and its handful of spellings are the placeholder-link idiom, not an\n * attack; matching is against the whole normalized value so nothing can be\n * appended to them. See `INERT_JAVASCRIPT_URLS`.\n *\n * - **`data:` is subtype-specific.** `data:image/png` in `<img src>` is safe\n * and common; `data:text/html` / `data:image/svg+xml` / `data:*xml` load as\n * a document and run script (SVG `<script>`, HTML/XHTML `<script>`). We\n * allowlist the inert media families (raster images, fonts, audio, video,\n * plain text/css) and drop every other `data:` — so a novel dangerous\n * subtype fails closed.\n *\n * - **SVG is safe in an image sink only.** An SVG loaded as an image\n * (`<img src>`, SVG `<image href>`) renders in the browser's secure static\n * mode: no script, no external loads, no interaction. So\n * `data:image/svg+xml` passes there (`isImageUrlSink`) and stays blocked\n * everywhere else (`<iframe src>`, `<embed src>`, `<object data>`, `<a\n * href>`, …), where it loads as a script-capable document.\n */\n\nimport { devHooks } from '../dev-hooks.js';\n\n/**\n * URL-bearing HTML/SVG attributes whose plain-string values are screened.\n * `data` covers `<object data>` (loads its target as a document, so\n * `data:text/html` there executes). Image-context URL attributes\n * (`srcset` / `poster` / `background` / `ping`) are intentionally NOT screened:\n * a `javascript:` / `data:` value in them does not execute as script in modern\n * browsers, so screening would add false positives without closing a real sink.\n */\nconst URL_ATTRS = new Set([\n 'href',\n 'src',\n 'xlink:href',\n 'formaction',\n 'action',\n 'data',\n]);\n\n/** Schemes that execute script when a browser resolves them as a URL. */\nconst DANGEROUS_SCHEMES = new Set(['javascript', 'vbscript']);\n\n/**\n * `javascript:` URLs that are provably no-ops — the placeholder-link idiom\n * (`<a href=\"javascript:void(0)\">`) that a decade of jQuery-era markup, CMS\n * output, and ported templates is full of.\n *\n * Screening them out was a false positive with a bad failure mode: the `href`\n * is dropped, so the anchor stops being a link — no keyboard focus, no `:link`\n * styling, no pointer cursor — and in production that happens behind a\n * `console.warn` nobody reads.\n *\n * Allowing them costs nothing. The match is against the **whole** normalized\n * value, so no attacker-supplied suffix survives it: `javascript:void(0)` is in\n * the set and `javascript:void(0);alert(1)` is not. The bodies here evaluate to\n * `undefined` or to nothing at all, and they carry no interpolation point.\n *\n * The alternative — telling authors to write `raw('javascript:void(0)')` — is\n * strictly worse for security: it teaches the general-purpose escape hatch as\n * the answer to a benign case, and an author who has learned `raw()` for one\n * `href` will reach for it on the next one.\n *\n * Matching is exact after `normalizeUrl` + lowercase + trailing-whitespace trim.\n * Internal whitespace is NOT collapsed, so each accepted spelling is listed\n * explicitly and the set stays auditable at a glance.\n */\nconst INERT_JAVASCRIPT_URLS = new Set([\n 'javascript:',\n 'javascript:;',\n 'javascript:void(0)',\n 'javascript:void(0);',\n 'javascript:void 0',\n 'javascript:void 0;',\n]);\n\n/** Matches every C0 control character (0x00-0x1F) and DEL (0x7F). */\n// eslint-disable-next-line no-control-regex -- deliberately matching C0 + DEL.\nconst CONTROL_CHARS = /[\\u0000-\\u001F\\u007F]/g;\n\n/** Bound diagnostic payloads so an unsafe, attacker-controlled URL cannot flood logs. */\nconst DANGEROUS_URL_DIAGNOSTIC_VALUE_LENGTH = 80;\n\n/**\n * Normalize a URL the way a browser does before scheme resolution: remove every\n * C0 control (0x00-0x1F) and DEL (0x7F) from anywhere — no legitimate URL\n * carries a raw control char (they must be percent-encoded), so this collapses\n * `java\\tscript:` / `\\x01javascript:` / `javascript\\x00:` back to their real\n * scheme — then trim leading whitespace. Internal spaces are left intact: a\n * space is not a valid scheme character, so a browser treats `java script:` as\n * a relative URL, not the `javascript:` scheme, and we must not \"repair\" it\n * into a false positive.\n */\nfunction normalizeUrl(value: string): string {\n return value.replace(CONTROL_CHARS, '').replace(/^\\s+/, '');\n}\n\n/**\n * The lowercased URL scheme (text before the first `:`) of an ALREADY-NORMALIZED\n * value, or null if none.\n */\nfunction schemeOf(normalized: string): string | null {\n const m = /^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(normalized);\n return m ? m[1].toLowerCase() : null;\n}\n\n/**\n * True if a `data:` URL (already normalized) is a script-executing document\n * type. Allowlists the inert media families and fails closed on everything else\n * — so `text/html`, `image/svg+xml`, XHTML/XML, and any unknown/novel subtype\n * are all treated as dangerous, while `data:image/png` / fonts / audio / video\n * / plain text pass.\n */\nfunction isDangerousDataUrl(normalized: string, imageSink: boolean): boolean {\n const media =\n /^data:([^;,]*)/.exec(normalized.toLowerCase())?.[1].trim() ?? '';\n if (media === '' || media === 'text/plain' || media === 'text/css')\n return false;\n // SVG can carry <script>, which runs when it loads as a document; as an\n // image it renders in secure static mode and runs nothing.\n if (media === 'image/svg+xml') return !imageSink;\n if (media.startsWith('image/')) return false;\n if (media.startsWith('font/') || media.startsWith('application/font'))\n return false;\n if (media.startsWith('audio/') || media.startsWith('video/')) return false;\n return true; // text/html, application/xhtml+xml, *xml, unknown → block\n}\n\n/**\n * True if `name` is one of the URL-bearing attributes the screen inspects.\n * A pure function of the name, so callers that see the same attribute name\n * over and over (the JSX serializer) may cache its answer per name.\n */\nexport function isUrlAttrName(name: string): boolean {\n // HTML attribute names are ASCII-case-insensitive, and JSX can reach this\n // helper with the author-written casing on both static and bound paths.\n // Normalize before the allowlist check so `HREF` / `Src` / `XLINK:HREF`\n // cannot bypass the same browser sink written in lowercase.\n // Lowercase names (nearly all of them) are checked without allocating.\n return URL_ATTRS.has(/[A-Z]/.test(name) ? name.toLowerCase() : name);\n}\n\n/**\n * True if attribute `name` on element `tag` loads its URL as an image, where\n * an SVG renders in secure static mode and runs no script: `<img src>` and\n * SVG `<image href>` / `<image xlink:href>`. Tag and attribute names compare\n * case-insensitively.\n */\nexport function isImageUrlSink(tag: string, name: string): boolean {\n return /^(?:img:src|image:(?:xlink:)?href)$/i.test(`${tag}:${name}`);\n}\n\n/**\n * True if `value` is a dangerous URL for the URL-bearing attribute `name` on\n * element `tag` (omit `tag` when it is unknown; the screen then treats the\n * attribute as a document sink).\n */\nexport function isDangerousUrlValue(\n name: string,\n value: string,\n tag = '',\n): boolean {\n return (\n isUrlAttrName(name) && isDangerousUrl(value, isImageUrlSink(tag, name))\n );\n}\n\n/**\n * True if `value`, written into a URL-bearing attribute (see `isUrlAttrName`),\n * would resolve to a script-executing URL.\n */\nexport function isDangerousUrl(value: string, imageSink = false): boolean {\n // No `:` → no scheme, so nothing to screen: a relative URL (`/a/b`, `#x`,\n // `?q`, `logo.png`) is the common case in a large page. Exact: normalization\n // only ever REMOVES characters, so it can never introduce the `:` that\n // `schemeOf` needs.\n if (!value.includes(':')) return false;\n // Normalized once here — every helper below reasons about the same string the\n // browser's scheme resolution would see.\n const normalized = normalizeUrl(value);\n const scheme = schemeOf(normalized);\n if (scheme === null) return false;\n if (DANGEROUS_SCHEMES.has(scheme)) {\n return !INERT_JAVASCRIPT_URLS.has(normalized.trimEnd().toLowerCase());\n }\n return scheme === 'data' && isDangerousDataUrl(normalized, imageSink);\n}\n\n/**\n * The shared warning body for a dropped dangerous URL. Each caller prefixes\n * its own context (`JSX:` for the string serializer, `kerf binding:` for the\n * live-attribute writer).\n */\nexport function dangerousUrlWarning(name: string, value: string): string {\n return (\n `dropped dangerous URL value for ${name}=${JSON.stringify(value.slice(0, DANGEROUS_URL_DIAGNOSTIC_VALUE_LENGTH))}. ` +\n 'kerf blocks javascript:, vbscript:, and script-executing data: URLs ' +\n '(text/html, image/svg+xml, xml) in href/src/data/formaction/action/xlink:href by default. ' +\n 'Wrap in raw() if this is intentional (e.g. bookmarklets), or sanitize upstream.'\n );\n}\n\n/**\n * Report a screened dangerous URL, with the dev-vs-prod split (KF-340). Both\n * call sites (the JSX string serializer's `renderAttr` and the live-attribute\n * writer's `setBoundAttr`) still DROP the attribute; this only chooses how the\n * screen surfaces the diagnostic:\n *\n * - **DEV** (the consumer imported `kerfjs/dev`): THROW an `Error` with the\n * diagnostic, failing loudly at the developer's desk so a mistyped/unsafe\n * URL can't slip by unnoticed (nobody reads the console).\n * - **PRODUCTION** (no dev entry installed): `console.warn` and let the\n * caller drop — never crash a shipped app on attacker-influenced data.\n *\n * `context` is the caller's prefix (`JSX`/`kerf binding`); the composed message\n * is byte-identical to the pre-KF-340 warn text in production.\n */\nexport function reportDangerousUrl(\n context: string,\n name: string,\n value: string,\n): void {\n const message = `${context}: ${dangerousUrlWarning(name, value)}`;\n devHooks.urlScreenThrow?.(message);\n console.warn(message);\n}\n","/**\n * Fine-grained signal bindings (KF-294 spike).\n *\n * When a `Signal` is interpolated straight into a JSX attribute\n * (`class={sig}`) or a text child (`{sig}`) INSIDE a `mount()` render, the\n * JSX runtime stops stringifying it. Instead it emits a marker into the HTML\n * string and records a binding here; after the string is parsed to DOM, a\n * wiring pass attaches one `effect` per binding that writes straight to the\n * live node. A later change to that signal then updates the node WITHOUT\n * re-running the render function or walking the list reconciler.\n *\n * This reuses the \"marker in string, wire up after parse\" mechanism the\n * keyed-list reconciler already uses for `<!--kf-list:{id}-->` markers.\n *\n * TWO SCOPES of binding, with disjoint marker namespaces so their wiring\n * passes never collide:\n *\n * - GLOBAL holes — signals in the static surrounds (outside any `each()`\n * row). Markers: `data-kfb` attribute / `<!--kfb:{id}-->` comment. Ids come\n * from the mount render context's counter; wired by `wireBindings()` over\n * the whole mount root; disposed/re-wired by `mount()` each render.\n *\n * - ROW holes — signals inside an `each()` row. Markers: `data-kfbrow`\n * attribute / `<!--kfbr:{id}-->` comment. Ids are row-LOCAL (reset per row)\n * so they stay stable and collision-free as rows are inserted/removed/moved.\n * Captured per row by `captureRowBindings()`, carried on the list segment\n * item, and wired/disposed by the list reconciler at each row node's\n * create/remove — so a binding's lifetime tracks its row node's lifetime,\n * and row reorders (which reuse the same node) are free.\n *\n * Outside a `mount()` render (SSR / `SafeHtml.toString()`) neither scope is\n * active: the runtime snapshots `signal.value` and emits no markers, so server\n * output is correct and legacy `.toString()` callers are unaffected.\n *\n * Module-level mutable state note: `context` / `rowSink` (plus `rowCounter`,\n * the row-hole id counter that resets with each row capture) are a third\n * sanctioned module-level mutable location (alongside `store.ts:REGISTRY` and\n * `each.ts:context`). They hold the current render's binding sinks and are set\n * / cleared by `mount()` and `each()` around the render calls. The only other\n * module-level container here is `insertedTextNodes`, a WeakMap keyed on text\n * marker comments — a pure cache whose entries die with their nodes (GC-tied\n * lifetime), so it carries no cross-render semantics.\n */\n\nimport { effect, isSignal, type Signal } from './reactive.js';\nimport { isOverlayHost } from './utils/overlay-host.js';\nimport { syncFormProp } from './utils/syncFormProp.js';\nimport { isDangerousUrlValue, reportDangerousUrl } from './utils/url-screen.js';\n\n// RESERVED NAMESPACE (consumer contract, KF-314). The wiring pass finds these\n// markers by scanning the mounted subtree and matching by id, and resolves an\n// id collision by document order (last/first wins) with no ownership check — so\n// a consumer element that carries `data-kfb`/`data-kfbrow`, or a comment\n// beginning `kfb:`/`kfbr:`/`kf-list:`, can collide with a real binding's id and\n// steal its effect (the update wires to the wrong node). These names are\n// therefore reserved: consumers must not emit them (documented in\n// docs/2-reactivity.md § \"Reserved marker names\"). Kerf's own escaping already\n// prevents a plain text/attribute *value* from forging one; the remaining ways\n// in are a hand-written attribute or a `raw()` payload — i.e. the consumer's\n// own trust boundary. A dev-mode collision warning is a possible future\n// enhancement (fix direction (a) on KF-314) if silent mis-wiring proves easy to\n// hit in practice.\n\n/** Marker attribute for GLOBAL (static-surround) attribute bindings. */\nexport const BIND_ATTR = 'data-kfb';\n/** Comment-marker prefix for a GLOBAL text binding: `<!--kfb:{id}-->`. */\nexport const TEXT_MARKER_PREFIX = 'kfb:';\n/** Marker attribute for ROW (each()-scoped) attribute bindings. */\nexport const BIND_ATTR_ROW = 'data-kfbrow';\n/** Comment-marker prefix for a ROW text binding: `<!--kfbr:{id}-->`. */\nexport const ROW_TEXT_PREFIX = 'kfbr:';\n\ninterface AttrBinding {\n kind: 'attr';\n id: string;\n attr: string;\n signal: Signal<unknown>;\n}\ninterface TextBinding {\n kind: 'text';\n id: string;\n signal: Signal<unknown>;\n}\nexport type Binding = AttrBinding | TextBinding;\n\n/**\n * Per-render GLOBAL binding sink. `counter` assigns ids by registration order\n * (stable across renders since the JSX render is deterministic); `list`\n * accumulates this render's global (static-surround) holes.\n */\nexport interface BindingContext {\n counter: number;\n list: Binding[];\n}\n\nlet context: BindingContext | null = null;\n\n// Active row-capture sink + its row-local id counter. Non-null only while\n// `each()` renders a single row through `captureRowBindings()`.\nlet rowSink: Binding[] | null = null;\nlet rowCounter = 0;\n\n// Frozen shared sentinel for the no-holes case — readonly so no caller can\n// push into it and corrupt every other no-hole mount.\nconst NO_DISPOSERS: ReadonlyArray<() => void> = Object.freeze([]);\n\nexport function newBindingContext(): BindingContext {\n return { counter: 0, list: [] };\n}\n\nexport function _setBindingContext(c: BindingContext | null): void {\n context = c;\n}\n\n/**\n * Render one `each()` row while capturing the row-scoped bindings it emits.\n * Row ids are local (reset to 0) so they're stable + collision-free per row.\n * Returns the row HTML and its captured bindings (empty when the row has no\n * signal holes). Restores the prior capture state (supports nested `each()`).\n */\nexport function captureRowBindings(renderRow: () => string): {\n html: string;\n bindings: Binding[];\n} {\n const prevSink = rowSink;\n const prevCounter = rowCounter;\n rowSink = [];\n rowCounter = 0;\n try {\n const html = renderRow();\n return { html, bindings: rowSink };\n } finally {\n rowSink = prevSink;\n rowCounter = prevCounter;\n }\n}\n\n/**\n * Register a signal attribute. Routes to the row sink when a row capture is\n * active, else the global context. Returns the marker id,\n * or null to snapshot. The marker attribute NAME (`data-kfb` vs `data-kfbrow`)\n * is fetched once per element via `bindMarkerAttr()` — all of an element's\n * signal attrs share the same scope — so this avoids a per-attr object alloc.\n */\nexport function bindAttr(attr: string, signal: Signal<unknown>): string | null {\n if (rowSink !== null) {\n const id = `a${rowCounter++}`;\n rowSink.push({ kind: 'attr', id, attr, signal });\n return id;\n }\n if (context !== null) {\n const id = `a${context.counter++}`;\n context.list.push({ kind: 'attr', id, attr, signal });\n return id;\n }\n return null;\n}\n\n/**\n * The marker attribute name for the currently-active binding scope — row holes\n * use `data-kfbrow`, global holes `data-kfb`. Called once per element by the\n * JSX runtime after collecting the element's signal-attr ids.\n */\nexport function bindMarkerAttr(): string {\n return rowSink !== null ? BIND_ATTR_ROW : BIND_ATTR;\n}\n\n/**\n * Register a signal text hole. Returns the comment-marker HTML to emit, or\n * null to snapshot. Same routing as `bindAttr()`.\n */\nexport function bindText(signal: Signal<unknown>): string | null {\n if (rowSink !== null) {\n const id = `t${rowCounter++}`;\n rowSink.push({ kind: 'text', id, signal });\n return `<!--${ROW_TEXT_PREFIX}${id}-->`;\n }\n if (context !== null) {\n const id = `t${context.counter++}`;\n context.list.push({ kind: 'text', id, signal });\n return `<!--${TEXT_MARKER_PREFIX}${id}-->`;\n }\n return null;\n}\n\n/**\n * Wire this render's GLOBAL bindings against the freshly-built live DOM.\n * Disposes `prevDisposers` first (a surrounds-changed morph strips bound attrs\n * and removes inserted text nodes, so we re-establish them), then attaches one\n * effect per hole. Zero-cost when there are no global holes.\n *\n * `rows` — the `each()` rows bound in this mount — are not searched: a row\n * renders in row scope, so it carries only `data-kfbrow` / `kfbr:` markers,\n * never a global one. Skipping them keeps the marker search proportional to\n * the surrounds instead of to every row's subtree.\n */\nexport function wireBindings(\n rootEl: Element,\n ctx: BindingContext,\n prevDisposers: ReadonlyArray<() => void>,\n rows?: ReadonlySet<Element>,\n): ReadonlyArray<() => void> {\n for (const d of prevDisposers) d();\n if (ctx.list.length === 0) return NO_DISPOSERS;\n const disposers: Array<() => void> = [];\n try {\n wireInto(rootEl, ctx.list, disposers, rows);\n } catch (err) {\n // A hole whose first write threw (a throwing `computed`, a screened URL in\n // dev) must not strand the effects wired before it: nobody would ever\n // receive their disposers.\n for (const d of disposers) d();\n throw err;\n }\n return disposers;\n}\n\n/**\n * Wire one row's ROW-scoped bindings against its freshly-built row node\n * (including the node itself, since a row's top-level element may carry the\n * marker, e.g. `<tr data-kfbrow>`). Returns the row's disposers for the\n * reconciler to store on the bound item and call when the row node is removed.\n */\nexport function wireRowBindings(\n rowNode: Element,\n bindings: Binding[],\n): Array<() => void> {\n // Callers (snapshot buildFreshNodes, mount first-render inline) only invoke\n // this for rows with at least one binding, so no empty-guard is needed.\n //\n // Hot path: most row holes are an attribute on the row's ROOT element (e.g.\n // `<tr class={sig}>`). For those we resolve the node with a single\n // `getAttribute` + allocation-free id membership check — no marker walk, no\n // Map. The descendant-attr index and the\n // text-comment index are built lazily, only if a hole actually needs them.\n // Dense by construction: disposers are PUSHED, never index-assigned, so a\n // skipped hole (the defensive missing-marker `continue` below) leaves no gap\n // for `disposeRowBindings` / `mount()`'s release loop to trip over (KF-5FM1Z6:\n // a sparse slot would throw a TypeError when called during disposal).\n const disposers: Array<() => void> = [];\n const rootIds = rowNode.getAttribute(BIND_ATTR_ROW);\n // For the common single-root-binding row, `rootIds === b.id` resolves the\n // node with zero allocation. Only a row with 2+ root bindings builds the Set.\n let rootIdSet: Set<string> | null = null;\n // The descendant-attr and text-comment indexes come from one walk of the\n // row, made the first time a hole needs either.\n let markers: Markers | null = null;\n const rowMarkers = (): Markers =>\n (markers ??= indexMarkers(rowNode, BIND_ATTR_ROW, ROW_TEXT_PREFIX));\n\n try {\n for (let i = 0; i < bindings.length; i++) {\n const b = bindings[i];\n if (b.kind === 'attr') {\n let onRoot = false;\n if (rootIds !== null) {\n if (rootIds === b.id) {\n onRoot = true;\n } else if (rootIds.indexOf(',') !== -1) {\n rootIdSet ??= new Set(rootIds.split(','));\n onRoot = rootIdSet.has(b.id);\n }\n }\n let el: Element | undefined;\n if (onRoot) {\n el = rowNode;\n } else {\n el = rowMarkers().attrs.get(b.id);\n }\n // Defensive: a registered binding always emits its marker into the row.\n if (el === undefined) continue;\n disposers.push(attachAttrEffect(el, b.attr, b.signal));\n } else {\n const marker = rowMarkers().texts.get(b.id);\n // Defensive: same invariant as the attr branch.\n if (marker === undefined) continue;\n disposers.push(attachTextEffect(marker, b.signal));\n }\n }\n } catch (err) {\n // Same contract as `wireBindings`: a hole that throws on its first write\n // disposes the row's already-wired effects before the error propagates\n // (only wired holes were pushed, so every entry is callable).\n for (const d of disposers) d();\n throw err;\n }\n return disposers;\n}\n\n/** Dispose a row's binding effects (called when its node leaves the DOM). */\nexport function disposeRowBindings(\n disposers: Array<() => void> | undefined,\n): void {\n if (disposers === undefined) return;\n for (const d of disposers) d();\n}\n\n/**\n * KF-347 — decide, for a row whose DOM node survives an in-place update,\n * whether the live binding effects can be carried forward or must be\n * re-wired. The old effects closed over the signal INSTANCES captured at the\n * previous render; if this render's bindings reference the same instances\n * per hole (the cache-hit case, and rows binding stable external signals),\n * the old effects remain correct and re-wiring would be wasted work — the\n * select-row hot path stays free. If any hole's instance changed — the\n * typical shape after `arraySignal.update()` swaps the row object and the\n * row re-renders fresh `computed`s closing over the NEW item — the old\n * effects are stale (they'd keep reading the pre-update row), so dispose\n * them and wire the fresh bindings against the surviving node. Marker\n * alignment holds across every in-place route: row-local binding ids are\n * deterministic per render, the surgical fast paths leave marker attrs and\n * comments untouched, and `_morphElement` syncs them.\n *\n * Also covers the from-scratch case (`oldBindings` undefined with fresh\n * `newBindings`): the length mismatch routes to the wire branch, so a\n * replaceChild caller can hand its brand-new node straight here.\n */\nexport function carryOrRewireRowBindings(\n node: Element,\n oldBindings: Binding[] | undefined,\n oldDisposers: Array<() => void> | undefined,\n newBindings: Binding[] | undefined,\n): {\n bindings: Binding[] | undefined;\n bindingDisposers: Array<() => void> | undefined;\n} {\n const oldLen = oldBindings === undefined ? 0 : oldBindings.length;\n const newLen = newBindings === undefined ? 0 : newBindings.length;\n if (oldLen === newLen) {\n let same = true;\n for (let i = 0; i < newLen; i++) {\n if (\n (oldBindings as Binding[])[i].signal !==\n (newBindings as Binding[])[i].signal\n ) {\n same = false;\n break;\n }\n }\n if (same) return { bindings: oldBindings, bindingDisposers: oldDisposers };\n }\n disposeRowBindings(oldDisposers);\n return {\n bindings: newBindings,\n bindingDisposers:\n newLen > 0 ? wireRowBindings(node, newBindings as Binding[]) : undefined,\n };\n}\n\n/**\n * GLOBAL-scope wiring core. Indexes `data-kfb`-marked elements + `kfb:`\n * comment markers under `scope` by binding id, then attaches an effect per\n * binding. Row-scope wiring lives in `wireRowBindings` (with its own inlined\n * root-attr fast path), so this always operates on the GLOBAL marker names.\n */\nfunction wireInto(\n scope: Element,\n bindings: Binding[],\n disposers: Array<() => void>,\n rows: ReadonlySet<Element> | undefined,\n): void {\n const markers = indexMarkers(scope, BIND_ATTR, TEXT_MARKER_PREFIX, rows);\n\n for (const b of bindings) {\n if (b.kind === 'attr') {\n const el = markers.attrs.get(b.id);\n /* c8 ignore next -- defensive: a registered binding always emits its marker into `scope`. */\n if (el === undefined) continue;\n disposers.push(attachAttrEffect(el, b.attr, b.signal));\n } else {\n const marker = markers.texts.get(b.id);\n /* c8 ignore next -- defensive: same invariant as the attr branch. */\n if (marker === undefined) continue;\n disposers.push(attachTextEffect(marker, b.signal));\n }\n }\n}\n\n/**\n * One walk that indexes, by binding id, the DESCENDANT elements of `node`\n * carrying `attrName` and the comment markers starting with `textPrefix`,\n * stepping over overlay host slots (another mount's markers) and `skip` (the\n * bound rows, when wiring the global scope: rows carry only row-scope\n * markers). Hand-rolled because happy-dom's `TreeWalker` does not surface\n * comment nodes; the attribute index rides along on the same walk.\n */\nfunction indexMarkers(\n node: Node,\n attrName: string,\n textPrefix: string,\n skip?: ReadonlySet<Element>,\n out: Markers = { attrs: new Map(), texts: new Map() },\n): Markers {\n for (let c: Node | null = node.firstChild; c !== null; c = c.nextSibling) {\n if (c.nodeType === Node.COMMENT_NODE) {\n const data = (c as Comment).data;\n if (data.startsWith(textPrefix))\n out.texts.set(data.slice(textPrefix.length), c as Comment);\n } else if (c.nodeType === Node.ELEMENT_NODE) {\n const el = c as Element;\n if (skip?.has(el) || isOverlayHost(el)) continue;\n const ids = el.getAttribute(attrName);\n if (ids !== null) for (const id of ids.split(',')) out.attrs.set(id, el);\n indexMarkers(el, attrName, textPrefix, skip, out);\n }\n }\n return out;\n}\n\n/** Binding markers under a scope, by binding id. */\ninterface Markers {\n attrs: Map<string, Element>;\n texts: Map<string, Comment>;\n}\n\n/** Attach a fine-grained attribute effect; returns its disposer. */\nfunction attachAttrEffect(\n el: Element,\n attr: string,\n signal: Signal<unknown>,\n): () => void {\n return effect(() => setBoundAttr(el, attr, signal.value));\n}\n\n/**\n * Tracks the live text node each text-hole marker owns, so RE-wiring a hole\n * (KF-347 — an in-place row update whose binding instances changed) reuses\n * the node it inserted the first time instead of stacking a second one next\n * to it. Keyed on the marker comment: markers persist exactly as long as\n * their row/surround nodes do, so the WeakMap entries die with them.\n */\nconst insertedTextNodes = new WeakMap<Comment, Text>();\n\n/**\n * The live text node `marker` currently owns, or null (KF-374 — morph drops\n * static siblings of a bound hole). Position-strict, same rule as the reuse\n * check below: the node counts as owned only while it still sits at\n * `marker.nextSibling`. The morph's child pairing uses this to step PAST the\n * binding-inserted node — the template never contains it (templates carry\n * only the marker comment), so without the skip a template static sibling\n * pairs positionally with the inserted node, the morph overwrites the bound\n * text with the static content, and the real static sibling falls off the\n * cursor's tail and is removed.\n */\nexport function boundTextNodeOf(marker: Comment): Text | null {\n const t = insertedTextNodes.get(marker);\n return t !== undefined && marker.nextSibling === t ? t : null;\n}\n\n/**\n * Bind a live text node after `marker` to `signal`; returns the effect\n * disposer. Reuses the marker's previously-inserted node when it is still\n * exactly where we put it (`marker.nextSibling`) — a rewire then just\n * retargets the write, preserving node identity. Anything else (fresh parse,\n * node removed by a morph) inserts anew. The reuse check is deliberately\n * position-strict so a static text node that legitimately follows the marker\n * in template output can never be hijacked: static content sits at\n * `nextSibling` only until the FIRST wiring inserts our node in front of it.\n */\nfunction attachTextEffect(\n marker: Comment,\n signal: Signal<unknown>,\n): () => void {\n let text = insertedTextNodes.get(marker);\n if (text === undefined || marker.nextSibling !== text) {\n text = (marker.ownerDocument as Document).createTextNode('');\n (marker.parentNode as Node).insertBefore(text, marker.nextSibling);\n insertedTextNodes.set(marker, text);\n }\n const node = text;\n return effect(() => {\n node.data = coerceText(signal.value);\n });\n}\n\n/**\n * Apply a bound value to a live attribute, mirroring the JSX runtime's\n * `renderAttr` rules: boolean/nullish toggling, `SafeHtml` (raw()) unwrapping,\n * and the KF-297 URL-screening that drops `javascript:` / `vbscript:` /\n * `data:text/html` on `href`/`src`/`formaction`/`action`/`xlink:href`.\n *\n * Unlike `renderAttr` (which builds an HTML string, so escapes with\n * `escapeAttr`), this writes the RAW value via `setAttribute` — the DOM stores\n * attribute values verbatim, so no HTML-escaping is applied here.\n *\n * The attribute NAME is trusted here: `on*` and malformed names are rejected at\n * binding-registration time in the JSX runtime's `jsx()` signal branch (shared\n * `assertEmittableAttrName`, KF-322), so `setAttribute('onclick', …)` — which\n * would install a live inline handler — can never reach this writer.\n */\nfunction setBoundAttr(el: Element, name: string, value: unknown): void {\n // KF-335: every attribute write below also syncs the matching form-state\n // property (checked/value/selected) — after user interaction the dirty flag\n // detaches the property from the attribute, so an attribute-only write\n // leaves the visible state stale. `syncFormProp` no-ops for other names,\n // and runs before the attribute write (KF-FMGEJ6: WebKit's change\n // baseline; see `syncFormProp`).\n if (value == null || value === false) {\n syncFormProp(el, name, '', false);\n el.removeAttribute(name);\n return;\n }\n if (value === true) {\n syncFormProp(el, name, '', true);\n el.setAttribute(name, '');\n return;\n }\n // SafeHtml (raw()) is the documented opt-out — bypasses URL screening and is\n // written verbatim, matching renderAttr's SafeHtml branch.\n if (isSafeHtmlValue(value)) {\n syncFormProp(el, name, value.__html, true);\n el.setAttribute(name, value.__html);\n return;\n }\n const str = String(value);\n if (isDangerousUrlValue(name, str, el.localName)) {\n // KF-340: throw in dev (fail loudly), warn+drop in prod.\n reportDangerousUrl('kerf binding', name, str);\n el.removeAttribute(name);\n return;\n }\n syncFormProp(el, name, str, true);\n el.setAttribute(name, str);\n}\n\n// Cross-bundle SafeHtml brand check (mirrors jsx-runtime's `isSafeHtml`).\n// Duplicated here — rather than importing `isSafeHtml` from jsx-runtime — to\n// keep the bindings ← jsx-runtime dependency acyclic. `Symbol.for` makes it\n// recognize SafeHtml instances from any copy of the module.\nconst SAFE_HTML_BRAND = Symbol.for('kerfjs.SafeHtml');\nfunction isSafeHtmlValue(v: unknown): v is { __html: string } {\n return (\n typeof v === 'object' &&\n v !== null &&\n (v as Record<symbol, unknown>)[SAFE_HTML_BRAND] === true\n );\n}\n\n/** Coerce a bound text value: nullish + boolean render nothing (React-style). */\nfunction coerceText(value: unknown): string {\n if (value == null || typeof value === 'boolean') return '';\n return String(value);\n}\n\n// Re-exported so the JSX runtime imports signal-detection + binding\n// registration from one place.\nexport { isSignal };\n","/**\n * HTML / attribute escaping for the JSX runtime. Identical to the helpers\n * used in any reasonable HTML emitter — included here so kerf has no extra\n * runtime dependencies beyond `@preact/signals-core`.\n */\n\nconst ENTITIES: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n};\n\n// One pass over the string, appending the unescaped runs between matches.\n// A value with nothing to escape (most ids, classes, SVG path data) comes back\n// as the same string with no allocation; one that needs escaping is about 2x\n// faster than a chain of one `replace` pass per character.\nfunction escapeWith(str: string, special: RegExp): string {\n special.lastIndex = 0;\n let out = '';\n let last = 0;\n let match;\n while ((match = special.exec(str))) {\n out += str.slice(last, match.index) + ENTITIES[match[0]];\n last = special.lastIndex;\n }\n return last ? out + str.slice(last) : str;\n}\n\nconst HTML_SPECIAL = /[&<>\"]/g;\nconst ATTR_SPECIAL = /[&\"'<>]/g;\n\nexport function escapeHtml(str: string): string {\n return escapeWith(str, HTML_SPECIAL);\n}\n\nexport function escapeAttr(str: string): string {\n return escapeWith(str, ATTR_SPECIAL);\n}\n","/**\n * JSX → HTML / SVG attribute name aliases.\n *\n * The JSX runtime translates camelCase attributes (React convention) to\n * the kebab-case / colon-form names the browser actually wants. Anything\n * not in this map is passed through verbatim — `data-*`, `aria-*`, and\n * any custom attribute work without ceremony.\n *\n * Lives in its own module so the alias data stays a separable concern from\n * `src/jsx-runtime.ts`'s runtime logic; the bulk of `jsx-runtime.ts` was this\n * table.\n *\n * **When a camelCase attribute needs an entry.** Pass-through is not the same\n * as \"no translation\": an unlisted `fooBar` is emitted verbatim, and the HTML\n * parser then lowercases it to `foobar`. That is silently *correct* whenever\n * the real attribute name is exactly the lowercased spelling (`fetchPriority`\n * → `fetchpriority`, `charSet` → `charset`, `playsInline` → `playsinline`), and\n * silently *wrong* whenever it isn't — `defaultSelected` rendered\n * `defaultselected`, an attribute no browser has ever read, so the option it\n * was supposed to pre-select never was. Any camelCase key whose HTML name is\n * not its own lowercase MUST have a row here.\n *\n * `tests/unit/jsx-attr-names.test.ts` pins that rule: it reads every attribute\n * key declared in `src/jsx-types.ts` and asserts the name kerf would actually\n * emit for each camelCase one, so a new typed attribute cannot join without\n * someone stating what it renders as.\n *\n * SVG is the reason the lowercasing shortcut can't be relied on in general —\n * SVG attribute names are case-sensitive, and only the fixed set in the HTML\n * parser's SVG adjustment table (`viewBox`, `preserveAspectRatio`,\n * `pathLength`, …) survives the round trip with its case intact.\n */\n\nexport const ATTR_ALIASES: Record<string, string> = {\n // HTML attributes\n className: 'class',\n htmlFor: 'for',\n httpEquiv: 'http-equiv',\n acceptCharset: 'accept-charset',\n accessKey: 'accesskey',\n autoCapitalize: 'autocapitalize',\n autoComplete: 'autocomplete',\n autoFocus: 'autofocus',\n autoPlay: 'autoplay',\n colSpan: 'colspan',\n contentEditable: 'contenteditable',\n crossOrigin: 'crossorigin',\n dateTime: 'datetime',\n defaultChecked: 'checked',\n defaultSelected: 'selected',\n defaultValue: 'value',\n encType: 'enctype',\n formAction: 'formaction',\n formEncType: 'formenctype',\n formMethod: 'formmethod',\n formNoValidate: 'formnovalidate',\n formTarget: 'formtarget',\n hrefLang: 'hreflang',\n inputMode: 'inputmode',\n maxLength: 'maxlength',\n minLength: 'minlength',\n noModule: 'nomodule',\n noValidate: 'novalidate',\n readOnly: 'readonly',\n referrerPolicy: 'referrerpolicy',\n rowSpan: 'rowspan',\n spellCheck: 'spellcheck',\n srcDoc: 'srcdoc',\n srcLang: 'srclang',\n srcSet: 'srcset',\n tabIndex: 'tabindex',\n useMap: 'usemap',\n\n // SVG presentation attributes (camelCase → kebab-case)\n strokeWidth: 'stroke-width',\n strokeLinecap: 'stroke-linecap',\n strokeLinejoin: 'stroke-linejoin',\n strokeDasharray: 'stroke-dasharray',\n strokeDashoffset: 'stroke-dashoffset',\n strokeMiterlimit: 'stroke-miterlimit',\n strokeOpacity: 'stroke-opacity',\n fillOpacity: 'fill-opacity',\n fillRule: 'fill-rule',\n clipPath: 'clip-path',\n clipRule: 'clip-rule',\n colorInterpolation: 'color-interpolation',\n colorInterpolationFilters: 'color-interpolation-filters',\n floodColor: 'flood-color',\n floodOpacity: 'flood-opacity',\n lightingColor: 'lighting-color',\n stopColor: 'stop-color',\n stopOpacity: 'stop-opacity',\n shapeRendering: 'shape-rendering',\n imageRendering: 'image-rendering',\n textRendering: 'text-rendering',\n pointerEvents: 'pointer-events',\n vectorEffect: 'vector-effect',\n paintOrder: 'paint-order',\n\n // SVG text/font attributes\n fontFamily: 'font-family',\n fontSize: 'font-size',\n fontStyle: 'font-style',\n fontVariant: 'font-variant',\n fontWeight: 'font-weight',\n fontStretch: 'font-stretch',\n textAnchor: 'text-anchor',\n textDecoration: 'text-decoration',\n dominantBaseline: 'dominant-baseline',\n alignmentBaseline: 'alignment-baseline',\n baselineShift: 'baseline-shift',\n letterSpacing: 'letter-spacing',\n wordSpacing: 'word-spacing',\n writingMode: 'writing-mode',\n\n // SVG marker attributes\n markerStart: 'marker-start',\n markerMid: 'marker-mid',\n markerEnd: 'marker-end',\n\n // SVG xlink (legacy but still used)\n xlinkHref: 'xlink:href',\n xlinkShow: 'xlink:show',\n xlinkActuate: 'xlink:actuate',\n xlinkType: 'xlink:type',\n xlinkRole: 'xlink:role',\n xlinkTitle: 'xlink:title',\n xlinkArcrole: 'xlink:arcrole',\n xmlBase: 'xml:base',\n xmlLang: 'xml:lang',\n xmlSpace: 'xml:space',\n xmlnsXlink: 'xmlns:xlink',\n};\n","/**\n * kerf JSX runtime.\n *\n * JSX renders to `SafeHtml`, which wraps both:\n * - `__html`: the flattened HTML string (what `toString()` returns; what\n * legacy/SSR consumers care about)\n * - `__segment`: a structured representation that distinguishes \"static\n * html\", \"keyed list\", and \"mixed\" content.\n *\n * Most renders are pure-static and the segment is just `{kind:'static',html}`.\n * When the tree contains a list (via `each()`) or a parent whose children\n * include a non-static segment, the runtime threads that structure up so\n * `mount()` can dispatch on it — running its native keyed reconciler for\n * the list parts and leaving the static surrounds to the general-purpose\n * diff.\n *\n * Configure in your `tsconfig.json`:\n *\n * \"jsx\": \"react-jsx\",\n * \"jsxImportSource\": \"kerfjs\"\n *\n * Then write JSX as you normally would — kerf provides the `jsx` /\n * `jsxs` / `jsxDEV` / `Fragment` exports the JSX transform looks for.\n */\n\nimport { bindAttr, bindMarkerAttr, bindText, isSignal } from './bindings.js';\nimport type { KerfBuiltinIntrinsicElements } from './jsx-types.js';\nimport type { ReadonlySignal, Signal } from './reactive.js';\nimport {\n flatten,\n type ListSegment,\n mergeChildSegments,\n type Segment,\n wrapWithTags,\n} from './segment.js';\nimport { escapeAttr, escapeHtml } from './utils/escapeHtml.js';\nimport { ATTR_ALIASES } from './utils/jsx-attr-aliases.js';\nimport {\n isDangerousUrl,\n isImageUrlSink,\n isUrlAttrName,\n reportDangerousUrl,\n} from './utils/url-screen.js';\n\n// Cross-realm/cross-bundle brand. Using `Symbol.for` (the global registry)\n// means two `SafeHtml` classes from different module copies still recognize\n// each other. Same approach React uses for `$$typeof: Symbol.for('react.element')`.\n// Without this, `instanceof SafeHtml` fails when the consumer's bundler ends\n// up loading two copies of kerf (separate barrel + jsx-runtime entries,\n// monorepo dedup misses, ESM/CJS interop, etc.).\nconst SAFE_HTML_BRAND = Symbol.for('kerfjs.SafeHtml');\n\nexport class SafeHtml {\n readonly __segment: Segment;\n // Branded so `isSafeHtml()` recognizes instances from any copy of this module.\n readonly [SAFE_HTML_BRAND] = true as const;\n // The flattened HTML, computed on first read. A structured segment wraps its\n // children's segments rather than their strings, so flattening eagerly made\n // every element above an `each()` copy all of the list's row HTML again —\n // O(depth × rows) per render, while `mount()` reads only the segment.\n #html: string | undefined;\n constructor(input: string | Segment) {\n if (typeof input === 'string') {\n this.__segment = { kind: 'static', html: input };\n this.#html = input;\n } else {\n this.__segment = input;\n if (input.kind === 'static') this.#html = input.html;\n }\n }\n /** The flattened HTML string (what `toString()` returns). */\n get __html(): string {\n return (this.#html ??= flatten(this.__segment, false));\n }\n toString(): string {\n return this.__html;\n }\n}\n\n/**\n * Type guard for `SafeHtml`. Prefer this over `instanceof SafeHtml` — it works\n * across module copies (e.g. when the consumer's bundler loads kerf's barrel\n * and JSX-runtime entries as independent modules).\n *\n * Security note (KF-321): this is a duck-check on the global `Symbol.for` brand,\n * so same-realm code *can* forge a \"trusted\" value — `{ [SAFE_HTML_BRAND]: true,\n * __html: '<img onerror=…>' }` passes and bypasses escaping + the URL screen.\n * This is intentional and not a vulnerability: minting the brand requires a\n * Symbol key, which no data channel (JSON.parse, form/query/localStorage,\n * structuredClone, JSON-based prototype-pollution) can produce — those all yield\n * string keys. The only way to forge it is to run JS that writes the symbol, and\n * such code can equally `import { raw }`. Forgery therefore grants no capability\n * an attacker with code execution lacks — the same posture as React's\n * `$$typeof: Symbol.for('react.element')`. The global `Symbol.for` (vs a\n * module-private symbol) is a deliberate cross-bundle-recognition tradeoff (see\n * the `SAFE_HTML_BRAND` note above); a private symbol would additionally block\n * same-realm forgery, but only closes a non-threat at the cost of that\n * recognition, so it's kept global by design.\n */\nexport function isSafeHtml(value: unknown): value is SafeHtml {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<symbol, unknown>)[SAFE_HTML_BRAND] === true\n );\n}\n\n/**\n * Inject a pre-escaped HTML string verbatim, bypassing kerf's auto-escaping.\n *\n * **Reach for this rarely.** kerf escapes automatically everywhere else, so a lot\n * of `raw()` in a codebase is usually a sign the wrong tool is being used — the\n * common cases have a safer, first-class answer:\n * - Interpolating dynamic text/attributes? Plain JSX (`<p>{value}</p>`,\n * `class={sig}`) already escapes it; you don't need `raw()`.\n * - Composing markup? Build a {@link SafeHtml} the normal way — a JSX expression,\n * the `html` tagged template (`kerfjs/html`), `each()`, or a component function\n * that returns JSX. Those all produce trusted `SafeHtml` without hand-writing\n * an HTML string.\n * - A genuinely trusted, pre-escaped **dynamic** value (server output, config, a\n * hard-coded string)? That's the one legitimate use. The\n * `kerfjs/no-raw-with-dynamic-arg` lint rule flags a `raw()` whose argument is\n * not a literal — because unsanitized user input is the canonical XSS mistake —\n * so acknowledge it with a `// eslint-disable-next-line\n * kerfjs/no-raw-with-dynamic-arg` at that call. That explicit override is the\n * single sanctioned way to say \"I've reviewed this; it's trusted,\" and it\n * leaves a searchable audit trail.\n *\n * `raw()` is NOT a sanitizer — it does no escaping. For user-controlled input,\n * sanitize first (`raw(DOMPurify.sanitize(marked(userMarkdown)))`) or, better,\n * render it through escaping JSX instead.\n */\nexport function raw(html: string): SafeHtml {\n return new SafeHtml(html);\n}\n\n/**\n * Internal: build a `SafeHtml` representing a list segment. Used by\n * `each()` so the JSX runtime is the sole owner of `SafeHtml` construction.\n */\nexport function listSafeHtml(\n id: string,\n items: ListSegment['items'],\n source?: object,\n): SafeHtml {\n return new SafeHtml({ kind: 'list', id, items, source });\n}\n\n/**\n * Internal: build a `SafeHtml` representing a granular list segment with\n * patches (KF-92). The reconciler applies the patches to the existing\n * binding directly, skipping the per-item iteration that the snapshot\n * `listSafeHtml` requires. `items` is included for fall-through paths\n * (toString during SSR, fall-back when the binding doesn't exist yet).\n *\n * Patch HTML is rendered upstream (in `each()`) inside a try/catch — see\n * KF-99 — so by the time we get here every `update` / `insert` patch\n * already carries a `html` string, and the reconciler does no further\n * row rendering.\n */\nexport function granularListSafeHtml(\n id: string,\n items: ListSegment['items'],\n patches: NonNullable<ListSegment['patches']>,\n source?: object,\n): SafeHtml {\n return new SafeHtml({ kind: 'list', id, items, patches, source });\n}\n\n/**\n * Content accepted by a Kerf JSX child position.\n *\n * Use this for `children` (and equivalent content slots) on third-party\n * function components. It deliberately mirrors the runtime: arrays may be\n * readonly and nested to any depth, signals bind fine-grained inside a mount,\n * and boolean/nullish values render nothing.\n */\nexport type JSXChildren =\n | SafeHtml\n | string\n | number\n | boolean\n | null\n | undefined\n | ReadonlySignal<unknown>\n | readonly JSXChildren[];\n\ninterface Props {\n children?: JSXChildren;\n [key: string]: unknown;\n}\n\nconst VOID_TAGS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'source',\n 'track',\n 'wbr',\n]);\n\n/**\n * Convert a single JSX child into a Segment. Handles SafeHtml passthrough,\n * primitive coercion + escaping, arrays (recursive), and the nullish/false\n * skip cases.\n */\nfunction toSegment(child: JSXChildren): Segment {\n if (child == null || typeof child === 'boolean')\n return { kind: 'static', html: '' };\n // KF-294: a signal handed straight into a text position. Inside a mount\n // render, emit a comment marker and record a binding so the text node\n // updates fine-grained (no render re-run). Outside a mount (SSR/toString),\n // snapshot the current value as escaped text.\n if (isSignal(child)) {\n const marker = bindText(child);\n if (marker !== null) return { kind: 'static', html: marker };\n const v = (child as Signal<unknown>).value;\n return {\n kind: 'static',\n html: v == null || typeof v === 'boolean' ? '' : escapeHtml(String(v)),\n };\n }\n if (isSafeHtml(child)) {\n // Cross-bundle SafeHtml shims (KF-14 case) may have only `__html`.\n return child.__segment ?? { kind: 'static', html: child.__html };\n }\n if (typeof child === 'string')\n return { kind: 'static', html: escapeHtml(child) };\n if (typeof child === 'number') return { kind: 'static', html: String(child) };\n if (Array.isArray(child)) return mergeChildSegments(child.map(toSegment));\n // Catch the common mistake of passing a DOM element (e.g. the result of\n // toElement(...)) as a JSX child. The runtime renders to HTML strings, so\n // DOM nodes can't be composed — they'd silently serialize to \"\" and their\n // event listeners would be lost. Throw loudly so this can't sneak in.\n const maybeNode = child as unknown;\n if (\n typeof maybeNode === 'object' &&\n maybeNode !== null &&\n ('nodeType' in maybeNode || 'outerHTML' in maybeNode)\n ) {\n throw new Error(\n 'JSX: DOM elements cannot be passed as children (the JSX runtime renders to HTML strings). ' +\n 'Build the tree in one JSX expression and use querySelector after toElement() to get element refs.',\n );\n }\n throw new Error(\n `JSX: unsupported child of type ${describeValue(child)}. ` +\n 'Children must be SafeHtml, string, number, boolean, null, undefined, a signal/computed, or a nested array of those. ' +\n 'Common mistakes: passing a Store object directly (use store.state.value), ' +\n 'passing a function (call it first), or passing a Promise (await it before render).',\n );\n}\n\nfunction describeValue(v: unknown): string {\n if (Array.isArray(v)) return 'array';\n if (typeof v === 'object' && v !== null) {\n const ctor = (v as { constructor?: { name?: string } }).constructor?.name;\n return ctor && ctor !== 'Object' ? `object (${ctor})` : 'object';\n }\n return typeof v;\n}\n\n/**\n * A well-formed HTML/SVG attribute name: a letter/underscore/colon, then\n * letters, digits, or `_.:-` — covers `class`, `data-id`, `aria-label`,\n * `xlink:href`, `xmlns:xlink`, `stroke-width`, `viewBox`, etc. A name outside\n * this shape can only come from spreading untrusted KEYS into JSX\n * (`<div {...obj}>`), and is exactly the shape that could carry the whitespace,\n * `>`, `=`, quotes, or control chars needed to break out of the open tag and\n * inject markup — so `renderAttr` rejects it (KF-306).\n */\nconst SAFE_ATTR_NAME = /^[A-Za-z_:][\\w.:-]*$/;\n\n/**\n * Reject an attribute NAME that kerf must never route into HTML or the DOM.\n * Shared by BOTH attribute paths so they enforce one contract (KF-306, KF-322):\n *\n * - the static string path (`renderAttr`) — a name is emitted verbatim into\n * the open tag, and `on*` values become live inline handlers once parsed;\n * - the fine-grained bound path (`jsx()` signal branch → `bindAttr` →\n * `setBoundAttr` → `el.setAttribute(name, …)`) — `setAttribute('onclick', …)`\n * installs a LIVE handler in the browser, an XSS vector that would otherwise\n * bypass the static guard entirely.\n *\n * Two rejections:\n * 1. `on*` (any case) — kerf's model is event delegation, never inline\n * handlers. `isFn` tailors the message: function values get the\n * delegate() migration pointer; string/signal/other values get the\n * XSS-aware message.\n * 2. a malformed name (spread of untrusted keys, `<div {...obj}>`) that could\n * break out of the open tag. The bound path can't actually inject markup\n * this way — `setAttribute` throws `InvalidCharacterError` rather than\n * parsing — but the same guard runs on both paths for one consistent\n * contract. Validated post-alias; every `ATTR_ALIASES` value is itself a\n * valid name, so aliasing is unaffected.\n */\nfunction assertEmittableAttrName(\n key: string,\n name: string,\n isFn: boolean,\n): void {\n if (/^on[a-z]/i.test(name)) {\n if (isFn) {\n throw new Error(\n `JSX: inline event handlers like ${key}={fn} are not supported by kerf's JSX → HTML-string runtime. ` +\n 'Use event delegation from the mount root instead:\\n\\n' +\n \" delegate(rootEl, 'click', '[data-action=\\\"...\\\"]', (evt, target) => { ... });\\n\" +\n ' <button data-action=\"...\">click</button>\\n\\n' +\n 'See docs/5-event-delegation.md for the tier-1/tier-2/tier-3 model.',\n );\n }\n throw new Error(\n `JSX: event-handler attribute ${JSON.stringify(key)} is not allowed — an ` +\n '`on*` attribute (whether a string emitted into HTML or a signal bound via ' +\n 'setAttribute) installs a live inline handler, an XSS vector. ' +\n \"kerf uses event delegation: delegate(rootEl, 'click', '[data-action=\\\"...\\\"]', handler). \" +\n 'See docs/5-event-delegation.md.',\n );\n }\n if (!SAFE_ATTR_NAME.test(name)) {\n throw new Error(\n `JSX: invalid attribute name ${JSON.stringify(key)}. Attribute names must be a ` +\n 'letter/underscore/colon followed by letters, digits, or \"_.:-\" (e.g. class, ' +\n 'data-id, aria-label, xlink:href). This usually means an untrusted object was ' +\n 'spread into JSX ({...obj}) with attacker-controlled keys — validate keys first.',\n );\n }\n}\n\n/**\n * KF-VBQJAX: per-name memo of the two checks that depend ONLY on the emitted\n * attribute name — `assertEmittableAttrName` passing, and whether the name is\n * URL-bearing (`isUrlAttrName`). A large page re-renders the same few dozen\n * names hundreds of thousands of times, and both checks are regex work.\n *\n * Only names that PASSED validation are stored (value: is-URL-attribute), so a\n * rejected name throws on every attempt with its exact message, as before; the\n * `isFn` message variant only matters for rejected names. Bounded so spreading\n * untrusted keys into JSX can't grow it without limit: once full, unseen names\n * are validated uncached.\n */\nconst VALIDATED_ATTR_NAMES = new Map<string, boolean>();\nconst VALIDATED_ATTR_NAMES_MAX = 1024;\n\n/** Validate `name` (throws like `assertEmittableAttrName`); true if URL-bearing. */\nfunction checkAttrName(key: string, name: string, isFn: boolean): boolean {\n const cached = VALIDATED_ATTR_NAMES.get(name);\n if (cached !== undefined) return cached;\n assertEmittableAttrName(key, name, isFn);\n const isUrl = isUrlAttrName(name);\n if (VALIDATED_ATTR_NAMES.size < VALIDATED_ATTR_NAMES_MAX)\n VALIDATED_ATTR_NAMES.set(name, isUrl);\n return isUrl;\n}\n\nfunction renderAttr(key: string, value: unknown, tag: string): string {\n return renderAttrNamed(key, ATTR_ALIASES[key] ?? key, value, tag);\n}\n\n/**\n * Core attribute renderer. `key` is the author-written attribute key (used in\n * error messages); `name` is the final emitted attribute name — post-alias for\n * JSX, verbatim for the `kerfjs/html` tagged-template path.\n */\nfunction renderAttrNamed(\n key: string,\n name: string,\n value: unknown,\n tag: string,\n): string {\n if (value == null || value === false) return '';\n const isUrlAttr = checkAttrName(key, name, typeof value === 'function');\n if (value === true) return ` ${name}`;\n let strValue: string;\n if (isSafeHtml(value)) {\n strValue = value.__html;\n } else if (typeof value === 'number') {\n strValue = String(value);\n } else if (typeof value === 'string') {\n // URL-screening shared with the fine-grained binding writer (KF-297).\n // `SafeHtml` values (raw()) skip this — they hit the branch above.\n // KF-340: throw in dev (fail loudly), warn+drop in prod.\n if (isUrlAttr && isDangerousUrl(value, isImageUrlSink(tag, name))) {\n reportDangerousUrl('JSX', name, value);\n return '';\n }\n strValue = escapeAttr(value);\n } else {\n throw new Error(\n `JSX: unsupported value for attribute \"${key}\" — got ${describeValue(value)}. ` +\n 'Attribute values must be string, number, boolean, null, undefined, or SafeHtml. ' +\n 'Did you mean to read .value off a Signal, or stringify the object first?',\n );\n }\n return ` ${name}=\"${strValue}\"`;\n}\n\nexport function jsx(\n tag: string | ((props: Props) => SafeHtml),\n props: Props,\n): SafeHtml {\n if (typeof tag === 'function') return tag(props);\n\n const children = props.children;\n let attrStr = '';\n let bindIds: string[] | null = null;\n // `for…in` with an own-key check, not a `{ children, ...attrs }` rest plus\n // `Object.entries`: same own-key order without two allocations per element,\n // and an inherited (e.g. prototype-polluted) key is never emitted.\n for (const k in props) {\n if (k === 'children' || !Object.hasOwn(props, k)) continue;\n const v = props[k];\n // KF-294: a signal handed straight into an attribute. Inside a mount\n // render, register a binding and mark the element (via `data-kfb` for\n // static-surround holes / `data-kfbrow` for each()-row holes) instead of\n // emitting the attribute — the wiring pass sets it after parse and keeps\n // it fine-grained. Outside a mount, snapshot the current value.\n if (isSignal(v)) {\n const name = ATTR_ALIASES[k] ?? k;\n // Reject `on*` / malformed names on the bound path too (KF-322 completes\n // KF-306). Unconditional: a signal's value can change over time, so we\n // can't gate on the current value — an `onclick={signal}` binding would\n // otherwise install a live inline handler via setAttribute, bypassing the\n // static renderAttr guard entirely. `isFn` is false: a signal is not a\n // function value, so this routes to the XSS-aware message.\n checkAttrName(k, name, false);\n const id = bindAttr(name, v);\n if (id !== null) {\n (bindIds ??= []).push(id);\n continue;\n }\n attrStr += renderAttr(k, (v as Signal<unknown>).value, tag);\n continue;\n }\n attrStr += renderAttr(k, v, tag);\n }\n // All signal attrs on one element share a scope, so the marker attr name is\n // fetched once (avoids a per-attr object alloc from bindAttr).\n if (bindIds !== null)\n attrStr += ` ${bindMarkerAttr()}=\"${bindIds.join(',')}\"`;\n\n if (VOID_TAGS.has(tag)) return new SafeHtml(`<${tag}${attrStr}>`);\n\n const childSegment: Segment =\n children != null ? toSegment(children) : { kind: 'static', html: '' };\n return new SafeHtml(\n wrapWithTags(childSegment, `<${tag}${attrStr}>`, `</${tag}>`),\n );\n}\n\nexport { jsx as jsxs };\n// vitest's dev-mode JSX transform emits `jsxDEV(tag, props, ...)`; the\n// alias lets tests import this module without the production build pipeline\n// caring.\nexport { jsx as jsxDEV };\n\nexport function Fragment({ children }: { children?: JSXChildren }): SafeHtml {\n return new SafeHtml(\n children != null ? toSegment(children) : { kind: 'static', html: '' },\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace JSX {\n export type Element = SafeHtml;\n export interface ElementChildrenAttribute {\n children: unknown;\n }\n // Per-tag attribute contracts live in `./jsx-types.ts` as\n // `KerfBuiltinIntrinsicElements`. Re-exposed as an **interface** (not a\n // type alias) so consumers can declaration-merge custom-element tags\n // (KF-100):\n //\n // declare module 'kerfjs/jsx-runtime' {\n // namespace JSX {\n // interface IntrinsicElements {\n // 'my-element': KerfCustomElement & { foo?: string };\n // }\n // }\n // }\n //\n // KF-123: the imported interface is named `KerfBuiltinIntrinsicElements`\n // upstream so tsup/tsc cannot strip an import alias and end up emitting\n // `interface IntrinsicElements extends IntrinsicElements {}` in the .d.ts\n // — that shadowed form self-resolves to empty and breaks every `<tag>` in\n // consumer .tsx with TS2339. Verified against `dist/jsx-runtime.d.ts` by\n // `tests/dist/jsx-typing/` on every `npm run build`.\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n export interface IntrinsicElements extends KerfBuiltinIntrinsicElements {}\n}\n\n/**\n * Internal coordination exports for the `kerfjs/html` tagged-template\n * front-end (`src/html.ts`). Underscore-prefixed and deliberately NOT in the\n * main barrel — the contract is that `html\\`\\`` routes through the exact same\n * value semantics as JSX (text holes: `_toSegment`; attribute holes:\n * `_assertEmittableAttrName` + `_renderAttrVerbatim`), so the two authoring\n * paths cannot drift. `_renderAttrVerbatim` skips the camelCase\n * `ATTR_ALIASES` table: template authors write real HTML attribute names\n * (`class`, not `className`).\n */\nexport function _toSegment(child: unknown): Segment {\n return toSegment(child as JSXChildren);\n}\n\nexport function _renderAttrVerbatim(\n name: string,\n value: unknown,\n tag: string,\n): string {\n return renderAttrNamed(name, name, value, tag);\n}\n\nexport { assertEmittableAttrName as _assertEmittableAttrName };\n\n/**\n * Public re-exports of the JSX type primitives so consumers can compose\n * attribute interfaces for custom elements without reaching into\n * `kerfjs/jsx-types` (which is intentionally not in `package.json#exports`).\n */\nexport type {\n AttrLike,\n AttrValue,\n DataAriaAttrs,\n KerfBaseAttrs,\n KerfCustomElement,\n} from './jsx-types.js';\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/syncFormProp.ts","../src/utils/url-screen.ts","../src/bindings.ts","../src/utils/escapeHtml.ts","../src/utils/jsx-attr-aliases.ts","../src/jsx-runtime.ts"],"names":["context","SAFE_HTML_BRAND"],"mappings":";;;;;AAgCO,SAAS,YAAA,CACd,EAAA,EACA,IAAA,EACA,KAAA,EACA,OAAA,EACM;AACN,EAAA,MAAM,MAAM,EAAA,CAAG,OAAA;AACf,EAAA,IAAI,SAAS,SAAA,EAAW;AACtB,IAAA,IAAI,GAAA,KAAQ,OAAA,EAAU,EAAA,CAAwB,OAAA,GAAU,OAAA;AAAA,EAC1D,CAAA,MAAA,IAAW,SAAS,OAAA,EAAS;AAC3B,IAAA,IAAI,GAAA,KAAQ,OAAA,IAAW,EAAA,KAAO,QAAA,CAAS,aAAA,EAAe;AACpD,MAAC,EAAA,CAAwB,KAAA,GAAQ,OAAA,GAAU,KAAA,GAAQ,EAAA;AAAA,IACrD;AAAA,EACF,CAAA,MAAA,IAAW,SAAS,UAAA,EAAY;AAC9B,IAAA,IAAI,GAAA,KAAQ,QAAA,EAAW,EAAA,CAAyB,QAAA,GAAW,OAAA;AAAA,EAC7D;AACF;;;ACGA,IAAM,SAAA,uBAAgB,GAAA,CAAI;AAAA,EACxB,MAAA;AAAA,EACA,KAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAC,CAAA;AAGD,IAAM,oCAAoB,IAAI,GAAA,CAAI,CAAC,YAAA,EAAc,UAAU,CAAC,CAAA;AA0B5D,IAAM,qBAAA,uBAA4B,GAAA,CAAI;AAAA,EACpC,aAAA;AAAA,EACA,cAAA;AAAA,EACA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AO,UAAU,KAAoB,CAAA;AACvC;AAEO,SAAS,mBAAA,CACd,IAAA,EACA,KAAA,EACA,GAAA,EACQ;AACR,EAAA,OAAO,eAAA,CAAgB,IAAA,EAAM,IAAA,EAAM,KAAA,EAAO,GAAG,CAAA;AAC/C","file":"chunk-4P6Z33YK.js","sourcesContent":["/**\n * Form-state property sync — shared by the morph's attribute writer and the\n * fine-grained binding writer (KF-335: controlled checked/value/selected went\n * stale after user interaction).\n *\n * Browsers detach a form control's live property from its attribute once the\n * control is \"dirty\" (the user — or script — has touched it): the attribute\n * becomes only the *default*. An attribute-only reconciler therefore updates\n * `checked=\"\"` / `value=\"…\"` / `selected=\"\"` while the visible state stays\n * stale.\n *\n * The rule: callers invoke this ONLY at the moment they actually MUTATE one of\n * these attributes (set, change, or remove). The property then follows the\n * attribute. Attribute-unchanged elements are never touched, so uncontrolled\n * usage — JSX that never mentions the attribute — keeps user-driven state\n * exactly as before. This is the same philosophy as the user-agent-owned\n * `open` carve-out on `<details>`/`<dialog>`: kerf only touches what the\n * template expressed an opinion about.\n *\n * The focused-element exception: a focused text-entry control's `value` is the\n * user's in-progress edit — the morph's preservation rule owns it, so `value`\n * sync is skipped for `document.activeElement`.\n *\n * Callers write the property BEFORE the attribute (KF-FMGEJ6). WebKit keeps a\n * clean input's change-event baseline at the value it was parsed with when only\n * its `value` attribute changes, and an attribute-first write leaves the\n * property already equal, so the property setter is a no-op there too. An input\n * parsed as `value=\"A\"` and re-pointed to `B` then fires no `change` when the\n * user types `A` back. Writing the property first really changes the value,\n * which resets the baseline; the attribute then sets only the default. The end\n * state is the same in every engine.\n */\nexport function syncFormProp(\n el: Element,\n name: string,\n value: string,\n present: boolean,\n): void {\n const tag = el.tagName;\n if (name === 'checked') {\n if (tag === 'INPUT') (el as HTMLInputElement).checked = present;\n } else if (name === 'value') {\n if (tag === 'INPUT' && el !== document.activeElement) {\n (el as HTMLInputElement).value = present ? value : '';\n }\n } else if (name === 'selected') {\n if (tag === 'OPTION') (el as HTMLOptionElement).selected = present;\n }\n}\n","/**\n * URL-attribute screening, shared by the JSX runtime's static-attribute\n * serializer (`renderAttr` in `jsx-runtime.ts`) and the fine-grained binding's\n * live-attribute writer (`setBoundAttr` in `bindings.ts`) — KF-297.\n *\n * A stored-XSS payload like `href={userInput}` with `javascript:alert(1)` is\n * dropped (attribute omitted from the string / removed from the live node)\n * rather than written. `raw(...)` / `SafeHtml` values bypass this — the\n * documented opt-out for legitimate cases (bookmarklet builders, values\n * sanitized by a separate trust layer).\n *\n * The screen is a scheme allow/deny check, not a full URL sanitizer, but it is\n * hardened against the obfuscations a real browser sees through:\n *\n * - **Control-character / whitespace obfuscation of the scheme.** Browsers\n * strip leading C0 controls + spaces and remove TAB/LF/CR from anywhere in\n * a URL before resolving the scheme, so `java\\tscript:`, `\\x01javascript:`,\n * and `javascript\\x00:` all resolve to `javascript:`. We normalize the same\n * way (strip every C0 control 0x00-0x1F + DEL, trim leading whitespace)\n * BEFORE extracting the scheme, so none of those slip past.\n *\n * - **The `javascript:` no-op placeholders are allowed.** `javascript:void(0)`\n * and its handful of spellings are the placeholder-link idiom, not an\n * attack; matching is against the whole normalized value so nothing can be\n * appended to them. See `INERT_JAVASCRIPT_URLS`.\n *\n * - **`data:` is subtype-specific.** `data:image/png` in `<img src>` is safe\n * and common; `data:text/html` / `data:image/svg+xml` / `data:*xml` load as\n * a document and run script (SVG `<script>`, HTML/XHTML `<script>`). We\n * allowlist the inert media families (raster images, fonts, audio, video,\n * plain text/css) and drop every other `data:` — so a novel dangerous\n * subtype fails closed.\n *\n * - **SVG is safe in an image sink only.** An SVG loaded as an image\n * (`<img src>`, SVG `<image href>`) renders in the browser's secure static\n * mode: no script, no external loads, no interaction. So\n * `data:image/svg+xml` passes there (`isImageUrlSink`) and stays blocked\n * everywhere else (`<iframe src>`, `<embed src>`, `<object data>`, `<a\n * href>`, …), where it loads as a script-capable document.\n */\n\nimport { devHooks } from '../dev-hooks.js';\n\n/**\n * URL-bearing HTML/SVG attributes whose plain-string values are screened.\n * `data` covers `<object data>` (loads its target as a document, so\n * `data:text/html` there executes). Image-context URL attributes\n * (`srcset` / `poster` / `background` / `ping`) are intentionally NOT screened:\n * a `javascript:` / `data:` value in them does not execute as script in modern\n * browsers, so screening would add false positives without closing a real sink.\n */\nconst URL_ATTRS = new Set([\n 'href',\n 'src',\n 'xlink:href',\n 'formaction',\n 'action',\n 'data',\n]);\n\n/** Schemes that execute script when a browser resolves them as a URL. */\nconst DANGEROUS_SCHEMES = new Set(['javascript', 'vbscript']);\n\n/**\n * `javascript:` URLs that are provably no-ops — the placeholder-link idiom\n * (`<a href=\"javascript:void(0)\">`) that a decade of jQuery-era markup, CMS\n * output, and ported templates is full of.\n *\n * Screening them out was a false positive with a bad failure mode: the `href`\n * is dropped, so the anchor stops being a link — no keyboard focus, no `:link`\n * styling, no pointer cursor — and in production that happens behind a\n * `console.warn` nobody reads.\n *\n * Allowing them costs nothing. The match is against the **whole** normalized\n * value, so no attacker-supplied suffix survives it: `javascript:void(0)` is in\n * the set and `javascript:void(0);alert(1)` is not. The bodies here evaluate to\n * `undefined` or to nothing at all, and they carry no interpolation point.\n *\n * The alternative — telling authors to write `raw('javascript:void(0)')` — is\n * strictly worse for security: it teaches the general-purpose escape hatch as\n * the answer to a benign case, and an author who has learned `raw()` for one\n * `href` will reach for it on the next one.\n *\n * Matching is exact after `normalizeUrl` + lowercase + trailing-whitespace trim.\n * Internal whitespace is NOT collapsed, so each accepted spelling is listed\n * explicitly and the set stays auditable at a glance.\n */\nconst INERT_JAVASCRIPT_URLS = new Set([\n 'javascript:',\n 'javascript:;',\n 'javascript:void(0)',\n 'javascript:void(0);',\n 'javascript:void 0',\n 'javascript:void 0;',\n]);\n\n/** Matches every C0 control character (0x00-0x1F) and DEL (0x7F). */\n// eslint-disable-next-line no-control-regex -- deliberately matching C0 + DEL.\nconst CONTROL_CHARS = /[\\u0000-\\u001F\\u007F]/g;\n\n/** Bound diagnostic payloads so an unsafe, attacker-controlled URL cannot flood logs. */\nconst DANGEROUS_URL_DIAGNOSTIC_VALUE_LENGTH = 80;\n\n/**\n * Normalize a URL the way a browser does before scheme resolution: remove every\n * C0 control (0x00-0x1F) and DEL (0x7F) from anywhere — no legitimate URL\n * carries a raw control char (they must be percent-encoded), so this collapses\n * `java\\tscript:` / `\\x01javascript:` / `javascript\\x00:` back to their real\n * scheme — then trim leading whitespace. Internal spaces are left intact: a\n * space is not a valid scheme character, so a browser treats `java script:` as\n * a relative URL, not the `javascript:` scheme, and we must not \"repair\" it\n * into a false positive.\n */\nfunction normalizeUrl(value: string): string {\n return value.replace(CONTROL_CHARS, '').replace(/^\\s+/, '');\n}\n\n/**\n * The lowercased URL scheme (text before the first `:`) of an ALREADY-NORMALIZED\n * value, or null if none.\n */\nfunction schemeOf(normalized: string): string | null {\n const m = /^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(normalized);\n return m ? m[1].toLowerCase() : null;\n}\n\n/**\n * True if a `data:` URL (already normalized) is a script-executing document\n * type. Allowlists the inert media families and fails closed on everything else\n * — so `text/html`, `image/svg+xml`, XHTML/XML, and any unknown/novel subtype\n * are all treated as dangerous, while `data:image/png` / fonts / audio / video\n * / plain text pass.\n */\nfunction isDangerousDataUrl(normalized: string, imageSink: boolean): boolean {\n const media =\n /^data:([^;,]*)/.exec(normalized.toLowerCase())?.[1].trim() ?? '';\n if (media === '' || media === 'text/plain' || media === 'text/css')\n return false;\n // SVG can carry <script>, which runs when it loads as a document; as an\n // image it renders in secure static mode and runs nothing.\n if (media === 'image/svg+xml') return !imageSink;\n if (media.startsWith('image/')) return false;\n if (media.startsWith('font/') || media.startsWith('application/font'))\n return false;\n if (media.startsWith('audio/') || media.startsWith('video/')) return false;\n return true; // text/html, application/xhtml+xml, *xml, unknown → block\n}\n\n/**\n * True if `name` is one of the URL-bearing attributes the screen inspects.\n * A pure function of the name, so callers that see the same attribute name\n * over and over (the JSX serializer) may cache its answer per name.\n */\nexport function isUrlAttrName(name: string): boolean {\n // HTML attribute names are ASCII-case-insensitive, and JSX can reach this\n // helper with the author-written casing on both static and bound paths.\n // Normalize before the allowlist check so `HREF` / `Src` / `XLINK:HREF`\n // cannot bypass the same browser sink written in lowercase.\n // Lowercase names (nearly all of them) are checked without allocating.\n return URL_ATTRS.has(/[A-Z]/.test(name) ? name.toLowerCase() : name);\n}\n\n/**\n * True if attribute `name` on element `tag` loads its URL as an image, where\n * an SVG renders in secure static mode and runs no script: `<img src>` and\n * SVG `<image href>` / `<image xlink:href>`. Tag and attribute names compare\n * case-insensitively.\n */\nexport function isImageUrlSink(tag: string, name: string): boolean {\n return /^(?:img:src|image:(?:xlink:)?href)$/i.test(`${tag}:${name}`);\n}\n\n/**\n * True if `value` is a dangerous URL for the URL-bearing attribute `name` on\n * element `tag` (omit `tag` when it is unknown; the screen then treats the\n * attribute as a document sink).\n */\nexport function isDangerousUrlValue(\n name: string,\n value: string,\n tag = '',\n): boolean {\n return (\n isUrlAttrName(name) && isDangerousUrl(value, isImageUrlSink(tag, name))\n );\n}\n\n/**\n * True if `value`, written into a URL-bearing attribute (see `isUrlAttrName`),\n * would resolve to a script-executing URL.\n */\nexport function isDangerousUrl(value: string, imageSink = false): boolean {\n // No `:` → no scheme, so nothing to screen: a relative URL (`/a/b`, `#x`,\n // `?q`, `logo.png`) is the common case in a large page. Exact: normalization\n // only ever REMOVES characters, so it can never introduce the `:` that\n // `schemeOf` needs.\n if (!value.includes(':')) return false;\n // Normalized once here — every helper below reasons about the same string the\n // browser's scheme resolution would see.\n const normalized = normalizeUrl(value);\n const scheme = schemeOf(normalized);\n if (scheme === null) return false;\n if (DANGEROUS_SCHEMES.has(scheme)) {\n return !INERT_JAVASCRIPT_URLS.has(normalized.trimEnd().toLowerCase());\n }\n return scheme === 'data' && isDangerousDataUrl(normalized, imageSink);\n}\n\n/**\n * The shared warning body for a dropped dangerous URL. Each caller prefixes\n * its own context (`JSX:` for the string serializer, `kerf binding:` for the\n * live-attribute writer).\n */\nexport function dangerousUrlWarning(name: string, value: string): string {\n return (\n `dropped dangerous URL value for ${name}=${JSON.stringify(value.slice(0, DANGEROUS_URL_DIAGNOSTIC_VALUE_LENGTH))}. ` +\n 'kerf blocks javascript:, vbscript:, and script-executing data: URLs ' +\n '(text/html, image/svg+xml, xml) in href/src/data/formaction/action/xlink:href by default. ' +\n 'Wrap in raw() if this is intentional (e.g. bookmarklets), or sanitize upstream.'\n );\n}\n\n/**\n * Report a screened dangerous URL, with the dev-vs-prod split (KF-340). Both\n * call sites (the JSX string serializer's `renderAttr` and the live-attribute\n * writer's `setBoundAttr`) still DROP the attribute; this only chooses how the\n * screen surfaces the diagnostic:\n *\n * - **DEV** (the consumer imported `kerfjs/dev`): THROW an `Error` with the\n * diagnostic, failing loudly at the developer's desk so a mistyped/unsafe\n * URL can't slip by unnoticed (nobody reads the console).\n * - **PRODUCTION** (no dev entry installed): `console.warn` and let the\n * caller drop — never crash a shipped app on attacker-influenced data.\n *\n * `context` is the caller's prefix (`JSX`/`kerf binding`); the composed message\n * is byte-identical to the pre-KF-340 warn text in production.\n */\nexport function reportDangerousUrl(\n context: string,\n name: string,\n value: string,\n): void {\n const message = `${context}: ${dangerousUrlWarning(name, value)}`;\n devHooks.urlScreenThrow?.(message);\n console.warn(message);\n}\n","/**\n * Fine-grained signal bindings (KF-294 spike).\n *\n * When a `Signal` is interpolated straight into a JSX attribute\n * (`class={sig}`) or a text child (`{sig}`) INSIDE a `mount()` render, the\n * JSX runtime stops stringifying it. Instead it emits a marker into the HTML\n * string and records a binding here; after the string is parsed to DOM, a\n * wiring pass attaches one `effect` per binding that writes straight to the\n * live node. A later change to that signal then updates the node WITHOUT\n * re-running the render function or walking the list reconciler.\n *\n * This reuses the \"marker in string, wire up after parse\" mechanism the\n * keyed-list reconciler already uses for `<!--kf-list:{id}-->` markers.\n *\n * TWO SCOPES of binding, with disjoint marker namespaces so their wiring\n * passes never collide:\n *\n * - GLOBAL holes — signals in the static surrounds (outside any `each()`\n * row). Markers: `data-kfb` attribute / `<!--kfb:{id}-->` comment. Ids come\n * from the mount render context's counter; wired by `wireBindings()` over\n * the whole mount root; disposed/re-wired by `mount()` each render.\n *\n * - ROW holes — signals inside an `each()` row. Markers: `data-kfbrow`\n * attribute / `<!--kfbr:{id}-->` comment. Ids are row-LOCAL (reset per row)\n * so they stay stable and collision-free as rows are inserted/removed/moved.\n * Captured per row by `captureRowBindings()`, carried on the list segment\n * item, and wired/disposed by the list reconciler at each row node's\n * create/remove — so a binding's lifetime tracks its row node's lifetime,\n * and row reorders (which reuse the same node) are free.\n *\n * Outside a `mount()` render (SSR / `SafeHtml.toString()`) neither scope is\n * active: the runtime snapshots `signal.value` and emits no markers, so server\n * output is correct and legacy `.toString()` callers are unaffected.\n *\n * Module-level mutable state note: `context` / `rowSink` (plus `rowCounter`,\n * the row-hole id counter that resets with each row capture) are a third\n * sanctioned module-level mutable location (alongside `store.ts:REGISTRY` and\n * `each.ts:context`). They hold the current render's binding sinks and are set\n * / cleared by `mount()` and `each()` around the render calls. The only other\n * module-level container here is `insertedTextNodes`, a WeakMap keyed on text\n * marker comments — a pure cache whose entries die with their nodes (GC-tied\n * lifetime), so it carries no cross-render semantics.\n */\n\nimport { effect, isSignal, type Signal } from './reactive.js';\nimport { isOverlayHost } from './utils/overlay-host.js';\nimport { syncFormProp } from './utils/syncFormProp.js';\nimport { isDangerousUrlValue, reportDangerousUrl } from './utils/url-screen.js';\n\n// RESERVED NAMESPACE (consumer contract, KF-314). The wiring pass finds these\n// markers by scanning the mounted subtree and matching by id, and resolves an\n// id collision by document order (last/first wins) with no ownership check — so\n// a consumer element that carries `data-kfb`/`data-kfbrow`, or a comment\n// beginning `kfb:`/`kfbr:`/`kf-list:`, can collide with a real binding's id and\n// steal its effect (the update wires to the wrong node). These names are\n// therefore reserved: consumers must not emit them (documented in\n// docs/2-reactivity.md § \"Reserved marker names\"). Kerf's own escaping already\n// prevents a plain text/attribute *value* from forging one; the remaining ways\n// in are a hand-written attribute or a `raw()` payload — i.e. the consumer's\n// own trust boundary. A dev-mode collision warning is a possible future\n// enhancement (fix direction (a) on KF-314) if silent mis-wiring proves easy to\n// hit in practice.\n\n/** Marker attribute for GLOBAL (static-surround) attribute bindings. */\nexport const BIND_ATTR = 'data-kfb';\n/** Comment-marker prefix for a GLOBAL text binding: `<!--kfb:{id}-->`. */\nexport const TEXT_MARKER_PREFIX = 'kfb:';\n/** Marker attribute for ROW (each()-scoped) attribute bindings. */\nexport const BIND_ATTR_ROW = 'data-kfbrow';\n/** Comment-marker prefix for a ROW text binding: `<!--kfbr:{id}-->`. */\nexport const ROW_TEXT_PREFIX = 'kfbr:';\n\ninterface AttrBinding {\n kind: 'attr';\n id: string;\n attr: string;\n signal: Signal<unknown>;\n}\ninterface TextBinding {\n kind: 'text';\n id: string;\n signal: Signal<unknown>;\n}\nexport type Binding = AttrBinding | TextBinding;\n\n/**\n * Per-render GLOBAL binding sink. `counter` assigns ids by registration order\n * (stable across renders since the JSX render is deterministic); `list`\n * accumulates this render's global (static-surround) holes.\n */\nexport interface BindingContext {\n counter: number;\n list: Binding[];\n}\n\nlet context: BindingContext | null = null;\n\n// Active row-capture sink + its row-local id counter. Non-null only while\n// `each()` renders a single row through `captureRowBindings()`.\nlet rowSink: Binding[] | null = null;\nlet rowCounter = 0;\n\n// Frozen shared sentinel for the no-holes case — readonly so no caller can\n// push into it and corrupt every other no-hole mount.\nconst NO_DISPOSERS: ReadonlyArray<() => void> = Object.freeze([]);\n\nexport function newBindingContext(): BindingContext {\n return { counter: 0, list: [] };\n}\n\nexport function _setBindingContext(c: BindingContext | null): void {\n context = c;\n}\n\n/**\n * Render one `each()` row while capturing the row-scoped bindings it emits.\n * Row ids are local (reset to 0) so they're stable + collision-free per row.\n * Returns the row HTML and its captured bindings (empty when the row has no\n * signal holes). Restores the prior capture state (supports nested `each()`).\n */\nexport function captureRowBindings(renderRow: () => string): {\n html: string;\n bindings: Binding[];\n} {\n const prevSink = rowSink;\n const prevCounter = rowCounter;\n rowSink = [];\n rowCounter = 0;\n try {\n const html = renderRow();\n return { html, bindings: rowSink };\n } finally {\n rowSink = prevSink;\n rowCounter = prevCounter;\n }\n}\n\n/**\n * Register a signal attribute. Routes to the row sink when a row capture is\n * active, else the global context. Returns the marker id,\n * or null to snapshot. The marker attribute NAME (`data-kfb` vs `data-kfbrow`)\n * is fetched once per element via `bindMarkerAttr()` — all of an element's\n * signal attrs share the same scope — so this avoids a per-attr object alloc.\n */\nexport function bindAttr(attr: string, signal: Signal<unknown>): string | null {\n if (rowSink !== null) {\n const id = `a${rowCounter++}`;\n rowSink.push({ kind: 'attr', id, attr, signal });\n return id;\n }\n if (context !== null) {\n const id = `a${context.counter++}`;\n context.list.push({ kind: 'attr', id, attr, signal });\n return id;\n }\n return null;\n}\n\n/**\n * The marker attribute name for the currently-active binding scope — row holes\n * use `data-kfbrow`, global holes `data-kfb`. Called once per element by the\n * JSX runtime after collecting the element's signal-attr ids.\n */\nexport function bindMarkerAttr(): string {\n return rowSink !== null ? BIND_ATTR_ROW : BIND_ATTR;\n}\n\n/**\n * Register a signal text hole. Returns the comment-marker HTML to emit, or\n * null to snapshot. Same routing as `bindAttr()`.\n */\nexport function bindText(signal: Signal<unknown>): string | null {\n if (rowSink !== null) {\n const id = `t${rowCounter++}`;\n rowSink.push({ kind: 'text', id, signal });\n return `<!--${ROW_TEXT_PREFIX}${id}-->`;\n }\n if (context !== null) {\n const id = `t${context.counter++}`;\n context.list.push({ kind: 'text', id, signal });\n return `<!--${TEXT_MARKER_PREFIX}${id}-->`;\n }\n return null;\n}\n\n/**\n * Wire this render's GLOBAL bindings against the freshly-built live DOM.\n * Disposes `prevDisposers` first (a surrounds-changed morph strips bound attrs\n * and removes inserted text nodes, so we re-establish them), then attaches one\n * effect per hole. Zero-cost when there are no global holes.\n *\n * `rows` — the `each()` rows bound in this mount — are not searched: a row\n * renders in row scope, so it carries only `data-kfbrow` / `kfbr:` markers,\n * never a global one. Skipping them keeps the marker search proportional to\n * the surrounds instead of to every row's subtree.\n */\nexport function wireBindings(\n rootEl: Element,\n ctx: BindingContext,\n prevDisposers: ReadonlyArray<() => void>,\n rows?: ReadonlySet<Element>,\n): ReadonlyArray<() => void> {\n for (const d of prevDisposers) d();\n if (ctx.list.length === 0) return NO_DISPOSERS;\n const disposers: Array<() => void> = [];\n try {\n wireInto(rootEl, ctx.list, disposers, rows);\n } catch (err) {\n // A hole whose first write threw (a throwing `computed`, a screened URL in\n // dev) must not strand the effects wired before it: nobody would ever\n // receive their disposers.\n for (const d of disposers) d();\n throw err;\n }\n return disposers;\n}\n\n/**\n * Wire one row's ROW-scoped bindings against its freshly-built row node\n * (including the node itself, since a row's top-level element may carry the\n * marker, e.g. `<tr data-kfbrow>`). Returns the row's disposers for the\n * reconciler to store on the bound item and call when the row node is removed.\n */\nexport function wireRowBindings(\n rowNode: Element,\n bindings: Binding[],\n): Array<() => void> {\n // Callers (snapshot buildFreshNodes, mount first-render inline) only invoke\n // this for rows with at least one binding, so no empty-guard is needed.\n //\n // Hot path: most row holes are an attribute on the row's ROOT element (e.g.\n // `<tr class={sig}>`). For those we resolve the node with a single\n // `getAttribute` + allocation-free id membership check — no marker walk, no\n // Map. The descendant-attr index and the\n // text-comment index are built lazily, only if a hole actually needs them.\n // Dense by construction: disposers are PUSHED, never index-assigned, so a\n // skipped hole (the defensive missing-marker `continue` below) leaves no gap\n // for `disposeRowBindings` / `mount()`'s release loop to trip over (KF-5FM1Z6:\n // a sparse slot would throw a TypeError when called during disposal).\n const disposers: Array<() => void> = [];\n const rootIds = rowNode.getAttribute(BIND_ATTR_ROW);\n // For the common single-root-binding row, `rootIds === b.id` resolves the\n // node with zero allocation. Only a row with 2+ root bindings builds the Set.\n let rootIdSet: Set<string> | null = null;\n // The descendant-attr and text-comment indexes come from one walk of the\n // row, made the first time a hole needs either.\n let markers: Markers | null = null;\n const rowMarkers = (): Markers =>\n (markers ??= indexMarkers(rowNode, BIND_ATTR_ROW, ROW_TEXT_PREFIX));\n\n try {\n for (let i = 0; i < bindings.length; i++) {\n const b = bindings[i];\n if (b.kind === 'attr') {\n let onRoot = false;\n if (rootIds !== null) {\n if (rootIds === b.id) {\n onRoot = true;\n } else if (rootIds.indexOf(',') !== -1) {\n rootIdSet ??= new Set(rootIds.split(','));\n onRoot = rootIdSet.has(b.id);\n }\n }\n let el: Element | undefined;\n if (onRoot) {\n el = rowNode;\n } else {\n el = rowMarkers().attrs.get(b.id);\n }\n // Defensive: a registered binding always emits its marker into the row.\n if (el === undefined) continue;\n disposers.push(attachAttrEffect(el, b.attr, b.signal));\n } else {\n const marker = rowMarkers().texts.get(b.id);\n // Defensive: same invariant as the attr branch.\n if (marker === undefined) continue;\n disposers.push(attachTextEffect(marker, b.signal));\n }\n }\n } catch (err) {\n // Same contract as `wireBindings`: a hole that throws on its first write\n // disposes the row's already-wired effects before the error propagates\n // (only wired holes were pushed, so every entry is callable).\n for (const d of disposers) d();\n throw err;\n }\n return disposers;\n}\n\n/** Dispose a row's binding effects (called when its node leaves the DOM). */\nexport function disposeRowBindings(\n disposers: Array<() => void> | undefined,\n): void {\n if (disposers === undefined) return;\n for (const d of disposers) d();\n}\n\n/**\n * KF-347 — decide, for a row whose DOM node survives an in-place update,\n * whether the live binding effects can be carried forward or must be\n * re-wired. The old effects closed over the signal INSTANCES captured at the\n * previous render; if this render's bindings reference the same instances\n * per hole (the cache-hit case, and rows binding stable external signals),\n * the old effects remain correct and re-wiring would be wasted work — the\n * select-row hot path stays free. If any hole's instance changed — the\n * typical shape after `arraySignal.update()` swaps the row object and the\n * row re-renders fresh `computed`s closing over the NEW item — the old\n * effects are stale (they'd keep reading the pre-update row), so dispose\n * them and wire the fresh bindings against the surviving node. Marker\n * alignment holds across every in-place route: row-local binding ids are\n * deterministic per render, the surgical fast paths leave marker attrs and\n * comments untouched, and `_morphElement` syncs them.\n *\n * Also covers the from-scratch case (`oldBindings` undefined with fresh\n * `newBindings`): the length mismatch routes to the wire branch, so a\n * replaceChild caller can hand its brand-new node straight here.\n */\nexport function carryOrRewireRowBindings(\n node: Element,\n oldBindings: Binding[] | undefined,\n oldDisposers: Array<() => void> | undefined,\n newBindings: Binding[] | undefined,\n): {\n bindings: Binding[] | undefined;\n bindingDisposers: Array<() => void> | undefined;\n} {\n const oldLen = oldBindings === undefined ? 0 : oldBindings.length;\n const newLen = newBindings === undefined ? 0 : newBindings.length;\n if (oldLen === newLen) {\n let same = true;\n for (let i = 0; i < newLen; i++) {\n if (\n (oldBindings as Binding[])[i].signal !==\n (newBindings as Binding[])[i].signal\n ) {\n same = false;\n break;\n }\n }\n if (same) return { bindings: oldBindings, bindingDisposers: oldDisposers };\n }\n disposeRowBindings(oldDisposers);\n return {\n bindings: newBindings,\n bindingDisposers:\n newLen > 0 ? wireRowBindings(node, newBindings as Binding[]) : undefined,\n };\n}\n\n/**\n * GLOBAL-scope wiring core. Indexes `data-kfb`-marked elements + `kfb:`\n * comment markers under `scope` by binding id, then attaches an effect per\n * binding. Row-scope wiring lives in `wireRowBindings` (with its own inlined\n * root-attr fast path), so this always operates on the GLOBAL marker names.\n */\nfunction wireInto(\n scope: Element,\n bindings: Binding[],\n disposers: Array<() => void>,\n rows: ReadonlySet<Element> | undefined,\n): void {\n const markers = indexMarkers(scope, BIND_ATTR, TEXT_MARKER_PREFIX, rows);\n\n for (const b of bindings) {\n if (b.kind === 'attr') {\n const el = markers.attrs.get(b.id);\n /* c8 ignore next -- defensive: a registered binding always emits its marker into `scope`. */\n if (el === undefined) continue;\n disposers.push(attachAttrEffect(el, b.attr, b.signal));\n } else {\n const marker = markers.texts.get(b.id);\n /* c8 ignore next -- defensive: same invariant as the attr branch. */\n if (marker === undefined) continue;\n disposers.push(attachTextEffect(marker, b.signal));\n }\n }\n}\n\n/**\n * One walk that indexes, by binding id, the DESCENDANT elements of `node`\n * carrying `attrName` and the comment markers starting with `textPrefix`,\n * stepping over overlay host slots (another mount's markers) and `skip` (the\n * bound rows, when wiring the global scope: rows carry only row-scope\n * markers). Hand-rolled because happy-dom's `TreeWalker` does not surface\n * comment nodes; the attribute index rides along on the same walk.\n */\nfunction indexMarkers(\n node: Node,\n attrName: string,\n textPrefix: string,\n skip?: ReadonlySet<Element>,\n out: Markers = { attrs: new Map(), texts: new Map() },\n): Markers {\n for (let c: Node | null = node.firstChild; c !== null; c = c.nextSibling) {\n if (c.nodeType === Node.COMMENT_NODE) {\n const data = (c as Comment).data;\n if (data.startsWith(textPrefix))\n out.texts.set(data.slice(textPrefix.length), c as Comment);\n } else if (c.nodeType === Node.ELEMENT_NODE) {\n const el = c as Element;\n if (skip?.has(el) || isOverlayHost(el)) continue;\n const ids = el.getAttribute(attrName);\n if (ids !== null) for (const id of ids.split(',')) out.attrs.set(id, el);\n indexMarkers(el, attrName, textPrefix, skip, out);\n }\n }\n return out;\n}\n\n/** Binding markers under a scope, by binding id. */\ninterface Markers {\n attrs: Map<string, Element>;\n texts: Map<string, Comment>;\n}\n\n/** Attach a fine-grained attribute effect; returns its disposer. */\nfunction attachAttrEffect(\n el: Element,\n attr: string,\n signal: Signal<unknown>,\n): () => void {\n return effect(() => setBoundAttr(el, attr, signal.value));\n}\n\n/**\n * Tracks the live text node each text-hole marker owns, so RE-wiring a hole\n * (KF-347 — an in-place row update whose binding instances changed) reuses\n * the node it inserted the first time instead of stacking a second one next\n * to it. Keyed on the marker comment: markers persist exactly as long as\n * their row/surround nodes do, so the WeakMap entries die with them.\n */\nconst insertedTextNodes = new WeakMap<Comment, Text>();\n\n/**\n * The live text node `marker` currently owns, or null (KF-374 — morph drops\n * static siblings of a bound hole). Position-strict, same rule as the reuse\n * check below: the node counts as owned only while it still sits at\n * `marker.nextSibling`. The morph's child pairing uses this to step PAST the\n * binding-inserted node — the template never contains it (templates carry\n * only the marker comment), so without the skip a template static sibling\n * pairs positionally with the inserted node, the morph overwrites the bound\n * text with the static content, and the real static sibling falls off the\n * cursor's tail and is removed.\n */\nexport function boundTextNodeOf(marker: Comment): Text | null {\n const t = insertedTextNodes.get(marker);\n return t !== undefined && marker.nextSibling === t ? t : null;\n}\n\n/**\n * Bind a live text node after `marker` to `signal`; returns the effect\n * disposer. Reuses the marker's previously-inserted node when it is still\n * exactly where we put it (`marker.nextSibling`) — a rewire then just\n * retargets the write, preserving node identity. Anything else (fresh parse,\n * node removed by a morph) inserts anew. The reuse check is deliberately\n * position-strict so a static text node that legitimately follows the marker\n * in template output can never be hijacked: static content sits at\n * `nextSibling` only until the FIRST wiring inserts our node in front of it.\n */\nfunction attachTextEffect(\n marker: Comment,\n signal: Signal<unknown>,\n): () => void {\n let text = insertedTextNodes.get(marker);\n if (text === undefined || marker.nextSibling !== text) {\n text = (marker.ownerDocument as Document).createTextNode('');\n (marker.parentNode as Node).insertBefore(text, marker.nextSibling);\n insertedTextNodes.set(marker, text);\n }\n const node = text;\n return effect(() => {\n node.data = coerceText(signal.value);\n });\n}\n\n/**\n * Apply a bound value to a live attribute, mirroring the JSX runtime's\n * `renderAttr` rules: boolean/nullish toggling, `SafeHtml` (raw()) unwrapping,\n * and the KF-297 URL-screening that drops `javascript:` / `vbscript:` /\n * `data:text/html` on `href`/`src`/`formaction`/`action`/`xlink:href`.\n *\n * Unlike `renderAttr` (which builds an HTML string, so escapes with\n * `escapeAttr`), this writes the RAW value via `setAttribute` — the DOM stores\n * attribute values verbatim, so no HTML-escaping is applied here.\n *\n * The attribute NAME is trusted here: `on*` and malformed names are rejected at\n * binding-registration time in the JSX runtime's `jsx()` signal branch (shared\n * `assertEmittableAttrName`, KF-322), so `setAttribute('onclick', …)` — which\n * would install a live inline handler — can never reach this writer.\n */\nfunction setBoundAttr(el: Element, name: string, value: unknown): void {\n // KF-335: every attribute write below also syncs the matching form-state\n // property (checked/value/selected) — after user interaction the dirty flag\n // detaches the property from the attribute, so an attribute-only write\n // leaves the visible state stale. `syncFormProp` no-ops for other names,\n // and runs before the attribute write (KF-FMGEJ6: WebKit's change\n // baseline; see `syncFormProp`).\n if (value == null || value === false) {\n syncFormProp(el, name, '', false);\n el.removeAttribute(name);\n return;\n }\n if (value === true) {\n syncFormProp(el, name, '', true);\n el.setAttribute(name, '');\n return;\n }\n // SafeHtml (raw()) is the documented opt-out — bypasses URL screening and is\n // written verbatim, matching renderAttr's SafeHtml branch.\n if (isSafeHtmlValue(value)) {\n syncFormProp(el, name, value.__html, true);\n el.setAttribute(name, value.__html);\n return;\n }\n const str = String(value);\n if (isDangerousUrlValue(name, str, el.localName)) {\n // KF-340: throw in dev (fail loudly), warn+drop in prod.\n reportDangerousUrl('kerf binding', name, str);\n el.removeAttribute(name);\n return;\n }\n syncFormProp(el, name, str, true);\n el.setAttribute(name, str);\n}\n\n// Cross-bundle SafeHtml brand check (mirrors jsx-runtime's `isSafeHtml`).\n// Duplicated here — rather than importing `isSafeHtml` from jsx-runtime — to\n// keep the bindings ← jsx-runtime dependency acyclic. `Symbol.for` makes it\n// recognize SafeHtml instances from any copy of the module.\nconst SAFE_HTML_BRAND = Symbol.for('kerfjs.SafeHtml');\nfunction isSafeHtmlValue(v: unknown): v is { __html: string } {\n return (\n typeof v === 'object' &&\n v !== null &&\n (v as Record<symbol, unknown>)[SAFE_HTML_BRAND] === true\n );\n}\n\n/**\n * Coerce a bound text value or a non-`SafeHtml` `mount()` render result:\n * nullish + boolean render nothing (React-style, so `{cond && <jsx/>}` works),\n * everything else is stringified. Shared with `mount.ts`.\n */\nexport function coerceText(value: unknown): string {\n if (value == null || typeof value === 'boolean') return '';\n return String(value);\n}\n\n// Re-exported so the JSX runtime imports signal-detection + binding\n// registration from one place.\nexport { isSignal };\n","/**\n * HTML / attribute escaping for the JSX runtime. Identical to the helpers\n * used in any reasonable HTML emitter — included here so kerf has no extra\n * runtime dependencies beyond `@preact/signals-core`.\n */\n\nconst ENTITIES: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n};\n\n// One pass over the string, appending the unescaped runs between matches.\n// A value with nothing to escape (most ids, classes, SVG path data) comes back\n// as the same string with no allocation; one that needs escaping is about 2x\n// faster than a chain of one `replace` pass per character.\nfunction escapeWith(str: string, special: RegExp): string {\n special.lastIndex = 0;\n let out = '';\n let last = 0;\n let match;\n while ((match = special.exec(str))) {\n out += str.slice(last, match.index) + ENTITIES[match[0]];\n last = special.lastIndex;\n }\n return last ? out + str.slice(last) : str;\n}\n\nconst HTML_SPECIAL = /[&<>\"]/g;\nconst ATTR_SPECIAL = /[&\"'<>]/g;\n\nexport function escapeHtml(str: string): string {\n return escapeWith(str, HTML_SPECIAL);\n}\n\nexport function escapeAttr(str: string): string {\n return escapeWith(str, ATTR_SPECIAL);\n}\n","/**\n * JSX → HTML / SVG attribute name aliases.\n *\n * The JSX runtime translates camelCase attributes (React convention) to\n * the kebab-case / colon-form names the browser actually wants. Anything\n * not in this map is passed through verbatim — `data-*`, `aria-*`, and\n * any custom attribute work without ceremony.\n *\n * Lives in its own module so the alias data stays a separable concern from\n * `src/jsx-runtime.ts`'s runtime logic; the bulk of `jsx-runtime.ts` was this\n * table.\n *\n * **When a camelCase attribute needs an entry.** Pass-through is not the same\n * as \"no translation\": an unlisted `fooBar` is emitted verbatim, and the HTML\n * parser then lowercases it to `foobar`. That is silently *correct* whenever\n * the real attribute name is exactly the lowercased spelling (`fetchPriority`\n * → `fetchpriority`, `charSet` → `charset`, `playsInline` → `playsinline`), and\n * silently *wrong* whenever it isn't — `defaultSelected` rendered\n * `defaultselected`, an attribute no browser has ever read, so the option it\n * was supposed to pre-select never was. Any camelCase key whose HTML name is\n * not its own lowercase MUST have a row here.\n *\n * `tests/unit/jsx-attr-names.test.ts` pins that rule: it reads every attribute\n * key declared in `src/jsx-types.ts` and asserts the name kerf would actually\n * emit for each camelCase one, so a new typed attribute cannot join without\n * someone stating what it renders as.\n *\n * SVG is the reason the lowercasing shortcut can't be relied on in general —\n * SVG attribute names are case-sensitive, and only the fixed set in the HTML\n * parser's SVG adjustment table (`viewBox`, `preserveAspectRatio`,\n * `pathLength`, …) survives the round trip with its case intact.\n */\n\nexport const ATTR_ALIASES: Record<string, string> = {\n // HTML attributes\n className: 'class',\n htmlFor: 'for',\n httpEquiv: 'http-equiv',\n acceptCharset: 'accept-charset',\n accessKey: 'accesskey',\n autoCapitalize: 'autocapitalize',\n autoComplete: 'autocomplete',\n autoFocus: 'autofocus',\n autoPlay: 'autoplay',\n colSpan: 'colspan',\n contentEditable: 'contenteditable',\n crossOrigin: 'crossorigin',\n dateTime: 'datetime',\n defaultChecked: 'checked',\n defaultSelected: 'selected',\n defaultValue: 'value',\n encType: 'enctype',\n formAction: 'formaction',\n formEncType: 'formenctype',\n formMethod: 'formmethod',\n formNoValidate: 'formnovalidate',\n formTarget: 'formtarget',\n hrefLang: 'hreflang',\n inputMode: 'inputmode',\n maxLength: 'maxlength',\n minLength: 'minlength',\n noModule: 'nomodule',\n noValidate: 'novalidate',\n readOnly: 'readonly',\n referrerPolicy: 'referrerpolicy',\n rowSpan: 'rowspan',\n spellCheck: 'spellcheck',\n srcDoc: 'srcdoc',\n srcLang: 'srclang',\n srcSet: 'srcset',\n tabIndex: 'tabindex',\n useMap: 'usemap',\n\n // SVG presentation attributes (camelCase → kebab-case)\n strokeWidth: 'stroke-width',\n strokeLinecap: 'stroke-linecap',\n strokeLinejoin: 'stroke-linejoin',\n strokeDasharray: 'stroke-dasharray',\n strokeDashoffset: 'stroke-dashoffset',\n strokeMiterlimit: 'stroke-miterlimit',\n strokeOpacity: 'stroke-opacity',\n fillOpacity: 'fill-opacity',\n fillRule: 'fill-rule',\n clipPath: 'clip-path',\n clipRule: 'clip-rule',\n colorInterpolation: 'color-interpolation',\n colorInterpolationFilters: 'color-interpolation-filters',\n floodColor: 'flood-color',\n floodOpacity: 'flood-opacity',\n lightingColor: 'lighting-color',\n stopColor: 'stop-color',\n stopOpacity: 'stop-opacity',\n shapeRendering: 'shape-rendering',\n imageRendering: 'image-rendering',\n textRendering: 'text-rendering',\n pointerEvents: 'pointer-events',\n vectorEffect: 'vector-effect',\n paintOrder: 'paint-order',\n\n // SVG text/font attributes\n fontFamily: 'font-family',\n fontSize: 'font-size',\n fontStyle: 'font-style',\n fontVariant: 'font-variant',\n fontWeight: 'font-weight',\n fontStretch: 'font-stretch',\n textAnchor: 'text-anchor',\n textDecoration: 'text-decoration',\n dominantBaseline: 'dominant-baseline',\n alignmentBaseline: 'alignment-baseline',\n baselineShift: 'baseline-shift',\n letterSpacing: 'letter-spacing',\n wordSpacing: 'word-spacing',\n writingMode: 'writing-mode',\n\n // SVG marker attributes\n markerStart: 'marker-start',\n markerMid: 'marker-mid',\n markerEnd: 'marker-end',\n\n // SVG xlink (legacy but still used)\n xlinkHref: 'xlink:href',\n xlinkShow: 'xlink:show',\n xlinkActuate: 'xlink:actuate',\n xlinkType: 'xlink:type',\n xlinkRole: 'xlink:role',\n xlinkTitle: 'xlink:title',\n xlinkArcrole: 'xlink:arcrole',\n xmlBase: 'xml:base',\n xmlLang: 'xml:lang',\n xmlSpace: 'xml:space',\n xmlnsXlink: 'xmlns:xlink',\n};\n","/**\n * kerf JSX runtime.\n *\n * JSX renders to `SafeHtml`, which wraps both:\n * - `__html`: the flattened HTML string (what `toString()` returns; what\n * legacy/SSR consumers care about)\n * - `__segment`: a structured representation that distinguishes \"static\n * html\", \"keyed list\", and \"mixed\" content.\n *\n * Most renders are pure-static and the segment is just `{kind:'static',html}`.\n * When the tree contains a list (via `each()`) or a parent whose children\n * include a non-static segment, the runtime threads that structure up so\n * `mount()` can dispatch on it — running its native keyed reconciler for\n * the list parts and leaving the static surrounds to the general-purpose\n * diff.\n *\n * Configure in your `tsconfig.json`:\n *\n * \"jsx\": \"react-jsx\",\n * \"jsxImportSource\": \"kerfjs\"\n *\n * Then write JSX as you normally would — kerf provides the `jsx` /\n * `jsxs` / `jsxDEV` / `Fragment` exports the JSX transform looks for.\n */\n\nimport { bindAttr, bindMarkerAttr, bindText, isSignal } from './bindings.js';\nimport type { KerfBuiltinIntrinsicElements } from './jsx-types.js';\nimport type { ReadonlySignal, Signal } from './reactive.js';\nimport {\n flatten,\n type ListSegment,\n mergeChildSegments,\n type Segment,\n wrapWithTags,\n} from './segment.js';\nimport { escapeAttr, escapeHtml } from './utils/escapeHtml.js';\nimport { ATTR_ALIASES } from './utils/jsx-attr-aliases.js';\nimport {\n isDangerousUrl,\n isImageUrlSink,\n isUrlAttrName,\n reportDangerousUrl,\n} from './utils/url-screen.js';\n\n// Cross-realm/cross-bundle brand. Using `Symbol.for` (the global registry)\n// means two `SafeHtml` classes from different module copies still recognize\n// each other. Same approach React uses for `$$typeof: Symbol.for('react.element')`.\n// Without this, `instanceof SafeHtml` fails when the consumer's bundler ends\n// up loading two copies of kerf (separate barrel + jsx-runtime entries,\n// monorepo dedup misses, ESM/CJS interop, etc.).\nconst SAFE_HTML_BRAND = Symbol.for('kerfjs.SafeHtml');\n\nexport class SafeHtml {\n readonly __segment: Segment;\n // Branded so `isSafeHtml()` recognizes instances from any copy of this module.\n readonly [SAFE_HTML_BRAND] = true as const;\n // The flattened HTML, computed on first read. A structured segment wraps its\n // children's segments rather than their strings, so flattening eagerly made\n // every element above an `each()` copy all of the list's row HTML again —\n // O(depth × rows) per render, while `mount()` reads only the segment.\n #html: string | undefined;\n constructor(input: string | Segment) {\n if (typeof input === 'string') {\n this.__segment = { kind: 'static', html: input };\n this.#html = input;\n } else {\n this.__segment = input;\n if (input.kind === 'static') this.#html = input.html;\n }\n }\n /** The flattened HTML string (what `toString()` returns). */\n get __html(): string {\n return (this.#html ??= flatten(this.__segment, false));\n }\n toString(): string {\n return this.__html;\n }\n}\n\n/**\n * Type guard for `SafeHtml`. Prefer this over `instanceof SafeHtml` — it works\n * across module copies (e.g. when the consumer's bundler loads kerf's barrel\n * and JSX-runtime entries as independent modules).\n *\n * Security note (KF-321): this is a duck-check on the global `Symbol.for` brand,\n * so same-realm code *can* forge a \"trusted\" value — `{ [SAFE_HTML_BRAND]: true,\n * __html: '<img onerror=…>' }` passes and bypasses escaping + the URL screen.\n * This is intentional and not a vulnerability: minting the brand requires a\n * Symbol key, which no data channel (JSON.parse, form/query/localStorage,\n * structuredClone, JSON-based prototype-pollution) can produce — those all yield\n * string keys. The only way to forge it is to run JS that writes the symbol, and\n * such code can equally `import { raw }`. Forgery therefore grants no capability\n * an attacker with code execution lacks — the same posture as React's\n * `$$typeof: Symbol.for('react.element')`. The global `Symbol.for` (vs a\n * module-private symbol) is a deliberate cross-bundle-recognition tradeoff (see\n * the `SAFE_HTML_BRAND` note above); a private symbol would additionally block\n * same-realm forgery, but only closes a non-threat at the cost of that\n * recognition, so it's kept global by design.\n */\nexport function isSafeHtml(value: unknown): value is SafeHtml {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<symbol, unknown>)[SAFE_HTML_BRAND] === true\n );\n}\n\n/**\n * Inject a pre-escaped HTML string verbatim, bypassing kerf's auto-escaping.\n *\n * **Reach for this rarely.** kerf escapes automatically everywhere else, so a lot\n * of `raw()` in a codebase is usually a sign the wrong tool is being used — the\n * common cases have a safer, first-class answer:\n * - Interpolating dynamic text/attributes? Plain JSX (`<p>{value}</p>`,\n * `class={sig}`) already escapes it; you don't need `raw()`.\n * - Composing markup? Build a {@link SafeHtml} the normal way — a JSX expression,\n * the `html` tagged template (`kerfjs/html`), `each()`, or a component function\n * that returns JSX. Those all produce trusted `SafeHtml` without hand-writing\n * an HTML string.\n * - A genuinely trusted, pre-escaped **dynamic** value (server output, config, a\n * hard-coded string)? That's the one legitimate use. The\n * `kerfjs/no-raw-with-dynamic-arg` lint rule flags a `raw()` whose argument is\n * not a literal — because unsanitized user input is the canonical XSS mistake —\n * so acknowledge it with a `// eslint-disable-next-line\n * kerfjs/no-raw-with-dynamic-arg` at that call. That explicit override is the\n * single sanctioned way to say \"I've reviewed this; it's trusted,\" and it\n * leaves a searchable audit trail.\n *\n * `raw()` is NOT a sanitizer — it does no escaping. For user-controlled input,\n * sanitize first (`raw(DOMPurify.sanitize(marked(userMarkdown)))`) or, better,\n * render it through escaping JSX instead.\n */\nexport function raw(html: string): SafeHtml {\n return new SafeHtml(html);\n}\n\n/**\n * Internal: build a `SafeHtml` representing a list segment. Used by\n * `each()` so the JSX runtime is the sole owner of `SafeHtml` construction.\n */\nexport function listSafeHtml(\n id: string,\n items: ListSegment['items'],\n source?: object,\n): SafeHtml {\n return new SafeHtml({ kind: 'list', id, items, source });\n}\n\n/**\n * Internal: build a `SafeHtml` representing a granular list segment with\n * patches (KF-92). The reconciler applies the patches to the existing\n * binding directly, skipping the per-item iteration that the snapshot\n * `listSafeHtml` requires. `items` is included for fall-through paths\n * (toString during SSR, fall-back when the binding doesn't exist yet).\n *\n * Patch HTML is rendered upstream (in `each()`) inside a try/catch — see\n * KF-99 — so by the time we get here every `update` / `insert` patch\n * already carries a `html` string, and the reconciler does no further\n * row rendering.\n */\nexport function granularListSafeHtml(\n id: string,\n items: ListSegment['items'],\n patches: NonNullable<ListSegment['patches']>,\n source?: object,\n): SafeHtml {\n return new SafeHtml({ kind: 'list', id, items, patches, source });\n}\n\n/**\n * Content accepted by a Kerf JSX child position.\n *\n * Use this for `children` (and equivalent content slots) on third-party\n * function components. It deliberately mirrors the runtime: arrays may be\n * readonly and nested to any depth, signals bind fine-grained inside a mount,\n * and boolean/nullish values render nothing.\n */\nexport type JSXChildren =\n | SafeHtml\n | string\n | number\n | boolean\n | null\n | undefined\n | ReadonlySignal<unknown>\n | readonly JSXChildren[];\n\ninterface Props {\n children?: JSXChildren;\n [key: string]: unknown;\n}\n\nconst VOID_TAGS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'source',\n 'track',\n 'wbr',\n]);\n\n/**\n * Convert a single JSX child into a Segment. Handles SafeHtml passthrough,\n * primitive coercion + escaping, arrays (recursive), and the nullish/false\n * skip cases.\n */\nfunction toSegment(child: JSXChildren): Segment {\n if (child == null || typeof child === 'boolean')\n return { kind: 'static', html: '' };\n // KF-294: a signal handed straight into a text position. Inside a mount\n // render, emit a comment marker and record a binding so the text node\n // updates fine-grained (no render re-run). Outside a mount (SSR/toString),\n // snapshot the current value as escaped text.\n if (isSignal(child)) {\n const marker = bindText(child);\n if (marker !== null) return { kind: 'static', html: marker };\n const v = (child as Signal<unknown>).value;\n return {\n kind: 'static',\n html: v == null || typeof v === 'boolean' ? '' : escapeHtml(String(v)),\n };\n }\n if (isSafeHtml(child)) {\n // Cross-bundle SafeHtml shims (KF-14 case) may have only `__html`.\n return child.__segment ?? { kind: 'static', html: child.__html };\n }\n if (typeof child === 'string')\n return { kind: 'static', html: escapeHtml(child) };\n if (typeof child === 'number') return { kind: 'static', html: String(child) };\n if (Array.isArray(child)) return mergeChildSegments(child.map(toSegment));\n // Catch the common mistake of passing a DOM element (e.g. the result of\n // toElement(...)) as a JSX child. The runtime renders to HTML strings, so\n // DOM nodes can't be composed — they'd silently serialize to \"\" and their\n // event listeners would be lost. Throw loudly so this can't sneak in.\n const maybeNode = child as unknown;\n if (\n typeof maybeNode === 'object' &&\n maybeNode !== null &&\n ('nodeType' in maybeNode || 'outerHTML' in maybeNode)\n ) {\n throw new Error(\n 'JSX: DOM elements cannot be passed as children (the JSX runtime renders to HTML strings). ' +\n 'Build the tree in one JSX expression and use querySelector after toElement() to get element refs.',\n );\n }\n throw new Error(\n `JSX: unsupported child of type ${describeValue(child)}. ` +\n 'Children must be SafeHtml, string, number, boolean, null, undefined, a signal/computed, or a nested array of those. ' +\n 'Common mistakes: passing a Store object directly (use store.state.value), ' +\n 'passing a function (call it first), or passing a Promise (await it before render).',\n );\n}\n\nfunction describeValue(v: unknown): string {\n if (Array.isArray(v)) return 'array';\n if (typeof v === 'object' && v !== null) {\n const ctor = (v as { constructor?: { name?: string } }).constructor?.name;\n return ctor && ctor !== 'Object' ? `object (${ctor})` : 'object';\n }\n return typeof v;\n}\n\n/**\n * A well-formed HTML/SVG attribute name: a letter/underscore/colon, then\n * letters, digits, or `_.:-` — covers `class`, `data-id`, `aria-label`,\n * `xlink:href`, `xmlns:xlink`, `stroke-width`, `viewBox`, etc. A name outside\n * this shape can only come from spreading untrusted KEYS into JSX\n * (`<div {...obj}>`), and is exactly the shape that could carry the whitespace,\n * `>`, `=`, quotes, or control chars needed to break out of the open tag and\n * inject markup — so `renderAttr` rejects it (KF-306).\n */\nconst SAFE_ATTR_NAME = /^[A-Za-z_:][\\w.:-]*$/;\n\n/**\n * Reject an attribute NAME that kerf must never route into HTML or the DOM.\n * Shared by BOTH attribute paths so they enforce one contract (KF-306, KF-322):\n *\n * - the static string path (`renderAttr`) — a name is emitted verbatim into\n * the open tag, and `on*` values become live inline handlers once parsed;\n * - the fine-grained bound path (`jsx()` signal branch → `bindAttr` →\n * `setBoundAttr` → `el.setAttribute(name, …)`) — `setAttribute('onclick', …)`\n * installs a LIVE handler in the browser, an XSS vector that would otherwise\n * bypass the static guard entirely.\n *\n * Two rejections:\n * 1. `on*` (any case) — kerf's model is event delegation, never inline\n * handlers. `isFn` tailors the message: function values get the\n * delegate() migration pointer; string/signal/other values get the\n * XSS-aware message.\n * 2. a malformed name (spread of untrusted keys, `<div {...obj}>`) that could\n * break out of the open tag. The bound path can't actually inject markup\n * this way — `setAttribute` throws `InvalidCharacterError` rather than\n * parsing — but the same guard runs on both paths for one consistent\n * contract. Validated post-alias; every `ATTR_ALIASES` value is itself a\n * valid name, so aliasing is unaffected.\n */\nfunction assertEmittableAttrName(\n key: string,\n name: string,\n isFn: boolean,\n): void {\n if (/^on[a-z]/i.test(name)) {\n if (isFn) {\n throw new Error(\n `JSX: inline event handlers like ${key}={fn} are not supported by kerf's JSX → HTML-string runtime. ` +\n 'Use event delegation from the mount root instead:\\n\\n' +\n \" delegate(rootEl, 'click', '[data-action=\\\"...\\\"]', (evt, target) => { ... });\\n\" +\n ' <button data-action=\"...\">click</button>\\n\\n' +\n 'See docs/5-event-delegation.md for the tier-1/tier-2/tier-3 model.',\n );\n }\n throw new Error(\n `JSX: event-handler attribute ${JSON.stringify(key)} is not allowed — an ` +\n '`on*` attribute (whether a string emitted into HTML or a signal bound via ' +\n 'setAttribute) installs a live inline handler, an XSS vector. ' +\n \"kerf uses event delegation: delegate(rootEl, 'click', '[data-action=\\\"...\\\"]', handler). \" +\n 'See docs/5-event-delegation.md.',\n );\n }\n if (!SAFE_ATTR_NAME.test(name)) {\n throw new Error(\n `JSX: invalid attribute name ${JSON.stringify(key)}. Attribute names must be a ` +\n 'letter/underscore/colon followed by letters, digits, or \"_.:-\" (e.g. class, ' +\n 'data-id, aria-label, xlink:href). This usually means an untrusted object was ' +\n 'spread into JSX ({...obj}) with attacker-controlled keys — validate keys first.',\n );\n }\n}\n\n/**\n * KF-VBQJAX: per-name memo of the two checks that depend ONLY on the emitted\n * attribute name — `assertEmittableAttrName` passing, and whether the name is\n * URL-bearing (`isUrlAttrName`). A large page re-renders the same few dozen\n * names hundreds of thousands of times, and both checks are regex work.\n *\n * Only names that PASSED validation are stored (value: is-URL-attribute), so a\n * rejected name throws on every attempt with its exact message, as before; the\n * `isFn` message variant only matters for rejected names. Bounded so spreading\n * untrusted keys into JSX can't grow it without limit: once full, unseen names\n * are validated uncached.\n */\nconst VALIDATED_ATTR_NAMES = new Map<string, boolean>();\nconst VALIDATED_ATTR_NAMES_MAX = 1024;\n\n/** Validate `name` (throws like `assertEmittableAttrName`); true if URL-bearing. */\nfunction checkAttrName(key: string, name: string, isFn: boolean): boolean {\n const cached = VALIDATED_ATTR_NAMES.get(name);\n if (cached !== undefined) return cached;\n assertEmittableAttrName(key, name, isFn);\n const isUrl = isUrlAttrName(name);\n if (VALIDATED_ATTR_NAMES.size < VALIDATED_ATTR_NAMES_MAX)\n VALIDATED_ATTR_NAMES.set(name, isUrl);\n return isUrl;\n}\n\nfunction renderAttr(key: string, value: unknown, tag: string): string {\n return renderAttrNamed(key, ATTR_ALIASES[key] ?? key, value, tag);\n}\n\n/**\n * Core attribute renderer. `key` is the author-written attribute key (used in\n * error messages); `name` is the final emitted attribute name — post-alias for\n * JSX, verbatim for the `kerfjs/html` tagged-template path.\n */\nfunction renderAttrNamed(\n key: string,\n name: string,\n value: unknown,\n tag: string,\n): string {\n if (value == null || value === false) return '';\n const isUrlAttr = checkAttrName(key, name, typeof value === 'function');\n if (value === true) return ` ${name}`;\n let strValue: string;\n if (isSafeHtml(value)) {\n strValue = value.__html;\n } else if (typeof value === 'number') {\n strValue = String(value);\n } else if (typeof value === 'string') {\n // URL-screening shared with the fine-grained binding writer (KF-297).\n // `SafeHtml` values (raw()) skip this — they hit the branch above.\n // KF-340: throw in dev (fail loudly), warn+drop in prod.\n if (isUrlAttr && isDangerousUrl(value, isImageUrlSink(tag, name))) {\n reportDangerousUrl('JSX', name, value);\n return '';\n }\n strValue = escapeAttr(value);\n } else {\n throw new Error(\n `JSX: unsupported value for attribute \"${key}\" — got ${describeValue(value)}. ` +\n 'Attribute values must be string, number, boolean, null, undefined, or SafeHtml. ' +\n 'Did you mean to read .value off a Signal, or stringify the object first?',\n );\n }\n return ` ${name}=\"${strValue}\"`;\n}\n\nexport function jsx(\n tag: string | ((props: Props) => SafeHtml),\n props: Props,\n): SafeHtml {\n if (typeof tag === 'function') return tag(props);\n\n const children = props.children;\n let attrStr = '';\n let bindIds: string[] | null = null;\n // `for…in` with an own-key check, not a `{ children, ...attrs }` rest plus\n // `Object.entries`: same own-key order without two allocations per element,\n // and an inherited (e.g. prototype-polluted) key is never emitted.\n for (const k in props) {\n if (k === 'children' || !Object.hasOwn(props, k)) continue;\n const v = props[k];\n // KF-294: a signal handed straight into an attribute. Inside a mount\n // render, register a binding and mark the element (via `data-kfb` for\n // static-surround holes / `data-kfbrow` for each()-row holes) instead of\n // emitting the attribute — the wiring pass sets it after parse and keeps\n // it fine-grained. Outside a mount, snapshot the current value.\n if (isSignal(v)) {\n const name = ATTR_ALIASES[k] ?? k;\n // Reject `on*` / malformed names on the bound path too (KF-322 completes\n // KF-306). Unconditional: a signal's value can change over time, so we\n // can't gate on the current value — an `onclick={signal}` binding would\n // otherwise install a live inline handler via setAttribute, bypassing the\n // static renderAttr guard entirely. `isFn` is false: a signal is not a\n // function value, so this routes to the XSS-aware message.\n checkAttrName(k, name, false);\n const id = bindAttr(name, v);\n if (id !== null) {\n (bindIds ??= []).push(id);\n continue;\n }\n attrStr += renderAttr(k, (v as Signal<unknown>).value, tag);\n continue;\n }\n attrStr += renderAttr(k, v, tag);\n }\n // All signal attrs on one element share a scope, so the marker attr name is\n // fetched once (avoids a per-attr object alloc from bindAttr).\n if (bindIds !== null)\n attrStr += ` ${bindMarkerAttr()}=\"${bindIds.join(',')}\"`;\n\n if (VOID_TAGS.has(tag)) return new SafeHtml(`<${tag}${attrStr}>`);\n\n const childSegment: Segment =\n children != null ? toSegment(children) : { kind: 'static', html: '' };\n return new SafeHtml(\n wrapWithTags(childSegment, `<${tag}${attrStr}>`, `</${tag}>`),\n );\n}\n\nexport { jsx as jsxs };\n// vitest's dev-mode JSX transform emits `jsxDEV(tag, props, ...)`; the\n// alias lets tests import this module without the production build pipeline\n// caring.\nexport { jsx as jsxDEV };\n\nexport function Fragment({ children }: { children?: JSXChildren }): SafeHtml {\n return new SafeHtml(\n children != null ? toSegment(children) : { kind: 'static', html: '' },\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace JSX {\n export type Element = SafeHtml;\n export interface ElementChildrenAttribute {\n children: unknown;\n }\n // Per-tag attribute contracts live in `./jsx-types.ts` as\n // `KerfBuiltinIntrinsicElements`. Re-exposed as an **interface** (not a\n // type alias) so consumers can declaration-merge custom-element tags\n // (KF-100):\n //\n // declare module 'kerfjs/jsx-runtime' {\n // namespace JSX {\n // interface IntrinsicElements {\n // 'my-element': KerfCustomElement & { foo?: string };\n // }\n // }\n // }\n //\n // KF-123: the imported interface is named `KerfBuiltinIntrinsicElements`\n // upstream so tsup/tsc cannot strip an import alias and end up emitting\n // `interface IntrinsicElements extends IntrinsicElements {}` in the .d.ts\n // — that shadowed form self-resolves to empty and breaks every `<tag>` in\n // consumer .tsx with TS2339. Verified against `dist/jsx-runtime.d.ts` by\n // `tests/dist/jsx-typing/` on every `npm run build`.\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n export interface IntrinsicElements extends KerfBuiltinIntrinsicElements {}\n}\n\n/**\n * Internal coordination exports for the `kerfjs/html` tagged-template\n * front-end (`src/html.ts`). Underscore-prefixed and deliberately NOT in the\n * main barrel — the contract is that `html\\`\\`` routes through the exact same\n * value semantics as JSX (text holes: `_toSegment`; attribute holes:\n * `_assertEmittableAttrName` + `_renderAttrVerbatim`), so the two authoring\n * paths cannot drift. `_renderAttrVerbatim` skips the camelCase\n * `ATTR_ALIASES` table: template authors write real HTML attribute names\n * (`class`, not `className`).\n */\nexport function _toSegment(child: unknown): Segment {\n return toSegment(child as JSXChildren);\n}\n\nexport function _renderAttrVerbatim(\n name: string,\n value: unknown,\n tag: string,\n): string {\n return renderAttrNamed(name, name, value, tag);\n}\n\nexport { assertEmittableAttrName as _assertEmittableAttrName };\n\n/**\n * Public re-exports of the JSX type primitives so consumers can compose\n * attribute interfaces for custom elements without reaching into\n * `kerfjs/jsx-types` (which is intentionally not in `package.json#exports`).\n */\nexport type {\n AttrLike,\n AttrValue,\n DataAriaAttrs,\n KerfBaseAttrs,\n KerfCustomElement,\n} from './jsx-types.js';\n"]}
|
|
@@ -38,10 +38,11 @@ function _delegate(rootEl, type, selector, bind, options, capture, fn) {
|
|
|
38
38
|
return void 0;
|
|
39
39
|
};
|
|
40
40
|
const listener = (event) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
const path = event.composedPath();
|
|
42
|
+
let [prior, snap] = event[KEY] ?? [];
|
|
43
|
+
if (!snap?.has(resolve) || path.some((node, i) => node !== prior[i]) || prior[path.length]) {
|
|
44
|
+
event[KEY] = [path, snap = /* @__PURE__ */ new Map()];
|
|
45
|
+
for (const node of path) {
|
|
45
46
|
for (const other of node[KEY] ?? []) {
|
|
46
47
|
snap.set(other, other(event));
|
|
47
48
|
}
|
|
@@ -83,4 +84,4 @@ function delegateCapture(rootEl, type, selector, handler, options) {
|
|
|
83
84
|
|
|
84
85
|
export { NON_BUBBLING, _delegate, delegate, delegateCapture };
|
|
85
86
|
|
|
86
|
-
//# sourceMappingURL=chunk-
|
|
87
|
+
//# sourceMappingURL=chunk-AP2FT33F.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/delegate.ts"],"names":[],"mappings":";;;AA+CO,IAAM,YAAA,uBAAmB,GAAA,CAAY;AAAA,EAC1C,OAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF,CAAC;AAqBD,SAAS,mBAAA,CAAoB,UAAkB,EAAA,EAAkB;AAC/D,EAAA,IAAI;AACF,IAAA,QAAA,CAAS,aAAA,CAAc,KAAK,CAAA,CAAE,OAAA,CAAQ,QAAQ,CAAA;AAAA,EAChD,CAAA,CAAA,MAAQ;AACN,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,EAAG,EAAE,CAAA,oBAAA,EAAuB,QAAQ,CAAA,2EAAA;AAAA,KAEtC;AAAA,EACF;AACF;AASA,IAAM,sBAAM,MAAA,EAAO;AAuDZ,SAAS,UACd,MAAA,EACA,IAAA,EACA,UACA,IAAA,EACA,OAAA,EACA,SACA,EAAA,EACY;AACZ,EAAA,mBAAA,CAAoB,UAAU,EAAE,CAAA;AAChC,EAAA,QAAA,CAAS,mBAAmB,EAAE,CAAA;AAC9B,EAAA,MAAM,MAAA,GAAS,SAAS,KAAA,KAAU,QAAA;AAClC,EAAA,MAAM,OAAA,GAAmB,CAAC,KAAA,KAAU;AAClC,IAAA,MAAM,SAAS,KAAA,CAAM,MAAA;AACrB,IAAA,IAAI,KAAA,CAAM,IAAA,KAAS,IAAA,IAAQ,MAAA,YAAkB,OAAA,EAAS;AACpD,MAAA,MAAM,OAAA,GAAU,MAAA,GACZ,MAAA,CAAO,OAAA,CAAQ,QAAQ,IACrB,MAAA,GACA,IAAA,GACF,MAAA,CAAO,OAAA,CAAQ,QAAQ,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,MAAA,CAAO,gBAAA,CAAiB,IAAA,EAAM,QAAA,EAAU,OAAO,CAAA;AAC/C,EAAA,OAAO,MAAM;AACX,IAAA,QAAA,CAAS,OAAO,OAAO,CAAA;AACvB,IAAA,MAAA,CAAO,mBAAA,CAAoB,IAAA,EAAM,QAAA,EAAU,OAAO,CAAA;AAAA,EACpD,CAAA;AACF;AAuBO,SAAS,QAAA,CACd,MAAA,EACA,IAAA,EACA,QAAA,EACA,SACA,OAAA,EACY;AACZ,EAAA,OAAO,SAAA;AAAA,IACL,MAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,CAAC,KAAA,EAAO,OAAA,KAAY,MAAM,OAAA,CAAQ,OAAO,OAAY,CAAA;AAAA,IACrD,OAAA;AAAA,IACA,YAAA,CAAa,IAAI,IAAI,CAAA;AAAA,IACrB;AAAA,GACF;AACF;AAuBO,SAAS,eAAA,CACd,MAAA,EACA,IAAA,EACA,QAAA,EACA,SACA,OAAA,EACY;AACZ,EAAA,OAAO,SAAA;AAAA,IACL,MAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,CAAC,KAAA,EAAO,OAAA,KAAY,MAAM,OAAA,CAAQ,OAAO,OAAY,CAAA;AAAA,IACrD,OAAA;AAAA,IACA,IAAA;AAAA,IACA;AAAA,GACF;AACF","file":"chunk-AP2FT33F.js","sourcesContent":["/**\n * Tiny event-delegation helpers. Replace per-element `addEventListener` calls\n * (which don't survive morph re-renders for nodes the diff creates) with one\n * listener at the morph-root that dispatches via `closest()`.\n *\n * Three-tier listener model:\n *\n * - Tier 1 (bubbling events) — use `delegate()`.\n * click, input, change, submit, mousedown/up, keydown/up, pointerdown/up/move,\n * drag*, drop, contextmenu, wheel, copy/paste/cut, focusin/focusout.\n *\n * `delegate()` also auto-promotes the well-known non-bubbling event\n * types (`focus`, `blur`, `scroll`, `load`, `error`, `mouseenter`,\n * `mouseleave`) to the capture phase under the hood, so the call site\n * looks identical for \"interactive thing happens on a descendant\"\n * regardless of whether that event bubbles. Selector matching stays\n * `closest()`-style — the same as for bubbling events — so a wrapper\n * selector like `'.field-row'` still matches when the event fires on\n * a descendant `<input>`.\n *\n * - Tier 2 (explicit capture) — use `delegateCapture()`.\n * The escape hatch for cases the auto-promotion list doesn't cover\n * (custom non-bubbling events) or when you want capture-phase\n * interception. Selector matching is `closest()`-style by default —\n * the same walk-up as `delegate()`, and it passes the matched ancestor\n * (not the raw target) to the handler — so a click on any descendant of\n * the selected element climbs to it. Pass `{ match: 'direct' }` to opt\n * into strict `matches()`-style matching (fire only when the event lands\n * on the exact element the selector identifies).\n *\n * - Tier 3 (per-element instances / library-owned subtrees) — mark the\n * host element with `data-morph-skip` and manage the library's\n * lifecycle directly. No delegation helper applies.\n */\n\nimport { devHooks } from './dev-hooks.js';\n\n/**\n * Event types that don't bubble and so wouldn't reach a root-level\n * bubble-phase listener. `delegate()` flips to capture for these; the\n * caller doesn't need to know or care.\n *\n * Membership is conservative — it covers the cases that \"should obviously\n * work\" with delegate() but otherwise don't. For exotic non-bubbling events\n * (custom events, less-common DOM events) the explicit `delegateCapture()`\n * remains the escape hatch.\n */\nexport const NON_BUBBLING = new Set<string>([\n 'focus',\n 'blur',\n 'scroll',\n 'load',\n 'error',\n 'mouseenter',\n 'mouseleave',\n]);\n\n/**\n * How the selector is matched against the event's target:\n *\n * - `'closest'` (the default for both helpers) — walk UP from `event.target`\n * via `closest(selector)`, firing for the nearest matching ancestor inside\n * `rootEl`. This is the delegation behavior you almost always want: a click\n * on an icon inside a button fires the button's handler.\n * - `'direct'` — strict `matches()` match: fire only when `event.target`\n * itself matches the selector, with no walk-up.\n */\nexport interface DelegateOptions {\n match?: 'closest' | 'direct';\n}\n\n/**\n * Validate a CSS selector at registration time, so a typo throws immediately\n * with the bad selector quoted instead of producing a cryptic DOMException\n * the first time a matching event fires.\n */\nfunction assertValidSelector(selector: string, fn: string): void {\n try {\n document.createElement('div').matches(selector);\n } catch {\n throw new Error(\n `${fn}: invalid selector \"${selector}\". ` +\n \"Pass a valid CSS selector (e.g. '[data-action=\\\"add\\\"]', '.btn', 'input').\",\n );\n }\n}\n\n/**\n * Per-root registry of the delegates installed on that root, and the per-event\n * dispatch snapshot. Both live ON the DOM objects, under one symbol key (a\n * root and an event are never the same object), rather than in module-level\n * maps — so they are collected with the root / event and add no module-level\n * mutable state (Design rule 5).\n */\nconst KEY = Symbol();\n\n/**\n * Resolves one delegate's selector against an event's target: the bound\n * handler call for a match, `undefined` otherwise.\n */\ntype Resolve = (event: Event) => (() => void) | undefined;\n\ninterface Registered {\n [KEY]?: Set<Resolve>;\n}\n\ninterface Snapshotted {\n [KEY]?: [EventTarget[], Map<Resolve, (() => void) | undefined>];\n}\n\n/**\n * Install one root-level delegate — the shared core of `delegate()`,\n * `delegateCapture()`, and `kerfjs/actions`' `delegateActions()`.\n *\n * The listener resolves the event's target to a matched element (walk-up\n * `closest()` or strict `matches()`, per `options.match`) that must lie inside\n * `rootEl`, then runs the call `bind(event, matched)` prepared. `bind` runs at\n * RESOLUTION time, so a caller can read matched-element state there (such as\n * `delegateActions`' action attribute) before any handler has mutated it.\n *\n * **Dispatch snapshot.** A handler that writes a signal makes `mount()` morph\n * synchronously, inside the same dispatch, and the morph can recycle the\n * clicked element in place into a control with a different selector identity\n * (same tag, same position, new `data-action`). Resolving later delegates\n * against that live DOM would fire one the user never clicked — typically one\n * that immediately undoes the first handler's state change. So the FIRST kerf\n * delegate listener to see an event resolves every kerf delegate on the\n * event's propagation path (fixed at dispatch start, per the DOM spec, and\n * listed by `composedPath()`) before any delegated handler runs, and stores\n * the results on the event; each listener then consumes its own entry. The\n * set of delegates an event reaches is fixed when it starts dispatching, like\n * per-element listeners. The matched element must also still be inside\n * `rootEl` when the listener runs: a handler that removed the target still\n * suppresses the later delegates, as before.\n *\n * A missing entry (a re-dispatch of the same event object, a delegate added\n * mid-dispatch, or a root hidden from the first listener by a closed shadow\n * boundary) takes a fresh snapshot, and so does a snapshot recorded on a\n * different propagation path: a stopped dispatch leaves entries unconsumed,\n * and the same event object re-dispatched on another target (or after its\n * target moved) must not consume them (KF-50DWVS: a re-dispatched stopped\n * event could hand a later listener its stale entry). A same-path re-dispatch\n * re-resolves at its first kerf listener, whose entry the first dispatch\n * already consumed. Accepted residuals: a same-path re-dispatch after a\n * stopped dispatch can reuse an unconsumed entry if all earlier kerf\n * listeners were disposed, and a closed shadow boundary can hide delegates\n * from the first listener's path view. See docs/5 §5.2.1.\n * Internal — exported for `kerfjs/actions`.\n */\nexport function _delegate(\n rootEl: HTMLElement,\n type: string,\n selector: string,\n bind: (event: Event, matched: Element) => () => void,\n options: DelegateOptions | undefined,\n capture: boolean,\n fn: 'delegate' | 'delegateCapture',\n): () => void {\n assertValidSelector(selector, fn);\n devHooks.delegateInEffect?.(fn);\n const direct = options?.match === 'direct';\n const resolve: Resolve = (event) => {\n const target = event.target;\n if (event.type === type && target instanceof Element) {\n const matched = direct\n ? target.matches(selector)\n ? target\n : null\n : target.closest(selector);\n if (matched !== null) {\n const run = bind(event, matched);\n // Checked when the handler would run, not at resolution: a match\n // outside `rootEl` never fires, and neither does one an earlier\n // handler removed from `rootEl`.\n return () => {\n if (rootEl.contains(matched)) run();\n };\n }\n }\n return undefined;\n };\n const listener = (event: Event): void => {\n const path = event.composedPath();\n let [prior, snap] = (event as Snapshotted)[KEY] ?? [];\n // A missing entry, or a snapshot taken on another propagation path (the\n // same event object re-dispatched after a stopped dispatch left entries\n // unconsumed), resolves afresh.\n if (\n !snap?.has(resolve) ||\n path.some((node, i) => node !== prior![i]) ||\n prior![path.length]\n ) {\n (event as Snapshotted)[KEY] = [path, (snap = new Map())];\n for (const node of path) {\n for (const other of (node as Registered)[KEY] ?? []) {\n snap.set(other, other(event));\n }\n }\n }\n const run = snap.get(resolve);\n snap.delete(resolve);\n run?.();\n };\n const registry = ((rootEl as Registered)[KEY] ??= new Set()).add(resolve);\n rootEl.addEventListener(type, listener, capture);\n return () => {\n registry.delete(resolve);\n rootEl.removeEventListener(type, listener, capture);\n };\n}\n\n/**\n * Delegation that \"just works\" for both bubbling and the common non-bubbling\n * events. Installs ONE listener on `rootEl`; for known non-bubblers (see\n * `NON_BUBBLING` above) the listener is registered on the capture phase so\n * it actually reaches the target, otherwise on the bubble phase. Either way,\n * matching walks up from `event.target` via `closest(selector)` and fires\n * `handler(event, matched)` if the match is inside `rootEl`.\n *\n * Pass `{ match: 'direct' }` to fire only when `event.target` itself matches\n * the selector (no walk-up); the default is `'closest'`.\n *\n * The generic `T` narrows the second handler argument to the expected element\n * type — `delegate<HTMLButtonElement>(root, 'click', 'button', (e, btn) => btn.value)`\n * — so consumers can avoid casts. Defaults to `Element` for untyped calls.\n *\n * Returns a disposer that removes the listener.\n *\n * Usage (pseudo-code — see examples for live ones):\n * delegate(rootEl, 'click', '[data-action=\"add\"]', handlerFn);\n * delegate(rootEl, 'focus', 'input', handlerFn); // auto-capture\n */\nexport function delegate<T extends Element = Element>(\n rootEl: HTMLElement,\n type: string,\n selector: string,\n handler: (event: Event, target: T) => void,\n options?: DelegateOptions,\n): () => void {\n return _delegate(\n rootEl,\n type,\n selector,\n (event, matched) => () => handler(event, matched as T),\n options,\n NON_BUBBLING.has(type),\n 'delegate',\n );\n}\n\n/**\n * Capture-phase delegation — the escape hatch for custom non-bubbling events\n * (ones `delegate()`'s auto-promotion list doesn't know about) and for\n * capture-phase interception (run before any descendant's bubble-phase\n * handler). Reaches descendants of `rootEl` that match `selector` regardless\n * of how many times the diff has rebuilt them.\n *\n * Selector matching is `closest()`-style by default — the same walk-up as\n * `delegate()`, and it passes the matched ancestor (not the raw target) to\n * the handler — so a click on any descendant of the selected element climbs\n * to it. Pass `{ match: 'direct' }` to opt into strict `matches()`-style\n * matching (fire only when the event lands on the exact element the selector\n * identifies, with no walk-up).\n *\n * The generic `T` narrows the second handler argument to the expected element\n * type, mirroring `delegate<T>()`. Defaults to `Element` for untyped calls.\n *\n * Usage (pseudo-code — see examples for live ones):\n * delegateCapture(rootEl, 'focus', 'input, textarea', handlerFn);\n * delegateCapture(rootEl, 'click', '.exact', handlerFn, { match: 'direct' });\n */\nexport function delegateCapture<T extends Element = Element>(\n rootEl: HTMLElement,\n type: string,\n selector: string,\n handler: (event: Event, target: T) => void,\n options?: DelegateOptions,\n): () => void {\n return _delegate(\n rootEl,\n type,\n selector,\n (event, matched) => () => handler(event, matched as T),\n options,\n true,\n 'delegateCapture',\n );\n}\n"]}
|