@pithyjs/core 0.1.0-beta.19 → 0.1.0-beta.20
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 +13 -1
- package/dist/compile/binds/bindAfterProjection.d.ts.map +1 -1
- package/dist/compile/binds/bindAfterProjection.js +2 -0
- package/dist/compile/binds/bindAfterProjection.js.map +1 -1
- package/dist/compile/binds/bindClassDirectives.d.ts.map +1 -1
- package/dist/compile/binds/bindClassDirectives.js +2 -1
- package/dist/compile/binds/bindClassDirectives.js.map +1 -1
- package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
- package/dist/compile/binds/bindComponentsTags.js +36 -21
- package/dist/compile/binds/bindComponentsTags.js.map +1 -1
- package/dist/compile/binds/bindErrorBoundary.d.ts +31 -0
- package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
- package/dist/compile/binds/bindErrorBoundary.js +110 -13
- package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
- package/dist/compile/binds/bindTextInterpolations.d.ts.map +1 -1
- package/dist/compile/binds/bindTextInterpolations.js +7 -5
- package/dist/compile/binds/bindTextInterpolations.js.map +1 -1
- package/dist/compile/compileNodes.d.ts.map +1 -1
- package/dist/compile/compileNodes.js +8 -4
- package/dist/compile/compileNodes.js.map +1 -1
- package/dist/compile/compileTemplate.d.ts.map +1 -1
- package/dist/compile/compileTemplate.js +12 -8
- package/dist/compile/compileTemplate.js.map +1 -1
- package/dist/compile/contentProjection.d.ts +2 -2
- package/dist/compile/contentProjection.d.ts.map +1 -1
- package/dist/compile/contentProjection.js +22 -8
- package/dist/compile/contentProjection.js.map +1 -1
- package/dist/compile/evalDiagnostics.d.ts +7 -0
- package/dist/compile/evalDiagnostics.d.ts.map +1 -0
- package/dist/compile/evalDiagnostics.js +8 -0
- package/dist/compile/evalDiagnostics.js.map +1 -0
- package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -1
- package/dist/compile/forLoops/createLoopManager.js +5 -0
- package/dist/compile/forLoops/createLoopManager.js.map +1 -1
- package/dist/compile/nodeExpando.d.ts +2 -0
- package/dist/compile/nodeExpando.d.ts.map +1 -1
- package/dist/compile/nodeExpando.js.map +1 -1
- package/dist/compile/renderBranch.d.ts.map +1 -1
- package/dist/compile/renderBranch.js +7 -2
- package/dist/compile/renderBranch.js.map +1 -1
- package/dist/compile/ssrCrashes.d.ts +64 -36
- package/dist/compile/ssrCrashes.d.ts.map +1 -1
- package/dist/compile/ssrCrashes.js +342 -37
- package/dist/compile/ssrCrashes.js.map +1 -1
- package/dist/runtime/applyBindings.d.ts.map +1 -1
- package/dist/runtime/applyBindings.js +13 -3
- package/dist/runtime/applyBindings.js.map +1 -1
- package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
- package/dist/runtime/bindings/applyComponent.js +19 -17
- package/dist/runtime/bindings/applyComponent.js.map +1 -1
- package/dist/runtime/bindings/applySimple.d.ts +7 -0
- package/dist/runtime/bindings/applySimple.d.ts.map +1 -1
- package/dist/runtime/bindings/applySimple.js +22 -10
- package/dist/runtime/bindings/applySimple.js.map +1 -1
- package/dist/runtime/bindings/applyStructural.d.ts.map +1 -1
- package/dist/runtime/bindings/applyStructural.js +115 -105
- package/dist/runtime/bindings/applyStructural.js.map +1 -1
- package/dist/runtime/bindings/index.d.ts +1 -1
- package/dist/runtime/bindings/index.d.ts.map +1 -1
- package/dist/runtime/bindings/index.js +1 -1
- package/dist/runtime/bindings/index.js.map +1 -1
- package/dist/types/globals.d.ts +6 -0
- package/dist/types/globals.d.ts.map +1 -1
- package/dist/types/globals.js.map +1 -1
- package/package.json +2 -2
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
"category": "feature"
|
|
6
6
|
}
|
|
7
7
|
*/
|
|
8
|
+
import { pithyGlobals } from '../../types/globals.js';
|
|
8
9
|
import { declaredValue } from './declaredDirective.js';
|
|
9
10
|
import { effect, untrack } from '@pithyjs/signals';
|
|
10
11
|
import { setStyleProp } from './bindBoundAttributes.js';
|
|
12
|
+
import { nodeExpando } from '../nodeExpando.js';
|
|
11
13
|
const boundElements = new WeakSet();
|
|
12
14
|
/**
|
|
13
15
|
* Global registry of active error boundaries
|
|
@@ -18,6 +20,7 @@ const activeBoundaries = [];
|
|
|
18
20
|
*/
|
|
19
21
|
let currentBoundaryContext = null;
|
|
20
22
|
let slotFrame = null;
|
|
23
|
+
let openBranches = 0;
|
|
21
24
|
/**
|
|
22
25
|
* Flag to ensure timer patching happens only once
|
|
23
26
|
*/
|
|
@@ -30,11 +33,18 @@ let timersPatched = false;
|
|
|
30
33
|
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"boundaryForElement","stability":"stable","signature":"(el: Element | null) => BoundaryInfo | null"} */
|
|
31
34
|
export function boundaryForElement(el) {
|
|
32
35
|
const boundaryEl = el?.closest('[data-error]');
|
|
36
|
+
// A crash in a branch built inside the slot is attributed (`deferCrash`), so
|
|
37
|
+
// the boundary does not hide the slot before its components are bound.
|
|
33
38
|
if (!boundaryEl)
|
|
34
|
-
return slotFrame?.
|
|
39
|
+
return openBranches === slotFrame?.branches ? slotFrameBoundary() : null;
|
|
35
40
|
// Find the registered boundary info
|
|
36
41
|
return (activeBoundaries.find(boundary => boundary.element === boundaryEl) || null);
|
|
37
42
|
}
|
|
43
|
+
function slotFrameBoundary() {
|
|
44
|
+
return slotFrame && boundaryContext() === slotFrame.context
|
|
45
|
+
? slotFrame.boundary
|
|
46
|
+
: null;
|
|
47
|
+
}
|
|
38
48
|
function liveSlotParent(boundary) {
|
|
39
49
|
const parent = boundary.slotParent;
|
|
40
50
|
return parent && activeBoundaries.includes(parent) ? parent : null;
|
|
@@ -48,38 +58,116 @@ function liveSlotParent(boundary) {
|
|
|
48
58
|
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"withSlotBoundary","stability":"experimental","signature":"<T>(anchor: Node | undefined, host: Element | undefined, fn: () => T) => T"} */
|
|
49
59
|
export function withSlotBoundary(anchor, host, fn) {
|
|
50
60
|
const outer = slotFrame;
|
|
61
|
+
const outerContext = boundaryContext();
|
|
51
62
|
const at = anchor ?? host;
|
|
52
63
|
if (at) {
|
|
53
64
|
// An anchor an earlier crash hid has no parent to resolve from.
|
|
54
65
|
const hider = hiderOf(at);
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
66
|
+
const own = hider ?? registeredClosest(anchor?.parentElement);
|
|
67
|
+
if (own)
|
|
68
|
+
setContext(own.element);
|
|
69
|
+
const boundary = own ?? outer?.boundary ?? currentBoundaryContext;
|
|
59
70
|
slotFrame =
|
|
60
71
|
boundary === outer?.boundary
|
|
61
|
-
? {
|
|
72
|
+
? {
|
|
73
|
+
...outer,
|
|
74
|
+
anchor: at,
|
|
75
|
+
host,
|
|
76
|
+
outer,
|
|
77
|
+
own: false,
|
|
78
|
+
direct: false,
|
|
79
|
+
context: boundaryContext(),
|
|
80
|
+
}
|
|
62
81
|
: {
|
|
63
82
|
boundary,
|
|
64
83
|
anchor: at,
|
|
65
84
|
host,
|
|
66
85
|
outer,
|
|
67
86
|
own: true,
|
|
87
|
+
context: boundaryContext(),
|
|
88
|
+
branches: openBranches,
|
|
68
89
|
direct: hider
|
|
69
90
|
? hider.contentPlaceholders.has(at)
|
|
70
91
|
: (anchor ?? host)?.parentElement === boundary?.element,
|
|
71
92
|
isContent: !!hider || !boundary?.fallbackElement?.contains(at),
|
|
72
93
|
};
|
|
73
94
|
}
|
|
95
|
+
const owner = slotFrame?.boundary?.element ?? boundaryContext();
|
|
74
96
|
try {
|
|
75
|
-
|
|
97
|
+
const output = fn();
|
|
98
|
+
if (owner)
|
|
99
|
+
markSlotOutput(output, owner);
|
|
100
|
+
return output;
|
|
76
101
|
}
|
|
77
102
|
finally {
|
|
78
103
|
slotFrame = outer;
|
|
104
|
+
setContext(outerContext);
|
|
79
105
|
}
|
|
80
106
|
}
|
|
107
|
+
function markSlotOutput(output, owner) {
|
|
108
|
+
var _a;
|
|
109
|
+
const el = output instanceof Node ? output : output?.el;
|
|
110
|
+
if (!(el instanceof Node))
|
|
111
|
+
return;
|
|
112
|
+
const nodes = el.nodeType === Node.DOCUMENT_FRAGMENT_NODE
|
|
113
|
+
? Array.from(el.childNodes)
|
|
114
|
+
: [el];
|
|
115
|
+
for (const node of nodes)
|
|
116
|
+
(_a = nodeExpando(node)).__pithySlotOwner ?? (_a.__pithySlotOwner = owner);
|
|
117
|
+
}
|
|
118
|
+
/** The boundary element of the slot that rendered `node`, if a slot did. */
|
|
119
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"slotOwnerOf","stability":"internal","signature":"(node: Node) => Element | null"} */
|
|
120
|
+
export function slotOwnerOf(node) {
|
|
121
|
+
for (let at = node; at; at = at.parentNode) {
|
|
122
|
+
const owner = nodeExpando(at).__pithySlotOwner;
|
|
123
|
+
if (owner)
|
|
124
|
+
return owner;
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* The boundary element that what is being rendered will sit under. A branch,
|
|
130
|
+
* slot or component built detached cannot `closest()` it, so each sets this
|
|
131
|
+
* while it runs; a crash takes the innermost one (`deferCrash`).
|
|
132
|
+
*/
|
|
133
|
+
// On `globalThis` with the attributed crashes, so a component another copy of
|
|
134
|
+
// core binds inside this copy's branch is attributed to the same boundary.
|
|
135
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"boundaryContext","stability":"internal","signature":"() => Element | null"} */
|
|
136
|
+
export function boundaryContext() {
|
|
137
|
+
return pithyGlobals().__pithyBoundaryContext ?? null;
|
|
138
|
+
}
|
|
139
|
+
function setContext(element) {
|
|
140
|
+
pithyGlobals().__pithyBoundaryContext = element;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Builds an `@if`/`@case` branch or `@for` item that will be inserted beside
|
|
144
|
+
* `anchor`, or inside it when `inside`. A detached landing place (a component's
|
|
145
|
+
* own template) keeps the enclosing context; an attached one with no boundary
|
|
146
|
+
* has none.
|
|
147
|
+
*/
|
|
148
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"withBranchBoundary","stability":"internal","signature":"<T>(anchor: Node, fn: () => T, inside?: boolean) => T"} */
|
|
149
|
+
export function withBranchBoundary(anchor, fn, inside = false) {
|
|
150
|
+
const into = inside ? anchor : anchor.parentNode;
|
|
151
|
+
const outer = boundaryContext();
|
|
152
|
+
const at = into?.nodeType === Node.ELEMENT_NODE ? into : null;
|
|
153
|
+
setContext(at?.closest('[data-error]') ?? (into?.isConnected ? null : outer));
|
|
154
|
+
openBranches++;
|
|
155
|
+
try {
|
|
156
|
+
return fn();
|
|
157
|
+
}
|
|
158
|
+
finally {
|
|
159
|
+
openBranches--;
|
|
160
|
+
setContext(outer);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/** Whether a boundary has hidden the detached subtree `node` belongs to. */
|
|
164
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"isInHiddenContent","stability":"internal","signature":"(node: Node) => boolean"} */
|
|
165
|
+
export function isInHiddenContent(node) {
|
|
166
|
+
return !!hiderOf(node);
|
|
167
|
+
}
|
|
81
168
|
/** The registered boundary of `el`'s nearest `[data-error]`, ignoring slot frames. */
|
|
82
|
-
|
|
169
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"registeredClosest","stability":"internal","signature":"(el: Element | null | undefined) => BoundaryInfo | null"} */
|
|
170
|
+
export function registeredClosest(el) {
|
|
83
171
|
const boundaryEl = el?.closest('[data-error]');
|
|
84
172
|
return ((boundaryEl && activeBoundaries.find(b => b.element === boundaryEl)) || null);
|
|
85
173
|
}
|
|
@@ -188,7 +276,8 @@ export function replaceHidden(node, content) {
|
|
|
188
276
|
* @param childBoundary - The child boundary to find parent for
|
|
189
277
|
* @returns Parent BoundaryInfo if found, null otherwise
|
|
190
278
|
*/
|
|
191
|
-
|
|
279
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"findParentBoundary","stability":"internal","signature":"(childBoundary: BoundaryInfo) => BoundaryInfo | null"} */
|
|
280
|
+
export function findParentBoundary(childBoundary) {
|
|
192
281
|
// Start searching from the child boundary's parent element
|
|
193
282
|
const parentEl = childBoundary.element.parentElement;
|
|
194
283
|
if (!parentEl)
|
|
@@ -260,13 +349,20 @@ export function currentBoundary() {
|
|
|
260
349
|
*/
|
|
261
350
|
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"runWithBoundary","stability":"stable","signature":"<T>(boundary: BoundaryInfo | null, fn: () => T) => T"} */
|
|
262
351
|
export function runWithBoundary(boundary, fn) {
|
|
352
|
+
return runUnder(boundary, fn, true);
|
|
353
|
+
}
|
|
354
|
+
function runUnder(boundary, fn, attribute) {
|
|
263
355
|
const previousContext = currentBoundaryContext;
|
|
356
|
+
const previous = boundaryContext();
|
|
264
357
|
currentBoundaryContext = boundary;
|
|
358
|
+
if (boundary && attribute)
|
|
359
|
+
setContext(boundary.element);
|
|
265
360
|
try {
|
|
266
361
|
return fn();
|
|
267
362
|
}
|
|
268
363
|
finally {
|
|
269
364
|
currentBoundaryContext = previousContext;
|
|
365
|
+
setContext(previous);
|
|
270
366
|
}
|
|
271
367
|
}
|
|
272
368
|
function patchTimersOnce() {
|
|
@@ -283,7 +379,8 @@ function patchTimersOnce() {
|
|
|
283
379
|
const capturedBoundary = currentBoundaryContext;
|
|
284
380
|
const fn = callback;
|
|
285
381
|
const wrappedCallback = (...callbackArgs) => {
|
|
286
|
-
|
|
382
|
+
// `false`: a detached render in a timer is not part of the render that scheduled it.
|
|
383
|
+
return runUnder(capturedBoundary, () => {
|
|
287
384
|
try {
|
|
288
385
|
return fn(...callbackArgs);
|
|
289
386
|
}
|
|
@@ -296,7 +393,7 @@ function patchTimersOnce() {
|
|
|
296
393
|
throw error;
|
|
297
394
|
}
|
|
298
395
|
}
|
|
299
|
-
});
|
|
396
|
+
}, false);
|
|
300
397
|
};
|
|
301
398
|
return originalSetTimeout(wrappedCallback, delay, ...args);
|
|
302
399
|
});
|
|
@@ -310,7 +407,7 @@ function patchTimersOnce() {
|
|
|
310
407
|
const capturedBoundary = currentBoundaryContext;
|
|
311
408
|
const fn = callback;
|
|
312
409
|
const wrappedCallback = (...callbackArgs) => {
|
|
313
|
-
return
|
|
410
|
+
return runUnder(capturedBoundary, () => {
|
|
314
411
|
try {
|
|
315
412
|
return fn(...callbackArgs);
|
|
316
413
|
}
|
|
@@ -323,7 +420,7 @@ function patchTimersOnce() {
|
|
|
323
420
|
throw error;
|
|
324
421
|
}
|
|
325
422
|
}
|
|
326
|
-
});
|
|
423
|
+
}, false);
|
|
327
424
|
};
|
|
328
425
|
return originalSetInterval(wrappedCallback, delay, ...args);
|
|
329
426
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindErrorBoundary.js","sourceRoot":"","sources":["../../../src/compile/binds/bindErrorBoundary.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,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;AAErD,MAAM,aAAa,GAAG,IAAI,OAAO,EAAW,CAAC;AAe7C;;GAEG;AACH,MAAM,gBAAgB,GAAmB,EAAE,CAAC;AAE5C;;GAEG;AACH,IAAI,sBAAsB,GAAwB,IAAI,CAAC;AAiBvD,IAAI,SAAS,GAAqB,IAAI,CAAC;AAEvC;;GAEG;AACH,IAAI,aAAa,GAAG,KAAK,CAAC;AAE1B;;;;GAIG;AACH,qKAAqK;AACrK,MAAM,UAAU,kBAAkB,CAAC,EAAkB;IACnD,MAAM,UAAU,GAAG,EAAE,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IAC/C,IAAI,CAAC,UAAU;QAAE,OAAO,SAAS,EAAE,QAAQ,IAAI,IAAI,CAAC;IAEpD,oCAAoC;IACpC,OAAO,CACL,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,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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 { declaredValue } from './declaredDirective';\nimport { effect, Signal, untrack } from '@pithyjs/signals';\nimport { setStyleProp } from './bindBoundAttributes';\n\nconst boundElements = new WeakSet<Element>();\n\n/**\n * Represents an active error boundary in the DOM\n */\nexport interface BoundaryInfo {\n element: Element;\n errorSignal: Signal<Error | null>;\n fallbackElement: Element | null;\n contentPlaceholders: Map<Node, Comment>;\n isActive: boolean;\n /** The receiving boundary of the slot this one was rendered in, detached. */\n slotParent?: BoundaryInfo | null;\n}\n\n/**\n * Global registry of active error boundaries\n */\nconst activeBoundaries: BoundaryInfo[] = [];\n\n/**\n * Current boundary context for async error routing (used in later phases)\n */\nlet currentBoundaryContext: BoundaryInfo | null = null;\n\n/** A slot being rendered, detached, so its content cannot `closest()` its boundary. */\ninterface SlotFrame {\n boundary: BoundaryInfo | null;\n anchor: Node;\n /** The component placeholder whose render mounts this slot. */\n host: Element | undefined;\n /** The slot rendering `host`. */\n outer: SlotFrame | null;\n /** Whether `boundary` was resolved here rather than inherited from `outer`. */\n own: boolean;\n /** Whether the slot's nodes land directly in `boundary.element`, when `own`. */\n direct: boolean;\n /** Whether the slot is the boundary's normal content, which its fallback replaces. */\n isContent: boolean;\n}\nlet slotFrame: SlotFrame | null = null;\n\n/**\n * Flag to ensure timer patching happens only once\n */\nlet timersPatched = false;\n\n/**\n * Finds the BoundaryInfo for a given DOM element by traversing up the tree\n * @param el - Element to find boundary for\n * @returns BoundaryInfo if found, null otherwise\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"boundaryForElement\",\"stability\":\"stable\",\"signature\":\"(el: Element | null) => BoundaryInfo | null\"} */\nexport function boundaryForElement(el: Element | null): BoundaryInfo | null {\n const boundaryEl = el?.closest('[data-error]');\n if (!boundaryEl) return slotFrame?.boundary ?? null;\n\n // Find the registered boundary info\n return (\n activeBoundaries.find(boundary => boundary.element === boundaryEl) || null\n );\n}\n\nfunction liveSlotParent(boundary: BoundaryInfo): BoundaryInfo | null {\n const parent = boundary.slotParent;\n return parent && activeBoundaries.includes(parent) ? parent : null;\n}\n\n/**\n * Renders a slot whose receiving `<slot>` sits at `anchor`, mounted by the\n * component placeholder `host`. Its content is detached while it renders, so\n * boundaries are resolved through the anchor, 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 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 boundary =\n hider ??\n registeredClosest(anchor?.parentElement) ??\n outer?.boundary ??\n currentBoundaryContext;\n slotFrame =\n boundary === outer?.boundary\n ? { ...outer, anchor: at, host, outer, own: false, direct: false }\n : {\n boundary,\n anchor: at,\n host,\n outer,\n own: true,\n direct: hider\n ? hider.contentPlaceholders.has(at)\n : (anchor ?? host)?.parentElement === boundary?.element,\n isContent: !!hider || !boundary?.fallbackElement?.contains(at),\n };\n }\n try {\n return fn();\n } finally {\n slotFrame = outer;\n }\n}\n\n/** The registered boundary of `el`'s nearest `[data-error]`, ignoring slot frames. */\nfunction 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 */\nfunction findParentBoundary(childBoundary: BoundaryInfo): BoundaryInfo | null {\n // Start searching from the child boundary's parent element\n const parentEl = childBoundary.element.parentElement;\n if (!parentEl) return liveSlotParent(childBoundary);\n\n // Find the closest ancestor boundary element\n const parentBoundaryEl = parentEl.closest('[data-error]');\n if (!parentBoundaryEl) return liveSlotParent(childBoundary);\n\n // Find the registered boundary info\n return (\n activeBoundaries.find(boundary => boundary.element === parentBoundaryEl) ||\n null\n );\n}\n\n/**\n * Clears the error state of a boundary, restoring normal content\n * @param boundary - The boundary to clear\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"clearBoundaryError\",\"stability\":\"stable\",\"signature\":\"(boundary: BoundaryInfo) => void\"} */\nexport function clearBoundaryError(boundary: BoundaryInfo): void {\n if (untrack(() => boundary.errorSignal()) !== null) {\n boundary.errorSignal.set(null);\n }\n}\n\n/**\n * Sets an error on a boundary with escalation logic\n * If the boundary is already in error state, escalates to parent boundary\n * Matches React behavior: first error wins, subsequent errors ignored\n *\n * @param boundary - The boundary to set error on\n * @param error - The error to set\n * @returns `true` if some boundary took ownership of `error`; `false` if it was\n * dropped because this boundary was already showing an error and no ancestor\n * boundary was free to take it.\n *\n * Callers must not assume the error was handled. A component rendering inside an\n * *active* boundary's `@fallback` hits exactly the `false` path — the fallback is\n * the part the user actually sees, so a crash there that nobody records ships a\n * visibly broken page with a green build. `bindComponentTags` and\n * `applyComponent` use the return value to decide between retracting an SSR\n * crash record and adding one.\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"setBoundaryError\",\"stability\":\"stable\",\"signature\":\"(boundary: BoundaryInfo, error: Error) => boolean\"} */\nexport function setBoundaryError(\n boundary: BoundaryInfo,\n error: Error\n): boolean {\n // Check if this boundary is already in error state\n if (untrack(() => boundary.errorSignal()) !== null) {\n // Escalate to parent boundary\n const parentBoundary = findParentBoundary(boundary);\n if (parentBoundary) {\n return setBoundaryError(parentBoundary, error);\n }\n // IGNORE subsequent errors (React behavior - first error wins).\n // Nobody owns this error now, and the caller needs to know.\n return false;\n }\n\n // Set the error on this boundary\n boundary.errorSignal.set(error);\n return true;\n}\n\n/** 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 const previousContext = currentBoundaryContext;\n currentBoundaryContext = boundary;\n try {\n return fn();\n } finally {\n currentBoundaryContext = previousContext;\n }\n}\n\nfunction patchTimersOnce(): void {\n if (timersPatched) return;\n timersPatched = true;\n\n // Patch setTimeout\n const originalSetTimeout = window.setTimeout;\n window.setTimeout = ((\n callback: TimerHandler,\n delay?: number,\n ...args: unknown[]\n ) => {\n // Don't wrap string callbacks; let the browser handle them\n if (typeof callback !== 'function') {\n return originalSetTimeout(callback, delay, ...args);\n }\n\n const capturedBoundary = currentBoundaryContext;\n const fn = callback as (...callbackArgs: unknown[]) => unknown;\n const wrappedCallback = (...callbackArgs: unknown[]) => {\n return runWithBoundary(capturedBoundary, () => {\n try {\n return fn(...callbackArgs);\n } catch (error) {\n if (capturedBoundary) {\n const err =\n error instanceof Error ? error : new Error(String(error));\n setBoundaryError(capturedBoundary, err);\n } else {\n throw error;\n }\n }\n });\n };\n return originalSetTimeout(wrappedCallback, delay, ...args);\n }) as typeof window.setTimeout;\n\n // Patch setInterval\n const originalSetInterval = window.setInterval;\n window.setInterval = ((\n callback: TimerHandler,\n delay?: number,\n ...args: unknown[]\n ) => {\n // Don't wrap string callbacks; let the browser handle them\n if (typeof callback !== 'function') {\n return originalSetInterval(callback, delay, ...args);\n }\n\n const capturedBoundary = currentBoundaryContext;\n const fn = callback as (...callbackArgs: unknown[]) => unknown;\n const wrappedCallback = (...callbackArgs: unknown[]) => {\n return runWithBoundary(capturedBoundary, () => {\n try {\n return fn(...callbackArgs);\n } catch (error) {\n if (capturedBoundary) {\n const err =\n error instanceof Error ? error : new Error(String(error));\n setBoundaryError(capturedBoundary, err);\n } else {\n throw error;\n }\n }\n });\n };\n return originalSetInterval(wrappedCallback, delay, ...args);\n }) as typeof window.setInterval;\n}\n\n/**\n * Finds the fallback element within a boundary\n * @param boundaryEl - The boundary element to search within\n * @returns The fallback element or null if not found\n */\nfunction findFallbackElement(boundaryEl: Element): Element | null {\n // Look through direct children first to avoid nested boundary fallbacks\n for (const child of Array.from(boundaryEl.children)) {\n if (child.hasAttribute('data-fallback')) {\n // Double-check that this fallback belongs to this boundary\n const fallbackBoundary = child.closest('[data-error]');\n if (fallbackBoundary === boundaryEl) {\n return child;\n }\n }\n }\n\n // If no direct child fallback found, search deeper but be more careful\n const allFallbacks = Array.from(\n boundaryEl.querySelectorAll('[data-fallback]')\n );\n for (const fallback of allFallbacks) {\n const fallbackBoundary = fallback.closest('[data-error]');\n if (fallbackBoundary === boundaryEl) {\n return fallback;\n }\n }\n\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] No fallback element found for boundary`,\n boundaryEl.tagName,\n 'Available children:',\n Array.from(boundaryEl.children).map(\n c =>\n c.tagName +\n (c.hasAttribute('data-fallback') ? '[fallback]' : '') +\n (c.hasAttribute('data-error') ? '[boundary]' : '')\n )\n );\n }\n\n return null;\n}\n\n/**\n * Gets current content nodes (excluding fallback) - recomputed each time\n * @param boundaryEl - The boundary element\n * @param fallbackEl - The fallback element to exclude\n * @returns Array of content nodes\n */\nfunction getCurrentContentNodes(\n boundaryEl: Element,\n fallbackEl: Element | null\n): Node[] {\n return Array.from(boundaryEl.childNodes).filter(n => {\n // Exclude the fallback element for this boundary\n if (n === fallbackEl) return false;\n\n // Exclude placeholder comments from other boundaries\n if (\n n.nodeType === Node.COMMENT_NODE &&\n (n as Comment).data === 'pithy-boundary-hidden'\n ) {\n return false;\n }\n\n // Don't hide nested boundary elements that are currently showing their fallback\n if (n.nodeType === Node.ELEMENT_NODE) {\n const element = n as Element;\n if (element.hasAttribute('data-error')) {\n // This is a nested boundary - check if it's currently in error state\n const nestedBoundary = activeBoundaries.find(\n b => b.element === element\n );\n if (nestedBoundary && nestedBoundary.isActive) {\n // If a nested boundary is already active, keep it visible instead of replacing with our fallback\n return false;\n }\n }\n }\n\n return true;\n });\n}\n\n/**\n * Hides content by replacing nodes with comment placeholders\n * @param boundary - The boundary info\n */\nfunction hideContent(boundary: BoundaryInfo): void {\n const { element, fallbackElement, contentPlaceholders } = boundary;\n const nodes = getCurrentContentNodes(element, fallbackElement);\n\n for (const node of nodes) {\n if (contentPlaceholders.has(node)) continue;\n const placeholder = document.createComment('pithy-boundary-hidden');\n node.parentNode?.replaceChild(placeholder, node);\n contentPlaceholders.set(node, placeholder);\n }\n\n // Always show the fallback element if it exists\n if (fallbackElement) {\n setStyleProp(fallbackElement, 'display', null);\n }\n}\n\n/**\n * Restores content by replacing comment placeholders with original nodes\n * @param boundary - The boundary info\n */\nfunction restoreContent(boundary: BoundaryInfo): void {\n const { fallbackElement, contentPlaceholders } = boundary;\n\n for (const [node, placeholder] of Array.from(contentPlaceholders.entries())) {\n placeholder.parentNode?.replaceChild(node, placeholder);\n contentPlaceholders.delete(node);\n }\n\n if (fallbackElement) {\n setStyleProp(fallbackElement, 'display', 'none');\n }\n}\n\n/**\n * Hides the fallback element\n * @param fallbackEl - The fallback element to hide\n */\nfunction hideFallback(fallbackEl: Element): void {\n setStyleProp(fallbackEl, 'display', 'none');\n}\n\n/**\n * Creates and registers an error boundary\n * @param boundaryEl - The boundary element\n * @param errorSignal - The error signal from context\n * @param disposers - Array to add cleanup functions to\n * @returns The created BoundaryInfo\n */\nfunction createBoundary(\n boundaryEl: Element,\n errorSignal: Signal<Error | null>,\n disposers: (() => void)[]\n): BoundaryInfo {\n const fallbackEl = findFallbackElement(boundaryEl);\n\n const boundary: BoundaryInfo = {\n element: boundaryEl,\n errorSignal,\n fallbackElement: fallbackEl,\n contentPlaceholders: new Map(),\n isActive: false,\n slotParent: slotFrame?.boundary ?? null,\n };\n\n // Register BEFORE effect so nested lookups can find us\n activeBoundaries.push(boundary);\n\n // Initially hide fallback\n if (fallbackEl) {\n hideFallback(fallbackEl);\n }\n\n // Set up reactive effect to toggle content/fallback based on error state\n const dispose = effect(() => {\n const error = errorSignal();\n const hasError = error !== null;\n\n if (hasError && !boundary.isActive) {\n // Show error state\n boundary.isActive = true;\n hideContent(boundary);\n } else if (!hasError && boundary.isActive) {\n // Show normal state\n boundary.isActive = false;\n restoreContent(boundary);\n }\n });\n\n // Add cleanup function\n disposers.push(() => {\n dispose();\n\n // Restore any hidden content\n if (boundary.isActive) {\n restoreContent(boundary);\n }\n\n // Remove from registry\n const index = activeBoundaries.indexOf(boundary);\n if (index >= 0) {\n activeBoundaries.splice(index, 1);\n }\n });\n\n return boundary;\n}\n\n/**\n * Register a single element as an error boundary.\n * Used by AOT applyBindings where the boundary element is known directly\n * (unlike bindErrorBoundary which scans children via querySelectorAll).\n *\n * @param boundaryEl - The element with data-error attribute\n * @param context - Reactive context containing error signals\n * @param disposers - Array to add cleanup functions to\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"registerBoundary\",\"stability\":\"stable\",\"signature\":\"(boundaryEl: Element, context: Record<string, unknown>, disposers: (() => void)[]) => void\"} */\nexport function registerBoundary(\n boundaryEl: Element,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n patchTimersOnce();\n\n const signalName = boundaryEl.getAttribute('data-error');\n if (!signalName) return;\n\n const errorSignal = context[signalName] as Signal<Error | null> | undefined;\n if (!errorSignal || typeof errorSignal !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] Signal \"${signalName}\" not found in context for boundary ${boundaryEl.tagName}`\n );\n }\n return;\n }\n\n // Validate that the signal is writable — computed signals or non-signal\n // functions will throw at runtime when setBoundaryError calls .set()\n if (typeof errorSignal.set !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] Signal \"${signalName}\" is not writable (no .set method) for boundary ${boundaryEl.tagName}`\n );\n }\n return;\n }\n\n createBoundary(boundaryEl, errorSignal, disposers);\n}\n\n/**\n * Binds error boundaries in the DOM fragment\n * Scans for [data-error] elements and sets up error boundary behavior\n *\n * @param fragment - DOM fragment to scan\n * @param context - Reactive context containing error signals\n * @param disposers - Array to add cleanup functions to\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"bindErrorBoundary\",\"stability\":\"stable\",\"signature\":\"(fragment: Element | DocumentFragment, context: Record<string, unknown>, disposers: (() => void)[]) => void\"} */\nexport function bindErrorBoundary(\n fragment: Element | DocumentFragment,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n // Patch timers on first boundary registration\n patchTimersOnce();\n\n const boundaryElements = Array.from(\n fragment.querySelectorAll('[data-error]')\n );\n\n for (const boundaryEl of boundaryElements) {\n if (boundElements.has(boundaryEl)) continue;\n const signalName = declaredValue(boundaryEl, 'data-error');\n if (!signalName) continue;\n\n const errorSignal = context[signalName] as Signal<Error | null> | undefined;\n if (!errorSignal || typeof errorSignal !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] Signal \"${signalName}\" not found in context for boundary ${boundaryEl.tagName}`\n );\n }\n continue;\n }\n\n // Validate that the signal is writable — computed signals or non-signal\n // functions will throw at runtime when setBoundaryError calls .set()\n if (typeof errorSignal.set !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] Signal \"${signalName}\" is not writable (no .set method) for boundary ${boundaryEl.tagName}`\n );\n }\n continue;\n }\n\n // Create and register the boundary (registration happens inside createBoundary)\n createBoundary(boundaryEl, errorSignal, disposers);\n boundElements.add(boundaryEl);\n disposers.push(() => boundElements.delete(boundaryEl));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bindErrorBoundary.js","sourceRoot":"","sources":["../../../src/compile/binds/bindErrorBoundary.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,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,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;GAEG;AACH,IAAI,aAAa,GAAG,KAAK,CAAC;AAE1B;;;;GAIG;AACH,qKAAqK;AACrK,MAAM,UAAU,kBAAkB,CAAC,EAAkB;IACnD,MAAM,UAAU,GAAG,EAAE,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IAC/C,6EAA6E;IAC7E,uEAAuE;IACvE,IAAI,CAAC,UAAU;QACb,OAAO,YAAY,KAAK,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAE3E,oCAAoC;IACpC,OAAO,CACL,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,KAAK,UAAU,CAAC,IAAI,IAAI,CAC3E,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB;IACxB,OAAO,SAAS,IAAI,eAAe,EAAE,KAAK,SAAS,CAAC,O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ED,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 openBranches = 0;\n\n/**\n * Flag to ensure timer patching happens only once\n */\nlet timersPatched = false;\n\n/**\n * Finds the BoundaryInfo for a given DOM element by traversing up the tree\n * @param el - Element to find boundary for\n * @returns BoundaryInfo if found, null otherwise\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"boundaryForElement\",\"stability\":\"stable\",\"signature\":\"(el: Element | null) => BoundaryInfo | null\"} */\nexport function boundaryForElement(el: Element | null): BoundaryInfo | null {\n const boundaryEl = el?.closest('[data-error]');\n // A crash in a branch built inside the slot is attributed (`deferCrash`), so\n // the boundary does not hide the slot before its components are bound.\n if (!boundaryEl)\n return openBranches === slotFrame?.branches ? slotFrameBoundary() : null;\n\n // Find the registered boundary info\n return (\n activeBoundaries.find(boundary => boundary.element === boundaryEl) || null\n );\n}\n\nfunction slotFrameBoundary(): BoundaryInfo | null {\n return slotFrame && boundaryContext() === slotFrame.context\n ? slotFrame.boundary\n : null;\n}\n\nfunction liveSlotParent(boundary: BoundaryInfo): BoundaryInfo | null {\n const parent = boundary.slotParent;\n return parent && activeBoundaries.includes(parent) ? parent : null;\n}\n\n/**\n * Renders a slot whose receiving `<slot>` sits at `anchor`, mounted by the\n * component placeholder `host`. Its content is detached while it renders, so\n * boundaries are resolved through the anchor, then the host's render. Without an\n * anchor (`renderChildren()`), the host is the frame's anchor.\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"withSlotBoundary\",\"stability\":\"experimental\",\"signature\":\"<T>(anchor: Node | undefined, host: Element | undefined, fn: () => T) => T\"} */\nexport function withSlotBoundary<T>(\n anchor: Node | undefined,\n host: Element | undefined,\n fn: () => T\n): T {\n const outer = slotFrame;\n const outerContext = boundaryContext();\n const at = anchor ?? host;\n if (at) {\n // An anchor an earlier crash hid has no parent to resolve from.\n const hider = hiderOf(at);\n const own = hider ?? registeredClosest(anchor?.parentElement);\n if (own) setContext(own.element);\n const boundary = own ?? outer?.boundary ?? currentBoundaryContext;\n slotFrame =\n boundary === outer?.boundary\n ? {\n ...outer,\n anchor: at,\n host,\n outer,\n own: false,\n direct: false,\n context: boundaryContext(),\n }\n : {\n boundary,\n anchor: at,\n host,\n outer,\n own: true,\n context: boundaryContext(),\n branches: openBranches,\n direct: hider\n ? hider.contentPlaceholders.has(at)\n : (anchor ?? host)?.parentElement === boundary?.element,\n isContent: !!hider || !boundary?.fallbackElement?.contains(at),\n };\n }\n const owner = slotFrame?.boundary?.element ?? boundaryContext();\n try {\n const output = fn();\n if (owner) markSlotOutput(output, owner);\n return output;\n } finally {\n slotFrame = outer;\n setContext(outerContext);\n }\n}\n\nfunction markSlotOutput(output: unknown, owner: Element): void {\n const el = output instanceof Node ? output : (output as { el?: unknown })?.el;\n if (!(el instanceof Node)) return;\n const nodes =\n el.nodeType === Node.DOCUMENT_FRAGMENT_NODE\n ? Array.from(el.childNodes)\n : [el];\n for (const node of nodes) nodeExpando(node).__pithySlotOwner ??= owner;\n}\n\n/** The boundary element of the slot that rendered `node`, if a slot did. */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"slotOwnerOf\",\"stability\":\"internal\",\"signature\":\"(node: Node) => Element | null\"} */\nexport function slotOwnerOf(node: Node): Element | null {\n for (let at: Node | null = node; at; at = at.parentNode) {\n const owner = nodeExpando(at).__pithySlotOwner;\n if (owner) return owner;\n }\n return null;\n}\n\n/**\n * The boundary element that what is being rendered will sit under. A branch,\n * slot or component built detached cannot `closest()` it, so each sets this\n * while it runs; a crash takes the innermost one (`deferCrash`).\n */\n// On `globalThis` with the attributed crashes, so a component another copy of\n// core binds inside this copy's branch is attributed to the same boundary.\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"boundaryContext\",\"stability\":\"internal\",\"signature\":\"() => Element | null\"} */\nexport function boundaryContext(): Element | null {\n return pithyGlobals().__pithyBoundaryContext ?? null;\n}\n\nfunction setContext(element: Element | null): void {\n pithyGlobals().__pithyBoundaryContext = element;\n}\n\n/**\n * Builds an `@if`/`@case` branch or `@for` item that will be inserted beside\n * `anchor`, or inside it when `inside`. A detached landing place (a component's\n * own template) keeps the enclosing context; an attached one with no boundary\n * has none.\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"withBranchBoundary\",\"stability\":\"internal\",\"signature\":\"<T>(anchor: Node, fn: () => T, inside?: boolean) => T\"} */\nexport function withBranchBoundary<T>(\n anchor: Node,\n fn: () => T,\n inside = false\n): T {\n const into = inside ? anchor : anchor.parentNode;\n const outer = boundaryContext();\n const at = into?.nodeType === Node.ELEMENT_NODE ? (into as Element) : null;\n setContext(at?.closest('[data-error]') ?? (into?.isConnected ? null : outer));\n openBranches++;\n try {\n return fn();\n } finally {\n openBranches--;\n setContext(outer);\n }\n}\n\n/** Whether a boundary has hidden the detached subtree `node` belongs to. */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"isInHiddenContent\",\"stability\":\"internal\",\"signature\":\"(node: Node) => boolean\"} */\nexport function isInHiddenContent(node: Node): boolean {\n return !!hiderOf(node);\n}\n\n/** The registered boundary of `el`'s nearest `[data-error]`, ignoring slot frames. */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"registeredClosest\",\"stability\":\"internal\",\"signature\":\"(el: Element | null | undefined) => BoundaryInfo | null\"} */\nexport function registeredClosest(\n el: Element | null | undefined\n): BoundaryInfo | null {\n const boundaryEl = el?.closest('[data-error]');\n return (\n (boundaryEl && activeBoundaries.find(b => b.element === boundaryEl)) || null\n );\n}\n\n/** Whether `el`, in the slot being rendered, is normal content an active fallback has replaced. */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"slotContentHidden\",\"stability\":\"experimental\",\"signature\":\"(el: Element) => boolean\"} */\nexport function slotContentHidden(el: Element): boolean {\n // Every boundary the slot frames pass through can hide it, not just the nearest.\n const inner = slotFrame;\n let up = 0;\n for (let frame = inner; frame; up++) {\n if (frame.isContent && frame.boundary?.isActive) {\n // As `hideContent`: an active nested boundary stays visible beside the fallback.\n const child = receiverChild(el, inner as SlotFrame, up);\n if (!activeBoundaries.some(b => b.element === child && b.isActive))\n return true;\n }\n while (!frame.own && frame.outer) frame = frame.outer;\n frame = frame.outer;\n }\n return false;\n}\n\n/**\n * The direct child of a boundary element that will hold `node`: the boundary\n * of `frame` when `up` is 0, else that many boundary changes further out.\n */\nfunction receiverChild(node: Node, frame: SlotFrame, up: number): Node | null {\n const top = rootOf(node);\n if (frame.own && up === 0) return frame.direct ? top : null;\n if (!frame.host || !frame.outer) return null;\n const hostChild = receiverChild(\n frame.host,\n frame.outer,\n frame.own ? up - 1 : up\n );\n if (hostChild !== frame.host) return hostChild;\n // The host's output replaces it; a bare slot puts this content in its place.\n // Anchorless (`renderChildren()`), the host is the anchor: whether it wraps its\n // children is unknown while they render, so they count as unwrapped.\n // A boundary may have hidden the anchor since: its stand-in holds the place.\n const at = standInOf(frame.anchor) ?? frame.anchor;\n const anchorTop = rootOf(at);\n return anchorTop === at ? top : anchorTop;\n}\n\nfunction standInOf(node: Node): Comment | undefined {\n for (const boundary of activeBoundaries) {\n const standIn = boundary.contentPlaceholders.get(node);\n if (standIn) return standIn;\n }\n return undefined;\n}\n\nfunction rootOf(node: Node): Node {\n let top = node;\n while (\n top.parentNode &&\n top.parentNode.nodeType !== Node.DOCUMENT_FRAGMENT_NODE\n )\n top = top.parentNode;\n return top;\n}\n\nfunction hiderOf(node: Node): BoundaryInfo | undefined {\n let top = node;\n while (top.parentNode) top = top.parentNode;\n return activeBoundaries.find(b => b.contentPlaceholders.has(top));\n}\n\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"isHiddenByBoundary\",\"stability\":\"experimental\",\"signature\":\"(node: Node) => boolean\"} */\nexport function isHiddenByBoundary(node: Node): boolean {\n return activeBoundaries.some(\n b => !!b.contentPlaceholders.get(node)?.parentNode\n );\n}\n\n/**\n * Inserts `content` after `anchor` when an active boundary has hidden the\n * anchor, which a crash during a slot's render can do, and hides it too.\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"insertBesideHidden\",\"stability\":\"experimental\",\"signature\":\"(anchor: Node, content: Node) => boolean\"} */\nexport function insertBesideHidden(anchor: Node, content: Node): boolean {\n for (const boundary of activeBoundaries) {\n const standIn = boundary.contentPlaceholders.get(anchor);\n if (!standIn?.parentNode) continue;\n standIn.parentNode.insertBefore(content, standIn.nextSibling);\n if (boundary.isActive) hideContent(boundary);\n return true;\n }\n return false;\n}\n\n/**\n * Puts `content` in the place of `node` when an active boundary has hidden it,\n * which a crash during `node`'s own render can do, and hides it there instead.\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"replaceHidden\",\"stability\":\"experimental\",\"signature\":\"(node: Node, content: Node[]) => boolean\"} */\nexport function replaceHidden(node: Node, content: Node[]): boolean {\n for (const boundary of activeBoundaries) {\n const standIn = boundary.contentPlaceholders.get(node);\n if (!standIn?.parentNode) continue;\n boundary.contentPlaceholders.delete(node);\n standIn.replaceWith(...content);\n if (boundary.isActive) hideContent(boundary);\n return true;\n }\n return false;\n}\n\n/**\n * Finds the parent boundary for a given boundary (for error escalation)\n * @param childBoundary - The child boundary to find parent for\n * @returns Parent BoundaryInfo if found, null otherwise\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"findParentBoundary\",\"stability\":\"internal\",\"signature\":\"(childBoundary: BoundaryInfo) => BoundaryInfo | null\"} */\nexport function findParentBoundary(\n childBoundary: BoundaryInfo\n): BoundaryInfo | null {\n // Start searching from the child boundary's parent element\n const parentEl = childBoundary.element.parentElement;\n if (!parentEl) return liveSlotParent(childBoundary);\n\n // Find the closest ancestor boundary element\n const parentBoundaryEl = parentEl.closest('[data-error]');\n if (!parentBoundaryEl) return liveSlotParent(childBoundary);\n\n // Find the registered boundary info\n return (\n activeBoundaries.find(boundary => boundary.element === parentBoundaryEl) ||\n null\n );\n}\n\n/**\n * Clears the error state of a boundary, restoring normal content\n * @param boundary - The boundary to clear\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"clearBoundaryError\",\"stability\":\"stable\",\"signature\":\"(boundary: BoundaryInfo) => void\"} */\nexport function clearBoundaryError(boundary: BoundaryInfo): void {\n if (untrack(() => boundary.errorSignal()) !== null) {\n boundary.errorSignal.set(null);\n }\n}\n\n/**\n * Sets an error on a boundary with escalation logic\n * If the boundary is already in error state, escalates to parent boundary\n * Matches React behavior: first error wins, subsequent errors ignored\n *\n * @param boundary - The boundary to set error on\n * @param error - The error to set\n * @returns `true` if some boundary took ownership of `error`; `false` if it was\n * dropped because this boundary was already showing an error and no ancestor\n * boundary was free to take it.\n *\n * Callers must not assume the error was handled. A component rendering inside an\n * *active* boundary's `@fallback` hits exactly the `false` path — the fallback is\n * the part the user actually sees, so a crash there that nobody records ships a\n * visibly broken page with a green build. `bindComponentTags` and\n * `applyComponent` use the return value to decide between retracting an SSR\n * crash record and adding one.\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"setBoundaryError\",\"stability\":\"stable\",\"signature\":\"(boundary: BoundaryInfo, error: Error) => boolean\"} */\nexport function setBoundaryError(\n boundary: BoundaryInfo,\n error: Error\n): boolean {\n // Check if this boundary is already in error state\n if (untrack(() => boundary.errorSignal()) !== null) {\n // Escalate to parent boundary\n const parentBoundary = findParentBoundary(boundary);\n if (parentBoundary) {\n return setBoundaryError(parentBoundary, error);\n }\n // IGNORE subsequent errors (React behavior - first error wins).\n // Nobody owns this error now, and the caller needs to know.\n return false;\n }\n\n // Set the error on this boundary\n boundary.errorSignal.set(error);\n return true;\n}\n\n/** The boundary the component being rendered sits under. */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"currentBoundary\",\"stability\":\"experimental\",\"signature\":\"() => BoundaryInfo | null\"} */\nexport function currentBoundary(): BoundaryInfo | null {\n return currentBoundaryContext;\n}\n\n/**\n * Runs a function within the context of a specific boundary\n * Used for scoping async operations to the correct boundary\n * @param boundary - Boundary to run within\n * @param fn - Function to execute\n * @returns Result of function execution\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"runWithBoundary\",\"stability\":\"stable\",\"signature\":\"<T>(boundary: BoundaryInfo | null, fn: () => T) => T\"} */\nexport function runWithBoundary<T>(\n boundary: BoundaryInfo | null,\n fn: () => T\n): T {\n return runUnder(boundary, fn, true);\n}\n\nfunction runUnder<T>(\n boundary: BoundaryInfo | null,\n fn: () => T,\n attribute: boolean\n): T {\n const previousContext = currentBoundaryContext;\n const previous = boundaryContext();\n currentBoundaryContext = boundary;\n if (boundary && attribute) setContext(boundary.element);\n try {\n return fn();\n } finally {\n currentBoundaryContext = previousContext;\n setContext(previous);\n }\n}\n\nfunction patchTimersOnce(): void {\n if (timersPatched) return;\n timersPatched = true;\n\n // Patch setTimeout\n const originalSetTimeout = window.setTimeout;\n window.setTimeout = ((\n callback: TimerHandler,\n delay?: number,\n ...args: unknown[]\n ) => {\n // Don't wrap string callbacks; let the browser handle them\n if (typeof callback !== 'function') {\n return originalSetTimeout(callback, delay, ...args);\n }\n\n const capturedBoundary = currentBoundaryContext;\n const fn = callback as (...callbackArgs: unknown[]) => unknown;\n const wrappedCallback = (...callbackArgs: unknown[]) => {\n // `false`: a detached render in a timer is not part of the render that scheduled it.\n return runUnder(\n capturedBoundary,\n () => {\n try {\n return fn(...callbackArgs);\n } catch (error) {\n if (capturedBoundary) {\n const err =\n error instanceof Error ? error : new Error(String(error));\n setBoundaryError(capturedBoundary, err);\n } else {\n throw error;\n }\n }\n },\n false\n );\n };\n return originalSetTimeout(wrappedCallback, delay, ...args);\n }) as typeof window.setTimeout;\n\n // Patch setInterval\n const originalSetInterval = window.setInterval;\n window.setInterval = ((\n callback: TimerHandler,\n delay?: number,\n ...args: unknown[]\n ) => {\n // Don't wrap string callbacks; let the browser handle them\n if (typeof callback !== 'function') {\n return originalSetInterval(callback, delay, ...args);\n }\n\n const capturedBoundary = currentBoundaryContext;\n const fn = callback as (...callbackArgs: unknown[]) => unknown;\n const wrappedCallback = (...callbackArgs: unknown[]) => {\n return runUnder(\n capturedBoundary,\n () => {\n try {\n return fn(...callbackArgs);\n } catch (error) {\n if (capturedBoundary) {\n const err =\n error instanceof Error ? error : new Error(String(error));\n setBoundaryError(capturedBoundary, err);\n } else {\n throw error;\n }\n }\n },\n false\n );\n };\n return originalSetInterval(wrappedCallback, delay, ...args);\n }) as typeof window.setInterval;\n}\n\n/**\n * Finds the fallback element within a boundary\n * @param boundaryEl - The boundary element to search within\n * @returns The fallback element or null if not found\n */\nfunction findFallbackElement(boundaryEl: Element): Element | null {\n // Look through direct children first to avoid nested boundary fallbacks\n for (const child of Array.from(boundaryEl.children)) {\n if (child.hasAttribute('data-fallback')) {\n // Double-check that this fallback belongs to this boundary\n const fallbackBoundary = child.closest('[data-error]');\n if (fallbackBoundary === boundaryEl) {\n return child;\n }\n }\n }\n\n // If no direct child fallback found, search deeper but be more careful\n const allFallbacks = Array.from(\n boundaryEl.querySelectorAll('[data-fallback]')\n );\n for (const fallback of allFallbacks) {\n const fallbackBoundary = fallback.closest('[data-error]');\n if (fallbackBoundary === boundaryEl) {\n return fallback;\n }\n }\n\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] No fallback element found for boundary`,\n boundaryEl.tagName,\n 'Available children:',\n Array.from(boundaryEl.children).map(\n c =>\n c.tagName +\n (c.hasAttribute('data-fallback') ? '[fallback]' : '') +\n (c.hasAttribute('data-error') ? '[boundary]' : '')\n )\n );\n }\n\n return null;\n}\n\n/**\n * Gets current content nodes (excluding fallback) - recomputed each time\n * @param boundaryEl - The boundary element\n * @param fallbackEl - The fallback element to exclude\n * @returns Array of content nodes\n */\nfunction getCurrentContentNodes(\n boundaryEl: Element,\n fallbackEl: Element | null\n): Node[] {\n return Array.from(boundaryEl.childNodes).filter(n => {\n // Exclude the fallback element for this boundary\n if (n === fallbackEl) return false;\n\n // Exclude placeholder comments from other boundaries\n if (\n n.nodeType === Node.COMMENT_NODE &&\n (n as Comment).data === 'pithy-boundary-hidden'\n ) {\n return false;\n }\n\n // Don't hide nested boundary elements that are currently showing their fallback\n if (n.nodeType === Node.ELEMENT_NODE) {\n const element = n as Element;\n if (element.hasAttribute('data-error')) {\n // This is a nested boundary - check if it's currently in error state\n const nestedBoundary = activeBoundaries.find(\n b => b.element === element\n );\n if (nestedBoundary && nestedBoundary.isActive) {\n // If a nested boundary is already active, keep it visible instead of replacing with our fallback\n return false;\n }\n }\n }\n\n return true;\n });\n}\n\n/**\n * Hides content by replacing nodes with comment placeholders\n * @param boundary - The boundary info\n */\nfunction hideContent(boundary: BoundaryInfo): void {\n const { element, fallbackElement, contentPlaceholders } = boundary;\n const nodes = getCurrentContentNodes(element, fallbackElement);\n\n for (const node of nodes) {\n if (contentPlaceholders.has(node)) continue;\n const placeholder = document.createComment('pithy-boundary-hidden');\n node.parentNode?.replaceChild(placeholder, node);\n contentPlaceholders.set(node, placeholder);\n }\n\n // Always show the fallback element if it exists\n if (fallbackElement) {\n setStyleProp(fallbackElement, 'display', null);\n }\n}\n\n/**\n * Restores content by replacing comment placeholders with original nodes\n * @param boundary - The boundary info\n */\nfunction restoreContent(boundary: BoundaryInfo): void {\n const { fallbackElement, contentPlaceholders } = boundary;\n\n for (const [node, placeholder] of Array.from(contentPlaceholders.entries())) {\n placeholder.parentNode?.replaceChild(node, placeholder);\n contentPlaceholders.delete(node);\n }\n\n if (fallbackElement) {\n setStyleProp(fallbackElement, 'display', 'none');\n }\n}\n\n/**\n * Hides the fallback element\n * @param fallbackEl - The fallback element to hide\n */\nfunction hideFallback(fallbackEl: Element): void {\n setStyleProp(fallbackEl, 'display', 'none');\n}\n\n/**\n * Creates and registers an error boundary\n * @param boundaryEl - The boundary element\n * @param errorSignal - The error signal from context\n * @param disposers - Array to add cleanup functions to\n * @returns The created BoundaryInfo\n */\nfunction createBoundary(\n boundaryEl: Element,\n errorSignal: Signal<Error | null>,\n disposers: (() => void)[]\n): BoundaryInfo {\n const fallbackEl = findFallbackElement(boundaryEl);\n\n const boundary: BoundaryInfo = {\n element: boundaryEl,\n errorSignal,\n fallbackElement: fallbackEl,\n contentPlaceholders: new Map(),\n isActive: false,\n slotParent: slotFrame?.boundary ?? null,\n };\n\n // Register BEFORE effect so nested lookups can find us\n activeBoundaries.push(boundary);\n\n // Initially hide fallback\n if (fallbackEl) {\n hideFallback(fallbackEl);\n }\n\n // Set up reactive effect to toggle content/fallback based on error state\n const dispose = effect(() => {\n const error = errorSignal();\n const hasError = error !== null;\n\n if (hasError && !boundary.isActive) {\n // Show error state\n boundary.isActive = true;\n hideContent(boundary);\n } else if (!hasError && boundary.isActive) {\n // Show normal state\n boundary.isActive = false;\n restoreContent(boundary);\n }\n });\n\n // Add cleanup function\n disposers.push(() => {\n dispose();\n\n // Restore any hidden content\n if (boundary.isActive) {\n restoreContent(boundary);\n }\n\n // Remove from registry\n const index = activeBoundaries.indexOf(boundary);\n if (index >= 0) {\n activeBoundaries.splice(index, 1);\n }\n });\n\n return boundary;\n}\n\n/**\n * Register a single element as an error boundary.\n * Used by AOT applyBindings where the boundary element is known directly\n * (unlike bindErrorBoundary which scans children via querySelectorAll).\n *\n * @param boundaryEl - The element with data-error attribute\n * @param context - Reactive context containing error signals\n * @param disposers - Array to add cleanup functions to\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"registerBoundary\",\"stability\":\"stable\",\"signature\":\"(boundaryEl: Element, context: Record<string, unknown>, disposers: (() => void)[]) => void\"} */\nexport function registerBoundary(\n boundaryEl: Element,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n patchTimersOnce();\n\n const signalName = boundaryEl.getAttribute('data-error');\n if (!signalName) return;\n\n const errorSignal = context[signalName] as Signal<Error | null> | undefined;\n if (!errorSignal || typeof errorSignal !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] Signal \"${signalName}\" not found in context for boundary ${boundaryEl.tagName}`\n );\n }\n return;\n }\n\n // Validate that the signal is writable — computed signals or non-signal\n // functions will throw at runtime when setBoundaryError calls .set()\n if (typeof errorSignal.set !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] Signal \"${signalName}\" is not writable (no .set method) for boundary ${boundaryEl.tagName}`\n );\n }\n return;\n }\n\n createBoundary(boundaryEl, errorSignal, disposers);\n}\n\n/**\n * Binds error boundaries in the DOM fragment\n * Scans for [data-error] elements and sets up error boundary behavior\n *\n * @param fragment - DOM fragment to scan\n * @param context - Reactive context containing error signals\n * @param disposers - Array to add cleanup functions to\n */\n/** @codexApi {\"parent\":\"pithy.feature.error-boundary\",\"name\":\"bindErrorBoundary\",\"stability\":\"stable\",\"signature\":\"(fragment: Element | DocumentFragment, context: Record<string, unknown>, disposers: (() => void)[]) => void\"} */\nexport function bindErrorBoundary(\n fragment: Element | DocumentFragment,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n // Patch timers on first boundary registration\n patchTimersOnce();\n\n const boundaryElements = Array.from(\n fragment.querySelectorAll('[data-error]')\n );\n\n for (const boundaryEl of boundaryElements) {\n if (boundElements.has(boundaryEl)) continue;\n const signalName = declaredValue(boundaryEl, 'data-error');\n if (!signalName) continue;\n\n const errorSignal = context[signalName] as Signal<Error | null> | undefined;\n if (!errorSignal || typeof errorSignal !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] Signal \"${signalName}\" not found in context for boundary ${boundaryEl.tagName}`\n );\n }\n continue;\n }\n\n // Validate that the signal is writable — computed signals or non-signal\n // functions will throw at runtime when setBoundaryError calls .set()\n if (typeof errorSignal.set !== 'function') {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ErrorBoundary] Signal \"${signalName}\" is not writable (no .set method) for boundary ${boundaryEl.tagName}`\n );\n }\n continue;\n }\n\n // Create and register the boundary (registration happens inside createBoundary)\n createBoundary(boundaryEl, errorSignal, disposers);\n boundElements.add(boundaryEl);\n disposers.push(() => boundElements.delete(boundaryEl));\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindTextInterpolations.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/bindTextInterpolations.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;
|
|
1
|
+
{"version":3,"file":"bindTextInterpolations.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/bindTextInterpolations.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAYF;;;;;;GAMG;AACH,iOAAiO;AACjO,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,OAAO,GAAG,gBAAgB,EAChC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAGN;AA0UD,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,GAAG,IAAI,CActD"}
|
|
@@ -10,6 +10,7 @@ import { effect, isSignal } from '@pithyjs/signals';
|
|
|
10
10
|
import { toTextValue } from '../textValue.js';
|
|
11
11
|
import { compileExpression } from '../compileExpression.js';
|
|
12
12
|
import { isSSRMode } from '../ssrMode.js';
|
|
13
|
+
import { textEvalMessage } from '../evalDiagnostics.js';
|
|
13
14
|
import { nodeExpando } from '../nodeExpando.js';
|
|
14
15
|
const INTERPOLATION_RE = /{{\s*([\s\S]*?)\s*}}/g;
|
|
15
16
|
/**
|
|
@@ -187,8 +188,8 @@ function bindTextNodeUpdates(node, rawText, expressions, matchStrings, renderFns
|
|
|
187
188
|
// must be inserted verbatim (e.g. literal code like `str.replace(/a/, '$&')`).
|
|
188
189
|
output = output.replace(matchStrings[i], () => toTextValue(result));
|
|
189
190
|
}
|
|
190
|
-
catch {
|
|
191
|
-
|
|
191
|
+
catch (err) {
|
|
192
|
+
console.error(textEvalMessage(expressions[i]), err);
|
|
192
193
|
output = output.replace(matchStrings[i], '');
|
|
193
194
|
}
|
|
194
195
|
});
|
|
@@ -223,7 +224,7 @@ function bindDynamicTextNode(textNode, expression, ctx, disposers, highlightTarg
|
|
|
223
224
|
textNode.nodeValue = toTextValue(compiledFn());
|
|
224
225
|
}
|
|
225
226
|
catch (err) {
|
|
226
|
-
console.error(
|
|
227
|
+
console.error(textEvalMessage(expression), err);
|
|
227
228
|
textNode.nodeValue = '';
|
|
228
229
|
}
|
|
229
230
|
}
|
|
@@ -246,15 +247,16 @@ function bindDynamicTextNode(textNode, expression, ctx, disposers, highlightTarg
|
|
|
246
247
|
}
|
|
247
248
|
}
|
|
248
249
|
catch (err) {
|
|
249
|
-
console.error(
|
|
250
|
+
console.error(textEvalMessage(expression), err);
|
|
250
251
|
textNode.nodeValue = '';
|
|
252
|
+
lastValue = '';
|
|
251
253
|
}
|
|
252
254
|
});
|
|
253
255
|
disposers.push(stop);
|
|
254
256
|
}
|
|
255
257
|
}
|
|
256
258
|
catch (err) {
|
|
257
|
-
console.error(`[
|
|
259
|
+
console.error(`[PithyJS] ❌ Failed to compile: ${expression}`, err);
|
|
258
260
|
}
|
|
259
261
|
}
|
|
260
262
|
/* -----------------------------------------------------------------------------
|