kerfjs 5.0.0-beta.124 → 5.0.0-beta.126

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/README.md +5 -0
  3. package/ai/manifest.json +1 -1
  4. package/dist/actions.js +1 -1
  5. package/dist/attach.js +1 -1
  6. package/dist/{chunk-MFRXN2G4.js → chunk-5QDM6HPD.js} +67 -145
  7. package/dist/chunk-5QDM6HPD.js.map +1 -0
  8. package/dist/{chunk-ZZI5NJIV.js → chunk-AP2FT33F.js} +6 -5
  9. package/dist/chunk-AP2FT33F.js.map +1 -0
  10. package/dist/{chunk-FM6N2B4N.js → chunk-BTOKH5FA.js} +1 -1
  11. package/dist/{chunk-FM6N2B4N.js.map → chunk-BTOKH5FA.js.map} +1 -1
  12. package/dist/{chunk-XL35DIZ2.js → chunk-GGADRIQO.js} +4 -4
  13. package/dist/chunk-GGADRIQO.js.map +1 -0
  14. package/dist/{chunk-6LXUC4ZY.js → chunk-NRPLVJVR.js} +16 -14
  15. package/dist/chunk-NRPLVJVR.js.map +1 -0
  16. package/dist/{chunk-OWNZCCJX.js → chunk-V322Z7FX.js} +3 -3
  17. package/dist/chunk-V322Z7FX.js.map +1 -0
  18. package/dist/dev.js +3 -3
  19. package/dist/dev.js.map +1 -1
  20. package/dist/html.js +1 -1
  21. package/dist/index.js +4 -4
  22. package/dist/jsx-runtime.d.ts +4 -4
  23. package/dist/jsx-runtime.js +1 -1
  24. package/dist/list.js +112 -61
  25. package/dist/list.js.map +1 -1
  26. package/dist/overlay.js +11 -7
  27. package/dist/overlay.js.map +1 -1
  28. package/dist/remount.js +1 -1
  29. package/dist/remount.js.map +1 -1
  30. package/dist/router.d.ts +7 -2
  31. package/dist/router.js +9 -6
  32. package/dist/router.js.map +1 -1
  33. package/dist/scope.d.ts +12 -2
  34. package/dist/scope.js +22 -14
  35. package/dist/scope.js.map +1 -1
  36. package/dist/testing.js +1 -1
  37. package/dist/timing.d.ts +14 -5
  38. package/dist/timing.js +7 -2
  39. package/dist/timing.js.map +1 -1
  40. package/package.json +8 -5
  41. package/setup/apply.mjs +202 -0
  42. package/setup/common.mjs +77 -0
  43. package/setup/detect.mjs +274 -0
  44. package/setup/index.mjs +482 -875
  45. package/dist/chunk-6LXUC4ZY.js.map +0 -1
  46. package/dist/chunk-MFRXN2G4.js.map +0 -1
  47. package/dist/chunk-OWNZCCJX.js.map +0 -1
  48. package/dist/chunk-XL35DIZ2.js.map +0 -1
  49. package/dist/chunk-ZZI5NJIV.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -8,10 +8,40 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
8
8
 
9
9
  ### Removed
10
10
 
11
+ - **`@kerfjs/ui/view` generator internals (KF-V5DPD1).** `printDoc` and `moduleSpecifier` are no longer exported by the public view subpath; repository tests import them from the generator module. The view subpath has only shipped in the 5.0.0 beta line.
11
12
  - **Pinned TabBarItem support.** Removed `pinned` and its sticky/backdrop tokens and RTL compensation. Put fixed controls in TabBar's existing `leading`, `trailing`, or `end` zones outside the scrolling tablist. Ordinary tabs retain keyboard navigation, selection reveal, reordering, scroll dividers, and optional whole-tab snapping (`KF-K6GKN3`).
12
13
 
13
14
  ### Added
14
15
 
16
+ - **Differential `bindList` and morph transition fuzzing (KF-YVMSEK).** Seeded mutations now compare incremental output with a fresh render across snapshot, granular, virtualized, and live-DOM protection states; directed tests cover recovery, refill, measured heights, and paired lists.
17
+ - **Kerf UI size, density, and inset prop vocabulary (KF-XQJECP).** Control sizes and row densities use `default` / `compact`; surface inset props use `none`, `compact`, `default`, or `comfortable` where applicable. Legacy literals remain accepted for this major version, with `KUI-L026` analyzer review findings and canonical DOM attributes. The component catalog records aliases and semantic exceptions, and its check rejects new divergent literals. `DialogSurface`'s legacy `compact` inset keeps its 8px geometry; new callers use `default` for 8px.
18
+
19
+ - **`debouncedSignal()` can be disposed (KF-EE8EPV).** It returns a `DebouncedSignal<T>`: the same read-only signal plus an idempotent `dispose()` that unsubscribes from the source and drops any pending write.
20
+ - **`@kerfjs/ui/view` exports one child-kind dispatch (KF-TZKGBZ).** `childKind()` / `classifyChild()` and the `ViewEachChild` / `ViewIfChild` / `ViewSlotChild` types replace hand-written `'$each' in child` chains.
21
+ - **`@kerfjs/ui` exports a shared `SurfacePresentation` type (KF-0MY6JQ).** The popover and pinnable presentation types are now aliases of it.
22
+ - **`npm create kerf-component --name <package-name>` (KF-7H7FWV).** Scoped package names are now reachable; the CLI rejects unknown flags and explains when the target is an existing file.
23
+ - **Kerf UI `wireTabBars` reports how each TabBar's tabs fit (KF-XFG3FZ).** A new `onFitChange(fit)` option reports `{ barId, overflowing, stripWidth, tabsWidth, free, trailingWidth, endWidth }`. It fires once per bar when the wiring first sees it, then on the next frame after any rounded value changes: a resize, an added or removed tab, or a swapped action. An app can swap a wide `end` action for a compact one while the tabs overflow without measuring TabBar's private parts. `free` is the room the tabs leave unused and is negative by the amount they overflow. Intrinsic tabs ellipsize before the strip scrolls, so `free` reaches 0 before `overflowing` turns true. The UX catalog's **Adaptive End Action** example shows the no-oscillation recipe: remember the wide action's `endWidth`, and restore it once `free` covers the difference. The new `TabBarFit` type is exported from `@kerfjs/ui/wire-tab-bars`.
24
+ - **The Kerf UI editor's Library offers the project's documents (KF-FXACB5).** With a storage that lists documents, the Library popover shows a **Documents** group after its component groups: each other `.kui.json` document as a row (file name over its folder) or, in the grid view, a tile with a file icon. The Library's filter also filters them (a match on "Documents" keeps them all). A click inserts a `#view` of the document inside the selected node (its main zone first), else after it; with nothing selected, inside the root; in a rootless document, as the root. A drag drops it onto the canvas or the outline like a component. Either way its required params are seeded, it renders at once, it is one undoable edit, and a transient Library closes unless it is pinned or Option is held. A document that cannot be composed (declares slots, unreadable, does not parse) is refused with the reason in the Library; a drag over the canvas says why. A node type without a package (`#view`) no longer adds a bogus catalog entry when placed.
25
+ - **The Kerf UI editor inserts an existing document as a `#view` from a picker (KF-PX5EVZ).** With storage, Add a child's Component Select offers **Existing document…**; Add opens an **Insert Document** dialog that lists the project's other `.kui.json` documents under a filter. Choosing one reads it, puts a `#view` of it in the chosen zone with its required params seeded with example values, selects it, and renders it at once, as one undoable edit. A document that declares slots, cannot be read, or does not parse is refused with the reason. `EditorStorage` gains an optional `list()` (project-relative `.kui.json` paths); `devServerStorage(api?, listApi?)` implements it over the new `EDITOR_LIST_API`, which `@kerfjs/ui/vite-editor`'s `editorFileMiddleware` answers (`KERF_UI_EDITOR_LIST_API`, `editorDocuments(root)`: sorted, at most 5000, skipping `node_modules`, `dist`, `test-results`, and dot-folders). A storage without `list()` gets a path field instead.
26
+ - **The Kerf UI editor says how to switch a condition chain to kinds (KF-B0ZDE6).** On a list whose rows are picked by an `$if` chain, Row designs now shows "Rows chosen by conditions; to pick them by kind, remove designs down to one." where a one-design list offers Or pick designs by kind. The editor deliberately does not convert between the two forms: a chain reads true/false item fields and a kinds map reads one kind field, so switching changes the data the application sends (docs/26 §3.5).
27
+ - **A document composed into a row is keyed, and its actions are row actions (KF-RDZ7N7, KF-EP2152).** Every generated `render<Name>(inputs, slots, rowKey?)` takes an optional third argument and puts it on its root as `data-key`; a row whose template (or `$if`-chain design, or kinds-map entry) is a `#view` passes `String(<key>)`, and `interpretView` / `previewView` thread the key the same way. Before, those composed row roots had no `data-key`, so kerf `each()` matched them by position and a row action's `key` read empty. Such a document's actions now count as row actions of the composing document (its own contract keeps them view-scoped), so the composing module's handlers get the row `key`, and the editor's Extract to document no longer refuses a row design that shares the other designs' action. Composing the same document both inside and outside a row reports `KUI-V009`. The argument is not an input, so contract digests are unchanged; regenerate view modules to pick up the key.
28
+ - **Kerf UI `Toolbar responsive="wrap-groups"` wraps a leading zone of control groups (KF-K3TXCT).** For a toolbar whose leading zone is several `ToolbarControlGroup`s rather than a title, each leading group shares a row with the trailing zone while it fits and otherwise moves, whole, to the next row; the trailing zone stays at the inline end. Before, `wrap` kept the leading zone on one row and `stack` wrapped only the center and trailing zones, so the last leading group was clipped at a narrow width. The existing policies are unchanged. The Kerf UI editor's play bar uses it: the device options and Scale are back beside the device picker at wide widths, and still wrap whole at 390px.
29
+ - **Play mode wires the rest of a composed document's controls (KF-HBRKFH).** Inside a `#view`'s document in the Kerf UI editor's play mode, a Combobox, ColorField, ColorPicker, or TagField change, a ResizableRegion or SplitView list resize, and a TabBar reorder now reach that document's play copy (or the row it sits in). Each composed SplitView follows the device into `compact`, and each composed NavStack starts at its root view. A repeated tab in a composed document closes out of the param its items come from, through the `#view`'s `$param` props to a top param, or by changing a literal (or unset) prop on the `#view` that holds it. A repeated `#view`'s structural state is still shared by its rows.
30
+ - **Play mode wires controlled components inside composed documents (KF-58917B).** In the Kerf UI editor's play mode, a Switch, TabBar, TabNavigator, NavStack, or other controlled component inside a `#view`'s document now responds. Each composed node plays with a composed id (its `#view`'s id and its own), each `#view` keeps a play copy of its document, and a row `#view` passes its row keys so per-row state stays in its row. A value change goes where the value comes from: through a `$param` to the `#view`'s prop, then to a param, the `#view`'s literal prop, or (for a repeated `#view`'s `$bind`) its row item's field. Anything it cannot trace stays on the node for its row. The pure parts are `ui/src/editor/model/play-views.ts`.
31
+ - **The Kerf UI editor shows and plays `PinnablePopoverSurface` (KF-ZWG0B2).** Like `PopoverDialogSurface`, it shows embedded on the edit canvas (header, Pin, Close, and content, all selectable) instead of as a closed top-layer popover, and the Components grid gives it its own sketch. In play mode it is wired with `wirePinnablePopover`, so it opens below its trigger, light-dismisses while transient, and pins, moves, and resizes; a `pinned` prop starts it pinned.
32
+ - **Play mode renders composed documents (KF-85SCQD).** In the Kerf UI editor's play mode, a `#view` (such as an `$each` row that is its own row document) played as a "cannot render" placeholder, because the play stage has no storage. The editor now sends the composed documents it loaded with the document it plays, so the stage renders the rows as the canvas does, and a row document's actions reach the host's play handlers and the action log, named as their `#view`.
33
+ - **Kerf UI editor: reorder row designs (KF-STBQBG).** A selected row design in the Repeat section's Row designs moves with Move design earlier and Move design later. In an `$if` chain a design's condition moves with it and the last design, the `else` for every other item, stays last; in a list keyed by kind any design moves, which changes only the map's order. The model edits are `moveRowDesign` and `rowDesignMoves` in the editor's `model/row-designs.ts`.
34
+ - **Smarter drop targeting in the Kerf UI editor (KF-WKABP2).** Dragging over a Workbench or SplitView shows each zone that would take the drag as a region where it renders (a Workbench's left and right rails, header, main, footer, and bottom drawer), and the region under the pointer is where the drop goes: dropping a NavStack on a new Workbench's left side now fills its left rail instead of always landing in the main header. A node alone in a one-child zone can be replaced by a drop ("Replace Main"); a seeded placeholder is replaced at once, authored content after a confirmation, and Undo restores it. A drop made with Option (Alt) held, or one inside a container with several zones and no main one, opens a menu listing every place it can go.
35
+ - **Kerf UI view documents: a row design per item (KF-8J8E5V).** An `$each` template may now be an `$if` chain, `{ "$if": <boolean>, "then": <node>, "else": <node or another chain> }`, so a list can render a section header row for some items and an item row for others. Each branch is one keyable node with a `data-*` channel, and `else` is required, so every item yields exactly one row. The condition resolves in the item's scope. `generateView` writes `each(items, (item) => (cond ? A : B), { key })`, `interpretView` and `previewView` render the same branch, and a named node in any branch is a keyed ref that returns `null` for a row that took another branch. `validateView` reports a chain without `else`, a branch that is not one node, and a branch with no `data-*` channel as `KUI-V008`. The view-document schema accepts the chain, and `ViewTemplate` / `ViewTemplateChain` are exported types. Documents that do not use a chain generate byte-identical modules. Authoring a chain in the Kerf UI editor follows in KF-1CRGP1.
36
+ - **Kerf UI `PinnablePopoverSurface`: a non-modal panel the person can pin and move (KF-C57ZX0).** `@kerfjs/ui/surface-scaffold` adds `PinnablePopoverSurface` with `wirePinnablePopover(surface, { anchor?, pinned?, placement?, step?, largeStep?, onChange? })`, `pinPopover(surface, pinned?)`, and `isPopoverPinned(surface)`. It opens transient below its `popoverTarget` control and closes on Escape or a press outside. Pinned by its header Pin toggle (`aria-pressed`) or `pinPopover`, it stays open while the page is used, drags by its title, moves with the arrow keys on the focused title (Shift moves farther), resizes from its corner, and stays inside the viewport gutter after a window resize, returning to where the person put it when there is room. Moving a transient surface pins it. `onChange` reports `{ pinned, placement, reason }` for the application to store, and the `pinned` and `placement` options restore it. The controller keeps its state across application re-renders. It takes `PopoverDialogSurface`'s geometry props and an `embedded` presentation. The Surface Scaffolds demo's Pinnable Popover example shows the transient, pinned, moved, and restored states. The UI skill is now 1.74.0.
37
+ - **The Kerf UI editor extracts a subtree into a document of its own (KF-D9P3NP).** **Extract to › New document…** in the Flow area (also **Extract to Document…** in the node context menu) asks for the new document's path in a Save As–style dialog, suggesting one beside the current document, then writes a document whose root is the selected node (a repeated row, one row design of an `$if` chain or kinds map, or any other subtree) and puts a `#view` of it in its place. Every `$param` and `$bind` the subtree reads becomes one of the new document's params, typed from the source (a row's `message.subject` becomes a string param `subject`), and the `#view` passes the values back. One Undo restores the subtree; the new file stays. It is disabled, with the reason, on the root, on a subtree holding a slot, and without storage, and refused when the result would add a problem.
38
+ - **The Kerf UI editor renders and inspects composed documents (KF-5N26H6).** A `#view` node, such as an `$each` row that is its own row document, now loads its document through the editor's storage (resolving `src` from the composing document's folder, as `kerf-ui-view` does) and renders it in place on the canvas; a click anywhere in it selects the `#view`. Problems validate against the loaded document, so a missing required param or a prop of the wrong type is `KUI-V012` on its field, and a document that cannot load says why (no storage, still loading, no such file, or unreadable). The Inspector edits a `#view`'s props as that document's params, with the same fields and **Bind a prop** sources as any prop (a row's `message.subject`, offered only when its type fits). **Open document** opens the composed document, saving the composing one first, and **Back to <file>** in the canvas toolbar returns to it with the `#view` selected. Export and Compare generate a composing document's module with its composed documents. Inserting a `#view` from a picker comes next.
39
+ - **Kerf UI view documents: row designs keyed by item kind (KF-YX6HMT).** An `$each` may carry `"templates": { "<kind>": <node>, … }` and `"kind": <string value>` instead of `template`, so each item's `kind` picks its row design, like Interface Builder's prototype cells. A `default` entry is required and takes every other kind, so a repeat never filters. `validateView` reports, as `KUI-V008`, an `$each` with both `template` and `templates`, a map without `default`, a missing or stray `kind`, and an entry that is not one keyable node. `generateView` compares the kind per row and exports `type <Name><As>Kind`; the contract gains a `kinds` member only for documents that use a map (other digests are unchanged), and `diffContracts` reports a removed kind as breaking and an added one as not. `interpretView` and `previewView` pick the same template, the schema accepts the map, and `ViewChild`'s `$each` gains the `templates`/`kind` variant. In the editor, a one-design list can pick its designs by kind, then add, rename, and remove kinds in Row designs. The view bundle budgets rise to 13000 B (`interpretView`, 12915 measured) and 9450 B (`validateView`, 9364 measured).
40
+ - **Kerf UI editor: row designs (KF-1CRGP1).** A repeated node's Inspector has a Row designs section that authors an `$if`-chain template: Add a row design picks a component and a true/false param or item field, and the new design shows for those items while the last design keeps every other item. A selected design changes when it shows or is removed; a chain left with one design becomes a plain template. The outline lists each design with `if …`, `else if …`, or `otherwise`, the canvas renders each item's design, and play mode keeps row state and logs row actions for rows of any design. `ViewChild`'s `$each` `template` is now typed `ViewTemplate`, so TypeScript code that reads `child.template.id` narrows it first.
41
+ - **Kerf UI's no-network guarantee is tested and documented (KF-WK5DEF).** No Kerf UI component requests anything at runtime: icons are bundled Lucide SVG, and no component renders a Web Awesome element (4.4.1's `Select` did, so its `wa-icon` chevron fetched from Font Awesome's CDN). A browser test now loads every Kerf component's catalog demo and fails on any request off the page's origin. `ui/docs/webawesome-theme.md`, `ui/llms.txt`, and the UI skill (1.73.0) say so, and tell an application that renders Web Awesome elements itself to register a local icon library.
42
+ - **A grid view for the Kerf UI editor's Components palette (KF-JC7WTW).** A List/Grid control beside the Components filter switches the palette to tiles, and the editor remembers the choice per browser. Each tile shows its component as it would be added, rendered live and scaled into the tile: a Switch looks like a switch. Layouts, dialogs, and arrangement primitives (Workbench, SplitView, NavStack, DialogSurface, Grid, Spacer, and others) show a simplified sketch of their arrangement instead, since they render almost nothing when added empty. Tiles select, filter, and drag onto the canvas or the Outline like rows.
43
+ - **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.
44
+ - **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
45
  - **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
46
  - **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
47
  - **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 +287,25 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
257
287
 
258
288
  ### Changed
259
289
 
290
+ - **The Kerf UI editor's view and wiring regions are separate modules (KF-YF1PDR, KF-N0CSVT).** Inspector controls, field editors, Library drag and drop, dialogs, and event handlers now receive typed state from `createEditor`; behavior and public entry points are unchanged.
291
+ - **UI source registration survives tree shaking (KF-TA779Y).** The source PopupMenu registration module is listed as side effectful, so Select's public registration import remains in source-built demos.
292
+ - **Browser waits follow UI state (KF-BG83G7).** Browser suites wait for navigation, animation, and rendered state instead of fixed sleeps, with bounded transition-settling checks.
293
+ - **Five long UI functions now have named phases (KF-70DQG4).** Search-field wiring, scroll-divider control, editor play wiring, project analysis, and UI doctor were split into focused helpers without changing their public behavior.
294
+ - **Workbench resize contract moved to its model folder (KF-8G51WR).** The editor and Workbench now import the shared contract without crossing a component's private `internal/` boundary; the source organization check has no allowlisted edge.
295
+ - **The basic site examples follow the Kerf lint rules (KF-4SA1SM).** They use `attr()` selectors and explicit page-lifetime delegates, and site lint now covers all examples.
296
+ - **CI exercises the published Node 18 floor (KF-Q1S54S).** It installs the packed package into a Node 18 consumer, runs the setup dry run, and checks a server render from `dist/`.
297
+ - **`kerfjs setup` separates detection and apply from planning (KF-Q0WSWJ).** The public CLI behavior and exports are unchanged; the packed package now includes focused `setup/detect.mjs`, `setup/apply.mjs`, and `setup/common.mjs` modules.
298
+ - **`bindList` virtualization uses a tagged height model (KF-BA1DW8).** Fixed, declared, and measured row heights now dispatch through one normalized model instead of nullable flags and unchecked casts; behavior is unchanged.
299
+ - **`kerfjs/jsx-runtime` no longer exports `listSafeHtml` / `granularListSafeHtml` (KF-JYCRRJ).** They were internal helpers for `each()`; they are now `_`-prefixed.
300
+ - **Router edge cases are defined (KF-EE8EPV).** `navigate()` to the URL already showing replaces the history entry instead of pushing a duplicate, and `navigate()` after `dispose()` does nothing.
301
+ - **`kerfjs/scope` reports disposer errors (KF-C0S46R).** `dispose()` still runs every disposer, then reports each error through `reportError` instead of swallowing it.
302
+ - **Overlay `dismiss` / `outsideIgnore` arrays are copied at open (KF-Y56AQD).** Mutating them after opening no longer changes the open overlay.
303
+ - **PopupMenu typeahead matches Select (KF-NF65PK).** Backspace backs up the query in both popups, and neither throws on an item without its label span.
304
+ - **`@kerfjs/ui` CLIs share one argument contract (KF-FSCXYT, KF-7NZM4K).** Every bin prints usage and exits 0 on `--help` / `-h` without doing work (`kerf-ui-analyze --help` used to run an analysis), reports a missing or malformed input as `<bin>: <path>: …` with exit 2 instead of a stack trace, and rejects unknown flags and flags missing a value.
305
+ - **`npm create kerf-component` no longer installs TypeScript (KF-7H7FWV).** It is an optional peer of the `kerf-component-catalog` bin, which the scaffold template and `kerfjs setup --ui` already install.
306
+ - **Release tooling (KF-12QS9G, KF-RV39NE).** Release notes keep their `##` / `###` headings and literal backslashes in the tag message and GitHub Release; `npm run release:beta` continues the highest beta series; `npm run release` refuses a dirty tree, a non-main branch, or an existing tag.
307
+ - **The Kerf UI editor's components moved into an Xcode-style Library popover (KF-Z54E4H).** The Document rail's Components tab is gone; the rail keeps Outline and Problems. The Preview toolbar's **Library** (`+`) button and Shift+Cmd+L (Ctrl+Shift+L elsewhere) open the Library, a `PinnablePopoverSurface` with the same filter, List/Grid view (still remembered per browser), thumbnails, categories, click-to-document, and drag onto the canvas or the Outline. It opens with focus in its filter and closes (Escape, Close, the shortcut, or a press outside) with focus back on the Library button. It is transient: a drag from it steps it aside so the canvas and outline it covered take the drop, a drop closes it, and a drop that finds no place brings it back. Hold Option (Alt) to keep it open, as the drag starts or at the drop; an Option drop that asks where it goes (the "drop where?" menu) brings the Library back once the menu closes. Pin it, or drag its title, to keep it open while you work; the editor remembers whether it was pinned and where. The drag chip now draws over the Library too.
308
+ - **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
309
  - **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
310
  - **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
311
  - **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 +372,29 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
323
372
 
324
373
  ### Fixed
325
374
 
375
+ - **`bindList` honors same-reference `arraySignal.update()` (KF-TMYJ4G).** Content rows refresh inside their existing row element, and element rows receive `update(item)`; all consumers see the new content.
376
+ - **Editor undo and redo discard refused Inspector drafts (KF-0Y88XZ).** When history restores the document, an invalid field value is reset alongside its error so the field displays the document's value.
377
+ - **Release pre-flight refuses stale lockfiles offline (KF-F1CPCK).** Before tagging, it checks each lockstep package's manifest against its `package-lock.json` and prints the packages that need an updated lockfile.
378
+ - **`bindList` snapshot render failures recover before later patches (KF-1267Y6).** A row-render throw during `replace()` or another snapshot pass latches a full reconcile for the next valid source notification.
379
+ - **Virtualized `bindList` freezes a rejected duplicate-key source until a valid update (KF-7HV0MF).** Scroll and measurement frames keep the last accepted window and measured-height baseline instead of re-rendering the invalid array.
380
+ - **Preserved nodes inside an `each()` row keep their text on a granular update (KF-HYAA4T).** The row text fast path skips consumer-injected `data-morph-preserve` nodes, including when their text matches the cell's old value. Morph protection now uses one shared bitmask helper.
381
+ - **Store actions no longer subscribe the code that calls them (KF-1268ZK).** An action's `get()` reads state untracked, so calling a `get()`+`set()` action inside `effect()` or `mount()` no longer throws "Cycle detected" or re-runs the effect in a loop.
382
+ - **`kerf-catalog-demo` runs through its npm bin symlink (KF-88VC6W).** It used to exit 0 without doing anything, so a consumer's `--check` passed vacuously.
383
+ - **TabBar drag state ends when a re-render replaces the dragged tab, and `onFitChange` reports a renamed `data-tab-bar-id` or a bar that returns to the root (KF-XJPZJ3).**
384
+ - **An open Select or PopupMenu keeps keyboard focus when its focused option is removed (KF-XJPZJ3).**
385
+ - **`kerfjs setup` names the file it cannot read (KF-7YHK22).** A malformed manifest, state or profile file is reported by its path, and an unreadable `package.json` is no longer treated as missing.
386
+ - **eslint-plugin-kerfjs UI rules refresh in long-running ESLint servers (KF-RZ2G3A).** They pick up a regenerated `component-composition.json`, an edited `.kerf-ui-profile.json`, or a renamed `package.json`, and stop reporting a stale KUI-L090 once the catalog is fixed.
387
+ - **Example apps (KF-203W27).** cart-htmx no longer interpolates JSON into an HTML attribute string, kanban recovers from `pointercancel`, and the dashboard chart loop stops with its feed.
388
+ - **An open Kerf UI `Combobox` list survives an application render while its field is focused (KF-YA45PW).** `Combobox` renders its list closed, so a render while the person was typing (for example when `suggestions` arrived) wrote `hidden` and `aria-expanded="false"` back and closed the open list, and the new options were never filtered against the typed text. `wireComboboxes` now restores a list it held open after such a render, re-filtered, with the same active option when it is still shown. An unfocused list, or one the person closed with Escape or by leaving the field, stays closed.
389
+ - **The Kerf UI editor's Inspector no longer throws on a `#view` with an array or object param (KF-WDA59Q).** Selecting a `#view` whose composed document declares an array- or object-typed param threw while rendering its JSON field, because the param's type had no text for the field's hint. Each param type now carries its text, so the field reads "JSON for readonly string[]".
390
+ - **A row document with its own repeat previews as a KUI-V016 placeholder (KF-A01VDM).** When a `#view` inside an `$each` row composes a document that has its own top-level `$each`, `previewView` (the Kerf UI editor's canvas and play) now renders the node holding that `$each` as a placeholder whose reason names `KUI-V016`, instead of kerf's generic `each()`-inside-a-row error. The rule is unchanged: validation already reports `KUI-V016` and `interpretView` refuses the document; put the repeat in the composing document.
391
+ - **Extract to document keeps an optional item field optional (KF-JE8KHX).** In the Kerf UI editor, extracting a row that reads an item field the item type does not mark `required` (`subject?: string`) gave the new document a required param, so the composing module passed `message.subject` (possibly `undefined`) to a required input and a strict `tsc` rejected it. View documents now accept `optional: true` on a param with no default: its input is optional, a `#view` may leave it out, and an omitted value reads as absent (no default stands in for it). Extract gives such a field that form, and the editor shows it as not required. `validateView` reports `optional` that is not `true`, or that sits beside a `default`, as `KUI-V001`. The view-document schema and the `ViewDocument` type gain the field. Contracts of documents that do not use it are unchanged.
392
+ - **Embedded `PopoverDialogSurface` and `PinnablePopoverSurface` no longer draw a shadow cut off in a square box (KF-ENXYEB).** With `presentation="embedded"`, in flow on the Kerf UI editor's canvas or in a catalog, they now draw their border without the drop shadow, as an embedded `DialogSurface` does. The scrolling container around them (a Pane's content) had clipped the shadow at its edges.
393
+ - **The Kerf UI editor's play bar no longer clips its Scale Select at a narrow window (KF-MAM4AT).** The device options and Scale now sit with the action log and Done in the play bar's trailing zone, which wraps whole groups, so at 390px they move to a second row instead of running off the edge.
394
+ - **A nested `#view` resolves from the document that contains it (KF-3X7MFF).** When `views/list.kui.json` composed `./rows/row.kui.json` and that row composed `./cell.kui.json`, `kerf-ui-view`, `validateView`, and the editor looked for `views/cell.kui.json`, while the generated row module imports `views/rows/cell.kui.json`. Every `src` now resolves from its own document's folder. `resolveView(src, path)` receives `path`, where `src` points relative to the top document's folder, and the new `composedViewPath(from, src)` from `@kerfjs/ui/view` computes it. A resolver that reads only `src` keeps working for the top document's own `#view`s. Cycles are found by path, so the same `src` in two folders is no longer a false cycle and a `../` loop back is no longer missed. The view bundle budgets rise to 13200 B (`interpretView`, 13069 measured) and 9600 B (`validateView`, 9496 measured).
395
+ - **Kerf UI popups open by the viewport's room in a scrolled page (KF-GRNDW5).** A `Select`, `PopupMenu`, or any popup placed by the shared positioning bounded itself by the document element's client rect, which moves up as the page scrolls. In a page that scrolls its document, a `Select` far down opened on the wrong side and was capped short (to 0px at phone width). Popups are now bounded by the viewport rectangle, so they flip and size by the room around their trigger wherever the page is scrolled.
396
+ - **The Kerf UI editor's drag chip draws over the rails in Safari (KF-23EBGS).** The chip naming what is dragged lived inside the canvas pane, which clipped it in WebKit as soon as the pointer left the canvas, so a palette drag heading for a spring-loaded Document tab or an Outline row showed nothing under the pointer. The chip now sits outside the panes and follows the pointer over the whole editor in every engine.
397
+ - **`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
398
  - **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
399
  - **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
400
  - **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.
@@ -520,6 +592,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
520
592
 
521
593
  ### Documentation
522
594
 
595
+ - **Imperative nodes inside keyed rows must be marked (KF-TBC6V7).** The render guide explains how an unmarked node can divert a text-only list update and why `data-morph-preserve` is required when adding it.
596
+ - **Nested removal observers use per-root containment (KF-6E8Y2C).** The scope API reference explains that an inner observer disposes a node moved outside its own root, even when it remains inside an outer observed root.
597
+ - **New consumer guides and references.** `ui/docs/view.md` covers `@kerfjs/ui/view` and the `kerf-ui-view` CLI (KF-ABHABR); the doctor, analyzer and evaluator guides gain CLI-option and Node-API tables (KF-GD1BDC); the API reference documents the tooling-facing JSX, brand and dev-hook exports and the `clearDevHooks` / `installDevHooks` signatures (KF-QGKQ0M, KF-FJQP4X); the htmx cart and counter-store apps get their own example pages (KF-GHSA8D).
523
598
  - The `@kerfjs/ui` UX catalog's Structured Ticket Search help is lighter: a short title and line, then grouped filter chips (action `Chip`s) that insert their filter into the field, instead of a key/value table. The SearchField examples' notes are shorter too (`KF-XP8742`).
524
599
 
525
600
  - New recipe in the `kerfjs/async` API reference: move heavy app compute (fuzzy search, CSV or markdown parsing, aggregation) into a Worker by having a `resource()` fetcher post a message to the worker and resolve with its reply. It covers request/reply ids, dropping superseded results, worker errors, transferring `ArrayBuffer`s, and keeping the render on the main thread (`KF-04KHT9`).
package/README.md CHANGED
@@ -54,6 +54,11 @@ Here's the whole development loop — write a component, run the dev server, cli
54
54
  npm install kerfjs
55
55
  ```
56
56
 
57
+ Kerf runs in modern browsers (ES2022). The published package, including the
58
+ `kerfjs setup` CLI and server-side `toString()` rendering, needs Node.js 18 or
59
+ newer (`engines.node`); contributing to this repository (building, testing,
60
+ the documentation site) needs Node.js 22.12+.
61
+
57
62
  For an existing project, install the AI guidance, strict TypeScript/ESLint
58
63
  feedback, and package scripts with a reviewed dry run:
59
64
 
package/ai/manifest.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "kerfjsVersion": "5.0.0-beta.124",
2
+ "kerfjsVersion": "5.0.0-beta.126",
3
3
  "files": [
4
4
  {
5
5
  "name": "skill",
package/dist/actions.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { attr } from './chunk-MK42GLPV.js';
2
- import { _delegate, NON_BUBBLING } from './chunk-ZZI5NJIV.js';
2
+ import { _delegate, NON_BUBBLING } from './chunk-AP2FT33F.js';
3
3
 
4
4
 
5
5
  // src/actions.ts
package/dist/attach.js CHANGED
@@ -1,3 +1,3 @@
1
- export { attach } from './chunk-FM6N2B4N.js';
1
+ export { attach } from './chunk-BTOKH5FA.js';
2
2
 
3
3
  //# sourceMappingURL=attach.js.map
@@ -1,8 +1,8 @@
1
1
  import { itemVersion } from './chunk-5WRGJZV6.js';
2
- import { seedRenderedAttrs, RENDERED_ATTRS, isUserAgentOwnedAttr, hasCustomTag, parseRowTemplate, rowContractError, parseSingleRow, collectTemplateChildren } from './chunk-6LXUC4ZY.js';
3
- import { captureRowBindings, listSafeHtml, boundTextNodeOf, syncFormProp, newBindingContext, wireBindings, disposeRowBindings, isSafeHtml, _setBindingContext, TEXT_MARKER_PREFIX, ROW_TEXT_PREFIX, wireRowBindings, carryOrRewireRowBindings, granularListSafeHtml } from './chunk-XL35DIZ2.js';
2
+ import { seedRenderedAttrs, RENDERED_ATTRS, isUserAgentOwnedAttr, hasCustomTag, parseSingleRow, parseRows } from './chunk-NRPLVJVR.js';
3
+ import { _listSafeHtml, boundTextNodeOf, syncFormProp, newBindingContext, wireBindings, disposeRowBindings, captureRowBindings, isSafeHtml, _setBindingContext, coerceText, TEXT_MARKER_PREFIX, ROW_TEXT_PREFIX, wireRowBindings, carryOrRewireRowBindings, _granularListSafeHtml } from './chunk-GGADRIQO.js';
4
4
  import { effect } from './chunk-N4VHHOCM.js';
5
- import { LIST_MARKER_PREFIX, flattenWithoutListItems, collectLists, isOverlayHost, flatten } from './chunk-4TX6YJDM.js';
5
+ import { flattenWithoutListItems, collectLists, LIST_MARKER_PREFIX, isOverlayHost, flatten } from './chunk-4TX6YJDM.js';
6
6
  import { devHooks } from './chunk-KUHXPPJ4.js';
7
7
 
8
8
  // src/list-render-state.ts
@@ -35,14 +35,17 @@ function isArraySignal(value) {
35
35
  }
36
36
  var context = null;
37
37
  var renderingRow = false;
38
- function inRowScope(fn) {
39
- const prev = renderingRow;
40
- renderingRow = true;
41
- try {
42
- return fn();
43
- } finally {
44
- renderingRow = prev;
45
- }
38
+ function renderRow(render, item, index) {
39
+ return captureRowBindings(() => {
40
+ const prev = renderingRow;
41
+ renderingRow = true;
42
+ try {
43
+ const out = render(item, index);
44
+ return isSafeHtml(out) ? out.toString() : out;
45
+ } finally {
46
+ renderingRow = prev;
47
+ }
48
+ });
46
49
  }
47
50
  function _setRenderContext(c) {
48
51
  context = c;
@@ -66,7 +69,8 @@ function assertValidKey(key) {
66
69
  );
67
70
  }
68
71
  }
69
- function claimKey(ctx, key) {
72
+ function listId(ctx, key) {
73
+ if (key === void 0) return String(ctx.counter++);
70
74
  assertValidKey(key);
71
75
  if (renderingRow) {
72
76
  throw new Error(
@@ -92,12 +96,7 @@ function each(items, render, cacheKeyOrOptions) {
92
96
  return eachSnapshot(snapshotItems, render, cacheKey, listKey);
93
97
  }
94
98
  function eachSnapshot(items, render, cacheKey, listKey) {
95
- let id;
96
- if (context !== null) {
97
- id = listKey !== void 0 ? claimKey(context, listKey) : String(context.counter++);
98
- } else {
99
- id = "orphan";
100
- }
99
+ const id = context !== null ? listId(context, listKey) : "orphan";
101
100
  return eachSnapshotById(items, render, cacheKey, id);
102
101
  }
103
102
  function assertObjectItem(item, index) {
@@ -138,7 +137,7 @@ function _hasGranularCacheKeyDrift(snapshot, cacheKey, cache) {
138
137
  }
139
138
  function eachGranular(sig, render, cacheKey, listKey) {
140
139
  const ctx = context;
141
- const id = listKey !== void 0 ? claimKey(ctx, listKey) : String(ctx.counter++);
140
+ const id = listId(ctx, listKey);
142
141
  const previousBindingCount = ctx.bindingCounts.get(id);
143
142
  const patches = sig._consumePatches();
144
143
  const snapshot = sig.value;
@@ -161,12 +160,6 @@ function eachGranular(sig, render, cacheKey, listKey) {
161
160
  return eachSnapshotById(snapshot, render, cacheKey, id, sig);
162
161
  }
163
162
  }
164
- const renderRow = (item, index) => captureRowBindings(
165
- () => inRowScope(() => {
166
- const out = render(item, index);
167
- return isSafeHtml(out) ? out.toString() : out;
168
- })
169
- );
170
163
  const internalPatches = new Array(patches.length);
171
164
  const cache = ctx.caches.get(id);
172
165
  try {
@@ -174,7 +167,7 @@ function eachGranular(sig, render, cacheKey, listKey) {
174
167
  const p = patches[i];
175
168
  if (p.type === "insert" || p.type === "update") {
176
169
  assertObjectItem(p.item, p.index);
177
- const { html, bindings } = renderRow(p.item, p.index);
170
+ const { html, bindings } = renderRow(render, p.item, p.index);
178
171
  internalPatches[i] = {
179
172
  type: p.type,
180
173
  index: p.index,
@@ -198,7 +191,7 @@ function eachGranular(sig, render, cacheKey, listKey) {
198
191
  return eachSnapshotById(snapshot, render, cacheKey, id, sig);
199
192
  }
200
193
  if (staleIndexShift) devHooks.staleIndex?.(id);
201
- return granularListSafeHtml(id, [], internalPatches, sig);
194
+ return _granularListSafeHtml(id, [], internalPatches, sig);
202
195
  }
203
196
  function eachSnapshotById(items, render, cacheKey, id, source) {
204
197
  let cache = null;
@@ -237,12 +230,7 @@ function eachSnapshotById(items, render, cacheKey, id, source) {
237
230
  devHooks.staleIndex?.(id);
238
231
  }
239
232
  } else {
240
- const captured = captureRowBindings(
241
- () => inRowScope(() => {
242
- const out = render(item, i);
243
- return isSafeHtml(out) ? out.toString() : out;
244
- })
245
- );
233
+ const captured = renderRow(render, item, i);
246
234
  html = captured.html;
247
235
  bindings = captured.bindings;
248
236
  if (cache !== null)
@@ -253,7 +241,7 @@ function eachSnapshotById(items, render, cacheKey, id, source) {
253
241
  if (cacheKey !== void 0) {
254
242
  devHooks.duplicateCacheKeys?.(id, segItems);
255
243
  }
256
- return listSafeHtml(id, segItems, source);
244
+ return _listSafeHtml(id, segItems, source);
257
245
  }
258
246
 
259
247
  // src/list-reconcile-focus.ts
@@ -303,6 +291,13 @@ function restoreFocus(snap) {
303
291
  }
304
292
  }
305
293
 
294
+ // src/utils/morph-protection.ts
295
+ var MORPH_PRESERVE_ATTR = "data-morph-preserve";
296
+ function protectionOf(el) {
297
+ const d = el.dataset;
298
+ return (d.morphSkip !== void 0 ? 1 : 0) | (d.morphSkipChildren !== void 0 ? 2 : 0) | (d.morphPreserve !== void 0 ? 4 : 0);
299
+ }
300
+
306
301
  // src/utils/moveNode.ts
307
302
  function moveNode(parent, node, ref) {
308
303
  const move = parent.moveBefore;
@@ -340,9 +335,6 @@ function morph(liveRoot, template, ownedItems = EMPTY_OWNED) {
340
335
  morphChildren(liveRoot, templateEl, ownedItems);
341
336
  if (focusSnap !== null) restoreFocus(focusSnap);
342
337
  }
343
- function _morphElement(fromEl, toEl, ownedItems = EMPTY_OWNED) {
344
- morphElement(fromEl, toEl, ownedItems);
345
- }
346
338
  function isElementNode(t) {
347
339
  return typeof t === "object" && t !== null && t.nodeType === ELEMENT_NODE;
348
340
  }
@@ -351,10 +343,6 @@ function parseTemplate(liveRoot, template) {
351
343
  el.innerHTML = String(template);
352
344
  return el;
353
345
  }
354
- function protectionTag(node) {
355
- const { dataset } = node;
356
- return (dataset.morphSkip !== void 0 ? "s" : "") + (dataset.morphSkipChildren !== void 0 ? "c" : "") + (dataset.morphPreserve !== void 0 ? "p" : "");
357
- }
358
346
  var MARKER_PREFIXES = [
359
347
  LIST_MARKER_PREFIX,
360
348
  TEXT_MARKER_PREFIX,
@@ -408,7 +396,7 @@ function morphChildren(fromParent, toParent, ownedItems) {
408
396
  fromChild = skipOwned(fromChild.nextSibling, ownedItems);
409
397
  }
410
398
  }
411
- if (matched === null && fromChild !== null && fromChild.nodeType === toChild.nodeType && markersPairable(fromChild, toChild) && (toChild.nodeType !== ELEMENT_NODE || fromChild.tagName === toChild.tagName && getNodeKey(fromChild) === void 0 && toKey === void 0 && protectionTag(fromChild) === protectionTag(toChild))) {
399
+ if (matched === null && fromChild !== null && fromChild.nodeType === toChild.nodeType && markersPairable(fromChild, toChild) && (toChild.nodeType !== ELEMENT_NODE || fromChild.tagName === toChild.tagName && getNodeKey(fromChild) === void 0 && toKey === void 0 && protectionOf(fromChild) === protectionOf(toChild))) {
412
400
  matched = fromChild;
413
401
  fromChild = skipOwned(
414
402
  isListMarker(matched) ? afterListRegion(matched, ownedItems) : fromChild.nextSibling,
@@ -428,13 +416,13 @@ function morphChildren(fromParent, toParent, ownedItems) {
428
416
  const el = scan;
429
417
  if (ownedItems.has(el)) continue;
430
418
  if (el.tagName !== toTag || getNodeKey(el) !== void 0) continue;
431
- if (protectionTag(el) !== protectionTag(toChild)) continue;
419
+ if (protectionOf(el) !== protectionOf(toChild)) continue;
432
420
  matched = el;
433
421
  moveNode(fromParent, el, fromChild);
434
422
  break;
435
423
  }
436
424
  }
437
- if (matched === null && fromChild !== null && toChild.nodeType === COMMENT_NODE && toChild.data.startsWith(LIST_MARKER_PREFIX)) {
425
+ if (matched === null && fromChild !== null && isListMarker(toChild)) {
438
426
  const wantData = toChild.data;
439
427
  for (let scan = fromChild.nextSibling; scan !== null; scan = scan.nextSibling) {
440
428
  if (scan.nodeType !== COMMENT_NODE || scan.data !== wantData)
@@ -486,7 +474,7 @@ function morphNode(fromNode, toNode, ownedItems) {
486
474
  if (fromText.data !== toText.data) fromText.data = toText.data;
487
475
  }
488
476
  }
489
- function morphElement(fromEl, toEl, ownedItems) {
477
+ function morphElement(fromEl, toEl, ownedItems = EMPTY_OWNED) {
490
478
  if (fromEl.tagName !== toEl.tagName) {
491
479
  const replacement = toEl.cloneNode(true);
492
480
  seedRenderedAttrs(toEl, replacement);
@@ -498,7 +486,7 @@ function morphElement(fromEl, toEl, ownedItems) {
498
486
  if (fromEl === document.activeElement) {
499
487
  const ce = fromEl.getAttribute("contenteditable");
500
488
  if (ce !== null && ce.toLowerCase() !== "false") return;
501
- if (isTextInputOrTextarea(fromEl)) preserveTextEntryState(fromEl, toEl);
489
+ preserveTextEntryState(fromEl, toEl);
502
490
  }
503
491
  morphAttributes(fromEl, toEl);
504
492
  if (fromEl.dataset.morphSkipChildren !== void 0) return;
@@ -541,16 +529,10 @@ function morphAttributes(fromEl, toEl) {
541
529
  }
542
530
  if (fromTag.includes("-")) host[RENDERED_ATTRS] = toEl.getAttributeNames();
543
531
  }
544
- function isTextInputOrTextarea(el) {
545
- if (el.tagName === "TEXTAREA") return true;
546
- if (el.tagName === "INPUT") {
547
- const type = el.type;
548
- return type === "text" || type === "search" || type === "url" || type === "email" || type === "tel" || type === "password" || type === "";
549
- }
550
- return false;
551
- }
552
532
  function preserveTextEntryState(fromEl, toEl) {
553
- if (fromEl.tagName === "TEXTAREA" || fromEl.tagName === "INPUT") {
533
+ if (fromEl.tagName === "TEXTAREA" || fromEl.tagName === "INPUT" && /^(text|search|url|email|tel|password|)$/.test(
534
+ fromEl.type
535
+ )) {
554
536
  const fromInput = fromEl;
555
537
  const toInput = toEl;
556
538
  toInput.value = fromInput.value;
@@ -623,6 +605,8 @@ function tryAttributeOnlyFastPath(liveNode, oldHtml, newHtml) {
623
605
  function tryTextContentFastPath(liveNode, oldHtml, newHtml) {
624
606
  if (containsDataMorphSkip(oldHtml) || containsDataMorphSkip(newHtml))
625
607
  return false;
608
+ if (oldHtml.indexOf(MORPH_PRESERVE_ATTR) !== -1 || newHtml.indexOf(MORPH_PRESERVE_ATTR) !== -1)
609
+ return false;
626
610
  let p = 0;
627
611
  const minLen = Math.min(oldHtml.length, newHtml.length);
628
612
  while (p < minLen && oldHtml.charCodeAt(p) === newHtml.charCodeAt(p)) p++;
@@ -703,8 +687,9 @@ function nthTextNodeDescendant(root, n) {
703
687
  return;
704
688
  }
705
689
  count++;
706
- } else if (c.nodeType === ELEMENT_NODE2) {
707
- walk(c);
690
+ } else {
691
+ if (c.nodeType !== ELEMENT_NODE2) continue;
692
+ if (!c.hasAttribute(MORPH_PRESERVE_ATTR)) walk(c);
708
693
  }
709
694
  }
710
695
  }
@@ -867,7 +852,7 @@ function applySingleUpdate(liveParent, items, patch) {
867
852
  function applyParsedRowUpdate(liveParent, items, patch, html, newNode) {
868
853
  const oldEntry = items[patch.index];
869
854
  if (oldEntry.node.tagName === newNode.tagName) {
870
- _morphElement(oldEntry.node, newNode);
855
+ morphElement(oldEntry.node, newNode);
871
856
  items[patch.index] = reuseBound(patch, html, oldEntry);
872
857
  } else {
873
858
  disposeRowBindings(oldEntry.bindingDisposers);
@@ -914,14 +899,11 @@ function applyBulkUpdate(liveParent, items, patches, start, end) {
914
899
  morphChanges.push({ patchIdx: k, html: p.html });
915
900
  }
916
901
  if (morphChanges.length === 0) return;
917
- const { content, count } = parseRowTemplate(
918
- morphChanges.map((c) => c.html).join(""),
919
- liveParent
902
+ const newNodes = parseRows(
903
+ morphChanges.map((c) => c.html),
904
+ liveParent,
905
+ (k) => patches[morphChanges[k].patchIdx].index
920
906
  );
921
- if (count !== morphChanges.length) {
922
- throw findOffendingChange(patches, morphChanges, liveParent);
923
- }
924
- const newNodes = collectTemplateChildren(content, morphChanges.length);
925
907
  for (let k = 0; k < morphChanges.length; k++) {
926
908
  const c = morphChanges[k];
927
909
  const p = patches[c.patchIdx];
@@ -934,13 +916,13 @@ function applyBulkInsert(liveParent, items, patches, start, end, tailAnchor) {
934
916
  for (let k = start; k < end; k++) {
935
917
  htmls[k - start] = patches[k].html;
936
918
  }
937
- const { content, count } = parseRowTemplate(htmls.join(""), liveParent);
938
- if (count !== htmls.length) {
939
- throw findOffendingInsert(patches, start, htmls, liveParent);
940
- }
941
- const newNodes = collectTemplateChildren(content, end - start);
919
+ const newNodes = parseRows(
920
+ htmls,
921
+ liveParent,
922
+ (k) => patches[start + k].index
923
+ );
942
924
  const anchor = startIdx < items.length ? items[startIdx].node : tailAnchor;
943
- liveParent.insertBefore(content, anchor);
925
+ liveParent.insertBefore(newNodes[0].parentNode, anchor);
944
926
  const newEntries = new Array(end - start);
945
927
  for (let k = 0; k < newEntries.length; k++) {
946
928
  const p = patches[start + k];
@@ -957,34 +939,6 @@ function applyBulkInsert(liveParent, items, patches, start, end, tailAnchor) {
957
939
  }
958
940
  items.splice(startIdx, 0, ...newEntries);
959
941
  }
960
- function findOffendingInsert(patches, start, htmls, liveParent) {
961
- for (let i = 0; i < htmls.length; i++) {
962
- if (parseRowTemplate(htmls[i], liveParent).count !== 1) {
963
- return rowContractError(
964
- patches[start + i].index,
965
- htmls[i],
966
- liveParent
967
- );
968
- }
969
- }
970
- return new Error(
971
- "each(): bulk-insert mismatch with no per-row offender (kerf bug)."
972
- );
973
- }
974
- function findOffendingChange(patches, changes, liveParent) {
975
- for (const c of changes) {
976
- if (parseRowTemplate(c.html, liveParent).count !== 1) {
977
- return rowContractError(
978
- patches[c.patchIdx].index,
979
- c.html,
980
- liveParent
981
- );
982
- }
983
- }
984
- return new Error(
985
- "each(): bulk-update mismatch with no per-row offender (kerf bug)."
986
- );
987
- }
988
942
 
989
943
  // src/list-reconcile-inplace.ts
990
944
  function tryInPlaceContentUpdate(binding, listSeg) {
@@ -1025,7 +979,7 @@ function updateRowInPlace(liveParent, old, ni, index, parsedNode) {
1025
979
  }
1026
980
  const newNode = parsedNode ?? parseSingleRow(ni.html, index, liveParent);
1027
981
  if (old.node.tagName === newNode.tagName) {
1028
- _morphElement(old.node, newNode);
982
+ morphElement(old.node, newNode);
1029
983
  const kept = carryOrRewireRowBindings(
1030
984
  old.node,
1031
985
  old.bindings,
@@ -1165,34 +1119,14 @@ function classifyItems(oldItems, listSeg) {
1165
1119
  }
1166
1120
  function buildFreshNodes(newRecord, freshIndices, freshHtmls, liveParent) {
1167
1121
  if (freshHtmls.length === 0) return;
1168
- const { content, count } = parseRowTemplate(freshHtmls.join(""), liveParent);
1169
- if (count !== freshHtmls.length) {
1170
- throw findOffendingRow(newRecord, freshIndices, freshHtmls, liveParent);
1171
- }
1172
- let node = content.firstElementChild;
1173
- for (const idx of freshIndices) {
1174
- const next = node.nextElementSibling;
1122
+ const rows = parseRows(freshHtmls, liveParent, (i) => freshIndices[i]);
1123
+ freshIndices.forEach((idx, k) => {
1175
1124
  const item = newRecord[idx];
1176
- item.node = node;
1125
+ item.node = rows[k];
1177
1126
  if (item.bindings !== void 0 && item.bindings.length > 0) {
1178
1127
  item.bindingDisposers = wireRowBindings(item.node, item.bindings);
1179
1128
  }
1180
- node = next;
1181
- }
1182
- }
1183
- function findOffendingRow(newRecord, freshIndices, freshHtmls, liveParent) {
1184
- for (let i = 0; i < freshHtmls.length; i++) {
1185
- if (parseRowTemplate(freshHtmls[i], liveParent).count !== 1) {
1186
- return rowContractError(
1187
- freshIndices[i],
1188
- newRecord[freshIndices[i]].html,
1189
- liveParent
1190
- );
1191
- }
1192
- }
1193
- return new Error(
1194
- "each(): bulk-parse mismatch with no per-row offender (kerf bug)."
1195
- );
1129
+ });
1196
1130
  }
1197
1131
  function removeOldNodes(liveParent, removedItems) {
1198
1132
  for (const item of removedItems) {
@@ -1313,9 +1247,8 @@ function bindListsFromMarkers(rootEl, segment, bindings, inlinedItems, rebuiltLi
1313
1247
  }
1314
1248
  function validateInlinedRowMatch(expectedHtml, index, boundEl, liveParent) {
1315
1249
  if (boundEl.outerHTML === expectedHtml) return;
1316
- const { content, count } = parseRowTemplate(expectedHtml, liveParent);
1317
- if (count !== 1) throw rowContractError(index, expectedHtml, liveParent);
1318
- const expectedTag = content.firstElementChild.tagName;
1250
+ const expected = parseSingleRow(expectedHtml, index, liveParent);
1251
+ const expectedTag = expected.tagName;
1319
1252
  if (boundEl.tagName !== expectedTag)
1320
1253
  throw rowStructureError(index, boundEl.tagName, expectedTag);
1321
1254
  }
@@ -1597,17 +1530,13 @@ function morphStaticChange(rootEl, prev, next, cache, ownedItems) {
1597
1530
  }
1598
1531
  const focusSnap = captureFocus(live);
1599
1532
  for (let m = 0; m < lives.length; m++)
1600
- _morphElement(lives[m], tos[m], ownedItems);
1533
+ morphElement(lives[m], tos[m], ownedItems);
1601
1534
  if (focusSnap !== null) restoreFocus(focusSnap);
1602
1535
  return true;
1603
1536
  }
1604
1537
  function keyOf(el) {
1605
1538
  return el.id !== "" ? `#${el.id}` : el.dataset.key !== void 0 ? `k${el.dataset.key}` : "";
1606
1539
  }
1607
- function protectionOf(el) {
1608
- const d = el.dataset;
1609
- return `${d.morphSkip !== void 0}${d.morphSkipChildren !== void 0}${d.morphPreserve !== void 0}`;
1610
- }
1611
1540
 
1612
1541
  // src/mount.ts
1613
1542
  var MOUNTED_MARKER = /* @__PURE__ */ Symbol.for("kerfjs.mounted");
@@ -1638,14 +1567,11 @@ function assertNotInsideMountedTree(rootEl) {
1638
1567
  if (isMounted(ancestor)) throw new Error(NESTED_MOUNT_MSG);
1639
1568
  ancestor = ancestor.parentElement;
1640
1569
  }
1641
- const stack = [];
1642
- for (let i = 0; i < rootEl.children.length; i++)
1643
- stack.push(rootEl.children[i]);
1644
- while (stack.length > 0) {
1645
- const cur = stack.pop();
1570
+ const stack = [...rootEl.children];
1571
+ for (let cur; cur = stack.pop(); ) {
1646
1572
  if (isMounted(cur)) throw new Error(NESTED_MOUNT_MSG);
1647
- if (isOverlayHost(cur)) continue;
1648
- for (let i = 0; i < cur.children.length; i++) stack.push(cur.children[i]);
1573
+ if (!isOverlayHost(cur))
1574
+ for (const child of cur.children) stack.push(child);
1649
1575
  }
1650
1576
  }
1651
1577
  function mount(rootEl, render) {
@@ -1853,14 +1779,10 @@ function runSubsequentRender(rootEl, segment, bindings, renderCtx, prevStaticHtm
1853
1779
  );
1854
1780
  return currentStaticHtml;
1855
1781
  }
1856
- function coerceRenderResult(result) {
1857
- if (result == null || typeof result === "boolean") return "";
1858
- return String(result);
1859
- }
1860
1782
  function resultToSegment(result) {
1861
- return isSafeHtml(result) ? result.__segment ?? { kind: "static", html: result.__html } : { kind: "static", html: coerceRenderResult(result) };
1783
+ return isSafeHtml(result) ? result.__segment ?? { kind: "static", html: result.__html } : { kind: "static", html: coerceText(result) };
1862
1784
  }
1863
1785
 
1864
1786
  export { captureFocus, each, morph, mount, moveNode, restoreFocus };
1865
1787
 
1866
- //# sourceMappingURL=chunk-MFRXN2G4.js.map
1788
+ //# sourceMappingURL=chunk-5QDM6HPD.js.map