@wcstack/signals 4.16.0 → 4.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +28 -5
- package/README.md +30 -7
- package/dist/{core-kS9CKPFP.esm.js → core-D0iUHBKc.esm.js} +0 -0
- package/dist/core-D0iUHBKc.esm.js.map +1 -0
- package/dist/core-SWYx7MR8.esm.min.js +2 -0
- package/dist/core-SWYx7MR8.esm.min.js.map +1 -0
- package/dist/dom.d.ts +14 -1
- package/dist/dom.esm.js +55 -28
- package/dist/dom.esm.js.map +1 -1
- package/dist/dom.esm.min.js +1 -1
- package/dist/dom.esm.min.js.map +1 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.min.js +1 -1
- package/package.json +1 -1
- package/dist/core-BBzx9zgt.esm.min.js +0 -2
- package/dist/core-BBzx9zgt.esm.min.js.map +0 -1
- package/dist/core-kS9CKPFP.esm.js.map +0 -1
package/dist/dom.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.esm.js","sources":["../src/dom.ts"],"sourcesContent":["// Fine-grained hyperscript (v1 design notes). The \"step before JSX\" (docs §4-1).\n//\n// `h(tag, props, ...children)` is the classic JSX factory shape, but it does NOT\n// build a virtual DOM and re-render. It creates a REAL DOM node once; any prop or\n// child given as a function (thunk) or signal is wired to a targeted `effect`, so\n// only that one binding updates when its signals change (Solid-style). This is\n// what keeps the package lightweight: no reconciler is shipped.\n//\n// JSX is intentionally NOT shipped. A consumer who wants it sets, in their own\n// tsconfig, `jsxFactory: \"h\"` + `jsxFragmentFactory: \"Fragment\"` (classic runtime)\n// — opting into a build step is their choice; the buildless path is calling `h`\n// directly. See docs/signals-state-design.md §4-1.\n//\n// OWNERSHIP: effects created here are owned by the enclosing reactive scope.\n// A reactive child's effect owns the prop/child effects of the subtree it builds,\n// so rebuilding that subtree disposes the previous one's effects (no leak). Mount\n// an app under `createRoot` so the whole tree can be torn down on unmount; a\n// dynamic child establishes its own scope automatically (it IS an effect).\n\nimport { signal, innerEffect as effect, onCleanup, createRoot, hasOwner, ReadSignal, WriteSignal } from \"./reactive.js\";\nimport { isDev, warnDev } from \"./dev.js\";\nimport { bindNode } from \"./bindNode.js\";\nimport type { BoundNode, NodeShape, DefaultNodeShape, WcBindableDescriptor } from \"./bindNode.js\";\n\n// `@wcstack/signals/dom` re-exports the headless core (signals, resource,\n// streamResource, bindNode, nodeSource) so UI code can import everything from one\n// module. Both built entries import a single shared `core-*.esm.js` chunk\n// (rollup.config.js `manualChunks`), so importing from BOTH `@wcstack/signals` and\n// `@wcstack/signals/dom` on a buildless page yields ONE reactive instance — the\n// tracking context is shared, not duplicated. `__tests__/packaging.test.ts` pins\n// this (both entries reference the same core chunk; a signal made via one entry is\n// observed by an effect from the other).\nexport {\n signal,\n computed,\n effect,\n createRoot,\n onCleanup,\n flushSync,\n} from \"./reactive.js\";\nexport type { ReadSignal, WriteSignal, EffectHandle, Cleanup, Equals } from \"./reactive.js\";\nexport { resource } from \"./resource.js\";\nexport type { ResourceState, ResourceOptions, ResourceSource } from \"./resource.js\";\nexport { streamResource } from \"./streamResource.js\";\nexport type {\n StreamResourceState,\n StreamResourceOptions,\n StreamSource,\n StreamProducer,\n StreamStatus,\n} from \"./streamResource.js\";\nexport { bindNode, nodeSource, DisposedError, isDisposedError } from \"./bindNode.js\";\nexport type {\n BoundNode,\n NodeShape,\n DefaultNodeShape,\n WcBindableDescriptor,\n WcBindableProperty,\n EventStreamOptions,\n} from \"./bindNode.js\";\n\nexport const Fragment = Symbol(\"signals.Fragment\");\n\nexport type Child = unknown;\nexport type Props = Record<string, unknown> | null;\n// h() always injects `children` into the props object it passes to a component, so\n// the parameter type makes that explicit (a component can declare `{ children }`).\nexport type Component = (\n props: Record<string, unknown> & { children?: Child[] },\n) => Node | Child[];\n\nfunction isReadSignal(value: unknown): value is ReadSignal<unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { get?: unknown }).get === \"function\" &&\n typeof (value as { peek?: unknown }).peek === \"function\"\n );\n}\n\nexport function h(\n tag: string | typeof Fragment | Component,\n props?: Props,\n ...children: Child[]\n): Node {\n if (tag === Fragment) {\n const frag = document.createDocumentFragment();\n appendChildren(frag, children);\n return frag;\n }\n\n if (typeof tag === \"function\") {\n const result = tag({ ...(props ?? {}), children });\n return Array.isArray(result) ? wrapFragment(result) : result;\n }\n\n const el = createElement(tag);\n if (props) {\n for (const key in props) {\n bindProp(el, key, props[key]);\n }\n }\n appendChildren(el, children);\n return el;\n}\n\nconst SVG_NS = \"http://www.w3.org/2000/svg\";\n\n// Tags created in the SVG namespace. Ambiguous names shared with HTML (`a`,\n// `title`, `script`, `style`) are intentionally EXCLUDED so ordinary HTML usage is\n// not broken; an SVG `<a>` / `<title>` must be created in an explicitly-namespaced\n// way by the caller. SVG DOM props are largely read-only, so `setProp`'s\n// settable-property check routes SVG attributes through `setAttribute` for free.\nconst SVG_TAGS = new Set([\n \"svg\", \"g\", \"path\", \"rect\", \"circle\", \"ellipse\", \"line\", \"polyline\", \"polygon\",\n \"text\", \"tspan\", \"defs\", \"use\", \"symbol\", \"marker\", \"linearGradient\",\n \"radialGradient\", \"stop\", \"clipPath\", \"mask\", \"pattern\", \"image\", \"foreignObject\",\n]);\n\nfunction createElement(tag: string): Element {\n return SVG_TAGS.has(tag)\n ? document.createElementNS(SVG_NS, tag)\n : document.createElement(tag);\n}\n\n/** Append `child` into `container`, resolving fragments/arrays. */\nexport function render(child: Child, container: Node): Node {\n appendChild(container, child);\n return container;\n}\n\nfunction wrapFragment(children: Child[]): DocumentFragment {\n const frag = document.createDocumentFragment();\n appendChildren(frag, children);\n return frag;\n}\n\n// --- props ------------------------------------------------------------------\n\n// Attribute names whose corresponding JS DOM property differs. `class` is handled\n// separately (it has reactive-falsy semantics in setProp), so it is not listed here.\nconst ATTR_TO_PROP: Record<string, string> = {\n for: \"htmlFor\",\n tabindex: \"tabIndex\",\n colspan: \"colSpan\",\n rowspan: \"rowSpan\",\n readonly: \"readOnly\",\n maxlength: \"maxLength\",\n minlength: \"minLength\",\n contenteditable: \"contentEditable\",\n};\n\n// True only if `key` resolves to a WRITABLE property on the element or its\n// prototype chain (a data property with `writable !== false`, or an accessor with a\n// setter). `key in el` is not enough: it also matches read-only members like\n// `firstChild` / `childNodes`, whose assignment throws in strict mode. The walk\n// starts at `el` itself so own instance fields (e.g. a custom element's properties)\n// are still matched, exactly as the previous `key in el` did — just without the\n// read-only false positives.\n//\n// MEMOIZATION: the prototype-chain walk runs on every bindProp/setProp. The result\n// depends only on the element's PROTOTYPE (its class) and the key, since DOM props\n// live on the prototype — not on per-instance own fields, which this library never\n// adds dynamically per element. So cache by `(prototype, key)`: a WeakMap keyed by\n// prototype (no leak — entries die with the class) holding a Map of key→result.\nconst settableCache = new WeakMap<object, Map<string, boolean>>();\n\nfunction computeSettable(el: Element, key: string): boolean {\n let obj: object | null = el;\n while (obj !== null) {\n const desc = Object.getOwnPropertyDescriptor(obj, key);\n if (desc) {\n return \"set\" in desc ? typeof desc.set === \"function\" : desc.writable !== false;\n }\n obj = Object.getPrototypeOf(obj);\n }\n return false;\n}\n\nfunction isSettableProperty(el: Element, key: string): boolean {\n // A real Element always has a prototype (HTMLElement.prototype → … → Object), so\n // `getPrototypeOf` is non-null here; use it as the cache key.\n const proto = Object.getPrototypeOf(el) as object;\n let byKey = settableCache.get(proto);\n if (byKey === undefined) {\n byKey = new Map<string, boolean>();\n settableCache.set(proto, byKey);\n }\n let result = byKey.get(key);\n if (result === undefined) {\n result = computeSettable(el, key);\n byKey.set(key, result);\n }\n return result;\n}\n\nfunction bindProp(el: Element, key: string, value: unknown): void {\n // Event handlers are special-cased BEFORE the reactive check: a function here is the\n // listener, not a thunk to track. `onClick` → \"click\" (lowercased); `onclick` /\n // `onadd-to-cart` → the name as written (\"click\", \"add-to-cart\" — data-wcs's `on<event>:`\n // form). A lowercase `onclick` used to fall through to the reactive path, so the handler\n // ran at render and never on click (docs/seam-apps.md, signals-shop).\n if (/^on[A-Za-z-]/.test(key) && typeof value === \"function\") {\n const type = /^on[A-Z]/.test(key) ? key.slice(2).toLowerCase() : key.slice(2);\n const listener = value as EventListener;\n el.addEventListener(type, listener);\n // Remove the listener when the owning scope is torn down (e.g. a dynamic\n // child that rebuilds this subtree), so handlers don't accumulate.\n onCleanup(() => el.removeEventListener(type, listener));\n return;\n }\n\n if (typeof value === \"function\") {\n effect(() => setProp(el, key, (value as () => unknown)()));\n return;\n }\n\n if (isReadSignal(value)) {\n effect(() => setProp(el, key, value.get()));\n return;\n }\n\n setProp(el, key, value);\n}\n\n/**\n * Objects given to a custom element that is not defined yet, by element → property, until it is\n * (docs/seam-apps.md, signals-shop: `h(\"product-card\", { product })` before `product-card.js` ran\n * landed as `product=\"[object Object]\"`). Not set on the element now: an own property set before\n * the upgrade would hide the class's accessor, so its setter would never run. The latest value is\n * assigned once the element is defined — through the setter, as a defined element gets it.\n */\nconst heldUntilDefined = new WeakMap<Element, Map<string, unknown>>();\n\n/** A custom element (a dash in its name) whose definition has not run yet. */\nfunction awaitsDefinition(el: Element): boolean {\n return el.localName.includes(\"-\") && typeof customElements !== \"undefined\" && customElements.get(el.localName) === undefined;\n}\n\nfunction holdUntilDefined(el: Element, key: string, value: unknown): void {\n let held = heldUntilDefined.get(el);\n if (!held) {\n heldUntilDefined.set(el, (held = new Map()));\n const props = held;\n void customElements.whenDefined(el.localName).then(() => {\n heldUntilDefined.delete(el);\n // (an element not in the document is not upgraded by define(): upgrade it before the setter is wanted)\n customElements.upgrade(el);\n for (const [k, v] of props) (el as unknown as Record<string, unknown>)[k] = v;\n });\n }\n held.set(key, value);\n}\n\nfunction setProp(el: Element, key: string, value: unknown): void {\n if (key === \"style\") {\n setStyle(el as HTMLElement, value);\n return;\n }\n if (key === \"class\" || key === \"className\") {\n // Set the `class` ATTRIBUTE, not the `className` property. On an SVGElement\n // `className` is a read-only `SVGAnimatedString`, so assigning it throws in\n // strict mode (ESM is always strict) — `setAttribute(\"class\", …)` works for both\n // HTML and SVG. Treat false like null → empty class (consistent with the\n // attribute path's false-removes-it rule), so `() => cond && \"active\"` yields \"\"\n // (not \"false\") when the condition is falsy.\n // STRING-ONLY: a non-null/non-false value is coerced via String(value). Array\n // (`[\"a\", \"b\"]`) and object (`{ active: true }`) class forms are NOT supported —\n // they would stringify to \"a,b\" / \"[object Object]\". Compose the class string in\n // the binding itself (e.g. `() => [a, b].join(\" \")`) and pass a string. This keeps\n // the core free of a class-merging convention.\n el.setAttribute(\"class\", value == null || value === false ? \"\" : String(value));\n return;\n }\n // Remap the handful of attribute names whose JS property differs, so `for` /\n // `tabindex` / `colspan` etc. reach the right property instead of falling through\n // to setAttribute (which works for some but not e.g. `htmlFor`).\n const propKey = ATTR_TO_PROP[key] ?? key;\n if (isSettableProperty(el, propKey)) {\n // Known, WRITABLE DOM property (value, checked, disabled, id, htmlFor, ...).\n // The settability check excludes read-only members (firstChild, childNodes, …)\n // that `key in el` would wrongly accept — assigning to those throws in strict\n // mode; we fall through to the attribute path for them instead.\n //\n // NORMALIZATION: null/undefined are coerced to \"\" before assignment. Without\n // this, a STRING prop (id/title/value/src) given a reactive null/undefined\n // lands as the literal \"null\"/\"undefined\" (e.g. img.src=\"null\" fires a real\n // request) — a correctness footgun. \"\" clears the prop instead. Safe for\n // non-string props too: boolean props coerce \"\"→false (same as null), numeric\n // props coerce \"\"→0 (same as null). We do NOT normalize `false`:\n // `el.disabled = false` is the intended boolean clear.\n (el as unknown as Record<string, unknown>)[propKey] = value == null ? \"\" : value;\n return;\n }\n // (a value given since replaces a held one: a primitive goes to the attribute, as below)\n heldUntilDefined.get(el)?.delete(propKey);\n if (typeof value === \"object\" && value !== null && awaitsDefinition(el)) {\n holdUntilDefined(el, propKey, value);\n return;\n }\n if (value == null || value === false) {\n el.removeAttribute(key);\n return;\n }\n if (value === true) {\n el.setAttribute(key, \"\");\n return;\n }\n el.setAttribute(key, String(value));\n}\n\nfunction setStyle(el: HTMLElement, value: unknown): void {\n if (value == null) {\n el.removeAttribute(\"style\");\n return;\n }\n if (typeof value === \"string\") {\n el.style.cssText = value;\n return;\n }\n // Object form: the object fully describes the style. Reset first so keys present\n // in a previous run but absent now are removed — otherwise a reactive style that\n // drops a key (e.g. {color,fontWeight} → {color}) would leave the stale property\n // applied. The object is the source of truth, so wiping cssText is correct here.\n el.style.cssText = \"\";\n const style = el.style as CSSStyleDeclaration & Record<string, string>;\n const obj = value as Record<string, string>;\n for (const k in obj) {\n // A key with a hyphen is either kebab-case (`font-weight`) or a CSS custom\n // property (`--accent`). Neither works via property assignment (`style[k]` would\n // just set an inert expando), so route them through setProperty. camelCase keys\n // (`fontWeight`) keep the faster property path.\n if (k.includes(\"-\")) {\n style.setProperty(k, obj[k]);\n } else {\n style[k] = obj[k];\n }\n }\n}\n\n// --- children ---------------------------------------------------------------\n\nfunction appendChildren(parent: Node, children: Child[]): void {\n for (const child of children) {\n appendChild(parent, child);\n }\n}\n\nfunction appendChild(parent: Node, child: Child): void {\n if (child == null || typeof child === \"boolean\") {\n return; // null / undefined / boolean render nothing\n }\n if (Array.isArray(child)) {\n for (const c of child) {\n appendChild(parent, c);\n }\n return;\n }\n if (isListView(child)) {\n // A keyed list (For / Index): it manages its own anchored region with in-place\n // reconciliation, so it does NOT go through the wholesale insertReactive path.\n child.mount(parent);\n return;\n }\n if (child instanceof Node) {\n parent.appendChild(child);\n return;\n }\n if (typeof child === \"function\") {\n insertReactive(parent, child as () => unknown);\n return;\n }\n if (isReadSignal(child)) {\n insertReactive(parent, () => child.get());\n return;\n }\n parent.appendChild(document.createTextNode(String(child)));\n}\n\n/**\n * A reactive insertion point. An anchor comment marks the position; on each run\n * the previous nodes are removed and the freshly-resolved nodes inserted before\n * the anchor. Using `anchor.parentNode` (not the original `parent`) keeps it\n * correct after the subtree is moved/mounted elsewhere.\n *\n * PRECONDITION: the Nodes returned by `accessor` are owned by this insertion point\n * — do not move them to another parent externally. On the next run they are\n * removed from wherever they currently are (`node.parentNode?.removeChild`), so an\n * externally-moved node would be yanked out of its new home without warning.\n *\n * OWNERSHIP: the `effect` below is owned by the enclosing reactive scope at call\n * time (the `currentOwner`). Used under `createRoot` / `SignalsElement` (the module\n * header's mount contract) it is disposed on teardown. Calling `h`/`render` with a\n * reactive child OUTSIDE any owner (no `createRoot`/`SignalsElement`) leaves this\n * effect un-owned and therefore never cleaned up — by design, per that contract.\n */\nfunction insertReactive(parent: Node, accessor: () => unknown): void {\n if (isDev() && !hasOwner()) {\n // A reactive child inserted with no enclosing owner: the effect below is never\n // disposed (the module header documents this as by-design, but it is a frequent\n // accidental leak). Warn once in dev so the un-owned mount is visible.\n warnDev(\n \"UNOWNED_INSERT\",\n \"\",\n \"reactive child inserted with no owner — its update effect will never be \" +\n \"disposed and may leak. Mount under createRoot / SignalsElement.\",\n );\n }\n const anchor = document.createComment(\"\");\n parent.appendChild(anchor);\n let current: Node[] = [];\n\n effect(() => {\n const value = accessor();\n // FAST PATH: a plain text result that replaces a plain text result. The common\n // reactive child is a string/number thunk (`() => \\`count: ${n.get()}\\``); the\n // wholesale path would remove the old Text node, allocate a new one, and re-insert\n // it on every change. When BOTH the previous and next renders are a single Text\n // node, mutate the existing node's `data` in place instead — no allocation, no\n // remove/insert, and the same DOM node identity is preserved across updates.\n if ((typeof value === \"string\" || typeof value === \"number\") && current.length === 1) {\n const node = current[0];\n if (node.nodeType === 3 /* TEXT_NODE */) {\n (node as Text).data = String(value);\n return;\n }\n }\n const next = toNodes(value);\n for (const node of current) {\n node.parentNode?.removeChild(node);\n }\n const host = anchor.parentNode;\n if (host) {\n for (const node of next) {\n host.insertBefore(node, anchor);\n }\n }\n current = next;\n });\n\n // On teardown, drop the references to the inserted Nodes. The disposed effect's\n // closure still captures `current`; if anything retains the effect after disposal\n // (e.g. a parent owner kept alive longer than the subtree), those Nodes would be\n // pinned via that closure even though they have left the DOM. Clearing the array\n // lets them be GC'd as soon as the enclosing owner tears this insertion point down.\n onCleanup(() => {\n current = [];\n });\n}\n\n// --- keyed lists: For / Index (migration-plan §9-3) --------------------------\n//\n// `insertReactive` rebuilds its whole subtree on every change. For lists that is\n// wasteful (and drops per-row state). `For` / `Index` instead keep a stable DOM row\n// per item and reconcile in place. Each row is built under its OWN `createRoot`, so\n// removing a row disposes exactly that row's effects/resources/listeners — the owner\n// tree (§8 (d)) is what makes this leak-free. The reconcile runs in a single\n// `effect` owned by the enclosing scope; an `onCleanup` disposes surviving rows when\n// that scope (e.g. the component) tears down.\n//\n// CONTRACT: `each` must return a SINGLE Node (one row = one node). Keys (For) must\n// be unique. `For` keys by value identity (=== / explicit `key`) and passes the\n// index as an accessor (it changes on move); `Index` keys by position and passes the\n// item as an accessor (the value at a slot changes, the slot does not).\n\nexport type ListAccessor<T> = ReadSignal<readonly T[]> | (() => readonly T[]);\n/**\n * `For`'s row builder. `item` is the item the row was built for — a plain value. A keyed row is\n * kept while its key is (an immutable update hands it a new object under the same key), so read\n * what changes through `current`, an accessor of the item under the row's key now\n * (`() => current().text`). docs/seam-apps.md, signals-shop.\n */\nexport type ForEach<T> = (item: T, index: () => number, current: () => T) => Node;\nexport type IndexEach<T> = (item: () => T, index: number) => Node;\n\n/**\n * The return type of {@link For} / {@link Index}: a keyed list that owns an anchored\n * region and reconciles rows in place. Exported (D4) so consumers can annotate\n * helpers that build or pass around lists. `mount` is called by `h`/`render` when the\n * list is used as a child; `__wcsList` is the brand `appendChild` checks.\n */\nexport interface ListView {\n readonly __wcsList: true;\n mount(parent: Node): void;\n}\n\nfunction isListView(value: unknown): value is ListView {\n return typeof value === \"object\" && value !== null && (value as ListView).__wcsList === true;\n}\n\nfunction readList<T>(list: ListAccessor<T>): () => readonly T[] {\n return isReadSignal(list) ? () => (list as ReadSignal<readonly T[]>).get() : (list as () => readonly T[]);\n}\n\nexport interface ForOptions<T> {\n /** Derive a unique key per item. Default: the item value itself (identity). */\n key?: (item: T, index: number) => unknown;\n}\n\n// --- LIS-based DOM reorder ---------------------------------------------------\n//\n// `reconcileOrder` brings the live DOM under `host` (the contiguous region ending\n// at `anchor`) into `order` — the desired final node sequence — using the FEWEST\n// `insertBefore` moves, while producing EXACTLY the order a naive full re-place\n// would. The naive approach (walk and insert every out-of-place node) does up to\n// O(n) DOM moves on a full reverse or a head insert; here we instead keep the\n// largest set of reused rows that are ALREADY in the right relative order, and\n// move only the others (Solid's reconcileArrays / udomdiff idea).\n//\n// HOW: `prevOrder` is the node sequence the previous run left in the DOM. For each\n// node in the new `order`, a reused row maps to its index in `prevOrder`; a freshly\n// created row has no previous position. The longest increasing subsequence (LIS)\n// of those previous indices marks the reused rows that need NOT move (their pairwise\n// relative order is already correct). Every other node — fresh ones, and reused\n// ones outside the LIS — is inserted before its already-correct successor, walking\n// back-to-front so the \"successor\" reference is always a settled node or the anchor.\n\n/**\n * Indices into `arr` (with value -1 meaning \"no previous position\") whose values\n * form a longest strictly-increasing subsequence. Entries equal to -1 are treated\n * as never part of the subsequence (a fresh node always moves). Classic\n * patience-sorting LIS in O(n log n); returns the chosen indices in ascending order.\n */\nfunction longestIncreasingSubsequence(arr: number[]): number[] {\n const n = arr.length;\n // `tails[k]` = index (into arr) of the smallest tail of an increasing\n // subsequence of length k+1. `prev[i]` = predecessor index, to rebuild the chain.\n const tails: number[] = [];\n const prev: number[] = new Array(n).fill(-1);\n for (let i = 0; i < n; i++) {\n const value = arr[i];\n if (value < 0) {\n continue; // fresh node: not eligible for the stable subsequence\n }\n // Binary search for the first tail whose value is >= this value, and replace it\n // (or extend the tails when this value beats every tail).\n let lo = 0;\n let hi = tails.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (arr[tails[mid]] < value) {\n lo = mid + 1;\n } else {\n hi = mid;\n }\n }\n if (lo > 0) {\n prev[i] = tails[lo - 1];\n }\n tails[lo] = i;\n }\n // Rebuild the index chain from the longest tail backwards.\n const result: number[] = [];\n let k = tails.length > 0 ? tails[tails.length - 1] : -1;\n while (k >= 0) {\n result.push(k);\n k = prev[k];\n }\n result.reverse();\n return result;\n}\n\nfunction reconcileOrder(\n host: Node,\n anchor: Node,\n order: Node[],\n prevOrder: Node[],\n): void {\n const n = order.length;\n if (n === 0) {\n return; // nothing to place (removals already happened)\n }\n\n // Map each previous node to its previous position, so a node in `order` can look\n // up where it used to be. A node absent from this map is FRESH (created this run,\n // or the first run where prevOrder is empty) and is encoded as -1 — it always moves.\n const prevIndex = new Map<Node, number>();\n for (let i = 0; i < prevOrder.length; i++) {\n prevIndex.set(prevOrder[i], i);\n }\n\n // previous-position sequence aligned to the new order. -1 marks a fresh node.\n const seq: number[] = new Array(n);\n for (let i = 0; i < n; i++) {\n const p = prevIndex.get(order[i]);\n seq[i] = p === undefined ? -1 : p;\n }\n\n // Rows whose relative order is already correct: leave them in place, move the rest.\n const lis = longestIncreasingSubsequence(seq);\n let lisPtr = lis.length - 1;\n\n // Walk back-to-front. `ref` is the node that must follow the one being placed; it\n // starts at the anchor (the region's tail) and becomes each placed node. A node in\n // the LIS is the maximal already-correctly-ordered set, so it is left untouched\n // (only adopted as the new `ref`). Every OTHER node is, by construction, out of\n // position relative to its settled successor and is inserted before `ref` — no\n // \"is it already in place?\" guard is needed (it never is, unlike the old\n // full-walk reconciler which visited correctly-placed nodes too).\n let ref: Node = anchor;\n for (let i = n - 1; i >= 0; i--) {\n const node = order[i];\n if (lisPtr >= 0 && lis[lisPtr] === i) {\n lisPtr--; // stable: do not move\n } else {\n host.insertBefore(node, ref);\n }\n ref = node;\n }\n}\n\n// Dev-only key sanity check (no effect in production — guarded by `isDev()` at the\n// call site so this is never reached when dev is off). Flags the silent-failure key\n// shapes: a nullish key (NaN / null / undefined collide under SameValueZero, so two\n// such items map to one row and a row is silently dropped), and — when no explicit\n// `key` was given — a non-primitive item used as its own identity key (every render\n// gets a fresh object reference, so the row is rebuilt instead of reused, silently\n// dropping per-row state). Warns once per distinct shape (deduped in warnDev).\nfunction checkKeyDev(key: unknown, item: unknown, hasExplicitKey: boolean): void {\n if (key == null || (typeof key === \"number\" && Number.isNaN(key))) {\n warnDev(\n \"NULLISH_KEY\",\n String(key),\n \"For: a key is null/undefined/NaN. Such keys collide under SameValueZero, \" +\n \"so rows silently merge/drop. Provide a stable unique `key`.\",\n { key },\n );\n return;\n }\n if (!hasExplicitKey && (typeof key === \"object\" || typeof key === \"function\")) {\n warnDev(\n \"NON_PRIMITIVE_KEY\",\n typeof key,\n \"For: a non-primitive item is used as its own key (no `key` option given). \" +\n \"Object identity changes across renders, so every row is rebuilt and per-row \" +\n \"state is lost. Pass `{ key: item => item.id }`, and read the item through current().\",\n { item },\n );\n }\n}\n\nexport function For<T>(list: ListAccessor<T>, each: ForEach<T>, options?: ForOptions<T>): ListView {\n const read = readList(list);\n const keyOf = options?.key;\n return {\n __wcsList: true,\n mount(parent: Node): void {\n const anchor = document.createComment(\"for\");\n parent.appendChild(anchor);\n\n interface Row {\n node: Node;\n dispose: () => void;\n idx: WriteSignal<number>;\n /** The item under the row's key now (`each`'s `current`). */\n cur: WriteSignal<T>;\n }\n let rows = new Map<unknown, Row>();\n // The node order placed by the previous reconcile run. Empty on first run.\n // Used to find which reused rows already sit in increasing relative order so\n // only the rest are moved (LIS reorder, see reconcileOrder).\n let prevOrder: Node[] = [];\n\n const make = (item: T, i: number): Row => {\n const idx = signal(i);\n const cur = signal(item);\n let node!: Node;\n const dispose = createRoot((d) => {\n node = each(item, () => idx.get(), () => cur.get());\n return d;\n });\n return { node, dispose, idx, cur };\n };\n\n effect(() => {\n const items = read() ?? [];\n\n // Key-uniqueness PRE-PASS (no side effects): throwing here, before any row is\n // created or moved, keeps a duplicate-key error from leaving half-built rows\n // orphaned (make() runs createRoot) and the DOM mid-reorder. Keys are reused\n // below so keyOf runs once per item.\n const keys: unknown[] = [];\n const seen = new Set<unknown>();\n const dev = isDev();\n for (let i = 0; i < items.length; i++) {\n const k = keyOf ? keyOf(items[i], i) : items[i];\n if (dev) {\n checkKeyDev(k, items[i], keyOf !== undefined);\n }\n if (seen.has(k)) {\n if (dev) {\n // The throw below still halts (production behaviour unchanged); the warn\n // adds the offending key + a pointer to the cause so the silent\n // \"updates stopped\" symptom is diagnosable.\n warnDev(\n \"DUPLICATE_KEY\",\n String(k),\n `For: duplicate key \"${String(k)}\" at index ${i} — keys must be unique. ` +\n \"Rendering throws and the list stops updating until keys are fixed.\",\n { key: k, index: i },\n );\n }\n throw new Error(`For: duplicate key \"${String(k)}\" — keys must be unique.`);\n }\n seen.add(k);\n keys.push(k);\n }\n\n const next = new Map<unknown, Row>();\n const order: Node[] = [];\n\n // Rows freshly created in THIS run (not reused from `rows`). If a later\n // `make()` — i.e. a user `each` — throws mid-loop, the rows already built\n // here are owned by their own detached `createRoot` and are not yet tracked\n // in any surviving map, so they would leak. Dispose them before re-throwing,\n // leaving the old `rows` map untouched (it is recoverable on the next run).\n const fresh: Row[] = [];\n try {\n for (let i = 0; i < items.length; i++) {\n const k = keys[i];\n let row = rows.get(k);\n if (row) {\n if (row.idx.peek() !== i) {\n row.idx.set(i); // position changed — refresh the index accessor\n }\n row.cur.set(items[i]); // the item under the key now (a no-op when it is the same)\n } else {\n row = make(items[i], i);\n fresh.push(row);\n }\n next.set(k, row);\n order.push(row.node);\n }\n } catch (err) {\n for (const row of fresh) {\n row.dispose();\n }\n throw err;\n }\n\n // The LIVE parent (`anchor.parentNode`, not the mount arg) so the region\n // stays correct after being moved (e.g. built inside a Fragment, then\n // appended elsewhere). `host` is null only if the anchor was detached\n // without disposing this scope (a misuse) — then there is nothing to\n // place into. Resolved before the removal phase so the wholesale-removal\n // fast path below can use it.\n const host = anchor.parentNode;\n\n // Dispose rows whose key vanished. `remove()` no-ops if already detached.\n if (rows.size > 0 && next.size === fresh.length) {\n // ZERO-REUSE run: no existing key survives (clear, or a full replacement\n // with disjoint keys), so EVERY current row is removed. When the host\n // contains exactly this list's region — first child is the region's\n // first row, last child is the anchor, and the child count matches\n // rows + anchor — detach them all with a single native\n // `textContent = \"\"` and re-append the anchor, instead of one\n // `remove()` per row (the dominant cost of clearing large lists).\n // Any deviation (foreign sibling, externally detached row, shared\n // host) fails the guard and falls back to the per-row path.\n // Disposal always runs per row; only the DOM detachment is batched.\n if (\n host !== null &&\n host.lastChild === anchor &&\n prevOrder.length > 0 &&\n host.firstChild === prevOrder[0] &&\n host.childNodes.length === rows.size + 1\n ) {\n host.textContent = \"\";\n host.appendChild(anchor);\n for (const row of rows.values()) {\n row.dispose();\n }\n } else {\n for (const row of rows.values()) {\n (row.node as ChildNode).remove();\n row.dispose();\n }\n }\n } else {\n for (const [k, row] of rows) {\n if (!next.has(k)) {\n (row.node as ChildNode).remove();\n row.dispose();\n }\n }\n }\n if (host) {\n reconcileOrder(host, anchor, order, prevOrder);\n }\n\n // Snapshot this run's final order so the NEXT run's reconcile can detect\n // which rows kept their relative position (the LIS basis below). Capturing\n // the array we just placed avoids re-deriving it from the map.\n prevOrder = order;\n rows = next;\n });\n\n onCleanup(() => {\n for (const row of rows.values()) {\n row.dispose();\n }\n rows.clear();\n });\n },\n };\n}\n\nexport function Index<T>(list: ListAccessor<T>, each: IndexEach<T>): ListView {\n const read = readList(list);\n return {\n __wcsList: true,\n mount(parent: Node): void {\n const anchor = document.createComment(\"index\");\n parent.appendChild(anchor);\n\n interface Row {\n node: Node;\n dispose: () => void;\n item: WriteSignal<T>;\n }\n const rows: Row[] = [];\n\n effect(() => {\n const items = read() ?? [];\n // Live parent (see `For`), null only if the anchor was detached undisposed.\n const host = anchor.parentNode;\n\n for (let i = 0; i < items.length; i++) {\n if (i < rows.length) {\n // Slot reused: just push the new value into the row's item signal. The\n // signal's equality guard skips the update when the value is unchanged.\n rows[i].item.set(items[i]);\n } else {\n const item = signal(items[i]);\n let node!: Node;\n const dispose = createRoot((d) => {\n node = each(() => item.get(), i);\n return d;\n });\n rows.push({ node, dispose, item });\n // Positions never move for index keying, so append at the tail (before\n // the anchor) in order. ORDERING CONTRACT (shared with For and the other\n // anchored insertions): the list owns the contiguous region ENDING at its\n // anchor comment. New rows go immediately before the anchor, so the list's\n // own rows always stay correctly ordered and grouped, and static siblings\n // before the anchor (or another list with its own anchor) are never\n // disturbed. Do NOT splice unrelated nodes into the middle of this region.\n host?.insertBefore(node, anchor);\n }\n }\n\n // Trailing slots that no longer exist: dispose and drop.\n if (items.length < rows.length) {\n // WHOLESALE CLEAR (same idea as For's zero-reuse fast path): every slot\n // vanishes and the host holds exactly this list's region (all rows +\n // the anchor), so one native `textContent = \"\"` replaces per-row\n // `remove()`. Guard failures (foreign sibling, detached row, shared\n // host) fall back to the per-row path. Disposal still runs per row.\n if (\n items.length === 0 &&\n host !== null &&\n host.lastChild === anchor &&\n host.firstChild === rows[0].node &&\n host.childNodes.length === rows.length + 1\n ) {\n host.textContent = \"\";\n host.appendChild(anchor);\n for (const row of rows) {\n row.dispose();\n }\n } else {\n for (let i = items.length; i < rows.length; i++) {\n (rows[i].node as ChildNode).remove();\n rows[i].dispose();\n }\n }\n rows.length = items.length;\n }\n });\n\n onCleanup(() => {\n for (const row of rows) {\n row.dispose();\n }\n rows.length = 0;\n });\n },\n };\n}\n\n// --- custom element lifecycle (docs §8 (e)) ---------------------------------\n//\n// The exit point for ownership: a custom element that mounts a signals view under\n// `createRoot` on connect and disposes that root on disconnect. This wires the\n// reactive ownership tree to the real DOM lifecycle — every effect, resource and\n// listener created in `render()` is torn down when the element leaves the DOM, and\n// rebuilt fresh on reconnect. Subclasses only implement `render()`.\n//\n// SCOPE (v1 intentional constraints — drive these reactively, not via this base):\n// - No attribute reactivity. There is no `attributeChangedCallback`/\n// `observedAttributes` wiring: this base does NOT turn HTML attributes into\n// signals. Feed reactive inputs as signals/props from the code that constructs\n// the view (or have a subclass map attributes to signals itself).\n// - Shadow DOM is opt-in and subclass-owned. The default mount point is light DOM\n// (`this`); a subclass that wants encapsulation overrides `getMountPoint()` to\n// return a shadow root it created (e.g. `this.attachShadow(...)` in its\n// constructor). This base never calls attachShadow implicitly.\n// - Mount/unmount only: render() runs once per connect and the whole subtree is\n// disposed on disconnect — there is no partial/incremental re-render hook here\n// (fine-grained updates come from the signals wired inside render()).\n\n// TYPE-ONLY shape of the lifecycle base. `declare abstract class` emits NO runtime\n// code (so it does not reference `HTMLElement` at module-evaluation time — the whole\n// point of the lazy factory below), but it gives the exported `SignalsElement` value\n// and `createSignalsElement()`'s return a precise type that preserves the original\n// contract: `render` is `protected abstract` (a subclass MUST implement it and may\n// only reach it from within), and `getMountPoint` is `protected` (overridable). This\n// is the same surface the previous concrete `abstract class SignalsElement` exposed.\n// (Used only via `typeof` below; the lint rule does not see that as a value use.)\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ndeclare abstract class SignalsElementType extends HTMLElement {\n /** Build the view with `h` + signals. Runs inside an ownership root. */\n protected abstract render(): Node;\n /** Mount target. Override to return a shadow root; default is light DOM. */\n protected getMountPoint(): Node;\n connectedCallback(): void;\n disconnectedCallback(): void;\n}\n\n/**\n * The lifecycle base contract: the abstract constructor type of the `SignalsElement`\n * base. Abstract, so `new SignalsElement()` is rejected (the base has an unimplemented\n * `render`) while `class X extends SignalsElement` is allowed. Returned by\n * {@link createSignalsElement} and the type of the {@link SignalsElement} value.\n */\nexport type SignalsElementClass = typeof SignalsElementType;\n\n// Memoized base class. Built lazily on first access so the `./dom` module can be\n// EVALUATED in a non-DOM environment (SSR pre-pass, a worker without a DOM shim)\n// without a top-level `class … extends HTMLElement` blowing up with\n// `ReferenceError: HTMLElement is not defined`. The class body is only constructed\n// when the consumer actually reaches for the base — at which point a DOM is required\n// and its absence yields a clear, actionable error instead of a raw ReferenceError.\nlet cachedBase: SignalsElementClass | null = null;\n\n/**\n * Build (once, memoized) the `SignalsElement` lifecycle base class. Resolves\n * `HTMLElement` at CALL TIME, so importing `@wcstack/signals/dom` no longer requires\n * a DOM at module-evaluation time — only *calling* this (or subclassing\n * {@link SignalsElement}) does.\n *\n * Contract:\n * - The `.` entry (`@wcstack/signals`) is non-DOM: it evaluates and runs in SSR,\n * Node, and Web Workers with no DOM globals.\n * - The `./dom` entry (`@wcstack/signals/dom`) may now also be *evaluated* without a\n * DOM (so an SSR pre-pass that imports it for the headless re-exports does not\n * crash). The DOM-touching surface — `h`/`render`/`For`/`Index` and this base —\n * still requires DOM globals when actually used.\n *\n * @throws a clear `Error` (not a raw `ReferenceError`) when no `HTMLElement` global is\n * present, naming the offending entry so the failure is self-explanatory.\n */\nexport function createSignalsElement(): SignalsElementClass {\n if (cachedBase !== null) {\n return cachedBase;\n }\n if (typeof HTMLElement === \"undefined\") {\n throw new Error(\n \"@wcstack/signals/dom: SignalsElement requires a DOM (HTMLElement is not defined). \" +\n \"The `./dom` entry's element/render surface is browser-only; in SSR/Node/worker \" +\n \"code import the headless core from `@wcstack/signals` instead, or inject a DOM \" +\n \"(e.g. happy-dom) before constructing custom elements.\",\n );\n }\n\n abstract class SignalsElementBase extends HTMLElement {\n private _dispose: (() => void) | null = null;\n\n /** Build the view with `h` + signals. Runs inside an ownership root. */\n protected abstract render(): Node;\n\n /** Mount target. Override to return a shadow root; default is light DOM. */\n protected getMountPoint(): Node {\n return this;\n }\n\n connectedCallback(): void {\n if (this._dispose !== null) {\n return; // already mounted (defensive against a redundant connect)\n }\n const mount = this.getMountPoint();\n // If render() throws, createRoot disposes any effects it built before the throw,\n // so nothing leaks; _dispose stays null (the element is simply not mounted) and\n // a later disconnectedCallback safely no-ops. The error propagates to the caller.\n this._dispose = createRoot((dispose) => {\n mount.appendChild(this.render());\n return dispose;\n });\n }\n\n disconnectedCallback(): void {\n if (this._dispose === null) {\n return; // not mounted\n }\n this._dispose();\n this._dispose = null;\n const mount = this.getMountPoint();\n while (mount.firstChild) {\n mount.removeChild(mount.firstChild);\n }\n }\n }\n\n cachedBase = SignalsElementBase as unknown as SignalsElementClass;\n return cachedBase;\n}\n\n// `SignalsElement` is the ergonomic name to `extends`. It is a lazily-resolved alias\n// for the class built by `createSignalsElement()`: a Proxy that forwards construct /\n// get / has / getPrototypeOf to the real (memoized) base, building it on first touch.\n// This keeps `class X extends SignalsElement { … }` working exactly as before WHILE\n// deferring the `HTMLElement` reference to subclass-definition time (in a real DOM),\n// instead of `./dom` module-evaluation time (which may be a non-DOM SSR pre-pass).\n//\n// BREAKING note: the value is now a Proxy, not the class object literal. Subclassing,\n// `instanceof`, and static/prototype access all still work; a consumer that relied on\n// `SignalsElement` being a *frozen* concrete class reference (uncommon) should call\n// `createSignalsElement()` to obtain the real class.\n// The Proxy target is a never-called placeholder (every operation is intercepted by a\n// trap below); it only needs to be constructable/callable so `new` / `extends` and the\n// `apply` trap engage. It is intentionally a no-op and never executed.\n/* v8 ignore next */\nconst signalsElementTarget = function (): void {};\nexport const SignalsElement: SignalsElementClass = new Proxy(signalsElementTarget as unknown as SignalsElementClass, {\n construct(_target, args, newTarget): object {\n return Reflect.construct(createSignalsElement(), args, newTarget);\n },\n get(_target, prop, receiver): unknown {\n return Reflect.get(createSignalsElement(), prop, receiver);\n },\n has(_target, prop): boolean {\n return Reflect.has(createSignalsElement(), prop);\n },\n apply(): never {\n throw new TypeError(\"SignalsElement is a class and cannot be invoked without `new`/`extends`.\");\n },\n getPrototypeOf(): object | null {\n return Reflect.getPrototypeOf(createSignalsElement());\n },\n});\n\nfunction toNodes(value: unknown): Node[] {\n const out: Node[] = [];\n const visit = (v: unknown): void => {\n if (v == null || typeof v === \"boolean\") {\n return;\n }\n if (Array.isArray(v)) {\n v.forEach(visit);\n return;\n }\n if (v instanceof Node) {\n out.push(v);\n return;\n }\n out.push(document.createTextNode(String(v)));\n };\n visit(value);\n return out;\n}\n\n// --- mountNode: create + bind + mount a headless wc-bindable node -------------\n//\n// `bindNode` adapts an EXISTING element, which forces its caller to guarantee the\n// custom element class is already registered (the descriptor is read from\n// `el.constructor.wcBindable` at call time — an un-upgraded element has none).\n// `mountNode` closes that gap for the common signals shape where the app OWNS its\n// headless IO nodes: it creates the element AFTER the definition exists (so it is\n// upgraded at construction), binds it, then connects it. The recommended pairing\n// is a side-effect import of the package's `/auto` entry in the same module —\n// module evaluation order then guarantees the definition:\n//\n// import \"@wcstack/fetch/auto\";\n// const fetcher = mountNode(\"wcs-fetch\", { attrs: { url: \"/api/people\" } });\n// fetcher.signals.value.get();\n//\n// The internal order is deliberate: attributes are set BEFORE connect (shells read\n// their config in `connectedCallback`), and the adapter subscribes BEFORE connect,\n// so an event fired from `connectedCallback` is already observed — the missed-event\n// window is structurally zero, not merely closed by bindNode's re-seed. Like\n// `bindNode`, the adapter is NOT auto-registered with a reactive owner; teardown is\n// explicit via `unmount()` — to which `dispose()` is aliased, see MountedNode —\n// (compose with `onCleanup(() => m.unmount())` if the node should die with a\n// scope). See docs/signals-definition-timing.md for the full definition-timing\n// contract (optional packages via dynamic import, the remaining whenDefined /\n// <wcs-defined> territory).\n\nexport interface MountNodeOptions {\n /**\n * Attributes set on the element BEFORE it is connected (declarative pre-connect\n * config, e.g. `{ url: \"/api\", timeout: 5000 }`). HTML boolean-attribute\n * semantics: `true` sets an empty attribute, `false` omits it; other values are\n * stringified.\n */\n attrs?: Record<string, string | number | boolean>;\n /** Parent to append the element to. Default: `document.body`. */\n parent?: Node;\n /**\n * Explicit wc-bindable descriptor forwarded to `bindNode`. When given, the\n * tag-definition check is skipped — the escape hatch for binding a\n * non-custom-element tag, mirroring `bindNode`'s second parameter.\n */\n descriptor?: WcBindableDescriptor;\n}\n\nexport interface MountedNode<S extends NodeShape = DefaultNodeShape> extends BoundNode<S> {\n /** The created element (connected until `unmount()`). */\n readonly el: HTMLElement;\n /**\n * Full teardown: dispose the adapter AND remove the element from the DOM\n * (disconnect stops the shell's IO). Idempotent. On a `MountedNode`,\n * `dispose()` is an alias of this — mountNode owns the element's lifecycle,\n * so the package-wide teardown verb must not leave a connected element with\n * live IO behind (a silent leak for callers habituated to `bindNode`).\n */\n unmount(): void;\n}\n\nexport function mountNode<S extends NodeShape = DefaultNodeShape>(\n tagName: string,\n options: MountNodeOptions = {},\n): MountedNode<S> {\n // Call-time DOM guard (not module-time): `./dom` must evaluate in non-DOM realms\n // (SSR pre-pass / worker) — same contract (and message shape) as `createSignalsElement`.\n if (typeof document === \"undefined\" || typeof customElements === \"undefined\") {\n throw new Error(\n \"@wcstack/signals/dom: mountNode requires a DOM (document/customElements is not defined). \" +\n \"It creates and connects a live element, so it is browser-only; inject a DOM \" +\n \"(e.g. happy-dom) before calling, or keep headless work on `@wcstack/signals`.\",\n );\n }\n const { attrs, parent, descriptor } = options;\n // Custom element names are lowercase; the registry is exact-key while\n // createElement ASCII-lowercases — normalize once so mountNode(el.tagName)\n // (uppercase in HTML documents) hits the same definition the element would.\n const tag = tagName.toLowerCase();\n // Fail loud with the actual cause. Without this, bindNode's generic \"no\n // wc-bindable descriptor\" error hides that the tag simply isn't defined yet.\n if (!descriptor && !customElements.get(tag)) {\n throw new Error(\n `mountNode: \"<${tag}>\" is not defined. Import its defining module first (e.g. a side-effect ` +\n `\\`import \"@wcstack/<pkg>/auto\"\\` in this module — evaluation order then guarantees the definition). ` +\n `For a tag loaded by someone else, await customElements.whenDefined(\"${tag}\") or gate with ` +\n `<wcs-defined> before mounting. Binding a non-custom-element tag requires an explicit \\`descriptor\\`.`,\n );\n }\n\n const el = document.createElement(tag);\n if (attrs) {\n for (const [name, value] of Object.entries(attrs)) {\n if (value === false) {\n continue; // boolean-attribute semantics: false = absent\n }\n el.setAttribute(name, value === true ? \"\" : String(value));\n }\n }\n const bound = bindNode<S>(el, descriptor);\n (parent ?? document.body).appendChild(el);\n const unmount = (): void => {\n bound.dispose();\n el.remove();\n };\n return {\n ...bound,\n el,\n unmount,\n // Override the inherited adapter-only dispose(): on a MountedNode it would be\n // a silent PARTIAL teardown (signals inert, but the created element stays\n // connected with its shell's IO still running). mountNode owns the element,\n // so dispose === unmount.\n dispose: unmount,\n };\n}\n"],"names":["effect"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MA4Ca,QAAQ,GAAG,MAAM,CAAC,kBAAkB;AAUjD,SAAS,YAAY,CAAC,KAAc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;;;;"}
|
|
1
|
+
{"version":3,"file":"dom.esm.js","sources":["../src/dom.ts"],"sourcesContent":["// Fine-grained hyperscript (v1 design notes). The \"step before JSX\" (docs §4-1).\n//\n// `h(tag, props, ...children)` is the classic JSX factory shape, but it does NOT\n// build a virtual DOM and re-render. It creates a REAL DOM node once; any prop or\n// child given as a function (thunk) or signal is wired to a targeted `effect`, so\n// only that one binding updates when its signals change (Solid-style). This is\n// what keeps the package lightweight: no reconciler is shipped.\n//\n// JSX is intentionally NOT shipped. A consumer who wants it sets, in their own\n// tsconfig, `jsxFactory: \"h\"` + `jsxFragmentFactory: \"Fragment\"` (classic runtime)\n// — opting into a build step is their choice; the buildless path is calling `h`\n// directly. See docs/signals-state-design.md §4-1.\n//\n// OWNERSHIP: effects created here are owned by the enclosing reactive scope.\n// A reactive child's effect owns the prop/child effects of the subtree it builds,\n// so rebuilding that subtree disposes the previous one's effects (no leak). Mount\n// an app under `createRoot` so the whole tree can be torn down on unmount; a\n// dynamic child establishes its own scope automatically (it IS an effect).\n\nimport { signal, innerEffect as effect, onCleanup, createRoot, hasOwner, ReadSignal, WriteSignal } from \"./reactive.js\";\nimport { isDev, warnDev } from \"./dev.js\";\nimport { bindNode } from \"./bindNode.js\";\nimport type { BoundNode, NodeShape, DefaultNodeShape, WcBindableDescriptor } from \"./bindNode.js\";\n\n// `@wcstack/signals/dom` re-exports the headless core (signals, resource,\n// streamResource, bindNode, nodeSource) so UI code can import everything from one\n// module. Both built entries import a single shared `core-*.esm.js` chunk\n// (rollup.config.js `manualChunks`), so importing from BOTH `@wcstack/signals` and\n// `@wcstack/signals/dom` on a buildless page yields ONE reactive instance — the\n// tracking context is shared, not duplicated. `__tests__/packaging.test.ts` pins\n// this (both entries reference the same core chunk; a signal made via one entry is\n// observed by an effect from the other).\nexport {\n signal,\n computed,\n effect,\n createRoot,\n onCleanup,\n flushSync,\n selector,\n} from \"./reactive.js\";\nexport type { ReadSignal, WriteSignal, EffectHandle, Cleanup, Equals } from \"./reactive.js\";\nexport { resource } from \"./resource.js\";\nexport type { ResourceState, ResourceOptions, ResourceSource } from \"./resource.js\";\nexport { streamResource } from \"./streamResource.js\";\nexport type {\n StreamResourceState,\n StreamResourceOptions,\n StreamSource,\n StreamProducer,\n StreamStatus,\n} from \"./streamResource.js\";\nexport { bindNode, nodeSource, DisposedError, isDisposedError } from \"./bindNode.js\";\nexport type {\n BoundNode,\n NodeShape,\n DefaultNodeShape,\n WcBindableDescriptor,\n WcBindableProperty,\n EventStreamOptions,\n} from \"./bindNode.js\";\n\nexport const Fragment = Symbol(\"signals.Fragment\");\n\nexport type Child = unknown;\nexport type Props = Record<string, unknown> | null;\n// h() always injects `children` into the props object it passes to a component, so\n// the parameter type makes that explicit (a component can declare `{ children }`).\nexport type Component = (\n props: Record<string, unknown> & { children?: Child[] },\n) => Node | Child[];\n\nfunction isReadSignal(value: unknown): value is ReadSignal<unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { get?: unknown }).get === \"function\" &&\n typeof (value as { peek?: unknown }).peek === \"function\"\n );\n}\n\nexport function h(\n tag: string | typeof Fragment | Component,\n props?: Props,\n ...children: Child[]\n): Node {\n if (tag === Fragment) {\n const frag = document.createDocumentFragment();\n appendChildren(frag, children);\n return frag;\n }\n\n if (typeof tag === \"function\") {\n const result = tag({ ...(props ?? {}), children });\n return Array.isArray(result) ? wrapFragment(result) : result;\n }\n\n const el = createElement(tag);\n if (props) {\n for (const key in props) {\n bindProp(el, key, props[key]);\n }\n }\n appendChildren(el, children);\n return el;\n}\n\nconst SVG_NS = \"http://www.w3.org/2000/svg\";\n\n// Tags created in the SVG namespace. Ambiguous names shared with HTML (`a`,\n// `title`, `script`, `style`) are intentionally EXCLUDED so ordinary HTML usage is\n// not broken; an SVG `<a>` / `<title>` must be created in an explicitly-namespaced\n// way by the caller. SVG DOM props are largely read-only, so `setProp`'s\n// settable-property check routes SVG attributes through `setAttribute` for free.\nconst SVG_TAGS = new Set([\n \"svg\", \"g\", \"path\", \"rect\", \"circle\", \"ellipse\", \"line\", \"polyline\", \"polygon\",\n \"text\", \"tspan\", \"defs\", \"use\", \"symbol\", \"marker\", \"linearGradient\",\n \"radialGradient\", \"stop\", \"clipPath\", \"mask\", \"pattern\", \"image\", \"foreignObject\",\n]);\n\nfunction createElement(tag: string): Element {\n return SVG_TAGS.has(tag)\n ? document.createElementNS(SVG_NS, tag)\n : document.createElement(tag);\n}\n\n/** Append `child` into `container`, resolving fragments/arrays. */\nexport function render(child: Child, container: Node): Node {\n appendChild(container, child);\n return container;\n}\n\nfunction wrapFragment(children: Child[]): DocumentFragment {\n const frag = document.createDocumentFragment();\n appendChildren(frag, children);\n return frag;\n}\n\n// --- props ------------------------------------------------------------------\n\n// Attribute names whose corresponding JS DOM property differs. `class` is handled\n// separately (it has reactive-falsy semantics in setProp), so it is not listed here.\nconst ATTR_TO_PROP: Record<string, string> = {\n for: \"htmlFor\",\n tabindex: \"tabIndex\",\n colspan: \"colSpan\",\n rowspan: \"rowSpan\",\n readonly: \"readOnly\",\n maxlength: \"maxLength\",\n minlength: \"minLength\",\n contenteditable: \"contentEditable\",\n};\n\n// True only if `key` resolves to a WRITABLE property on the element or its\n// prototype chain (a data property with `writable !== false`, or an accessor with a\n// setter). `key in el` is not enough: it also matches read-only members like\n// `firstChild` / `childNodes`, whose assignment throws in strict mode. The walk\n// starts at `el` itself so own instance fields (e.g. a custom element's properties)\n// are still matched, exactly as the previous `key in el` did — just without the\n// read-only false positives.\n//\n// MEMOIZATION: the prototype-chain walk runs on every bindProp/setProp. The result\n// depends only on the element's PROTOTYPE (its class) and the key, since DOM props\n// live on the prototype — not on per-instance own fields, which this library never\n// adds dynamically per element. So cache by `(prototype, key)`: a WeakMap keyed by\n// prototype (no leak — entries die with the class) holding a Map of key→result.\nconst settableCache = new WeakMap<object, Map<string, boolean>>();\n\nfunction computeSettable(el: Element, key: string): boolean {\n let obj: object | null = el;\n while (obj !== null) {\n const desc = Object.getOwnPropertyDescriptor(obj, key);\n if (desc) {\n return \"set\" in desc ? typeof desc.set === \"function\" : desc.writable !== false;\n }\n obj = Object.getPrototypeOf(obj);\n }\n return false;\n}\n\nfunction isSettableProperty(el: Element, key: string): boolean {\n // A real Element always has a prototype (HTMLElement.prototype → … → Object), so\n // `getPrototypeOf` is non-null here; use it as the cache key.\n const proto = Object.getPrototypeOf(el) as object;\n let byKey = settableCache.get(proto);\n if (byKey === undefined) {\n byKey = new Map<string, boolean>();\n settableCache.set(proto, byKey);\n }\n let result = byKey.get(key);\n if (result === undefined) {\n result = computeSettable(el, key);\n byKey.set(key, result);\n }\n return result;\n}\n\nfunction bindProp(el: Element, key: string, value: unknown): void {\n // Event handlers are special-cased BEFORE the reactive check: a function here is the\n // listener, not a thunk to track. `onClick` → \"click\" (lowercased); `onclick` /\n // `onadd-to-cart` → the name as written (\"click\", \"add-to-cart\" — data-wcs's `on<event>:`\n // form). A lowercase `onclick` used to fall through to the reactive path, so the handler\n // ran at render and never on click (docs/seam-apps.md, signals-shop).\n // `on` and a letter or `-` (no regex per prop: it ran twice for every prop of every element).\n // `| 32` folds A-Z onto a-z and leaves \"-\" (45) as it is.\n const c2 = key.charCodeAt(2) | 32;\n if (key[0] === \"o\" && key[1] === \"n\" && ((c2 >= 97 && c2 <= 122) || c2 === 45) && typeof value === \"function\") {\n const type = key.charCodeAt(2) < 91 ? key.slice(2).toLowerCase() : key.slice(2);\n const listener = value as EventListener;\n el.addEventListener(type, listener);\n // Remove the listener when the owning scope is torn down while the element is still in the\n // document (e.g. a reactive child of a kept element, or a SignalsElement re-render), so handlers\n // don't accumulate on an element that lives on. A detached element (a removed row, a replaced\n // subtree) is not touched: its listeners go with it, and removing them one by one was a fifth\n // of clearing a list.\n onCleanup(() => {\n if (el.isConnected) el.removeEventListener(type, listener);\n });\n return;\n }\n\n if (typeof value === \"function\") {\n effect(() => setProp(el, key, (value as () => unknown)()));\n return;\n }\n\n if (isReadSignal(value)) {\n effect(() => setProp(el, key, value.get()));\n return;\n }\n\n setProp(el, key, value);\n}\n\n/**\n * Objects given to a custom element that is not defined yet, by element → property, until it is\n * (docs/seam-apps.md, signals-shop: `h(\"product-card\", { product })` before `product-card.js` ran\n * landed as `product=\"[object Object]\"`). Not set on the element now: an own property set before\n * the upgrade would hide the class's accessor, so its setter would never run. The latest value is\n * assigned once the element is defined — through the setter, as a defined element gets it.\n */\nconst heldUntilDefined = new WeakMap<Element, Map<string, unknown>>();\n\n/** A custom element (a dash in its name) whose definition has not run yet. */\nfunction awaitsDefinition(el: Element): boolean {\n return el.localName.includes(\"-\") && typeof customElements !== \"undefined\" && customElements.get(el.localName) === undefined;\n}\n\nfunction holdUntilDefined(el: Element, key: string, value: unknown): void {\n let held = heldUntilDefined.get(el);\n if (!held) {\n heldUntilDefined.set(el, (held = new Map()));\n const props = held;\n void customElements.whenDefined(el.localName).then(() => {\n heldUntilDefined.delete(el);\n // (an element not in the document is not upgraded by define(): upgrade it before the setter is wanted)\n customElements.upgrade(el);\n for (const [k, v] of props) (el as unknown as Record<string, unknown>)[k] = v;\n });\n }\n held.set(key, value);\n}\n\nfunction setProp(el: Element, key: string, value: unknown): void {\n if (key === \"style\") {\n setStyle(el as HTMLElement, value);\n return;\n }\n if (key === \"class\" || key === \"className\") {\n // Set the `class` ATTRIBUTE, not the `className` property. On an SVGElement\n // `className` is a read-only `SVGAnimatedString`, so assigning it throws in\n // strict mode (ESM is always strict) — `setAttribute(\"class\", …)` works for both\n // HTML and SVG. Treat false like null → empty class (consistent with the\n // attribute path's false-removes-it rule), so `() => cond && \"active\"` yields \"\"\n // (not \"false\") when the condition is falsy.\n // STRING-ONLY: a non-null/non-false value is coerced via String(value). Array\n // (`[\"a\", \"b\"]`) and object (`{ active: true }`) class forms are NOT supported —\n // they would stringify to \"a,b\" / \"[object Object]\". Compose the class string in\n // the binding itself (e.g. `() => [a, b].join(\" \")`) and pass a string. This keeps\n // the core free of a class-merging convention.\n el.setAttribute(\"class\", value == null || value === false ? \"\" : String(value));\n return;\n }\n // Remap the handful of attribute names whose JS property differs, so `for` /\n // `tabindex` / `colspan` etc. reach the right property instead of falling through\n // to setAttribute (which works for some but not e.g. `htmlFor`).\n const propKey = ATTR_TO_PROP[key] ?? key;\n if (isSettableProperty(el, propKey)) {\n // Known, WRITABLE DOM property (value, checked, disabled, id, htmlFor, ...).\n // The settability check excludes read-only members (firstChild, childNodes, …)\n // that `key in el` would wrongly accept — assigning to those throws in strict\n // mode; we fall through to the attribute path for them instead.\n //\n // NORMALIZATION: null/undefined are coerced to \"\" before assignment. Without\n // this, a STRING prop (id/title/value/src) given a reactive null/undefined\n // lands as the literal \"null\"/\"undefined\" (e.g. img.src=\"null\" fires a real\n // request) — a correctness footgun. \"\" clears the prop instead. Safe for\n // non-string props too: boolean props coerce \"\"→false (same as null), numeric\n // props coerce \"\"→0 (same as null). We do NOT normalize `false`:\n // `el.disabled = false` is the intended boolean clear.\n (el as unknown as Record<string, unknown>)[propKey] = value == null ? \"\" : value;\n return;\n }\n // (a value given since replaces a held one: a primitive goes to the attribute, as below)\n heldUntilDefined.get(el)?.delete(propKey);\n if (typeof value === \"object\" && value !== null && awaitsDefinition(el)) {\n holdUntilDefined(el, propKey, value);\n return;\n }\n if (value == null || value === false) {\n el.removeAttribute(key);\n return;\n }\n if (value === true) {\n el.setAttribute(key, \"\");\n return;\n }\n el.setAttribute(key, String(value));\n}\n\nfunction setStyle(el: HTMLElement, value: unknown): void {\n if (value == null) {\n el.removeAttribute(\"style\");\n return;\n }\n if (typeof value === \"string\") {\n el.style.cssText = value;\n return;\n }\n // Object form: the object fully describes the style. Reset first so keys present\n // in a previous run but absent now are removed — otherwise a reactive style that\n // drops a key (e.g. {color,fontWeight} → {color}) would leave the stale property\n // applied. The object is the source of truth, so wiping cssText is correct here.\n el.style.cssText = \"\";\n const style = el.style as CSSStyleDeclaration & Record<string, string>;\n const obj = value as Record<string, string>;\n for (const k in obj) {\n // A key with a hyphen is either kebab-case (`font-weight`) or a CSS custom\n // property (`--accent`). Neither works via property assignment (`style[k]` would\n // just set an inert expando), so route them through setProperty. camelCase keys\n // (`fontWeight`) keep the faster property path.\n if (k.includes(\"-\")) {\n style.setProperty(k, obj[k]);\n } else {\n style[k] = obj[k];\n }\n }\n}\n\n// --- children ---------------------------------------------------------------\n\nfunction appendChildren(parent: Node, children: Child[]): void {\n for (const child of children) {\n appendChild(parent, child);\n }\n}\n\nfunction appendChild(parent: Node, child: Child): void {\n if (child == null || typeof child === \"boolean\") {\n return; // null / undefined / boolean render nothing\n }\n if (Array.isArray(child)) {\n for (const c of child) {\n appendChild(parent, c);\n }\n return;\n }\n if (isListView(child)) {\n // A keyed list (For / Index): it manages its own anchored region with in-place\n // reconciliation, so it does NOT go through the wholesale insertReactive path.\n child.mount(parent);\n return;\n }\n if (child instanceof Node) {\n parent.appendChild(child);\n return;\n }\n if (typeof child === \"function\") {\n insertReactive(parent, child as () => unknown);\n return;\n }\n if (isReadSignal(child)) {\n insertReactive(parent, () => child.get());\n return;\n }\n parent.appendChild(document.createTextNode(String(child)));\n}\n\n/**\n * A reactive insertion point. An anchor comment marks the position; on each run\n * the previous nodes are removed and the freshly-resolved nodes inserted before\n * the anchor. Using `anchor.parentNode` (not the original `parent`) keeps it\n * correct after the subtree is moved/mounted elsewhere.\n *\n * PRECONDITION: the Nodes returned by `accessor` are owned by this insertion point\n * — do not move them to another parent externally. On the next run they are\n * removed from wherever they currently are (`node.parentNode?.removeChild`), so an\n * externally-moved node would be yanked out of its new home without warning.\n *\n * OWNERSHIP: the `effect` below is owned by the enclosing reactive scope at call\n * time (the `currentOwner`). Used under `createRoot` / `SignalsElement` (the module\n * header's mount contract) it is disposed on teardown. Calling `h`/`render` with a\n * reactive child OUTSIDE any owner (no `createRoot`/`SignalsElement`) leaves this\n * effect un-owned and therefore never cleaned up — by design, per that contract.\n */\nfunction insertReactive(parent: Node, accessor: () => unknown): void {\n if (isDev() && !hasOwner()) {\n // A reactive child inserted with no enclosing owner: the effect below is never\n // disposed (the module header documents this as by-design, but it is a frequent\n // accidental leak). Warn once in dev so the un-owned mount is visible.\n warnDev(\n \"UNOWNED_INSERT\",\n \"\",\n \"reactive child inserted with no owner — its update effect will never be \" +\n \"disposed and may leak. Mount under createRoot / SignalsElement.\",\n );\n }\n // The position: the first render's Text node while the value stays text (no anchor comment per text\n // child — most reactive children are text); an anchor comment from the first render of nodes on.\n // Until the anchor exists, `current` is empty (before the first run) or that one Text node.\n let anchor: Comment | null = null;\n let current: Node[] = [];\n\n effect(() => {\n const value = accessor();\n if (typeof value === \"string\" || typeof value === \"number\") {\n if (anchor === null && current.length === 0) {\n current = [parent.appendChild(document.createTextNode(String(value)))];\n return;\n }\n // FAST PATH: a plain text result that replaces a plain text result. The common\n // reactive child is a string/number thunk (`() => \\`count: ${n.get()}\\``); the\n // wholesale path would remove the old Text node, allocate a new one, and re-insert\n // it on every change. When BOTH the previous and next renders are a single Text\n // node, mutate the existing node's `data` in place instead — no allocation, no\n // remove/insert, and the same DOM node identity is preserved across updates.\n if (current.length === 1 && current[0].nodeType === 3 /* TEXT_NODE */) {\n (current[0] as Text).data = String(value);\n return;\n }\n }\n if (anchor === null) {\n // the first render of nodes: at the end, or right after the text rendered until now\n anchor = document.createComment(\"\");\n if (current.length === 0) {\n parent.appendChild(anchor);\n } else {\n (current[0] as ChildNode).after(anchor);\n }\n }\n const next = toNodes(value);\n for (const node of current) {\n node.parentNode?.removeChild(node);\n }\n const host = anchor.parentNode;\n if (host) {\n for (const node of next) {\n host.insertBefore(node, anchor);\n }\n }\n current = next;\n });\n\n // On teardown, drop the references to the inserted Nodes. The disposed effect's\n // closure still captures `current`; if anything retains the effect after disposal\n // (e.g. a parent owner kept alive longer than the subtree), those Nodes would be\n // pinned via that closure even though they have left the DOM. Clearing the array\n // lets them be GC'd as soon as the enclosing owner tears this insertion point down.\n onCleanup(() => {\n current = [];\n });\n}\n\n// --- keyed lists: For / Index (migration-plan §9-3) --------------------------\n//\n// `insertReactive` rebuilds its whole subtree on every change. For lists that is\n// wasteful (and drops per-row state). `For` / `Index` instead keep a stable DOM row\n// per item and reconcile in place. Each row is built under its OWN `createRoot`, so\n// removing a row disposes exactly that row's effects/resources/listeners — the owner\n// tree (§8 (d)) is what makes this leak-free. The reconcile runs in a single\n// `effect` owned by the enclosing scope; an `onCleanup` disposes surviving rows when\n// that scope (e.g. the component) tears down.\n//\n// CONTRACT: `each` must return a SINGLE Node (one row = one node). Keys (For) must\n// be unique. `For` keys by value identity (=== / explicit `key`) and passes the\n// index as an accessor (it changes on move); `Index` keys by position and passes the\n// item as an accessor (the value at a slot changes, the slot does not).\n\nexport type ListAccessor<T> = ReadSignal<readonly T[]> | (() => readonly T[]);\n/**\n * `For`'s row builder. `item` is the item the row was built for — a plain value. A keyed row is\n * kept while its key is (an immutable update hands it a new object under the same key), so read\n * what changes through `current`, an accessor of the item under the row's key now\n * (`() => current().text`). docs/seam-apps.md, signals-shop.\n */\nexport type ForEach<T> = (item: T, index: () => number, current: () => T) => Node;\nexport type IndexEach<T> = (item: () => T, index: number) => Node;\n\n/**\n * The return type of {@link For} / {@link Index}: a keyed list that owns an anchored\n * region and reconciles rows in place. Exported (D4) so consumers can annotate\n * helpers that build or pass around lists. `mount` is called by `h`/`render` when the\n * list is used as a child; `__wcsList` is the brand `appendChild` checks.\n */\nexport interface ListView {\n readonly __wcsList: true;\n mount(parent: Node): void;\n}\n\nfunction isListView(value: unknown): value is ListView {\n return typeof value === \"object\" && value !== null && (value as ListView).__wcsList === true;\n}\n\nfunction readList<T>(list: ListAccessor<T>): () => readonly T[] {\n return isReadSignal(list) ? () => (list as ReadSignal<readonly T[]>).get() : (list as () => readonly T[]);\n}\n\nexport interface ForOptions<T> {\n /** Derive a unique key per item. Default: the item value itself (identity). */\n key?: (item: T, index: number) => unknown;\n}\n\n// --- LIS-based DOM reorder ---------------------------------------------------\n//\n// `reconcileOrder` brings the live DOM under `host` (the contiguous region ending\n// at `anchor`) into `order` — the desired final node sequence — using the FEWEST\n// `insertBefore` moves, while producing EXACTLY the order a naive full re-place\n// would. The naive approach (walk and insert every out-of-place node) does up to\n// O(n) DOM moves on a full reverse or a head insert; here we instead keep the\n// largest set of reused rows that are ALREADY in the right relative order, and\n// move only the others (Solid's reconcileArrays / udomdiff idea).\n//\n// HOW: `prevOrder` is the node sequence the previous run left in the DOM. For each\n// node in the new `order`, a reused row maps to its index in `prevOrder`; a freshly\n// created row has no previous position. The longest increasing subsequence (LIS)\n// of those previous indices marks the reused rows that need NOT move (their pairwise\n// relative order is already correct). Every other node — fresh ones, and reused\n// ones outside the LIS — is inserted before its already-correct successor, walking\n// back-to-front so the \"successor\" reference is always a settled node or the anchor.\n\n/**\n * Indices into `arr` (with value -1 meaning \"no previous position\") whose values\n * form a longest strictly-increasing subsequence. Entries equal to -1 are treated\n * as never part of the subsequence (a fresh node always moves). Classic\n * patience-sorting LIS in O(n log n); returns the chosen indices in ascending order.\n */\nfunction longestIncreasingSubsequence(arr: number[]): number[] {\n const n = arr.length;\n // `tails[k]` = index (into arr) of the smallest tail of an increasing\n // subsequence of length k+1. `prev[i]` = predecessor index, to rebuild the chain.\n const tails: number[] = [];\n const prev: number[] = new Array(n).fill(-1);\n for (let i = 0; i < n; i++) {\n const value = arr[i];\n if (value < 0) {\n continue; // fresh node: not eligible for the stable subsequence\n }\n // Binary search for the first tail whose value is >= this value, and replace it\n // (or extend the tails when this value beats every tail).\n let lo = 0;\n let hi = tails.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (arr[tails[mid]] < value) {\n lo = mid + 1;\n } else {\n hi = mid;\n }\n }\n if (lo > 0) {\n prev[i] = tails[lo - 1];\n }\n tails[lo] = i;\n }\n // Rebuild the index chain from the longest tail backwards.\n const result: number[] = [];\n let k = tails.length > 0 ? tails[tails.length - 1] : -1;\n while (k >= 0) {\n result.push(k);\n k = prev[k];\n }\n result.reverse();\n return result;\n}\n\nfunction reconcileOrder(\n host: Node,\n anchor: Node,\n order: Node[],\n prevOrder: Node[],\n): void {\n const n = order.length;\n if (n === 0) {\n return; // nothing to place (removals already happened)\n }\n\n // Map each previous node to its previous position, so a node in `order` can look\n // up where it used to be. A node absent from this map is FRESH (created this run,\n // or the first run where prevOrder is empty) and is encoded as -1 — it always moves.\n const prevIndex = new Map<Node, number>();\n for (let i = 0; i < prevOrder.length; i++) {\n prevIndex.set(prevOrder[i], i);\n }\n\n // previous-position sequence aligned to the new order. -1 marks a fresh node.\n const seq: number[] = new Array(n);\n for (let i = 0; i < n; i++) {\n const p = prevIndex.get(order[i]);\n seq[i] = p === undefined ? -1 : p;\n }\n\n // Rows whose relative order is already correct: leave them in place, move the rest.\n const lis = longestIncreasingSubsequence(seq);\n let lisPtr = lis.length - 1;\n\n // Walk back-to-front. `ref` is the node that must follow the one being placed; it\n // starts at the anchor (the region's tail) and becomes each placed node. A node in\n // the LIS is the maximal already-correctly-ordered set, so it is left untouched\n // (only adopted as the new `ref`). Every OTHER node is, by construction, out of\n // position relative to its settled successor and is inserted before `ref` — no\n // \"is it already in place?\" guard is needed (it never is, unlike the old\n // full-walk reconciler which visited correctly-placed nodes too).\n let ref: Node = anchor;\n for (let i = n - 1; i >= 0; i--) {\n const node = order[i];\n if (lisPtr >= 0 && lis[lisPtr] === i) {\n lisPtr--; // stable: do not move\n } else {\n host.insertBefore(node, ref);\n }\n ref = node;\n }\n}\n\n// Dev-only key sanity check (no effect in production — guarded by `isDev()` at the\n// call site so this is never reached when dev is off). Flags the silent-failure key\n// shapes: a nullish key (NaN / null / undefined collide under SameValueZero, so two\n// such items map to one row and a row is silently dropped), and — when no explicit\n// `key` was given — a non-primitive item used as its own identity key (every render\n// gets a fresh object reference, so the row is rebuilt instead of reused, silently\n// dropping per-row state). Warns once per distinct shape (deduped in warnDev).\nfunction checkKeyDev(key: unknown, item: unknown, hasExplicitKey: boolean): void {\n if (key == null || (typeof key === \"number\" && Number.isNaN(key))) {\n warnDev(\n \"NULLISH_KEY\",\n String(key),\n \"For: a key is null/undefined/NaN. Such keys collide under SameValueZero, \" +\n \"so rows silently merge/drop. Provide a stable unique `key`.\",\n { key },\n );\n return;\n }\n if (!hasExplicitKey && (typeof key === \"object\" || typeof key === \"function\")) {\n warnDev(\n \"NON_PRIMITIVE_KEY\",\n typeof key,\n \"For: a non-primitive item is used as its own key (no `key` option given). \" +\n \"Object identity changes across renders, so every row is rebuilt and per-row \" +\n \"state is lost. Pass `{ key: item => item.id }`, and read the item through current().\",\n { item },\n );\n }\n}\n\nexport function For<T>(list: ListAccessor<T>, each: ForEach<T>, options?: ForOptions<T>): ListView {\n const read = readList(list);\n const keyOf = options?.key;\n return {\n __wcsList: true,\n mount(parent: Node): void {\n const anchor = document.createComment(\"for\");\n parent.appendChild(anchor);\n\n interface Row {\n node: Node;\n dispose: () => void;\n /** The row's position, and its signal once `each`'s index accessor was read (made on first read). */\n i: number;\n idx: WriteSignal<number> | null;\n /** The item under the row's key now (`each`'s `current`), and its signal once read. */\n item: T;\n cur: WriteSignal<T> | null;\n }\n let rows = new Map<unknown, Row>();\n // The node order placed by the previous reconcile run. Empty on first run.\n // Used to find which reused rows already sit in increasing relative order so\n // only the rest are moved (LIS reorder, see reconcileOrder).\n let prevOrder: Node[] = [];\n\n // A row's index and current-item signals are made the first time `each`'s accessor is read: a row\n // that never reads them (most rows) owns two signals fewer. Until then the reconcile keeps the plain\n // values on the row, and the signal starts from them.\n const make = (item: T, i: number): Row => {\n const row: Row = { node: null as unknown as Node, dispose: null as unknown as () => void, i, idx: null, item, cur: null };\n row.dispose = createRoot((d) => {\n row.node = each(item, () => (row.idx ??= signal(row.i)).get(), () => (row.cur ??= signal(row.item)).get());\n return d;\n });\n return row;\n };\n\n effect(() => {\n const items = read() ?? [];\n\n // Key-uniqueness PRE-PASS (no side effects): throwing here, before any row is\n // created or moved, keeps a duplicate-key error from leaving half-built rows\n // orphaned (make() runs createRoot) and the DOM mid-reorder. Keys are reused\n // below so keyOf runs once per item.\n const keys: unknown[] = [];\n const seen = new Set<unknown>();\n const dev = isDev();\n for (let i = 0; i < items.length; i++) {\n const k = keyOf ? keyOf(items[i], i) : items[i];\n if (dev) {\n checkKeyDev(k, items[i], keyOf !== undefined);\n }\n if (seen.has(k)) {\n if (dev) {\n // The throw below still halts (production behaviour unchanged); the warn\n // adds the offending key + a pointer to the cause so the silent\n // \"updates stopped\" symptom is diagnosable.\n warnDev(\n \"DUPLICATE_KEY\",\n String(k),\n `For: duplicate key \"${String(k)}\" at index ${i} — keys must be unique. ` +\n \"Rendering throws and the list stops updating until keys are fixed.\",\n { key: k, index: i },\n );\n }\n throw new Error(`For: duplicate key \"${String(k)}\" — keys must be unique.`);\n }\n seen.add(k);\n keys.push(k);\n }\n\n const next = new Map<unknown, Row>();\n const order: Node[] = [];\n\n // Rows freshly created in THIS run (not reused from `rows`). If a later\n // `make()` — i.e. a user `each` — throws mid-loop, the rows already built\n // here are owned by their own detached `createRoot` and are not yet tracked\n // in any surviving map, so they would leak. Dispose them before re-throwing,\n // leaving the old `rows` map untouched (it is recoverable on the next run).\n const fresh: Row[] = [];\n try {\n for (let i = 0; i < items.length; i++) {\n const k = keys[i];\n let row = rows.get(k);\n if (row) {\n if (row.i !== i) {\n row.i = i;\n row.idx?.set(i); // position changed — refresh the index accessor\n }\n row.item = items[i];\n row.cur?.set(items[i]); // the item under the key now (a no-op when it is the same)\n } else {\n row = make(items[i], i);\n fresh.push(row);\n }\n next.set(k, row);\n order.push(row.node);\n }\n } catch (err) {\n for (const row of fresh) {\n row.dispose();\n }\n throw err;\n }\n\n // The LIVE parent (`anchor.parentNode`, not the mount arg) so the region\n // stays correct after being moved (e.g. built inside a Fragment, then\n // appended elsewhere). `host` is null only if the anchor was detached\n // without disposing this scope (a misuse) — then there is nothing to\n // place into. Resolved before the removal phase so the wholesale-removal\n // fast path below can use it.\n const host = anchor.parentNode;\n\n // Dispose rows whose key vanished. `remove()` no-ops if already detached.\n if (rows.size > 0 && next.size === fresh.length) {\n // ZERO-REUSE run: no existing key survives (clear, or a full replacement\n // with disjoint keys), so EVERY current row is removed. When the host\n // contains exactly this list's region — first child is the region's\n // first row, last child is the anchor, and the child count matches\n // rows + anchor — detach them all with a single native\n // `textContent = \"\"` and re-append the anchor, instead of one\n // `remove()` per row (the dominant cost of clearing large lists).\n // Any deviation (foreign sibling, externally detached row, shared\n // host) fails the guard and falls back to the per-row path.\n // Disposal always runs per row; only the DOM detachment is batched.\n if (\n host !== null &&\n host.lastChild === anchor &&\n prevOrder.length > 0 &&\n host.firstChild === prevOrder[0] &&\n host.childNodes.length === rows.size + 1\n ) {\n host.textContent = \"\";\n host.appendChild(anchor);\n for (const row of rows.values()) {\n row.dispose();\n }\n } else {\n for (const row of rows.values()) {\n (row.node as ChildNode).remove();\n row.dispose();\n }\n }\n } else {\n for (const [k, row] of rows) {\n if (!next.has(k)) {\n (row.node as ChildNode).remove();\n row.dispose();\n }\n }\n }\n if (host) {\n reconcileOrder(host, anchor, order, prevOrder);\n }\n\n // Snapshot this run's final order so the NEXT run's reconcile can detect\n // which rows kept their relative position (the LIS basis below). Capturing\n // the array we just placed avoids re-deriving it from the map.\n prevOrder = order;\n rows = next;\n });\n\n onCleanup(() => {\n for (const row of rows.values()) {\n row.dispose();\n }\n rows.clear();\n });\n },\n };\n}\n\nexport function Index<T>(list: ListAccessor<T>, each: IndexEach<T>): ListView {\n const read = readList(list);\n return {\n __wcsList: true,\n mount(parent: Node): void {\n const anchor = document.createComment(\"index\");\n parent.appendChild(anchor);\n\n interface Row {\n node: Node;\n dispose: () => void;\n item: WriteSignal<T>;\n }\n const rows: Row[] = [];\n\n effect(() => {\n const items = read() ?? [];\n // Live parent (see `For`), null only if the anchor was detached undisposed.\n const host = anchor.parentNode;\n\n for (let i = 0; i < items.length; i++) {\n if (i < rows.length) {\n // Slot reused: just push the new value into the row's item signal. The\n // signal's equality guard skips the update when the value is unchanged.\n rows[i].item.set(items[i]);\n } else {\n const item = signal(items[i]);\n let node!: Node;\n const dispose = createRoot((d) => {\n node = each(() => item.get(), i);\n return d;\n });\n rows.push({ node, dispose, item });\n // Positions never move for index keying, so append at the tail (before\n // the anchor) in order. ORDERING CONTRACT (shared with For and the other\n // anchored insertions): the list owns the contiguous region ENDING at its\n // anchor comment. New rows go immediately before the anchor, so the list's\n // own rows always stay correctly ordered and grouped, and static siblings\n // before the anchor (or another list with its own anchor) are never\n // disturbed. Do NOT splice unrelated nodes into the middle of this region.\n host?.insertBefore(node, anchor);\n }\n }\n\n // Trailing slots that no longer exist: dispose and drop.\n if (items.length < rows.length) {\n // WHOLESALE CLEAR (same idea as For's zero-reuse fast path): every slot\n // vanishes and the host holds exactly this list's region (all rows +\n // the anchor), so one native `textContent = \"\"` replaces per-row\n // `remove()`. Guard failures (foreign sibling, detached row, shared\n // host) fall back to the per-row path. Disposal still runs per row.\n if (\n items.length === 0 &&\n host !== null &&\n host.lastChild === anchor &&\n host.firstChild === rows[0].node &&\n host.childNodes.length === rows.length + 1\n ) {\n host.textContent = \"\";\n host.appendChild(anchor);\n for (const row of rows) {\n row.dispose();\n }\n } else {\n for (let i = items.length; i < rows.length; i++) {\n (rows[i].node as ChildNode).remove();\n rows[i].dispose();\n }\n }\n rows.length = items.length;\n }\n });\n\n onCleanup(() => {\n for (const row of rows) {\n row.dispose();\n }\n rows.length = 0;\n });\n },\n };\n}\n\n// --- custom element lifecycle (docs §8 (e)) ---------------------------------\n//\n// The exit point for ownership: a custom element that mounts a signals view under\n// `createRoot` on connect and disposes that root on disconnect. This wires the\n// reactive ownership tree to the real DOM lifecycle — every effect, resource and\n// listener created in `render()` is torn down when the element leaves the DOM, and\n// rebuilt fresh on reconnect. Subclasses only implement `render()`.\n//\n// SCOPE (v1 intentional constraints — drive these reactively, not via this base):\n// - No attribute reactivity. There is no `attributeChangedCallback`/\n// `observedAttributes` wiring: this base does NOT turn HTML attributes into\n// signals. Feed reactive inputs as signals/props from the code that constructs\n// the view (or have a subclass map attributes to signals itself).\n// - Shadow DOM is opt-in and subclass-owned. The default mount point is light DOM\n// (`this`); a subclass that wants encapsulation overrides `getMountPoint()` to\n// return a shadow root it created (e.g. `this.attachShadow(...)` in its\n// constructor). This base never calls attachShadow implicitly.\n// - Mount/unmount only: render() runs once per connect and the whole subtree is\n// disposed on disconnect — there is no partial/incremental re-render hook here\n// (fine-grained updates come from the signals wired inside render()).\n\n// TYPE-ONLY shape of the lifecycle base. `declare abstract class` emits NO runtime\n// code (so it does not reference `HTMLElement` at module-evaluation time — the whole\n// point of the lazy factory below), but it gives the exported `SignalsElement` value\n// and `createSignalsElement()`'s return a precise type that preserves the original\n// contract: `render` is `protected abstract` (a subclass MUST implement it and may\n// only reach it from within), and `getMountPoint` is `protected` (overridable). This\n// is the same surface the previous concrete `abstract class SignalsElement` exposed.\n// (Used only via `typeof` below; the lint rule does not see that as a value use.)\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ndeclare abstract class SignalsElementType extends HTMLElement {\n /** Build the view with `h` + signals. Runs inside an ownership root. */\n protected abstract render(): Node;\n /** Mount target. Override to return a shadow root; default is light DOM. */\n protected getMountPoint(): Node;\n connectedCallback(): void;\n disconnectedCallback(): void;\n}\n\n/**\n * The lifecycle base contract: the abstract constructor type of the `SignalsElement`\n * base. Abstract, so `new SignalsElement()` is rejected (the base has an unimplemented\n * `render`) while `class X extends SignalsElement` is allowed. Returned by\n * {@link createSignalsElement} and the type of the {@link SignalsElement} value.\n */\nexport type SignalsElementClass = typeof SignalsElementType;\n\n// Memoized base class. Built lazily on first access so the `./dom` module can be\n// EVALUATED in a non-DOM environment (SSR pre-pass, a worker without a DOM shim)\n// without a top-level `class … extends HTMLElement` blowing up with\n// `ReferenceError: HTMLElement is not defined`. The class body is only constructed\n// when the consumer actually reaches for the base — at which point a DOM is required\n// and its absence yields a clear, actionable error instead of a raw ReferenceError.\nlet cachedBase: SignalsElementClass | null = null;\n\n/**\n * Build (once, memoized) the `SignalsElement` lifecycle base class. Resolves\n * `HTMLElement` at CALL TIME, so importing `@wcstack/signals/dom` no longer requires\n * a DOM at module-evaluation time — only *calling* this (or subclassing\n * {@link SignalsElement}) does.\n *\n * Contract:\n * - The `.` entry (`@wcstack/signals`) is non-DOM: it evaluates and runs in SSR,\n * Node, and Web Workers with no DOM globals.\n * - The `./dom` entry (`@wcstack/signals/dom`) may now also be *evaluated* without a\n * DOM (so an SSR pre-pass that imports it for the headless re-exports does not\n * crash). The DOM-touching surface — `h`/`render`/`For`/`Index` and this base —\n * still requires DOM globals when actually used.\n *\n * @throws a clear `Error` (not a raw `ReferenceError`) when no `HTMLElement` global is\n * present, naming the offending entry so the failure is self-explanatory.\n */\nexport function createSignalsElement(): SignalsElementClass {\n if (cachedBase !== null) {\n return cachedBase;\n }\n if (typeof HTMLElement === \"undefined\") {\n throw new Error(\n \"@wcstack/signals/dom: SignalsElement requires a DOM (HTMLElement is not defined). \" +\n \"The `./dom` entry's element/render surface is browser-only; in SSR/Node/worker \" +\n \"code import the headless core from `@wcstack/signals` instead, or inject a DOM \" +\n \"(e.g. happy-dom) before constructing custom elements.\",\n );\n }\n\n abstract class SignalsElementBase extends HTMLElement {\n private _dispose: (() => void) | null = null;\n\n /** Build the view with `h` + signals. Runs inside an ownership root. */\n protected abstract render(): Node;\n\n /** Mount target. Override to return a shadow root; default is light DOM. */\n protected getMountPoint(): Node {\n return this;\n }\n\n connectedCallback(): void {\n if (this._dispose !== null) {\n return; // already mounted (defensive against a redundant connect)\n }\n const mount = this.getMountPoint();\n // If render() throws, createRoot disposes any effects it built before the throw,\n // so nothing leaks; _dispose stays null (the element is simply not mounted) and\n // a later disconnectedCallback safely no-ops. The error propagates to the caller.\n this._dispose = createRoot((dispose) => {\n mount.appendChild(this.render());\n return dispose;\n });\n }\n\n disconnectedCallback(): void {\n if (this._dispose === null) {\n return; // not mounted\n }\n this._dispose();\n this._dispose = null;\n const mount = this.getMountPoint();\n while (mount.firstChild) {\n mount.removeChild(mount.firstChild);\n }\n }\n }\n\n cachedBase = SignalsElementBase as unknown as SignalsElementClass;\n return cachedBase;\n}\n\n// `SignalsElement` is the ergonomic name to `extends`. It is a lazily-resolved alias\n// for the class built by `createSignalsElement()`: a Proxy that forwards construct /\n// get / has / getPrototypeOf to the real (memoized) base, building it on first touch.\n// This keeps `class X extends SignalsElement { … }` working exactly as before WHILE\n// deferring the `HTMLElement` reference to subclass-definition time (in a real DOM),\n// instead of `./dom` module-evaluation time (which may be a non-DOM SSR pre-pass).\n//\n// BREAKING note: the value is now a Proxy, not the class object literal. Subclassing,\n// `instanceof`, and static/prototype access all still work; a consumer that relied on\n// `SignalsElement` being a *frozen* concrete class reference (uncommon) should call\n// `createSignalsElement()` to obtain the real class.\n// The Proxy target is a never-called placeholder (every operation is intercepted by a\n// trap below); it only needs to be constructable/callable so `new` / `extends` and the\n// `apply` trap engage. It is intentionally a no-op and never executed.\n/* v8 ignore next */\nconst signalsElementTarget = function (): void {};\nexport const SignalsElement: SignalsElementClass = new Proxy(signalsElementTarget as unknown as SignalsElementClass, {\n construct(_target, args, newTarget): object {\n return Reflect.construct(createSignalsElement(), args, newTarget);\n },\n get(_target, prop, receiver): unknown {\n return Reflect.get(createSignalsElement(), prop, receiver);\n },\n has(_target, prop): boolean {\n return Reflect.has(createSignalsElement(), prop);\n },\n apply(): never {\n throw new TypeError(\"SignalsElement is a class and cannot be invoked without `new`/`extends`.\");\n },\n getPrototypeOf(): object | null {\n return Reflect.getPrototypeOf(createSignalsElement());\n },\n});\n\nfunction toNodes(value: unknown): Node[] {\n const out: Node[] = [];\n const visit = (v: unknown): void => {\n if (v == null || typeof v === \"boolean\") {\n return;\n }\n if (Array.isArray(v)) {\n v.forEach(visit);\n return;\n }\n if (v instanceof Node) {\n out.push(v);\n return;\n }\n out.push(document.createTextNode(String(v)));\n };\n visit(value);\n return out;\n}\n\n// --- mountNode: create + bind + mount a headless wc-bindable node -------------\n//\n// `bindNode` adapts an EXISTING element, which forces its caller to guarantee the\n// custom element class is already registered (the descriptor is read from\n// `el.constructor.wcBindable` at call time — an un-upgraded element has none).\n// `mountNode` closes that gap for the common signals shape where the app OWNS its\n// headless IO nodes: it creates the element AFTER the definition exists (so it is\n// upgraded at construction), binds it, then connects it. The recommended pairing\n// is a side-effect import of the package's `/auto` entry in the same module —\n// module evaluation order then guarantees the definition:\n//\n// import \"@wcstack/fetch/auto\";\n// const fetcher = mountNode(\"wcs-fetch\", { attrs: { url: \"/api/people\" } });\n// fetcher.signals.value.get();\n//\n// The internal order is deliberate: attributes are set BEFORE connect (shells read\n// their config in `connectedCallback`), and the adapter subscribes BEFORE connect,\n// so an event fired from `connectedCallback` is already observed — the missed-event\n// window is structurally zero, not merely closed by bindNode's re-seed. Like\n// `bindNode`, the adapter is NOT auto-registered with a reactive owner; teardown is\n// explicit via `unmount()` — to which `dispose()` is aliased, see MountedNode —\n// (compose with `onCleanup(() => m.unmount())` if the node should die with a\n// scope). See docs/signals-definition-timing.md for the full definition-timing\n// contract (optional packages via dynamic import, the remaining whenDefined /\n// <wcs-defined> territory).\n\nexport interface MountNodeOptions {\n /**\n * Attributes set on the element BEFORE it is connected (declarative pre-connect\n * config, e.g. `{ url: \"/api\", timeout: 5000 }`). HTML boolean-attribute\n * semantics: `true` sets an empty attribute, `false` omits it; other values are\n * stringified.\n */\n attrs?: Record<string, string | number | boolean>;\n /** Parent to append the element to. Default: `document.body`. */\n parent?: Node;\n /**\n * Explicit wc-bindable descriptor forwarded to `bindNode`. When given, the\n * tag-definition check is skipped — the escape hatch for binding a\n * non-custom-element tag, mirroring `bindNode`'s second parameter.\n */\n descriptor?: WcBindableDescriptor;\n}\n\nexport interface MountedNode<S extends NodeShape = DefaultNodeShape> extends BoundNode<S> {\n /** The created element (connected until `unmount()`). */\n readonly el: HTMLElement;\n /**\n * Full teardown: dispose the adapter AND remove the element from the DOM\n * (disconnect stops the shell's IO). Idempotent. On a `MountedNode`,\n * `dispose()` is an alias of this — mountNode owns the element's lifecycle,\n * so the package-wide teardown verb must not leave a connected element with\n * live IO behind (a silent leak for callers habituated to `bindNode`).\n */\n unmount(): void;\n}\n\nexport function mountNode<S extends NodeShape = DefaultNodeShape>(\n tagName: string,\n options: MountNodeOptions = {},\n): MountedNode<S> {\n // Call-time DOM guard (not module-time): `./dom` must evaluate in non-DOM realms\n // (SSR pre-pass / worker) — same contract (and message shape) as `createSignalsElement`.\n if (typeof document === \"undefined\" || typeof customElements === \"undefined\") {\n throw new Error(\n \"@wcstack/signals/dom: mountNode requires a DOM (document/customElements is not defined). \" +\n \"It creates and connects a live element, so it is browser-only; inject a DOM \" +\n \"(e.g. happy-dom) before calling, or keep headless work on `@wcstack/signals`.\",\n );\n }\n const { attrs, parent, descriptor } = options;\n // Custom element names are lowercase; the registry is exact-key while\n // createElement ASCII-lowercases — normalize once so mountNode(el.tagName)\n // (uppercase in HTML documents) hits the same definition the element would.\n const tag = tagName.toLowerCase();\n // Fail loud with the actual cause. Without this, bindNode's generic \"no\n // wc-bindable descriptor\" error hides that the tag simply isn't defined yet.\n if (!descriptor && !customElements.get(tag)) {\n throw new Error(\n `mountNode: \"<${tag}>\" is not defined. Import its defining module first (e.g. a side-effect ` +\n `\\`import \"@wcstack/<pkg>/auto\"\\` in this module — evaluation order then guarantees the definition). ` +\n `For a tag loaded by someone else, await customElements.whenDefined(\"${tag}\") or gate with ` +\n `<wcs-defined> before mounting. Binding a non-custom-element tag requires an explicit \\`descriptor\\`.`,\n );\n }\n\n const el = document.createElement(tag);\n if (attrs) {\n for (const [name, value] of Object.entries(attrs)) {\n if (value === false) {\n continue; // boolean-attribute semantics: false = absent\n }\n el.setAttribute(name, value === true ? \"\" : String(value));\n }\n }\n const bound = bindNode<S>(el, descriptor);\n (parent ?? document.body).appendChild(el);\n const unmount = (): void => {\n bound.dispose();\n el.remove();\n };\n return {\n ...bound,\n el,\n unmount,\n // Override the inherited adapter-only dispose(): on a MountedNode it would be\n // a silent PARTIAL teardown (signals inert, but the created element stays\n // connected with its shell's IO still running). mountNode owns the element,\n // so dispose === unmount.\n dispose: unmount,\n };\n}\n"],"names":["effect"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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,CAAC,UAAU,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;AAC3C,QAAA,MAAM,IAAI,KAAK,CACb,CAAA,aAAA,EAAgB,GAAG,CAAA,wEAAA,CAA0E;YAC3F,CAAA,oGAAA,CAAsG;AACtG,YAAA,CAAA,oEAAA,EAAuE,GAAG,CAAA,gBAAA,CAAkB;AAC5F,YAAA,CAAA,oGAAA,CAAsG,CACzG;IACH;IAEA,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC;IACtC,IAAI,KAAK,EAAE;AACT,QAAA,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACjD,YAAA,IAAI,KAAK,KAAK,KAAK,EAAE;AACnB,gBAAA,SAAS;YACX;YACA,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,GAAG,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5D;IACF;IACA,MAAM,KAAK,GAAG,QAAQ,CAAI,EAAE,EAAE,UAAU,CAAC;IACzC,CAAC,MAAM,IAAI,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,CAAC;IACzC,MAAM,OAAO,GAAG,MAAW;QACzB,KAAK,CAAC,OAAO,EAAE;QACf,EAAE,CAAC,MAAM,EAAE;AACb,IAAA,CAAC;IACD,OAAO;AACL,QAAA,GAAG,KAAK;QACR,EAAE;QACF,OAAO;;;;;AAKP,QAAA,OAAO,EAAE,OAAO;KACjB;AACH;;;;"}
|
package/dist/dom.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h as t,o,b as l,j as a,k as d,w as u,d as p,a as m}from"./core-SWYx7MR8.esm.min.js";export{D as DisposedError,c as computed,e as effect,f as flushSync,i as isDisposedError,n as nodeSource,r as resource,s as selector,g as streamResource}from"./core-SWYx7MR8.esm.min.js";const h=Symbol("signals.Fragment");function y(e){return"object"==typeof e&&null!==e&&"function"==typeof e.get&&"function"==typeof e.peek}function w(e,t,...n){if(e===h){const e=document.createDocumentFragment();return O(e,n),e}if("function"==typeof e){const o=e({...t??{},children:n});return Array.isArray(o)?function(e){const t=document.createDocumentFragment();return O(t,e),t}(o):o}const o=function(e){return v.has(e)?document.createElementNS(b,e):document.createElement(e)}(e);if(t)for(const e in t)S(o,e,t[e]);return O(o,n),o}const b="http://www.w3.org/2000/svg",v=new Set(["svg","g","path","rect","circle","ellipse","line","polyline","polygon","text","tspan","defs","use","symbol","marker","linearGradient","radialGradient","stop","clipPath","mask","pattern","image","foreignObject"]);function E(e,t){return A(t,e),t}const k={for:"htmlFor",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",readonly:"readOnly",maxlength:"maxLength",minlength:"minLength",contenteditable:"contentEditable"},C=new WeakMap;function N(e,t){const n=Object.getPrototypeOf(e);let o=C.get(n);void 0===o&&(o=new Map,C.set(n,o));let s=o.get(t);return void 0===s&&(s=function(e,t){let n=e;for(;null!==n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return"set"in e?"function"==typeof e.set:!1!==e.writable;n=Object.getPrototypeOf(n)}return!1}(e,t),o.set(t,s)),s}function S(e,n,s){const r=32|n.charCodeAt(2);if("o"===n[0]&&"n"===n[1]&&(r>=97&&r<=122||45===r)&&"function"==typeof s){const t=n.charCodeAt(2)<91?n.slice(2).toLowerCase():n.slice(2),r=s;return e.addEventListener(t,r),void o(()=>{e.isConnected&&e.removeEventListener(t,r)})}"function"!=typeof s?y(s)?t(()=>M(e,n,s.get())):M(e,n,s):t(()=>M(e,n,s()))}const x=new WeakMap;function M(e,t,n){if("style"===t)return void function(e,t){if(null==t)return void e.removeAttribute("style");if("string"==typeof t)return void(e.style.cssText=t);e.style.cssText="";const n=e.style,o=t;for(const e in o)e.includes("-")?n.setProperty(e,o[e]):n[e]=o[e]}(e,n);if("class"===t||"className"===t)return void e.setAttribute("class",null==n||!1===n?"":String(n));const o=k[t]??t;N(e,o)?e[o]=null==n?"":n:(x.get(e)?.delete(o),"object"==typeof n&&null!==n&&function(e){return e.localName.includes("-")&&"undefined"!=typeof customElements&&void 0===customElements.get(e.localName)}(e)?function(e,t,n){let o=x.get(e);if(!o){x.set(e,o=new Map);const t=o;customElements.whenDefined(e.localName).then(()=>{x.delete(e),customElements.upgrade(e);for(const[n,o]of t)e[n]=o})}o.set(t,n)}(e,o,n):null!=n&&!1!==n?!0!==n?e.setAttribute(t,String(n)):e.setAttribute(t,""):e.removeAttribute(t))}function O(e,t){for(const n of t)A(e,n)}function A(e,t){var n;if(null!=t&&"boolean"!=typeof t)if(Array.isArray(t))for(const n of t)A(e,n);else"object"!=typeof(n=t)||null===n||!0!==n.__wcsList?t instanceof Node?e.appendChild(t):"function"!=typeof t?y(t)?_(e,()=>t.get()):e.appendChild(document.createTextNode(String(t))):_(e,t):t.mount(e)}function _(e,n){a()&&!d()&&u("UNOWNED_INSERT","","reactive child inserted with no owner — its update effect will never be disposed and may leak. Mount under createRoot / SignalsElement.");let s=null,r=[];t(()=>{const t=n();if("string"==typeof t||"number"==typeof t){if(null===s&&0===r.length)return void(r=[e.appendChild(document.createTextNode(String(t)))]);if(1===r.length&&3===r[0].nodeType)return void(r[0].data=String(t))}null===s&&(s=document.createComment(""),0===r.length?e.appendChild(s):r[0].after(s));const o=function(e){const t=[],n=e=>{null!=e&&"boolean"!=typeof e&&(Array.isArray(e)?e.forEach(n):e instanceof Node?t.push(e):t.push(document.createTextNode(String(e))))};return n(e),t}(t);for(const e of r)e.parentNode?.removeChild(e);const i=s.parentNode;if(i)for(const e of o)i.insertBefore(e,s);r=o}),o(()=>{r=[]})}function j(e){return y(e)?()=>e.get():e}function L(e,t,n,o){const s=n.length;if(0===s)return;const r=new Map;for(let e=0;e<o.length;e++)r.set(o[e],e);const i=new Array(s);for(let e=0;e<s;e++){const t=r.get(n[e]);i[e]=void 0===t?-1:t}const l=function(e){const t=e.length,n=[],o=new Array(t).fill(-1);for(let s=0;s<t;s++){const t=e[s];if(t<0)continue;let r=0,i=n.length;for(;r<i;){const o=r+i>>1;e[n[o]]<t?r=o+1:i=o}r>0&&(o[s]=n[r-1]),n[r]=s}const s=[];let r=n.length>0?n[n.length-1]:-1;for(;r>=0;)s.push(r),r=o[r];return s.reverse(),s}(i);let c=l.length-1,a=t;for(let t=s-1;t>=0;t--){const o=n[t];c>=0&&l[c]===t?c--:e.insertBefore(o,a),a=o}}function P(e,t,n){null==e||"number"==typeof e&&Number.isNaN(e)?u("NULLISH_KEY",String(e),"For: a key is null/undefined/NaN. Such keys collide under SameValueZero, so rows silently merge/drop. Provide a stable unique `key`.",{key:e}):n||"object"!=typeof e&&"function"!=typeof e||u("NON_PRIMITIVE_KEY",typeof e,"For: a non-primitive item is used as its own key (no `key` option given). Object identity changes across renders, so every row is rebuilt and per-row state is lost. Pass `{ key: item => item.id }`, and read the item through current().",{item:t})}function T(e,n,s){const r=j(e),i=s?.key;return{__wcsList:!0,mount(e){const s=document.createComment("for");e.appendChild(s);let l=new Map,c=[];const d=(e,t)=>{const o={node:null,dispose:null,i:t,idx:null,item:e,cur:null};return o.dispose=m(t=>(o.node=n(e,()=>(o.idx??=p(o.i)).get(),()=>(o.cur??=p(o.item)).get()),t)),o};t(()=>{const e=r()??[],t=[],n=new Set,o=a();for(let s=0;s<e.length;s++){const r=i?i(e[s],s):e[s];if(o&&P(r,e[s],void 0!==i),n.has(r))throw o&&u("DUPLICATE_KEY",String(r),`For: duplicate key "${String(r)}" at index ${s} — keys must be unique. Rendering throws and the list stops updating until keys are fixed.`,{key:r,index:s}),new Error(`For: duplicate key "${String(r)}" — keys must be unique.`);n.add(r),t.push(r)}const f=new Map,p=[],m=[];try{for(let n=0;n<e.length;n++){const o=t[n];let s=l.get(o);s?(s.i!==n&&(s.i=n,s.idx?.set(n)),s.item=e[n],s.cur?.set(e[n])):(s=d(e[n],n),m.push(s)),f.set(o,s),p.push(s.node)}}catch(e){for(const e of m)e.dispose();throw e}const h=s.parentNode;if(l.size>0&&f.size===m.length)if(null!==h&&h.lastChild===s&&c.length>0&&h.firstChild===c[0]&&h.childNodes.length===l.size+1){h.textContent="",h.appendChild(s);for(const e of l.values())e.dispose()}else for(const e of l.values())e.node.remove(),e.dispose();else for(const[e,t]of l)f.has(e)||(t.node.remove(),t.dispose());h&&L(h,s,p,c),c=p,l=f}),o(()=>{for(const e of l.values())e.dispose();l.clear()})}}}function R(e,n){const s=j(e);return{__wcsList:!0,mount(e){const r=document.createComment("index");e.appendChild(r);const i=[];t(()=>{const e=s()??[],t=r.parentNode;for(let o=0;o<e.length;o++)if(o<i.length)i[o].item.set(e[o]);else{const s=p(e[o]);let l;const c=m(e=>(l=n(()=>s.get(),o),e));i.push({node:l,dispose:c,item:s}),t?.insertBefore(l,r)}if(e.length<i.length){if(0===e.length&&null!==t&&t.lastChild===r&&t.firstChild===i[0].node&&t.childNodes.length===i.length+1){t.textContent="",t.appendChild(r);for(const e of i)e.dispose()}else for(let t=e.length;t<i.length;t++)i[t].node.remove(),i[t].dispose();i.length=e.length}}),o(()=>{for(const e of i)e.dispose();i.length=0})}}}let F=null;function I(){if(null!==F)return F;if("undefined"==typeof HTMLElement)throw new Error("@wcstack/signals/dom: SignalsElement requires a DOM (HTMLElement is not defined). The `./dom` entry's element/render surface is browser-only; in SSR/Node/worker code import the headless core from `@wcstack/signals` instead, or inject a DOM (e.g. happy-dom) before constructing custom elements.");class e extends HTMLElement{_dispose=null;getMountPoint(){return this}connectedCallback(){if(null!==this._dispose)return;const e=this.getMountPoint();this._dispose=m(t=>(e.appendChild(this.render()),t))}disconnectedCallback(){if(null===this._dispose)return;this._dispose(),this._dispose=null;const e=this.getMountPoint();for(;e.firstChild;)e.removeChild(e.firstChild)}}return F=e,F}const q=new Proxy(function(){},{construct:(e,t,n)=>Reflect.construct(I(),t,n),get:(e,t,n)=>Reflect.get(I(),t,n),has:(e,t)=>Reflect.has(I(),t),apply(){throw new TypeError("SignalsElement is a class and cannot be invoked without `new`/`extends`.")},getPrototypeOf:()=>Reflect.getPrototypeOf(I())});function $(e,t={}){if("undefined"==typeof document||"undefined"==typeof customElements)throw new Error("@wcstack/signals/dom: mountNode requires a DOM (document/customElements is not defined). It creates and connects a live element, so it is browser-only; inject a DOM (e.g. happy-dom) before calling, or keep headless work on `@wcstack/signals`.");const{attrs:n,parent:o,descriptor:s}=t,r=e.toLowerCase();if(!s&&!customElements.get(r))throw new Error(`mountNode: "<${r}>" is not defined. Import its defining module first (e.g. a side-effect \`import "@wcstack/<pkg>/auto"\` in this module — evaluation order then guarantees the definition). For a tag loaded by someone else, await customElements.whenDefined("${r}") or gate with <wcs-defined> before mounting. Binding a non-custom-element tag requires an explicit \`descriptor\`.`);const i=document.createElement(r);if(n)for(const[e,t]of Object.entries(n))!1!==t&&i.setAttribute(e,!0===t?"":String(t));const c=l(i,s);(o??document.body).appendChild(i);const a=()=>{c.dispose(),i.remove()};return{...c,el:i,unmount:a,dispose:a}}export{T as For,h as Fragment,R as Index,q as SignalsElement,l as bindNode,m as createRoot,I as createSignalsElement,w as h,$ as mountNode,o as onCleanup,E as render,p as signal};
|
|
2
2
|
//# sourceMappingURL=dom.esm.min.js.map
|