@pithyjs/core 0.1.0-beta.10 → 0.1.0-beta.12

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 (32) hide show
  1. package/README.md +2 -2
  2. package/dist/compile/binds/bindBoundAttributes.d.ts +1 -1
  3. package/dist/compile/binds/bindBoundAttributes.d.ts.map +1 -1
  4. package/dist/compile/binds/bindBoundAttributes.js +34 -11
  5. package/dist/compile/binds/bindBoundAttributes.js.map +1 -1
  6. package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
  7. package/dist/compile/binds/bindComponentsTags.js +13 -1
  8. package/dist/compile/binds/bindComponentsTags.js.map +1 -1
  9. package/dist/compile/binds/bindErrorBoundary.d.ts +20 -0
  10. package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
  11. package/dist/compile/binds/bindErrorBoundary.js +124 -7
  12. package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
  13. package/dist/compile/contentProjection.d.ts +1 -1
  14. package/dist/compile/contentProjection.d.ts.map +1 -1
  15. package/dist/compile/contentProjection.js +6 -4
  16. package/dist/compile/contentProjection.js.map +1 -1
  17. package/dist/compile/renderChildren.d.ts +8 -0
  18. package/dist/compile/renderChildren.d.ts.map +1 -1
  19. package/dist/compile/renderChildren.js +22 -0
  20. package/dist/compile/renderChildren.js.map +1 -1
  21. package/dist/runtime/applyBindings.d.ts.map +1 -1
  22. package/dist/runtime/applyBindings.js +13 -11
  23. package/dist/runtime/applyBindings.js.map +1 -1
  24. package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
  25. package/dist/runtime/bindings/applyComponent.js +73 -43
  26. package/dist/runtime/bindings/applyComponent.js.map +1 -1
  27. package/dist/runtime/bindings/applySimple.js +4 -4
  28. package/dist/runtime/bindings/applySimple.js.map +1 -1
  29. package/dist/runtime/bindings/types.d.ts +2 -0
  30. package/dist/runtime/bindings/types.d.ts.map +1 -1
  31. package/dist/runtime/bindings/types.js.map +1 -1
  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AAE,CAAC;YAC1C,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC;gBACzB,OAAO,CAAC,IAAI,CACV,2BAA2B,UAAU,mDAAmD,UAAU,CAAC,OAAO,EAAE,CAC7G,CAAC;YACJ,CAAC;YACD,SAAS;QACX,CAAC;QAED,gFAAgF;QAChF,cAAc,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;QACnD,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC9B,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IACzD,CAAC;AACH,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.feature.error-boundary\",\n \"title\": \"Error Boundary System\",\n \"category\": \"feature\"\n}\n*/\n\nimport { effect, Signal, untrack } from '@pithyjs/signals';\n\nconst boundElements = new WeakSet<Element>();\n\n/**\n * Represents an active error boundary in the DOM\n */\nexport interface BoundaryInfo {\n element: Element;\n errorSignal: Signal<Error | null>;\n fallbackElement: Element | null;\n contentPlaceholders: Map<Node, Comment>;\n isActive: boolean;\n}\n\n/**\n * Global registry of active error boundaries\n */\nconst activeBoundaries: BoundaryInfo[] = [];\n\n/**\n * Current boundary context for async error routing (used in later phases)\n */\nlet currentBoundaryContext: BoundaryInfo | null = null;\n\n/**\n * Flag to ensure timer patching happens only once\n */\nlet timersPatched = false;\n\n/**\n * Finds the BoundaryInfo for a given DOM element by traversing up the tree\n * @param el - Element to find boundary for\n * @returns BoundaryInfo if found, null otherwise\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"boundaryForElement\",\"stability\":\"stable\",\"signature\":\"(el: Element | null) => BoundaryInfo | null\"} */\nexport function boundaryForElement(el: Element | null): BoundaryInfo | null {\n if (!el) return null;\n\n // Find the closest boundary element\n const boundaryEl = el.closest('[data-error]');\n if (!boundaryEl) return null;\n\n // Find the registered boundary info\n return (\n activeBoundaries.find(boundary => boundary.element === boundaryEl) || null\n );\n}\n\n/**\n * Finds the parent boundary for a given boundary (for error escalation)\n * @param childBoundary - The child boundary to find parent for\n * @returns Parent BoundaryInfo if found, null otherwise\n */\nfunction findParentBoundary(childBoundary: BoundaryInfo): BoundaryInfo | null {\n // Start searching from the child boundary's parent element\n const parentEl = childBoundary.element.parentElement;\n if (!parentEl) return null;\n\n // Find the closest ancestor boundary element\n const parentBoundaryEl = parentEl.closest('[data-error]');\n if (!parentBoundaryEl) return null;\n\n // Find the registered boundary info\n return (\n activeBoundaries.find(boundary => boundary.element === parentBoundaryEl) ||\n null\n );\n}\n\n/**\n * Clears the error state of a boundary, restoring normal content\n * @param boundary - The boundary to clear\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"clearBoundaryError\",\"stability\":\"stable\",\"signature\":\"(boundary: BoundaryInfo) => void\"} */\nexport function clearBoundaryError(boundary: BoundaryInfo): void {\n if (untrack(() => boundary.errorSignal()) !== null) {\n boundary.errorSignal.set(null);\n }\n}\n\n/**\n * Sets an error on a boundary with escalation logic\n * If the boundary is already in error state, escalates to parent boundary\n * Matches React behavior: first error wins, subsequent errors ignored\n *\n * @param boundary - The boundary to set error on\n * @param error - The error to set\n * @returns `true` if some boundary took ownership of `error`; `false` if it was\n * dropped because this boundary was already showing an error and no ancestor\n * boundary was free to take it.\n *\n * Callers must not assume the error was handled. A component rendering inside an\n * *active* boundary's `@fallback` hits exactly the `false` path — the fallback is\n * the part the user actually sees, so a crash there that nobody records ships a\n * visibly broken page with a green build. `bindComponentTags` and\n * `applyComponent` use the return value to decide between retracting an SSR\n * crash record and adding one.\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"setBoundaryError\",\"stability\":\"stable\",\"signature\":\"(boundary: BoundaryInfo, error: Error) => boolean\"} */\nexport function setBoundaryError(\n boundary: BoundaryInfo,\n error: Error\n): boolean {\n // Check if this boundary is already in error state\n if (untrack(() => boundary.errorSignal()) !== null) {\n // Escalate to parent boundary\n const parentBoundary = findParentBoundary(boundary);\n if (parentBoundary) {\n return setBoundaryError(parentBoundary, error);\n }\n // IGNORE subsequent errors (React behavior - first error wins).\n // Nobody owns this error now, and the caller needs to know.\n return false;\n }\n\n // Set the error on this boundary\n boundary.errorSignal.set(error);\n return true;\n}\n\n/**\n * Runs a function within the context of a specific boundary\n * Used for scoping async operations to the correct boundary\n * @param boundary - Boundary to run within\n * @param fn - Function to execute\n * @returns Result of function execution\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"runWithBoundary\",\"stability\":\"stable\",\"signature\":\"<T>(boundary: BoundaryInfo | null, fn: () => T) => T\"} */\nexport function runWithBoundary<T>(\n boundary: BoundaryInfo | null,\n fn: () => T\n): T {\n const previousContext = currentBoundaryContext;\n currentBoundaryContext = boundary;\n try {\n return fn();\n } finally {\n currentBoundaryContext = previousContext;\n }\n}\n\nfunction patchTimersOnce(): void {\n if (timersPatched) return;\n timersPatched = true;\n\n // Patch setTimeout\n const originalSetTimeout = window.setTimeout;\n window.setTimeout = ((\n callback: TimerHandler,\n delay?: number,\n ...args: unknown[]\n ) => {\n // Don't wrap string callbacks; let the browser handle them\n if (typeof callback !== 'function') {\n return originalSetTimeout(callback, delay, ...args);\n }\n\n const capturedBoundary = currentBoundaryContext;\n const fn = callback as (...callbackArgs: unknown[]) => unknown;\n const wrappedCallback = (...callbackArgs: unknown[]) => {\n return runWithBoundary(capturedBoundary, () => {\n try {\n return fn(...callbackArgs);\n } catch (error) {\n if (capturedBoundary) {\n const err =\n error instanceof Error ? error : new Error(String(error));\n setBoundaryError(capturedBoundary, err);\n } else {\n throw error;\n }\n }\n });\n };\n return originalSetTimeout(wrappedCallback, delay, ...args);\n }) as typeof window.setTimeout;\n\n // Patch setInterval\n const originalSetInterval = window.setInterval;\n window.setInterval = ((\n callback: TimerHandler,\n delay?: number,\n ...args: unknown[]\n ) => {\n // Don't wrap string callbacks; let the browser handle them\n if (typeof callback !== 'function') {\n return originalSetInterval(callback, delay, ...args);\n }\n\n const capturedBoundary = currentBoundaryContext;\n const fn = callback as (...callbackArgs: unknown[]) => unknown;\n const wrappedCallback = (...callbackArgs: unknown[]) => {\n return runWithBoundary(capturedBoundary, () => {\n try {\n return fn(...callbackArgs);\n } catch (error) {\n if (capturedBoundary) {\n const err =\n error instanceof Error ? error : new Error(String(error));\n setBoundaryError(capturedBoundary, err);\n } else {\n throw error;\n }\n }\n });\n };\n return originalSetInterval(wrappedCallback, delay, ...args);\n }) as typeof window.setInterval;\n}\n\n/**\n * Finds the fallback element within a boundary\n * @param boundaryEl - The boundary element to search within\n * @returns The fallback element or null if not found\n */\nfunction findFallbackElement(boundaryEl: Element): Element | null {\n // Look through direct children first to avoid nested boundary fallbacks\n for (const child of Array.from(boundaryEl.children)) {\n if (child.hasAttribute('data-fallback')) {\n // Double-check that this fallback belongs to this boundary\n const fallbackBoundary = child.closest('[data-error]');\n if (fallbackBoundary === boundaryEl) {\n return child;\n }\n }\n }\n\n // If no direct child fallback found, search deeper but be more careful\n const allFallbacks = Array.from(\n boundaryEl.querySelectorAll('[data-fallback]')\n );\n for (const fallback of allFallbacks) {\n const fallbackBoundary = fallback.closest('[data-error]');\n if (fallbackBoundary === boundaryEl) {\n return fallback;\n }\n }\n\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] No fallback element found for boundary`,\n boundaryEl.tagName,\n 'Available children:',\n Array.from(boundaryEl.children).map(\n c =>\n c.tagName +\n (c.hasAttribute('data-fallback') ? '[fallback]' : '') +\n (c.hasAttribute('data-error') ? '[boundary]' : '')\n )\n );\n }\n\n return null;\n}\n\n/**\n * Gets current content nodes (excluding fallback) - recomputed each time\n * @param boundaryEl - The boundary element\n * @param fallbackEl - The fallback element to exclude\n * @returns Array of content nodes\n */\nfunction getCurrentContentNodes(\n boundaryEl: Element,\n fallbackEl: Element | null\n): Node[] {\n return Array.from(boundaryEl.childNodes).filter(n => {\n // Exclude the fallback element for this boundary\n if (n === fallbackEl) return false;\n\n // Exclude placeholder comments from other boundaries\n if (\n n.nodeType === Node.COMMENT_NODE &&\n (n as Comment).data === 'pithy-boundary-hidden'\n ) {\n return false;\n }\n\n // Don't hide nested boundary elements that are currently showing their fallback\n if (n.nodeType === Node.ELEMENT_NODE) {\n const element = n as Element;\n if (element.hasAttribute('data-error')) {\n // This is a nested boundary - check if it's currently in error state\n const nestedBoundary = activeBoundaries.find(\n b => b.element === element\n );\n if (nestedBoundary && nestedBoundary.isActive) {\n // If a nested boundary is already active, keep it visible instead of replacing with our fallback\n return false;\n }\n }\n }\n\n return true;\n });\n}\n\n/**\n * Hides content by replacing nodes with comment placeholders\n * @param boundary - The boundary info\n */\nfunction hideContent(boundary: BoundaryInfo): void {\n const { element, fallbackElement, contentPlaceholders } = boundary;\n const nodes = getCurrentContentNodes(element, fallbackElement);\n\n for (const node of nodes) {\n if (contentPlaceholders.has(node)) continue;\n const placeholder = document.createComment('pithy-boundary-hidden');\n node.parentNode?.replaceChild(placeholder, node);\n contentPlaceholders.set(node, placeholder);\n }\n\n // Always show the fallback element if it exists\n if (fallbackElement) {\n (fallbackElement as HTMLElement).style.display = '';\n }\n}\n\n/**\n * Restores content by replacing comment placeholders with original nodes\n * @param boundary - The boundary info\n */\nfunction restoreContent(boundary: BoundaryInfo): void {\n const { fallbackElement, contentPlaceholders } = boundary;\n\n for (const [node, placeholder] of Array.from(contentPlaceholders.entries())) {\n placeholder.parentNode?.replaceChild(node, placeholder);\n contentPlaceholders.delete(node);\n }\n\n if (fallbackElement) {\n (fallbackElement as HTMLElement).style.display = 'none';\n }\n}\n\n/**\n * Hides the fallback element\n * @param fallbackEl - The fallback element to hide\n */\nfunction hideFallback(fallbackEl: Element): void {\n (fallbackEl as HTMLElement).style.display = 'none';\n}\n\n/**\n * Creates and registers an error boundary\n * @param boundaryEl - The boundary element\n * @param errorSignal - The error signal from context\n * @param disposers - Array to add cleanup functions to\n * @returns The created BoundaryInfo\n */\nfunction createBoundary(\n boundaryEl: Element,\n errorSignal: Signal<Error | null>,\n disposers: (() => void)[]\n): BoundaryInfo {\n const fallbackEl = findFallbackElement(boundaryEl);\n\n const boundary: BoundaryInfo = {\n element: boundaryEl,\n errorSignal,\n fallbackElement: fallbackEl,\n contentPlaceholders: new Map(),\n isActive: false,\n };\n\n // Register BEFORE effect so nested lookups can find us\n activeBoundaries.push(boundary);\n\n // Initially hide fallback\n if (fallbackEl) {\n hideFallback(fallbackEl);\n }\n\n // Set up reactive effect to toggle content/fallback based on error state\n const dispose = effect(() => {\n const error = errorSignal();\n const hasError = error !== null;\n\n if (hasError && !boundary.isActive) {\n // Show error state\n boundary.isActive = true;\n hideContent(boundary);\n } else if (!hasError && boundary.isActive) {\n // Show normal state\n boundary.isActive = false;\n restoreContent(boundary);\n }\n });\n\n // Add cleanup function\n disposers.push(() => {\n dispose();\n\n // Restore any hidden content\n if (boundary.isActive) {\n restoreContent(boundary);\n }\n\n // Remove from registry\n const index = activeBoundaries.indexOf(boundary);\n if (index >= 0) {\n activeBoundaries.splice(index, 1);\n }\n });\n\n return boundary;\n}\n\n/**\n * Register a single element as an error boundary.\n * Used by AOT applyBindings where the boundary element is known directly\n * (unlike bindErrorBoundary which scans children via querySelectorAll).\n *\n * @param boundaryEl - The element with data-error attribute\n * @param context - Reactive context containing error signals\n * @param disposers - Array to add cleanup functions to\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"registerBoundary\",\"stability\":\"stable\",\"signature\":\"(boundaryEl: Element, context: Record<string, unknown>, disposers: (() => void)[]) => void\"} */\nexport function registerBoundary(\n boundaryEl: Element,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n patchTimersOnce();\n\n const signalName = boundaryEl.getAttribute('data-error');\n if (!signalName) return;\n\n const errorSignal = context[signalName] as Signal<Error | null> | undefined;\n if (!errorSignal || typeof errorSignal !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] Signal \"${signalName}\" not found in context for boundary ${boundaryEl.tagName}`\n );\n }\n return;\n }\n\n // Validate that the signal is writable — computed signals or non-signal\n // functions will throw at runtime when setBoundaryError calls .set()\n if (typeof errorSignal.set !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] Signal \"${signalName}\" is not writable (no .set method) for boundary ${boundaryEl.tagName}`\n );\n }\n return;\n }\n\n createBoundary(boundaryEl, errorSignal, disposers);\n}\n\n/**\n * Binds error boundaries in the DOM fragment\n * Scans for [data-error] elements and sets up error boundary behavior\n *\n * @param fragment - DOM fragment to scan\n * @param context - Reactive context containing error signals\n * @param disposers - Array to add cleanup functions to\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"bindErrorBoundary\",\"stability\":\"stable\",\"signature\":\"(fragment: Element | DocumentFragment, context: Record<string, unknown>, disposers: (() => void)[]) => void\"} */\nexport function bindErrorBoundary(\n fragment: Element | DocumentFragment,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n // Patch timers on first boundary registration\n patchTimersOnce();\n\n const boundaryElements = Array.from(\n fragment.querySelectorAll('[data-error]')\n );\n\n for (const boundaryEl of boundaryElements) {\n if (boundElements.has(boundaryEl)) continue;\n const signalName = boundaryEl.getAttribute('data-error');\n if (!signalName) continue;\n\n const errorSignal = context[signalName] as Signal<Error | null> | undefined;\n if (!errorSignal || typeof errorSignal !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] Signal \"${signalName}\" not found in context for boundary ${boundaryEl.tagName}`\n );\n }\n continue;\n }\n\n // Validate that the signal is writable — computed signals or non-signal\n // functions will throw at runtime when setBoundaryError calls .set()\n if (typeof errorSignal.set !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] Signal \"${signalName}\" is not writable (no .set method) for boundary ${boundaryEl.tagName}`\n );\n }\n continue;\n }\n\n // Create and register the boundary (registration happens inside createBoundary)\n createBoundary(boundaryEl, errorSignal, disposers);\n boundElements.add(boundaryEl);\n disposers.push(() => boundElements.delete(boundaryEl));\n }\n}\n"]}
1
+ {"version":3,"file":"bindErrorBoundary.js","sourceRoot":"","sources":["../../../src/compile/binds/bindErrorBoundary.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,MAAM,EAAU,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3D,MAAM,aAAa,GAAG,IAAI,OAAO,EAAW,CAAC;AAe7C;;GAEG;AACH,MAAM,gBAAgB,GAAmB,EAAE,CAAC;AAE5C;;GAEG;AACH,IAAI,sBAAsB,GAAwB,IAAI,CAAC;AAiBvD,IAAI,SAAS,GAAqB,IAAI,CAAC;AAEvC;;GAEG;AACH,IAAI,aAAa,GAAG,KAAK,CAAC;AAE1B;;;;GAIG;AACH,qKAAqK;AACrK,MAAM,UAAU,kBAAkB,CAAC,EAAkB;IACnD,MAAM,UAAU,GAAG,EAAE,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IAC/C,IAAI,CAAC,UAAU;QAAE,OAAO,SAAS,EAAE,QAAQ,IAAI,IAAI,CAAC;IAEpD,oCAAoC;IACpC,OAAO,CACL,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,KAAK,UAAU,CAAC,IAAI,IAAI,CAC3E,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,QAAsB;IAC5C,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC;IACnC,OAAO,MAAM,IAAI,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACrE,CAAC;AAED;;;;GAIG;AACH,wMAAwM;AACxM,MAAM,UAAU,gBAAgB,CAC9B,MAAwB,EACxB,IAAyB,EACzB,EAAW;IAEX,MAAM,KAAK,GAAG,SAAS,CAAC;IACxB,IAAI,MAAM,EAAE,CAAC;QACX,gEA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\",\n \"category\": \"feature\"\n}\n*/\n\nimport { effect, Signal, untrack } from '@pithyjs/signals';\n\nconst boundElements = new WeakSet<Element>();\n\n/**\n * Represents an active error boundary in the DOM\n */\nexport interface BoundaryInfo {\n element: Element;\n errorSignal: Signal<Error | null>;\n fallbackElement: Element | null;\n contentPlaceholders: Map<Node, Comment>;\n isActive: boolean;\n /** The receiving boundary of the slot this one was rendered in, detached. */\n slotParent?: BoundaryInfo | null;\n}\n\n/**\n * Global registry of active error boundaries\n */\nconst activeBoundaries: BoundaryInfo[] = [];\n\n/**\n * Current boundary context for async error routing (used in later phases)\n */\nlet currentBoundaryContext: BoundaryInfo | null = null;\n\n/** A slot being rendered, detached, so its content cannot `closest()` its boundary. */\ninterface SlotFrame {\n boundary: BoundaryInfo | null;\n anchor: Node;\n /** The component placeholder whose render mounts this slot. */\n host: Element | undefined;\n /** The slot rendering `host`. */\n outer: SlotFrame | null;\n /** Whether `boundary` was resolved here rather than inherited from `outer`. */\n own: boolean;\n /** Whether the slot's nodes land directly in `boundary.element`, when `own`. */\n direct: boolean;\n /** Whether the slot is the boundary's normal content, which its fallback replaces. */\n isContent: boolean;\n}\nlet slotFrame: SlotFrame | null = null;\n\n/**\n * Flag to ensure timer patching happens only once\n */\nlet timersPatched = false;\n\n/**\n * Finds the BoundaryInfo for a given DOM element by traversing up the tree\n * @param el - Element to find boundary for\n * @returns BoundaryInfo if found, null otherwise\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"boundaryForElement\",\"stability\":\"stable\",\"signature\":\"(el: Element | null) => BoundaryInfo | null\"} */\nexport function boundaryForElement(el: Element | null): BoundaryInfo | null {\n const boundaryEl = el?.closest('[data-error]');\n if (!boundaryEl) return slotFrame?.boundary ?? null;\n\n // Find the registered boundary info\n return (\n activeBoundaries.find(boundary => boundary.element === boundaryEl) || null\n );\n}\n\nfunction liveSlotParent(boundary: BoundaryInfo): BoundaryInfo | null {\n const parent = boundary.slotParent;\n return parent && activeBoundaries.includes(parent) ? parent : null;\n}\n\n/**\n * Renders a slot whose receiving `<slot>` sits at `anchor`, mounted by the\n * component placeholder `host`. Its content is detached while it renders, so\n * boundaries are resolved through the anchor.\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"withSlotBoundary\",\"stability\":\"experimental\",\"signature\":\"<T>(anchor: Node | undefined, host: Element | undefined, fn: () => T) => T\"} */\nexport function withSlotBoundary<T>(\n anchor: Node | undefined,\n host: Element | undefined,\n fn: () => T\n): T {\n const outer = slotFrame;\n if (anchor) {\n // An anchor an earlier crash hid has no parent to resolve from.\n const hider = hiderOf(anchor);\n const boundary = hider ?? boundaryForElement(anchor.parentElement);\n slotFrame =\n boundary === outer?.boundary\n ? { ...outer, anchor, host, outer, own: false, direct: false }\n : {\n boundary,\n anchor,\n host,\n outer,\n own: true,\n direct: hider\n ? hider.contentPlaceholders.has(anchor)\n : anchor.parentElement === boundary?.element,\n isContent: !!hider || !boundary?.fallbackElement?.contains(anchor),\n };\n }\n try {\n return fn();\n } finally {\n slotFrame = outer;\n }\n}\n\n/** Whether `el`, in the slot being rendered, is normal content an active fallback has replaced. */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"slotContentHidden\",\"stability\":\"experimental\",\"signature\":\"(el: Element) => boolean\"} */\nexport function slotContentHidden(el: Element): boolean {\n // Every boundary the slot frames pass through can hide it, not just the nearest.\n const inner = slotFrame;\n let up = 0;\n for (let frame = inner; frame; up++) {\n if (frame.isContent && frame.boundary?.isActive) {\n // As `hideContent`: an active nested boundary stays visible beside the fallback.\n const child = receiverChild(el, inner as SlotFrame, up);\n if (!activeBoundaries.some(b => b.element === child && b.isActive))\n return true;\n }\n while (!frame.own && frame.outer) frame = frame.outer;\n frame = frame.outer;\n }\n return false;\n}\n\n/**\n * The direct child of a boundary element that will hold `node`: the boundary\n * of `frame` when `up` is 0, else that many boundary changes further out.\n */\nfunction receiverChild(node: Node, frame: SlotFrame, up: number): Node | null {\n const top = rootOf(node);\n if (frame.own && up === 0) return frame.direct ? top : null;\n if (!frame.host || !frame.outer) return null;\n const hostChild = receiverChild(\n frame.host,\n frame.outer,\n frame.own ? up - 1 : up\n );\n if (hostChild !== frame.host) return hostChild;\n // The host's output replaces it; a bare slot puts this content in its place.\n // A boundary may have hidden the anchor since: its stand-in holds the place.\n const at = standInOf(frame.anchor) ?? frame.anchor;\n const anchorTop = rootOf(at);\n return anchorTop === at ? top : anchorTop;\n}\n\nfunction standInOf(node: Node): Comment | undefined {\n for (const boundary of activeBoundaries) {\n const standIn = boundary.contentPlaceholders.get(node);\n if (standIn) return standIn;\n }\n return undefined;\n}\n\nfunction rootOf(node: Node): Node {\n let top = node;\n while (\n top.parentNode &&\n top.parentNode.nodeType !== Node.DOCUMENT_FRAGMENT_NODE\n )\n top = top.parentNode;\n return top;\n}\n\nfunction hiderOf(node: Node): BoundaryInfo | undefined {\n let top = node;\n while (top.parentNode) top = top.parentNode;\n return activeBoundaries.find(b => b.contentPlaceholders.has(top));\n}\n\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"isHiddenByBoundary\",\"stability\":\"experimental\",\"signature\":\"(node: Node) => boolean\"} */\nexport function isHiddenByBoundary(node: Node): boolean {\n return activeBoundaries.some(\n b => !!b.contentPlaceholders.get(node)?.parentNode\n );\n}\n\n/**\n * Inserts `content` after `anchor` when an active boundary has hidden the\n * anchor, which a crash during a slot's render can do, and hides it too.\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"insertBesideHidden\",\"stability\":\"experimental\",\"signature\":\"(anchor: Node, content: Node) => boolean\"} */\nexport function insertBesideHidden(anchor: Node, content: Node): boolean {\n for (const boundary of activeBoundaries) {\n const standIn = boundary.contentPlaceholders.get(anchor);\n if (!standIn?.parentNode) continue;\n standIn.parentNode.insertBefore(content, standIn.nextSibling);\n if (boundary.isActive) hideContent(boundary);\n return true;\n }\n return false;\n}\n\n/**\n * Finds the parent boundary for a given boundary (for error escalation)\n * @param childBoundary - The child boundary to find parent for\n * @returns Parent BoundaryInfo if found, null otherwise\n */\nfunction findParentBoundary(childBoundary: BoundaryInfo): BoundaryInfo | null {\n // Start searching from the child boundary's parent element\n const parentEl = childBoundary.element.parentElement;\n if (!parentEl) return liveSlotParent(childBoundary);\n\n // Find the closest ancestor boundary element\n const parentBoundaryEl = parentEl.closest('[data-error]');\n if (!parentBoundaryEl) return liveSlotParent(childBoundary);\n\n // Find the registered boundary info\n return (\n activeBoundaries.find(boundary => boundary.element === parentBoundaryEl) ||\n null\n );\n}\n\n/**\n * Clears the error state of a boundary, restoring normal content\n * @param boundary - The boundary to clear\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"clearBoundaryError\",\"stability\":\"stable\",\"signature\":\"(boundary: BoundaryInfo) => void\"} */\nexport function clearBoundaryError(boundary: BoundaryInfo): void {\n if (untrack(() => boundary.errorSignal()) !== null) {\n boundary.errorSignal.set(null);\n }\n}\n\n/**\n * Sets an error on a boundary with escalation logic\n * If the boundary is already in error state, escalates to parent boundary\n * Matches React behavior: first error wins, subsequent errors ignored\n *\n * @param boundary - The boundary to set error on\n * @param error - The error to set\n * @returns `true` if some boundary took ownership of `error`; `false` if it was\n * dropped because this boundary was already showing an error and no ancestor\n * boundary was free to take it.\n *\n * Callers must not assume the error was handled. A component rendering inside an\n * *active* boundary's `@fallback` hits exactly the `false` path — the fallback is\n * the part the user actually sees, so a crash there that nobody records ships a\n * visibly broken page with a green build. `bindComponentTags` and\n * `applyComponent` use the return value to decide between retracting an SSR\n * crash record and adding one.\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"setBoundaryError\",\"stability\":\"stable\",\"signature\":\"(boundary: BoundaryInfo, error: Error) => boolean\"} */\nexport function setBoundaryError(\n boundary: BoundaryInfo,\n error: Error\n): boolean {\n // Check if this boundary is already in error state\n if (untrack(() => boundary.errorSignal()) !== null) {\n // Escalate to parent boundary\n const parentBoundary = findParentBoundary(boundary);\n if (parentBoundary) {\n return setBoundaryError(parentBoundary, error);\n }\n // IGNORE subsequent errors (React behavior - first error wins).\n // Nobody owns this error now, and the caller needs to know.\n return false;\n }\n\n // Set the error on this boundary\n boundary.errorSignal.set(error);\n return true;\n}\n\n/**\n * Runs a function within the context of a specific boundary\n * Used for scoping async operations to the correct boundary\n * @param boundary - Boundary to run within\n * @param fn - Function to execute\n * @returns Result of function execution\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"runWithBoundary\",\"stability\":\"stable\",\"signature\":\"<T>(boundary: BoundaryInfo | null, fn: () => T) => T\"} */\nexport function runWithBoundary<T>(\n boundary: BoundaryInfo | null,\n fn: () => T\n): T {\n const previousContext = currentBoundaryContext;\n currentBoundaryContext = boundary;\n try {\n return fn();\n } finally {\n currentBoundaryContext = previousContext;\n }\n}\n\nfunction patchTimersOnce(): void {\n if (timersPatched) return;\n timersPatched = true;\n\n // Patch setTimeout\n const originalSetTimeout = window.setTimeout;\n window.setTimeout = ((\n callback: TimerHandler,\n delay?: number,\n ...args: unknown[]\n ) => {\n // Don't wrap string callbacks; let the browser handle them\n if (typeof callback !== 'function') {\n return originalSetTimeout(callback, delay, ...args);\n }\n\n const capturedBoundary = currentBoundaryContext;\n const fn = callback as (...callbackArgs: unknown[]) => unknown;\n const wrappedCallback = (...callbackArgs: unknown[]) => {\n return runWithBoundary(capturedBoundary, () => {\n try {\n return fn(...callbackArgs);\n } catch (error) {\n if (capturedBoundary) {\n const err =\n error instanceof Error ? error : new Error(String(error));\n setBoundaryError(capturedBoundary, err);\n } else {\n throw error;\n }\n }\n });\n };\n return originalSetTimeout(wrappedCallback, delay, ...args);\n }) as typeof window.setTimeout;\n\n // Patch setInterval\n const originalSetInterval = window.setInterval;\n window.setInterval = ((\n callback: TimerHandler,\n delay?: number,\n ...args: unknown[]\n ) => {\n // Don't wrap string callbacks; let the browser handle them\n if (typeof callback !== 'function') {\n return originalSetInterval(callback, delay, ...args);\n }\n\n const capturedBoundary = currentBoundaryContext;\n const fn = callback as (...callbackArgs: unknown[]) => unknown;\n const wrappedCallback = (...callbackArgs: unknown[]) => {\n return runWithBoundary(capturedBoundary, () => {\n try {\n return fn(...callbackArgs);\n } catch (error) {\n if (capturedBoundary) {\n const err =\n error instanceof Error ? error : new Error(String(error));\n setBoundaryError(capturedBoundary, err);\n } else {\n throw error;\n }\n }\n });\n };\n return originalSetInterval(wrappedCallback, delay, ...args);\n }) as typeof window.setInterval;\n}\n\n/**\n * Finds the fallback element within a boundary\n * @param boundaryEl - The boundary element to search within\n * @returns The fallback element or null if not found\n */\nfunction findFallbackElement(boundaryEl: Element): Element | null {\n // Look through direct children first to avoid nested boundary fallbacks\n for (const child of Array.from(boundaryEl.children)) {\n if (child.hasAttribute('data-fallback')) {\n // Double-check that this fallback belongs to this boundary\n const fallbackBoundary = child.closest('[data-error]');\n if (fallbackBoundary === boundaryEl) {\n return child;\n }\n }\n }\n\n // If no direct child fallback found, search deeper but be more careful\n const allFallbacks = Array.from(\n boundaryEl.querySelectorAll('[data-fallback]')\n );\n for (const fallback of allFallbacks) {\n const fallbackBoundary = fallback.closest('[data-error]');\n if (fallbackBoundary === boundaryEl) {\n return fallback;\n }\n }\n\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] No fallback element found for boundary`,\n boundaryEl.tagName,\n 'Available children:',\n Array.from(boundaryEl.children).map(\n c =>\n c.tagName +\n (c.hasAttribute('data-fallback') ? '[fallback]' : '') +\n (c.hasAttribute('data-error') ? '[boundary]' : '')\n )\n );\n }\n\n return null;\n}\n\n/**\n * Gets current content nodes (excluding fallback) - recomputed each time\n * @param boundaryEl - The boundary element\n * @param fallbackEl - The fallback element to exclude\n * @returns Array of content nodes\n */\nfunction getCurrentContentNodes(\n boundaryEl: Element,\n fallbackEl: Element | null\n): Node[] {\n return Array.from(boundaryEl.childNodes).filter(n => {\n // Exclude the fallback element for this boundary\n if (n === fallbackEl) return false;\n\n // Exclude placeholder comments from other boundaries\n if (\n n.nodeType === Node.COMMENT_NODE &&\n (n as Comment).data === 'pithy-boundary-hidden'\n ) {\n return false;\n }\n\n // Don't hide nested boundary elements that are currently showing their fallback\n if (n.nodeType === Node.ELEMENT_NODE) {\n const element = n as Element;\n if (element.hasAttribute('data-error')) {\n // This is a nested boundary - check if it's currently in error state\n const nestedBoundary = activeBoundaries.find(\n b => b.element === element\n );\n if (nestedBoundary && nestedBoundary.isActive) {\n // If a nested boundary is already active, keep it visible instead of replacing with our fallback\n return false;\n }\n }\n }\n\n return true;\n });\n}\n\n/**\n * Hides content by replacing nodes with comment placeholders\n * @param boundary - The boundary info\n */\nfunction hideContent(boundary: BoundaryInfo): void {\n const { element, fallbackElement, contentPlaceholders } = boundary;\n const nodes = getCurrentContentNodes(element, fallbackElement);\n\n for (const node of nodes) {\n if (contentPlaceholders.has(node)) continue;\n const placeholder = document.createComment('pithy-boundary-hidden');\n node.parentNode?.replaceChild(placeholder, node);\n contentPlaceholders.set(node, placeholder);\n }\n\n // Always show the fallback element if it exists\n if (fallbackElement) {\n (fallbackElement as HTMLElement).style.display = '';\n }\n}\n\n/**\n * Restores content by replacing comment placeholders with original nodes\n * @param boundary - The boundary info\n */\nfunction restoreContent(boundary: BoundaryInfo): void {\n const { fallbackElement, contentPlaceholders } = boundary;\n\n for (const [node, placeholder] of Array.from(contentPlaceholders.entries())) {\n placeholder.parentNode?.replaceChild(node, placeholder);\n contentPlaceholders.delete(node);\n }\n\n if (fallbackElement) {\n (fallbackElement as HTMLElement).style.display = 'none';\n }\n}\n\n/**\n * Hides the fallback element\n * @param fallbackEl - The fallback element to hide\n */\nfunction hideFallback(fallbackEl: Element): void {\n (fallbackEl as HTMLElement).style.display = 'none';\n}\n\n/**\n * Creates and registers an error boundary\n * @param boundaryEl - The boundary element\n * @param errorSignal - The error signal from context\n * @param disposers - Array to add cleanup functions to\n * @returns The created BoundaryInfo\n */\nfunction createBoundary(\n boundaryEl: Element,\n errorSignal: Signal<Error | null>,\n disposers: (() => void)[]\n): BoundaryInfo {\n const fallbackEl = findFallbackElement(boundaryEl);\n\n const boundary: BoundaryInfo = {\n element: boundaryEl,\n errorSignal,\n fallbackElement: fallbackEl,\n contentPlaceholders: new Map(),\n isActive: false,\n slotParent: slotFrame?.boundary ?? null,\n };\n\n // Register BEFORE effect so nested lookups can find us\n activeBoundaries.push(boundary);\n\n // Initially hide fallback\n if (fallbackEl) {\n hideFallback(fallbackEl);\n }\n\n // Set up reactive effect to toggle content/fallback based on error state\n const dispose = effect(() => {\n const error = errorSignal();\n const hasError = error !== null;\n\n if (hasError && !boundary.isActive) {\n // Show error state\n boundary.isActive = true;\n hideContent(boundary);\n } else if (!hasError && boundary.isActive) {\n // Show normal state\n boundary.isActive = false;\n restoreContent(boundary);\n }\n });\n\n // Add cleanup function\n disposers.push(() => {\n dispose();\n\n // Restore any hidden content\n if (boundary.isActive) {\n restoreContent(boundary);\n }\n\n // Remove from registry\n const index = activeBoundaries.indexOf(boundary);\n if (index >= 0) {\n activeBoundaries.splice(index, 1);\n }\n });\n\n return boundary;\n}\n\n/**\n * Register a single element as an error boundary.\n * Used by AOT applyBindings where the boundary element is known directly\n * (unlike bindErrorBoundary which scans children via querySelectorAll).\n *\n * @param boundaryEl - The element with data-error attribute\n * @param context - Reactive context containing error signals\n * @param disposers - Array to add cleanup functions to\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"registerBoundary\",\"stability\":\"stable\",\"signature\":\"(boundaryEl: Element, context: Record<string, unknown>, disposers: (() => void)[]) => void\"} */\nexport function registerBoundary(\n boundaryEl: Element,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n patchTimersOnce();\n\n const signalName = boundaryEl.getAttribute('data-error');\n if (!signalName) return;\n\n const errorSignal = context[signalName] as Signal<Error | null> | undefined;\n if (!errorSignal || typeof errorSignal !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] Signal \"${signalName}\" not found in context for boundary ${boundaryEl.tagName}`\n );\n }\n return;\n }\n\n // Validate that the signal is writable — computed signals or non-signal\n // functions will throw at runtime when setBoundaryError calls .set()\n if (typeof errorSignal.set !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] Signal \"${signalName}\" is not writable (no .set method) for boundary ${boundaryEl.tagName}`\n );\n }\n return;\n }\n\n createBoundary(boundaryEl, errorSignal, disposers);\n}\n\n/**\n * Binds error boundaries in the DOM fragment\n * Scans for [data-error] elements and sets up error boundary behavior\n *\n * @param fragment - DOM fragment to scan\n * @param context - Reactive context containing error signals\n * @param disposers - Array to add cleanup functions to\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"bindErrorBoundary\",\"stability\":\"stable\",\"signature\":\"(fragment: Element | DocumentFragment, context: Record<string, unknown>, disposers: (() => void)[]) => void\"} */\nexport function bindErrorBoundary(\n fragment: Element | DocumentFragment,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n // Patch timers on first boundary registration\n patchTimersOnce();\n\n const boundaryElements = Array.from(\n fragment.querySelectorAll('[data-error]')\n );\n\n for (const boundaryEl of boundaryElements) {\n if (boundElements.has(boundaryEl)) continue;\n const signalName = boundaryEl.getAttribute('data-error');\n if (!signalName) continue;\n\n const errorSignal = context[signalName] as Signal<Error | null> | undefined;\n if (!errorSignal || typeof errorSignal !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] Signal \"${signalName}\" not found in context for boundary ${boundaryEl.tagName}`\n );\n }\n continue;\n }\n\n // Validate that the signal is writable — computed signals or non-signal\n // functions will throw at runtime when setBoundaryError calls .set()\n if (typeof errorSignal.set !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] Signal \"${signalName}\" is not writable (no .set method) for boundary ${boundaryEl.tagName}`\n );\n }\n continue;\n }\n\n // Create and register the boundary (registration happens inside createBoundary)\n createBoundary(boundaryEl, errorSignal, disposers);\n boundElements.add(boundaryEl);\n disposers.push(() => boundElements.delete(boundaryEl));\n }\n}\n"]}
@@ -10,7 +10,7 @@ import { PithyNode } from '@pithyjs/compiler';
10
10
  * SlotMap contains renderer functions for each slot name.
11
11
  * Each entry is a factory that returns a DocumentFragment of the slot's content.
12
12
  */
13
- export type SlotMap = Map<string, (disposers?: (() => void)[]) => DocumentFragment>;
13
+ export type SlotMap = Map<string, (disposers?: (() => void)[], anchor?: Node) => DocumentFragment>;
14
14
  /**
15
15
  * SlotDef describes a slot anchor and its fallback content
16
16
  */
@@ -1 +1 @@
1
- {"version":3,"file":"contentProjection.d.ts","sourceRoot":"","sources":["../../src/compile/contentProjection.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAQ9C;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,GAAG,CACvB,MAAM,EACN,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,KAAK,gBAAgB,CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,WAAW,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAE/E,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAaD,gMAAgM;AAChM,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,SAAS,EAAE,EACrB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACrC,OAAO,CAkFT;AAED,oKAAoK;AACpK,wBAAgB,eAAe,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,EAAE,CA6BrE;AAED,qMAAqM;AACrM,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAmKN"}
1
+ {"version":3,"file":"contentProjection.d.ts","sourceRoot":"","sources":["../../src/compile/contentProjection.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAY9C;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,GAAG,CACvB,MAAM,EACN,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,IAAI,KAAK,gBAAgB,CAChE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,WAAW,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAE/E,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAaD,gMAAgM;AAChM,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,SAAS,EAAE,EACrB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACrC,OAAO,CAkFT;AAED,oKAAoK;AACpK,wBAAgB,eAAe,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,EAAE,CA6BrE;AAED,qMAAqM;AACrM,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAqKN"}
@@ -8,7 +8,7 @@
8
8
  import { pithyTreeToDom } from './pithyTreeToDom.js';
9
9
  import { bindStructuralDirectives } from './compileTemplate.js';
10
10
  import { nodeExpando } from './nodeExpando.js';
11
- import { bindErrorBoundary } from './binds/bindErrorBoundary.js';
11
+ import { bindErrorBoundary, insertBesideHidden, isHiddenByBoundary, } from './binds/bindErrorBoundary.js';
12
12
  import { pithyGlobals } from '../types/globals.js';
13
13
  import { trimBlankEdges } from './trimBlankEdges.js';
14
14
  function expando(node) {
@@ -112,7 +112,8 @@ export function mountProjection(slotDefs, slotMap, disposers) {
112
112
  // Mark this slot as processed to prevent multiple passes
113
113
  expando(anchor).__projectionProcessed = true;
114
114
  const parent = anchor.parentNode;
115
- if (!parent) {
115
+ // A crash in an earlier slot can have hidden this anchor behind a fallback.
116
+ if (!parent && !isHiddenByBoundary(anchor)) {
116
117
  if (import.meta.env?.DEV) {
117
118
  console.warn(`[ContentProjection] Slot anchor "${name}" has no parent node - skipping`);
118
119
  }
@@ -123,7 +124,7 @@ export function mountProjection(slotDefs, slotMap, disposers) {
123
124
  let isProjectedContent = false;
124
125
  if (renderer) {
125
126
  // Use projected content
126
- contentFragment = renderer(disposers);
127
+ contentFragment = renderer(disposers, anchor);
127
128
  isProjectedContent = true;
128
129
  if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {
129
130
  console.log(`[PithyJS:Projection] Mounting projected content for slot "${name}"`);
@@ -199,7 +200,8 @@ export function mountProjection(slotDefs, slotMap, disposers) {
199
200
  }
200
201
  }
201
202
  // Insert new content after the anchor comment
202
- parent.insertBefore(contentFragment, anchor.nextSibling);
203
+ if (!insertBesideHidden(anchor, contentFragment))
204
+ parent?.insertBefore(contentFragment, anchor.nextSibling);
203
205
  // Track cleanup - remove projected nodes when component unmounts
204
206
  disposers.push(() => {
205
207
  for (const node of nodesToInsert) {
@@ -1 +1 @@
1
- {"version":3,"file":"contentProjection.js","sourceRoot":"","sources":["../../src/compile/contentProjection.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAGF,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,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,cAAc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AAG,CACT,0CAA0C,IAAI,oCAAoC,CACnF,CAAC;YACJ,CAAC;YACD,SAAS;QACX,CAAC;QAED,0BAA0B;QAC1B,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;YACjC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACpB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;QAED,8CAA8C;QAC9C,MAAM,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAEzD,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 { PithyNode } from '@pithyjs/compiler';\nimport { pithyTreeToDom } from './pithyTreeToDom';\nimport { bindStructuralDirectives } from './compileTemplate';\nimport { nodeExpando } from './nodeExpando';\nimport { bindErrorBoundary } from './binds/bindErrorBoundary';\nimport { pithyGlobals } from '../types/globals';\nimport { trimBlankEdges } from './trimBlankEdges';\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)[]) => 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\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"collectSlotMap\",\"stability\":\"stable\",\"signature\":\"(children: PithyNode[], parentContext: Record<string, any>) => SlotMap\"} */\nexport function collectSlotMap(\n children: PithyNode[],\n parentContext: Record<string, unknown>\n): SlotMap {\n const slotMap: SlotMap = new Map();\n const slotGroups = new Map<string, PithyNode[]>();\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 // Validate slot usage in DEV mode\n if (import.meta.env?.DEV) {\n const slotNames = Array.from(slotGroups.keys());\n const duplicateSlots = slotNames.filter(\n name => name !== '' && slotGroups.get(name)!.length > 1\n );\n if (duplicateSlots.length > 0) {\n console.warn(\n `[ContentProjection] Multiple content nodes targeting the same slot. This is allowed but may indicate a mistake:`,\n duplicateSlots\n );\n }\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 = (disposers: (() => void)[] = []): 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 bindStructuralDirectives(\n capturedNodes,\n fragment,\n capturedContext,\n disposers\n );\n bindErrorBoundary(fragment, capturedContext, 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 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/** @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 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 if (!parent) {\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);\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 bindStructuralDirectives(\n slotNode.fallbackChildren,\n contentFragment,\n fallbackCtx,\n disposers\n );\n bindErrorBoundary(contentFragment, fallbackCtx, disposers);\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 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;AAGF,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,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA6BlD,SAAS,OAAO,CAAC,IAAU;IACzB,OAAO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\": \"Content Projection System\",\n \"category\": \"feature\"\n}\n*/\n\nimport { PithyNode } from '@pithyjs/compiler';\nimport { pithyTreeToDom } from './pithyTreeToDom';\nimport { bindStructuralDirectives } from './compileTemplate';\nimport { nodeExpando } from './nodeExpando';\nimport {\n bindErrorBoundary,\n insertBesideHidden,\n isHiddenByBoundary,\n} from './binds/bindErrorBoundary';\nimport { pithyGlobals } from '../types/globals';\nimport { trimBlankEdges } from './trimBlankEdges';\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\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"collectSlotMap\",\"stability\":\"stable\",\"signature\":\"(children: PithyNode[], parentContext: Record<string, any>) => SlotMap\"} */\nexport function collectSlotMap(\n children: PithyNode[],\n parentContext: Record<string, unknown>\n): SlotMap {\n const slotMap: SlotMap = new Map();\n const slotGroups = new Map<string, PithyNode[]>();\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 // Validate slot usage in DEV mode\n if (import.meta.env?.DEV) {\n const slotNames = Array.from(slotGroups.keys());\n const duplicateSlots = slotNames.filter(\n name => name !== '' && slotGroups.get(name)!.length > 1\n );\n if (duplicateSlots.length > 0) {\n console.warn(\n `[ContentProjection] Multiple content nodes targeting the same slot. This is allowed but may indicate a mistake:`,\n duplicateSlots\n );\n }\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 = (disposers: (() => void)[] = []): 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 bindStructuralDirectives(\n capturedNodes,\n fragment,\n capturedContext,\n disposers\n );\n bindErrorBoundary(fragment, capturedContext, 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 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/** @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 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 bindStructuralDirectives(\n slotNode.fallbackChildren,\n contentFragment,\n fallbackCtx,\n disposers\n );\n bindErrorBoundary(contentFragment, fallbackCtx, disposers);\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,6 +1,8 @@
1
1
  import type { PithyNode } from '@pithyjs/compiler';
2
2
  import { type PithyComponentContext } from '../types/globals.js';
3
3
  import type { ChildFactory } from '../runtime/bindings/types.js';
4
+ import type { SlotMap } from './contentProjection.js';
5
+ type SlotRenderer = NonNullable<ReturnType<SlotMap['get']>>;
4
6
  /**
5
7
  * If the registry renderer has set `globalThis.__pithyProjectedChildren` (a
6
8
  * `DocumentFragment` of already-rendered slot children), returns and clears it —
@@ -8,6 +10,8 @@ import type { ChildFactory } from '../runtime/bindings/types.js';
8
10
  * children on the registry path. The registry path has no AST fallback, so a
9
11
  * second `renderChildren()`/`captureChildren()` call returns an empty fragment.
10
12
  *
13
+ * A build-compiled parent's default slot is rendered afresh on every call.
14
+ *
11
15
  * Otherwise compiles child AST nodes from the current component context through
12
16
  * the full pipeline (structural + non-structural directives). This enables
13
17
  * nested components inside projected content — unlike `<slot>`, which inserts
@@ -50,11 +54,14 @@ export declare function captureChildren(): {
50
54
  el: DocumentFragment;
51
55
  destroy: () => void;
52
56
  };
57
+ /** @codexApi {"parent":"pithy.runtime.compile-nodes","name":"ChildPayload","stability":"experimental","signature":"interface ChildPayload"} */
53
58
  export interface ChildPayload {
54
59
  context: PithyComponentContext | undefined;
55
60
  factory?: ChildFactory;
56
61
  astNodes?: PithyNode[];
57
62
  projected?: DocumentFragment;
63
+ /** A build's default slot, rendered by `renderChildren()` on each call. */
64
+ slot?: SlotRenderer;
58
65
  }
59
66
  /**
60
67
  * Reads the children addressed to the component being rendered, without
@@ -64,4 +71,5 @@ export interface ChildPayload {
64
71
  */
65
72
  /** @codexApi {"parent":"pithy.runtime.compile-nodes","name":"readChildPayload","stability":"experimental","signature":"() => ChildPayload"} */
66
73
  export declare function readChildPayload(): ChildPayload;
74
+ export {};
67
75
  //# sourceMappingURL=renderChildren.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderChildren.d.ts","sourceRoot":"","sources":["../../src/compile/renderChildren.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAgB,KAAK,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D;;;;;;;;;;;;;;GAcG;AACH,wKAAwK;AACxK,wBAAgB,cAAc,IAAI;IAChC,EAAE,EAAE,gBAAgB,CAAC;IACrB,OAAO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AAE,qBAAqB,GAAG,SAAS,CAAC;IAC3C,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,2EAA2E;IAC3E,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB;AAED;;;;;GAKG;AACH,+IAA+I;AAC/I,wBAAgB,gBAAgB,IAAI,YAAY,CAY/C"}
@@ -7,6 +7,8 @@ import { pithyGlobals } from '../types/globals.js';
7
7
  * children on the registry path. The registry path has no AST fallback, so a
8
8
  * second `renderChildren()`/`captureChildren()` call returns an empty fragment.
9
9
  *
10
+ * A build-compiled parent's default slot is rendered afresh on every call.
11
+ *
10
12
  * Otherwise compiles child AST nodes from the current component context through
11
13
  * the full pipeline (structural + non-structural directives). This enables
12
14
  * nested components inside projected content — unlike `<slot>`, which inserts
@@ -24,6 +26,19 @@ export function renderChildren() {
24
26
  return { el: injected, destroy: () => { } };
25
27
  }
26
28
  const componentCtx = pithyGlobals().__pithyComponentContext;
29
+ const slot = buildDefaultSlot(componentCtx);
30
+ if (slot) {
31
+ const disposers = [];
32
+ const el = slot(disposers);
33
+ return {
34
+ el,
35
+ destroy: () => {
36
+ for (let i = disposers.length - 1; i >= 0; i--)
37
+ disposers[i]();
38
+ disposers.length = 0;
39
+ },
40
+ };
41
+ }
27
42
  // A parent composing atoms by direct call after captureChildren() cleared its
28
43
  // context is still mid-render (`rendering` truthy) — not the misuse this guards
29
44
  // against, so a consumed context alone must not trigger the warning.
@@ -73,6 +88,12 @@ export function captureChildren() {
73
88
  g.__pithyComponentContext = prevCtx?.__parentComponentContext ?? undefined;
74
89
  return result;
75
90
  }
91
+ /** Default-slot renderer of a build-compiled parent; it has no AST. */
92
+ function buildDefaultSlot(ctx) {
93
+ return ctx && !ctx.__childAstNodes && !ctx.__childFactory
94
+ ? ctx.__slotMap?.get('')
95
+ : undefined;
96
+ }
76
97
  /**
77
98
  * Reads the children addressed to the component being rendered, without
78
99
  * consuming them. `factory` and `astNodes` are mutually exclusive: an AOT child
@@ -90,6 +111,7 @@ export function readChildPayload() {
90
111
  factory,
91
112
  astNodes: !factory && ast && ast.length > 0 ? ast : undefined,
92
113
  projected: g.__pithyProjectedChildren,
114
+ slot: buildDefaultSlot(context),
93
115
  };
94
116
  }
95
117
  //# sourceMappingURL=renderChildren.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderChildren.js","sourceRoot":"","sources":["../../src/compile/renderChildren.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAA8B,MAAM,kBAAkB,CAAC;AAG5E;;;;;;;;;;;;;;GAcG;AACH,wKAAwK;AACxK,MAAM,UAAU,cAAc;IAI5B,MAAM,WAAW,GAAG,YAAY,EAAE,CAAC;IACnC,MAAM,QAAQ,GAAG,WAAW,CAAC,wBAAwB,CAAC;IACtD,IAAI,QAAQ,EAAE,CAAC;QACb,WAAW,CAAC,wBAAwB,GAAG,SAAS,CAAC;QACjD,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC;IAC7C,CAAC;IAED,MAAM,YAAY,GAAG,YAAY,EAAE,CAAC,uBAAuB,CAAC;IAE5D,8EAA8E;IAC9E,gFAAgF;IAChF,qEAAqE;IACrE,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC,yBAAyB,CAAC;IAC3D,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,YAAY,IAAI,CAAC,SAAS,EAAE,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;IAC3E,CAAC;IAED,MAAM,aAAa,GAAgB,YAAY,EAAE,eAAe,IAAI,EAAE,CAAC;IAEvE,uFAAuF;IACvF,MAAM,SAAS,GAA4B,YAAY;QACrD,CAAC,CAAC,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAClE;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO,YAAY,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;AAChD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,yKAAyK;AACzK,MAAM,UAAU,eAAe;IAI7B,MAAM,CAAC,GAAG,YAAY,EAAE,CAAC;IACzB,MAAM,OAAO,GAAG,CAAC,CAAC,uBAAuB,CAAC;IAC1C,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,sDAAsD;IACtD,qEAAqE;IACrE,iEAAiE;IACjE,CAAC,CAAC,uBAAuB,GAAG,OAAO,EAAE,wBAAwB,IAAI,SAAS,CAAC;IAC3E,OAAO,MAAM,CAAC;AAChB,CAAC;AASD;;;;;GAKG;AACH,+IAA+I;AAC/I,MAAM,UAAU,gBAAgB;IAC9B,MAAM,CAAC,GAAG,YAAY,EAAE,CAAC;IACzB,MAAM,OAAO,GAAG,CAAC,CAAC,uBAAuB,CAAC;IAC1C,MAAM,OAAO,GAAG,OAAO,EAAE,cAAc,CAAC;IACxC,MAAM,GAAG,GAAG,OAAO,EAAE,eAAe,CAAC;IACrC,OAAO;QACL,OAAO;QACP,OAAO;QACP,QAAQ,EAAE,CAAC,OAAO,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;QAC7D,SAAS,EAAE,CAAC,CAAC,wBAAwB;KACtC,CAAC;AACJ,CAAC","sourcesContent":["import { compileNodes } from './compileNodes';\nimport type { PithyNode } from '@pithyjs/compiler';\nimport { pithyGlobals, type PithyComponentContext } from '../types/globals';\nimport type { ChildFactory } from '../runtime/bindings/types';\n\n/**\n * If the registry renderer has set `globalThis.__pithyProjectedChildren` (a\n * `DocumentFragment` of already-rendered slot children), returns and clears it —\n * single-consume, so the first caller wins. This delivers construction-time\n * children on the registry path. The registry path has no AST fallback, so a\n * second `renderChildren()`/`captureChildren()` call returns an empty fragment.\n *\n * Otherwise compiles child AST nodes from the current component context through\n * the full pipeline (structural + non-structural directives). This enables\n * nested components inside projected content — unlike `<slot>`, which inserts\n * DOM after `bindComponentTags` has already run.\n *\n * Use inside component functions (Stack, Grid, etc.) that need to compile\n * their children without named slots or fallback content.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"renderChildren\",\"stability\":\"stable\",\"signature\":\"() => { el: DocumentFragment; destroy: () => void }\"} */\nexport function renderChildren(): {\n el: DocumentFragment;\n destroy: () => void;\n} {\n const globalScope = pithyGlobals();\n const injected = globalScope.__pithyProjectedChildren;\n if (injected) {\n globalScope.__pithyProjectedChildren = undefined;\n return { el: injected, destroy: () => {} };\n }\n\n const componentCtx = pithyGlobals().__pithyComponentContext;\n\n // A parent composing atoms by direct call after captureChildren() cleared its\n // context is still mid-render (`rendering` truthy) — not the misuse this guards\n // against, so a consumed context alone must not trigger the warning.\n const rendering = pithyGlobals().__pithyRenderingComponent;\n if (import.meta.env?.DEV && !componentCtx && !rendering) {\n console.warn('[renderChildren] Called outside component render context');\n }\n\n const childAstNodes: PithyNode[] = componentCtx?.__childAstNodes ?? [];\n\n // Strip internal __ properties, keep parent scope (includes components, signals, etc.)\n const parentCtx: Record<string, unknown> = componentCtx\n ? Object.fromEntries(\n Object.entries(componentCtx).filter(([k]) => !k.startsWith('__'))\n )\n : {};\n\n return compileNodes(childAstNodes, parentCtx);\n}\n\n/**\n * Captures projected children and clears the component context so\n * inner component calls (e.g. `Heading()`, `Text()`) don't consume\n * the outer component's children.\n *\n * After capture, the current component's context on `globalThis` is\n * reset to the value of `__parentComponentContext` if present, or\n * otherwise to `undefined`. In the current core implementation,\n * `__parentComponentContext` is not set by the runtime, so this\n * effectively clears the active component context to prevent child\n * leakage into inner component calls.\n *\n * **Important invariant:** This function must be called exactly once per\n * component, before any inner component function calls. It consumes the\n * current context's children — a second call would return an empty fragment.\n * After this call, the caller must not rely on reading its own context\n * properties from `globalThis.__pithyComponentContext`.\n *\n * For 3+ levels of nesting (e.g., section A → section B → atoms), each\n * level should call `captureChildren()` independently. Any multi-level\n * parent restoration depends on `__parentComponentContext` being managed\n * by external tooling; the core library only performs a best-effort reset\n * from that property when present.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"captureChildren\",\"stability\":\"stable\",\"signature\":\"() => { el: DocumentFragment; destroy: () => void }\"} */\nexport function captureChildren(): {\n el: DocumentFragment;\n destroy: () => void;\n} {\n const g = pithyGlobals();\n const prevCtx = g.__pithyComponentContext;\n const result = renderChildren();\n // Clear context so inner component calls start fresh.\n // If there was a parent context, it will be restored by the parent's\n // own render cycle — we only need to prevent child leakage here.\n g.__pithyComponentContext = prevCtx?.__parentComponentContext ?? undefined;\n return result;\n}\n\nexport interface ChildPayload {\n context: PithyComponentContext | undefined;\n factory?: ChildFactory;\n astNodes?: PithyNode[];\n projected?: DocumentFragment;\n}\n\n/**\n * Reads the children addressed to the component being rendered, without\n * consuming them. `factory` and `astNodes` are mutually exclusive: an AOT child\n * factory wins, because a JIT parent's AST can reach an AOT component's context\n * through `mergeContexts`, never the reverse.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"readChildPayload\",\"stability\":\"experimental\",\"signature\":\"() => ChildPayload\"} */\nexport function readChildPayload(): ChildPayload {\n const g = pithyGlobals();\n const context = g.__pithyComponentContext;\n const factory = context?.__childFactory;\n const ast = context?.__childAstNodes;\n return {\n context,\n factory,\n astNodes: !factory && ast && ast.length > 0 ? ast : undefined,\n projected: g.__pithyProjectedChildren,\n };\n}\n"]}
1
+ {"version":3,"file":"renderChildren.js","sourceRoot":"","sources":["../../src/compile/renderChildren.ts"],"names":[],"mappings":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e,CAAC;IACrC,OAAO;QACL,OAAO;QACP,OAAO;QACP,QAAQ,EAAE,CAAC,OAAO,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;QAC7D,SAAS,EAAE,CAAC,CAAC,wBAAwB;QACrC,IAAI,EAAE,gBAAgB,CAAC,OAAO,CAAC;KAChC,CAAC;AACJ,CAAC","sourcesContent":["import { compileNodes } from './compileNodes';\nimport type { PithyNode } from '@pithyjs/compiler';\nimport { pithyGlobals, type PithyComponentContext } from '../types/globals';\nimport type { ChildFactory } from '../runtime/bindings/types';\nimport type { SlotMap } from './contentProjection';\n\ntype SlotRenderer = NonNullable<ReturnType<SlotMap['get']>>;\n\n/**\n * If the registry renderer has set `globalThis.__pithyProjectedChildren` (a\n * `DocumentFragment` of already-rendered slot children), returns and clears it —\n * single-consume, so the first caller wins. This delivers construction-time\n * children on the registry path. The registry path has no AST fallback, so a\n * second `renderChildren()`/`captureChildren()` call returns an empty fragment.\n *\n * A build-compiled parent's default slot is rendered afresh on every call.\n *\n * Otherwise compiles child AST nodes from the current component context through\n * the full pipeline (structural + non-structural directives). This enables\n * nested components inside projected content — unlike `<slot>`, which inserts\n * DOM after `bindComponentTags` has already run.\n *\n * Use inside component functions (Stack, Grid, etc.) that need to compile\n * their children without named slots or fallback content.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"renderChildren\",\"stability\":\"stable\",\"signature\":\"() => { el: DocumentFragment; destroy: () => void }\"} */\nexport function renderChildren(): {\n el: DocumentFragment;\n destroy: () => void;\n} {\n const globalScope = pithyGlobals();\n const injected = globalScope.__pithyProjectedChildren;\n if (injected) {\n globalScope.__pithyProjectedChildren = undefined;\n return { el: injected, destroy: () => {} };\n }\n\n const componentCtx = pithyGlobals().__pithyComponentContext;\n const slot = buildDefaultSlot(componentCtx);\n if (slot) {\n const disposers: (() => void)[] = [];\n const el = slot(disposers);\n return {\n el,\n destroy: () => {\n for (let i = disposers.length - 1; i >= 0; i--) disposers[i]();\n disposers.length = 0;\n },\n };\n }\n\n // A parent composing atoms by direct call after captureChildren() cleared its\n // context is still mid-render (`rendering` truthy) — not the misuse this guards\n // against, so a consumed context alone must not trigger the warning.\n const rendering = pithyGlobals().__pithyRenderingComponent;\n if (import.meta.env?.DEV && !componentCtx && !rendering) {\n console.warn('[renderChildren] Called outside component render context');\n }\n\n const childAstNodes: PithyNode[] = componentCtx?.__childAstNodes ?? [];\n\n // Strip internal __ properties, keep parent scope (includes components, signals, etc.)\n const parentCtx: Record<string, unknown> = componentCtx\n ? Object.fromEntries(\n Object.entries(componentCtx).filter(([k]) => !k.startsWith('__'))\n )\n : {};\n\n return compileNodes(childAstNodes, parentCtx);\n}\n\n/**\n * Captures projected children and clears the component context so\n * inner component calls (e.g. `Heading()`, `Text()`) don't consume\n * the outer component's children.\n *\n * After capture, the current component's context on `globalThis` is\n * reset to the value of `__parentComponentContext` if present, or\n * otherwise to `undefined`. In the current core implementation,\n * `__parentComponentContext` is not set by the runtime, so this\n * effectively clears the active component context to prevent child\n * leakage into inner component calls.\n *\n * **Important invariant:** This function must be called exactly once per\n * component, before any inner component function calls. It consumes the\n * current context's children — a second call would return an empty fragment.\n * After this call, the caller must not rely on reading its own context\n * properties from `globalThis.__pithyComponentContext`.\n *\n * For 3+ levels of nesting (e.g., section A → section B → atoms), each\n * level should call `captureChildren()` independently. Any multi-level\n * parent restoration depends on `__parentComponentContext` being managed\n * by external tooling; the core library only performs a best-effort reset\n * from that property when present.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"captureChildren\",\"stability\":\"stable\",\"signature\":\"() => { el: DocumentFragment; destroy: () => void }\"} */\nexport function captureChildren(): {\n el: DocumentFragment;\n destroy: () => void;\n} {\n const g = pithyGlobals();\n const prevCtx = g.__pithyComponentContext;\n const result = renderChildren();\n // Clear context so inner component calls start fresh.\n // If there was a parent context, it will be restored by the parent's\n // own render cycle — we only need to prevent child leakage here.\n g.__pithyComponentContext = prevCtx?.__parentComponentContext ?? undefined;\n return result;\n}\n\n/** Default-slot renderer of a build-compiled parent; it has no AST. */\nfunction buildDefaultSlot(ctx: PithyComponentContext | undefined) {\n return ctx && !ctx.__childAstNodes && !ctx.__childFactory\n ? ctx.__slotMap?.get('')\n : undefined;\n}\n\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"ChildPayload\",\"stability\":\"experimental\",\"signature\":\"interface ChildPayload\"} */\nexport interface ChildPayload {\n context: PithyComponentContext | undefined;\n factory?: ChildFactory;\n astNodes?: PithyNode[];\n projected?: DocumentFragment;\n /** A build's default slot, rendered by `renderChildren()` on each call. */\n slot?: SlotRenderer;\n}\n\n/**\n * Reads the children addressed to the component being rendered, without\n * consuming them. `factory` and `astNodes` are mutually exclusive: an AOT child\n * factory wins, because a JIT parent's AST can reach an AOT component's context\n * through `mergeContexts`, never the reverse.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"readChildPayload\",\"stability\":\"experimental\",\"signature\":\"() => ChildPayload\"} */\nexport function readChildPayload(): ChildPayload {\n const g = pithyGlobals();\n const context = g.__pithyComponentContext;\n const factory = context?.__childFactory;\n const ast = context?.__childAstNodes;\n return {\n context,\n factory,\n astNodes: !factory && ast && ast.length > 0 ? ast : undefined,\n projected: g.__pithyProjectedChildren,\n slot: buildDefaultSlot(context),\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"applyBindings.d.ts","sourceRoot":"","sources":["../../src/runtime/applyBindings.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAKF,OAAO,EAoBL,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;;;;;;;;;;;;;;;;;;;;GAoBG;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,CAyL/C"}
1
+ {"version":3,"file":"applyBindings.d.ts","sourceRoot":"","sources":["../../src/runtime/applyBindings.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAKF,OAAO,EAoBL,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;;;;;;;;;;;;;;;;;;;;GAoBG;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,CA2L/C"}
@@ -79,30 +79,31 @@ export function __applyBindings(fragment, bindings, context, ownsDestroyCallback
79
79
  for (const d of (byType.get('proj') ?? [])) {
80
80
  applyProjection(d, commentMap, ctx, disposers);
81
81
  }
82
- // A placeholder in another component's slot content is moved into that
83
- // component. A runtime-compiled one renders it from its own binder when it
84
- // mounts the slot; the hook keeps it on this binder, in the context it was
85
- // written in. An AOT-compiled one mounting its slot late does not call the
86
- // hook yet (BUG-117).
82
+ // A placeholder that reaches a runtime-compiled component's binder (slot
83
+ // content serialized into a descriptor without `slots`, or a failed
84
+ // render left in place) is rendered through this hook, in the context it
85
+ // was written in.
87
86
  const comps = (byType.get('comp') ?? []);
88
87
  const mounted = new Set();
89
88
  const binds = new Map();
90
89
  const live = new Map();
90
+ // A placeholder that failed stays put, and every enclosing slot's pass
91
+ // finds it again; a re-mount moves it first. One this pass already
92
+ // rendered is never retried (`true`).
93
+ const failedIn = new Map();
91
94
  for (const d of comps) {
92
95
  const el = pidMap.get(d.pid);
93
96
  if (!el)
94
97
  continue;
95
98
  const scope = nearestCtx(el, ctx);
96
99
  binds.set(d.pid, []);
97
- // A placeholder that failed stays put, and every enclosing slot's pass
98
- // finds it again; a re-mount moves it first.
99
- let failedIn = null;
100
100
  nodeExpando(el).__pithyAotMount = slotDisposers => {
101
101
  mounted.add(d);
102
- if (failedIn && el.parentNode === failedIn)
102
+ const failed = failedIn.get(d);
103
+ if (failed === true || (failed && el.parentNode === failed))
103
104
  return [];
104
105
  const nodes = applyComponent(d, el, ctx, slotDisposers, pidMap, scope);
105
- failedIn = nodes ? null : el.parentNode;
106
+ failedIn.set(d, nodes ? null : el.parentNode);
106
107
  // On failure `pidMap` still holds the previous root.
107
108
  const root = nodes && pidMap.get(d.pid);
108
109
  if (!nodes || !root)
@@ -147,7 +148,8 @@ export function __applyBindings(fragment, bindings, context, ownsDestroyCallback
147
148
  // subtree: that calls `applyBindings` with the branch's OWN fragment as
148
149
  // `fragment`, so its placeholders are inside it and still bind.
149
150
  if (el && fragment.contains(el)) {
150
- applyComponent(d, el, ctx, disposers, pidMap);
151
+ if (!applyComponent(d, el, ctx, disposers, pidMap))
152
+ failedIn.set(d, true);
151
153
  binds.delete(d.pid);
152
154
  }
153
155
  else if (el) {