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

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 (53) hide show
  1. package/README.md +4 -0
  2. package/dist/compile/bindSwitchCases.d.ts.map +1 -1
  3. package/dist/compile/bindSwitchCases.js +2 -1
  4. package/dist/compile/bindSwitchCases.js.map +1 -1
  5. package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
  6. package/dist/compile/binds/bindComponentsTags.js +20 -68
  7. package/dist/compile/binds/bindComponentsTags.js.map +1 -1
  8. package/dist/compile/binds/bindDefaultTwoWay.d.ts.map +1 -1
  9. package/dist/compile/binds/bindDefaultTwoWay.js +2 -1
  10. package/dist/compile/binds/bindDefaultTwoWay.js.map +1 -1
  11. package/dist/compile/binds/bindErrorBoundary.d.ts +2 -0
  12. package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
  13. package/dist/compile/binds/bindErrorBoundary.js +13 -5
  14. package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
  15. package/dist/compile/binds/propNames.d.ts +5 -1
  16. package/dist/compile/binds/propNames.d.ts.map +1 -1
  17. package/dist/compile/binds/propNames.js +36 -1
  18. package/dist/compile/binds/propNames.js.map +1 -1
  19. package/dist/compile/binds/propWarnings.d.ts +11 -0
  20. package/dist/compile/binds/propWarnings.d.ts.map +1 -0
  21. package/dist/compile/binds/propWarnings.js +43 -0
  22. package/dist/compile/binds/propWarnings.js.map +1 -0
  23. package/dist/compile/contentProjection.d.ts.map +1 -1
  24. package/dist/compile/contentProjection.js +6 -6
  25. package/dist/compile/contentProjection.js.map +1 -1
  26. package/dist/compile/evalDiagnostics.d.ts +5 -0
  27. package/dist/compile/evalDiagnostics.d.ts.map +1 -1
  28. package/dist/compile/evalDiagnostics.js +5 -0
  29. package/dist/compile/evalDiagnostics.js.map +1 -1
  30. package/dist/compile/forLoops/createLoopManager.d.ts +3 -1
  31. package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -1
  32. package/dist/compile/forLoops/createLoopManager.js +9 -5
  33. package/dist/compile/forLoops/createLoopManager.js.map +1 -1
  34. package/dist/compile/ssrCrashes.d.ts +6 -0
  35. package/dist/compile/ssrCrashes.d.ts.map +1 -1
  36. package/dist/compile/ssrCrashes.js +17 -1
  37. package/dist/compile/ssrCrashes.js.map +1 -1
  38. package/dist/runtime/applyBindings.js +7 -2
  39. package/dist/runtime/applyBindings.js.map +1 -1
  40. package/dist/runtime/bindings/applyComponent.d.ts +3 -1
  41. package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
  42. package/dist/runtime/bindings/applyComponent.js +11 -3
  43. package/dist/runtime/bindings/applyComponent.js.map +1 -1
  44. package/dist/runtime/bindings/applyStructural.d.ts.map +1 -1
  45. package/dist/runtime/bindings/applyStructural.js +19 -5
  46. package/dist/runtime/bindings/applyStructural.js.map +1 -1
  47. package/dist/runtime/bindings/types.d.ts +2 -0
  48. package/dist/runtime/bindings/types.d.ts.map +1 -1
  49. package/dist/runtime/bindings/types.js.map +1 -1
  50. package/dist/types/globals.d.ts +2 -0
  51. package/dist/types/globals.d.ts.map +1 -1
  52. package/dist/types/globals.js.map +1 -1
  53. package/package.json +2 -2
@@ -20,7 +20,11 @@ const activeBoundaries = [];
20
20
  */
21
21
  let currentBoundaryContext = null;
22
22
  let slotFrame = null;
23
- let openBranches = 0;
23
+ // Shared like the boundary context, so a nested core copy sees the branch.
24
+ const openBranches = () => pithyGlobals().__pithyOpenBranches ?? 0;
25
+ const addBranches = (n) => {
26
+ pithyGlobals().__pithyOpenBranches = openBranches() + n;
27
+ };
24
28
  /**
25
29
  * Flag to ensure timer patching happens only once
26
30
  */
@@ -36,7 +40,7 @@ export function boundaryForElement(el) {
36
40
  // A crash in a branch built inside the slot is attributed (`deferCrash`), so
37
41
  // the boundary does not hide the slot before its components are bound.
38
42
  if (!boundaryEl)
39
- return openBranches === slotFrame?.branches ? slotFrameBoundary() : null;
43
+ return openBranches() === slotFrame?.branches ? slotFrameBoundary() : null;
40
44
  // Find the registered boundary info
41
45
  return (activeBoundaries.find(boundary => boundary.element === boundaryEl) || null);
42
46
  }
@@ -85,7 +89,7 @@ export function withSlotBoundary(anchor, host, fn) {
85
89
  outer,
86
90
  own: true,
87
91
  context: boundaryContext(),
88
- branches: openBranches,
92
+ branches: openBranches(),
89
93
  direct: hider
90
94
  ? hider.contentPlaceholders.has(at)
91
95
  : (anchor ?? host)?.parentElement === boundary?.element,
@@ -151,15 +155,19 @@ export function withBranchBoundary(anchor, fn, inside = false) {
151
155
  const outer = boundaryContext();
152
156
  const at = into?.nodeType === Node.ELEMENT_NODE ? into : null;
153
157
  setContext(at?.closest('[data-error]') ?? (into?.isConnected ? null : outer));
154
- openBranches++;
158
+ addBranches(1);
155
159
  try {
156
160
  return fn();
157
161
  }
158
162
  finally {
159
- openBranches--;
163
+ addBranches(-1);
160
164
  setContext(outer);
161
165
  }
162
166
  }
167
+ /** Whether an `@if`/`@case` branch or `@for` item is being built. */
168
+ export function inBranch() {
169
+ return openBranches() > 0;
170
+ }
163
171
  /** Whether a boundary has hidden the detached subtree `node` belongs to. */
164
172
  /** @codexApi {"parent":"pithy.feature.error-boundary","name":"isInHiddenContent","stability":"internal","signature":"(node: Node) => boolean"} */
165
173
  export function isInHiddenContent(node) {
@@ -1 +1 @@
1
- {"version":3,"file":"bindErrorBoundary.js","sourceRoot":"","sources":["../../../src/compile/binds/bindErrorBoundary.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAU,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,aAAa,GAAG,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AAa,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 { pithyGlobals } from '../../types/globals';\nimport { declaredValue } from './declaredDirective';\nimport { effect, Signal, untrack } from '@pithyjs/signals';\nimport { setStyleProp } from './bindBoundAttributes';\nimport { nodeExpando } from '../nodeExpando';\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 /** The boundary context when the frame opened; a later one is nearer. */\n context: Element | null;\n /** Branches open when the boundary's frame opened; a crash in a later one is deferred. */\n branches: number;\n}\nlet slotFrame: SlotFrame | null = null;\nlet openBranches = 0;\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 // A crash in a branch built inside the slot is attributed (`deferCrash`), so\n // the boundary does not hide the slot before its components are bound.\n if (!boundaryEl)\n return openBranches === slotFrame?.branches ? slotFrameBoundary() : null;\n\n // Find the registered boundary info\n return (\n activeBoundaries.find(boundary => boundary.element === boundaryEl) || null\n );\n}\n\nfunction slotFrameBoundary(): BoundaryInfo | null {\n return slotFrame && boundaryContext() === slotFrame.context\n ? slotFrame.boundary\n : null;\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, then the host's render. Without an\n * anchor (`renderChildren()`), the host is the frame's 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 const outerContext = boundaryContext();\n const at = anchor ?? host;\n if (at) {\n // An anchor an earlier crash hid has no parent to resolve from.\n const hider = hiderOf(at);\n const own = hider ?? registeredClosest(anchor?.parentElement);\n if (own) setContext(own.element);\n const boundary = own ?? outer?.boundary ?? currentBoundaryContext;\n slotFrame =\n boundary === outer?.boundary\n ? {\n ...outer,\n anchor: at,\n host,\n outer,\n own: false,\n direct: false,\n context: boundaryContext(),\n }\n : {\n boundary,\n anchor: at,\n host,\n outer,\n own: true,\n context: boundaryContext(),\n branches: openBranches,\n direct: hider\n ? hider.contentPlaceholders.has(at)\n : (anchor ?? host)?.parentElement === boundary?.element,\n isContent: !!hider || !boundary?.fallbackElement?.contains(at),\n };\n }\n const owner = slotFrame?.boundary?.element ?? boundaryContext();\n try {\n const output = fn();\n if (owner) markSlotOutput(output, owner);\n return output;\n } finally {\n slotFrame = outer;\n setContext(outerContext);\n }\n}\n\nfunction markSlotOutput(output: unknown, owner: Element): void {\n const el = output instanceof Node ? output : (output as { el?: unknown })?.el;\n if (!(el instanceof Node)) return;\n const nodes =\n el.nodeType === Node.DOCUMENT_FRAGMENT_NODE\n ? Array.from(el.childNodes)\n : [el];\n for (const node of nodes) nodeExpando(node).__pithySlotOwner ??= owner;\n}\n\n/** The boundary element of the slot that rendered `node`, if a slot did. */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"slotOwnerOf\",\"stability\":\"internal\",\"signature\":\"(node: Node) => Element | null\"} */\nexport function slotOwnerOf(node: Node): Element | null {\n for (let at: Node | null = node; at; at = at.parentNode) {\n const owner = nodeExpando(at).__pithySlotOwner;\n if (owner) return owner;\n }\n return null;\n}\n\n/**\n * The boundary element that what is being rendered will sit under. A branch,\n * slot or component built detached cannot `closest()` it, so each sets this\n * while it runs; a crash takes the innermost one (`deferCrash`).\n */\n// On `globalThis` with the attributed crashes, so a component another copy of\n// core binds inside this copy's branch is attributed to the same boundary.\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"boundaryContext\",\"stability\":\"internal\",\"signature\":\"() => Element | null\"} */\nexport function boundaryContext(): Element | null {\n return pithyGlobals().__pithyBoundaryContext ?? null;\n}\n\nfunction setContext(element: Element | null): void {\n pithyGlobals().__pithyBoundaryContext = element;\n}\n\n/**\n * Builds an `@if`/`@case` branch or `@for` item that will be inserted beside\n * `anchor`, or inside it when `inside`. A detached landing place (a component's\n * own template) keeps the enclosing context; an attached one with no boundary\n * has none.\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"withBranchBoundary\",\"stability\":\"internal\",\"signature\":\"<T>(anchor: Node, fn: () => T, inside?: boolean) => T\"} */\nexport function withBranchBoundary<T>(\n anchor: Node,\n fn: () => T,\n inside = false\n): T {\n const into = inside ? anchor : anchor.parentNode;\n const outer = boundaryContext();\n const at = into?.nodeType === Node.ELEMENT_NODE ? (into as Element) : null;\n setContext(at?.closest('[data-error]') ?? (into?.isConnected ? null : outer));\n openBranches++;\n try {\n return fn();\n } finally {\n openBranches--;\n setContext(outer);\n }\n}\n\n/** Whether a boundary has hidden the detached subtree `node` belongs to. */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"isInHiddenContent\",\"stability\":\"internal\",\"signature\":\"(node: Node) => boolean\"} */\nexport function isInHiddenContent(node: Node): boolean {\n return !!hiderOf(node);\n}\n\n/** The registered boundary of `el`'s nearest `[data-error]`, ignoring slot frames. */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"registeredClosest\",\"stability\":\"internal\",\"signature\":\"(el: Element | null | undefined) => BoundaryInfo | null\"} */\nexport function registeredClosest(\n el: Element | null | undefined\n): BoundaryInfo | null {\n const boundaryEl = el?.closest('[data-error]');\n return (\n (boundaryEl && activeBoundaries.find(b => b.element === boundaryEl)) || null\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 // Anchorless (`renderChildren()`), the host is the anchor: whether it wraps its\n // children is unknown while they render, so they count as unwrapped.\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 * Puts `content` in the place of `node` when an active boundary has hidden it,\n * which a crash during `node`'s own render can do, and hides it there instead.\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"replaceHidden\",\"stability\":\"experimental\",\"signature\":\"(node: Node, content: Node[]) => boolean\"} */\nexport function replaceHidden(node: Node, content: Node[]): boolean {\n for (const boundary of activeBoundaries) {\n const standIn = boundary.contentPlaceholders.get(node);\n if (!standIn?.parentNode) continue;\n boundary.contentPlaceholders.delete(node);\n standIn.replaceWith(...content);\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 */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"findParentBoundary\",\"stability\":\"internal\",\"signature\":\"(childBoundary: BoundaryInfo) => BoundaryInfo | null\"} */\nexport function findParentBoundary(\n childBoundary: BoundaryInfo\n): 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/** The boundary the component being rendered sits under. */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"currentBoundary\",\"stability\":\"experimental\",\"signature\":\"() => BoundaryInfo | null\"} */\nexport function currentBoundary(): BoundaryInfo | null {\n return currentBoundaryContext;\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 return runUnder(boundary, fn, true);\n}\n\nfunction runUnder<T>(\n boundary: BoundaryInfo | null,\n fn: () => T,\n attribute: boolean\n): T {\n const previousContext = currentBoundaryContext;\n const previous = boundaryContext();\n currentBoundaryContext = boundary;\n if (boundary && attribute) setContext(boundary.element);\n try {\n return fn();\n } finally {\n currentBoundaryContext = previousContext;\n setContext(previous);\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 // `false`: a detached render in a timer is not part of the render that scheduled it.\n return runUnder(\n capturedBoundary,\n () => {\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 false\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 runUnder(\n capturedBoundary,\n () => {\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 false\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 setStyleProp(fallbackElement, 'display', null);\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 setStyleProp(fallbackElement, '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 setStyleProp(fallbackEl, '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 = declaredValue(boundaryEl, '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,YAAY,EAAE,MAAM,qBAAqB,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G,EAAE,CAAC;gBACzB,OAAO,CAAC,IAAI,CACV,2BAA2B,UAAU,uCAAuC,UAAU,CAAC,OAAO,EAAE,CACjG,CAAC;YACJ,CAAC;YACD,SAAS;QACX,CAAC;QAED,wEAAwE;QACxE,qEAAqE;QACrE,IAAI,OAAO,WAAW,CAAC,GAAG,KAAK,UAAU,EAAE,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 { pithyGlobals } from '../../types/globals';\nimport { declaredValue } from './declaredDirective';\nimport { effect, Signal, untrack } from '@pithyjs/signals';\nimport { setStyleProp } from './bindBoundAttributes';\nimport { nodeExpando } from '../nodeExpando';\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 /** The boundary context when the frame opened; a later one is nearer. */\n context: Element | null;\n /** Branches open when the boundary's frame opened; a crash in a later one is deferred. */\n branches: number;\n}\nlet slotFrame: SlotFrame | null = null;\n// Shared like the boundary context, so a nested core copy sees the branch.\nconst openBranches = (): number => pithyGlobals().__pithyOpenBranches ?? 0;\nconst addBranches = (n: number): void => {\n pithyGlobals().__pithyOpenBranches = openBranches() + n;\n};\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 // A crash in a branch built inside the slot is attributed (`deferCrash`), so\n // the boundary does not hide the slot before its components are bound.\n if (!boundaryEl)\n return openBranches() === slotFrame?.branches ? slotFrameBoundary() : null;\n\n // Find the registered boundary info\n return (\n activeBoundaries.find(boundary => boundary.element === boundaryEl) || null\n );\n}\n\nfunction slotFrameBoundary(): BoundaryInfo | null {\n return slotFrame && boundaryContext() === slotFrame.context\n ? slotFrame.boundary\n : null;\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, then the host's render. Without an\n * anchor (`renderChildren()`), the host is the frame's 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 const outerContext = boundaryContext();\n const at = anchor ?? host;\n if (at) {\n // An anchor an earlier crash hid has no parent to resolve from.\n const hider = hiderOf(at);\n const own = hider ?? registeredClosest(anchor?.parentElement);\n if (own) setContext(own.element);\n const boundary = own ?? outer?.boundary ?? currentBoundaryContext;\n slotFrame =\n boundary === outer?.boundary\n ? {\n ...outer,\n anchor: at,\n host,\n outer,\n own: false,\n direct: false,\n context: boundaryContext(),\n }\n : {\n boundary,\n anchor: at,\n host,\n outer,\n own: true,\n context: boundaryContext(),\n branches: openBranches(),\n direct: hider\n ? hider.contentPlaceholders.has(at)\n : (anchor ?? host)?.parentElement === boundary?.element,\n isContent: !!hider || !boundary?.fallbackElement?.contains(at),\n };\n }\n const owner = slotFrame?.boundary?.element ?? boundaryContext();\n try {\n const output = fn();\n if (owner) markSlotOutput(output, owner);\n return output;\n } finally {\n slotFrame = outer;\n setContext(outerContext);\n }\n}\n\nfunction markSlotOutput(output: unknown, owner: Element): void {\n const el = output instanceof Node ? output : (output as { el?: unknown })?.el;\n if (!(el instanceof Node)) return;\n const nodes =\n el.nodeType === Node.DOCUMENT_FRAGMENT_NODE\n ? Array.from(el.childNodes)\n : [el];\n for (const node of nodes) nodeExpando(node).__pithySlotOwner ??= owner;\n}\n\n/** The boundary element of the slot that rendered `node`, if a slot did. */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"slotOwnerOf\",\"stability\":\"internal\",\"signature\":\"(node: Node) => Element | null\"} */\nexport function slotOwnerOf(node: Node): Element | null {\n for (let at: Node | null = node; at; at = at.parentNode) {\n const owner = nodeExpando(at).__pithySlotOwner;\n if (owner) return owner;\n }\n return null;\n}\n\n/**\n * The boundary element that what is being rendered will sit under. A branch,\n * slot or component built detached cannot `closest()` it, so each sets this\n * while it runs; a crash takes the innermost one (`deferCrash`).\n */\n// On `globalThis` with the attributed crashes, so a component another copy of\n// core binds inside this copy's branch is attributed to the same boundary.\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"boundaryContext\",\"stability\":\"internal\",\"signature\":\"() => Element | null\"} */\nexport function boundaryContext(): Element | null {\n return pithyGlobals().__pithyBoundaryContext ?? null;\n}\n\nfunction setContext(element: Element | null): void {\n pithyGlobals().__pithyBoundaryContext = element;\n}\n\n/**\n * Builds an `@if`/`@case` branch or `@for` item that will be inserted beside\n * `anchor`, or inside it when `inside`. A detached landing place (a component's\n * own template) keeps the enclosing context; an attached one with no boundary\n * has none.\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"withBranchBoundary\",\"stability\":\"internal\",\"signature\":\"<T>(anchor: Node, fn: () => T, inside?: boolean) => T\"} */\nexport function withBranchBoundary<T>(\n anchor: Node,\n fn: () => T,\n inside = false\n): T {\n const into = inside ? anchor : anchor.parentNode;\n const outer = boundaryContext();\n const at = into?.nodeType === Node.ELEMENT_NODE ? (into as Element) : null;\n setContext(at?.closest('[data-error]') ?? (into?.isConnected ? null : outer));\n addBranches(1);\n try {\n return fn();\n } finally {\n addBranches(-1);\n setContext(outer);\n }\n}\n\n/** Whether an `@if`/`@case` branch or `@for` item is being built. */\nexport function inBranch(): boolean {\n return openBranches() > 0;\n}\n\n/** Whether a boundary has hidden the detached subtree `node` belongs to. */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"isInHiddenContent\",\"stability\":\"internal\",\"signature\":\"(node: Node) => boolean\"} */\nexport function isInHiddenContent(node: Node): boolean {\n return !!hiderOf(node);\n}\n\n/** The registered boundary of `el`'s nearest `[data-error]`, ignoring slot frames. */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"registeredClosest\",\"stability\":\"internal\",\"signature\":\"(el: Element | null | undefined) => BoundaryInfo | null\"} */\nexport function registeredClosest(\n el: Element | null | undefined\n): BoundaryInfo | null {\n const boundaryEl = el?.closest('[data-error]');\n return (\n (boundaryEl && activeBoundaries.find(b => b.element === boundaryEl)) || null\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 // Anchorless (`renderChildren()`), the host is the anchor: whether it wraps its\n // children is unknown while they render, so they count as unwrapped.\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 * Puts `content` in the place of `node` when an active boundary has hidden it,\n * which a crash during `node`'s own render can do, and hides it there instead.\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"replaceHidden\",\"stability\":\"experimental\",\"signature\":\"(node: Node, content: Node[]) => boolean\"} */\nexport function replaceHidden(node: Node, content: Node[]): boolean {\n for (const boundary of activeBoundaries) {\n const standIn = boundary.contentPlaceholders.get(node);\n if (!standIn?.parentNode) continue;\n boundary.contentPlaceholders.delete(node);\n standIn.replaceWith(...content);\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 */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"findParentBoundary\",\"stability\":\"internal\",\"signature\":\"(childBoundary: BoundaryInfo) => BoundaryInfo | null\"} */\nexport function findParentBoundary(\n childBoundary: BoundaryInfo\n): 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/** The boundary the component being rendered sits under. */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"currentBoundary\",\"stability\":\"experimental\",\"signature\":\"() => BoundaryInfo | null\"} */\nexport function currentBoundary(): BoundaryInfo | null {\n return currentBoundaryContext;\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 return runUnder(boundary, fn, true);\n}\n\nfunction runUnder<T>(\n boundary: BoundaryInfo | null,\n fn: () => T,\n attribute: boolean\n): T {\n const previousContext = currentBoundaryContext;\n const previous = boundaryContext();\n currentBoundaryContext = boundary;\n if (boundary && attribute) setContext(boundary.element);\n try {\n return fn();\n } finally {\n currentBoundaryContext = previousContext;\n setContext(previous);\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 // `false`: a detached render in a timer is not part of the render that scheduled it.\n return runUnder(\n capturedBoundary,\n () => {\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 false\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 runUnder(\n capturedBoundary,\n () => {\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 false\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 setStyleProp(fallbackElement, 'display', null);\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 setStyleProp(fallbackElement, '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 setStyleProp(fallbackEl, '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 = declaredValue(boundaryEl, '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,5 +10,9 @@ export interface PropNames {
10
10
  fromParam: boolean;
11
11
  exhaustive: boolean;
12
12
  }
13
- export declare function parsePropNames(src: string): PropNames;
13
+ export declare function parsePropNames(source: string): PropNames;
14
+ /** `src` without comments. */
15
+ export declare function stripComments(src: string): string;
16
+ /** `parsePropNames` of a component's source, cached per function. */
17
+ export declare function readPropNames(fn: (...args: never[]) => unknown): PropNames;
14
18
  //# sourceMappingURL=propNames.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"propNames.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/propNames.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB;AAID,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAgDrD"}
1
+ {"version":3,"file":"propNames.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/propNames.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB;AAID,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAWxD;AA0DD,8BAA8B;AAC9B,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIjD;AAuDD,qEAAqE;AACrE,wBAAgB,aAAa,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,GAAG,SAAS,CAW1E"}
@@ -6,7 +6,19 @@
6
6
  }
7
7
  */
8
8
  const NONE = { names: [], fromParam: false, exhaustive: false };
9
- export function parsePropNames(src) {
9
+ export function parsePropNames(source) {
10
+ const stripped = readSignature(stripComments(source));
11
+ // Never fewer names than the raw read, which a misread strip could drop.
12
+ const raw = readSignature(source);
13
+ if (stripped.fromParam !== raw.fromParam)
14
+ return stripped.fromParam ? stripped : raw;
15
+ return {
16
+ names: [...new Set([...stripped.names, ...raw.names])],
17
+ fromParam: stripped.fromParam,
18
+ exhaustive: stripped.exhaustive && raw.exhaustive,
19
+ };
20
+ }
21
+ function readSignature(src) {
10
22
  const arrow = /^\s*(?:async\s+)?([A-Za-z_$][\w$]*)\s*=>/.exec(src);
11
23
  let head;
12
24
  if (arrow) {
@@ -53,6 +65,14 @@ export function parsePropNames(src) {
53
65
  }
54
66
  return { names: [...names], fromParam: false, exhaustive: false };
55
67
  }
68
+ // A comment in a signature can hold a comma or a quote (BUG-102). Strings are
69
+ // kept; a regex is not recognised, so `/\//` can read as a comment, and the
70
+ // raw read in `parsePropNames` keeps the names that drops.
71
+ const COMMENT = /(["'`])(?:\\[\s\S]|(?!\1)[^\\])*\1?|\/\/[^\n]*|\/\*[\s\S]*?(?:\*\/|$)/g;
72
+ /** `src` without comments. */
73
+ export function stripComments(src) {
74
+ return src.replace(COMMENT, t => t[0] !== '/' ? t : t[1] === '/' ? '' : ' ');
75
+ }
56
76
  function balanced(src, start) {
57
77
  let depth = 0;
58
78
  let quote = '';
@@ -113,4 +133,19 @@ function keyNames(entries) {
113
133
  .map(s => s.split(/[:=]/)[0].trim())
114
134
  .filter(s => /^[A-Za-z_$][\w$]*$/.test(s));
115
135
  }
136
+ const propNameCache = new WeakMap();
137
+ /** `parsePropNames` of a component's source, cached per function. */
138
+ export function readPropNames(fn) {
139
+ let cached = propNameCache.get(fn);
140
+ if (!cached) {
141
+ try {
142
+ cached = parsePropNames(fn.toString());
143
+ }
144
+ catch {
145
+ cached = NONE;
146
+ }
147
+ propNameCache.set(fn, cached);
148
+ }
149
+ return cached;
150
+ }
116
151
  //# sourceMappingURL=propNames.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"propNames.js","sourceRoot":"","sources":["../../../src/compile/binds/propNames.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAQF,MAAM,IAAI,GAAc,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AAE3E,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,KAAK,GAAG,0CAA0C,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnE,IAAI,IAAY,CAAC;IACjB,IAAI,KAAK,EAAE,CAAC;QACV,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC9B,IACE,IAAI,GAAG,CAAC;YACR,CAAC,8DAA8D,CAAC,IAAI,CAClE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CACnB,EACD,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;Q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AC,EAAE,CAAC;YACpC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAClC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/B,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,QAAQ,CAAC,OAAiB;IACjC,OAAO,OAAO;SACX,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;SACjC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACnC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.components\",\n \"title\": \"Component Tag Binding System\",\n \"category\": \"runtime\"\n}\n*/\n\nexport interface PropNames {\n names: string[];\n fromParam: boolean;\n exhaustive: boolean;\n}\n\nconst NONE: PropNames = { names: [], fromParam: false, exhaustive: false };\n\nexport function parsePropNames(src: string): PropNames {\n const arrow = /^\\s*(?:async\\s+)?([A-Za-z_$][\\w$]*)\\s*=>/.exec(src);\n let head: string;\n if (arrow) {\n head = arrow[1];\n } else {\n const open = src.indexOf('(');\n if (\n open < 0 ||\n !/^\\s*(?:async\\b\\s*)?(?:function\\b[^(]*|[A-Za-z_$][\\w$]*\\s*)?$/.test(\n src.slice(0, open)\n )\n ) {\n return NONE;\n }\n head = src.slice(open + 1).trimStart();\n }\n if (head.startsWith('{')) {\n const body = balanced(head, 0);\n if (body === null) return NONE;\n const entries = topLevelEntries(body);\n return {\n names: keyNames(entries),\n fromParam: true,\n exhaustive: !entries.some(e => e.startsWith('...')),\n };\n }\n\n const param = /^([A-Za-z_$][\\w$]*)/.exec(head)?.[1]?.replace(/\\$/g, '\\\\$');\n if (!param) return NONE;\n const names = new Set<string>();\n const destructure = /\\b(?:const|let|var)\\s*\\{/g;\n let m: RegExpExecArray | null;\n while ((m = destructure.exec(src))) {\n const start = m.index + m[0].length - 1;\n const body = balanced(src, start);\n if (body === null) break;\n const rest = src.slice(start + body.length + 2);\n if (new RegExp(`^\\\\s*=\\\\s*${param}\\\\b(?!\\\\s*\\\\.)`).test(rest)) {\n for (const name of keyNames(topLevelEntries(body))) names.add(name);\n }\n }\n for (const access of src.matchAll(\n new RegExp(`\\\\b${param}\\\\.([A-Za-z_$][\\\\w$]*)`, 'g')\n )) {\n names.add(access[1]);\n }\n return { names: [...names], fromParam: false, exhaustive: false };\n}\n\nfunction balanced(src: string, start: number): string | null {\n let depth = 0;\n let quote = '';\n for (let i = start; i < src.length; i++) {\n const c = src[i];\n if (quote) {\n if (c === '\\\\') i++;\n else if (c === quote) quote = '';\n } else if (c === '\"' || c === \"'\" || c === '`') {\n quote = c;\n } else if (c === '{' || c === '[' || c === '(') {\n depth++;\n } else if (c === '}' || c === ']' || c === ')') {\n if (--depth === 0) return src.slice(start + 1, i);\n }\n }\n return null;\n}\n\nfunction topLevelEntries(body: string): string[] {\n const entries: string[] = [];\n let depth = 0;\n let quote = '';\n let from = 0;\n for (let i = 0; i < body.length; i++) {\n const c = body[i];\n if (quote) {\n if (c === '\\\\') i++;\n else if (c === quote) quote = '';\n } else if (c === '\"' || c === \"'\" || c === '`') {\n quote = c;\n } else if (c === '{' || c === '[' || c === '(') {\n depth++;\n } else if (c === '}' || c === ']' || c === ')') {\n depth--;\n } else if (c === ',' && depth === 0) {\n entries.push(body.slice(from, i));\n from = i + 1;\n }\n }\n entries.push(body.slice(from));\n return entries.map(s => s.trim()).filter(Boolean);\n}\n\nfunction keyNames(entries: string[]): string[] {\n return entries\n .filter(s => !s.startsWith('...'))\n .map(s => s.split(/[:=]/)[0].trim())\n .filter(s => /^[A-Za-z_$][\\w$]*$/.test(s));\n}\n"]}
1
+ {"version":3,"file":"propNames.js","sourceRoot":"","sources":["../../../src/compile/binds/propNames.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAQF,MAAM,IAAI,GAAc,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AAE3E,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,MAAM,QAAQ,GAAG,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IACtD,yEAAyE;IACzE,MAAM,GAAG,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAClC,IAAI,QAAQ,CAAC,SAAS,KAAK,GAAG,CAAC,SAAS;QACtC,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC;IAC7C,OAAO;QACL,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;QACtD,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,UAAU,EAAE,QAAQ,CAAC,UAAU,IAAI,GAAG,CAAC,UAAU;KAClD,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,MAAM,KAAK,GAAG,0CAA0C,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnE,IAAI,IAAY,CAAC;IACjB,IAAI,KAAK,EAAE,CAAC;QACV,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,GAAG,GAAG,CA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AAE,CAAC;SACnC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,aAAa,GAAG,IAAI,OAAO,EAAqB,CAAC;AAEvD,qEAAqE;AACrE,MAAM,UAAU,aAAa,CAAC,EAAiC;IAC7D,IAAI,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACnC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,IAAI,CAAC;YACH,MAAM,GAAG,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;QACzC,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;QACD,aAAa,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.components\",\n \"title\": \"Component Tag Binding System\",\n \"category\": \"runtime\"\n}\n*/\n\nexport interface PropNames {\n names: string[];\n fromParam: boolean;\n exhaustive: boolean;\n}\n\nconst NONE: PropNames = { names: [], fromParam: false, exhaustive: false };\n\nexport function parsePropNames(source: string): PropNames {\n const stripped = readSignature(stripComments(source));\n // Never fewer names than the raw read, which a misread strip could drop.\n const raw = readSignature(source);\n if (stripped.fromParam !== raw.fromParam)\n return stripped.fromParam ? stripped : raw;\n return {\n names: [...new Set([...stripped.names, ...raw.names])],\n fromParam: stripped.fromParam,\n exhaustive: stripped.exhaustive && raw.exhaustive,\n };\n}\n\nfunction readSignature(src: string): PropNames {\n const arrow = /^\\s*(?:async\\s+)?([A-Za-z_$][\\w$]*)\\s*=>/.exec(src);\n let head: string;\n if (arrow) {\n head = arrow[1];\n } else {\n const open = src.indexOf('(');\n if (\n open < 0 ||\n !/^\\s*(?:async\\b\\s*)?(?:function\\b[^(]*|[A-Za-z_$][\\w$]*\\s*)?$/.test(\n src.slice(0, open)\n )\n ) {\n return NONE;\n }\n head = src.slice(open + 1).trimStart();\n }\n if (head.startsWith('{')) {\n const body = balanced(head, 0);\n if (body === null) return NONE;\n const entries = topLevelEntries(body);\n return {\n names: keyNames(entries),\n fromParam: true,\n exhaustive: !entries.some(e => e.startsWith('...')),\n };\n }\n\n const param = /^([A-Za-z_$][\\w$]*)/.exec(head)?.[1]?.replace(/\\$/g, '\\\\$');\n if (!param) return NONE;\n const names = new Set<string>();\n const destructure = /\\b(?:const|let|var)\\s*\\{/g;\n let m: RegExpExecArray | null;\n while ((m = destructure.exec(src))) {\n const start = m.index + m[0].length - 1;\n const body = balanced(src, start);\n if (body === null) break;\n const rest = src.slice(start + body.length + 2);\n if (new RegExp(`^\\\\s*=\\\\s*${param}\\\\b(?!\\\\s*\\\\.)`).test(rest)) {\n for (const name of keyNames(topLevelEntries(body))) names.add(name);\n }\n }\n for (const access of src.matchAll(\n new RegExp(`\\\\b${param}\\\\.([A-Za-z_$][\\\\w$]*)`, 'g')\n )) {\n names.add(access[1]);\n }\n return { names: [...names], fromParam: false, exhaustive: false };\n}\n\n// A comment in a signature can hold a comma or a quote (BUG-102). Strings are\n// kept; a regex is not recognised, so `/\\//` can read as a comment, and the\n// raw read in `parsePropNames` keeps the names that drops.\nconst COMMENT =\n /([\"'`])(?:\\\\[\\s\\S]|(?!\\1)[^\\\\])*\\1?|\\/\\/[^\\n]*|\\/\\*[\\s\\S]*?(?:\\*\\/|$)/g;\n\n/** `src` without comments. */\nexport function stripComments(src: string): string {\n return src.replace(COMMENT, t =>\n t[0] !== '/' ? t : t[1] === '/' ? '' : ' '\n );\n}\n\nfunction balanced(src: string, start: number): string | null {\n let depth = 0;\n let quote = '';\n for (let i = start; i < src.length; i++) {\n const c = src[i];\n if (quote) {\n if (c === '\\\\') i++;\n else if (c === quote) quote = '';\n } else if (c === '\"' || c === \"'\" || c === '`') {\n quote = c;\n } else if (c === '{' || c === '[' || c === '(') {\n depth++;\n } else if (c === '}' || c === ']' || c === ')') {\n if (--depth === 0) return src.slice(start + 1, i);\n }\n }\n return null;\n}\n\nfunction topLevelEntries(body: string): string[] {\n const entries: string[] = [];\n let depth = 0;\n let quote = '';\n let from = 0;\n for (let i = 0; i < body.length; i++) {\n const c = body[i];\n if (quote) {\n if (c === '\\\\') i++;\n else if (c === quote) quote = '';\n } else if (c === '\"' || c === \"'\" || c === '`') {\n quote = c;\n } else if (c === '{' || c === '[' || c === '(') {\n depth++;\n } else if (c === '}' || c === ']' || c === ')') {\n depth--;\n } else if (c === ',' && depth === 0) {\n entries.push(body.slice(from, i));\n from = i + 1;\n }\n }\n entries.push(body.slice(from));\n return entries.map(s => s.trim()).filter(Boolean);\n}\n\nfunction keyNames(entries: string[]): string[] {\n return entries\n .filter(s => !s.startsWith('...'))\n .map(s => s.split(/[:=]/)[0].trim())\n .filter(s => /^[A-Za-z_$][\\w$]*$/.test(s));\n}\n\nconst propNameCache = new WeakMap<object, PropNames>();\n\n/** `parsePropNames` of a component's source, cached per function. */\nexport function readPropNames(fn: (...args: never[]) => unknown): PropNames {\n let cached = propNameCache.get(fn);\n if (!cached) {\n try {\n cached = parsePropNames(fn.toString());\n } catch {\n cached = NONE;\n }\n propNameCache.set(fn, cached);\n }\n return cached;\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { PropNames } from './propNames.js';
2
+ /**
3
+ * Warns for props a component that destructures all of its props does not name.
4
+ * Missing props are not reported: a template assembles props at runtime.
5
+ */
6
+ export declare function warnUnexpectedProps({ names, exhaustive }: PropNames, props: Record<string, unknown>, tag: string): void;
7
+ /** Test-only: forget which bound props were warned about. */
8
+ export declare function __resetBoundPropWarnings(): void;
9
+ /** Warns once per tag for `[x]` on a component tag where `x` is one of its props. */
10
+ export declare function warnBoundProps(names: string[], bound: string[], tag: string): void;
11
+ //# sourceMappingURL=propWarnings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propWarnings.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/propWarnings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,SAAS,EAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,GAAG,EAAE,MAAM,GACV,IAAI,CAON;AAaD,6DAA6D;AAC7D,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C;AAED,qFAAqF;AACrF,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EAAE,EACf,KAAK,EAAE,MAAM,EAAE,EACf,GAAG,EAAE,MAAM,GACV,IAAI,CAUN"}
@@ -0,0 +1,43 @@
1
+ import { boundPropMessage, unexpectedPropsMessage } from '../evalDiagnostics.js';
2
+ /**
3
+ * Warns for props a component that destructures all of its props does not name.
4
+ * Missing props are not reported: a template assembles props at runtime.
5
+ */
6
+ export function warnUnexpectedProps({ names, exhaustive }, props, tag) {
7
+ if (!exhaustive || names.length === 0)
8
+ return;
9
+ const passed = Object.keys(props);
10
+ const expected = new Set(names);
11
+ const unexpected = passed.filter(p => !expected.has(p));
12
+ if (unexpected.length)
13
+ console.warn(unexpectedPropsMessage(tag, unexpected, names, passed));
14
+ }
15
+ const GLOBAL_ATTRS = new Set([
16
+ 'id',
17
+ 'class',
18
+ 'style',
19
+ 'title',
20
+ 'role',
21
+ 'tabindex',
22
+ 'hidden',
23
+ ]);
24
+ const warned = new Set();
25
+ /** Test-only: forget which bound props were warned about. */
26
+ export function __resetBoundPropWarnings() {
27
+ warned.clear();
28
+ }
29
+ /** Warns once per tag for `[x]` on a component tag where `x` is one of its props. */
30
+ export function warnBoundProps(names, bound, tag) {
31
+ for (const attr of bound) {
32
+ const name = attr.toLowerCase();
33
+ if (GLOBAL_ATTRS.has(name))
34
+ continue;
35
+ const prop = names.find(p => p.toLowerCase() === name);
36
+ const key = `${tag} ${name}`;
37
+ if (!prop || warned.has(key))
38
+ continue;
39
+ warned.add(key);
40
+ console.warn(boundPropMessage(tag, name, prop));
41
+ }
42
+ }
43
+ //# sourceMappingURL=propWarnings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propWarnings.js","sourceRoot":"","sources":["../../../src/compile/binds/propWarnings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG9E;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,EAAE,KAAK,EAAE,UAAU,EAAa,EAChC,KAA8B,EAC9B,GAAW;IAEX,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAC9C,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,IAAI,UAAU,CAAC,MAAM;QACnB,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,IAAI;IACJ,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;IACN,UAAU;IACV,QAAQ;CACT,CAAC,CAAC;AACH,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;AAEjC,6DAA6D;AAC7D,MAAM,UAAU,wBAAwB;IACtC,MAAM,CAAC,KAAK,EAAE,CAAC;AACjB,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,cAAc,CAC5B,KAAe,EACf,KAAe,EACf,GAAW;IAEX,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAChC,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAS;QACrC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,CAAC;QACvD,MAAM,GAAG,GAAG,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;QACvC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAClD,CAAC;AACH,CAAC","sourcesContent":["import { boundPropMessage, unexpectedPropsMessage } from '../evalDiagnostics';\nimport type { PropNames } from './propNames';\n\n/**\n * Warns for props a component that destructures all of its props does not name.\n * Missing props are not reported: a template assembles props at runtime.\n */\nexport function warnUnexpectedProps(\n { names, exhaustive }: PropNames,\n props: Record<string, unknown>,\n tag: string\n): void {\n if (!exhaustive || names.length === 0) return;\n const passed = Object.keys(props);\n const expected = new Set(names);\n const unexpected = passed.filter(p => !expected.has(p));\n if (unexpected.length)\n console.warn(unexpectedPropsMessage(tag, unexpected, names, passed));\n}\n\nconst GLOBAL_ATTRS = new Set([\n 'id',\n 'class',\n 'style',\n 'title',\n 'role',\n 'tabindex',\n 'hidden',\n]);\nconst warned = new Set<string>();\n\n/** Test-only: forget which bound props were warned about. */\nexport function __resetBoundPropWarnings(): void {\n warned.clear();\n}\n\n/** Warns once per tag for `[x]` on a component tag where `x` is one of its props. */\nexport function warnBoundProps(\n names: string[],\n bound: string[],\n tag: string\n): void {\n for (const attr of bound) {\n const name = attr.toLowerCase();\n if (GLOBAL_ATTRS.has(name)) continue;\n const prop = names.find(p => p.toLowerCase() === name);\n const key = `${tag} ${name}`;\n if (!prop || warned.has(key)) continue;\n warned.add(key);\n console.warn(boundPropMessage(tag, name, prop));\n }\n}\n"]}
@@ -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;AAc9C;;;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;AAqBD;;;GAGG;AACH,+KAA+K;AAC/K,wBAAgB,YAAY,CAC1B,OAAO,EAAE,OAAO,GAAG,SAAS,GAC3B,OAAO,GAAG,SAAS,CAErB;AAED,uFAAuF;AACvF,sLAAsL;AACtL,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,IAAI,CAGN;AAED,gNAAgN;AAChN,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,SAAS,EAAE,EACrB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtC,IAAI,CAAC,EAAE,OAAO,GACb,OAAO,CAiGT;AAED,oKAAoK;AACpK,wBAAgB,eAAe,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,EAAE,CA+BrE;AAED,6DAA6D;AAC7D,uJ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AgB,eAAe,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,EAAE,CA+BrE;AAED,6DAA6D;AAC7D,uJAAuJ;AACvJ,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAItD;AAQD,qMAAqM;AACrM,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAGN"}
@@ -5,6 +5,7 @@
5
5
  "category": "feature"
6
6
  }
7
7
  */
8
+ import { sharedSlotMessage, sharedSlots } from '@pithyjs/compiler';
8
9
  import { pithyTreeToDom } from './pithyTreeToDom.js';
9
10
  import { bindStructuralDirectives } from './compileTemplate.js';
10
11
  import { nodeExpando } from './nodeExpando.js';
@@ -56,13 +57,12 @@ export function collectSlotMap(children, parentContext, host) {
56
57
  else
57
58
  slotGroups.delete('');
58
59
  }
59
- // Validate slot usage in DEV mode
60
60
  if (import.meta.env?.DEV) {
61
- const slotNames = Array.from(slotGroups.keys());
62
- const duplicateSlots = slotNames.filter(name => name !== '' && slotGroups.get(name).length > 1);
63
- if (duplicateSlots.length > 0) {
64
- console.warn(`[ContentProjection] Multiple content nodes targeting the same slot. This is allowed but may indicate a mistake:`, duplicateSlots);
65
- }
61
+ const tag = (host && nodeExpando(host).__pithyNode?.originalTagName) ??
62
+ host?.localName ??
63
+ 'component';
64
+ for (const name of sharedSlots(children))
65
+ console.warn(`[PithyJS] ${sharedSlotMessage(tag, name)}`);
66
66
  }
67
67
  // Create renderer functions for each slot group.
68
68
  // NOTE: We intentionally do NOT cache or clone DocumentFragments here.