@pithyjs/core 0.1.0-beta.11 → 0.1.0-beta.13

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.
@@ -1 +1 @@
1
- {"version":3,"file":"applyBindings.js","sourceRoot":"","sources":["../../src/runtime/applyBindings.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,EACV,QAAQ,EACR,UAAU,EACV,eAAe,EACf,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EACX,UAAU,GAiBX,MAAM,YAAY,CAAC;AAsBpB,iFAAiF;AAEjF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,8RAA8R;AAC9R,MAAM,UAAU,eAAe,CAC7B,QAA0B,EAC1B,QAAgB,EAChB,OAAgC,EAChC,oBAAoB,GAAG,IAAI;IAE3B,4EAA4E;IAC5E,4EAA4E;IAC5E,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,CAAC,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAE7E,MAAM,SAAS,GAAmB,EAAE,CAAC;IACrC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QACvB,OAAO,cAAc,CAAC,QAAQ,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;IAE/D,8EAA8E;IAC9E,MAAM,GAAG,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAEnC,oBAAoB;IACpB,MAAM,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrC,MAAM,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Content":["/** @codex\n{\n \"id\": \"pithy.runtime.apply-bindings\",\n \"title\": \"AOT Binding Applicator\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { drainDestroyCallbacks } from './onDestroy';\nimport { clearSSRRenderCrash } from '../compile/ssrCrashes';\nimport { nodeExpando } from '../compile/nodeExpando';\nimport {\n buildPidMap,\n buildCommentMap,\n mergeContexts,\n nearestCtx,\n applyRef,\n applyError,\n applyProjection,\n applyComponent,\n applyBind,\n applyInterpolation,\n applyEvent,\n applyClass,\n applyClasses,\n applyStyle,\n applyBound,\n applyIf,\n applyFor,\n applySwitch,\n applyDefer,\n type Desc,\n type EventDesc,\n type InterpDesc,\n type ClassDesc,\n type ClassesDesc,\n type StyleDesc,\n type BoundDesc,\n type RefDesc,\n type BindDesc,\n type CompDesc,\n type DeferDesc,\n type ErrorDesc,\n type ProjDesc,\n type IfDesc,\n type ForDesc,\n type SwitchDesc,\n} from './bindings';\n\n// Re-export types for external consumers\nexport type {\n Desc,\n EventDesc,\n InterpDesc,\n ClassDesc,\n ClassesDesc,\n StyleDesc,\n BoundDesc,\n RefDesc,\n BindDesc,\n CompDesc,\n DeferDesc,\n ErrorDesc,\n ProjDesc,\n IfDesc,\n ForDesc,\n SwitchDesc,\n};\n\n// ─── Main entry point ─────────────────────────────────────────────────────────\n\n/**\n * Applies pre-extracted binding descriptors to an AOT-generated DOM fragment.\n *\n * This is the Phase 5 runtime binder — the counterpart to the build-time\n * codegen (Phases 1-4). It processes descriptor arrays emitted by\n * generateDomFactory + generateBindings and wires reactive effects,\n * event handlers, component mounts, and structural directive logic.\n *\n * **Binding order** mirrors (but is not identical to) bindTemplateDirectives:\n * 1. Structural: switch → if → for\n * 2. Non-structural: ref → error → projection → component → bind →\n * interpolation → event → class → classes → style → bound attr → defer\n *\n * Differences from JIT bindTemplateDirectives:\n * - AOT has an explicit `style` phase (JIT folds inline styles into bound attrs)\n * - AOT omits the `custom-directive` step (router directives handled at build time)\n *\n * @param fragment - DOM fragment created by the AOT factory function\n * @param bindings - Array of binding descriptors from codegen\n * @param context - Reactive context object with signals, methods, components\n */\n/** @codexApi {\"parent\":\"pithy.runtime.apply-bindings\",\"name\":\"__applyBindings\",\"stability\":\"experimental\",\"signature\":\"(fragment: DocumentFragment, bindings: Desc[], context: Record<string, unknown>, ownsDestroyCallbacks?: boolean) => { el: DocumentFragment; destroy: () => void }\"} */\nexport function __applyBindings(\n fragment: DocumentFragment,\n bindings: Desc[],\n context: Record<string, unknown>,\n ownsDestroyCallbacks = true\n): { el: DocumentFragment; destroy: () => void } {\n // Drain onDestroy() callbacks BEFORE processing bindings — child components\n // instantiated during binding will drain their own callbacks independently.\n const destroyCallbacks = ownsDestroyCallbacks ? drainDestroyCallbacks() : [];\n\n const disposers: (() => void)[] = [];\n if (bindings.length === 0)\n return bindingsResult(fragment, disposers, destroyCallbacks);\n\n // Merge parent component + async (SSR) contexts — AOT factories bypass html()\n const ctx = mergeContexts(context);\n\n // Build lookup maps\n const pidMap = buildPidMap(fragment);\n const commentMap = buildCommentMap(fragment);\n\n // Group descriptors by type for ordered processing\n const byType = new Map<string, Desc[]>();\n for (const d of bindings as Desc[]) {\n const list = byType.get(d.t) ?? [];\n list.push(d);\n byType.set(d.t, list);\n }\n\n try {\n // ─── Phase 1: Structural directives (shape-changing) ─────────────────\n // Order: switch → if → for (matches bindStructuralDirectives)\n\n for (const d of (byType.get('switch') ?? []) as SwitchDesc[]) {\n applySwitch(d, pidMap, ctx, disposers);\n }\n for (const d of (byType.get('if') ?? []) as IfDesc[]) {\n applyIf(d, commentMap, ctx, disposers);\n }\n for (const d of (byType.get('for') ?? []) as ForDesc[]) {\n applyFor(d, commentMap, ctx, disposers);\n }\n\n // ─── Phase 2: Non-structural bindings ────────────────────────────────\n // Order matches bindTemplateDirectives: ref → error → proj → comp →\n // bind → interp → event → class → classes → style → bound → defer\n\n for (const d of (byType.get('ref') ?? []) as RefDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyRef(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('error') ?? []) as ErrorDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyError(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('proj') ?? []) as ProjDesc[]) {\n applyProjection(d, commentMap, ctx, disposers);\n }\n\n // A placeholder in another component's slot content is moved into that\n // component. A runtime-compiled one renders it from its own binder when it\n // mounts the slot; the hook keeps it on this binder, in the context it was\n // written in. An AOT-compiled one mounting its slot late does not call the\n // hook yet (BUG-117).\n const comps = (byType.get('comp') ?? []) as CompDesc[];\n const mounted = new Set<CompDesc>();\n // A hooked tag's forwarded bindings live on its latest root, owned by the\n // disposers of whoever rendered it, and are replayed on every mount.\n type Bind = (el: Element, ds: (() => void)[]) => void;\n const binds = new Map<string, Bind[]>();\n const live = new Map<string, { root: Element; ds: (() => void)[] }>();\n for (const d of comps) {\n const el = pidMap.get(d.pid);\n if (!el) continue;\n const scope = nearestCtx(el, ctx);\n binds.set(d.pid, []);\n // A placeholder that failed stays put, and every enclosing slot's pass\n // finds it again; a re-mount moves it first.\n let failedIn: ParentNode | null = null;\n nodeExpando(el).__pithyAotMount = slotDisposers => {\n mounted.add(d);\n if (failedIn && el.parentNode === failedIn) return [];\n const nodes = applyComponent(d, el, ctx, slotDisposers, pidMap, scope);\n failedIn = nodes ? null : el.parentNode;\n // On failure `pidMap` still holds the previous root.\n const root = nodes && pidMap.get(d.pid);\n if (!nodes || !root) return nodes ?? [];\n const mount = { root, ds: slotDisposers };\n live.set(d.pid, mount);\n // A slot closed before a later binding is queued must not receive it.\n slotDisposers.push(() => {\n if (live.get(d.pid) === mount) live.delete(d.pid);\n });\n for (const bind of binds.get(d.pid) ?? []) bind(root, slotDisposers);\n return nodes;\n };\n }\n const forwarded = (pid: string, bind: Bind) => {\n const stored = binds.get(pid);\n const mount = live.get(pid);\n stored?.push(bind);\n if (mount) bind(mount.root, mount.ds);\n else if (!stored) {\n const el = pidMap.get(pid);\n if (el) bind(el, disposers);\n }\n };\n\n for (const d of comps) {\n if (mounted.has(d)) continue;\n const el = pidMap.get(d.pid);\n // `pidMap` is built once, up front. An activated `@error-boundary`\n // detaches its normal children, so a later sibling's placeholder can\n // still be in the map while no longer being in the tree. Rendering it is\n // pointless — and because it can no longer resolve the boundary that\n // already handled the failure, recording its crash would fail a route\n // whose fallback rendered perfectly well. Mirrors the `scope.contains(el)`\n // guard in `bindComponentTags`.\n //\n // This does not affect a structural branch factory binding a detached\n // subtree: that calls `applyBindings` with the branch's OWN fragment as\n // `fragment`, so its placeholders are inside it and still bind.\n if (el && fragment.contains(el)) {\n applyComponent(d, el, ctx, disposers, pidMap);\n binds.delete(d.pid);\n } else if (el) {\n // Left the tree, so it contributes nothing to the output — and any crash\n // recorded for it on an earlier detached pass is stale. Same reasoning\n // as the `scope.contains(el)` skip in `bindComponentTags`.\n clearSSRRenderCrash(el);\n }\n }\n\n for (const d of (byType.get('bind') ?? []) as BindDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyBind(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('interp') ?? []) as InterpDesc[]) {\n // pid === '' means root-level text node (no parent element with data-pid)\n const el = d.pid === '' ? fragment : pidMap.get(d.pid);\n if (el) applyInterpolation(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('event') ?? []) as EventDesc[]) {\n forwarded(d.pid, (el, ds) => applyEvent(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('class') ?? []) as ClassDesc[]) {\n forwarded(d.pid, (el, ds) => applyClass(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('classes') ?? []) as ClassesDesc[]) {\n forwarded(d.pid, (el, ds) => applyClasses(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('style') ?? []) as StyleDesc[]) {\n forwarded(d.pid, (el, ds) => applyStyle(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('bound') ?? []) as BoundDesc[]) {\n forwarded(d.pid, (el, ds) => applyBound(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('defer') ?? []) as DeferDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyDefer(d, el as HTMLElement, ctx, disposers);\n }\n } catch (err) {\n // Clean up any disposers already registered during partial binding\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore */\n }\n }\n for (let i = destroyCallbacks.length - 1; i >= 0; i--) {\n try {\n destroyCallbacks[i]();\n } catch {\n /* ignore */\n }\n }\n throw err;\n }\n\n return bindingsResult(fragment, disposers, destroyCallbacks);\n}\n\nfunction bindingsResult(\n fragment: DocumentFragment,\n disposers: (() => void)[],\n destroyCallbacks: (() => void)[]\n): { el: DocumentFragment; destroy: () => void } {\n return {\n el: fragment,\n destroy() {\n // Reverse order: child disposers (pushed later) run before parents\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore disposal errors */\n }\n }\n disposers.length = 0;\n // onDestroy callbacks in LIFO order, after template disposers\n for (let i = destroyCallbacks.length - 1; i >= 0; i--) {\n try {\n destroyCallbacks[i]();\n } catch {\n /* ignore disposal errors */\n }\n }\n destroyCallbacks.length = 0;\n },\n };\n}\n"]}
1
+ {"version":3,"file":"applyBindings.js","sourceRoot":"","sources":["../../src/runtime/applyBindings.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,EACV,QAAQ,EACR,UAAU,EACV,eAAe,EACf,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EACX,UAAU,GAiBX,MAAM,YAAY,CAAC;AAsBpB,iFAAiF;AAEjF;;;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AC;AAC/D,CAAC;AAED,SAAS,cAAc,CACrB,QAA0B,EAC1B,SAAyB,EACzB,gBAAgC;IAEhC,OAAO;QACL,EAAE,EAAE,QAAQ;QACZ,OAAO;YACL,mEAAmE;YACnE,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC/C,IAAI,CAAC;oBACH,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjB,CAAC;gBAAC,MAAM,CAAC;oBACP,4BAA4B;gBAC9B,CAAC;YACH,CAAC;YACD,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;YACrB,8DAA8D;YAC9D,KAAK,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC;oBACH,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxB,CAAC;gBAAC,MAAM,CAAC;oBACP,4BAA4B;gBAC9B,CAAC;YACH,CAAC;YACD,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.apply-bindings\",\n \"title\": \"AOT Binding Applicator\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { drainDestroyCallbacks } from './onDestroy';\nimport { clearSSRRenderCrash } from '../compile/ssrCrashes';\nimport { nodeExpando } from '../compile/nodeExpando';\nimport {\n buildPidMap,\n buildCommentMap,\n mergeContexts,\n nearestCtx,\n applyRef,\n applyError,\n applyProjection,\n applyComponent,\n applyBind,\n applyInterpolation,\n applyEvent,\n applyClass,\n applyClasses,\n applyStyle,\n applyBound,\n applyIf,\n applyFor,\n applySwitch,\n applyDefer,\n type Desc,\n type EventDesc,\n type InterpDesc,\n type ClassDesc,\n type ClassesDesc,\n type StyleDesc,\n type BoundDesc,\n type RefDesc,\n type BindDesc,\n type CompDesc,\n type DeferDesc,\n type ErrorDesc,\n type ProjDesc,\n type IfDesc,\n type ForDesc,\n type SwitchDesc,\n} from './bindings';\n\n// Re-export types for external consumers\nexport type {\n Desc,\n EventDesc,\n InterpDesc,\n ClassDesc,\n ClassesDesc,\n StyleDesc,\n BoundDesc,\n RefDesc,\n BindDesc,\n CompDesc,\n DeferDesc,\n ErrorDesc,\n ProjDesc,\n IfDesc,\n ForDesc,\n SwitchDesc,\n};\n\n// ─── Main entry point ─────────────────────────────────────────────────────────\n\n/**\n * Applies pre-extracted binding descriptors to an AOT-generated DOM fragment.\n *\n * This is the Phase 5 runtime binder — the counterpart to the build-time\n * codegen (Phases 1-4). It processes descriptor arrays emitted by\n * generateDomFactory + generateBindings and wires reactive effects,\n * event handlers, component mounts, and structural directive logic.\n *\n * **Binding order** mirrors (but is not identical to) bindTemplateDirectives:\n * 1. Structural: switch → if → for\n * 2. Non-structural: ref → error → projection → component → bind →\n * interpolation → event → class → classes → style → bound attr → defer\n *\n * Differences from JIT bindTemplateDirectives:\n * - AOT has an explicit `style` phase (JIT folds inline styles into bound attrs)\n * - AOT omits the `custom-directive` step (router directives handled at build time)\n *\n * @param fragment - DOM fragment created by the AOT factory function\n * @param bindings - Array of binding descriptors from codegen\n * @param context - Reactive context object with signals, methods, components\n */\n/** @codexApi {\"parent\":\"pithy.runtime.apply-bindings\",\"name\":\"__applyBindings\",\"stability\":\"experimental\",\"signature\":\"(fragment: DocumentFragment, bindings: Desc[], context: Record<string, unknown>, ownsDestroyCallbacks?: boolean) => { el: DocumentFragment; destroy: () => void }\"} */\nexport function __applyBindings(\n fragment: DocumentFragment,\n bindings: Desc[],\n context: Record<string, unknown>,\n ownsDestroyCallbacks = true\n): { el: DocumentFragment; destroy: () => void } {\n // Drain onDestroy() callbacks BEFORE processing bindings — child components\n // instantiated during binding will drain their own callbacks independently.\n const destroyCallbacks = ownsDestroyCallbacks ? drainDestroyCallbacks() : [];\n\n const disposers: (() => void)[] = [];\n if (bindings.length === 0)\n return bindingsResult(fragment, disposers, destroyCallbacks);\n\n // Merge parent component + async (SSR) contexts — AOT factories bypass html()\n const ctx = mergeContexts(context);\n\n // Build lookup maps\n const pidMap = buildPidMap(fragment);\n const commentMap = buildCommentMap(fragment);\n\n // Group descriptors by type for ordered processing\n const byType = new Map<string, Desc[]>();\n for (const d of bindings as Desc[]) {\n const list = byType.get(d.t) ?? [];\n list.push(d);\n byType.set(d.t, list);\n }\n\n try {\n // ─── Phase 1: Structural directives (shape-changing) ─────────────────\n // Order: switch → if → for (matches bindStructuralDirectives)\n\n for (const d of (byType.get('switch') ?? []) as SwitchDesc[]) {\n applySwitch(d, pidMap, ctx, disposers);\n }\n for (const d of (byType.get('if') ?? []) as IfDesc[]) {\n applyIf(d, commentMap, ctx, disposers);\n }\n for (const d of (byType.get('for') ?? []) as ForDesc[]) {\n applyFor(d, commentMap, ctx, disposers);\n }\n\n // ─── Phase 2: Non-structural bindings ────────────────────────────────\n // Order matches bindTemplateDirectives: ref → error → proj → comp →\n // bind → interp → event → class → classes → style → bound → defer\n\n for (const d of (byType.get('ref') ?? []) as RefDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyRef(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('error') ?? []) as ErrorDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyError(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('proj') ?? []) as ProjDesc[]) {\n applyProjection(d, commentMap, ctx, disposers);\n }\n\n // A placeholder that reaches a runtime-compiled component's binder (slot\n // content serialized into a descriptor without `slots`, or a failed\n // render left in place) is rendered through this hook, in the context it\n // was written in.\n const comps = (byType.get('comp') ?? []) as CompDesc[];\n const mounted = new Set<CompDesc>();\n // A hooked tag's forwarded bindings live on its latest root, owned by the\n // disposers of whoever rendered it, and are replayed on every mount.\n type Bind = (el: Element, ds: (() => void)[]) => void;\n const binds = new Map<string, Bind[]>();\n const live = new Map<string, { root: Element; ds: (() => void)[] }>();\n // A placeholder that failed stays put, and every enclosing slot's pass\n // finds it again; a re-mount moves it first. One this pass already\n // rendered is never retried (`true`).\n const failedIn = new Map<CompDesc, ParentNode | null | true>();\n for (const d of comps) {\n const el = pidMap.get(d.pid);\n if (!el) continue;\n const scope = nearestCtx(el, ctx);\n binds.set(d.pid, []);\n nodeExpando(el).__pithyAotMount = slotDisposers => {\n mounted.add(d);\n const failed = failedIn.get(d);\n if (failed === true || (failed && el.parentNode === failed)) return [];\n const nodes = applyComponent(d, el, ctx, slotDisposers, pidMap, scope);\n failedIn.set(d, nodes ? null : el.parentNode);\n // On failure `pidMap` still holds the previous root.\n const root = nodes && pidMap.get(d.pid);\n if (!nodes || !root) return nodes ?? [];\n const mount = { root, ds: slotDisposers };\n live.set(d.pid, mount);\n // A slot closed before a later binding is queued must not receive it.\n slotDisposers.push(() => {\n if (live.get(d.pid) === mount) live.delete(d.pid);\n });\n for (const bind of binds.get(d.pid) ?? []) bind(root, slotDisposers);\n return nodes;\n };\n }\n const forwarded = (pid: string, bind: Bind) => {\n const stored = binds.get(pid);\n const mount = live.get(pid);\n stored?.push(bind);\n if (mount) bind(mount.root, mount.ds);\n else if (!stored) {\n const el = pidMap.get(pid);\n if (el) bind(el, disposers);\n }\n };\n\n for (const d of comps) {\n if (mounted.has(d)) continue;\n const el = pidMap.get(d.pid);\n // `pidMap` is built once, up front. An activated `@error-boundary`\n // detaches its normal children, so a later sibling's placeholder can\n // still be in the map while no longer being in the tree. Rendering it is\n // pointless — and because it can no longer resolve the boundary that\n // already handled the failure, recording its crash would fail a route\n // whose fallback rendered perfectly well. Mirrors the `scope.contains(el)`\n // guard in `bindComponentTags`.\n //\n // This does not affect a structural branch factory binding a detached\n // subtree: that calls `applyBindings` with the branch's OWN fragment as\n // `fragment`, so its placeholders are inside it and still bind.\n if (el && fragment.contains(el)) {\n if (!applyComponent(d, el, ctx, disposers, pidMap))\n failedIn.set(d, true);\n binds.delete(d.pid);\n } else if (el) {\n // Left the tree, so it contributes nothing to the output — and any crash\n // recorded for it on an earlier detached pass is stale. Same reasoning\n // as the `scope.contains(el)` skip in `bindComponentTags`.\n clearSSRRenderCrash(el);\n }\n }\n\n for (const d of (byType.get('bind') ?? []) as BindDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyBind(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('interp') ?? []) as InterpDesc[]) {\n // pid === '' means root-level text node (no parent element with data-pid)\n const el = d.pid === '' ? fragment : pidMap.get(d.pid);\n if (el) applyInterpolation(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('event') ?? []) as EventDesc[]) {\n forwarded(d.pid, (el, ds) => applyEvent(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('class') ?? []) as ClassDesc[]) {\n forwarded(d.pid, (el, ds) => applyClass(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('classes') ?? []) as ClassesDesc[]) {\n forwarded(d.pid, (el, ds) => applyClasses(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('style') ?? []) as StyleDesc[]) {\n forwarded(d.pid, (el, ds) => applyStyle(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('bound') ?? []) as BoundDesc[]) {\n forwarded(d.pid, (el, ds) => applyBound(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('defer') ?? []) as DeferDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyDefer(d, el as HTMLElement, ctx, disposers);\n }\n } catch (err) {\n // Clean up any disposers already registered during partial binding\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore */\n }\n }\n for (let i = destroyCallbacks.length - 1; i >= 0; i--) {\n try {\n destroyCallbacks[i]();\n } catch {\n /* ignore */\n }\n }\n throw err;\n }\n\n return bindingsResult(fragment, disposers, destroyCallbacks);\n}\n\nfunction bindingsResult(\n fragment: DocumentFragment,\n disposers: (() => void)[],\n destroyCallbacks: (() => void)[]\n): { el: DocumentFragment; destroy: () => void } {\n return {\n el: fragment,\n destroy() {\n // Reverse order: child disposers (pushed later) run before parents\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore disposal errors */\n }\n }\n disposers.length = 0;\n // onDestroy callbacks in LIFO order, after template disposers\n for (let i = destroyCallbacks.length - 1; i >= 0; i--) {\n try {\n destroyCallbacks[i]();\n } catch {\n /* ignore disposal errors */\n }\n }\n destroyCallbacks.length = 0;\n },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"applyComponent.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/applyComponent.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAgB,MAAM,SAAS,CAAC;AA6DtE,wBAAgB,cAAc,CAC5B,CAAC,EAAE,QAAQ,EACX,EAAE,EAAE,OAAO,EACX,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,EACzB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,KAAK,CAAC,EAAE,cAAc,GACrB,IAAI,EAAE,GAAG,SAAS,CA+QpB"}
1
+ {"version":3,"file":"applyComponent.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/applyComponent.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAgB,MAAM,SAAS,CAAC;AAuItE,wBAAgB,cAAc,CAC5B,CAAC,EAAE,QAAQ,EACX,EAAE,EAAE,OAAO,EACX,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,EACzB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,KAAK,CAAC,EAAE,cAAc,GACrB,IAAI,EAAE,GAAG,SAAS,CA+OpB"}
@@ -1,5 +1,5 @@
1
1
  import { compileExpression } from '../../compile/compileExpression.js';
2
- import { boundaryForElement, runWithBoundary, } from '../../compile/binds/bindErrorBoundary.js';
2
+ import { boundaryForElement, runWithBoundary, withSlotBoundary, slotContentHidden, } from '../../compile/binds/bindErrorBoundary.js';
3
3
  import { collectForwardedAttrs, applyForwardedAttrs, } from '../../compile/binds/forwardedAttrs.js';
4
4
  import { nativeTags } from '@pithyjs/compiler';
5
5
  import { createRoot, untrack } from '@pithyjs/signals';
@@ -11,6 +11,7 @@ import { isRenderableComponentEl } from '../../compile/componentResult.js';
11
11
  import { clearSSRRenderCrash, reportComponentFailure, } from '../../compile/ssrCrashes.js';
12
12
  import { isolateDestroyCallbacks } from '../onDestroy.js';
13
13
  import { parsePropNames } from '../../compile/binds/propNames.js';
14
+ import { nodeExpando } from '../../compile/nodeExpando.js';
14
15
  /** Map kebab-case or lowered DOM attr name to expected camelCase prop name. */
15
16
  function normalizePropName(authored, expectedProps) {
16
17
  if (expectedProps.includes(authored))
@@ -48,6 +49,68 @@ function extractExpectedPropNames(fn) {
48
49
  return [];
49
50
  }
50
51
  }
52
+ /** Runs a slot factory against the parent's context, owned by the mount's disposers. */
53
+ function renderSlot(factory, ctx, disposers, anchor, host) {
54
+ const g = pithyGlobals();
55
+ const rendering = g.__pithyComponentContext;
56
+ // Otherwise mergeContexts would read the child's names into the slot's context.
57
+ g.__pithyComponentContext = undefined;
58
+ try {
59
+ const { el, destroy } = withSlotBoundary(anchor, host, () => isolateDestroyCallbacks(() => factory(ctx)));
60
+ disposers.push(destroy);
61
+ // Bound already: a runtime-compiled child's binders must not bind it again.
62
+ el.childNodes.forEach(node => (nodeExpando(node).__pithyComponentDom = true));
63
+ return el;
64
+ }
65
+ finally {
66
+ g.__pithyComponentContext = rendering;
67
+ }
68
+ }
69
+ /**
70
+ * Slot content serialized into the placeholder, from a descriptor without
71
+ * `slots`. The nodes are moved, so each slot can be mounted only once.
72
+ */
73
+ function slotsFromChildren(el, slotMap) {
74
+ const slotGroups = new Map();
75
+ for (const child of Array.from(el.childNodes)) {
76
+ const slotName = child.nodeType === Node.ELEMENT_NODE
77
+ ? child.getAttribute('slot') || ''
78
+ : '';
79
+ const group = slotGroups.get(slotName);
80
+ if (group)
81
+ group.push(child);
82
+ else
83
+ slotGroups.set(slotName, [child]);
84
+ }
85
+ const defaultSlot = slotGroups.get('');
86
+ if (defaultSlot) {
87
+ const content = trimBlankEdges(defaultSlot, node => node.nodeType === Node.TEXT_NODE ? node.textContent : null);
88
+ if (content.length)
89
+ slotGroups.set('', content);
90
+ else
91
+ slotGroups.delete('');
92
+ }
93
+ // `renderChildren()` and `<slot>` must share one fragment, or the later
94
+ // consumer steals the nodes out of the first.
95
+ let injection;
96
+ for (const [slotName, nodes] of slotGroups) {
97
+ if (slotName === '') {
98
+ injection = document.createDocumentFragment();
99
+ for (const node of nodes)
100
+ injection.appendChild(node);
101
+ const shared = injection;
102
+ slotMap.set('', () => shared);
103
+ continue;
104
+ }
105
+ slotMap.set(slotName, () => {
106
+ const frag = document.createDocumentFragment();
107
+ for (const node of nodes)
108
+ frag.appendChild(node);
109
+ return frag;
110
+ });
111
+ }
112
+ return injection;
113
+ }
51
114
  export function applyComponent(d, el, ctx, disposers, pidMap, scope) {
52
115
  // Skip native HTML elements — prevents <div> matching a `div` in context.
53
116
  // Only apply when the authored tag is already lowercase; PascalCase tags like
@@ -81,6 +144,9 @@ export function applyComponent(d, el, ctx, disposers, pidMap, scope) {
81
144
  }
82
145
  if (typeof candidate !== 'function')
83
146
  return;
147
+ // Hidden like a sibling an activated boundary detached: never rendered.
148
+ if (slotContentHidden(el))
149
+ return;
84
150
  const componentFn = candidate;
85
151
  const localCtx = scope ?? nearestCtx(el, ctx);
86
152
  // Extract expected props for case-insensitive normalization
@@ -97,50 +163,14 @@ export function applyComponent(d, el, ctx, disposers, pidMap, scope) {
97
163
  // Leave undefined — child uses defaults
98
164
  }
99
165
  }
100
- // Collect slot content from el's children — move original nodes instead
101
- // of cloning to preserve any expandos (__pithyCtx) and event listeners.
102
- // The placeholder el is about to be replaced, so its children are orphaned anyway.
103
166
  const slotMap = new Map();
104
- const children = Array.from(el.childNodes);
105
- const slotGroups = new Map();
106
- for (const child of children) {
107
- const slotName = child.nodeType === Node.ELEMENT_NODE
108
- ? child.getAttribute('slot') || ''
109
- : '';
110
- if (!slotGroups.has(slotName))
111
- slotGroups.set(slotName, []);
112
- slotGroups.get(slotName).push(child);
113
- }
114
- const defaultSlot = slotGroups.get('');
115
- if (defaultSlot) {
116
- const content = trimBlankEdges(defaultSlot, node => node.nodeType === Node.TEXT_NODE ? node.textContent : null);
117
- if (content.length)
118
- slotGroups.set('', content);
119
- else
120
- slotGroups.delete('');
121
- }
122
- // AOT has no runtime AST, so default-slot content reaches the component two
123
- // ways: `renderChildren()` reads the injection fragment off the global, and
124
- // `<slot>` reads it through the slot map. Both must reference the SAME
125
- // fragment — a DOM node lives in one place, so two fragments would let the
126
- // later consumer steal the nodes out of the first.
127
167
  let injection;
128
- for (const [slotName, nodes] of slotGroups) {
129
- if (slotName === '') {
130
- injection = document.createDocumentFragment();
131
- for (const node of nodes)
132
- injection.appendChild(node);
133
- const shared = injection;
134
- slotMap.set('', () => shared);
135
- continue;
136
- }
137
- slotMap.set(slotName, () => {
138
- const frag = document.createDocumentFragment();
139
- for (const node of nodes) {
140
- frag.appendChild(node);
141
- }
142
- return frag;
143
- });
168
+ if (d.slots) {
169
+ for (const [name, factory] of Object.entries(d.slots))
170
+ slotMap.set(name, (ds = disposers, at) => renderSlot(factory, localCtx, ds, at, el));
171
+ }
172
+ else {
173
+ injection = slotsFromChildren(el, slotMap);
144
174
  }
145
175
  let invoking = true;
146
176
  const childrenFactory = d.children;
@@ -1 +1 @@
1
- {"version":3,"file":"applyComponent.js","sourceRoot":"","sources":["../../../src/runtime/bindings/applyComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EACL,kBAAkB,EAClB,eAAe,GAChB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EACL,qBAA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E,CAAC,CAAC,GAAG,CAAC,CAAC;IAC3D,CAAC;IAED,yEAAyE;IACzE,0EAA0E;IAC1E,oEAAoE;IACpE,uDAAuD;IACvD,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAClC,CAAC;SAAM,CAAC;QACN,IACE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG;YACpB,CAAC,cAAc;gBACb,cAAc,CAAC,MAAM,GAAG,CAAC;gBACzB,CAAC,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAC/C,CAAC;YACD,OAAO,CAAC,IAAI,CACV,UAAU,CAAC,CAAC,GAAG,qGAAqG,CACrH,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,IAAI,YAAY;QAAE,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC/C,IAAI,OAAO,OAAO,KAAK,UAAU;QAAE,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3D,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACtC,CAAC","sourcesContent":["import { compileExpression } from '../../compile/compileExpression';\nimport {\n boundaryForElement,\n runWithBoundary,\n} from '../../compile/binds/bindErrorBoundary';\nimport type { SlotMap } from '../../compile/contentProjection';\nimport {\n collectForwardedAttrs,\n applyForwardedAttrs,\n} from '../../compile/binds/forwardedAttrs';\nimport { nativeTags } from '@pithyjs/compiler';\nimport { createRoot, untrack } from '@pithyjs/signals';\nimport type { CompDesc, BindingContext, ChildFactory } from './types';\nimport { nearestCtx } from './helpers';\nimport { trimBlankEdges } from '../../compile/trimBlankEdges';\nimport { pithyGlobals } from '../../types/globals';\nimport { isSSRMode } from '../../compile/ssrMode';\nimport { isRenderableComponentEl } from '../../compile/componentResult';\nimport {\n clearSSRRenderCrash,\n reportComponentFailure,\n} from '../../compile/ssrCrashes';\nimport { isolateDestroyCallbacks } from '../onDestroy';\nimport { parsePropNames } from '../../compile/binds/propNames';\n\ninterface ComponentResult {\n /** Any DOM node — see the `Component` type for why this is not narrower. */\n el: Node;\n destroy?: () => void;\n}\ntype ComponentFn = (props: Record<string, unknown>) => ComponentResult;\n\n/** Map kebab-case or lowered DOM attr name to expected camelCase prop name. */\nfunction normalizePropName(authored: string, expectedProps: string[]): string {\n if (expectedProps.includes(authored)) return authored;\n const lower = authored.toLowerCase();\n const matches = expectedProps.filter(p => p.toLowerCase() === lower);\n return matches.length === 1 ? matches[0] : authored;\n}\n\n/** Cache for extractExpectedPropNames to avoid re-parsing the same function. */\nconst propNamesCache = new WeakMap<ComponentFn, string[]>();\n\n/**\n * Extract destructured prop names from component function signature.\n * NOTE: Uses fn.toString() which may return mangled names under aggressive\n * minification (Terser). In that case, prop name normalization becomes a\n * no-op and props are passed as-is (kebab/lowered). This is acceptable\n * because Vite's default esbuild minifier preserves parameter names.\n */\nfunction extractExpectedPropNames(fn: ComponentFn): string[] {\n const cached = propNamesCache.get(fn);\n if (cached) return cached;\n try {\n const parsed = parsePropNames(fn.toString());\n const names = parsed.fromParam ? parsed.names : [];\n // Detect likely minification: single-char names suggest mangled output\n if (\n import.meta.env?.DEV &&\n names.length > 0 &&\n names.every(n => n.length === 1)\n ) {\n console.warn(\n `[AOT] extractExpectedPropNames: detected single-char names (${names.join(',')}) — prop normalization may not work under minification`\n );\n }\n propNamesCache.set(fn, names);\n return names;\n } catch {\n return [];\n }\n}\n\nexport function applyComponent(\n d: CompDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[],\n pidMap: Map<string, Element>,\n scope?: BindingContext\n): Node[] | undefined {\n // Skip native HTML elements — prevents <div> matching a `div` in context.\n // Only apply when the authored tag is already lowercase; PascalCase tags like\n // <Button> are valid components even though \"button\" is a native tag.\n const tagLower = d.tag.toLowerCase();\n if (d.tag === tagLower && nativeTags.has(tagLower)) return;\n\n // Exact case first: the context holds the template's own locals alongside its\n // components, so a prop named `icon` sits next to the `Icon` component and\n // collides case-insensitively. The JIT path lowercases into a Map, where the\n // components — appended last — overwrite the locals; matching that ordering is\n // why `<Icon>` resolves in dev, and breaking on the first match is why it did\n // not in a build. Falling back last-wins keeps the two paths agreeing.\n let candidate: unknown = Object.prototype.hasOwnProperty.call(ctx, d.tag)\n ? ctx[d.tag]\n : undefined;\n if (candidate === undefined) {\n for (const key of Object.keys(ctx)) {\n if (key.toLowerCase() === tagLower) candidate = ctx[key];\n }\n }\n if (!candidate) return;\n\n // Support default exports\n if (\n candidate &&\n typeof candidate === 'object' &&\n 'default' in candidate &&\n typeof candidate.default === 'function'\n ) {\n candidate = candidate.default;\n }\n if (typeof candidate !== 'function') return;\n\n const componentFn = candidate as ComponentFn;\n const localCtx = scope ?? nearestCtx(el, ctx);\n\n // Extract expected props for case-insensitive normalization\n const expectedProps = extractExpectedPropNames(componentFn);\n\n // Evaluate prop expressions with prop name normalization\n const props: Record<string, unknown> = {};\n for (const [rawName, expr] of Object.entries(d.props)) {\n const propName = normalizePropName(rawName, expectedProps);\n try {\n const fn = compileExpression(expr, localCtx);\n props[propName] = untrack(fn);\n } catch {\n // Leave undefined — child uses defaults\n }\n }\n\n // Collect slot content from el's children — move original nodes instead\n // of cloning to preserve any expandos (__pithyCtx) and event listeners.\n // The placeholder el is about to be replaced, so its children are orphaned anyway.\n const slotMap: SlotMap = new Map();\n const children = Array.from(el.childNodes);\n const slotGroups = new Map<string, Node[]>();\n for (const child of children) {\n const slotName =\n child.nodeType === Node.ELEMENT_NODE\n ? (child as Element).getAttribute('slot') || ''\n : '';\n if (!slotGroups.has(slotName)) slotGroups.set(slotName, []);\n slotGroups.get(slotName)!.push(child);\n }\n const defaultSlot = slotGroups.get('');\n if (defaultSlot) {\n const content = trimBlankEdges(defaultSlot, node =>\n node.nodeType === Node.TEXT_NODE ? node.textContent : null\n );\n if (content.length) slotGroups.set('', content);\n else slotGroups.delete('');\n }\n // AOT has no runtime AST, so default-slot content reaches the component two\n // ways: `renderChildren()` reads the injection fragment off the global, and\n // `<slot>` reads it through the slot map. Both must reference the SAME\n // fragment — a DOM node lives in one place, so two fragments would let the\n // later consumer steal the nodes out of the first.\n let injection: DocumentFragment | undefined;\n for (const [slotName, nodes] of slotGroups) {\n if (slotName === '') {\n injection = document.createDocumentFragment();\n for (const node of nodes) injection.appendChild(node);\n const shared = injection;\n slotMap.set('', () => shared);\n continue;\n }\n slotMap.set(slotName, () => {\n const frag = document.createDocumentFragment();\n for (const node of nodes) {\n frag.appendChild(node);\n }\n return frag;\n });\n }\n\n let invoking = true;\n const childrenFactory = d.children;\n const childFactory: ChildFactory | undefined = childrenFactory\n ? (ctx, wrap) =>\n invoking\n ? childrenFactory(ctx, wrap)\n : isolateDestroyCallbacks(() => childrenFactory(ctx, wrap))\n : undefined;\n\n const componentContext = {\n ...localCtx,\n __slotMap: slotMap,\n __childAstNodes: undefined,\n __childFactory: childFactory,\n };\n\n // Find nearest error boundary\n const boundaryEl = el.closest('[data-error]') as Element | null;\n const boundary = boundaryForElement(boundaryEl);\n\n let out: ComponentResult | undefined;\n let disposeSetup: (() => void) | undefined;\n try {\n out = runWithBoundary(boundary, () => {\n const g = pithyGlobals();\n const originalContext = g.__pithyComponentContext;\n const wasRendering = g.__pithyRenderingComponent;\n const prevInjection = g.__pithyProjectedChildren;\n g.__pithyComponentContext = componentContext;\n g.__pithyRenderingComponent = true;\n g.__pithyProjectedChildren = injection;\n try {\n return createRoot(disposeRoot => {\n disposeSetup = disposeRoot;\n return componentFn(props);\n });\n } finally {\n g.__pithyComponentContext = originalContext;\n g.__pithyRenderingComponent = wasRendering;\n g.__pithyProjectedChildren = prevInjection;\n invoking = false;\n }\n });\n } catch (err) {\n if (boundary) {\n const error = err instanceof Error ? err : new Error(String(err));\n // See `setBoundaryError`: an already-active boundary with no free ancestor\n // drops the error rather than taking it, which is the normal case for a\n // component rendering inside that boundary's `@fallback`.\n reportComponentFailure(el, d.tag, error, boundary);\n return;\n }\n\n // No boundary in scope *yet*. Degrade in both modes — an AOT branch\n // factory renders detached, so `closest()` here cannot see a boundary the\n // element will sit under once the branch is inserted, and throwing would\n // only be swallowed by the structural handler's own catch\n // (`applyStructural.ts`) anyway.\n //\n // A static/server render records the crash instead: dropping the component\n // silently shipped HTML with <${d.tag}> left raw while `pithy-ssg` counted\n // the route as rendered and exited 0 (BUG-018). Anything still recorded\n // when the render finishes fails the route.\n //\n // Note this path cannot reach a boundary at all when the element is inside\n // a detached structural branch: `el.closest('[data-error]')` above found\n // nothing, and no later pass re-binds it, so the boundary never receives\n // the error even though the nodes are inserted underneath it. That is\n // BUG-023; recording is what stops it from shipping silently.\n reportComponentFailure(\n el,\n d.tag,\n err instanceof Error ? err : new Error(String(err)),\n null\n );\n\n console.error(`[AOT] Component <${d.tag}> crashed:`, err);\n return;\n }\n\n if (\n !out ||\n typeof out !== 'object' ||\n !('el' in out) ||\n !isRenderableComponentEl(out.el, el)\n ) {\n // Not a throw, but the same outcome: the raw <${d.tag}> is left in place\n // and the subtree never renders, which under SSR is content silently\n // missing from the emitted HTML. Recorded exactly like a crash (BUG-018).\n // Same funnel as a throw — see `bindComponentTags`. Recording without\n // offering it to the boundary left an AOT component under `@error-boundary`\n // failing its route with the boundary signal unset.\n reportComponentFailure(\n el,\n d.tag,\n new Error(\n `Invalid render result from <${d.tag}>; expected { el, destroy }`\n ),\n boundary\n );\n disposeSetup?.();\n return;\n }\n\n const { el: renderedEl, destroy } = out;\n\n // Capture rendered root element before fragment is consumed by replaceWith\n const forwardedClass = el.getAttribute('class');\n const forwardedAttrs = collectForwardedAttrs(el);\n const renderedRoot: HTMLElement | null =\n renderedEl instanceof DocumentFragment\n ? (renderedEl.firstElementChild as HTMLElement | null)\n : renderedEl instanceof HTMLElement\n ? renderedEl\n : null;\n\n const nodes =\n renderedEl instanceof DocumentFragment\n ? Array.from(renderedEl.childNodes)\n : [renderedEl];\n let replaced = true;\n try {\n el.replaceWith(...nodes);\n } catch (err) {\n // The raw <${d.tag}> is left exactly where a crash would have left it, so\n // this is the same content loss and is recorded the same way.\n replaced = false;\n reportComponentFailure(\n el,\n d.tag,\n err instanceof Error ? err : new Error(String(err)),\n boundary\n );\n console.error(`[AOT] Failed to replace <${d.tag}>:`, err);\n }\n\n // Retracted only here, and in the boundary catch above. This is the point at\n // which the component is known to have produced a usable node AND to have\n // reached the document.\n if (isSSRMode() && replaced) clearSSRRenderCrash(el);\n\n if (forwardedClass && renderedRoot) {\n for (const cls of forwardedClass.split(/\\s+/)) {\n if (cls) renderedRoot.classList.add(cls);\n }\n }\n\n if (forwardedAttrs.length > 0 && renderedRoot) {\n applyForwardedAttrs(renderedRoot, forwardedAttrs, d.tag);\n }\n\n // Re-target the component pid to the rendered root so subsequent binding\n // passes (event, bound, class, style) apply to the component's actual DOM\n // element. This matches the JIT path where data-on-* attributes are\n // forwarded from the placeholder to the rendered root.\n if (renderedRoot) {\n pidMap.set(d.pid, renderedRoot);\n } else {\n if (\n import.meta.env?.DEV &&\n (forwardedClass ||\n forwardedAttrs.length > 0 ||\n (d.props && Object.keys(d.props).length > 0))\n ) {\n console.warn(\n `[AOT] <${d.tag}> has forwarded attributes but returns a fragment with no single root element — forwarding skipped.`\n );\n }\n pidMap.delete(d.pid);\n }\n\n if (disposeSetup) disposers.push(disposeSetup);\n if (typeof destroy === 'function') disposers.push(destroy);\n return replaced ? nodes : undefined;\n}\n"]}
1
+ {"version":3,"file":"applyComponent.js","sourceRoot":"","sources":["../../../src/runtime/bindings/applyComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAC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EAAE,CAAC;QAC9C,mBAAmB,CAAC,YAAY,EAAE,cAAc,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;IAC3D,CAAC;IAED,yEAAyE;IACzE,0EAA0E;IAC1E,oEAAoE;IACpE,uDAAuD;IACvD,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAClC,CAAC;SAAM,CAAC;QACN,IACE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG;YACpB,CAAC,cAAc;gBACb,cAAc,CAAC,MAAM,GAAG,CAAC;gBACzB,CAAC,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAC/C,CAAC;YACD,OAAO,CAAC,IAAI,CACV,UAAU,CAAC,CAAC,GAAG,qGAAqG,CACrH,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,IAAI,YAAY;QAAE,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC/C,IAAI,OAAO,OAAO,KAAK,UAAU;QAAE,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3D,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACtC,CAAC","sourcesContent":["import { compileExpression } from '../../compile/compileExpression';\nimport {\n boundaryForElement,\n runWithBoundary,\n withSlotBoundary,\n slotContentHidden,\n} from '../../compile/binds/bindErrorBoundary';\nimport type { SlotMap } from '../../compile/contentProjection';\nimport {\n collectForwardedAttrs,\n applyForwardedAttrs,\n} from '../../compile/binds/forwardedAttrs';\nimport { nativeTags } from '@pithyjs/compiler';\nimport { createRoot, untrack } from '@pithyjs/signals';\nimport type { CompDesc, BindingContext, ChildFactory } from './types';\nimport { nearestCtx } from './helpers';\nimport { trimBlankEdges } from '../../compile/trimBlankEdges';\nimport { pithyGlobals } from '../../types/globals';\nimport { isSSRMode } from '../../compile/ssrMode';\nimport { isRenderableComponentEl } from '../../compile/componentResult';\nimport {\n clearSSRRenderCrash,\n reportComponentFailure,\n} from '../../compile/ssrCrashes';\nimport { isolateDestroyCallbacks } from '../onDestroy';\nimport { parsePropNames } from '../../compile/binds/propNames';\nimport { nodeExpando } from '../../compile/nodeExpando';\n\ninterface ComponentResult {\n /** Any DOM node — see the `Component` type for why this is not narrower. */\n el: Node;\n destroy?: () => void;\n}\ntype ComponentFn = (props: Record<string, unknown>) => ComponentResult;\n\n/** Map kebab-case or lowered DOM attr name to expected camelCase prop name. */\nfunction normalizePropName(authored: string, expectedProps: string[]): string {\n if (expectedProps.includes(authored)) return authored;\n const lower = authored.toLowerCase();\n const matches = expectedProps.filter(p => p.toLowerCase() === lower);\n return matches.length === 1 ? matches[0] : authored;\n}\n\n/** Cache for extractExpectedPropNames to avoid re-parsing the same function. */\nconst propNamesCache = new WeakMap<ComponentFn, string[]>();\n\n/**\n * Extract destructured prop names from component function signature.\n * NOTE: Uses fn.toString() which may return mangled names under aggressive\n * minification (Terser). In that case, prop name normalization becomes a\n * no-op and props are passed as-is (kebab/lowered). This is acceptable\n * because Vite's default esbuild minifier preserves parameter names.\n */\nfunction extractExpectedPropNames(fn: ComponentFn): string[] {\n const cached = propNamesCache.get(fn);\n if (cached) return cached;\n try {\n const parsed = parsePropNames(fn.toString());\n const names = parsed.fromParam ? parsed.names : [];\n // Detect likely minification: single-char names suggest mangled output\n if (\n import.meta.env?.DEV &&\n names.length > 0 &&\n names.every(n => n.length === 1)\n ) {\n console.warn(\n `[AOT] extractExpectedPropNames: detected single-char names (${names.join(',')}) — prop normalization may not work under minification`\n );\n }\n propNamesCache.set(fn, names);\n return names;\n } catch {\n return [];\n }\n}\n\n/** Runs a slot factory against the parent's context, owned by the mount's disposers. */\nfunction renderSlot(\n factory: ChildFactory,\n ctx: BindingContext,\n disposers: (() => void)[],\n anchor?: Node,\n host?: Element\n): DocumentFragment {\n const g = pithyGlobals();\n const rendering = g.__pithyComponentContext;\n // Otherwise mergeContexts would read the child's names into the slot's context.\n g.__pithyComponentContext = undefined;\n try {\n const { el, destroy } = withSlotBoundary(anchor, host, () =>\n isolateDestroyCallbacks(() => factory(ctx))\n );\n disposers.push(destroy);\n // Bound already: a runtime-compiled child's binders must not bind it again.\n el.childNodes.forEach(\n node => (nodeExpando(node).__pithyComponentDom = true)\n );\n return el;\n } finally {\n g.__pithyComponentContext = rendering;\n }\n}\n\n/**\n * Slot content serialized into the placeholder, from a descriptor without\n * `slots`. The nodes are moved, so each slot can be mounted only once.\n */\nfunction slotsFromChildren(\n el: Element,\n slotMap: SlotMap\n): DocumentFragment | undefined {\n const slotGroups = new Map<string, Node[]>();\n for (const child of Array.from(el.childNodes)) {\n const slotName =\n child.nodeType === Node.ELEMENT_NODE\n ? (child as Element).getAttribute('slot') || ''\n : '';\n const group = slotGroups.get(slotName);\n if (group) group.push(child);\n else slotGroups.set(slotName, [child]);\n }\n const defaultSlot = slotGroups.get('');\n if (defaultSlot) {\n const content = trimBlankEdges(defaultSlot, node =>\n node.nodeType === Node.TEXT_NODE ? node.textContent : null\n );\n if (content.length) slotGroups.set('', content);\n else slotGroups.delete('');\n }\n // `renderChildren()` and `<slot>` must share one fragment, or the later\n // consumer steals the nodes out of the first.\n let injection: DocumentFragment | undefined;\n for (const [slotName, nodes] of slotGroups) {\n if (slotName === '') {\n injection = document.createDocumentFragment();\n for (const node of nodes) injection.appendChild(node);\n const shared = injection;\n slotMap.set('', () => shared);\n continue;\n }\n slotMap.set(slotName, () => {\n const frag = document.createDocumentFragment();\n for (const node of nodes) frag.appendChild(node);\n return frag;\n });\n }\n return injection;\n}\n\nexport function applyComponent(\n d: CompDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[],\n pidMap: Map<string, Element>,\n scope?: BindingContext\n): Node[] | undefined {\n // Skip native HTML elements — prevents <div> matching a `div` in context.\n // Only apply when the authored tag is already lowercase; PascalCase tags like\n // <Button> are valid components even though \"button\" is a native tag.\n const tagLower = d.tag.toLowerCase();\n if (d.tag === tagLower && nativeTags.has(tagLower)) return;\n\n // Exact case first: the context holds the template's own locals alongside its\n // components, so a prop named `icon` sits next to the `Icon` component and\n // collides case-insensitively. The JIT path lowercases into a Map, where the\n // components — appended last — overwrite the locals; matching that ordering is\n // why `<Icon>` resolves in dev, and breaking on the first match is why it did\n // not in a build. Falling back last-wins keeps the two paths agreeing.\n let candidate: unknown = Object.prototype.hasOwnProperty.call(ctx, d.tag)\n ? ctx[d.tag]\n : undefined;\n if (candidate === undefined) {\n for (const key of Object.keys(ctx)) {\n if (key.toLowerCase() === tagLower) candidate = ctx[key];\n }\n }\n if (!candidate) return;\n\n // Support default exports\n if (\n candidate &&\n typeof candidate === 'object' &&\n 'default' in candidate &&\n typeof candidate.default === 'function'\n ) {\n candidate = candidate.default;\n }\n if (typeof candidate !== 'function') return;\n // Hidden like a sibling an activated boundary detached: never rendered.\n if (slotContentHidden(el)) return;\n\n const componentFn = candidate as ComponentFn;\n const localCtx = scope ?? nearestCtx(el, ctx);\n\n // Extract expected props for case-insensitive normalization\n const expectedProps = extractExpectedPropNames(componentFn);\n\n // Evaluate prop expressions with prop name normalization\n const props: Record<string, unknown> = {};\n for (const [rawName, expr] of Object.entries(d.props)) {\n const propName = normalizePropName(rawName, expectedProps);\n try {\n const fn = compileExpression(expr, localCtx);\n props[propName] = untrack(fn);\n } catch {\n // Leave undefined — child uses defaults\n }\n }\n\n const slotMap: SlotMap = new Map();\n let injection: DocumentFragment | undefined;\n if (d.slots) {\n for (const [name, factory] of Object.entries(d.slots))\n slotMap.set(name, (ds = disposers, at) =>\n renderSlot(factory, localCtx, ds, at, el)\n );\n } else {\n injection = slotsFromChildren(el, slotMap);\n }\n\n let invoking = true;\n const childrenFactory = d.children;\n const childFactory: ChildFactory | undefined = childrenFactory\n ? (ctx, wrap) =>\n invoking\n ? childrenFactory(ctx, wrap)\n : isolateDestroyCallbacks(() => childrenFactory(ctx, wrap))\n : undefined;\n\n const componentContext = {\n ...localCtx,\n __slotMap: slotMap,\n __childAstNodes: undefined,\n __childFactory: childFactory,\n };\n\n // Find nearest error boundary\n const boundaryEl = el.closest('[data-error]') as Element | null;\n const boundary = boundaryForElement(boundaryEl);\n\n let out: ComponentResult | undefined;\n let disposeSetup: (() => void) | undefined;\n try {\n out = runWithBoundary(boundary, () => {\n const g = pithyGlobals();\n const originalContext = g.__pithyComponentContext;\n const wasRendering = g.__pithyRenderingComponent;\n const prevInjection = g.__pithyProjectedChildren;\n g.__pithyComponentContext = componentContext;\n g.__pithyRenderingComponent = true;\n g.__pithyProjectedChildren = injection;\n try {\n return createRoot(disposeRoot => {\n disposeSetup = disposeRoot;\n return componentFn(props);\n });\n } finally {\n g.__pithyComponentContext = originalContext;\n g.__pithyRenderingComponent = wasRendering;\n g.__pithyProjectedChildren = prevInjection;\n invoking = false;\n }\n });\n } catch (err) {\n if (boundary) {\n const error = err instanceof Error ? err : new Error(String(err));\n // See `setBoundaryError`: an already-active boundary with no free ancestor\n // drops the error rather than taking it, which is the normal case for a\n // component rendering inside that boundary's `@fallback`.\n reportComponentFailure(el, d.tag, error, boundary);\n return;\n }\n\n // No boundary in scope *yet*. Degrade in both modes — an AOT branch\n // factory renders detached, so `closest()` here cannot see a boundary the\n // element will sit under once the branch is inserted, and throwing would\n // only be swallowed by the structural handler's own catch\n // (`applyStructural.ts`) anyway.\n //\n // A static/server render records the crash instead: dropping the component\n // silently shipped HTML with <${d.tag}> left raw while `pithy-ssg` counted\n // the route as rendered and exited 0 (BUG-018). Anything still recorded\n // when the render finishes fails the route.\n //\n // Note this path cannot reach a boundary at all when the element is inside\n // a detached structural branch: `el.closest('[data-error]')` above found\n // nothing, and no later pass re-binds it, so the boundary never receives\n // the error even though the nodes are inserted underneath it. That is\n // BUG-023; recording is what stops it from shipping silently.\n reportComponentFailure(\n el,\n d.tag,\n err instanceof Error ? err : new Error(String(err)),\n null\n );\n\n console.error(`[AOT] Component <${d.tag}> crashed:`, err);\n return;\n }\n\n if (\n !out ||\n typeof out !== 'object' ||\n !('el' in out) ||\n !isRenderableComponentEl(out.el, el)\n ) {\n // Not a throw, but the same outcome: the raw <${d.tag}> is left in place\n // and the subtree never renders, which under SSR is content silently\n // missing from the emitted HTML. Recorded exactly like a crash (BUG-018).\n // Same funnel as a throw — see `bindComponentTags`. Recording without\n // offering it to the boundary left an AOT component under `@error-boundary`\n // failing its route with the boundary signal unset.\n reportComponentFailure(\n el,\n d.tag,\n new Error(\n `Invalid render result from <${d.tag}>; expected { el, destroy }`\n ),\n boundary\n );\n disposeSetup?.();\n return;\n }\n\n const { el: renderedEl, destroy } = out;\n\n // Capture rendered root element before fragment is consumed by replaceWith\n const forwardedClass = el.getAttribute('class');\n const forwardedAttrs = collectForwardedAttrs(el);\n const renderedRoot: HTMLElement | null =\n renderedEl instanceof DocumentFragment\n ? (renderedEl.firstElementChild as HTMLElement | null)\n : renderedEl instanceof HTMLElement\n ? renderedEl\n : null;\n\n const nodes =\n renderedEl instanceof DocumentFragment\n ? Array.from(renderedEl.childNodes)\n : [renderedEl];\n let replaced = true;\n try {\n el.replaceWith(...nodes);\n } catch (err) {\n // The raw <${d.tag}> is left exactly where a crash would have left it, so\n // this is the same content loss and is recorded the same way.\n replaced = false;\n reportComponentFailure(\n el,\n d.tag,\n err instanceof Error ? err : new Error(String(err)),\n boundary\n );\n console.error(`[AOT] Failed to replace <${d.tag}>:`, err);\n }\n\n // Retracted only here, and in the boundary catch above. This is the point at\n // which the component is known to have produced a usable node AND to have\n // reached the document.\n if (isSSRMode() && replaced) clearSSRRenderCrash(el);\n\n if (forwardedClass && renderedRoot) {\n for (const cls of forwardedClass.split(/\\s+/)) {\n if (cls) renderedRoot.classList.add(cls);\n }\n }\n\n if (forwardedAttrs.length > 0 && renderedRoot) {\n applyForwardedAttrs(renderedRoot, forwardedAttrs, d.tag);\n }\n\n // Re-target the component pid to the rendered root so subsequent binding\n // passes (event, bound, class, style) apply to the component's actual DOM\n // element. This matches the JIT path where data-on-* attributes are\n // forwarded from the placeholder to the rendered root.\n if (renderedRoot) {\n pidMap.set(d.pid, renderedRoot);\n } else {\n if (\n import.meta.env?.DEV &&\n (forwardedClass ||\n forwardedAttrs.length > 0 ||\n (d.props && Object.keys(d.props).length > 0))\n ) {\n console.warn(\n `[AOT] <${d.tag}> has forwarded attributes but returns a fragment with no single root element — forwarding skipped.`\n );\n }\n pidMap.delete(d.pid);\n }\n\n if (disposeSetup) disposers.push(disposeSetup);\n if (typeof destroy === 'function') disposers.push(destroy);\n return replaced ? nodes : undefined;\n}\n"]}
@@ -59,8 +59,8 @@ export function applyProjection(d, commentMap, ctx, disposers) {
59
59
  const render = slotMap.get(d.name);
60
60
  const bound = new Map();
61
61
  if (render)
62
- bound.set(d.name, slotDisposers => {
63
- const content = render(slotDisposers);
62
+ bound.set(d.name, (slotDisposers, at) => {
63
+ const content = render(slotDisposers, at);
64
64
  const pageCtx = nodeExpando(content).__pithyCtx;
65
65
  if (pageCtx)
66
66
  bindTextInterpolations(content, pageCtx, slotDisposers ?? disposers);
@@ -1 +1 @@
1
- {"version":3,"file":"applySimple.js","sourceRoot":"","sources":["../../../src/runtime/bindings/applySimple.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC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MAAM,QAAQ,GAAG,iBAAiB,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAErD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,EAAE;YACvB,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;gBACzB,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;oBAC/B,IAAI,KAAK;wBAAE,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;;wBAClC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAClC,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;oBACjC,IAAI,iBAAiB,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC;wBAAE,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;;wBAC/D,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACrC,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,YAAY;YACd,CAAC;QACH,CAAC,CAAC,CAAC;QACH,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,+BAA+B;IACjC,CAAC;AACH,CAAC","sourcesContent":["import { effect, isSignal } from '@pithyjs/signals';\nimport { compileExpression } from '../../compile/compileExpression';\nimport { rejectsScriptSink } from '../../compile/binds/bindBoundAttributes';\nimport { toTextValue } from '../../compile/textValue';\nimport { isSSRMode } from '../../compile/ssrMode';\nimport {\n registerBoundary,\n boundaryForElement,\n setBoundaryError,\n} from '../../compile/binds/bindErrorBoundary';\nimport { applyClassGroup } from '../../compile/binds/bindClassDirectives';\nimport { mountProjection, type SlotMap } from '../../compile/contentProjection';\nimport { bindTextInterpolations } from '../../compile/binds/bindTextInterpolations';\nimport { nodeExpando } from '../../compile/nodeExpando';\nimport type {\n RefDesc,\n ErrorDesc,\n ProjDesc,\n BindDesc,\n InterpDesc,\n EventDesc,\n ClassDesc,\n ClassesDesc,\n StyleDesc,\n BoundDesc,\n BindingContext,\n} from './types';\nimport { nearestCtx, compileWithEvent } from './helpers';\n\n// ─── Individual binding handlers ──────────────────────────────────────────────\n\nexport function applyRef(\n d: RefDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const ref = ctx[d.name] as\n | { set?: (value: Element | null) => void }\n | undefined;\n if (ref && typeof ref.set === 'function') {\n ref.set(el);\n disposers.push(() => ref.set!(null));\n }\n}\n\nexport function applyError(\n d: ErrorDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n // Ensure data-error attribute is set from descriptor (source of truth)\n // so registerBoundary can find the signal name, even if AOT codegen\n // stops emitting the transitional data-error attribute in the future.\n if (d.expr && !el.getAttribute('data-error')) {\n el.setAttribute('data-error', d.expr);\n }\n\n // Register el itself as an error boundary. We use registerBoundary (not\n // bindErrorBoundary) because bindErrorBoundary uses querySelectorAll which\n // only searches children — it would miss el itself.\n registerBoundary(el, ctx, disposers);\n}\n\nexport function applyProjection(\n d: ProjDesc,\n commentMap: Map<string, Comment>,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const anchor = commentMap.get(`slot:${d.name}`);\n if (!anchor) return;\n\n const fallback = d.fallback;\n const anchorExpando = anchor as Comment & {\n __slotName?: string;\n __fallbackFactory?: (\n factoryCtx?: BindingContext\n ) => HTMLElement | DocumentFragment | undefined;\n };\n\n // Set expando properties that extractSlotDefs expects\n anchorExpando.__slotName = d.name;\n if (fallback) {\n anchorExpando.__fallbackFactory = (factoryCtx?: BindingContext) => {\n const result = fallback(factoryCtx || ctx);\n if (result && typeof result.destroy === 'function') {\n disposers.push(result.destroy);\n }\n return result?.el;\n };\n }\n\n // Check for SlotMap in context\n const slotMap = ('__slotMap' in ctx ? ctx.__slotMap : undefined) as\n | SlotMap\n | undefined;\n if (slotMap) {\n const slotDefs = [\n {\n name: d.name,\n anchor,\n fallbackFactory: anchorExpando.__fallbackFactory,\n },\n ];\n const render = slotMap.get(d.name);\n const bound: SlotMap = new Map();\n if (render)\n bound.set(d.name, slotDisposers => {\n const content = render(slotDisposers);\n const pageCtx = nodeExpando(content).__pithyCtx;\n if (pageCtx)\n bindTextInterpolations(content, pageCtx, slotDisposers ?? disposers);\n return content;\n });\n mountProjection(slotDefs, bound, disposers);\n } else if (fallback) {\n // No projected content — mount fallback\n const fallbackResult = fallback(ctx);\n const parent = anchor.parentNode;\n if (parent && fallbackResult?.el) {\n // Capture nodes for cleanup (fragment empties itself on insert)\n const nodes =\n fallbackResult.el instanceof DocumentFragment\n ? Array.from(fallbackResult.el.childNodes)\n : [fallbackResult.el];\n // Insert directly — fragment preserves child order; single node is trivial\n parent.insertBefore(fallbackResult.el, anchor.nextSibling);\n if (typeof fallbackResult.destroy === 'function') {\n disposers.push(fallbackResult.destroy);\n }\n disposers.push(() => {\n for (const node of nodes) {\n if (node.parentNode) node.parentNode.removeChild(node);\n }\n });\n }\n }\n}\n\nexport function applyBind(\n d: BindDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n if (!(el instanceof HTMLElement)) return;\n\n const sig = ctx[d.expr];\n if (!isSignal(sig) || typeof sig.set !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(`[AOT @bind] \"${d.expr}\" must refer to a writable signal`);\n }\n return;\n }\n const write = sig.set;\n\n const prop = inferBindableProperty(el);\n const target = el as HTMLElement & Record<string, unknown>;\n const stop = effect(() => {\n const value = sig();\n if (target[prop] !== value) target[prop] = value;\n });\n\n const event = prop === 'checked' ? 'change' : 'input';\n const handler = () => {\n write(extractBindableValue(el, prop));\n };\n el.addEventListener(event, handler);\n\n disposers.push(() => {\n el.removeEventListener(event, handler);\n stop();\n });\n}\n\nfunction inferBindableProperty(el: HTMLElement): string {\n const tag = el.tagName.toLowerCase();\n if (tag === 'input') {\n const type = (el as HTMLInputElement).type;\n if (type === 'checkbox' || type === 'radio') return 'checked';\n }\n return 'value';\n}\n\n/** Extract value from element with type coercion for number inputs. */\nfunction extractBindableValue(el: HTMLElement, prop: string): unknown {\n if (prop === 'checked') return (el as HTMLInputElement).checked;\n\n const tag = el.tagName.toLowerCase();\n if (tag === 'input') {\n const inputEl = el as HTMLInputElement;\n if (inputEl.type === 'number') {\n const numValue = Number(inputEl.value);\n return isNaN(numValue) ? inputEl.value : numValue;\n }\n return inputEl.value;\n }\n\n return (el as HTMLElement & Record<string, unknown>)[prop];\n}\n\nexport function applyInterpolation(\n d: InterpDesc,\n el: Element | DocumentFragment,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n // Find text nodes within el that contain {{ }} markers\n const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT);\n let textNode: Text | null;\n const targets: Text[] = [];\n\n const rootLevel = d.pid === '';\n while ((textNode = walker.nextNode() as Text | null)) {\n const val = textNode.nodeValue ?? '';\n if (!val.includes('{{')) continue;\n if (rootLevel && textNode.parentElement?.closest('[data-pid]')) continue;\n targets.push(textNode);\n break;\n }\n\n if (targets.length === 0 && import.meta.env?.DEV) {\n console.warn(\n `[AOT interp] No text node with {{ }} markers found ${rootLevel ? 'at the template root' : `in element pid=\"${d.pid}\"`}`\n );\n }\n\n // Process each target text node matching this interpolation descriptor\n for (const node of targets) {\n const localCtx = nearestCtx(node, ctx);\n const parent = node.parentNode;\n if (!parent) continue;\n\n const nextSibling = node.nextSibling;\n parent.removeChild(node);\n\n for (const part of d.parts) {\n if ('s' in part) {\n // Static text\n parent.insertBefore(document.createTextNode(part.s), nextSibling);\n } else {\n // Dynamic expression\n const expr = part.e;\n const startComment = document.createComment('t');\n const dynText = document.createTextNode('');\n const endComment = document.createComment('/t');\n\n parent.insertBefore(startComment, nextSibling);\n parent.insertBefore(dynText, nextSibling);\n parent.insertBefore(endComment, nextSibling);\n\n try {\n const compiledFn = compileExpression(expr, localCtx);\n\n if (isSSRMode()) {\n try {\n dynText.nodeValue = toTextValue(compiledFn());\n } catch {\n dynText.nodeValue = '';\n }\n } else {\n let lastValue: string | undefined;\n const stop = effect(() => {\n try {\n const next = toTextValue(compiledFn());\n if (next !== lastValue) {\n dynText.nodeValue = next;\n lastValue = next;\n }\n } catch {\n dynText.nodeValue = '';\n }\n });\n disposers.push(stop);\n }\n } catch {\n dynText.nodeValue = '';\n }\n }\n }\n\n // Only process the first matching text node per interpolation descriptor\n break;\n }\n}\n\n/** Per-element, per-event idempotency guard (mirrors JIT's BOUND_KEY symbol). */\nconst AOT_BOUND_KEY: unique symbol = Symbol('pithy:aot-bound');\n\nfunction getAotBoundSet(el: Element, eventName: string): Set<string> {\n const host = el as Element & {\n [AOT_BOUND_KEY]?: Record<string, Set<string>>;\n };\n const store =\n host[AOT_BOUND_KEY] ??\n (host[AOT_BOUND_KEY] = Object.create(null) as Record<string, Set<string>>);\n return (store[eventName] ??= new Set<string>());\n}\n\nexport function applyEvent(\n d: EventDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n // Idempotency: skip if this exact event+expr combo was already bound\n const boundSet = getAotBoundSet(el, d.event);\n const boundKey = `${d.event}${d.mods ? '.' + d.mods.join('.') : ''}=${d.expr}`;\n if (boundSet.has(boundKey)) return;\n\n const localCtx = nearestCtx(el, ctx);\n const mods = parseMods(d.mods);\n const handlerExpr = d.expr;\n\n const isSimpleIdentifier = /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(handlerExpr);\n const directFn =\n isSimpleIdentifier && typeof localCtx[handlerExpr] === 'function'\n ? (localCtx[handlerExpr] as EventListener)\n : null;\n const runWithEvt = directFn ? null : compileWithEvent(handlerExpr, localCtx);\n\n const listener: EventListener = (ev: Event) => {\n if (mods.self && ev.target !== el) return;\n if (mods.prevent) ev.preventDefault();\n if (mods.stop) ev.stopPropagation();\n\n try {\n if (directFn) {\n return directFn.call(localCtx, ev);\n } else if (runWithEvt) {\n const out = runWithEvt(ev, el);\n if (typeof out === 'function')\n return (out as (e: Event) => unknown).call(localCtx, ev);\n return out;\n }\n } catch (error) {\n const boundaryEl = el.closest('[data-error]') as Element | null;\n const boundary = boundaryForElement(boundaryEl);\n if (boundary) {\n setBoundaryError(\n boundary,\n error instanceof Error ? error : new Error(String(error))\n );\n } else {\n throw error;\n }\n }\n };\n\n const options: AddEventListenerOptions = {\n capture: !!mods.capture,\n passive: !!mods.passive,\n once: !!mods.once,\n };\n\n el.addEventListener(d.event, listener, options);\n boundSet.add(boundKey);\n disposers.push(() => {\n el.removeEventListener(d.event, listener, { capture: !!mods.capture });\n boundSet.delete(boundKey);\n });\n}\n\nfunction parseMods(mods?: string[]): {\n once?: boolean;\n prevent?: boolean;\n stop?: boolean;\n self?: boolean;\n capture?: boolean;\n passive?: boolean;\n} {\n if (!mods) return {};\n const m: Record<string, boolean> = {};\n for (const mod of mods) m[mod] = true;\n return m;\n}\n\nexport function applyClass(\n d: ClassDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const localCtx = nearestCtx(el, ctx);\n try {\n const evaluate = compileExpression(d.expr, localCtx);\n const stop = effect(() => {\n try {\n el.classList.toggle(d.name, !!evaluate());\n } catch {\n /* ignore */\n }\n });\n disposers.push(stop);\n } catch {\n /* ignore */\n }\n}\n\nexport function applyClasses(\n d: ClassesDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const localCtx = nearestCtx(el, ctx);\n try {\n const evaluate = compileExpression(d.expr, localCtx);\n const owned = new Set<string>();\n const stop = effect(() => {\n try {\n applyClassGroup(el, evaluate(), owned);\n } catch {\n /* ignore */\n }\n });\n disposers.push(stop);\n } catch {\n /* ignore */\n }\n}\n\n/** Convert camelCase to kebab-case for CSS property names. */\nfunction toKebabCase(prop: string): string {\n return prop.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`);\n}\n\nexport function applyStyle(\n d: StyleDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n // Not `instanceof HTMLElement`: SVG elements have inline styles too.\n const style = (el as Partial<ElementCSSInlineStyle>).style;\n if (!style) return;\n const localCtx = nearestCtx(el, ctx);\n // setProperty requires kebab-case; codegen may emit camelCase (e.g. fontSize)\n const cssProp = d.prop.includes('-') ? d.prop : toKebabCase(d.prop);\n try {\n const evaluate = compileExpression(d.expr, localCtx);\n const stop = effect(() => {\n try {\n const value = evaluate();\n if (value == null || value === false) {\n style.removeProperty(cssProp);\n return;\n }\n const text = String(value);\n const important = /\\s*!important\\s*$/i.exec(text);\n if (important) {\n style.setProperty(\n cssProp,\n text.slice(0, important.index),\n 'important'\n );\n } else {\n style.setProperty(cssProp, text);\n }\n } catch {\n /* ignore */\n }\n });\n disposers.push(stop);\n } catch {\n /* ignore */\n }\n}\n\nexport function applyBound(\n d: BoundDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const localCtx = nearestCtx(el, ctx);\n // Compile once outside effect via compileExpression (consistent with applyClass/applyStyle).\n try {\n const evaluate = compileExpression(d.expr, localCtx);\n\n const stop = effect(() => {\n try {\n const value = evaluate();\n if (typeof value === 'boolean') {\n if (value) el.setAttribute(d.attr, '');\n else el.removeAttribute(d.attr);\n } else {\n const text = String(value ?? '');\n if (rejectsScriptSink(el, d.attr, text)) el.removeAttribute(d.attr);\n else el.setAttribute(d.attr, text);\n }\n } catch {\n /* ignore */\n }\n });\n disposers.push(stop);\n } catch {\n /* ignore invalid expression */\n }\n}\n"]}
1
+ {"version":3,"file":"applySimple.js","sourceRoot":"","sources":["../../../src/runtime/bindings/applySimple.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,E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C;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,YAAY;IACd,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,CAAY,EACZ,EAAW,EACX,GAAmB,EACnB,SAAyB;IAEzB,MAAM,QAAQ,GAAG,UAAU,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACrC,6FAA6F;IAC7F,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,iBAAiB,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAErD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,EAAE;YACvB,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;gBACzB,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;oBAC/B,IAAI,KAAK;wBAAE,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;;wBAClC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAClC,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;oBACjC,IAAI,iBAAiB,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC;wBAAE,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;;wBAC/D,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACrC,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,YAAY;YACd,CAAC;QACH,CAAC,CAAC,CAAC;QACH,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,+BAA+B;IACjC,CAAC;AACH,CAAC","sourcesContent":["import { effect, isSignal } from '@pithyjs/signals';\nimport { compileExpression } from '../../compile/compileExpression';\nimport { rejectsScriptSink } from '../../compile/binds/bindBoundAttributes';\nimport { toTextValue } from '../../compile/textValue';\nimport { isSSRMode } from '../../compile/ssrMode';\nimport {\n registerBoundary,\n boundaryForElement,\n setBoundaryError,\n} from '../../compile/binds/bindErrorBoundary';\nimport { applyClassGroup } from '../../compile/binds/bindClassDirectives';\nimport { mountProjection, type SlotMap } from '../../compile/contentProjection';\nimport { bindTextInterpolations } from '../../compile/binds/bindTextInterpolations';\nimport { nodeExpando } from '../../compile/nodeExpando';\nimport type {\n RefDesc,\n ErrorDesc,\n ProjDesc,\n BindDesc,\n InterpDesc,\n EventDesc,\n ClassDesc,\n ClassesDesc,\n StyleDesc,\n BoundDesc,\n BindingContext,\n} from './types';\nimport { nearestCtx, compileWithEvent } from './helpers';\n\n// ─── Individual binding handlers ──────────────────────────────────────────────\n\nexport function applyRef(\n d: RefDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const ref = ctx[d.name] as\n | { set?: (value: Element | null) => void }\n | undefined;\n if (ref && typeof ref.set === 'function') {\n ref.set(el);\n disposers.push(() => ref.set!(null));\n }\n}\n\nexport function applyError(\n d: ErrorDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n // Ensure data-error attribute is set from descriptor (source of truth)\n // so registerBoundary can find the signal name, even if AOT codegen\n // stops emitting the transitional data-error attribute in the future.\n if (d.expr && !el.getAttribute('data-error')) {\n el.setAttribute('data-error', d.expr);\n }\n\n // Register el itself as an error boundary. We use registerBoundary (not\n // bindErrorBoundary) because bindErrorBoundary uses querySelectorAll which\n // only searches children — it would miss el itself.\n registerBoundary(el, ctx, disposers);\n}\n\nexport function applyProjection(\n d: ProjDesc,\n commentMap: Map<string, Comment>,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const anchor = commentMap.get(`slot:${d.name}`);\n if (!anchor) return;\n\n const fallback = d.fallback;\n const anchorExpando = anchor as Comment & {\n __slotName?: string;\n __fallbackFactory?: (\n factoryCtx?: BindingContext\n ) => HTMLElement | DocumentFragment | undefined;\n };\n\n // Set expando properties that extractSlotDefs expects\n anchorExpando.__slotName = d.name;\n if (fallback) {\n anchorExpando.__fallbackFactory = (factoryCtx?: BindingContext) => {\n const result = fallback(factoryCtx || ctx);\n if (result && typeof result.destroy === 'function') {\n disposers.push(result.destroy);\n }\n return result?.el;\n };\n }\n\n // Check for SlotMap in context\n const slotMap = ('__slotMap' in ctx ? ctx.__slotMap : undefined) as\n | SlotMap\n | undefined;\n if (slotMap) {\n const slotDefs = [\n {\n name: d.name,\n anchor,\n fallbackFactory: anchorExpando.__fallbackFactory,\n },\n ];\n const render = slotMap.get(d.name);\n const bound: SlotMap = new Map();\n if (render)\n bound.set(d.name, (slotDisposers, at) => {\n const content = render(slotDisposers, at);\n const pageCtx = nodeExpando(content).__pithyCtx;\n if (pageCtx)\n bindTextInterpolations(content, pageCtx, slotDisposers ?? disposers);\n return content;\n });\n mountProjection(slotDefs, bound, disposers);\n } else if (fallback) {\n // No projected content — mount fallback\n const fallbackResult = fallback(ctx);\n const parent = anchor.parentNode;\n if (parent && fallbackResult?.el) {\n // Capture nodes for cleanup (fragment empties itself on insert)\n const nodes =\n fallbackResult.el instanceof DocumentFragment\n ? Array.from(fallbackResult.el.childNodes)\n : [fallbackResult.el];\n // Insert directly — fragment preserves child order; single node is trivial\n parent.insertBefore(fallbackResult.el, anchor.nextSibling);\n if (typeof fallbackResult.destroy === 'function') {\n disposers.push(fallbackResult.destroy);\n }\n disposers.push(() => {\n for (const node of nodes) {\n if (node.parentNode) node.parentNode.removeChild(node);\n }\n });\n }\n }\n}\n\nexport function applyBind(\n d: BindDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n if (!(el instanceof HTMLElement)) return;\n\n const sig = ctx[d.expr];\n if (!isSignal(sig) || typeof sig.set !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(`[AOT @bind] \"${d.expr}\" must refer to a writable signal`);\n }\n return;\n }\n const write = sig.set;\n\n const prop = inferBindableProperty(el);\n const target = el as HTMLElement & Record<string, unknown>;\n const stop = effect(() => {\n const value = sig();\n if (target[prop] !== value) target[prop] = value;\n });\n\n const event = prop === 'checked' ? 'change' : 'input';\n const handler = () => {\n write(extractBindableValue(el, prop));\n };\n el.addEventListener(event, handler);\n\n disposers.push(() => {\n el.removeEventListener(event, handler);\n stop();\n });\n}\n\nfunction inferBindableProperty(el: HTMLElement): string {\n const tag = el.tagName.toLowerCase();\n if (tag === 'input') {\n const type = (el as HTMLInputElement).type;\n if (type === 'checkbox' || type === 'radio') return 'checked';\n }\n return 'value';\n}\n\n/** Extract value from element with type coercion for number inputs. */\nfunction extractBindableValue(el: HTMLElement, prop: string): unknown {\n if (prop === 'checked') return (el as HTMLInputElement).checked;\n\n const tag = el.tagName.toLowerCase();\n if (tag === 'input') {\n const inputEl = el as HTMLInputElement;\n if (inputEl.type === 'number') {\n const numValue = Number(inputEl.value);\n return isNaN(numValue) ? inputEl.value : numValue;\n }\n return inputEl.value;\n }\n\n return (el as HTMLElement & Record<string, unknown>)[prop];\n}\n\nexport function applyInterpolation(\n d: InterpDesc,\n el: Element | DocumentFragment,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n // Find text nodes within el that contain {{ }} markers\n const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT);\n let textNode: Text | null;\n const targets: Text[] = [];\n\n const rootLevel = d.pid === '';\n while ((textNode = walker.nextNode() as Text | null)) {\n const val = textNode.nodeValue ?? '';\n if (!val.includes('{{')) continue;\n if (rootLevel && textNode.parentElement?.closest('[data-pid]')) continue;\n targets.push(textNode);\n break;\n }\n\n if (targets.length === 0 && import.meta.env?.DEV) {\n console.warn(\n `[AOT interp] No text node with {{ }} markers found ${rootLevel ? 'at the template root' : `in element pid=\"${d.pid}\"`}`\n );\n }\n\n // Process each target text node matching this interpolation descriptor\n for (const node of targets) {\n const localCtx = nearestCtx(node, ctx);\n const parent = node.parentNode;\n if (!parent) continue;\n\n const nextSibling = node.nextSibling;\n parent.removeChild(node);\n\n for (const part of d.parts) {\n if ('s' in part) {\n // Static text\n parent.insertBefore(document.createTextNode(part.s), nextSibling);\n } else {\n // Dynamic expression\n const expr = part.e;\n const startComment = document.createComment('t');\n const dynText = document.createTextNode('');\n const endComment = document.createComment('/t');\n\n parent.insertBefore(startComment, nextSibling);\n parent.insertBefore(dynText, nextSibling);\n parent.insertBefore(endComment, nextSibling);\n\n try {\n const compiledFn = compileExpression(expr, localCtx);\n\n if (isSSRMode()) {\n try {\n dynText.nodeValue = toTextValue(compiledFn());\n } catch {\n dynText.nodeValue = '';\n }\n } else {\n let lastValue: string | undefined;\n const stop = effect(() => {\n try {\n const next = toTextValue(compiledFn());\n if (next !== lastValue) {\n dynText.nodeValue = next;\n lastValue = next;\n }\n } catch {\n dynText.nodeValue = '';\n }\n });\n disposers.push(stop);\n }\n } catch {\n dynText.nodeValue = '';\n }\n }\n }\n\n // Only process the first matching text node per interpolation descriptor\n break;\n }\n}\n\n/** Per-element, per-event idempotency guard (mirrors JIT's BOUND_KEY symbol). */\nconst AOT_BOUND_KEY: unique symbol = Symbol('pithy:aot-bound');\n\nfunction getAotBoundSet(el: Element, eventName: string): Set<string> {\n const host = el as Element & {\n [AOT_BOUND_KEY]?: Record<string, Set<string>>;\n };\n const store =\n host[AOT_BOUND_KEY] ??\n (host[AOT_BOUND_KEY] = Object.create(null) as Record<string, Set<string>>);\n return (store[eventName] ??= new Set<string>());\n}\n\nexport function applyEvent(\n d: EventDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n // Idempotency: skip if this exact event+expr combo was already bound\n const boundSet = getAotBoundSet(el, d.event);\n const boundKey = `${d.event}${d.mods ? '.' + d.mods.join('.') : ''}=${d.expr}`;\n if (boundSet.has(boundKey)) return;\n\n const localCtx = nearestCtx(el, ctx);\n const mods = parseMods(d.mods);\n const handlerExpr = d.expr;\n\n const isSimpleIdentifier = /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(handlerExpr);\n const directFn =\n isSimpleIdentifier && typeof localCtx[handlerExpr] === 'function'\n ? (localCtx[handlerExpr] as EventListener)\n : null;\n const runWithEvt = directFn ? null : compileWithEvent(handlerExpr, localCtx);\n\n const listener: EventListener = (ev: Event) => {\n if (mods.self && ev.target !== el) return;\n if (mods.prevent) ev.preventDefault();\n if (mods.stop) ev.stopPropagation();\n\n try {\n if (directFn) {\n return directFn.call(localCtx, ev);\n } else if (runWithEvt) {\n const out = runWithEvt(ev, el);\n if (typeof out === 'function')\n return (out as (e: Event) => unknown).call(localCtx, ev);\n return out;\n }\n } catch (error) {\n const boundaryEl = el.closest('[data-error]') as Element | null;\n const boundary = boundaryForElement(boundaryEl);\n if (boundary) {\n setBoundaryError(\n boundary,\n error instanceof Error ? error : new Error(String(error))\n );\n } else {\n throw error;\n }\n }\n };\n\n const options: AddEventListenerOptions = {\n capture: !!mods.capture,\n passive: !!mods.passive,\n once: !!mods.once,\n };\n\n el.addEventListener(d.event, listener, options);\n boundSet.add(boundKey);\n disposers.push(() => {\n el.removeEventListener(d.event, listener, { capture: !!mods.capture });\n boundSet.delete(boundKey);\n });\n}\n\nfunction parseMods(mods?: string[]): {\n once?: boolean;\n prevent?: boolean;\n stop?: boolean;\n self?: boolean;\n capture?: boolean;\n passive?: boolean;\n} {\n if (!mods) return {};\n const m: Record<string, boolean> = {};\n for (const mod of mods) m[mod] = true;\n return m;\n}\n\nexport function applyClass(\n d: ClassDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const localCtx = nearestCtx(el, ctx);\n try {\n const evaluate = compileExpression(d.expr, localCtx);\n const stop = effect(() => {\n try {\n el.classList.toggle(d.name, !!evaluate());\n } catch {\n /* ignore */\n }\n });\n disposers.push(stop);\n } catch {\n /* ignore */\n }\n}\n\nexport function applyClasses(\n d: ClassesDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const localCtx = nearestCtx(el, ctx);\n try {\n const evaluate = compileExpression(d.expr, localCtx);\n const owned = new Set<string>();\n const stop = effect(() => {\n try {\n applyClassGroup(el, evaluate(), owned);\n } catch {\n /* ignore */\n }\n });\n disposers.push(stop);\n } catch {\n /* ignore */\n }\n}\n\n/** Convert camelCase to kebab-case for CSS property names. */\nfunction toKebabCase(prop: string): string {\n return prop.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`);\n}\n\nexport function applyStyle(\n d: StyleDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n // Not `instanceof HTMLElement`: SVG elements have inline styles too.\n const style = (el as Partial<ElementCSSInlineStyle>).style;\n if (!style) return;\n const localCtx = nearestCtx(el, ctx);\n // setProperty requires kebab-case; codegen may emit camelCase (e.g. fontSize)\n const cssProp = d.prop.includes('-') ? d.prop : toKebabCase(d.prop);\n try {\n const evaluate = compileExpression(d.expr, localCtx);\n const stop = effect(() => {\n try {\n const value = evaluate();\n if (value == null || value === false) {\n style.removeProperty(cssProp);\n return;\n }\n const text = String(value);\n const important = /\\s*!important\\s*$/i.exec(text);\n if (important) {\n style.setProperty(\n cssProp,\n text.slice(0, important.index),\n 'important'\n );\n } else {\n style.setProperty(cssProp, text);\n }\n } catch {\n /* ignore */\n }\n });\n disposers.push(stop);\n } catch {\n /* ignore */\n }\n}\n\nexport function applyBound(\n d: BoundDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const localCtx = nearestCtx(el, ctx);\n // Compile once outside effect via compileExpression (consistent with applyClass/applyStyle).\n try {\n const evaluate = compileExpression(d.expr, localCtx);\n\n const stop = effect(() => {\n try {\n const value = evaluate();\n if (typeof value === 'boolean') {\n if (value) el.setAttribute(d.attr, '');\n else el.removeAttribute(d.attr);\n } else {\n const text = String(value ?? '');\n if (rejectsScriptSink(el, d.attr, text)) el.removeAttribute(d.attr);\n else el.setAttribute(d.attr, text);\n }\n } catch {\n /* ignore */\n }\n });\n disposers.push(stop);\n } catch {\n /* ignore invalid expression */\n }\n}\n"]}
@@ -64,6 +64,8 @@ export interface CompDesc {
64
64
  tag: string;
65
65
  props: Record<string, string>;
66
66
  children?: ChildFactory;
67
+ /** Slot name → factory that renders and binds that slot's content once per mount. */
68
+ slots?: Record<string, ChildFactory>;
67
69
  }
68
70
  export interface DeferDesc {
69
71
  t: 'defer';
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/types.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErD,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,WAAW,GAAG,gBAAgB,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,aAAa,GAAG,IAAI,GAAG,SAAS,CAAC;AAEhF,yQAAyQ;AACzQ,MAAM,MAAM,YAAY,GAAG,CACzB,GAAG,EAAE,cAAc,EACnB,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,gBAAgB,KACjD;IAAE,EAAE,EAAE,gBAAgB,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC;AAEnD,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,OAAO,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AACD,MAAM,WAAW,UAAU;IACzB,CAAC,EAAE,QAAQ,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,CAAC;QAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;CAC1C;AACD,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,OAAO,C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,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AACD,MAAM,WAAW,MAAM;IACrB,CAAC,EAAE,IAAI,CAAC;IACR,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CACjD;AACD,MAAM,WAAW,OAAO;IACtB,CAAC,EAAE,KAAK,CAAC;IACT,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AACD,MAAM,WAAW,UAAU;IACzB,CAAC,EAAE,QAAQ,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CAC7C;AAED,MAAM,MAAM,IAAI,GACZ,SAAS,GACT,UAAU,GACV,SAAS,GACT,WAAW,GACX,SAAS,GACT,SAAS,GACT,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,GACT,QAAQ,GACR,MAAM,GACN,OAAO,GACP,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/runtime/bindings/types.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,4EAA4E;AAC5E,mFAAmF","sourcesContent":["// ─── Descriptor types (mirror codegen output) ────────────────────────────────\n// These describe the shape of the compact binding arrays emitted by the AOT\n// codegen in generateBindings.ts. Handlers narrow inside via the `t` discriminant.\n\nexport type BindingContext = Record<string, unknown>;\n\nexport interface FactoryResult {\n el?: HTMLElement | DocumentFragment;\n destroy?: () => void;\n}\n\nexport type Factory = (ctx: BindingContext) => FactoryResult | null | undefined;\n\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"ChildFactory\",\"stability\":\"experimental\",\"signature\":\"type ChildFactory = (ctx: BindingContext, wrap?: (nodes: DocumentFragment) => DocumentFragment) => { el: DocumentFragment; destroy: () => void }\"} */\nexport type ChildFactory = (\n ctx: BindingContext,\n wrap?: (nodes: DocumentFragment) => DocumentFragment\n) => { el: DocumentFragment; destroy: () => void };\n\nexport interface EventDesc {\n t: 'event';\n pid: string;\n event: string;\n expr: string;\n mods?: string[];\n}\nexport interface InterpDesc {\n t: 'interp';\n pid: string;\n parts: ({ s: string } | { e: string })[];\n}\nexport interface ClassDesc {\n t: 'class';\n pid: string;\n name: string;\n expr: string;\n}\nexport interface ClassesDesc {\n t: 'classes';\n pid: string;\n expr: string;\n}\nexport interface StyleDesc {\n t: 'style';\n pid: string;\n prop: string;\n expr: string;\n}\nexport interface BoundDesc {\n t: 'bound';\n pid: string;\n attr: string;\n expr: string;\n}\nexport interface RefDesc {\n t: 'ref';\n pid: string;\n name: string;\n}\nexport interface BindDesc {\n t: 'bind';\n pid: string;\n expr: string;\n}\nexport interface CompDesc {\n t: 'comp';\n pid: string;\n tag: string;\n props: Record<string, string>;\n children?: ChildFactory;\n}\nexport interface DeferDesc {\n t: 'defer';\n pid: string;\n trigger: string;\n load: string;\n placeholder?: string;\n when?: string;\n priority?: string;\n timeout?: number;\n}\nexport interface ErrorDesc {\n t: 'error';\n pid: string;\n expr: string;\n}\nexport interface ProjDesc {\n t: 'proj';\n pid: string;\n name: string;\n fallback?: Factory;\n}\nexport interface IfDesc {\n t: 'if';\n pid: string;\n branches: { expr?: string; factory: Factory }[];\n}\nexport interface ForDesc {\n t: 'for';\n pid: string;\n item: string;\n index?: string;\n expr: string;\n trackBy?: string;\n factory: Factory;\n}\nexport interface SwitchDesc {\n t: 'switch';\n pid: string;\n expr: string;\n cases: { val?: string; factory: Factory }[];\n}\n\nexport type Desc =\n | EventDesc\n | InterpDesc\n | ClassDesc\n | ClassesDesc\n | StyleDesc\n | BoundDesc\n | RefDesc\n | BindDesc\n | CompDesc\n | DeferDesc\n | ErrorDesc\n | ProjDesc\n | IfDesc\n | ForDesc\n | SwitchDesc;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/runtime/bindings/types.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,4EAA4E;AAC5E,mFAAmF","sourcesContent":["// ─── Descriptor types (mirror codegen output) ────────────────────────────────\n// These describe the shape of the compact binding arrays emitted by the AOT\n// codegen in generateBindings.ts. Handlers narrow inside via the `t` discriminant.\n\nexport type BindingContext = Record<string, unknown>;\n\nexport interface FactoryResult {\n el?: HTMLElement | DocumentFragment;\n destroy?: () => void;\n}\n\nexport type Factory = (ctx: BindingContext) => FactoryResult | null | undefined;\n\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"ChildFactory\",\"stability\":\"experimental\",\"signature\":\"type ChildFactory = (ctx: BindingContext, wrap?: (nodes: DocumentFragment) => DocumentFragment) => { el: DocumentFragment; destroy: () => void }\"} */\nexport type ChildFactory = (\n ctx: BindingContext,\n wrap?: (nodes: DocumentFragment) => DocumentFragment\n) => { el: DocumentFragment; destroy: () => void };\n\nexport interface EventDesc {\n t: 'event';\n pid: string;\n event: string;\n expr: string;\n mods?: string[];\n}\nexport interface InterpDesc {\n t: 'interp';\n pid: string;\n parts: ({ s: string } | { e: string })[];\n}\nexport interface ClassDesc {\n t: 'class';\n pid: string;\n name: string;\n expr: string;\n}\nexport interface ClassesDesc {\n t: 'classes';\n pid: string;\n expr: string;\n}\nexport interface StyleDesc {\n t: 'style';\n pid: string;\n prop: string;\n expr: string;\n}\nexport interface BoundDesc {\n t: 'bound';\n pid: string;\n attr: string;\n expr: string;\n}\nexport interface RefDesc {\n t: 'ref';\n pid: string;\n name: string;\n}\nexport interface BindDesc {\n t: 'bind';\n pid: string;\n expr: string;\n}\nexport interface CompDesc {\n t: 'comp';\n pid: string;\n tag: string;\n props: Record<string, string>;\n children?: ChildFactory;\n /** Slot name → factory that renders and binds that slot's content once per mount. */\n slots?: Record<string, ChildFactory>;\n}\nexport interface DeferDesc {\n t: 'defer';\n pid: string;\n trigger: string;\n load: string;\n placeholder?: string;\n when?: string;\n priority?: string;\n timeout?: number;\n}\nexport interface ErrorDesc {\n t: 'error';\n pid: string;\n expr: string;\n}\nexport interface ProjDesc {\n t: 'proj';\n pid: string;\n name: string;\n fallback?: Factory;\n}\nexport interface IfDesc {\n t: 'if';\n pid: string;\n branches: { expr?: string; factory: Factory }[];\n}\nexport interface ForDesc {\n t: 'for';\n pid: string;\n item: string;\n index?: string;\n expr: string;\n trackBy?: string;\n factory: Factory;\n}\nexport interface SwitchDesc {\n t: 'switch';\n pid: string;\n expr: string;\n cases: { val?: string; factory: Factory }[];\n}\n\nexport type Desc =\n | EventDesc\n | InterpDesc\n | ClassDesc\n | ClassesDesc\n | StyleDesc\n | BoundDesc\n | RefDesc\n | BindDesc\n | CompDesc\n | DeferDesc\n | ErrorDesc\n | ProjDesc\n | IfDesc\n | ForDesc\n | SwitchDesc;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pithyjs/core",
3
- "version": "0.1.0-beta.11",
3
+ "version": "0.1.0-beta.13",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/PithyJS/pithyjs.git",
@@ -27,7 +27,7 @@
27
27
  "@pithyjs/shared": "0.1.0-beta.3",
28
28
  "@pithyjs/signals": "0.1.0-beta.2",
29
29
  "@pithyjs/compiler": "0.1.0-beta.4",
30
- "@pithyjs/design-system": "0.1.0-beta.6"
30
+ "@pithyjs/design-system": "0.1.0-beta.7"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "parse5": ">=7.0.0"