@pithyjs/core 0.1.0-beta.23 → 0.1.0-beta.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
- package/dist/compile/binds/bindComponentsTags.js +24 -11
- package/dist/compile/binds/bindComponentsTags.js.map +1 -1
- package/dist/compile/binds/bindDeferDirectives.d.ts +3 -3
- package/dist/compile/binds/bindDeferDirectives.d.ts.map +1 -1
- package/dist/compile/binds/bindDeferDirectives.js +7 -5
- package/dist/compile/binds/bindDeferDirectives.js.map +1 -1
- package/dist/compile/binds/bindErrorBoundary.d.ts +6 -2
- package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
- package/dist/compile/binds/bindErrorBoundary.js +86 -20
- package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
- package/dist/compile/compileTemplate.d.ts.map +1 -1
- package/dist/compile/compileTemplate.js +5 -1
- package/dist/compile/compileTemplate.js.map +1 -1
- package/dist/compile/contentProjection.d.ts +53 -2
- package/dist/compile/contentProjection.d.ts.map +1 -1
- package/dist/compile/contentProjection.js +118 -5
- package/dist/compile/contentProjection.js.map +1 -1
- package/dist/compile/index.d.ts +1 -0
- package/dist/compile/index.d.ts.map +1 -1
- package/dist/compile/index.js +1 -0
- package/dist/compile/index.js.map +1 -1
- package/dist/compile/nodeExpando.d.ts +5 -0
- package/dist/compile/nodeExpando.d.ts.map +1 -1
- package/dist/compile/nodeExpando.js.map +1 -1
- package/dist/compile/renderChildren.d.ts +2 -0
- package/dist/compile/renderChildren.d.ts.map +1 -1
- package/dist/compile/renderChildren.js +6 -2
- package/dist/compile/renderChildren.js.map +1 -1
- package/dist/compile/ssrCrashes.d.ts.map +1 -1
- package/dist/compile/ssrCrashes.js +76 -20
- package/dist/compile/ssrCrashes.js.map +1 -1
- package/dist/runtime/applyBindings.d.ts +6 -0
- package/dist/runtime/applyBindings.d.ts.map +1 -1
- package/dist/runtime/applyBindings.js +15 -0
- package/dist/runtime/applyBindings.js.map +1 -1
- package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
- package/dist/runtime/bindings/applyComponent.js +5 -1
- package/dist/runtime/bindings/applyComponent.js.map +1 -1
- package/dist/runtime/bindings/applyDefer.js +2 -2
- package/dist/runtime/bindings/applyDefer.js.map +1 -1
- package/dist/runtime/bindings/applySimple.d.ts.map +1 -1
- package/dist/runtime/bindings/applySimple.js +10 -4
- package/dist/runtime/bindings/applySimple.js.map +1 -1
- package/dist/runtime/bindings/helpers.d.ts.map +1 -1
- package/dist/runtime/bindings/helpers.js +2 -1
- package/dist/runtime/bindings/helpers.js.map +1 -1
- package/dist/runtime/bindings/types.d.ts +2 -0
- package/dist/runtime/bindings/types.d.ts.map +1 -1
- package/dist/runtime/bindings/types.js.map +1 -1
- package/dist/types/globals.d.ts +1 -0
- package/dist/types/globals.d.ts.map +1 -1
- package/dist/types/globals.js.map +1 -1
- package/package.json +2 -2
|
@@ -20,6 +20,7 @@ const activeBoundaries = [];
|
|
|
20
20
|
*/
|
|
21
21
|
let currentBoundaryContext = null;
|
|
22
22
|
let slotFrame = null;
|
|
23
|
+
let hostInFallback = false;
|
|
23
24
|
// Shared like the boundary context, so a nested core copy sees the branch.
|
|
24
25
|
const openBranches = () => pithyGlobals().__pithyOpenBranches ?? 0;
|
|
25
26
|
const addBranches = (n) => {
|
|
@@ -63,6 +64,7 @@ function liveSlotParent(boundary) {
|
|
|
63
64
|
export function withSlotBoundary(anchor, host, fn) {
|
|
64
65
|
const outer = slotFrame;
|
|
65
66
|
const outerContext = boundaryContext();
|
|
67
|
+
const outerInFallback = contextInFallback();
|
|
66
68
|
const at = anchor ?? host;
|
|
67
69
|
if (at) {
|
|
68
70
|
// An anchor an earlier crash hid has no parent to resolve from.
|
|
@@ -93,31 +95,66 @@ export function withSlotBoundary(anchor, host, fn) {
|
|
|
93
95
|
direct: hider
|
|
94
96
|
? hider.contentPlaceholders.has(at)
|
|
95
97
|
: (anchor ?? host)?.parentElement === boundary?.element,
|
|
96
|
-
isContent: !!hider ||
|
|
98
|
+
isContent: !!hider ||
|
|
99
|
+
!(boundary?.fallbackElement?.contains(at) ||
|
|
100
|
+
(host && boundary && inOwnFallback(boundary, host))),
|
|
97
101
|
};
|
|
98
102
|
}
|
|
99
103
|
const owner = slotFrame?.boundary?.element ?? boundaryContext();
|
|
104
|
+
const inFallback = slotFrame?.boundary
|
|
105
|
+
? !slotFrame.isContent
|
|
106
|
+
: contextInFallback();
|
|
100
107
|
try {
|
|
101
108
|
const output = fn();
|
|
102
109
|
if (owner)
|
|
103
|
-
markSlotOutput(output, owner);
|
|
110
|
+
markSlotOutput(output, owner, inFallback);
|
|
104
111
|
return output;
|
|
105
112
|
}
|
|
106
113
|
finally {
|
|
107
114
|
slotFrame = outer;
|
|
108
|
-
setContext(outerContext);
|
|
115
|
+
setContext(outerContext, outerInFallback);
|
|
109
116
|
}
|
|
110
117
|
}
|
|
111
|
-
|
|
112
|
-
|
|
118
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"inOwnFallback","stability":"internal","signature":"(boundary: BoundaryInfo, el: Element) => boolean"} */
|
|
119
|
+
export function inOwnFallback(boundary, el) {
|
|
120
|
+
if (boundary.fallbackElement?.contains(el))
|
|
121
|
+
return true;
|
|
122
|
+
if (boundary.element.contains(el))
|
|
123
|
+
return false;
|
|
124
|
+
if (slotFrame?.boundary === boundary)
|
|
125
|
+
return !slotFrame.isContent;
|
|
126
|
+
if (hostInFallback && currentBoundaryContext === boundary)
|
|
127
|
+
return true;
|
|
128
|
+
for (let at = el; at; at = at.parentNode) {
|
|
129
|
+
const { __pithySlotOwner: owner, __pithySlotInFallback: inFallback } = nodeExpando(at);
|
|
130
|
+
if (owner)
|
|
131
|
+
return owner === boundary.element
|
|
132
|
+
? !!inFallback
|
|
133
|
+
: inOwnFallback(boundary, owner);
|
|
134
|
+
}
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"boundaryTaking","stability":"internal","signature":"(el: Element) => BoundaryInfo | null"} */
|
|
138
|
+
export function boundaryTaking(el) {
|
|
139
|
+
let at = boundaryForElement(el);
|
|
140
|
+
while (at && inOwnFallback(at, el))
|
|
141
|
+
at = findParentBoundary(at);
|
|
142
|
+
return at;
|
|
143
|
+
}
|
|
144
|
+
function markSlotOutput(output, owner, inFallback) {
|
|
113
145
|
const el = output instanceof Node ? output : output?.el;
|
|
114
146
|
if (!(el instanceof Node))
|
|
115
147
|
return;
|
|
116
148
|
const nodes = el.nodeType === Node.DOCUMENT_FRAGMENT_NODE
|
|
117
149
|
? Array.from(el.childNodes)
|
|
118
150
|
: [el];
|
|
119
|
-
for (const node of nodes)
|
|
120
|
-
|
|
151
|
+
for (const node of nodes) {
|
|
152
|
+
const expando = nodeExpando(node);
|
|
153
|
+
if (expando.__pithySlotOwner)
|
|
154
|
+
continue;
|
|
155
|
+
expando.__pithySlotOwner = owner;
|
|
156
|
+
expando.__pithySlotInFallback = inFallback;
|
|
157
|
+
}
|
|
121
158
|
}
|
|
122
159
|
/** The boundary element of the slot that rendered `node`, if a slot did. */
|
|
123
160
|
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"slotOwnerOf","stability":"internal","signature":"(node: Node) => Element | null"} */
|
|
@@ -140,8 +177,13 @@ export function slotOwnerOf(node) {
|
|
|
140
177
|
export function boundaryContext() {
|
|
141
178
|
return pithyGlobals().__pithyBoundaryContext ?? null;
|
|
142
179
|
}
|
|
143
|
-
function
|
|
144
|
-
pithyGlobals().
|
|
180
|
+
function contextInFallback() {
|
|
181
|
+
return pithyGlobals().__pithyBoundaryContextInFallback ?? false;
|
|
182
|
+
}
|
|
183
|
+
function setContext(element, inFallback = false) {
|
|
184
|
+
const g = pithyGlobals();
|
|
185
|
+
g.__pithyBoundaryContext = element;
|
|
186
|
+
g.__pithyBoundaryContextInFallback = inFallback;
|
|
145
187
|
}
|
|
146
188
|
/**
|
|
147
189
|
* Builds an `@if`/`@case` branch or `@for` item that will be inserted beside
|
|
@@ -153,15 +195,27 @@ function setContext(element) {
|
|
|
153
195
|
export function withBranchBoundary(anchor, fn, inside = false) {
|
|
154
196
|
const into = inside ? anchor : anchor.parentNode;
|
|
155
197
|
const outer = boundaryContext();
|
|
198
|
+
const outerInFallback = contextInFallback();
|
|
156
199
|
const at = into?.nodeType === Node.ELEMENT_NODE ? into : null;
|
|
157
|
-
|
|
200
|
+
const closest = at?.closest('[data-error]');
|
|
201
|
+
if (at && closest) {
|
|
202
|
+
const boundary = activeBoundaries.find(b => b.element === closest);
|
|
203
|
+
const inFallback = boundary
|
|
204
|
+
? inOwnFallback(boundary, at)
|
|
205
|
+
: !!ownFallbackElement(closest)?.contains(at);
|
|
206
|
+
setContext(closest, inFallback);
|
|
207
|
+
}
|
|
208
|
+
else if (into?.isConnected)
|
|
209
|
+
setContext(null);
|
|
210
|
+
else
|
|
211
|
+
setContext(outer, outerInFallback);
|
|
158
212
|
addBranches(1);
|
|
159
213
|
try {
|
|
160
214
|
return fn();
|
|
161
215
|
}
|
|
162
216
|
finally {
|
|
163
217
|
addBranches(-1);
|
|
164
|
-
setContext(outer);
|
|
218
|
+
setContext(outer, outerInFallback);
|
|
165
219
|
}
|
|
166
220
|
}
|
|
167
221
|
/** Whether an `@if`/`@case` branch or `@for` item is being built. */
|
|
@@ -355,13 +409,21 @@ export function currentBoundary() {
|
|
|
355
409
|
* @param fn - Function to execute
|
|
356
410
|
* @returns Result of function execution
|
|
357
411
|
*/
|
|
358
|
-
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"runWithBoundary","stability":"stable","signature":"<T>(boundary: BoundaryInfo | null, fn: () => T) => T"} */
|
|
359
|
-
export function runWithBoundary(boundary, fn) {
|
|
360
|
-
|
|
412
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"runWithBoundary","stability":"stable","signature":"<T>(boundary: BoundaryInfo | null, fn: () => T, host?: Element) => T"} */
|
|
413
|
+
export function runWithBoundary(boundary, fn, host) {
|
|
414
|
+
const previous = hostInFallback;
|
|
415
|
+
hostInFallback = !!(host && boundary && inOwnFallback(boundary, host));
|
|
416
|
+
try {
|
|
417
|
+
return runUnder(boundary, fn, true);
|
|
418
|
+
}
|
|
419
|
+
finally {
|
|
420
|
+
hostInFallback = previous;
|
|
421
|
+
}
|
|
361
422
|
}
|
|
362
423
|
function runUnder(boundary, fn, attribute) {
|
|
363
424
|
const previousContext = currentBoundaryContext;
|
|
364
425
|
const previous = boundaryContext();
|
|
426
|
+
const previousInFallback = contextInFallback();
|
|
365
427
|
currentBoundaryContext = boundary;
|
|
366
428
|
if (boundary && attribute)
|
|
367
429
|
setContext(boundary.element);
|
|
@@ -370,7 +432,7 @@ function runUnder(boundary, fn, attribute) {
|
|
|
370
432
|
}
|
|
371
433
|
finally {
|
|
372
434
|
currentBoundaryContext = previousContext;
|
|
373
|
-
setContext(previous);
|
|
435
|
+
setContext(previous, previousInFallback);
|
|
374
436
|
}
|
|
375
437
|
}
|
|
376
438
|
function patchTimersOnce() {
|
|
@@ -439,6 +501,15 @@ function patchTimersOnce() {
|
|
|
439
501
|
* @returns The fallback element or null if not found
|
|
440
502
|
*/
|
|
441
503
|
function findFallbackElement(boundaryEl) {
|
|
504
|
+
const fallback = ownFallbackElement(boundaryEl);
|
|
505
|
+
if (fallback || !import.meta.env?.DEV)
|
|
506
|
+
return fallback;
|
|
507
|
+
console.warn(`[ErrorBoundary] No fallback element found for boundary`, boundaryEl.tagName, 'Available children:', Array.from(boundaryEl.children).map(c => c.tagName +
|
|
508
|
+
(c.hasAttribute('data-fallback') ? '[fallback]' : '') +
|
|
509
|
+
(c.hasAttribute('data-error') ? '[boundary]' : '')));
|
|
510
|
+
return null;
|
|
511
|
+
}
|
|
512
|
+
function ownFallbackElement(boundaryEl) {
|
|
442
513
|
// Look through direct children first to avoid nested boundary fallbacks
|
|
443
514
|
for (const child of Array.from(boundaryEl.children)) {
|
|
444
515
|
if (child.hasAttribute('data-fallback')) {
|
|
@@ -457,11 +528,6 @@ function findFallbackElement(boundaryEl) {
|
|
|
457
528
|
return fallback;
|
|
458
529
|
}
|
|
459
530
|
}
|
|
460
|
-
if (import.meta.env?.DEV) {
|
|
461
|
-
console.warn(`[ErrorBoundary] No fallback element found for boundary`, boundaryEl.tagName, 'Available children:', Array.from(boundaryEl.children).map(c => c.tagName +
|
|
462
|
-
(c.hasAttribute('data-fallback') ? '[fallback]' : '') +
|
|
463
|
-
(c.hasAttribute('data-error') ? '[boundary]' : '')));
|
|
464
|
-
}
|
|
465
531
|
return null;
|
|
466
532
|
}
|
|
467
533
|
/**
|
|
@@ -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,IAAI,OAAO,EAAW,CAAC;AAe7C;;GAEG;AACH,MAAM,gBAAgB,GAAmB,EAAE,CAAC;AAE5C;;GAEG;AACH,IAAI,sBAAsB,GAAwB,IAAI,CAAC;AAqBvD,IAAI,SAAS,GAAqB,IAAI,CAAC;AACvC,2EAA2E;AAC3E,MAAM,YAAY,GAAG,GAAW,EAAE,CAAC,YAAY,EAAE,CAAC,mBAAmB,IAAI,CAAC,CAAC;AAC3E,MAAM,WAAW,GAAG,CAAC,CAAS,EAAQ,EAAE;IACtC,YAAY,EAAE,CAAC,mBAAmB,GAAG,YAAY,EAAE,GAAG,CAAC,CAAC;AAC1D,CAAC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H,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"]}
|
|
1
|
+
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1C,IAAI,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC;YAAE,SAAS;QAC5C,MAAM,UAAU,GAAG,aAAa,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAC3D,IAAI,CAAC,UAAU;YAAE,SAAS;QAE1B,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAqC,CAAC;QAC5E,IAAI,CAAC,WAAW,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE,CAAC;YACtD,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,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;\nlet hostInFallback = false;\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 outerInFallback = contextInFallback();\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:\n !!hider ||\n !(\n boundary?.fallbackElement?.contains(at) ||\n (host && boundary && inOwnFallback(boundary, host))\n ),\n };\n }\n const owner = slotFrame?.boundary?.element ?? boundaryContext();\n const inFallback = slotFrame?.boundary\n ? !slotFrame.isContent\n : contextInFallback();\n try {\n const output = fn();\n if (owner) markSlotOutput(output, owner, inFallback);\n return output;\n } finally {\n slotFrame = outer;\n setContext(outerContext, outerInFallback);\n }\n}\n\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"inOwnFallback\",\"stability\":\"internal\",\"signature\":\"(boundary: BoundaryInfo, el: Element) => boolean\"} */\nexport function inOwnFallback(boundary: BoundaryInfo, el: Element): boolean {\n if (boundary.fallbackElement?.contains(el)) return true;\n if (boundary.element.contains(el)) return false;\n if (slotFrame?.boundary === boundary) return !slotFrame.isContent;\n if (hostInFallback && currentBoundaryContext === boundary) return true;\n for (let at: Node | null = el; at; at = at.parentNode) {\n const { __pithySlotOwner: owner, __pithySlotInFallback: inFallback } =\n nodeExpando(at);\n if (owner)\n return owner === boundary.element\n ? !!inFallback\n : inOwnFallback(boundary, owner);\n }\n return false;\n}\n\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"boundaryTaking\",\"stability\":\"internal\",\"signature\":\"(el: Element) => BoundaryInfo | null\"} */\nexport function boundaryTaking(el: Element): BoundaryInfo | null {\n let at = boundaryForElement(el);\n while (at && inOwnFallback(at, el)) at = findParentBoundary(at);\n return at;\n}\n\nfunction markSlotOutput(\n output: unknown,\n owner: Element,\n inFallback: boolean\n): 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) {\n const expando = nodeExpando(node);\n if (expando.__pithySlotOwner) continue;\n expando.__pithySlotOwner = owner;\n expando.__pithySlotInFallback = inFallback;\n }\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 contextInFallback(): boolean {\n return pithyGlobals().__pithyBoundaryContextInFallback ?? false;\n}\n\nfunction setContext(element: Element | null, inFallback = false): void {\n const g = pithyGlobals();\n g.__pithyBoundaryContext = element;\n g.__pithyBoundaryContextInFallback = inFallback;\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 outerInFallback = contextInFallback();\n const at = into?.nodeType === Node.ELEMENT_NODE ? (into as Element) : null;\n const closest = at?.closest('[data-error]');\n if (at && closest) {\n const boundary = activeBoundaries.find(b => b.element === closest);\n const inFallback = boundary\n ? inOwnFallback(boundary, at)\n : !!ownFallbackElement(closest)?.contains(at);\n setContext(closest, inFallback);\n } else if (into?.isConnected) setContext(null);\n else setContext(outer, outerInFallback);\n addBranches(1);\n try {\n return fn();\n } finally {\n addBranches(-1);\n setContext(outer, outerInFallback);\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, host?: Element) => T\"} */\nexport function runWithBoundary<T>(\n boundary: BoundaryInfo | null,\n fn: () => T,\n host?: Element\n): T {\n const previous = hostInFallback;\n hostInFallback = !!(host && boundary && inOwnFallback(boundary, host));\n try {\n return runUnder(boundary, fn, true);\n } finally {\n hostInFallback = previous;\n }\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 const previousInFallback = contextInFallback();\n currentBoundaryContext = boundary;\n if (boundary && attribute) setContext(boundary.element);\n try {\n return fn();\n } finally {\n currentBoundaryContext = previousContext;\n setContext(previous, previousInFallback);\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 const fallback = ownFallbackElement(boundaryEl);\n if (fallback || !import.meta.env?.DEV) return fallback;\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 return null;\n}\n\nfunction ownFallbackElement(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 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileTemplate.d.ts","sourceRoot":"","sources":["../../src/compile/compileTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;
|
|
1
|
+
{"version":3,"file":"compileTemplate.d.ts","sourceRoot":"","sources":["../../src/compile/compileTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAqBF;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,mBAAmB,EAAE,SAAS,EAAE,EAC9C,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAUN;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,+RAA+R;AAC/R,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,GAAG,CAAC,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,EAChB,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAChC;IAAE,EAAE,EAAE,WAAW,GAAG,gBAAgB,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAmD7D;AAED;;;;;;;;;;;;;;;GAeG;AACH,qNAAqN;AACrN,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAsBN"}
|
|
@@ -13,7 +13,8 @@ import { bindRefDirectives } from './binds/bindRefDirectives.js';
|
|
|
13
13
|
import { bindErrorBoundary } from './binds/bindErrorBoundary.js';
|
|
14
14
|
import { bindForLoops } from './forLoops/bindForLoops.js';
|
|
15
15
|
import { bindSwitchCases } from './bindSwitchCases.js';
|
|
16
|
-
import {
|
|
16
|
+
import { collectSlotNames } from '@pithyjs/compiler';
|
|
17
|
+
import { declareSlotNames, extractSlotDefs, mountProjection, slotMapOf, } from './contentProjection.js';
|
|
17
18
|
import { bindAfterProjection } from './binds/bindAfterProjection.js';
|
|
18
19
|
import { orderByDocument } from './disposeOrder.js';
|
|
19
20
|
/**
|
|
@@ -61,6 +62,9 @@ export function compileTemplate(html, context, css, scopeId, importedIdentifiers
|
|
|
61
62
|
// Parse into fragment + AST
|
|
62
63
|
const parsed = parseHtml(html, id, context, importedIdentifiers);
|
|
63
64
|
fragment = parsed.fragment;
|
|
65
|
+
const slotMap = import.meta.env?.DEV ? slotMapOf(context) : undefined;
|
|
66
|
+
if (slotMap)
|
|
67
|
+
declareSlotNames(slotMap, collectSlotNames(parsed.pithyNodes));
|
|
64
68
|
const built = fragment;
|
|
65
69
|
withinRender(() => {
|
|
66
70
|
// Structural transforms first (they change the DOM shape and add anchors)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileTemplate.js","sourceRoot":"","sources":["../../src/compile/compileTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,eAAe,EACf,eAAe,GAEhB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;;;;;;GAOG;AACH,MAAM,U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CAAC;IACd,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC3C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,eAAe,CAAC,QAAQ,EAAE,OAAO,IAAI,IAAI,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;IAC7D,CAAC;IAED,8EAA8E;IAC9E,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AACpD,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.renderer\",\n \"title\": \"Template Compiler & Renderer\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { parseHtml } from './parseHtml';\nimport { withinRender } from './ssrCrashes';\nimport { injectScopedStyle } from './injectScopedStyle';\nimport { bindConditionals } from './binds/bindConditionals';\nimport { bindRefDirectives } from './binds/bindRefDirectives';\nimport { bindErrorBoundary } from './binds/bindErrorBoundary';\nimport { bindForLoops } from './forLoops/bindForLoops';\nimport { bindSwitchCases } from './bindSwitchCases';\nimport {\n extractSlotDefs,\n mountProjection,\n type SlotMap,\n} from './contentProjection';\nimport { bindAfterProjection } from './binds/bindAfterProjection';\nimport { orderByDocument } from './disposeOrder';\n\n/**\n * Runs all structural directive bindings on a fragment.\n *\n * Ordering:\n * 1) Switch cases first — they claim their case subtrees before conditionals walk the DOM\n * 2) Conditionals (@if/@else) — each branch binds its own nested switches\n * 3) For loops — skips nodes already processed by switches and conditionals\n */\nexport function bindStructuralDirectives(\n nodes: import('@pithyjs/compiler').PithyNode[],\n fragment: DocumentFragment,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n const processed = bindSwitchCases(\n nodes,\n fragment,\n context,\n new Set(),\n disposers\n );\n bindConditionals(nodes, fragment, context, processed, disposers);\n bindForLoops(nodes, fragment, context, disposers, processed);\n}\n\n/**\n * Compiles a raw HTML template into live DOM nodes with signal bindings,\n * event handlers, and optional styles.\n *\n * Pipeline overview:\n * 1) parseHtml → returns a DocumentFragment + AST nodes (pithyNodes)\n * 2) structural directives first: @if/@else, @switch, @for (they shape the DOM)\n * 3) inject CSS (scoped)\n * 4) run remaining binders in an order that avoids double-binding and cross-contamination:\n * - refs (so later passes can access refs if needed)\n * - components (instantiate/replace custom tags BEFORE binding into their subtree)\n * - two-way (default model bindings for inputs)\n * - text interpolations\n * - events\n * - classes\n * - bound attributes\n *\n * @param html - Raw HTML template string\n * @param context - Reactive context object (signals, methods, components)\n * @param css - Optional CSS string to scope and inject\n * @param scopeId - Optional scope id for CSS scoping\n * @param importedIdentifiers - Optional set of ids exposed to expressions\n */\n/** @codexApi {\"parent\":\"pithy.runtime.renderer\",\"name\":\"compileTemplate\",\"stability\":\"stable\",\"signature\":\"(html: string, context: Record<string, any>, css?: string, scopeId?: string, importedIdentifiers?: Set<string>) => { el: HTMLElement | DocumentFragment; destroy: () => void }\"} */\nexport function compileTemplate(\n html: string,\n context: Record<string, unknown>,\n css?: string,\n scopeId?: string,\n importedIdentifiers?: Set<string>\n): { el: HTMLElement | DocumentFragment; destroy: () => void } {\n const id = scopeId ?? `pithy-${Math.random().toString(36).slice(2, 8)}`;\n const disposers: (() => void)[] = [];\n\n let fragment: DocumentFragment;\n try {\n // Parse into fragment + AST\n const parsed = parseHtml(html, id, context, importedIdentifiers);\n fragment = parsed.fragment;\n\n const built = fragment;\n withinRender(() => {\n // Structural transforms first (they change the DOM shape and add anchors)\n bindStructuralDirectives(parsed.pithyNodes, built, context, disposers);\n\n // Scoped CSS after structure is stable\n if (css) {\n injectScopedStyle(css, id);\n }\n\n // Remaining directives/bindings in carefully chosen order\n bindTemplateDirectives(built, context, disposers);\n });\n orderByDocument(disposers);\n } catch (err) {\n // Clean up any disposers registered during partial compilation\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore */\n }\n }\n throw err;\n }\n\n return {\n el: fragment,\n destroy() {\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore */\n }\n }\n disposers.length = 0;\n },\n };\n}\n\n/**\n * Applies all non-structural bindings to the compiled fragment.\n *\n * Ordering rationale:\n * - refs: collected early, sometimes needed by subsequent binders\n * - error boundaries: register boundaries before components render (enables error capture)\n * - projection: mount projected content into slot anchors BEFORE component binding,\n * so nested component tags in projected content get processed\n * - components: instantiate/replace custom tags (including those in projected content);\n * prevents parent binders from walking into raw component tags\n * - two-way: attach default v-model-ish behavior on real inputs (not inside components)\n * - text: {{ ... }} bindings (skips nested loops / component subtrees via flags)\n * - events: add listeners (idempotent; supports modifiers; nearest ctx; $event/$el)\n * - classes: dynamic class toggles\n * - attributes: remaining [attr]=\"...\" bindings\n */\n/** @codexApi {\"parent\":\"pithy.runtime.renderer\",\"name\":\"bindTemplateDirectives\",\"stability\":\"stable\",\"signature\":\"(fragment: DocumentFragment, context: Record<string, any>, disposers: (() => void)[]) => void\"} */\nexport function bindTemplateDirectives(\n fragment: DocumentFragment,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n // 1) refs first — enables grabbing component roots/elements if needed\n bindRefDirectives(fragment, context, disposers);\n\n // 2) error boundaries — register before components so they can catch component errors\n bindErrorBoundary(fragment, context, disposers);\n\n // 3) content projection — mount projected content into slot anchors BEFORE components.\n // Projected content may contain component tags (e.g., nested <Show> inside <Show>).\n // If components ran first, those nested component tags would never be processed.\n // Without a SlotMap (a component called directly) slots still get their fallback.\n // Use 'in' operator to check via Proxy's has() trap without triggering the get() warning\n const slotMap = ('__slotMap' in context ? context.__slotMap : undefined) as\n | SlotMap\n | undefined;\n const slotDefs = extractSlotDefs(fragment);\n if (slotDefs.length > 0) {\n mountProjection(slotDefs, slotMap ?? new Map(), disposers);\n }\n\n // 4-11) components, two-way, text, events, classes, attributes, custom, defer\n bindAfterProjection(fragment, context, disposers);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"compileTemplate.js","sourceRoot":"","sources":["../../src/compile/compileTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;E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D,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.renderer\",\n \"title\": \"Template Compiler & Renderer\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { parseHtml } from './parseHtml';\nimport { withinRender } from './ssrCrashes';\nimport { injectScopedStyle } from './injectScopedStyle';\nimport { bindConditionals } from './binds/bindConditionals';\nimport { bindRefDirectives } from './binds/bindRefDirectives';\nimport { bindErrorBoundary } from './binds/bindErrorBoundary';\nimport { bindForLoops } from './forLoops/bindForLoops';\nimport { bindSwitchCases } from './bindSwitchCases';\nimport { collectSlotNames } from '@pithyjs/compiler';\nimport {\n declareSlotNames,\n extractSlotDefs,\n mountProjection,\n slotMapOf,\n type SlotMap,\n} from './contentProjection';\nimport { bindAfterProjection } from './binds/bindAfterProjection';\nimport { orderByDocument } from './disposeOrder';\n\n/**\n * Runs all structural directive bindings on a fragment.\n *\n * Ordering:\n * 1) Switch cases first — they claim their case subtrees before conditionals walk the DOM\n * 2) Conditionals (@if/@else) — each branch binds its own nested switches\n * 3) For loops — skips nodes already processed by switches and conditionals\n */\nexport function bindStructuralDirectives(\n nodes: import('@pithyjs/compiler').PithyNode[],\n fragment: DocumentFragment,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n const processed = bindSwitchCases(\n nodes,\n fragment,\n context,\n new Set(),\n disposers\n );\n bindConditionals(nodes, fragment, context, processed, disposers);\n bindForLoops(nodes, fragment, context, disposers, processed);\n}\n\n/**\n * Compiles a raw HTML template into live DOM nodes with signal bindings,\n * event handlers, and optional styles.\n *\n * Pipeline overview:\n * 1) parseHtml → returns a DocumentFragment + AST nodes (pithyNodes)\n * 2) structural directives first: @if/@else, @switch, @for (they shape the DOM)\n * 3) inject CSS (scoped)\n * 4) run remaining binders in an order that avoids double-binding and cross-contamination:\n * - refs (so later passes can access refs if needed)\n * - components (instantiate/replace custom tags BEFORE binding into their subtree)\n * - two-way (default model bindings for inputs)\n * - text interpolations\n * - events\n * - classes\n * - bound attributes\n *\n * @param html - Raw HTML template string\n * @param context - Reactive context object (signals, methods, components)\n * @param css - Optional CSS string to scope and inject\n * @param scopeId - Optional scope id for CSS scoping\n * @param importedIdentifiers - Optional set of ids exposed to expressions\n */\n/** @codexApi {\"parent\":\"pithy.runtime.renderer\",\"name\":\"compileTemplate\",\"stability\":\"stable\",\"signature\":\"(html: string, context: Record<string, any>, css?: string, scopeId?: string, importedIdentifiers?: Set<string>) => { el: HTMLElement | DocumentFragment; destroy: () => void }\"} */\nexport function compileTemplate(\n html: string,\n context: Record<string, unknown>,\n css?: string,\n scopeId?: string,\n importedIdentifiers?: Set<string>\n): { el: HTMLElement | DocumentFragment; destroy: () => void } {\n const id = scopeId ?? `pithy-${Math.random().toString(36).slice(2, 8)}`;\n const disposers: (() => void)[] = [];\n\n let fragment: DocumentFragment;\n try {\n // Parse into fragment + AST\n const parsed = parseHtml(html, id, context, importedIdentifiers);\n fragment = parsed.fragment;\n const slotMap = import.meta.env?.DEV ? slotMapOf(context) : undefined;\n if (slotMap) declareSlotNames(slotMap, collectSlotNames(parsed.pithyNodes));\n\n const built = fragment;\n withinRender(() => {\n // Structural transforms first (they change the DOM shape and add anchors)\n bindStructuralDirectives(parsed.pithyNodes, built, context, disposers);\n\n // Scoped CSS after structure is stable\n if (css) {\n injectScopedStyle(css, id);\n }\n\n // Remaining directives/bindings in carefully chosen order\n bindTemplateDirectives(built, context, disposers);\n });\n orderByDocument(disposers);\n } catch (err) {\n // Clean up any disposers registered during partial compilation\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore */\n }\n }\n throw err;\n }\n\n return {\n el: fragment,\n destroy() {\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore */\n }\n }\n disposers.length = 0;\n },\n };\n}\n\n/**\n * Applies all non-structural bindings to the compiled fragment.\n *\n * Ordering rationale:\n * - refs: collected early, sometimes needed by subsequent binders\n * - error boundaries: register boundaries before components render (enables error capture)\n * - projection: mount projected content into slot anchors BEFORE component binding,\n * so nested component tags in projected content get processed\n * - components: instantiate/replace custom tags (including those in projected content);\n * prevents parent binders from walking into raw component tags\n * - two-way: attach default v-model-ish behavior on real inputs (not inside components)\n * - text: {{ ... }} bindings (skips nested loops / component subtrees via flags)\n * - events: add listeners (idempotent; supports modifiers; nearest ctx; $event/$el)\n * - classes: dynamic class toggles\n * - attributes: remaining [attr]=\"...\" bindings\n */\n/** @codexApi {\"parent\":\"pithy.runtime.renderer\",\"name\":\"bindTemplateDirectives\",\"stability\":\"stable\",\"signature\":\"(fragment: DocumentFragment, context: Record<string, any>, disposers: (() => void)[]) => void\"} */\nexport function bindTemplateDirectives(\n fragment: DocumentFragment,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n // 1) refs first — enables grabbing component roots/elements if needed\n bindRefDirectives(fragment, context, disposers);\n\n // 2) error boundaries — register before components so they can catch component errors\n bindErrorBoundary(fragment, context, disposers);\n\n // 3) content projection — mount projected content into slot anchors BEFORE components.\n // Projected content may contain component tags (e.g., nested <Show> inside <Show>).\n // If components ran first, those nested component tags would never be processed.\n // Without a SlotMap (a component called directly) slots still get their fallback.\n // Use 'in' operator to check via Proxy's has() trap without triggering the get() warning\n const slotMap = ('__slotMap' in context ? context.__slotMap : undefined) as\n | SlotMap\n | undefined;\n const slotDefs = extractSlotDefs(fragment);\n if (slotDefs.length > 0) {\n mountProjection(slotDefs, slotMap ?? new Map(), disposers);\n }\n\n // 4-11) components, two-way, text, events, classes, attributes, custom, defer\n bindAfterProjection(fragment, context, disposers);\n}\n"]}
|
|
@@ -20,6 +20,57 @@ export interface SlotDef {
|
|
|
20
20
|
anchor: Comment;
|
|
21
21
|
fallbackFactory?: FallbackFactory;
|
|
22
22
|
}
|
|
23
|
+
/** Records the component tag `slotMap` fills, and the component, for DEV warnings. */
|
|
24
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"nameSlotMap","stability":"internal","signature":"(slotMap: SlotMap, tag: string, owner?: object) => void"} */
|
|
25
|
+
export declare function nameSlotMap(slotMap: SlotMap, tag: string, owner?: object): void;
|
|
26
|
+
/**
|
|
27
|
+
* DEV: warns once per component and slot name that a later `<slot>` gets no
|
|
28
|
+
* content. Without a known component, once per `instance` (one render).
|
|
29
|
+
*/
|
|
30
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"warnDuplicateSlot","stability":"internal","signature":"(slotMap: SlotMap | undefined, name: string, instance: object) => void"} */
|
|
31
|
+
export declare function warnDuplicateSlot(slotMap: SlotMap | undefined, name: string, instance: object): void;
|
|
32
|
+
/** Test hook: lets each test see its first duplicate-slot warning. */
|
|
33
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"resetDuplicateSlotWarnings","stability":"internal","signature":"() => void"} */
|
|
34
|
+
export declare function resetDuplicateSlotWarnings(): void;
|
|
35
|
+
/**
|
|
36
|
+
* DEV: records `names` as slots the component that `slotMap` fills renders,
|
|
37
|
+
* and that its template or children were looked at, which is what lets
|
|
38
|
+
* `warnUndeclaredSlots` check the rest.
|
|
39
|
+
*/
|
|
40
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"declareSlotNames","stability":"internal","signature":"(slotMap: SlotMap | undefined, names: Iterable<string>) => void"} */
|
|
41
|
+
export declare function declareSlotNames(slotMap: SlotMap | undefined, names: Iterable<string>): void;
|
|
42
|
+
/**
|
|
43
|
+
* DEV: a template rendered for `slotMap` without its `<slot>` list, as an
|
|
44
|
+
* older plugin's build or a precompiled library does. `warnUndeclaredSlots`
|
|
45
|
+
* then stays silent for the map, whatever else declared names for it.
|
|
46
|
+
*/
|
|
47
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"markSlotsUnknown","stability":"internal","signature":"(slotMap: SlotMap | undefined) => void"} */
|
|
48
|
+
export declare function markSlotsUnknown(slotMap: SlotMap | undefined): void;
|
|
49
|
+
/**
|
|
50
|
+
* Declares slot names a component reads from its children by hand, such as
|
|
51
|
+
* `slot="fallback"`, so DEV does not report content addressed to them as
|
|
52
|
+
* having nowhere to go, and marks its children as read, so DEV reports the
|
|
53
|
+
* rest. With no names, it only marks them read. Call it during render, before
|
|
54
|
+
* `captureChildren()`, which clears the context it reads. A no-op outside DEV
|
|
55
|
+
* or a render.
|
|
56
|
+
*
|
|
57
|
+
* @param names - The `slot="…"` values the component handles itself
|
|
58
|
+
*/
|
|
59
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"declareSlots","stability":"experimental","signature":"(...names: string[]) => void"} */
|
|
60
|
+
export declare function declareSlots(...names: string[]): void;
|
|
61
|
+
/**
|
|
62
|
+
* DEV: warns once per component and slot name for content in `slotMap`
|
|
63
|
+
* addressed to a named slot its component never declared. Silent for a
|
|
64
|
+
* component whose template and children were never looked at, or whose
|
|
65
|
+
* template rendered without its `<slot>` list.
|
|
66
|
+
*/
|
|
67
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"warnUndeclaredSlots","stability":"internal","signature":"(slotMap: SlotMap) => void"} */
|
|
68
|
+
export declare function warnUndeclaredSlots(slotMap: SlotMap): void;
|
|
69
|
+
/** Test hook: lets each test see its first undeclared-slot warning. */
|
|
70
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"resetUndeclaredSlotWarnings","stability":"internal","signature":"() => void"} */
|
|
71
|
+
export declare function resetUndeclaredSlotWarnings(): void;
|
|
72
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"slotMapOf","stability":"internal","signature":"(ctx: Record<string, unknown>) => SlotMap | undefined"} */
|
|
73
|
+
export declare function slotMapOf(ctx: Record<string, unknown>): SlotMap | undefined;
|
|
23
74
|
/**
|
|
24
75
|
* The slot map of the template the children behind `slotMap` were written in:
|
|
25
76
|
* what a `<slot>` among those children receives.
|
|
@@ -29,8 +80,8 @@ export declare function outerSlotMap(slotMap: SlotMap | undefined): SlotMap | un
|
|
|
29
80
|
/** Records `ctx`'s slot map as what a `<slot>` among `slotMap`'s children receives. */
|
|
30
81
|
/** @codexApi {"parent":"pithy.feature.content-projection","name":"linkOuterSlotMap","stability":"internal","signature":"(slotMap: SlotMap, ctx: Record<string, unknown>) => void"} */
|
|
31
82
|
export declare function linkOuterSlotMap(slotMap: SlotMap, ctx: Record<string, unknown>): void;
|
|
32
|
-
/** @codexApi {"parent":"pithy.feature.content-projection","name":"collectSlotMap","stability":"stable","signature":"(children: PithyNode[], parentContext: Record<string, any>, host?: Element) => SlotMap"} */
|
|
33
|
-
export declare function collectSlotMap(children: PithyNode[], parentContext: Record<string, unknown>, host?: Element): SlotMap;
|
|
83
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"collectSlotMap","stability":"stable","signature":"(children: PithyNode[], parentContext: Record<string, any>, host?: Element, owner?: object) => SlotMap"} */
|
|
84
|
+
export declare function collectSlotMap(children: PithyNode[], parentContext: Record<string, unknown>, host?: Element, owner?: object): SlotMap;
|
|
34
85
|
/** @codexApi {"parent":"pithy.feature.content-projection","name":"extractSlotDefs","stability":"stable","signature":"(fragment: DocumentFragment) => SlotDef[]"} */
|
|
35
86
|
export declare function extractSlotDefs(fragment: DocumentFragment): SlotDef[];
|
|
36
87
|
/** Whether `node` is inside content a `<slot>` projected. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentProjection.d.ts","sourceRoot":"","sources":["../../src/compile/contentProjection.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,
|
|
1
|
+
{"version":3,"file":"contentProjection.d.ts","sourceRoot":"","sources":["../../src/compile/contentProjection.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EACL,SAAS,EAKV,MAAM,mBAAmB,CAAC;AAc3B;;;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,G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