@pithyjs/core 0.1.0-beta.23 → 0.1.0-beta.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +2 -0
  2. package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
  3. package/dist/compile/binds/bindComponentsTags.js +21 -10
  4. package/dist/compile/binds/bindComponentsTags.js.map +1 -1
  5. package/dist/compile/binds/bindDeferDirectives.d.ts +3 -3
  6. package/dist/compile/binds/bindDeferDirectives.d.ts.map +1 -1
  7. package/dist/compile/binds/bindDeferDirectives.js +7 -5
  8. package/dist/compile/binds/bindDeferDirectives.js.map +1 -1
  9. package/dist/compile/binds/bindErrorBoundary.d.ts +6 -2
  10. package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
  11. package/dist/compile/binds/bindErrorBoundary.js +86 -20
  12. package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
  13. package/dist/compile/contentProjection.d.ts +14 -2
  14. package/dist/compile/contentProjection.d.ts.map +1 -1
  15. package/dist/compile/contentProjection.js +42 -4
  16. package/dist/compile/contentProjection.js.map +1 -1
  17. package/dist/compile/nodeExpando.d.ts +1 -0
  18. package/dist/compile/nodeExpando.d.ts.map +1 -1
  19. package/dist/compile/nodeExpando.js.map +1 -1
  20. package/dist/compile/ssrCrashes.d.ts.map +1 -1
  21. package/dist/compile/ssrCrashes.js +76 -20
  22. package/dist/compile/ssrCrashes.js.map +1 -1
  23. package/dist/runtime/applyBindings.d.ts +6 -0
  24. package/dist/runtime/applyBindings.d.ts.map +1 -1
  25. package/dist/runtime/applyBindings.js +6 -0
  26. package/dist/runtime/applyBindings.js.map +1 -1
  27. package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
  28. package/dist/runtime/bindings/applyComponent.js +3 -1
  29. package/dist/runtime/bindings/applyComponent.js.map +1 -1
  30. package/dist/runtime/bindings/applyDefer.js +2 -2
  31. package/dist/runtime/bindings/applyDefer.js.map +1 -1
  32. package/dist/runtime/bindings/applySimple.d.ts.map +1 -1
  33. package/dist/runtime/bindings/applySimple.js +10 -4
  34. package/dist/runtime/bindings/applySimple.js.map +1 -1
  35. package/dist/runtime/bindings/helpers.d.ts.map +1 -1
  36. package/dist/runtime/bindings/helpers.js +2 -1
  37. package/dist/runtime/bindings/helpers.js.map +1 -1
  38. package/dist/runtime/bindings/types.d.ts +2 -0
  39. package/dist/runtime/bindings/types.d.ts.map +1 -1
  40. package/dist/runtime/bindings/types.js.map +1 -1
  41. package/dist/types/globals.d.ts +1 -0
  42. package/dist/types/globals.d.ts.map +1 -1
  43. package/dist/types/globals.js.map +1 -1
  44. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"contentProjection.js","sourceRoot":"","sources":["../../src/compile/contentProjection.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAa,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AA6B5C,SAAS,OAAO,CAAC,IAAU;IACzB,OAAO,IAAgC,CAAC;AAC1C,CAAC;AAED,MAAM,aAAa,GAAG,IAAI,OAAO,EAAoB,CAAC;AAEtD,SAAS,SAAS,CAAC,GAA4B;IAC7C,OAAO,CAAC,WAAW,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CA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AAC;YAChE,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,YAAY,EAAE,CAAC,sBAAsB,EAAE,CAAC;YAClE,OAAO,CAAC,GAAG,CACT,6CAA6C,aAAa,CAAC,MAAM,oBAAoB,IAAI,GAAG,CAC7F,CAAC;QACJ,CAAC;IACH,CAAC;IAED,2BAA2B;IAC3B,2EAA2E;IAC3E,yEAAyE;IACzE,6EAA6E;IAC7E,sEAAsE;IACtE,uEAAuE;IACvE,qEAAqE;IACrE,gDAAgD;AAClD,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.feature.content-projection\",\n \"title\": \"Content Projection System\",\n \"category\": \"feature\"\n}\n*/\n\nimport { PithyNode, sharedSlotMessage, sharedSlots } from '@pithyjs/compiler';\nimport { pithyTreeToDom } from './pithyTreeToDom';\nimport { bindStructuralDirectives } from './compileTemplate';\nimport { nodeExpando } from './nodeExpando';\nimport {\n bindErrorBoundary,\n insertBesideHidden,\n withSlotBoundary,\n isHiddenByBoundary,\n} from './binds/bindErrorBoundary';\nimport { pithyGlobals } from '../types/globals';\nimport { trimBlankEdges } from './trimBlankEdges';\nimport { withinRender } from './ssrCrashes';\n\n/**\n * SlotMap contains renderer functions for each slot name.\n * Each entry is a factory that returns a DocumentFragment of the slot's content.\n */\nexport type SlotMap = Map<\n string,\n (disposers?: (() => void)[], anchor?: Node) => DocumentFragment\n>;\n\n/**\n * SlotDef describes a slot anchor and its fallback content\n */\nexport type FallbackFactory = () => HTMLElement | DocumentFragment | undefined;\n\nexport interface SlotDef {\n name: string;\n anchor: Comment;\n fallbackFactory?: FallbackFactory;\n}\n\ninterface ProjectionExpando {\n __slotName?: string;\n __fallbackFactory?: FallbackFactory;\n __projectionProcessed?: boolean;\n __projectedContent?: boolean;\n}\n\nfunction expando(node: Node): ProjectionExpando {\n return node as Node & ProjectionExpando;\n}\n\nconst outerSlotMaps = new WeakMap<SlotMap, SlotMap>();\n\nfunction slotMapOf(ctx: Record<string, unknown>): SlotMap | undefined {\n return ('__slotMap' in ctx ? ctx.__slotMap : undefined) as\n | SlotMap\n | undefined;\n}\n\n/**\n * The slot map of the template the children behind `slotMap` were written in:\n * what a `<slot>` among those children receives.\n */\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"outerSlotMap\",\"stability\":\"internal\",\"signature\":\"(slotMap: SlotMap | undefined) => SlotMap | undefined\"} */\nexport function outerSlotMap(\n slotMap: SlotMap | undefined\n): SlotMap | undefined {\n return slotMap && outerSlotMaps.get(slotMap);\n}\n\n/** Records `ctx`'s slot map as what a `<slot>` among `slotMap`'s children receives. */\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"linkOuterSlotMap\",\"stability\":\"internal\",\"signature\":\"(slotMap: SlotMap, ctx: Record<string, unknown>) => void\"} */\nexport function linkOuterSlotMap(\n slotMap: SlotMap,\n ctx: Record<string, unknown>\n): void {\n const outer = slotMapOf(ctx);\n if (outer) outerSlotMaps.set(slotMap, outer);\n}\n\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"collectSlotMap\",\"stability\":\"stable\",\"signature\":\"(children: PithyNode[], parentContext: Record<string, any>, host?: Element) => SlotMap\"} */\nexport function collectSlotMap(\n children: PithyNode[],\n parentContext: Record<string, unknown>,\n host?: Element\n): SlotMap {\n const slotMap: SlotMap = new Map();\n const slotGroups = new Map<string, PithyNode[]>();\n linkOuterSlotMap(slotMap, parentContext);\n const outer = slotMapOf(parentContext);\n\n // Group children by slot attribute\n for (const child of children) {\n const slotName = child.directives?.slot || ''; // default slot if no slot attribute\n\n if (!slotGroups.has(slotName)) {\n slotGroups.set(slotName, []);\n }\n slotGroups.get(slotName)!.push(child);\n }\n const defaultSlot = slotGroups.get('');\n if (defaultSlot) {\n const content = trimBlankEdges(defaultSlot, node =>\n node.type === 'text' ? (node.textContent ?? '') : null\n );\n if (content.length) slotGroups.set('', content);\n else slotGroups.delete('');\n }\n\n if (import.meta.env?.DEV) {\n const tag =\n (host && nodeExpando(host).__pithyNode?.originalTagName) ??\n host?.localName ??\n 'component';\n for (const name of sharedSlots(children))\n console.warn(`[PithyJS] ${sharedSlotMessage(tag, name)}`);\n }\n\n // Create renderer functions for each slot group.\n // NOTE: We intentionally do NOT cache or clone DocumentFragments here.\n // Using fragment caching + cloneNode(true) would strip custom JS properties\n // like __pithyCtx that binders rely on to resolve projected content\n // expressions (including interpolation, [class], and [attr] bindings)\n // against the *parent* component's context.\n //\n // This behavior is relied upon by regression tests that exercise projected\n // nodes containing such bindings; changing this to reuse or clone\n // fragments will cause those tests to fail and break content projection.\n // pithyTreeToDom is cheap (just creates DOM nodes), so recreating is fine.\n\n for (const [slotName, nodes] of slotGroups) {\n // Capture nodes and context in closure for stable reference\n const capturedNodes = nodes;\n const capturedContext = parentContext;\n\n const render = (\n disposers: (() => void)[] = [],\n at?: Node\n ): DocumentFragment => {\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Rendering slot \"${slotName}\" with ${capturedNodes.length} nodes`\n );\n }\n\n const fragment = pithyTreeToDom(capturedNodes, capturedContext);\n // As the AOT renderer does: a branch in the content then finds a boundary\n // the receiver wraps its `<slot>` in.\n withSlotBoundary(at, host, () =>\n withinRender(() => {\n bindStructuralDirectives(\n capturedNodes,\n fragment,\n capturedContext,\n disposers\n );\n bindErrorBoundary(fragment, capturedContext, disposers);\n return fragment;\n })\n );\n // A `<slot>` passed through: the receiving component has already looked for its slots.\n const passed = extractSlotDefs(fragment);\n if (passed.length) mountProjection(passed, outer ?? new Map(), disposers);\n nodeExpando(fragment).__pithyCtx = capturedContext;\n return fragment;\n };\n\n slotMap.set(slotName, render);\n }\n\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Collected SlotMap with slots:`,\n Array.from(slotMap.keys())\n );\n }\n return slotMap;\n}\n\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"extractSlotDefs\",\"stability\":\"stable\",\"signature\":\"(fragment: DocumentFragment) => SlotDef[]\"} */\nexport function extractSlotDefs(fragment: DocumentFragment): SlotDef[] {\n const slotDefs: SlotDef[] = [];\n const walker = document.createTreeWalker(fragment, NodeFilter.SHOW_COMMENT, {\n acceptNode: node => {\n const comment = node as Comment;\n return comment.textContent?.startsWith('slot:')\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_REJECT;\n },\n });\n\n let node: Comment | null;\n while ((node = walker.nextNode() as Comment | null)) {\n // Inside a component tag, the slot is that component's content to place.\n if (inComponentTag(node)) continue;\n const slotName = expando(node).__slotName || '';\n const fallbackFactory = expando(node).__fallbackFactory;\n\n slotDefs.push({\n name: slotName,\n anchor: node,\n fallbackFactory,\n });\n }\n\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Extracted ${slotDefs.length} slot definitions`\n );\n }\n return slotDefs;\n}\n\n/** Whether `node` is inside content a `<slot>` projected. */\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"inProjectedContent\",\"stability\":\"internal\",\"signature\":\"(node: Node) => boolean\"} */\nexport function inProjectedContent(node: Node): boolean {\n for (let n: Node | null = node; n; n = n.parentNode)\n if (expando(n).__projectedContent) return true;\n return false;\n}\n\nfunction inComponentTag(node: Node): boolean {\n for (let el = node.parentElement; el; el = el.parentElement)\n if (nodeExpando(el).__pithyNode?.isComponent) return true;\n return false;\n}\n\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"mountProjection\",\"stability\":\"stable\",\"signature\":\"(slotDefs: SlotDef[], slotMap: SlotMap, disposers: (() => void)[]) => void\"} */\nexport function mountProjection(\n slotDefs: SlotDef[],\n slotMap: SlotMap,\n disposers: (() => void)[]\n): void {\n // A slot's content is rendered and then inserted: one render transaction.\n withinRender(() => mountSlots(slotDefs, slotMap, disposers));\n}\n\nfunction mountSlots(\n slotDefs: SlotDef[],\n slotMap: SlotMap,\n disposers: (() => void)[]\n): void {\n for (const slotDef of slotDefs) {\n const { name, anchor, fallbackFactory } = slotDef;\n const renderer = slotMap.get(name);\n\n // Skip if this slot has already been processed\n if (expando(anchor).__projectionProcessed) {\n continue;\n }\n\n // Mark this slot as processed to prevent multiple passes\n expando(anchor).__projectionProcessed = true;\n\n const parent = anchor.parentNode;\n // A crash in an earlier slot can have hidden this anchor behind a fallback.\n if (!parent && !isHiddenByBoundary(anchor)) {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ContentProjection] Slot anchor \"${name}\" has no parent node - skipping`\n );\n }\n continue;\n }\n\n // Determine which content to render\n let contentFragment: HTMLElement | DocumentFragment | null = null;\n let isProjectedContent = false;\n\n if (renderer) {\n // Use projected content\n contentFragment = renderer(disposers, anchor);\n isProjectedContent = true;\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Mounting projected content for slot \"${name}\"`\n );\n }\n } else if (fallbackFactory) {\n // Use fallback content\n contentFragment = fallbackFactory() ?? null;\n const slotNode = nodeExpando(anchor).__pithyNode;\n if (\n contentFragment instanceof DocumentFragment &&\n slotNode?.fallbackChildren\n ) {\n const fallbackCtx = nodeExpando(anchor).__pithyCtx ?? {};\n const fallbackFragment = contentFragment;\n const fallbackNodes = slotNode.fallbackChildren;\n withinRender(() => {\n bindStructuralDirectives(\n fallbackNodes,\n fallbackFragment,\n fallbackCtx,\n disposers\n );\n bindErrorBoundary(fallbackFragment, fallbackCtx, disposers);\n });\n }\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Mounting fallback content for slot \"${name}\"`\n );\n }\n } else {\n // No content to mount\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(`[PithyJS:Projection] No content for slot \"${name}\"`);\n }\n continue;\n }\n\n // Validate content\n if (!contentFragment || contentFragment.childNodes.length === 0) {\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Empty content for slot \"${name}\" - skipping`\n );\n }\n continue;\n }\n\n // CRITICAL: Collect nodes BEFORE inserting into DOM (for cleanup tracking)\n // Once inserted, the fragment's childNodes will be empty\n const nodesToInsert: Node[] = Array.from(contentFragment.childNodes);\n\n // Mark nodes for tracking\n for (const node of nodesToInsert) {\n expando(node).__projectedContent = isProjectedContent;\n expando(node).__slotName = name;\n }\n\n // Find and remove any existing content for this slot\n const existingNodes: Node[] = [];\n let current = anchor.nextSibling;\n\n while (current) {\n // Stop if we hit another slot anchor\n if (\n current.nodeType === Node.COMMENT_NODE &&\n (current as Comment).textContent?.startsWith('slot:')\n ) {\n break;\n }\n\n // A sibling no projection marked is the component's own markup.\n const meta = expando(current);\n if (meta.__projectedContent === undefined || meta.__slotName !== name) {\n break;\n }\n existingNodes.push(current);\n\n current = current.nextSibling;\n }\n\n // Simple diffing: only replace if content appears different\n // Compare node count and types as a basic heuristic\n const shouldReplace =\n existingNodes.length !== nodesToInsert.length ||\n existingNodes.some(\n (node, i) => node.nodeType !== nodesToInsert[i]?.nodeType\n );\n\n if (!shouldReplace && existingNodes.length > 0) {\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Content for slot \"${name}\" unchanged - skipping replacement`\n );\n }\n continue;\n }\n\n // Remove existing content\n for (const node of existingNodes) {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n }\n\n // Insert new content after the anchor comment\n if (!insertBesideHidden(anchor, contentFragment))\n parent?.insertBefore(contentFragment, anchor.nextSibling);\n\n // Track cleanup - remove projected nodes when component unmounts\n disposers.push(() => {\n for (const node of nodesToInsert) {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n }\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(`[PithyJS:Projection] Cleaned up slot \"${name}\"`);\n }\n });\n\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Successfully mounted ${nodesToInsert.length} nodes for slot \"${name}\"`\n );\n }\n }\n\n // DEV: Validate slot usage\n // NOTE: We intentionally do NOT warn about unmatched projected slots here.\n // When a component uses @if/@else with different <slot> elements in each\n // branch (e.g., Show has <slot> in @if and <slot name=\"fallback\"> in @else),\n // the currently-rendered branch may not include all slot targets. The\n // projected \"fallback\" content is legitimate — it will be mounted when\n // the @else branch activates. Warnings here would be false positives\n // and fire repeatedly on every reactive toggle.\n}\n"]}
1
+ {"version":3,"file":"contentProjection.js","sourceRoot":"","sources":["../../src/compile/contentProjection.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAEL,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AA6B5C,SAAS,OAAO,CAAC,IAAU;IACzB,OAAO,IAAgC,CAAC;AAC1C,CAAC;AAED,MAAM,aAAa,GAAG,IAAI,OAAO,EAAoB,CAAC;AACtD,MAAM,WAAW,GAAG,IAAI,OAAO,EAAmB,CAAC;AACnD,MAAM,aAAa,GAAG,IAAI,OAAO,EAAmB,CAAC;AACr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MAAM,CAAC,WAAW,CAAC,CAAC;QAE5D,iEAAiE;QACjE,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE;YAClB,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;gBACjC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBACpB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACpC,CAAC;YACH,CAAC;YACD,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,YAAY,EAAE,CAAC,sBAAsB,EAAE,CAAC;gBAClE,OAAO,CAAC,GAAG,CAAC,yCAAyC,IAAI,GAAG,CAAC,CAAC;YAChE,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,YAAY,EAAE,CAAC,sBAAsB,EAAE,CAAC;YAClE,OAAO,CAAC,GAAG,CACT,6CAA6C,aAAa,CAAC,MAAM,oBAAoB,IAAI,GAAG,CAC7F,CAAC;QACJ,CAAC;IACH,CAAC;IAED,2BAA2B;IAC3B,2EAA2E;IAC3E,yEAAyE;IACzE,6EAA6E;IAC7E,sEAAsE;IACtE,uEAAuE;IACvE,qEAAqE;IACrE,gDAAgD;AAClD,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.feature.content-projection\",\n \"title\": \"Content Projection System\",\n \"category\": \"feature\"\n}\n*/\n\nimport {\n PithyNode,\n duplicateSlotMessage,\n sharedSlotMessage,\n sharedSlots,\n} from '@pithyjs/compiler';\nimport { pithyTreeToDom } from './pithyTreeToDom';\nimport { bindStructuralDirectives } from './compileTemplate';\nimport { nodeExpando } from './nodeExpando';\nimport {\n bindErrorBoundary,\n insertBesideHidden,\n withSlotBoundary,\n isHiddenByBoundary,\n} from './binds/bindErrorBoundary';\nimport { pithyGlobals } from '../types/globals';\nimport { trimBlankEdges } from './trimBlankEdges';\nimport { withinRender } from './ssrCrashes';\n\n/**\n * SlotMap contains renderer functions for each slot name.\n * Each entry is a factory that returns a DocumentFragment of the slot's content.\n */\nexport type SlotMap = Map<\n string,\n (disposers?: (() => void)[], anchor?: Node) => DocumentFragment\n>;\n\n/**\n * SlotDef describes a slot anchor and its fallback content\n */\nexport type FallbackFactory = () => HTMLElement | DocumentFragment | undefined;\n\nexport interface SlotDef {\n name: string;\n anchor: Comment;\n fallbackFactory?: FallbackFactory;\n}\n\ninterface ProjectionExpando {\n __slotName?: string;\n __fallbackFactory?: FallbackFactory;\n __projectionProcessed?: boolean;\n __projectedContent?: boolean;\n}\n\nfunction expando(node: Node): ProjectionExpando {\n return node as Node & ProjectionExpando;\n}\n\nconst outerSlotMaps = new WeakMap<SlotMap, SlotMap>();\nconst slotMapTags = new WeakMap<SlotMap, string>();\nconst slotMapOwners = new WeakMap<SlotMap, object>();\nlet warnedDuplicates = new WeakMap<object, Set<string>>();\n\n/** Records the component tag `slotMap` fills, and the component, for DEV warnings. */\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"nameSlotMap\",\"stability\":\"internal\",\"signature\":\"(slotMap: SlotMap, tag: string, owner?: object) => void\"} */\nexport function nameSlotMap(\n slotMap: SlotMap,\n tag: string,\n owner?: object\n): void {\n slotMapTags.set(slotMap, tag);\n if (owner) slotMapOwners.set(slotMap, owner);\n}\n\n/**\n * DEV: warns once per component and slot name that a later `<slot>` gets no\n * content. Without a known component, once per `instance` (one render).\n */\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"warnDuplicateSlot\",\"stability\":\"internal\",\"signature\":\"(slotMap: SlotMap | undefined, name: string, instance: object) => void\"} */\nexport function warnDuplicateSlot(\n slotMap: SlotMap | undefined,\n name: string,\n instance: object\n): void {\n const key = (slotMap && slotMapOwners.get(slotMap)) ?? instance;\n let names = warnedDuplicates.get(key);\n if (!names) warnedDuplicates.set(key, (names = new Set()));\n if (names.has(name)) return;\n names.add(name);\n const tag = (slotMap && slotMapTags.get(slotMap)) ?? 'component';\n console.warn(`[PithyJS] ${duplicateSlotMessage(tag, name)}`);\n}\n\n/** Test hook: lets each test see its first duplicate-slot warning. */\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"resetDuplicateSlotWarnings\",\"stability\":\"internal\",\"signature\":\"() => void\"} */\nexport function resetDuplicateSlotWarnings(): void {\n warnedDuplicates = new WeakMap();\n}\n\nfunction slotMapOf(ctx: Record<string, unknown>): SlotMap | undefined {\n return ('__slotMap' in ctx ? ctx.__slotMap : undefined) as\n | SlotMap\n | undefined;\n}\n\n/**\n * The slot map of the template the children behind `slotMap` were written in:\n * what a `<slot>` among those children receives.\n */\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"outerSlotMap\",\"stability\":\"internal\",\"signature\":\"(slotMap: SlotMap | undefined) => SlotMap | undefined\"} */\nexport function outerSlotMap(\n slotMap: SlotMap | undefined\n): SlotMap | undefined {\n return slotMap && outerSlotMaps.get(slotMap);\n}\n\n/** Records `ctx`'s slot map as what a `<slot>` among `slotMap`'s children receives. */\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"linkOuterSlotMap\",\"stability\":\"internal\",\"signature\":\"(slotMap: SlotMap, ctx: Record<string, unknown>) => void\"} */\nexport function linkOuterSlotMap(\n slotMap: SlotMap,\n ctx: Record<string, unknown>\n): void {\n const outer = slotMapOf(ctx);\n if (outer) outerSlotMaps.set(slotMap, outer);\n}\n\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"collectSlotMap\",\"stability\":\"stable\",\"signature\":\"(children: PithyNode[], parentContext: Record<string, any>, host?: Element, owner?: object) => SlotMap\"} */\nexport function collectSlotMap(\n children: PithyNode[],\n parentContext: Record<string, unknown>,\n host?: Element,\n owner?: object\n): SlotMap {\n const slotMap: SlotMap = new Map();\n const slotGroups = new Map<string, PithyNode[]>();\n linkOuterSlotMap(slotMap, parentContext);\n const outer = slotMapOf(parentContext);\n\n // Group children by slot attribute\n for (const child of children) {\n const slotName = child.directives?.slot || ''; // default slot if no slot attribute\n\n if (!slotGroups.has(slotName)) {\n slotGroups.set(slotName, []);\n }\n slotGroups.get(slotName)!.push(child);\n }\n const defaultSlot = slotGroups.get('');\n if (defaultSlot) {\n const content = trimBlankEdges(defaultSlot, node =>\n node.type === 'text' ? (node.textContent ?? '') : null\n );\n if (content.length) slotGroups.set('', content);\n else slotGroups.delete('');\n }\n\n if (import.meta.env?.DEV) {\n const tag =\n (host && nodeExpando(host).__pithyNode?.originalTagName) ??\n host?.localName ??\n 'component';\n nameSlotMap(slotMap, tag, owner);\n for (const name of sharedSlots(children))\n console.warn(`[PithyJS] ${sharedSlotMessage(tag, name)}`);\n }\n\n // Create renderer functions for each slot group.\n // NOTE: We intentionally do NOT cache or clone DocumentFragments here.\n // Using fragment caching + cloneNode(true) would strip custom JS properties\n // like __pithyCtx that binders rely on to resolve projected content\n // expressions (including interpolation, [class], and [attr] bindings)\n // against the *parent* component's context.\n //\n // This behavior is relied upon by regression tests that exercise projected\n // nodes containing such bindings; changing this to reuse or clone\n // fragments will cause those tests to fail and break content projection.\n // pithyTreeToDom is cheap (just creates DOM nodes), so recreating is fine.\n\n for (const [slotName, nodes] of slotGroups) {\n // Capture nodes and context in closure for stable reference\n const capturedNodes = nodes;\n const capturedContext = parentContext;\n\n const render = (\n disposers: (() => void)[] = [],\n at?: Node\n ): DocumentFragment => {\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Rendering slot \"${slotName}\" with ${capturedNodes.length} nodes`\n );\n }\n\n const fragment = pithyTreeToDom(capturedNodes, capturedContext);\n // As the AOT renderer does: a branch in the content then finds a boundary\n // the receiver wraps its `<slot>` in.\n withSlotBoundary(at, host, () =>\n withinRender(() => {\n bindStructuralDirectives(\n capturedNodes,\n fragment,\n capturedContext,\n disposers\n );\n bindErrorBoundary(fragment, capturedContext, disposers);\n return fragment;\n })\n );\n // A `<slot>` passed through: the receiving component has already looked for its slots.\n const passed = extractSlotDefs(fragment);\n if (passed.length) mountProjection(passed, outer ?? new Map(), disposers);\n nodeExpando(fragment).__pithyCtx = capturedContext;\n return fragment;\n };\n\n slotMap.set(slotName, render);\n }\n\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Collected SlotMap with slots:`,\n Array.from(slotMap.keys())\n );\n }\n return slotMap;\n}\n\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"extractSlotDefs\",\"stability\":\"stable\",\"signature\":\"(fragment: DocumentFragment) => SlotDef[]\"} */\nexport function extractSlotDefs(fragment: DocumentFragment): SlotDef[] {\n const slotDefs: SlotDef[] = [];\n const walker = document.createTreeWalker(fragment, NodeFilter.SHOW_COMMENT, {\n acceptNode: node => {\n const comment = node as Comment;\n return comment.textContent?.startsWith('slot:')\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_REJECT;\n },\n });\n\n let node: Comment | null;\n while ((node = walker.nextNode() as Comment | null)) {\n // Inside a component tag, the slot is that component's content to place.\n if (inComponentTag(node)) continue;\n const slotName = expando(node).__slotName || '';\n const fallbackFactory = expando(node).__fallbackFactory;\n\n slotDefs.push({\n name: slotName,\n anchor: node,\n fallbackFactory,\n });\n }\n\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Extracted ${slotDefs.length} slot definitions`\n );\n }\n return slotDefs;\n}\n\n/** Whether `node` is inside content a `<slot>` projected. */\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"inProjectedContent\",\"stability\":\"internal\",\"signature\":\"(node: Node) => boolean\"} */\nexport function inProjectedContent(node: Node): boolean {\n for (let n: Node | null = node; n; n = n.parentNode)\n if (expando(n).__projectedContent) return true;\n return false;\n}\n\nfunction inComponentTag(node: Node): boolean {\n for (let el = node.parentElement; el; el = el.parentElement)\n if (nodeExpando(el).__pithyNode?.isComponent) return true;\n return false;\n}\n\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"mountProjection\",\"stability\":\"stable\",\"signature\":\"(slotDefs: SlotDef[], slotMap: SlotMap, disposers: (() => void)[]) => void\"} */\nexport function mountProjection(\n slotDefs: SlotDef[],\n slotMap: SlotMap,\n disposers: (() => void)[]\n): void {\n // A slot's content is rendered and then inserted: one render transaction.\n withinRender(() => mountSlots(slotDefs, slotMap, disposers));\n}\n\nfunction mountSlots(\n slotDefs: SlotDef[],\n slotMap: SlotMap,\n disposers: (() => void)[]\n): void {\n // As in the HTML spec, only the first slot of a name receives content.\n const filled = new Set<string>();\n for (const slotDef of slotDefs) {\n const { name, anchor, fallbackFactory } = slotDef;\n\n // Skip if this slot has already been processed\n if (expando(anchor).__projectionProcessed) {\n continue;\n }\n\n // Mark this slot as processed to prevent multiple passes\n expando(anchor).__projectionProcessed = true;\n\n const later = filled.has(name);\n filled.add(name);\n if (later && import.meta.env?.DEV)\n warnDuplicateSlot(slotMap, name, slotMap);\n const renderer = later ? undefined : slotMap.get(name);\n\n const parent = anchor.parentNode;\n // A crash in an earlier slot can have hidden this anchor behind a fallback.\n if (!parent && !isHiddenByBoundary(anchor)) {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ContentProjection] Slot anchor \"${name}\" has no parent node - skipping`\n );\n }\n continue;\n }\n\n // Determine which content to render\n let contentFragment: HTMLElement | DocumentFragment | null = null;\n let isProjectedContent = false;\n\n if (renderer) {\n // Use projected content\n contentFragment = renderer(disposers, anchor);\n isProjectedContent = true;\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Mounting projected content for slot \"${name}\"`\n );\n }\n } else if (fallbackFactory) {\n // Use fallback content\n contentFragment = fallbackFactory() ?? null;\n const slotNode = nodeExpando(anchor).__pithyNode;\n if (\n contentFragment instanceof DocumentFragment &&\n slotNode?.fallbackChildren\n ) {\n const fallbackCtx = nodeExpando(anchor).__pithyCtx ?? {};\n const fallbackFragment = contentFragment;\n const fallbackNodes = slotNode.fallbackChildren;\n withinRender(() => {\n bindStructuralDirectives(\n fallbackNodes,\n fallbackFragment,\n fallbackCtx,\n disposers\n );\n bindErrorBoundary(fallbackFragment, fallbackCtx, disposers);\n });\n }\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Mounting fallback content for slot \"${name}\"`\n );\n }\n } else {\n // No content to mount\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(`[PithyJS:Projection] No content for slot \"${name}\"`);\n }\n continue;\n }\n\n // Validate content\n if (!contentFragment || contentFragment.childNodes.length === 0) {\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Empty content for slot \"${name}\" - skipping`\n );\n }\n continue;\n }\n\n // CRITICAL: Collect nodes BEFORE inserting into DOM (for cleanup tracking)\n // Once inserted, the fragment's childNodes will be empty\n const nodesToInsert: Node[] = Array.from(contentFragment.childNodes);\n\n // Mark nodes for tracking\n for (const node of nodesToInsert) {\n expando(node).__projectedContent = isProjectedContent;\n expando(node).__slotName = name;\n }\n\n // Find and remove any existing content for this slot\n const existingNodes: Node[] = [];\n let current = anchor.nextSibling;\n\n while (current) {\n // Stop if we hit another slot anchor\n if (\n current.nodeType === Node.COMMENT_NODE &&\n (current as Comment).textContent?.startsWith('slot:')\n ) {\n break;\n }\n\n // A sibling no projection marked is the component's own markup.\n const meta = expando(current);\n if (meta.__projectedContent === undefined || meta.__slotName !== name) {\n break;\n }\n existingNodes.push(current);\n\n current = current.nextSibling;\n }\n\n // Simple diffing: only replace if content appears different\n // Compare node count and types as a basic heuristic\n const shouldReplace =\n existingNodes.length !== nodesToInsert.length ||\n existingNodes.some(\n (node, i) => node.nodeType !== nodesToInsert[i]?.nodeType\n );\n\n if (!shouldReplace && existingNodes.length > 0) {\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Content for slot \"${name}\" unchanged - skipping replacement`\n );\n }\n continue;\n }\n\n // Remove existing content\n for (const node of existingNodes) {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n }\n\n // Insert new content after the anchor comment\n if (!insertBesideHidden(anchor, contentFragment))\n parent?.insertBefore(contentFragment, anchor.nextSibling);\n\n // Track cleanup - remove projected nodes when component unmounts\n disposers.push(() => {\n for (const node of nodesToInsert) {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n }\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(`[PithyJS:Projection] Cleaned up slot \"${name}\"`);\n }\n });\n\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Successfully mounted ${nodesToInsert.length} nodes for slot \"${name}\"`\n );\n }\n }\n\n // DEV: Validate slot usage\n // NOTE: We intentionally do NOT warn about unmatched projected slots here.\n // When a component uses @if/@else with different <slot> elements in each\n // branch (e.g., Show has <slot> in @if and <slot name=\"fallback\"> in @else),\n // the currently-rendered branch may not include all slot targets. The\n // projected \"fallback\" content is legitimate — it will be mounted when\n // the @else branch activates. Warnings here would be false positives\n // and fire repeatedly on every reactive toggle.\n}\n"]}
@@ -31,6 +31,7 @@ export interface NodeExpando {
31
31
  __pithyForwardId?: number;
32
32
  /** The boundary element a slot rendered this node for, wherever a portal moves it. */
33
33
  __pithySlotOwner?: Element;
34
+ __pithySlotInFallback?: boolean;
34
35
  }
35
36
  /** Records that `ctx`'s tag forwarded `names` onto `root`. */
36
37
  export declare function markForwardTarget(root: Element, ctx: Record<string, unknown>, names: Set<string>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"nodeExpando.d.ts","sourceRoot":"","sources":["../../src/compile/nodeExpando.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mB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AG,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC,iBAAiB,GAAG,GAAG,CAAC;IAC1B,CAAC,CAAC,mBAAmB,GAAG,KAAK,CAAC;IAC9B,CAAC,CAAC,gBAAgB,GAAG,EAAE,aAAa,CAAC;AACvC,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,eAAe,CAAC,EAAW,EAAE,GAAW;IACtD,OAAO,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC,gBAAgB,IAAI,GAAG,EAAE,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,WAAW,CAAiB,IAAO;IACjD,OAAO,IAAuB,CAAC;AACjC,CAAC","sourcesContent":["import type { PithyNode } from '@pithyjs/compiler';\n\nexport interface StyleOwners {\n strings: string[];\n props: Map<string, [value: string, priority: string]>;\n}\n\nexport interface NodeExpando {\n __pithyCtx?: Record<string, unknown>;\n __pithyNode?: PithyNode;\n __nodeId?: string;\n __slotName?: string;\n __fallbackFactory?: () => DocumentFragment;\n __nested?: boolean;\n __pithySkipText?: boolean;\n __pithyComponentDom?: boolean;\n /** A build's component placeholder: renders it through the AOT binder. */\n /** Renders a build's placeholder; returns the nodes that replaced it. */\n __pithyAotMount?: (disposers: (() => void)[]) => Node[];\n __styleProps?: string[];\n __styleOwners?: StyleOwners;\n __selectValue?: { text: string; picks: Set<string> | null };\n __classToggles?: string[];\n __forwardedDirectives?: Map<string, string>;\n /** A component root's forwarded bindings evaluate in the tag's template. */\n __pithyForwardCtx?: Record<string, unknown>;\n /** The attributes the tag that set `__pithyForwardCtx` forwarded. */\n __pithyForwardAttrs?: Set<string>;\n /** Identifies that forwarding, so two tags in one scope stay two bindings. */\n __pithyForwardId?: number;\n /** The boundary element a slot rendered this node for, wherever a portal moves it. */\n __pithySlotOwner?: Element;\n}\n\nlet nextForwardId = 0;\n\n/** Records that `ctx`'s tag forwarded `names` onto `root`. */\nexport function markForwardTarget(\n root: Element,\n ctx: Record<string, unknown>,\n names: Set<string>\n): void {\n const x = nodeExpando(root);\n x.__pithyForwardCtx = ctx;\n x.__pithyForwardAttrs = names;\n x.__pithyForwardId = ++nextForwardId;\n}\n\n/** Keys a forwarded event by the forwarding that put it on `el`. */\nexport function forwardEventKey(el: Element, key: string): string {\n return `${nodeExpando(el).__pithyForwardId}|${key}`;\n}\n\nexport function nodeExpando<T extends Node>(node: T): T & NodeExpando {\n return node as T & NodeExpando;\n}\n"]}
1
+ {"version":3,"file":"nodeExpando.js","sourceRoot":"","sources":["../../src/compile/nodeExpando.ts"],"names":[],"mappings":"AAmCA,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB,8DAA8D;AAC9D,MAAM,UAAU,iBAAiB,CAC/B,IAAa,EACb,GAA4B,EAC5B,KAAkB;IAElB,MAAM,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC,iBAAiB,GAAG,GAAG,CAAC;IAC1B,CAAC,CAAC,mBAAmB,GAAG,KAAK,CAAC;IAC9B,CAAC,CAAC,gBAAgB,GAAG,EAAE,aAAa,CAAC;AACvC,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,eAAe,CAAC,EAAW,EAAE,GAAW;IACtD,OAAO,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC,gBAAgB,IAAI,GAAG,EAAE,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,WAAW,CAAiB,IAAO;IACjD,OAAO,IAAuB,CAAC;AACjC,CAAC","sourcesContent":["import type { PithyNode } from '@pithyjs/compiler';\n\nexport interface StyleOwners {\n strings: string[];\n props: Map<string, [value: string, priority: string]>;\n}\n\nexport interface NodeExpando {\n __pithyCtx?: Record<string, unknown>;\n __pithyNode?: PithyNode;\n __nodeId?: string;\n __slotName?: string;\n __fallbackFactory?: () => DocumentFragment;\n __nested?: boolean;\n __pithySkipText?: boolean;\n __pithyComponentDom?: boolean;\n /** A build's component placeholder: renders it through the AOT binder. */\n /** Renders a build's placeholder; returns the nodes that replaced it. */\n __pithyAotMount?: (disposers: (() => void)[]) => Node[];\n __styleProps?: string[];\n __styleOwners?: StyleOwners;\n __selectValue?: { text: string; picks: Set<string> | null };\n __classToggles?: string[];\n __forwardedDirectives?: Map<string, string>;\n /** A component root's forwarded bindings evaluate in the tag's template. */\n __pithyForwardCtx?: Record<string, unknown>;\n /** The attributes the tag that set `__pithyForwardCtx` forwarded. */\n __pithyForwardAttrs?: Set<string>;\n /** Identifies that forwarding, so two tags in one scope stay two bindings. */\n __pithyForwardId?: number;\n /** The boundary element a slot rendered this node for, wherever a portal moves it. */\n __pithySlotOwner?: Element;\n __pithySlotInFallback?: boolean;\n}\n\nlet nextForwardId = 0;\n\n/** Records that `ctx`'s tag forwarded `names` onto `root`. */\nexport function markForwardTarget(\n root: Element,\n ctx: Record<string, unknown>,\n names: Set<string>\n): void {\n const x = nodeExpando(root);\n x.__pithyForwardCtx = ctx;\n x.__pithyForwardAttrs = names;\n x.__pithyForwardId = ++nextForwardId;\n}\n\n/** Keys a forwarded event by the forwarding that put it on `el`. */\nexport function forwardEventKey(el: Element, key: string): string {\n return `${nodeExpando(el).__pithyForwardId}|${key}`;\n}\n\nexport function nodeExpando<T extends Node>(node: T): T & NodeExpando {\n return node as T & NodeExpando;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ssrCrashes.d.ts","sourceRoot":"","sources":["../../src/compile/ssrCrashes.ts"],"names":[],"mappings":"AAAA;;;;;;;EAOE;AAKF,OAAO,EAQL,KAAK,YAAY,EAClB,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,2EAA2E;IAC3E,EAAE,EAAE,OAAO,CAAC;IACZ,kDAAkD;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,qCAAqC;IACrC,KAAK,EAAE,KAAK,CAAC;CACd;AAwBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,+IAA+I;AAC/I,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI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AAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAkGD,4GAA4G;AAC5G,yIAAyI;AACzI,wBAAgB,UAAU,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAE/C;AAED;;;;;GAKG;AACH,wIAAwI;AACxI,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAkB9C;AAOD,2EAA2E;AAC3E,uJAAuJ;AACvJ,wBAAgB,UAAU,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,IAAI,GAAG,IAAI,CAG7D;AAED,wHAAwH;AACxH,6IAA6I;AAC7I,wBAAgB,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAEnD;AAED;;;;;GAKG;AACH,+LAA+L;AAC/L,wBAAgB,UAAU,CACxB,EAAE,EAAE,OAAO,EACX,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,KAAK,EACZ,EAAE,OAAc,EAAE,UAAU,EAAE,GAAE,WAAgB,GAC/C,OAAO,CAiBT;AA8BD;;;;;;;;;;GAUG;AACH,iMAAiM;AACjM,wBAAgB,wBAAwB,CACtC,IAAI,GAAE,QAAQ,GAAG,MAAM,GAAG,SAAoB,EAC9C,KAAK,CAAC,EAAE,UAAU,GACjB,IAAI,CA8DN;AA6ID;;;;GAIG;AACH,iJAAiJ;AACjJ,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAIvD"}
@@ -9,7 +9,7 @@
9
9
  import { untrack } from '@pithyjs/signals';
10
10
  import { pithyGlobals } from '../types/globals.js';
11
11
  import { isSSRMode } from './ssrMode.js';
12
- import { boundaryContext, findParentBoundary, inBranch, isInHiddenContent, registeredClosest, setBoundaryError, slotOwnerOf, } from './binds/bindErrorBoundary.js';
12
+ import { boundaryContext, findParentBoundary, inOwnFallback, inBranch, isInHiddenContent, registeredClosest, setBoundaryError, slotOwnerOf, } from './binds/bindErrorBoundary.js';
13
13
  /**
14
14
  * Crashes recorded during the current server render, keyed by the placeholder
15
15
  * element so a later binding pass over the same element can retract its own
@@ -160,14 +160,22 @@ export function collectUnhandledSSRRenderCrashes() {
160
160
  export function reportComponentFailure(el, tag, error, boundary, attribution = {}) {
161
161
  if (!boundary && deferCrash(el, tag, error, attribution))
162
162
  return true;
163
- return settleFailure(el, tag, error, boundary);
164
- }
165
- function settleFailure(el, tag, error, boundary) {
163
+ return settleFailure(el, tag, error, boundary, attribution);
164
+ }
165
+ function settleFailure(el, tag, error, boundary, attribution = {}) {
166
+ while (boundary && inOwnFallback(boundary, el)) {
167
+ const from = boundary;
168
+ boundary = findParentBoundary(from);
169
+ if (!boundary &&
170
+ !from.element.isConnected &&
171
+ deferCrash(el, tag, error, attribution))
172
+ return true;
173
+ }
166
174
  // A boundary in scope is not a boundary that accepted: an already-active one
167
175
  // with no free ancestor rejects, and that is as unhandled as having none.
168
176
  const accepted = boundary ? setBoundaryError(boundary, error) : false;
169
177
  if (isSSRMode()) {
170
- if (accepted)
178
+ if (accepted || isInHiddenContent(el))
171
179
  clearSSRRenderCrash(el);
172
180
  else
173
181
  recordSSRRenderCrash(el, tag, error);
@@ -179,6 +187,7 @@ const ops = {
179
187
  owner: slotOwnerOf,
180
188
  hidden: isInHiddenContent,
181
189
  parent: findParentBoundary,
190
+ ownFallback: inOwnFallback,
182
191
  settle: settleFailure,
183
192
  };
184
193
  let taskEndQueued = false;
@@ -290,6 +299,12 @@ export function deferCrash(el, tag, error, { message = null, onCaptured } = {})
290
299
  resolveAtTaskEnd();
291
300
  return true;
292
301
  }
302
+ function hold(crash) {
303
+ var _a;
304
+ ((_a = pithyGlobals()).__pithyAttributedCrashes ?? (_a.__pithyAttributedCrashes = [])).push(crash);
305
+ if (renderDepth() === 0)
306
+ resolveAtTaskEnd();
307
+ }
293
308
  function reportCrashesOf(render) {
294
309
  const list = heldCrashes();
295
310
  if (!list?.length)
@@ -379,10 +394,16 @@ export function resolveAttributedCrashes(mode = 'render', scope) {
379
394
  .map(entry => ({ entry, depth: depthOf(entry[0].element) }))
380
395
  .sort((a, b) => b.depth - a.depth)
381
396
  .map(({ entry }) => entry);
382
- const handled = new Set();
397
+ const run = {
398
+ groups,
399
+ handled: new Set(),
400
+ settled: new Set(),
401
+ resolved: new Set(),
402
+ final: mode === 'task',
403
+ };
383
404
  for (const [boundary, group] of innermostFirst) {
384
405
  try {
385
- resolveGroup(boundary, group, handled);
406
+ resolveGroup(boundary, group, run);
386
407
  }
387
408
  catch (err) {
388
409
  reportResolveFailure(group, err);
@@ -401,26 +422,52 @@ function depthOf(node) {
401
422
  depth++;
402
423
  return depth;
403
424
  }
425
+ function settleContent(boundary, run) {
426
+ if (run.settled.has(boundary))
427
+ return;
428
+ run.settled.add(boundary);
429
+ for (const [inner, group] of run.groups)
430
+ if (inner !== boundary &&
431
+ boundary.element.contains(inner.element) &&
432
+ !boundary.fallbackElement?.contains(inner.element))
433
+ resolveGroup(inner, group, run);
434
+ for (const crash of run.groups.get(boundary) ?? []) {
435
+ if (boundary.fallbackElement?.contains(crash.el))
436
+ continue;
437
+ if (partOfShown(crash, boundary))
438
+ logCrash(crash);
439
+ else
440
+ deliver(crash, boundary, run);
441
+ }
442
+ }
404
443
  /**
405
444
  * One boundary's crashes, content before fallback, so the outcome does not
406
445
  * depend on the order they happened in. Each is handled as a crash placed there
407
- * directly: a content crash goes to the boundary, a fallback crash too unless
408
- * the boundary already shows its fallback, in which case it goes further out.
446
+ * directly: a content crash goes to the boundary, a fallback crash further out.
409
447
  */
410
- function resolveGroup(boundary, group, handled) {
411
- const inFallback = (crash) => !!boundary.fallbackElement?.contains(crash.el);
412
- for (const crash of group.filter(crash => !inFallback(crash)))
413
- if (partOfShown(crash, boundary))
414
- logCrash(crash);
415
- else
416
- deliver(crash, boundary, handled);
417
- for (const crash of group.filter(inFallback)) {
418
- if (partOfShown(crash, boundary))
448
+ function resolveGroup(boundary, group, run) {
449
+ if (run.resolved.has(boundary))
450
+ return;
451
+ run.resolved.add(boundary);
452
+ settleContent(boundary, run);
453
+ for (const crash of group) {
454
+ if (!boundary.fallbackElement?.contains(crash.el))
455
+ continue;
456
+ const outer = crash.ops.parent(boundary);
457
+ if (!outer && !run.final && !boundary.element.isConnected)
458
+ hold(crash);
459
+ else if (partOfShown(crash, outsideOwnFallback(crash, outer)))
419
460
  logCrash(crash);
420
461
  else
421
- deliver(crash, showsError(boundary) ? crash.ops.parent(boundary) : boundary, handled);
462
+ deliver(crash, outer, run);
422
463
  }
423
464
  }
465
+ function outsideOwnFallback(crash, from) {
466
+ let at = from;
467
+ while (at && crash.ops.ownFallback(at, crash.el))
468
+ at = crash.ops.parent(at);
469
+ return at;
470
+ }
424
471
  // Slot content a portal moves out of its boundary goes to that boundary, as a
425
472
  // component crash in it does through the slot frame. Only the nodes a slot
426
473
  // rendered carry an owner: a root a component mounts during setup has none.
@@ -447,8 +494,17 @@ function showsError(boundary) {
447
494
  * showing an error, as `setBoundaryError` escalates a crash placed there. One
448
495
  * that reaches a boundary showing an error from this resolution is part of it.
449
496
  */
450
- function deliver(crash, from, handled) {
497
+ function deliver(crash, from, run) {
498
+ const { handled, final } = run;
451
499
  for (let at = from; at; at = crash.ops.parent(at)) {
500
+ if (crash.ops.ownFallback(at, crash.el)) {
501
+ if (!final && !at.element.isConnected && !crash.ops.parent(at)) {
502
+ hold(crash);
503
+ return;
504
+ }
505
+ settleContent(at, run);
506
+ continue;
507
+ }
452
508
  if (handled.has(at)) {
453
509
  logCrash(crash);
454
510
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"ssrCrashes.js","sourceRoot":"","sources":["../../src/compile/ssrCrashes.ts"],"names":[],"mappings":"AAAA;;;;;;;EAOE;AAEF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,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CAAC;YACjE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,OAAO;QACT,CAAC;QACD,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC;QACvB,CAAC;;YAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;QACvB,OAAO;IACT,CAAC;IACD,SAAS,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,iJAAiJ;AACjJ,MAAM,UAAU,qBAAqB,CAAC,EAAW;IAC/C,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,MAAM;QAAE,OAAO;IACnD,MAAM,KAAK,GAAG,EAAE,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACrE,IAAI,KAAK;QAAE,wBAAwB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AACvD,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.ssr-crashes\",\n \"title\": \"SSR Unhandled Component Crash Collector\",\n \"category\": \"runtime\",\n \"risk\": \"high\"\n}\n*/\n\nimport { untrack } from '@pithyjs/signals';\nimport { pithyGlobals } from '../types/globals';\nimport { isSSRMode } from './ssrMode';\nimport {\n boundaryContext,\n findParentBoundary,\n inBranch,\n isInHiddenContent,\n registeredClosest,\n setBoundaryError,\n slotOwnerOf,\n type BoundaryInfo,\n} from './binds/bindErrorBoundary';\n\n/**\n * A component render crash recorded during a static/server render.\n */\nexport interface SSRRenderCrash {\n /** The custom-element placeholder the crashed component was to replace. */\n el: Element;\n /** Authored tag name, for the failure message. */\n tag: string;\n /** The error the component threw. */\n error: Error;\n}\n\n/**\n * Crashes recorded during the current server render, keyed by the placeholder\n * element so a later binding pass over the same element can retract its own\n * earlier record (see `clearSSRRenderCrash`).\n *\n * Held on `globalThis`, not in this module. `@pithyjs/ssr` depends on\n * `@pithyjs/core` as a regular dependency, so an app and the SSR package can\n * resolve two physical copies: `html()` would record into the app's copy while\n * `renderToString()` collected and reset the SSR package's, reintroducing\n * BUG-018 *and* leaking the app copy's DOM records for the life of the process.\n * The same reasoning already puts `__PITHY_SSR__` and `__getComponentContext`\n * on this bridge.\n *\n * A `Map` (not a `WeakMap`) because the collector must be enumerable at flush\n * time. `resetSSRRenderCrashes()` is what keeps it from retaining DOM across\n * renders — the SSR renderer calls it in a `finally`.\n */\nfunction crashRegistry(): Map<Element, SSRRenderCrash> {\n const g = pithyGlobals();\n return (g.__pithySSRCrashes ??= new Map()) as Map<Element, SSRRenderCrash>;\n}\n\n/**\n * Forget any crash previously recorded for `el`.\n *\n * Called only at points where the record is provably no longer the outcome, and\n * NEVER before invoking a component. Retracting eagerly at the top of an attempt\n * hides a failed retry: a component that throws detached and then returns\n * something unusable would have its only record erased, shipping a page with a\n * missing subtree and a green build. The three call sites are:\n *\n * 1. A boundary ACCEPTING the error (`setBoundaryError()` returning `true`).\n * A boundary merely being in scope is not enough — an already-active one\n * with no free ancestor rejects the error, and that is as unhandled as\n * having no boundary at all.\n * 2. A component returning a usable node that then successfully reaches the\n * document, i.e. after `replaceWith` has not thrown.\n * 3. An element that has left the tree being bound (`scope.contains(el)` in\n * `bindComponentTags`, `fragment.contains(el)` in `applyBindings`). It can\n * no longer contribute to the output, so any record for it is stale.\n *\n * Every one of these is mutation-tested; removing any of them turns a correct\n * render into a failed route, or a broken one into a silent success.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"clearSSRRenderCrash\",\"stability\":\"internal\",\"signature\":\"(el: Element) => void\"} */\nexport function clearSSRRenderCrash(el: Element): void {\n crashRegistry().delete(el);\n}\n\n/**\n * Record a component failure that no error boundary took ownership of.\n *\n * The precondition is **not** \"no boundary was in scope\". It is that no boundary\n * ACCEPTED the error, which is a strictly weaker thing: `setBoundaryError()`\n * rejects an error when the nearest boundary is already showing one and no\n * ancestor is free, and both binders call this on that path with a boundary\n * very much present. Getting the two confused is what this whole module exists\n * to prevent.\n *\n * Nor is \"crash\" limited to a thrown error. The binders also record a component\n * that returned an unusable result, and one whose rendered node failed to reach\n * the document — both leave the raw tag exactly where a throw would, which is\n * the same content loss from the page's point of view.\n *\n * Callers must have established `isSSRMode()` themselves; this does not\n * re-check.\n */\nfunction recordSSRRenderCrash(el: Element, tag: string, error: unknown): void {\n crashRegistry().set(el, {\n el,\n tag,\n error: error instanceof Error ? error : new Error(String(error)),\n });\n}\n\n/**\n * Drop every recorded crash. Called by the SSR renderer before a render starts\n * and again in its `finally`, so one route's crash can never fail the next.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"resetSSRRenderCrashes\",\"stability\":\"stable\",\"signature\":\"() => void\"} */\nexport function resetSSRRenderCrashes(): void {\n crashRegistry().clear();\n const g = pithyGlobals();\n g.__pithyAttributedCrashes = [];\n g.__pithyRenderDepth = 0;\n}\n\n/**\n * An element that left the tree being bound contributes nothing to the output:\n * its recorded crash is stale, and an attributed one is only logged.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"forgetCrash\",\"stability\":\"internal\",\"signature\":\"(el: Element) => void\"} */\nexport function forgetCrash(el: Element): void {\n clearSSRRenderCrash(el);\n const crash = takeAttributedCrash(el);\n if (crash) logCrash(crash);\n}\n\nfunction takeAttributedCrash(el: Element): AttributedCrash | undefined {\n const list = heldCrashes();\n const at = list?.findIndex(crash => crash.el === el) ?? -1;\n return at >= 0 ? list?.splice(at, 1)[0] : undefined;\n}\n\n/**\n * Return the crashes still recorded once the render has finished, and empty\n * the collector.\n *\n * Every surviving record is a failure. A record is only ever retracted by\n * `clearSSRRenderCrash`, i.e. by a genuine re-attempt at the same element that\n * then went better — never by inspecting the finished tree.\n *\n * An earlier draft re-resolved each record's boundary here, dropping any crash\n * whose element had ended up inside an `@error-boundary`. That is unsound,\n * because a boundary *existing* above an element is not the same as that\n * boundary having *handled* the crash. A crash that a boundary rejected, or\n * that ran where no boundary resolved, is placed under one afterwards just the\n * same. Re-resolution dropped such a record: the boundary signal stayed null,\n * its fallback never activated, the raw component tag shipped, and the build\n * went green — the exact BUG-018 symptom, reintroduced by its own fix.\n *\n * A crash in a branch, slot or component built detached is attributed to its\n * boundary instead (`deferCrash`); whatever is still attributed here is\n * recorded.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"collectUnhandledSSRRenderCrashes\",\"stability\":\"stable\",\"signature\":\"() => SSRRenderCrash[]\"} */\nexport function collectUnhandledSSRRenderCrashes(): SSRRenderCrash[] {\n resolveAttributedCrashes('collect');\n const registry = crashRegistry();\n const unhandled = [...registry.values()];\n registry.clear();\n return unhandled;\n}\n\n/**\n * Hand a component failure to its `@error-boundary`, or record it if none takes\n * it. Returns whether a boundary accepted ownership.\n *\n * The single funnel for every way a component can fail to produce content: a\n * thrown error, an unusable return value, and a rendered node that never reached\n * the document. They were handled in five separate places and drifted — the\n * throw paths consulted the boundary while the malformed paths recorded\n * directly, so a component under `@error-boundary` that returned garbage left\n * the boundary signal null, rendered no fallback, and failed the route, even\n * though the code called it \"the same content loss as a crash\".\n *\n * With no `boundary`, a failure in a branch, slot or component built detached\n * is attributed to the boundary its render sits under (`deferCrash`) and counts\n * as handled here; `attribution` says how it is logged if no boundary takes it.\n *\n * Callers still do their own logging, since the wording differs per failure.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"reportComponentFailure\",\"stability\":\"internal\",\"signature\":\"(el: Element, tag: string, error: Error, boundary: BoundaryInfo | null, attribution?: Attribution) => boolean\"} */\nexport function reportComponentFailure(\n el: Element,\n tag: string,\n error: Error,\n boundary: BoundaryInfo | null,\n attribution: Attribution = {}\n): boolean {\n if (!boundary && deferCrash(el, tag, error, attribution)) return true;\n return settleFailure(el, tag, error, boundary);\n}\n\n/** How an attributed crash is logged: `message` if no boundary takes it, `onCaptured` if one does. */\nexport interface Attribution {\n message?: string | null;\n onCaptured?: () => void;\n}\n\nfunction settleFailure(\n el: Element,\n tag: string,\n error: Error,\n boundary: BoundaryInfo | null\n): boolean {\n // A boundary in scope is not a boundary that accepted: an already-active one\n // with no free ancestor rejects, and that is as unhandled as having none.\n const accepted = boundary ? setBoundaryError(boundary, error) : false;\n\n if (isSSRMode()) {\n if (accepted) clearSSRRenderCrash(el);\n else recordSSRRenderCrash(el, tag, error);\n }\n\n return accepted;\n}\n\n/** A crash raised where no boundary was reachable, owned by the boundary its render sat under. */\ninterface AttributedCrash extends SSRRenderCrash {\n /** The boundary the branch, slot or component was built for: the crash waits until it is inside. */\n boundaryEl: Element;\n message: string | null;\n onCaptured?: () => void;\n ops: CrashOps;\n /** The outermost render it was attributed in; `0` outside any. */\n render: number;\n}\n\n/** The copy of core that attributed a crash answers these, against its own boundaries. */\ninterface CrashOps {\n locate: (el: Element) => BoundaryInfo | null;\n owner: (node: Node) => Element | null;\n hidden: (node: Node) => boolean;\n parent: (boundary: BoundaryInfo) => BoundaryInfo | null;\n settle: typeof settleFailure;\n}\n\nconst ops: CrashOps = {\n locate: registeredClosest,\n owner: slotOwnerOf,\n hidden: isInHiddenContent,\n parent: findParentBoundary,\n settle: settleFailure,\n};\n\nlet taskEndQueued = false;\n\n// A crash that is neither in place nor hidden when a render ends may belong to\n// content its caller inserts right after (a slot rendered from an effect): it\n// waits once, to the end of the task, before it is reported.\nfunction resolveAtTaskEnd(): void {\n if (taskEndQueued) return;\n taskEndQueued = true;\n queueMicrotask(() => {\n taskEndQueued = false;\n resolveAttributedCrashes('task');\n });\n}\n\n// Shared on `globalThis` for the reason the registry is: a second copy of core\n// must neither miss these nor resolve them in the middle of a render.\n\nfunction heldCrashes(): AttributedCrash[] | undefined {\n return pithyGlobals().__pithyAttributedCrashes as\n | AttributedCrash[]\n | undefined;\n}\n\nfunction renderDepth(change = 0): number {\n const g = pithyGlobals();\n return (g.__pithyRenderDepth = (g.__pithyRenderDepth ?? 0) + change);\n}\n\nfunction currentRender(): number {\n return renderDepth() > 0 ? (pithyGlobals().__pithyRenderId ?? 0) : 0;\n}\n\nfunction crashedElements(): WeakSet<Element> {\n const g = pithyGlobals();\n return (g.__pithyCrashedElements ??= new WeakSet()) as WeakSet<Element>;\n}\n\n/** Whether `el` crashed and was attributed; a retry would run its setup twice, which a build never does. */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"hasCrashed\",\"stability\":\"internal\",\"signature\":\"(el: Element) => boolean\"} */\nexport function hasCrashed(el: Element): boolean {\n return crashedElements().has(el);\n}\n\n/**\n * Brackets a render transaction: a template bind, or one structural update\n * that builds a branch and inserts it. Attributed crashes are resolved when the\n * outermost one ends, so a boundary hides its content only once everything in\n * it is bound and in place.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"withinRender\",\"stability\":\"internal\",\"signature\":\"<T>(fn: () => T) => T\"} */\nexport function withinRender<T>(fn: () => T): T {\n const g = pithyGlobals();\n if (renderDepth() === 0) g.__pithyRenderId = (g.__pithyRenderId ?? 0) + 1;\n const render = g.__pithyRenderId ?? 0;\n renderDepth(1);\n let failed = false;\n try {\n return fn();\n } catch (err) {\n failed = true;\n throw err;\n } finally {\n renderDepth(-1);\n // Never throws, so a failed render keeps its own error. Its caller disposes\n // what it bound, boundaries included, so its own crashes are only reported.\n if (failed && renderDepth() === 0) reportCrashesOf(render);\n else resolveAttributedCrashes();\n }\n}\n\nfunction branchFailures(): WeakSet<Element> {\n const g = pithyGlobals();\n return (g.__pithyBranchFailures ??= new WeakSet()) as WeakSet<Element>;\n}\n\n/** Logs a component failure, and marks `el` when it failed in a branch. */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"logFailure\",\"stability\":\"internal\",\"signature\":\"(el: Element, log: () => void) => void\"} */\nexport function logFailure(el: Element, log: () => void): void {\n if (inBranch()) branchFailures().add(el);\n log();\n}\n\n/** Whether `el` failed while its branch was built; the pass that binds the inserted branch would retry it (BUG-161). */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"failedInBranch\",\"stability\":\"internal\",\"signature\":\"(el: Element) => boolean\"} */\nexport function failedInBranch(el: Element): boolean {\n return branchFailures().has(el);\n}\n\n/**\n * Attributes a crash that reached no boundary through the DOM to the boundary\n * its render sits under (`boundaryContext`): a branch, slot or component built\n * detached. Returns `false` with no such context, so the caller handles the\n * crash as before.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"deferCrash\",\"stability\":\"internal\",\"signature\":\"(el: Element, tag: string, error: Error, attribution?: Attribution) => boolean\"} */\nexport function deferCrash(\n el: Element,\n tag: string,\n error: Error,\n { message = null, onCaptured }: Attribution = {}\n): boolean {\n const boundaryEl = boundaryContext();\n if (!boundaryEl) return false;\n crashedElements().add(el);\n takeAttributedCrash(el);\n (pithyGlobals().__pithyAttributedCrashes ??= []).push({\n el,\n tag,\n error,\n boundaryEl,\n message,\n onCaptured,\n ops,\n render: currentRender(),\n });\n if (renderDepth() === 0) resolveAtTaskEnd();\n return true;\n}\n\nfunction reportCrashesOf(render: number): void {\n const list = heldCrashes();\n if (!list?.length) return;\n for (const crash of list.splice(0)) {\n if (crash.render !== render) list.push(crash);\n else\n try {\n unhandled(crash);\n } catch (err) {\n reportResolveFailure([crash], err);\n }\n }\n}\n\nfunction logCrash(crash: AttributedCrash): void {\n if (crash.message) console.error(crash.message, crash.error);\n}\n\nfunction unhandled(crash: AttributedCrash): void {\n crash.ops.settle(crash.el, crash.tag, crash.error, null);\n logCrash(crash);\n}\n\n/**\n * Resolves attributed crashes once they are in place. Each goes to the nearest\n * registered boundary at its final position, exactly as a crash placed there\n * would, and within one resolution a boundary takes at most one error. In the\n * browser this waits for the\n * outermost render to end. A static render binds text once, so there the\n * component pass of the template that owns a boundary resolves its crashes\n * (`scope`), before that template's text is bound and after its components\n * ran. `task` runs at the end of the task; `collect` after the HTML is\n * serialized, and only records.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"resolveAttributedCrashes\",\"stability\":\"internal\",\"signature\":\"(mode?: 'render' | 'task' | 'collect', scope?: ParentNode) => void\"} */\nexport function resolveAttributedCrashes(\n mode: 'render' | 'task' | 'collect' = 'render',\n scope?: ParentNode\n): void {\n const list = heldCrashes();\n if (!list?.length) return;\n const midRender = mode === 'render' && renderDepth() > 0;\n if (midRender && (!scope || !isSSRMode())) return;\n const groups = new Map<BoundaryInfo, AttributedCrash[]>();\n const into = (boundary: BoundaryInfo, crash: AttributedCrash) => {\n const group = groups.get(boundary);\n if (group) group.push(crash);\n else groups.set(boundary, [crash]);\n };\n let waiting = false;\n for (const crash of list.splice(0)) {\n try {\n if (mode === 'collect') {\n unhandled(crash);\n continue;\n }\n if (midRender && !scope?.contains(crash.boundaryEl)) {\n list.push(crash);\n continue;\n }\n const target = placedAt(crash);\n if (partOfShown(crash, target)) {\n logCrash(crash);\n continue;\n }\n if (target) into(target, crash);\n // In its boundary with no registered one around it, or out of time.\n else if (\n mode === 'task' ||\n (!midRender && crash.boundaryEl.contains(crash.el))\n )\n unhandled(crash);\n else {\n // Not inserted yet: its caller may insert it right after.\n list.push(crash);\n waiting ||= !midRender;\n }\n } catch (err) {\n reportResolveFailure([crash], err);\n }\n }\n if (waiting) resolveAtTaskEnd();\n const innermostFirst = [...groups.entries()]\n .map(entry => ({ entry, depth: depthOf(entry[0].element) }))\n .sort((a, b) => b.depth - a.depth)\n .map(({ entry }) => entry);\n const handled = new Set<BoundaryInfo>();\n for (const [boundary, group] of innermostFirst) {\n try {\n resolveGroup(boundary, group, handled);\n } catch (err) {\n reportResolveFailure(group, err);\n }\n }\n}\n\nfunction reportResolveFailure(crashes: AttributedCrash[], err: unknown): void {\n for (const crash of crashes)\n if (isSSRMode()) recordSSRRenderCrash(crash.el, crash.tag, crash.error);\n console.error('❌ Resolving a component crash failed:', err);\n}\n\nfunction depthOf(node: Node): number {\n let depth = 0;\n for (let at = node.parentNode; at; at = at.parentNode) depth++;\n return depth;\n}\n\n/**\n * One boundary's crashes, content before fallback, so the outcome does not\n * depend on the order they happened in. Each is handled as a crash placed there\n * directly: a content crash goes to the boundary, a fallback crash too unless\n * the boundary already shows its fallback, in which case it goes further out.\n */\nfunction resolveGroup(\n boundary: BoundaryInfo,\n group: AttributedCrash[],\n handled: Set<BoundaryInfo>\n): void {\n const inFallback = (crash: AttributedCrash) =>\n !!boundary.fallbackElement?.contains(crash.el);\n for (const crash of group.filter(crash => !inFallback(crash)))\n if (partOfShown(crash, boundary)) logCrash(crash);\n else deliver(crash, boundary, handled);\n for (const crash of group.filter(inFallback)) {\n if (partOfShown(crash, boundary)) logCrash(crash);\n else\n deliver(\n crash,\n showsError(boundary) ? crash.ops.parent(boundary) : boundary,\n handled\n );\n }\n}\n\n// Slot content a portal moves out of its boundary goes to that boundary, as a\n// component crash in it does through the slot frame. Only the nodes a slot\n// rendered carry an owner: a root a component mounts during setup has none.\nfunction placedAt(crash: AttributedCrash): BoundaryInfo | null {\n const { el, ops } = crash;\n const at = ops.locate(el);\n if (at || !el.isConnected) return at;\n const owner = ops.owner(el);\n return owner && !owner.contains(el) ? ops.locate(owner) : null;\n}\n\n// A delivery earlier in the resolution can hide it. A nearest boundary still\n// free takes it, though an ancestor hides both, as it would a crash placed there.\nfunction partOfShown(\n crash: AttributedCrash,\n nearest: BoundaryInfo | null\n): boolean {\n return crash.ops.hidden(crash.el) && (!nearest || showsError(nearest));\n}\n\n// As `setBoundaryError` decides: by the signal, which a `batch()` sets before\n// the boundary's effect updates `isActive`.\nfunction showsError(boundary: BoundaryInfo): boolean {\n return untrack(() => boundary.errorSignal()) !== null;\n}\n\n/**\n * Hands a crash to the first boundary from `from` outward that is not already\n * showing an error, as `setBoundaryError` escalates a crash placed there. One\n * that reaches a boundary showing an error from this resolution is part of it.\n */\nfunction deliver(\n crash: AttributedCrash,\n from: BoundaryInfo | null,\n handled: Set<BoundaryInfo>\n): void {\n for (let at = from; at; at = crash.ops.parent(at)) {\n if (handled.has(at)) {\n logCrash(crash);\n return;\n }\n if (showsError(at)) continue;\n let accepted = false;\n try {\n accepted = crash.ops.settle(crash.el, crash.tag, crash.error, at);\n } catch (err) {\n // An effect of the boundary threw; the crash is settled only if it took it.\n if (!showsError(at)) reportResolveFailure([crash], err);\n else console.error('❌ Resolving a component crash failed:', err);\n handled.add(at);\n return;\n }\n if (accepted) {\n handled.add(at);\n crash.onCaptured?.();\n } else logCrash(crash);\n return;\n }\n unhandled(crash);\n}\n\n/**\n * Before a component inside a boundary's fallback renders in a static render,\n * that boundary takes its crashes, so content the component renders from the\n * error (text is bound once there) has it.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"resolveBeforeFallback\",\"stability\":\"internal\",\"signature\":\"(el: Element) => void\"} */\nexport function resolveBeforeFallback(el: Element): void {\n if (!isSSRMode() || !heldCrashes()?.length) return;\n const owner = el.closest('[data-fallback]')?.closest('[data-error]');\n if (owner) resolveAttributedCrashes('render', owner);\n}\n"]}
1
+ {"version":3,"file":"ssrCrashes.js","sourceRoot":"","sources":["../../src/compile/ssrCrashes.ts"],"names":[],"mappings":"AAAA;;;;;;;EAOE;AAEF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,GAEZ,MAAM,2BAA2B,CAAC;AAcnC;;;;;;;;;;;;;;;;GAgBG;AACH,SAAS,aAAa;IACpB,MAAM,CAAC,GAAG,YAAY,EAAE,CAAC;IACzB,OAAO,CAAC,CAAC,CAAC,iBAAiB,KAAnB,CAAC,CAAC,iBAAiB,GAAK,IAAI,GAAG,EAAE,EAAi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AAG,EAAE,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACrE,IAAI,KAAK;QAAE,wBAAwB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AACvD,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.ssr-crashes\",\n \"title\": \"SSR Unhandled Component Crash Collector\",\n \"category\": \"runtime\",\n \"risk\": \"high\"\n}\n*/\n\nimport { untrack } from '@pithyjs/signals';\nimport { pithyGlobals } from '../types/globals';\nimport { isSSRMode } from './ssrMode';\nimport {\n boundaryContext,\n findParentBoundary,\n inOwnFallback,\n inBranch,\n isInHiddenContent,\n registeredClosest,\n setBoundaryError,\n slotOwnerOf,\n type BoundaryInfo,\n} from './binds/bindErrorBoundary';\n\n/**\n * A component render crash recorded during a static/server render.\n */\nexport interface SSRRenderCrash {\n /** The custom-element placeholder the crashed component was to replace. */\n el: Element;\n /** Authored tag name, for the failure message. */\n tag: string;\n /** The error the component threw. */\n error: Error;\n}\n\n/**\n * Crashes recorded during the current server render, keyed by the placeholder\n * element so a later binding pass over the same element can retract its own\n * earlier record (see `clearSSRRenderCrash`).\n *\n * Held on `globalThis`, not in this module. `@pithyjs/ssr` depends on\n * `@pithyjs/core` as a regular dependency, so an app and the SSR package can\n * resolve two physical copies: `html()` would record into the app's copy while\n * `renderToString()` collected and reset the SSR package's, reintroducing\n * BUG-018 *and* leaking the app copy's DOM records for the life of the process.\n * The same reasoning already puts `__PITHY_SSR__` and `__getComponentContext`\n * on this bridge.\n *\n * A `Map` (not a `WeakMap`) because the collector must be enumerable at flush\n * time. `resetSSRRenderCrashes()` is what keeps it from retaining DOM across\n * renders — the SSR renderer calls it in a `finally`.\n */\nfunction crashRegistry(): Map<Element, SSRRenderCrash> {\n const g = pithyGlobals();\n return (g.__pithySSRCrashes ??= new Map()) as Map<Element, SSRRenderCrash>;\n}\n\n/**\n * Forget any crash previously recorded for `el`.\n *\n * Called only at points where the record is provably no longer the outcome, and\n * NEVER before invoking a component. Retracting eagerly at the top of an attempt\n * hides a failed retry: a component that throws detached and then returns\n * something unusable would have its only record erased, shipping a page with a\n * missing subtree and a green build. The three call sites are:\n *\n * 1. A boundary ACCEPTING the error (`setBoundaryError()` returning `true`).\n * A boundary merely being in scope is not enough — an already-active one\n * with no free ancestor rejects the error, and that is as unhandled as\n * having no boundary at all.\n * 2. A component returning a usable node that then successfully reaches the\n * document, i.e. after `replaceWith` has not thrown.\n * 3. An element that has left the tree being bound (`scope.contains(el)` in\n * `bindComponentTags`, `fragment.contains(el)` in `applyBindings`). It can\n * no longer contribute to the output, so any record for it is stale.\n *\n * Every one of these is mutation-tested; removing any of them turns a correct\n * render into a failed route, or a broken one into a silent success.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"clearSSRRenderCrash\",\"stability\":\"internal\",\"signature\":\"(el: Element) => void\"} */\nexport function clearSSRRenderCrash(el: Element): void {\n crashRegistry().delete(el);\n}\n\n/**\n * Record a component failure that no error boundary took ownership of.\n *\n * The precondition is **not** \"no boundary was in scope\". It is that no boundary\n * ACCEPTED the error, which is a strictly weaker thing: `setBoundaryError()`\n * rejects an error when the nearest boundary is already showing one and no\n * ancestor is free, and both binders call this on that path with a boundary\n * very much present. Getting the two confused is what this whole module exists\n * to prevent.\n *\n * Nor is \"crash\" limited to a thrown error. The binders also record a component\n * that returned an unusable result, and one whose rendered node failed to reach\n * the document — both leave the raw tag exactly where a throw would, which is\n * the same content loss from the page's point of view.\n *\n * Callers must have established `isSSRMode()` themselves; this does not\n * re-check.\n */\nfunction recordSSRRenderCrash(el: Element, tag: string, error: unknown): void {\n crashRegistry().set(el, {\n el,\n tag,\n error: error instanceof Error ? error : new Error(String(error)),\n });\n}\n\n/**\n * Drop every recorded crash. Called by the SSR renderer before a render starts\n * and again in its `finally`, so one route's crash can never fail the next.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"resetSSRRenderCrashes\",\"stability\":\"stable\",\"signature\":\"() => void\"} */\nexport function resetSSRRenderCrashes(): void {\n crashRegistry().clear();\n const g = pithyGlobals();\n g.__pithyAttributedCrashes = [];\n g.__pithyRenderDepth = 0;\n}\n\n/**\n * An element that left the tree being bound contributes nothing to the output:\n * its recorded crash is stale, and an attributed one is only logged.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"forgetCrash\",\"stability\":\"internal\",\"signature\":\"(el: Element) => void\"} */\nexport function forgetCrash(el: Element): void {\n clearSSRRenderCrash(el);\n const crash = takeAttributedCrash(el);\n if (crash) logCrash(crash);\n}\n\nfunction takeAttributedCrash(el: Element): AttributedCrash | undefined {\n const list = heldCrashes();\n const at = list?.findIndex(crash => crash.el === el) ?? -1;\n return at >= 0 ? list?.splice(at, 1)[0] : undefined;\n}\n\n/**\n * Return the crashes still recorded once the render has finished, and empty\n * the collector.\n *\n * Every surviving record is a failure. A record is only ever retracted by\n * `clearSSRRenderCrash`, i.e. by a genuine re-attempt at the same element that\n * then went better — never by inspecting the finished tree.\n *\n * An earlier draft re-resolved each record's boundary here, dropping any crash\n * whose element had ended up inside an `@error-boundary`. That is unsound,\n * because a boundary *existing* above an element is not the same as that\n * boundary having *handled* the crash. A crash that a boundary rejected, or\n * that ran where no boundary resolved, is placed under one afterwards just the\n * same. Re-resolution dropped such a record: the boundary signal stayed null,\n * its fallback never activated, the raw component tag shipped, and the build\n * went green — the exact BUG-018 symptom, reintroduced by its own fix.\n *\n * A crash in a branch, slot or component built detached is attributed to its\n * boundary instead (`deferCrash`); whatever is still attributed here is\n * recorded.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"collectUnhandledSSRRenderCrashes\",\"stability\":\"stable\",\"signature\":\"() => SSRRenderCrash[]\"} */\nexport function collectUnhandledSSRRenderCrashes(): SSRRenderCrash[] {\n resolveAttributedCrashes('collect');\n const registry = crashRegistry();\n const unhandled = [...registry.values()];\n registry.clear();\n return unhandled;\n}\n\n/**\n * Hand a component failure to its `@error-boundary`, or record it if none takes\n * it. Returns whether a boundary accepted ownership.\n *\n * The single funnel for every way a component can fail to produce content: a\n * thrown error, an unusable return value, and a rendered node that never reached\n * the document. They were handled in five separate places and drifted — the\n * throw paths consulted the boundary while the malformed paths recorded\n * directly, so a component under `@error-boundary` that returned garbage left\n * the boundary signal null, rendered no fallback, and failed the route, even\n * though the code called it \"the same content loss as a crash\".\n *\n * With no `boundary`, a failure in a branch, slot or component built detached\n * is attributed to the boundary its render sits under (`deferCrash`) and counts\n * as handled here; `attribution` says how it is logged if no boundary takes it.\n *\n * Callers still do their own logging, since the wording differs per failure.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"reportComponentFailure\",\"stability\":\"internal\",\"signature\":\"(el: Element, tag: string, error: Error, boundary: BoundaryInfo | null, attribution?: Attribution) => boolean\"} */\nexport function reportComponentFailure(\n el: Element,\n tag: string,\n error: Error,\n boundary: BoundaryInfo | null,\n attribution: Attribution = {}\n): boolean {\n if (!boundary && deferCrash(el, tag, error, attribution)) return true;\n return settleFailure(el, tag, error, boundary, attribution);\n}\n\n/** How an attributed crash is logged: `message` if no boundary takes it, `onCaptured` if one does. */\nexport interface Attribution {\n message?: string | null;\n onCaptured?: () => void;\n}\n\nfunction settleFailure(\n el: Element,\n tag: string,\n error: Error,\n boundary: BoundaryInfo | null,\n attribution: Attribution = {}\n): boolean {\n while (boundary && inOwnFallback(boundary, el)) {\n const from: BoundaryInfo = boundary;\n boundary = findParentBoundary(from);\n if (\n !boundary &&\n !from.element.isConnected &&\n deferCrash(el, tag, error, attribution)\n )\n return true;\n }\n // A boundary in scope is not a boundary that accepted: an already-active one\n // with no free ancestor rejects, and that is as unhandled as having none.\n const accepted = boundary ? setBoundaryError(boundary, error) : false;\n\n if (isSSRMode()) {\n if (accepted || isInHiddenContent(el)) clearSSRRenderCrash(el);\n else recordSSRRenderCrash(el, tag, error);\n }\n\n return accepted;\n}\n\n/** A crash raised where no boundary was reachable, owned by the boundary its render sat under. */\ninterface AttributedCrash extends SSRRenderCrash {\n /** The boundary the branch, slot or component was built for: the crash waits until it is inside. */\n boundaryEl: Element;\n message: string | null;\n onCaptured?: () => void;\n ops: CrashOps;\n /** The outermost render it was attributed in; `0` outside any. */\n render: number;\n}\n\n/** The copy of core that attributed a crash answers these, against its own boundaries. */\ninterface CrashOps {\n locate: (el: Element) => BoundaryInfo | null;\n owner: (node: Node) => Element | null;\n hidden: (node: Node) => boolean;\n parent: (boundary: BoundaryInfo) => BoundaryInfo | null;\n ownFallback: (boundary: BoundaryInfo, el: Element) => boolean;\n settle: typeof settleFailure;\n}\n\nconst ops: CrashOps = {\n locate: registeredClosest,\n owner: slotOwnerOf,\n hidden: isInHiddenContent,\n parent: findParentBoundary,\n ownFallback: inOwnFallback,\n settle: settleFailure,\n};\n\nlet taskEndQueued = false;\n\n// A crash that is neither in place nor hidden when a render ends may belong to\n// content its caller inserts right after (a slot rendered from an effect): it\n// waits once, to the end of the task, before it is reported.\nfunction resolveAtTaskEnd(): void {\n if (taskEndQueued) return;\n taskEndQueued = true;\n queueMicrotask(() => {\n taskEndQueued = false;\n resolveAttributedCrashes('task');\n });\n}\n\n// Shared on `globalThis` for the reason the registry is: a second copy of core\n// must neither miss these nor resolve them in the middle of a render.\n\nfunction heldCrashes(): AttributedCrash[] | undefined {\n return pithyGlobals().__pithyAttributedCrashes as\n | AttributedCrash[]\n | undefined;\n}\n\nfunction renderDepth(change = 0): number {\n const g = pithyGlobals();\n return (g.__pithyRenderDepth = (g.__pithyRenderDepth ?? 0) + change);\n}\n\nfunction currentRender(): number {\n return renderDepth() > 0 ? (pithyGlobals().__pithyRenderId ?? 0) : 0;\n}\n\nfunction crashedElements(): WeakSet<Element> {\n const g = pithyGlobals();\n return (g.__pithyCrashedElements ??= new WeakSet()) as WeakSet<Element>;\n}\n\n/** Whether `el` crashed and was attributed; a retry would run its setup twice, which a build never does. */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"hasCrashed\",\"stability\":\"internal\",\"signature\":\"(el: Element) => boolean\"} */\nexport function hasCrashed(el: Element): boolean {\n return crashedElements().has(el);\n}\n\n/**\n * Brackets a render transaction: a template bind, or one structural update\n * that builds a branch and inserts it. Attributed crashes are resolved when the\n * outermost one ends, so a boundary hides its content only once everything in\n * it is bound and in place.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"withinRender\",\"stability\":\"internal\",\"signature\":\"<T>(fn: () => T) => T\"} */\nexport function withinRender<T>(fn: () => T): T {\n const g = pithyGlobals();\n if (renderDepth() === 0) g.__pithyRenderId = (g.__pithyRenderId ?? 0) + 1;\n const render = g.__pithyRenderId ?? 0;\n renderDepth(1);\n let failed = false;\n try {\n return fn();\n } catch (err) {\n failed = true;\n throw err;\n } finally {\n renderDepth(-1);\n // Never throws, so a failed render keeps its own error. Its caller disposes\n // what it bound, boundaries included, so its own crashes are only reported.\n if (failed && renderDepth() === 0) reportCrashesOf(render);\n else resolveAttributedCrashes();\n }\n}\n\nfunction branchFailures(): WeakSet<Element> {\n const g = pithyGlobals();\n return (g.__pithyBranchFailures ??= new WeakSet()) as WeakSet<Element>;\n}\n\n/** Logs a component failure, and marks `el` when it failed in a branch. */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"logFailure\",\"stability\":\"internal\",\"signature\":\"(el: Element, log: () => void) => void\"} */\nexport function logFailure(el: Element, log: () => void): void {\n if (inBranch()) branchFailures().add(el);\n log();\n}\n\n/** Whether `el` failed while its branch was built; the pass that binds the inserted branch would retry it (BUG-161). */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"failedInBranch\",\"stability\":\"internal\",\"signature\":\"(el: Element) => boolean\"} */\nexport function failedInBranch(el: Element): boolean {\n return branchFailures().has(el);\n}\n\n/**\n * Attributes a crash that reached no boundary through the DOM to the boundary\n * its render sits under (`boundaryContext`): a branch, slot or component built\n * detached. Returns `false` with no such context, so the caller handles the\n * crash as before.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"deferCrash\",\"stability\":\"internal\",\"signature\":\"(el: Element, tag: string, error: Error, attribution?: Attribution) => boolean\"} */\nexport function deferCrash(\n el: Element,\n tag: string,\n error: Error,\n { message = null, onCaptured }: Attribution = {}\n): boolean {\n const boundaryEl = boundaryContext();\n if (!boundaryEl) return false;\n crashedElements().add(el);\n takeAttributedCrash(el);\n (pithyGlobals().__pithyAttributedCrashes ??= []).push({\n el,\n tag,\n error,\n boundaryEl,\n message,\n onCaptured,\n ops,\n render: currentRender(),\n });\n if (renderDepth() === 0) resolveAtTaskEnd();\n return true;\n}\n\nfunction hold(crash: AttributedCrash): void {\n (pithyGlobals().__pithyAttributedCrashes ??= []).push(crash);\n if (renderDepth() === 0) resolveAtTaskEnd();\n}\n\nfunction reportCrashesOf(render: number): void {\n const list = heldCrashes();\n if (!list?.length) return;\n for (const crash of list.splice(0)) {\n if (crash.render !== render) list.push(crash);\n else\n try {\n unhandled(crash);\n } catch (err) {\n reportResolveFailure([crash], err);\n }\n }\n}\n\nfunction logCrash(crash: AttributedCrash): void {\n if (crash.message) console.error(crash.message, crash.error);\n}\n\nfunction unhandled(crash: AttributedCrash): void {\n crash.ops.settle(crash.el, crash.tag, crash.error, null);\n logCrash(crash);\n}\n\n/**\n * Resolves attributed crashes once they are in place. Each goes to the nearest\n * registered boundary at its final position, exactly as a crash placed there\n * would, and within one resolution a boundary takes at most one error. In the\n * browser this waits for the\n * outermost render to end. A static render binds text once, so there the\n * component pass of the template that owns a boundary resolves its crashes\n * (`scope`), before that template's text is bound and after its components\n * ran. `task` runs at the end of the task; `collect` after the HTML is\n * serialized, and only records.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"resolveAttributedCrashes\",\"stability\":\"internal\",\"signature\":\"(mode?: 'render' | 'task' | 'collect', scope?: ParentNode) => void\"} */\nexport function resolveAttributedCrashes(\n mode: 'render' | 'task' | 'collect' = 'render',\n scope?: ParentNode\n): void {\n const list = heldCrashes();\n if (!list?.length) return;\n const midRender = mode === 'render' && renderDepth() > 0;\n if (midRender && (!scope || !isSSRMode())) return;\n const groups = new Map<BoundaryInfo, AttributedCrash[]>();\n const into = (boundary: BoundaryInfo, crash: AttributedCrash) => {\n const group = groups.get(boundary);\n if (group) group.push(crash);\n else groups.set(boundary, [crash]);\n };\n let waiting = false;\n for (const crash of list.splice(0)) {\n try {\n if (mode === 'collect') {\n unhandled(crash);\n continue;\n }\n if (midRender && !scope?.contains(crash.boundaryEl)) {\n list.push(crash);\n continue;\n }\n const target = placedAt(crash);\n if (partOfShown(crash, target)) {\n logCrash(crash);\n continue;\n }\n if (target) into(target, crash);\n // In its boundary with no registered one around it, or out of time.\n else if (\n mode === 'task' ||\n (!midRender && crash.boundaryEl.contains(crash.el))\n )\n unhandled(crash);\n else {\n // Not inserted yet: its caller may insert it right after.\n list.push(crash);\n waiting ||= !midRender;\n }\n } catch (err) {\n reportResolveFailure([crash], err);\n }\n }\n if (waiting) resolveAtTaskEnd();\n const innermostFirst = [...groups.entries()]\n .map(entry => ({ entry, depth: depthOf(entry[0].element) }))\n .sort((a, b) => b.depth - a.depth)\n .map(({ entry }) => entry);\n const run: Run = {\n groups,\n handled: new Set(),\n settled: new Set(),\n resolved: new Set(),\n final: mode === 'task',\n };\n for (const [boundary, group] of innermostFirst) {\n try {\n resolveGroup(boundary, group, run);\n } catch (err) {\n reportResolveFailure(group, err);\n }\n }\n}\n\nfunction reportResolveFailure(crashes: AttributedCrash[], err: unknown): void {\n for (const crash of crashes)\n if (isSSRMode()) recordSSRRenderCrash(crash.el, crash.tag, crash.error);\n console.error('❌ Resolving a component crash failed:', err);\n}\n\nfunction depthOf(node: Node): number {\n let depth = 0;\n for (let at = node.parentNode; at; at = at.parentNode) depth++;\n return depth;\n}\n\ninterface Run {\n groups: Map<BoundaryInfo, AttributedCrash[]>;\n handled: Set<BoundaryInfo>;\n settled: Set<BoundaryInfo>;\n resolved: Set<BoundaryInfo>;\n final: boolean;\n}\n\nfunction settleContent(boundary: BoundaryInfo, run: Run): void {\n if (run.settled.has(boundary)) return;\n run.settled.add(boundary);\n for (const [inner, group] of run.groups)\n if (\n inner !== boundary &&\n boundary.element.contains(inner.element) &&\n !boundary.fallbackElement?.contains(inner.element)\n )\n resolveGroup(inner, group, run);\n for (const crash of run.groups.get(boundary) ?? []) {\n if (boundary.fallbackElement?.contains(crash.el)) continue;\n if (partOfShown(crash, boundary)) logCrash(crash);\n else deliver(crash, boundary, run);\n }\n}\n\n/**\n * One boundary's crashes, content before fallback, so the outcome does not\n * depend on the order they happened in. Each is handled as a crash placed there\n * directly: a content crash goes to the boundary, a fallback crash further out.\n */\nfunction resolveGroup(\n boundary: BoundaryInfo,\n group: AttributedCrash[],\n run: Run\n): void {\n if (run.resolved.has(boundary)) return;\n run.resolved.add(boundary);\n settleContent(boundary, run);\n for (const crash of group) {\n if (!boundary.fallbackElement?.contains(crash.el)) continue;\n const outer = crash.ops.parent(boundary);\n if (!outer && !run.final && !boundary.element.isConnected) hold(crash);\n else if (partOfShown(crash, outsideOwnFallback(crash, outer)))\n logCrash(crash);\n else deliver(crash, outer, run);\n }\n}\n\nfunction outsideOwnFallback(\n crash: AttributedCrash,\n from: BoundaryInfo | null\n): BoundaryInfo | null {\n let at = from;\n while (at && crash.ops.ownFallback(at, crash.el)) at = crash.ops.parent(at);\n return at;\n}\n\n// Slot content a portal moves out of its boundary goes to that boundary, as a\n// component crash in it does through the slot frame. Only the nodes a slot\n// rendered carry an owner: a root a component mounts during setup has none.\nfunction placedAt(crash: AttributedCrash): BoundaryInfo | null {\n const { el, ops } = crash;\n const at = ops.locate(el);\n if (at || !el.isConnected) return at;\n const owner = ops.owner(el);\n return owner && !owner.contains(el) ? ops.locate(owner) : null;\n}\n\n// A delivery earlier in the resolution can hide it. A nearest boundary still\n// free takes it, though an ancestor hides both, as it would a crash placed there.\nfunction partOfShown(\n crash: AttributedCrash,\n nearest: BoundaryInfo | null\n): boolean {\n return crash.ops.hidden(crash.el) && (!nearest || showsError(nearest));\n}\n\n// As `setBoundaryError` decides: by the signal, which a `batch()` sets before\n// the boundary's effect updates `isActive`.\nfunction showsError(boundary: BoundaryInfo): boolean {\n return untrack(() => boundary.errorSignal()) !== null;\n}\n\n/**\n * Hands a crash to the first boundary from `from` outward that is not already\n * showing an error, as `setBoundaryError` escalates a crash placed there. One\n * that reaches a boundary showing an error from this resolution is part of it.\n */\nfunction deliver(\n crash: AttributedCrash,\n from: BoundaryInfo | null,\n run: Run\n): void {\n const { handled, final } = run;\n for (let at = from; at; at = crash.ops.parent(at)) {\n if (crash.ops.ownFallback(at, crash.el)) {\n if (!final && !at.element.isConnected && !crash.ops.parent(at)) {\n hold(crash);\n return;\n }\n settleContent(at, run);\n continue;\n }\n if (handled.has(at)) {\n logCrash(crash);\n return;\n }\n if (showsError(at)) continue;\n let accepted = false;\n try {\n accepted = crash.ops.settle(crash.el, crash.tag, crash.error, at);\n } catch (err) {\n // An effect of the boundary threw; the crash is settled only if it took it.\n if (!showsError(at)) reportResolveFailure([crash], err);\n else console.error('❌ Resolving a component crash failed:', err);\n handled.add(at);\n return;\n }\n if (accepted) {\n handled.add(at);\n crash.onCaptured?.();\n } else logCrash(crash);\n return;\n }\n unhandled(crash);\n}\n\n/**\n * Before a component inside a boundary's fallback renders in a static render,\n * that boundary takes its crashes, so content the component renders from the\n * error (text is bound once there) has it.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"resolveBeforeFallback\",\"stability\":\"internal\",\"signature\":\"(el: Element) => void\"} */\nexport function resolveBeforeFallback(el: Element): void {\n if (!isSSRMode() || !heldCrashes()?.length) return;\n const owner = el.closest('[data-fallback]')?.closest('[data-error]');\n if (owner) resolveAttributedCrashes('render', owner);\n}\n"]}
@@ -7,6 +7,12 @@
7
7
  */
8
8
  import { type Desc, type EventDesc, type InterpDesc, type ClassDesc, type ClassesDesc, type StyleDesc, type BoundDesc, type RefDesc, type BindDesc, type CompDesc, type DeferDesc, type ErrorDesc, type ProjDesc, type IfDesc, type ForDesc, type SwitchDesc } from './bindings/index.js';
9
9
  export type { Desc, EventDesc, InterpDesc, ClassDesc, ClassesDesc, StyleDesc, BoundDesc, RefDesc, BindDesc, CompDesc, DeferDesc, ErrorDesc, ProjDesc, IfDesc, ForDesc, SwitchDesc, };
10
+ /**
11
+ * Marks a later `<slot>` of a name (`dup`). Generated code imports it, so a
12
+ * core older than the plugin fails to link instead of misplacing fallbacks.
13
+ */
14
+ /** @codexApi {"parent":"pithy.runtime.apply-bindings","name":"__slotDup","stability":"internal","signature":"true"} */
15
+ export declare const __slotDup = true;
10
16
  /**
11
17
  * Applies pre-extracted binding descriptors to an AOT-generated DOM fragment.
12
18
  *
@@ -1 +1 @@
1
- {"version":3,"file":"applyBindings.d.ts","sourceRoot":"","sources":["../../src/runtime/applyBindings.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAWF,OAAO,EAsBL,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,CAI/C"}
1
+ {"version":3,"file":"applyBindings.d.ts","sourceRoot":"","sources":["../../src/runtime/applyBindings.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAWF,OAAO,EAsBL,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;;;GAGG;AACH,uHAAuH;AACvH,eAAO,MAAM,SAAS,OAAO,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;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,CAI/C"}
@@ -12,6 +12,12 @@ import { orderByDocument } from '../compile/disposeOrder.js';
12
12
  import { executeCustomDirectiveBinders } from '../compile/binds/directiveRegistry.js';
13
13
  import { buildPidMap, buildCommentMap, mergeContexts, nearestCtx, applyRef, applyError, markBoundary, applyProjection, applyComponent, applyBind, applyInterpolation, markSkeletonText, applyEvent, applyClass, applyClasses, applyStyle, applyBound, applyIf, applyFor, applySwitch, applyDefer, } from './bindings/index.js';
14
14
  // ─── Main entry point ─────────────────────────────────────────────────────────
15
+ /**
16
+ * Marks a later `<slot>` of a name (`dup`). Generated code imports it, so a
17
+ * core older than the plugin fails to link instead of misplacing fallbacks.
18
+ */
19
+ /** @codexApi {"parent":"pithy.runtime.apply-bindings","name":"__slotDup","stability":"internal","signature":"true"} */
20
+ export const __slotDup = true;
15
21
  /**
16
22
  * Applies pre-extracted binding descriptors to an AOT-generated DOM fragment.
17
23
  *