@pithyjs/core 0.1.0-beta.14 → 0.1.0-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/dist/compile/bindSwitchCases.d.ts.map +1 -1
- package/dist/compile/bindSwitchCases.js +14 -7
- package/dist/compile/bindSwitchCases.js.map +1 -1
- package/dist/compile/binds/bindAfterComponents.d.ts +4 -0
- package/dist/compile/binds/bindAfterComponents.d.ts.map +1 -0
- package/dist/compile/binds/bindAfterComponents.js +26 -0
- package/dist/compile/binds/bindAfterComponents.js.map +1 -0
- package/dist/compile/binds/bindAfterProjection.d.ts.map +1 -1
- package/dist/compile/binds/bindAfterProjection.js +2 -21
- package/dist/compile/binds/bindAfterProjection.js.map +1 -1
- package/dist/compile/binds/bindBoundAttributes.d.ts +4 -0
- package/dist/compile/binds/bindBoundAttributes.d.ts.map +1 -1
- package/dist/compile/binds/bindBoundAttributes.js +63 -3
- package/dist/compile/binds/bindBoundAttributes.js.map +1 -1
- package/dist/compile/binds/bindClassDirectives.d.ts.map +1 -1
- package/dist/compile/binds/bindClassDirectives.js +3 -2
- package/dist/compile/binds/bindClassDirectives.js.map +1 -1
- package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
- package/dist/compile/binds/bindComponentsTags.js +47 -11
- package/dist/compile/binds/bindComponentsTags.js.map +1 -1
- package/dist/compile/binds/bindDefaultTwoWay.d.ts.map +1 -1
- package/dist/compile/binds/bindDefaultTwoWay.js +2 -1
- package/dist/compile/binds/bindDefaultTwoWay.js.map +1 -1
- package/dist/compile/binds/bindDeferDirectives.d.ts.map +1 -1
- package/dist/compile/binds/bindDeferDirectives.js +17 -15
- package/dist/compile/binds/bindDeferDirectives.js.map +1 -1
- package/dist/compile/binds/bindErrorBoundary.d.ts +11 -1
- package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
- package/dist/compile/binds/bindErrorBoundary.js +50 -13
- package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
- package/dist/compile/binds/bindEventHandlers.d.ts.map +1 -1
- package/dist/compile/binds/bindEventHandlers.js +2 -1
- package/dist/compile/binds/bindEventHandlers.js.map +1 -1
- package/dist/compile/binds/bindRefDirectives.d.ts.map +1 -1
- package/dist/compile/binds/bindRefDirectives.js +2 -1
- package/dist/compile/binds/bindRefDirectives.js.map +1 -1
- package/dist/compile/binds/bindStyleDirectives.d.ts.map +1 -1
- package/dist/compile/binds/bindStyleDirectives.js +2 -1
- package/dist/compile/binds/bindStyleDirectives.js.map +1 -1
- package/dist/compile/binds/bindTextInterpolations.d.ts +2 -1
- package/dist/compile/binds/bindTextInterpolations.d.ts.map +1 -1
- package/dist/compile/binds/bindTextInterpolations.js +25 -14
- package/dist/compile/binds/bindTextInterpolations.js.map +1 -1
- package/dist/compile/binds/declaredDirective.d.ts +12 -0
- package/dist/compile/binds/declaredDirective.d.ts.map +1 -0
- package/dist/compile/binds/declaredDirective.js +42 -0
- package/dist/compile/binds/declaredDirective.js.map +1 -0
- package/dist/compile/binds/forwardedAttrs.d.ts +4 -2
- package/dist/compile/binds/forwardedAttrs.d.ts.map +1 -1
- package/dist/compile/binds/forwardedAttrs.js +10 -2
- package/dist/compile/binds/forwardedAttrs.js.map +1 -1
- package/dist/compile/binds/staleRowProps.d.ts +9 -0
- package/dist/compile/binds/staleRowProps.d.ts.map +1 -0
- package/dist/compile/binds/staleRowProps.js +86 -0
- package/dist/compile/binds/staleRowProps.js.map +1 -0
- package/dist/compile/compileNodes.d.ts.map +1 -1
- package/dist/compile/compileNodes.js +2 -0
- package/dist/compile/compileNodes.js.map +1 -1
- package/dist/compile/compileTemplate.d.ts.map +1 -1
- package/dist/compile/compileTemplate.js +2 -0
- package/dist/compile/compileTemplate.js.map +1 -1
- package/dist/compile/contentProjection.d.ts +3 -0
- package/dist/compile/contentProjection.d.ts.map +1 -1
- package/dist/compile/contentProjection.js +8 -0
- package/dist/compile/contentProjection.js.map +1 -1
- package/dist/compile/disposeOrder.d.ts +35 -0
- package/dist/compile/disposeOrder.d.ts.map +1 -0
- package/dist/compile/disposeOrder.js +81 -0
- package/dist/compile/disposeOrder.js.map +1 -0
- package/dist/compile/forLoops/bindForLoops.d.ts +1 -1
- package/dist/compile/forLoops/bindForLoops.d.ts.map +1 -1
- package/dist/compile/forLoops/bindForLoops.js +10 -3
- package/dist/compile/forLoops/bindForLoops.js.map +1 -1
- package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -1
- package/dist/compile/forLoops/createLoopManager.js +19 -2
- package/dist/compile/forLoops/createLoopManager.js.map +1 -1
- package/dist/compile/forLoops/loopSignals.d.ts.map +1 -1
- package/dist/compile/forLoops/loopSignals.js +15 -1
- package/dist/compile/forLoops/loopSignals.js.map +1 -1
- package/dist/compile/handleConditionalChain.d.ts.map +1 -1
- package/dist/compile/handleConditionalChain.js +2 -3
- package/dist/compile/handleConditionalChain.js.map +1 -1
- package/dist/compile/nodeExpando.d.ts +6 -0
- package/dist/compile/nodeExpando.d.ts.map +1 -1
- package/dist/compile/nodeExpando.js.map +1 -1
- package/dist/compile/pithyTreeToDom.js +1 -0
- package/dist/compile/pithyTreeToDom.js.map +1 -1
- package/dist/compile/renderBranch.d.ts +1 -1
- package/dist/compile/renderBranch.d.ts.map +1 -1
- package/dist/compile/renderBranch.js +5 -3
- package/dist/compile/renderBranch.js.map +1 -1
- package/dist/compile/renderChildren.d.ts.map +1 -1
- package/dist/compile/renderChildren.js +3 -2
- package/dist/compile/renderChildren.js.map +1 -1
- package/dist/runtime/applyBindings.d.ts.map +1 -1
- package/dist/runtime/applyBindings.js +5 -1
- package/dist/runtime/applyBindings.js.map +1 -1
- package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
- package/dist/runtime/bindings/applyComponent.js +19 -7
- package/dist/runtime/bindings/applyComponent.js.map +1 -1
- package/dist/runtime/bindings/applyDefer.d.ts.map +1 -1
- package/dist/runtime/bindings/applyDefer.js +10 -9
- package/dist/runtime/bindings/applyDefer.js.map +1 -1
- package/dist/runtime/bindings/applySimple.d.ts +2 -0
- package/dist/runtime/bindings/applySimple.d.ts.map +1 -1
- package/dist/runtime/bindings/applySimple.js +50 -10
- package/dist/runtime/bindings/applySimple.js.map +1 -1
- package/dist/runtime/bindings/applyStructural.d.ts.map +1 -1
- package/dist/runtime/bindings/applyStructural.js +11 -13
- package/dist/runtime/bindings/applyStructural.js.map +1 -1
- package/dist/runtime/bindings/helpers.d.ts +7 -0
- package/dist/runtime/bindings/helpers.d.ts.map +1 -1
- package/dist/runtime/bindings/helpers.js +35 -1
- package/dist/runtime/bindings/helpers.js.map +1 -1
- package/dist/runtime/bindings/index.d.ts +1 -1
- package/dist/runtime/bindings/index.d.ts.map +1 -1
- package/dist/runtime/bindings/index.js +1 -1
- package/dist/runtime/bindings/index.js.map +1 -1
- package/dist/runtime/html.d.ts.map +1 -1
- package/dist/runtime/html.js +2 -3
- package/dist/runtime/html.js.map +1 -1
- package/dist/types/globals.d.ts +2 -0
- package/dist/types/globals.d.ts.map +1 -1
- package/dist/types/globals.js.map +1 -1
- package/package.json +5 -5
|
@@ -4,6 +4,7 @@ import { flashUpdate } from './binds/bindTextInterpolations.js';
|
|
|
4
4
|
import { bindSwitchBlock, bindSwitchCases } from './bindSwitchCases.js';
|
|
5
5
|
import { bindTemplateDirectives } from './compileTemplate.js';
|
|
6
6
|
import { bindForLoops } from './forLoops/bindForLoops.js';
|
|
7
|
+
import { orderByDocument } from './disposeOrder.js';
|
|
7
8
|
import { pithyTreeToDom } from './pithyTreeToDom.js';
|
|
8
9
|
import { isSSRMode } from './ssrMode.js';
|
|
9
10
|
/**
|
|
@@ -33,6 +34,7 @@ export function renderBranch(ast, ctx, anchor) {
|
|
|
33
34
|
bindConditionals(children, rebuilt, ctx, processed, disposers);
|
|
34
35
|
bindForLoops(children, rebuilt, ctx, disposers, processed);
|
|
35
36
|
bindTemplateDirectives(fragment, ctx, disposers);
|
|
37
|
+
orderByDocument(disposers);
|
|
36
38
|
});
|
|
37
39
|
branch.nodes = Array.from(fragment.childNodes);
|
|
38
40
|
anchor.parentNode.insertBefore(fragment, anchor.nextSibling);
|
|
@@ -46,11 +48,11 @@ export function renderBranch(ast, ctx, anchor) {
|
|
|
46
48
|
}
|
|
47
49
|
return branch;
|
|
48
50
|
}
|
|
49
|
-
/** Disposes a branch's effects, then removes its nodes. */
|
|
51
|
+
/** Disposes a branch's effects, last registered first, then removes its nodes. */
|
|
50
52
|
export function clearBranch(branch) {
|
|
51
|
-
for (
|
|
53
|
+
for (let i = branch.disposers.length - 1; i >= 0; i--) {
|
|
52
54
|
try {
|
|
53
|
-
|
|
55
|
+
branch.disposers[i]();
|
|
54
56
|
}
|
|
55
57
|
catch {
|
|
56
58
|
/* ignore */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderBranch.js","sourceRoot":"","sources":["../../src/compile/renderBranch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAOtC;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,GAAc,EACd,GAA4B,EAC5B,MAAY;IAEZ,MAAM,MAAM,GAAW,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IACpD,MAAM,OAAO,GAAG,cAAc,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,UAA4B,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CAAC;YACP,YAAY;QACd,CAAC;IACH,CAAC;IACD,MAAM,CAAC,SAAS,GAAG,EAAE,CAAC;IACtB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAChC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IACD,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;AACpB,CAAC","sourcesContent":["import type { PithyNode } from '@pithyjs/compiler';\nimport { createRoot } from '@pithyjs/signals';\nimport { bindConditionals } from './binds/bindConditionals';\nimport { flashUpdate } from './binds/bindTextInterpolations';\nimport { bindSwitchBlock, bindSwitchCases } from './bindSwitchCases';\nimport { bindTemplateDirectives } from './compileTemplate';\nimport { bindForLoops } from './forLoops/bindForLoops';\nimport { orderByDocument } from './disposeOrder';\nimport { pithyTreeToDom } from './pithyTreeToDom';\nimport { isSSRMode } from './ssrMode';\n\nexport interface Branch {\n nodes: Node[];\n disposers: (() => void)[];\n}\n\n/**\n * Builds the DOM for one `@if` or `@case` branch from its AST, binds it, and\n * inserts it after `anchor`.\n */\nexport function renderBranch(\n ast: PithyNode,\n ctx: Record<string, unknown>,\n anchor: Node\n): Branch {\n const branch: Branch = { nodes: [], disposers: [] };\n const rebuilt = pithyTreeToDom([ast], ctx).firstChild as Element | null;\n if (!rebuilt || !anchor.parentNode) return branch;\n\n // A component tag is replaced by what it renders while binding, so the\n // fragment, not `rebuilt`, holds the nodes to insert and later remove.\n const fragment = document.createDocumentFragment();\n fragment.appendChild(rebuilt);\n const children = ast.isComponent ? [] : ast.children || [];\n const { disposers } = branch;\n\n createRoot(disposeRoot => {\n disposers.push(disposeRoot);\n const processed = new Set<string>();\n if (ast.directives?.switch !== undefined) {\n bindSwitchBlock(ast, rebuilt, ctx, processed, disposers);\n } else {\n bindSwitchCases(children, rebuilt, ctx, processed, disposers);\n }\n bindConditionals(children, rebuilt, ctx, processed, disposers);\n bindForLoops(children, rebuilt, ctx, disposers, processed);\n bindTemplateDirectives(fragment, ctx, disposers);\n orderByDocument(disposers);\n });\n\n branch.nodes = Array.from(fragment.childNodes);\n anchor.parentNode.insertBefore(fragment, anchor.nextSibling);\n\n if (!isSSRMode()) {\n queueMicrotask(() => {\n for (const node of branch.nodes) {\n if (node.nodeType === Node.ELEMENT_NODE) flashUpdate(node as Element);\n }\n });\n }\n return branch;\n}\n\n/** Disposes a branch's effects, last registered first, then removes its nodes. */\nexport function clearBranch(branch: Branch): void {\n for (let i = branch.disposers.length - 1; i >= 0; i--) {\n try {\n branch.disposers[i]();\n } catch {\n /* ignore */\n }\n }\n branch.disposers = [];\n for (const node of branch.nodes) {\n node.parentNode?.removeChild(node);\n }\n branch.nodes = [];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderChildren.d.ts","sourceRoot":"","sources":["../../src/compile/renderChildren.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAgB,KAAK,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderChildren.d.ts","sourceRoot":"","sources":["../../src/compile/renderChildren.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAgB,KAAK,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGjE,KAAK,YAAY,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAE5D;;;;;;;;;;;;;;;;GAgBG;AACH,wKAAwK;AACxK,wBAAgB,cAAc,IAAI;IAChC,EAAE,EAAE,gBAAgB,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CA+CA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,yKAAyK;AACzK,wBAAgB,eAAe,IAAI;IACjC,EAAE,EAAE,gBAAgB,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CASA;AASD,+IAA+I;AAC/I,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,qBAAqB,GAAG,SAAS,CAAC;IAC3C,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,2EAA2E;IAC3E,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,iDAAiD;IACjD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;GAKG;AACH,+IAA+I;AAC/I,wBAAgB,gBAAgB,IAAI,YAAY,CAa/C"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { compileNodes } from './compileNodes.js';
|
|
2
2
|
import { pithyGlobals } from '../types/globals.js';
|
|
3
3
|
import { outerSlotMap } from './contentProjection.js';
|
|
4
|
+
import { withSlotBoundary } from './binds/bindErrorBoundary.js';
|
|
4
5
|
/**
|
|
5
6
|
* If the registry renderer has set `globalThis.__pithyProjectedChildren` (a
|
|
6
7
|
* `DocumentFragment` of already-rendered slot children), returns and clears it —
|
|
@@ -50,13 +51,13 @@ export function renderChildren() {
|
|
|
50
51
|
const childAstNodes = componentCtx?.__childAstNodes ?? [];
|
|
51
52
|
// Strip internal __ properties, keep parent scope (includes components, signals, etc.)
|
|
52
53
|
const parentCtx = componentCtx
|
|
53
|
-
? Object.fromEntries(Object.entries(componentCtx).filter(([k]) => !k.startsWith('__')))
|
|
54
|
+
? Object.fromEntries(Object.entries(componentCtx).filter(([k]) => !k.startsWith('__') || k === '__pithyRowLocals'))
|
|
54
55
|
: {};
|
|
55
56
|
// What a `<slot>` among the children receives.
|
|
56
57
|
const outer = outerSlotMap(componentCtx?.__slotMap);
|
|
57
58
|
if (outer)
|
|
58
59
|
parentCtx.__slotMap = outer;
|
|
59
|
-
return compileNodes(childAstNodes, parentCtx);
|
|
60
|
+
return withSlotBoundary(undefined, componentCtx?.__slotHost, () => compileNodes(childAstNodes, parentCtx));
|
|
60
61
|
}
|
|
61
62
|
/**
|
|
62
63
|
* Captures projected children and clears the component context so
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderChildren.js","sourceRoot":"","sources":["../../src/compile/renderChildren.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAA8B,MAAM,kBAAkB,CAAC;AAE5E,OAAO,EAAE,YAAY,EAAgB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderChildren.js","sourceRoot":"","sources":["../../src/compile/renderChildren.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAA8B,MAAM,kBAAkB,CAAC;AAE5E,OAAO,EAAE,YAAY,EAAgB,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAI7D;;;;;;;;;;;;;;;;GAgBG;AACH,wKAAwK;AACxK,MAAM,UAAU,cAAc;IAI5B,MAAM,WAAW,GAAG,YAAY,EAAE,CAAC;IACnC,MAAM,QAAQ,GAAG,WAAW,CAAC,wBAAwB,CAAC;IACtD,IAAI,QAAQ,EAAE,CAAC;QACb,WAAW,CAAC,wBAAwB,GAAG,SAAS,CAAC;QACjD,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAA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C,CAAC,wBAAwB;QACrC,IAAI,EAAE,gBAAgB,CAAC,OAAO,CAAC;QAC/B,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC;KACxC,CAAC;AACJ,CAAC","sourcesContent":["import { compileNodes } from './compileNodes';\nimport type { PithyNode } from '@pithyjs/compiler';\nimport { pithyGlobals, type PithyComponentContext } from '../types/globals';\nimport type { ChildFactory } from '../runtime/bindings/types';\nimport { outerSlotMap, type SlotMap } from './contentProjection';\nimport { withSlotBoundary } from './binds/bindErrorBoundary';\n\ntype SlotRenderer = NonNullable<ReturnType<SlotMap['get']>>;\n\n/**\n * If the registry renderer has set `globalThis.__pithyProjectedChildren` (a\n * `DocumentFragment` of already-rendered slot children), returns and clears it —\n * single-consume, so the first caller wins. This delivers construction-time\n * children on the registry path. The registry path has no AST fallback, so a\n * second `renderChildren()`/`captureChildren()` call returns an empty fragment.\n *\n * A build-compiled parent's default slot is rendered afresh on every call.\n *\n * Otherwise compiles child AST nodes from the current component context through\n * the full pipeline (structural + non-structural directives). This enables\n * nested components inside projected content — unlike `<slot>`, which inserts\n * DOM after `bindComponentTags` has already run.\n *\n * Use inside component functions (Stack, Grid, etc.) that need to compile\n * their children without named slots or fallback content.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"renderChildren\",\"stability\":\"stable\",\"signature\":\"() => { el: DocumentFragment; destroy: () => void }\"} */\nexport function renderChildren(): {\n el: DocumentFragment;\n destroy: () => void;\n} {\n const globalScope = pithyGlobals();\n const injected = globalScope.__pithyProjectedChildren;\n if (injected) {\n globalScope.__pithyProjectedChildren = undefined;\n return { el: injected, destroy: () => {} };\n }\n\n const componentCtx = pithyGlobals().__pithyComponentContext;\n const slot = buildDefaultSlot(componentCtx);\n if (slot) {\n const disposers: (() => void)[] = [];\n const el = slot(disposers);\n return {\n el,\n destroy: () => {\n for (let i = disposers.length - 1; i >= 0; i--) disposers[i]();\n disposers.length = 0;\n },\n };\n }\n\n // A parent composing atoms by direct call after captureChildren() cleared its\n // context is still mid-render (`rendering` truthy) — not the misuse this guards\n // against, so a consumed context alone must not trigger the warning.\n const rendering = pithyGlobals().__pithyRenderingComponent;\n if (import.meta.env?.DEV && !componentCtx && !rendering) {\n console.warn('[renderChildren] Called outside component render context');\n }\n\n const childAstNodes: PithyNode[] = componentCtx?.__childAstNodes ?? [];\n\n // Strip internal __ properties, keep parent scope (includes components, signals, etc.)\n const parentCtx: Record<string, unknown> = componentCtx\n ? Object.fromEntries(\n Object.entries(componentCtx).filter(\n ([k]) => !k.startsWith('__') || k === '__pithyRowLocals'\n )\n )\n : {};\n // What a `<slot>` among the children receives.\n const outer = outerSlotMap(componentCtx?.__slotMap);\n if (outer) parentCtx.__slotMap = outer;\n\n return withSlotBoundary(undefined, componentCtx?.__slotHost, () =>\n compileNodes(childAstNodes, parentCtx)\n );\n}\n\n/**\n * Captures projected children and clears the component context so\n * inner component calls (e.g. `Heading()`, `Text()`) don't consume\n * the outer component's children.\n *\n * After capture, the current component's context on `globalThis` is\n * reset to the value of `__parentComponentContext` if present, or\n * otherwise to `undefined`. In the current core implementation,\n * `__parentComponentContext` is not set by the runtime, so this\n * effectively clears the active component context to prevent child\n * leakage into inner component calls.\n *\n * **Important invariant:** This function must be called exactly once per\n * component, before any inner component function calls. It consumes the\n * current context's children — a second call would return an empty fragment.\n * After this call, the caller must not rely on reading its own context\n * properties from `globalThis.__pithyComponentContext`.\n *\n * For 3+ levels of nesting (e.g., section A → section B → atoms), each\n * level should call `captureChildren()` independently. Any multi-level\n * parent restoration depends on `__parentComponentContext` being managed\n * by external tooling; the core library only performs a best-effort reset\n * from that property when present.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"captureChildren\",\"stability\":\"stable\",\"signature\":\"() => { el: DocumentFragment; destroy: () => void }\"} */\nexport function captureChildren(): {\n el: DocumentFragment;\n destroy: () => void;\n} {\n const g = pithyGlobals();\n const prevCtx = g.__pithyComponentContext;\n const result = renderChildren();\n // Clear context so inner component calls start fresh.\n // If there was a parent context, it will be restored by the parent's\n // own render cycle — we only need to prevent child leakage here.\n g.__pithyComponentContext = prevCtx?.__parentComponentContext ?? undefined;\n return result;\n}\n\n/** Default-slot renderer of a build-compiled parent; it has no AST. */\nfunction buildDefaultSlot(ctx: PithyComponentContext | undefined) {\n return ctx && !ctx.__childAstNodes && !ctx.__childFactory\n ? ctx.__slotMap?.get('')\n : undefined;\n}\n\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"ChildPayload\",\"stability\":\"experimental\",\"signature\":\"interface ChildPayload\"} */\nexport interface ChildPayload {\n context: PithyComponentContext | undefined;\n factory?: ChildFactory;\n astNodes?: PithyNode[];\n projected?: DocumentFragment;\n /** A build's default slot, rendered by `renderChildren()` on each call. */\n slot?: SlotRenderer;\n /** What a `<slot>` among `astNodes` receives. */\n outer?: SlotMap;\n}\n\n/**\n * Reads the children addressed to the component being rendered, without\n * consuming them. `factory` and `astNodes` are mutually exclusive: an AOT child\n * factory wins, because a JIT parent's AST can reach an AOT component's context\n * through `mergeContexts`, never the reverse.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"readChildPayload\",\"stability\":\"experimental\",\"signature\":\"() => ChildPayload\"} */\nexport function readChildPayload(): ChildPayload {\n const g = pithyGlobals();\n const context = g.__pithyComponentContext;\n const factory = context?.__childFactory;\n const ast = context?.__childAstNodes;\n return {\n context,\n factory,\n astNodes: !factory && ast && ast.length > 0 ? ast : undefined,\n projected: g.__pithyProjectedChildren,\n slot: buildDefaultSlot(context),\n outer: outerSlotMap(context?.__slotMap),\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyBindings.d.ts","sourceRoot":"","sources":["../../src/runtime/applyBindings.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;
|
|
1
|
+
{"version":3,"file":"applyBindings.d.ts","sourceRoot":"","sources":["../../src/runtime/applyBindings.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAOF,OAAO,EAqBL,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,MAAM,EACX,KAAK,OAAO,EACZ,KAAK,UAAU,EAChB,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,IAAI,EACJ,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,QAAQ,EACR,MAAM,EACN,OAAO,EACP,UAAU,GACX,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,8RAA8R;AAC9R,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,IAAI,EAAE,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,oBAAoB,UAAO,GAC1B;IAAE,EAAE,EAAE,gBAAgB,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CA4L/C"}
|
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
import { drainDestroyCallbacks } from './onDestroy.js';
|
|
9
9
|
import { clearSSRRenderCrash } from '../compile/ssrCrashes.js';
|
|
10
10
|
import { nodeExpando } from '../compile/nodeExpando.js';
|
|
11
|
+
import { orderByDocument } from '../compile/disposeOrder.js';
|
|
11
12
|
import { executeCustomDirectiveBinders } from '../compile/binds/directiveRegistry.js';
|
|
12
|
-
import { buildPidMap, buildCommentMap, mergeContexts, nearestCtx, applyRef, applyError, applyProjection, applyComponent, applyBind, applyInterpolation, applyEvent, applyClass, applyClasses, applyStyle, applyBound, applyIf, applyFor, applySwitch, applyDefer, } from './bindings/index.js';
|
|
13
|
+
import { buildPidMap, buildCommentMap, mergeContexts, nearestCtx, applyRef, applyError, applyProjection, applyComponent, applyBind, applyInterpolation, markSkeletonText, applyEvent, applyClass, applyClasses, applyStyle, applyBound, applyIf, applyFor, applySwitch, applyDefer, } from './bindings/index.js';
|
|
13
14
|
// ─── Main entry point ─────────────────────────────────────────────────────────
|
|
14
15
|
/**
|
|
15
16
|
* Applies pre-extracted binding descriptors to an AOT-generated DOM fragment.
|
|
@@ -56,6 +57,8 @@ export function __applyBindings(fragment, bindings, context, ownsDestroyCallback
|
|
|
56
57
|
}
|
|
57
58
|
return bindingsResult(fragment, disposers, destroyCallbacks);
|
|
58
59
|
}
|
|
60
|
+
if (bindings.some(d => d.t === 'interp'))
|
|
61
|
+
markSkeletonText(fragment);
|
|
59
62
|
// Build lookup maps
|
|
60
63
|
const pidMap = buildPidMap(fragment);
|
|
61
64
|
const commentMap = buildCommentMap(fragment);
|
|
@@ -206,6 +209,7 @@ export function __applyBindings(fragment, bindings, context, ownsDestroyCallback
|
|
|
206
209
|
if (el)
|
|
207
210
|
applyDefer(d, el, ctx, disposers);
|
|
208
211
|
}
|
|
212
|
+
orderByDocument(disposers);
|
|
209
213
|
}
|
|
210
214
|
catch (err) {
|
|
211
215
|
unwind(disposers, destroyCallbacks);
|
|
@@ -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,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,EACV,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ACH,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 { executeCustomDirectiveBinders } from '../compile/binds/directiveRegistry';\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 →\n * custom directives → defer\n *\n * Differences from JIT bindTemplateDirectives:\n * - AOT has an explicit `style` phase (JIT folds inline styles into bound attrs)\n *\n * Custom directives (registered via `registerDirectiveBinder`, e.g. the\n * router's `@routerLink`) run even when `bindings` is empty: codegen emits no\n * descriptor for them, only the `data-*` marker attribute.\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\n // Merge parent component + async (SSR) contexts — AOT factories bypass html().\n // Before the empty-bindings branch: custom binders must see the same context\n // whether or not the template also carries an ordinary descriptor.\n const ctx = mergeContexts(context);\n\n if (bindings.length === 0) {\n try {\n executeCustomDirectiveBinders(fragment, ctx, disposers);\n } catch (err) {\n unwind(disposers, destroyCallbacks);\n throw err;\n }\n return bindingsResult(fragment, disposers, destroyCallbacks);\n }\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 executeCustomDirectiveBinders(fragment, ctx, disposers);\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 unwind(disposers, destroyCallbacks);\n throw err;\n }\n\n return bindingsResult(fragment, disposers, destroyCallbacks);\n}\n\n/** Runs everything registered so far after a partial bind fails. */\nfunction unwind(\n disposers: (() => void)[],\n destroyCallbacks: (() => void)[]\n): void {\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}\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,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,EACV,QAAQ,EACR,UAAU,EACV,eAAe,EACf,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EACX,UAAU,GAiBX,MAAM,YAAY,CAAC;AAsBpB,iFAAiF;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;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;IAErC,+EAA+E;IAC/E,6EAA6E;IAC7E,mEAAmE;IACnE,MAAM,GAAG,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAEnC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B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C,EAAE,EAAE,CAAC;QACtD,IAAI,CAAC;YACH,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,YAAY;QACd,CAAC;IACH,CAAC;AACH,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 { orderByDocument } from '../compile/disposeOrder';\nimport { executeCustomDirectiveBinders } from '../compile/binds/directiveRegistry';\nimport {\n buildPidMap,\n buildCommentMap,\n mergeContexts,\n nearestCtx,\n applyRef,\n applyError,\n applyProjection,\n applyComponent,\n applyBind,\n applyInterpolation,\n markSkeletonText,\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 →\n * custom directives → defer\n *\n * Differences from JIT bindTemplateDirectives:\n * - AOT has an explicit `style` phase (JIT folds inline styles into bound attrs)\n *\n * Custom directives (registered via `registerDirectiveBinder`, e.g. the\n * router's `@routerLink`) run even when `bindings` is empty: codegen emits no\n * descriptor for them, only the `data-*` marker attribute.\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\n // Merge parent component + async (SSR) contexts — AOT factories bypass html().\n // Before the empty-bindings branch: custom binders must see the same context\n // whether or not the template also carries an ordinary descriptor.\n const ctx = mergeContexts(context);\n\n if (bindings.length === 0) {\n try {\n executeCustomDirectiveBinders(fragment, ctx, disposers);\n } catch (err) {\n unwind(disposers, destroyCallbacks);\n throw err;\n }\n return bindingsResult(fragment, disposers, destroyCallbacks);\n }\n\n if (bindings.some(d => d.t === 'interp')) markSkeletonText(fragment);\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 executeCustomDirectiveBinders(fragment, ctx, disposers);\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 orderByDocument(disposers);\n } catch (err) {\n unwind(disposers, destroyCallbacks);\n throw err;\n }\n\n return bindingsResult(fragment, disposers, destroyCallbacks);\n}\n\n/** Runs everything registered so far after a partial bind fails. */\nfunction unwind(\n disposers: (() => void)[],\n destroyCallbacks: (() => void)[]\n): void {\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}\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":"
|
|
1
|
+
{"version":3,"file":"applyComponent.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/applyComponent.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAgB,MAAM,SAAS,CAAC;AAyItE,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,CAwQpB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { compileExpression } from '../../compile/compileExpression.js';
|
|
2
|
-
import { boundaryForElement, runWithBoundary, withSlotBoundary, slotContentHidden, } from '../../compile/binds/bindErrorBoundary.js';
|
|
2
|
+
import { boundaryForElement, replaceHidden, runWithBoundary, withSlotBoundary, slotContentHidden, } from '../../compile/binds/bindErrorBoundary.js';
|
|
3
3
|
import { linkOuterSlotMap, } from '../../compile/contentProjection.js';
|
|
4
4
|
import { collectForwardedAttrs, applyForwardedAttrs, } from '../../compile/binds/forwardedAttrs.js';
|
|
5
5
|
import { nativeTags } from '@pithyjs/compiler';
|
|
@@ -12,7 +12,9 @@ import { isRenderableComponentEl } from '../../compile/componentResult.js';
|
|
|
12
12
|
import { clearSSRRenderCrash, reportComponentFailure, } from '../../compile/ssrCrashes.js';
|
|
13
13
|
import { isolateDestroyCallbacks } from '../onDestroy.js';
|
|
14
14
|
import { parsePropNames } from '../../compile/binds/propNames.js';
|
|
15
|
+
import { watchStaleRowProp } from '../../compile/binds/staleRowProps.js';
|
|
15
16
|
import { nodeExpando } from '../../compile/nodeExpando.js';
|
|
17
|
+
import { anchorDisposer, componentDisposer } from '../../compile/disposeOrder.js';
|
|
16
18
|
/** Map kebab-case or lowered DOM attr name to expected camelCase prop name. */
|
|
17
19
|
function normalizePropName(authored, expectedProps) {
|
|
18
20
|
if (expectedProps.includes(authored))
|
|
@@ -58,7 +60,7 @@ function renderSlot(factory, ctx, disposers, anchor, host) {
|
|
|
58
60
|
g.__pithyComponentContext = undefined;
|
|
59
61
|
try {
|
|
60
62
|
const { el, destroy } = withSlotBoundary(anchor, host, () => isolateDestroyCallbacks(() => factory(ctx)));
|
|
61
|
-
disposers.push(destroy);
|
|
63
|
+
disposers.push(anchorDisposer(destroy, anchor ?? el.firstChild));
|
|
62
64
|
// Bound already: a runtime-compiled child's binders must not bind it again.
|
|
63
65
|
el.childNodes.forEach(node => (nodeExpando(node).__pithyComponentDom = true));
|
|
64
66
|
return el;
|
|
@@ -154,11 +156,16 @@ export function applyComponent(d, el, ctx, disposers, pidMap, scope) {
|
|
|
154
156
|
const expectedProps = extractExpectedPropNames(componentFn);
|
|
155
157
|
// Evaluate prop expressions with prop name normalization
|
|
156
158
|
const props = {};
|
|
159
|
+
const staleWatchers = [];
|
|
157
160
|
for (const [rawName, expr] of Object.entries(d.props)) {
|
|
158
161
|
const propName = normalizePropName(rawName, expectedProps);
|
|
159
162
|
try {
|
|
160
163
|
const fn = compileExpression(expr, localCtx);
|
|
161
164
|
props[propName] = untrack(fn);
|
|
165
|
+
if (import.meta.env?.DEV) {
|
|
166
|
+
const value = props[propName];
|
|
167
|
+
staleWatchers.push(() => watchStaleRowProp(localCtx, d, d.tag, propName, expr, value, fn, disposers));
|
|
168
|
+
}
|
|
162
169
|
}
|
|
163
170
|
catch {
|
|
164
171
|
// Leave undefined — child uses defaults
|
|
@@ -186,6 +193,7 @@ export function applyComponent(d, el, ctx, disposers, pidMap, scope) {
|
|
|
186
193
|
__slotMap: slotMap,
|
|
187
194
|
__childAstNodes: undefined,
|
|
188
195
|
__childFactory: childFactory,
|
|
196
|
+
__slotHost: el,
|
|
189
197
|
};
|
|
190
198
|
// Find nearest error boundary
|
|
191
199
|
const boundaryEl = el.closest('[data-error]');
|
|
@@ -272,7 +280,9 @@ export function applyComponent(d, el, ctx, disposers, pidMap, scope) {
|
|
|
272
280
|
: [renderedEl];
|
|
273
281
|
let replaced = true;
|
|
274
282
|
try {
|
|
275
|
-
el
|
|
283
|
+
// A boundary that caught a crash in this render may have hidden `el`.
|
|
284
|
+
if (!replaceHidden(el, nodes))
|
|
285
|
+
el.replaceWith(...nodes);
|
|
276
286
|
}
|
|
277
287
|
catch (err) {
|
|
278
288
|
// The raw <${d.tag}> is left exactly where a crash would have left it, so
|
|
@@ -311,10 +321,12 @@ export function applyComponent(d, el, ctx, disposers, pidMap, scope) {
|
|
|
311
321
|
}
|
|
312
322
|
pidMap.delete(d.pid);
|
|
313
323
|
}
|
|
314
|
-
if (
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
324
|
+
if (replaced)
|
|
325
|
+
for (const watch of staleWatchers)
|
|
326
|
+
watch();
|
|
327
|
+
const teardown = componentDisposer(destroy, disposeSetup, nodes[0] ?? (replaced ? null : el));
|
|
328
|
+
if (teardown)
|
|
329
|
+
disposers.push(teardown);
|
|
318
330
|
return replaced ? nodes : undefined;
|
|
319
331
|
}
|
|
320
332
|
//# sourceMappingURL=applyComponent.js.map
|
|
@@ -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,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,gBAAgB,GAEjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,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AM,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 {\n linkOuterSlotMap,\n type SlotMap,\n} 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 linkOuterSlotMap(slotMap, localCtx);\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"]}
|
|
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,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,gBAAgB,GAEjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EACL,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE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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,QAAQ;QAAE,KAAK,MAAM,KAAK,IAAI,aAAa;YAAE,KAAK,EAAE,CAAC;IAEzD,MAAM,QAAQ,GAAG,iBAAiB,CAChC,OAAO,EACP,YAAY,EACZ,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CACnC,CAAC;IACF,IAAI,QAAQ;QAAE,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvC,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACtC,CAAC","sourcesContent":["import { compileExpression } from '../../compile/compileExpression';\nimport {\n boundaryForElement,\n replaceHidden,\n runWithBoundary,\n withSlotBoundary,\n slotContentHidden,\n} from '../../compile/binds/bindErrorBoundary';\nimport {\n linkOuterSlotMap,\n type SlotMap,\n} 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 { watchStaleRowProp } from '../../compile/binds/staleRowProps';\nimport { nodeExpando } from '../../compile/nodeExpando';\nimport { anchorDisposer, componentDisposer } from '../../compile/disposeOrder';\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(anchorDisposer(destroy, anchor ?? el.firstChild));\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 const staleWatchers: (() => void)[] = [];\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 if (import.meta.env?.DEV) {\n const value = props[propName];\n staleWatchers.push(() =>\n watchStaleRowProp(\n localCtx,\n d,\n d.tag,\n propName,\n expr,\n value,\n fn,\n disposers\n )\n );\n }\n } catch {\n // Leave undefined — child uses defaults\n }\n }\n\n const slotMap: SlotMap = new Map();\n linkOuterSlotMap(slotMap, localCtx);\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 __slotHost: el,\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 // A boundary that caught a crash in this render may have hidden `el`.\n if (!replaceHidden(el, nodes)) 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 (replaced) for (const watch of staleWatchers) watch();\n\n const teardown = componentDisposer(\n destroy,\n disposeSetup,\n nodes[0] ?? (replaced ? null : el)\n );\n if (teardown) disposers.push(teardown);\n return replaced ? nodes : undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyDefer.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/applyDefer.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"applyDefer.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/applyDefer.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAUzD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,CAAC,EAAE,SAAS,EACZ,OAAO,EAAE,WAAW,EACpB,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAkfN"}
|
|
@@ -7,6 +7,7 @@ import { isLazyHandle } from '../lazy.js';
|
|
|
7
7
|
import { observeVisibilityOnce, DEFAULT_VISIBILITY_MARGIN, } from '@pithyjs/shared';
|
|
8
8
|
import { nearestCtx } from './helpers.js';
|
|
9
9
|
import { loadWithTimeout, scheduleByPriority } from '../deferHelpers.js';
|
|
10
|
+
import { setStyleProp } from '../../compile/binds/bindBoundAttributes.js';
|
|
10
11
|
// ─── Defer directive handler ──────────────────────────────────────────────────
|
|
11
12
|
/** Unique ID counter for defer elements (AOT path). */
|
|
12
13
|
let aotDeferIdCounter = 0;
|
|
@@ -138,7 +139,7 @@ export function applyDefer(d, element, ctx, disposers) {
|
|
|
138
139
|
errorEl = slotError;
|
|
139
140
|
errorEl.removeAttribute('slot');
|
|
140
141
|
errorEl.setAttribute('data-defer-error', deferId);
|
|
141
|
-
errorEl
|
|
142
|
+
setStyleProp(errorEl, 'display', 'none');
|
|
142
143
|
}
|
|
143
144
|
// ─── Insert placeholder into DOM ────────────────────────────────
|
|
144
145
|
const parent = element.parentNode;
|
|
@@ -147,7 +148,7 @@ export function applyDefer(d, element, ctx, disposers) {
|
|
|
147
148
|
if (placeholderEl) {
|
|
148
149
|
// For @defer="when", placeholder starts hidden (only shows during loading)
|
|
149
150
|
if (trigger === 'when' && placeholderEl instanceof HTMLElement) {
|
|
150
|
-
placeholderEl
|
|
151
|
+
setStyleProp(placeholderEl, 'display', 'none');
|
|
151
152
|
}
|
|
152
153
|
parent.insertBefore(placeholderEl, element);
|
|
153
154
|
}
|
|
@@ -155,7 +156,7 @@ export function applyDefer(d, element, ctx, disposers) {
|
|
|
155
156
|
parent.insertBefore(errorEl, element);
|
|
156
157
|
}
|
|
157
158
|
// Hide the original element
|
|
158
|
-
element
|
|
159
|
+
setStyleProp(element, 'display', 'none');
|
|
159
160
|
// ─── Mount lifecycle state ────────────────────────────────────────
|
|
160
161
|
let mountedDestroy = null;
|
|
161
162
|
let disposeMountedSetup = null;
|
|
@@ -205,7 +206,7 @@ export function applyDefer(d, element, ctx, disposers) {
|
|
|
205
206
|
insertedNodes = [];
|
|
206
207
|
isMounted = false;
|
|
207
208
|
if (placeholderEl && placeholderEl instanceof HTMLElement) {
|
|
208
|
-
placeholderEl
|
|
209
|
+
setStyleProp(placeholderEl, 'display', 'none');
|
|
209
210
|
}
|
|
210
211
|
element.setAttribute('data-defer-state', 'pending');
|
|
211
212
|
}
|
|
@@ -225,14 +226,14 @@ export function applyDefer(d, element, ctx, disposers) {
|
|
|
225
226
|
setBoundaryError(boundary, error);
|
|
226
227
|
}
|
|
227
228
|
else if (errorEl) {
|
|
228
|
-
errorEl
|
|
229
|
+
setStyleProp(errorEl, 'display', null);
|
|
229
230
|
}
|
|
230
231
|
element.dispatchEvent(new CustomEvent('error', {
|
|
231
232
|
detail: {
|
|
232
233
|
error,
|
|
233
234
|
retry: () => {
|
|
234
235
|
if (errorEl)
|
|
235
|
-
errorEl
|
|
236
|
+
setStyleProp(errorEl, 'display', 'none');
|
|
236
237
|
void mountComponent();
|
|
237
238
|
},
|
|
238
239
|
},
|
|
@@ -251,7 +252,7 @@ export function applyDefer(d, element, ctx, disposers) {
|
|
|
251
252
|
element.setAttribute('data-defer-state', 'loading');
|
|
252
253
|
// Show placeholder during loading
|
|
253
254
|
if (placeholderEl && placeholderEl instanceof HTMLElement) {
|
|
254
|
-
placeholderEl
|
|
255
|
+
setStyleProp(placeholderEl, 'display', null);
|
|
255
256
|
}
|
|
256
257
|
try {
|
|
257
258
|
const effectiveTimeout = typeof timeout === 'number' && Number.isFinite(timeout) && timeout > 0
|
|
@@ -390,7 +391,7 @@ export function applyDefer(d, element, ctx, disposers) {
|
|
|
390
391
|
!isMounting &&
|
|
391
392
|
elementState === 'error') {
|
|
392
393
|
if (errorEl)
|
|
393
|
-
errorEl
|
|
394
|
+
setStyleProp(errorEl, 'display', 'none');
|
|
394
395
|
mountComponent();
|
|
395
396
|
}
|
|
396
397
|
});
|
|
@@ -438,7 +439,7 @@ export function applyDefer(d, element, ctx, disposers) {
|
|
|
438
439
|
unmountComponent();
|
|
439
440
|
}
|
|
440
441
|
if (errorEl)
|
|
441
|
-
errorEl
|
|
442
|
+
setStyleProp(errorEl, 'display', 'none');
|
|
442
443
|
}
|
|
443
444
|
});
|
|
444
445
|
disposers.push(() => {
|