@pithyjs/core 0.1.0-beta.0
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/LICENSE +21 -0
- package/README.md +513 -0
- package/dist/a11y/focus-trap.d.ts +109 -0
- package/dist/a11y/focus-trap.d.ts.map +1 -0
- package/dist/a11y/focus-trap.js +246 -0
- package/dist/a11y/focus-trap.js.map +1 -0
- package/dist/a11y/index.d.ts +12 -0
- package/dist/a11y/index.d.ts.map +1 -0
- package/dist/a11y/index.js +16 -0
- package/dist/a11y/index.js.map +1 -0
- package/dist/a11y/keyboard-utils.d.ts +165 -0
- package/dist/a11y/keyboard-utils.d.ts.map +1 -0
- package/dist/a11y/keyboard-utils.js +321 -0
- package/dist/a11y/keyboard-utils.js.map +1 -0
- package/dist/a11y/roving-tabindex.d.ts +118 -0
- package/dist/a11y/roving-tabindex.d.ts.map +1 -0
- package/dist/a11y/roving-tabindex.js +249 -0
- package/dist/a11y/roving-tabindex.js.map +1 -0
- package/dist/a11y/skip-link.d.ts +55 -0
- package/dist/a11y/skip-link.d.ts.map +1 -0
- package/dist/a11y/skip-link.js +164 -0
- package/dist/a11y/skip-link.js.map +1 -0
- package/dist/compile/bindSwitchCases.d.ts +16 -0
- package/dist/compile/bindSwitchCases.d.ts.map +1 -0
- package/dist/compile/bindSwitchCases.js +323 -0
- package/dist/compile/bindSwitchCases.js.map +1 -0
- package/dist/compile/binds/bindBoundAttributes.d.ts +14 -0
- package/dist/compile/binds/bindBoundAttributes.d.ts.map +1 -0
- package/dist/compile/binds/bindBoundAttributes.js +57 -0
- package/dist/compile/binds/bindBoundAttributes.js.map +1 -0
- package/dist/compile/binds/bindClassDirectives.d.ts +20 -0
- package/dist/compile/binds/bindClassDirectives.d.ts.map +1 -0
- package/dist/compile/binds/bindClassDirectives.js +94 -0
- package/dist/compile/binds/bindClassDirectives.js.map +1 -0
- package/dist/compile/binds/bindComponentsTags.d.ts +17 -0
- package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -0
- package/dist/compile/binds/bindComponentsTags.js +355 -0
- package/dist/compile/binds/bindComponentsTags.js.map +1 -0
- package/dist/compile/binds/bindConditionals.d.ts +16 -0
- package/dist/compile/binds/bindConditionals.d.ts.map +1 -0
- package/dist/compile/binds/bindConditionals.js +102 -0
- package/dist/compile/binds/bindConditionals.js.map +1 -0
- package/dist/compile/binds/bindDefaultTwoWay.d.ts +35 -0
- package/dist/compile/binds/bindDefaultTwoWay.d.ts.map +1 -0
- package/dist/compile/binds/bindDefaultTwoWay.js +128 -0
- package/dist/compile/binds/bindDefaultTwoWay.js.map +1 -0
- package/dist/compile/binds/bindDeferDirectives.d.ts +21 -0
- package/dist/compile/binds/bindDeferDirectives.d.ts.map +1 -0
- package/dist/compile/binds/bindDeferDirectives.js +465 -0
- package/dist/compile/binds/bindDeferDirectives.js.map +1 -0
- package/dist/compile/binds/bindErrorBoundary.d.ts +71 -0
- package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -0
- package/dist/compile/binds/bindErrorBoundary.js +389 -0
- package/dist/compile/binds/bindErrorBoundary.js.map +1 -0
- package/dist/compile/binds/bindEventHandlers.d.ts +17 -0
- package/dist/compile/binds/bindEventHandlers.d.ts.map +1 -0
- package/dist/compile/binds/bindEventHandlers.js +174 -0
- package/dist/compile/binds/bindEventHandlers.js.map +1 -0
- package/dist/compile/binds/bindRefDirectives.d.ts +14 -0
- package/dist/compile/binds/bindRefDirectives.d.ts.map +1 -0
- package/dist/compile/binds/bindRefDirectives.js +35 -0
- package/dist/compile/binds/bindRefDirectives.js.map +1 -0
- package/dist/compile/binds/bindTextInterpolations.d.ts +16 -0
- package/dist/compile/binds/bindTextInterpolations.d.ts.map +1 -0
- package/dist/compile/binds/bindTextInterpolations.js +408 -0
- package/dist/compile/binds/bindTextInterpolations.js.map +1 -0
- package/dist/compile/binds/directiveRegistry.d.ts +46 -0
- package/dist/compile/binds/directiveRegistry.d.ts.map +1 -0
- package/dist/compile/binds/directiveRegistry.js +50 -0
- package/dist/compile/binds/directiveRegistry.js.map +1 -0
- package/dist/compile/compileExpression.d.ts +10 -0
- package/dist/compile/compileExpression.d.ts.map +1 -0
- package/dist/compile/compileExpression.js +26 -0
- package/dist/compile/compileExpression.js.map +1 -0
- package/dist/compile/compileNodes.d.ts +32 -0
- package/dist/compile/compileNodes.d.ts.map +1 -0
- package/dist/compile/compileNodes.js +104 -0
- package/dist/compile/compileNodes.js.map +1 -0
- package/dist/compile/compileTemplate.d.ts +64 -0
- package/dist/compile/compileTemplate.d.ts.map +1 -0
- package/dist/compile/compileTemplate.js +157 -0
- package/dist/compile/compileTemplate.js.map +1 -0
- package/dist/compile/contentProjection.d.ts +29 -0
- package/dist/compile/contentProjection.d.ts.map +1 -0
- package/dist/compile/contentProjection.js +210 -0
- package/dist/compile/contentProjection.js.map +1 -0
- package/dist/compile/forLoops/bindForLoops.d.ts +21 -0
- package/dist/compile/forLoops/bindForLoops.d.ts.map +1 -0
- package/dist/compile/forLoops/bindForLoops.js +151 -0
- package/dist/compile/forLoops/bindForLoops.js.map +1 -0
- package/dist/compile/forLoops/createLoopManager.d.ts +51 -0
- package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -0
- package/dist/compile/forLoops/createLoopManager.js +429 -0
- package/dist/compile/forLoops/createLoopManager.js.map +1 -0
- package/dist/compile/forLoops/index.d.ts +6 -0
- package/dist/compile/forLoops/index.d.ts.map +1 -0
- package/dist/compile/forLoops/index.js +8 -0
- package/dist/compile/forLoops/index.js.map +1 -0
- package/dist/compile/forLoops/loopHelpers.d.ts +33 -0
- package/dist/compile/forLoops/loopHelpers.d.ts.map +1 -0
- package/dist/compile/forLoops/loopHelpers.js +69 -0
- package/dist/compile/forLoops/loopHelpers.js.map +1 -0
- package/dist/compile/forLoops/loopSignals.d.ts +36 -0
- package/dist/compile/forLoops/loopSignals.d.ts.map +1 -0
- package/dist/compile/forLoops/loopSignals.js +64 -0
- package/dist/compile/forLoops/loopSignals.js.map +1 -0
- package/dist/compile/forLoops/loopTraversal.d.ts +18 -0
- package/dist/compile/forLoops/loopTraversal.d.ts.map +1 -0
- package/dist/compile/forLoops/loopTraversal.js +38 -0
- package/dist/compile/forLoops/loopTraversal.js.map +1 -0
- package/dist/compile/handleConditionalChain.d.ts +15 -0
- package/dist/compile/handleConditionalChain.d.ts.map +1 -0
- package/dist/compile/handleConditionalChain.js +181 -0
- package/dist/compile/handleConditionalChain.js.map +1 -0
- package/dist/compile/index.d.ts +15 -0
- package/dist/compile/index.d.ts.map +1 -0
- package/dist/compile/index.js +19 -0
- package/dist/compile/index.js.map +1 -0
- package/dist/compile/injectScopedStyle.d.ts +16 -0
- package/dist/compile/injectScopedStyle.d.ts.map +1 -0
- package/dist/compile/injectScopedStyle.js +50 -0
- package/dist/compile/injectScopedStyle.js.map +1 -0
- package/dist/compile/nodeExpando.d.ts +12 -0
- package/dist/compile/nodeExpando.d.ts.map +1 -0
- package/dist/compile/nodeExpando.js +4 -0
- package/dist/compile/nodeExpando.js.map +1 -0
- package/dist/compile/parseHtml.d.ts +70 -0
- package/dist/compile/parseHtml.d.ts.map +1 -0
- package/dist/compile/parseHtml.js +164 -0
- package/dist/compile/parseHtml.js.map +1 -0
- package/dist/compile/pithyTreeToDom.d.ts +16 -0
- package/dist/compile/pithyTreeToDom.d.ts.map +1 -0
- package/dist/compile/pithyTreeToDom.js +118 -0
- package/dist/compile/pithyTreeToDom.js.map +1 -0
- package/dist/compile/renderChildren.d.ts +50 -0
- package/dist/compile/renderChildren.d.ts.map +1 -0
- package/dist/compile/renderChildren.js +76 -0
- package/dist/compile/renderChildren.js.map +1 -0
- package/dist/compile/ssrMode.d.ts +17 -0
- package/dist/compile/ssrMode.d.ts.map +1 -0
- package/dist/compile/ssrMode.js +20 -0
- package/dist/compile/ssrMode.js.map +1 -0
- package/dist/compile/textValue.d.ts +28 -0
- package/dist/compile/textValue.d.ts.map +1 -0
- package/dist/compile/textValue.js +30 -0
- package/dist/compile/textValue.js.map +1 -0
- package/dist/config/index.d.ts +37 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +16 -0
- package/dist/config/index.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/index.d.ts +3 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +3 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/ref-signal.interface.d.ts +6 -0
- package/dist/interfaces/ref-signal.interface.d.ts.map +1 -0
- package/dist/interfaces/ref-signal.interface.js +2 -0
- package/dist/interfaces/ref-signal.interface.js.map +1 -0
- package/dist/interfaces/ref.interface.d.ts +5 -0
- package/dist/interfaces/ref.interface.d.ts.map +1 -0
- package/dist/interfaces/ref.interface.js +2 -0
- package/dist/interfaces/ref.interface.js.map +1 -0
- package/dist/runtime/applyBindings.d.ts +36 -0
- package/dist/runtime/applyBindings.d.ts.map +1 -0
- package/dist/runtime/applyBindings.js +165 -0
- package/dist/runtime/applyBindings.js.map +1 -0
- package/dist/runtime/bindings/applyComponent.d.ts +3 -0
- package/dist/runtime/bindings/applyComponent.d.ts.map +1 -0
- package/dist/runtime/bindings/applyComponent.js +190 -0
- package/dist/runtime/bindings/applyComponent.js.map +1 -0
- package/dist/runtime/bindings/applyDefer.d.ts +11 -0
- package/dist/runtime/bindings/applyDefer.d.ts.map +1 -0
- package/dist/runtime/bindings/applyDefer.js +422 -0
- package/dist/runtime/bindings/applyDefer.js.map +1 -0
- package/dist/runtime/bindings/applySimple.d.ts +11 -0
- package/dist/runtime/bindings/applySimple.d.ts.map +1 -0
- package/dist/runtime/bindings/applySimple.js +346 -0
- package/dist/runtime/bindings/applySimple.js.map +1 -0
- package/dist/runtime/bindings/applyStructural.d.ts +5 -0
- package/dist/runtime/bindings/applyStructural.d.ts.map +1 -0
- package/dist/runtime/bindings/applyStructural.js +312 -0
- package/dist/runtime/bindings/applyStructural.js.map +1 -0
- package/dist/runtime/bindings/helpers.d.ts +56 -0
- package/dist/runtime/bindings/helpers.d.ts.map +1 -0
- package/dist/runtime/bindings/helpers.js +121 -0
- package/dist/runtime/bindings/helpers.js.map +1 -0
- package/dist/runtime/bindings/index.d.ts +7 -0
- package/dist/runtime/bindings/index.d.ts.map +1 -0
- package/dist/runtime/bindings/index.js +6 -0
- package/dist/runtime/bindings/index.js.map +1 -0
- package/dist/runtime/bindings/types.d.ts +105 -0
- package/dist/runtime/bindings/types.d.ts.map +1 -0
- package/dist/runtime/bindings/types.js +5 -0
- package/dist/runtime/bindings/types.js.map +1 -0
- package/dist/runtime/bootstrap.d.ts +59 -0
- package/dist/runtime/bootstrap.d.ts.map +1 -0
- package/dist/runtime/bootstrap.js +82 -0
- package/dist/runtime/bootstrap.js.map +1 -0
- package/dist/runtime/createContextProxy.d.ts +10 -0
- package/dist/runtime/createContextProxy.d.ts.map +1 -0
- package/dist/runtime/createContextProxy.js +45 -0
- package/dist/runtime/createContextProxy.js.map +1 -0
- package/dist/runtime/deferHelpers.d.ts +49 -0
- package/dist/runtime/deferHelpers.d.ts.map +1 -0
- package/dist/runtime/deferHelpers.js +65 -0
- package/dist/runtime/deferHelpers.js.map +1 -0
- package/dist/runtime/html.d.ts +23 -0
- package/dist/runtime/html.d.ts.map +1 -0
- package/dist/runtime/html.js +97 -0
- package/dist/runtime/html.js.map +1 -0
- package/dist/runtime/index.d.ts +8 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +21 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/lazy.d.ts +144 -0
- package/dist/runtime/lazy.d.ts.map +1 -0
- package/dist/runtime/lazy.js +295 -0
- package/dist/runtime/lazy.js.map +1 -0
- package/dist/runtime/module-cache.d.ts +78 -0
- package/dist/runtime/module-cache.d.ts.map +1 -0
- package/dist/runtime/module-cache.js +109 -0
- package/dist/runtime/module-cache.js.map +1 -0
- package/dist/runtime/onDestroy.d.ts +29 -0
- package/dist/runtime/onDestroy.d.ts.map +1 -0
- package/dist/runtime/onDestroy.js +66 -0
- package/dist/runtime/onDestroy.js.map +1 -0
- package/dist/runtime/parseIdentifiersFromTemplate.d.ts +17 -0
- package/dist/runtime/parseIdentifiersFromTemplate.d.ts.map +1 -0
- package/dist/runtime/parseIdentifiersFromTemplate.js +68 -0
- package/dist/runtime/parseIdentifiersFromTemplate.js.map +1 -0
- package/dist/types/globals.d.ts +18 -0
- package/dist/types/globals.d.ts.map +1 -0
- package/dist/types/globals.js +4 -0
- package/dist/types/globals.js.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utilities/index.d.ts +3 -0
- package/dist/utilities/index.d.ts.map +1 -0
- package/dist/utilities/index.js +3 -0
- package/dist/utilities/index.js.map +1 -0
- package/dist/utilities/ref-signal.utility.d.ts +32 -0
- package/dist/utilities/ref-signal.utility.d.ts.map +1 -0
- package/dist/utilities/ref-signal.utility.js +46 -0
- package/dist/utilities/ref-signal.utility.js.map +1 -0
- package/dist/utilities/ref.untility.d.ts +37 -0
- package/dist/utilities/ref.untility.d.ts.map +1 -0
- package/dist/utilities/ref.untility.js +47 -0
- package/dist/utilities/ref.untility.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** @codex
|
|
2
|
+
{
|
|
3
|
+
"id": "pithy.feature.error-boundary",
|
|
4
|
+
"title": "Error Boundary System",
|
|
5
|
+
"category": "feature"
|
|
6
|
+
}
|
|
7
|
+
*/
|
|
8
|
+
import { Signal } from '@pithyjs/signals';
|
|
9
|
+
/**
|
|
10
|
+
* Represents an active error boundary in the DOM
|
|
11
|
+
*/
|
|
12
|
+
export interface BoundaryInfo {
|
|
13
|
+
element: Element;
|
|
14
|
+
errorSignal: Signal<Error | null>;
|
|
15
|
+
fallbackElement: Element | null;
|
|
16
|
+
contentPlaceholders: Map<Node, Comment>;
|
|
17
|
+
isActive: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Finds the BoundaryInfo for a given DOM element by traversing up the tree
|
|
21
|
+
* @param el - Element to find boundary for
|
|
22
|
+
* @returns BoundaryInfo if found, null otherwise
|
|
23
|
+
*/
|
|
24
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"boundaryForElement","stability":"stable","signature":"(el: Element | null) => BoundaryInfo | null"} */
|
|
25
|
+
export declare function boundaryForElement(el: Element | null): BoundaryInfo | null;
|
|
26
|
+
/**
|
|
27
|
+
* Clears the error state of a boundary, restoring normal content
|
|
28
|
+
* @param boundary - The boundary to clear
|
|
29
|
+
*/
|
|
30
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"clearBoundaryError","stability":"stable","signature":"(boundary: BoundaryInfo) => void"} */
|
|
31
|
+
export declare function clearBoundaryError(boundary: BoundaryInfo): void;
|
|
32
|
+
/**
|
|
33
|
+
* Sets an error on a boundary with escalation logic
|
|
34
|
+
* If the boundary is already in error state, escalates to parent boundary
|
|
35
|
+
* Matches React behavior: first error wins, subsequent errors ignored
|
|
36
|
+
* @param boundary - The boundary to set error on
|
|
37
|
+
* @param error - The error to set
|
|
38
|
+
*/
|
|
39
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"setBoundaryError","stability":"stable","signature":"(boundary: BoundaryInfo, error: Error) => void"} */
|
|
40
|
+
export declare function setBoundaryError(boundary: BoundaryInfo, error: Error): void;
|
|
41
|
+
/**
|
|
42
|
+
* Runs a function within the context of a specific boundary
|
|
43
|
+
* Used for scoping async operations to the correct boundary
|
|
44
|
+
* @param boundary - Boundary to run within
|
|
45
|
+
* @param fn - Function to execute
|
|
46
|
+
* @returns Result of function execution
|
|
47
|
+
*/
|
|
48
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"runWithBoundary","stability":"stable","signature":"<T>(boundary: BoundaryInfo | null, fn: () => T) => T"} */
|
|
49
|
+
export declare function runWithBoundary<T>(boundary: BoundaryInfo | null, fn: () => T): T;
|
|
50
|
+
/**
|
|
51
|
+
* Register a single element as an error boundary.
|
|
52
|
+
* Used by AOT applyBindings where the boundary element is known directly
|
|
53
|
+
* (unlike bindErrorBoundary which scans children via querySelectorAll).
|
|
54
|
+
*
|
|
55
|
+
* @param boundaryEl - The element with data-error attribute
|
|
56
|
+
* @param context - Reactive context containing error signals
|
|
57
|
+
* @param disposers - Array to add cleanup functions to
|
|
58
|
+
*/
|
|
59
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"registerBoundary","stability":"stable","signature":"(boundaryEl: Element, context: Record<string, unknown>, disposers: (() => void)[]) => void"} */
|
|
60
|
+
export declare function registerBoundary(boundaryEl: Element, context: Record<string, unknown>, disposers: (() => void)[]): void;
|
|
61
|
+
/**
|
|
62
|
+
* Binds error boundaries in the DOM fragment
|
|
63
|
+
* Scans for [data-error] elements and sets up error boundary behavior
|
|
64
|
+
*
|
|
65
|
+
* @param fragment - DOM fragment to scan
|
|
66
|
+
* @param context - Reactive context containing error signals
|
|
67
|
+
* @param disposers - Array to add cleanup functions to
|
|
68
|
+
*/
|
|
69
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"bindErrorBoundary","stability":"stable","signature":"(fragment: Element | DocumentFragment, context: Record<string, unknown>, disposers: (() => void)[]) => void"} */
|
|
70
|
+
export declare function bindErrorBoundary(fragment: Element | DocumentFragment, context: Record<string, unknown>, disposers: (() => void)[]): void;
|
|
71
|
+
//# sourceMappingURL=bindErrorBoundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindErrorBoundary.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/bindErrorBoundary.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAU,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,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|
|
5
|
+
"category": "feature"
|
|
6
|
+
}
|
|
7
|
+
*/
|
|
8
|
+
import { effect } from '@pithyjs/signals';
|
|
9
|
+
/**
|
|
10
|
+
* Global registry of active error boundaries
|
|
11
|
+
*/
|
|
12
|
+
const activeBoundaries = [];
|
|
13
|
+
/**
|
|
14
|
+
* Current boundary context for async error routing (used in later phases)
|
|
15
|
+
*/
|
|
16
|
+
let currentBoundaryContext = null;
|
|
17
|
+
/**
|
|
18
|
+
* Flag to ensure timer patching happens only once
|
|
19
|
+
*/
|
|
20
|
+
let timersPatched = false;
|
|
21
|
+
/**
|
|
22
|
+
* Finds the BoundaryInfo for a given DOM element by traversing up the tree
|
|
23
|
+
* @param el - Element to find boundary for
|
|
24
|
+
* @returns BoundaryInfo if found, null otherwise
|
|
25
|
+
*/
|
|
26
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"boundaryForElement","stability":"stable","signature":"(el: Element | null) => BoundaryInfo | null"} */
|
|
27
|
+
export function boundaryForElement(el) {
|
|
28
|
+
if (!el)
|
|
29
|
+
return null;
|
|
30
|
+
// Find the closest boundary element
|
|
31
|
+
const boundaryEl = el.closest('[data-error]');
|
|
32
|
+
if (!boundaryEl)
|
|
33
|
+
return null;
|
|
34
|
+
// Find the registered boundary info
|
|
35
|
+
return (activeBoundaries.find(boundary => boundary.element === boundaryEl) || null);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Finds the parent boundary for a given boundary (for error escalation)
|
|
39
|
+
* @param childBoundary - The child boundary to find parent for
|
|
40
|
+
* @returns Parent BoundaryInfo if found, null otherwise
|
|
41
|
+
*/
|
|
42
|
+
function findParentBoundary(childBoundary) {
|
|
43
|
+
// Start searching from the child boundary's parent element
|
|
44
|
+
const parentEl = childBoundary.element.parentElement;
|
|
45
|
+
if (!parentEl)
|
|
46
|
+
return null;
|
|
47
|
+
// Find the closest ancestor boundary element
|
|
48
|
+
const parentBoundaryEl = parentEl.closest('[data-error]');
|
|
49
|
+
if (!parentBoundaryEl)
|
|
50
|
+
return null;
|
|
51
|
+
// Find the registered boundary info
|
|
52
|
+
return (activeBoundaries.find(boundary => boundary.element === parentBoundaryEl) ||
|
|
53
|
+
null);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Clears the error state of a boundary, restoring normal content
|
|
57
|
+
* @param boundary - The boundary to clear
|
|
58
|
+
*/
|
|
59
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"clearBoundaryError","stability":"stable","signature":"(boundary: BoundaryInfo) => void"} */
|
|
60
|
+
export function clearBoundaryError(boundary) {
|
|
61
|
+
if (boundary.errorSignal() !== null) {
|
|
62
|
+
boundary.errorSignal.set(null);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Sets an error on a boundary with escalation logic
|
|
67
|
+
* If the boundary is already in error state, escalates to parent boundary
|
|
68
|
+
* Matches React behavior: first error wins, subsequent errors ignored
|
|
69
|
+
* @param boundary - The boundary to set error on
|
|
70
|
+
* @param error - The error to set
|
|
71
|
+
*/
|
|
72
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"setBoundaryError","stability":"stable","signature":"(boundary: BoundaryInfo, error: Error) => void"} */
|
|
73
|
+
export function setBoundaryError(boundary, error) {
|
|
74
|
+
// Check if this boundary is already in error state
|
|
75
|
+
if (boundary.errorSignal() !== null) {
|
|
76
|
+
// Escalate to parent boundary
|
|
77
|
+
const parentBoundary = findParentBoundary(boundary);
|
|
78
|
+
if (parentBoundary) {
|
|
79
|
+
setBoundaryError(parentBoundary, error);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// IGNORE subsequent errors (React behavior - first error wins)
|
|
84
|
+
return; // Don't replace the error
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Set the error on this boundary
|
|
88
|
+
boundary.errorSignal.set(error);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Runs a function within the context of a specific boundary
|
|
92
|
+
* Used for scoping async operations to the correct boundary
|
|
93
|
+
* @param boundary - Boundary to run within
|
|
94
|
+
* @param fn - Function to execute
|
|
95
|
+
* @returns Result of function execution
|
|
96
|
+
*/
|
|
97
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"runWithBoundary","stability":"stable","signature":"<T>(boundary: BoundaryInfo | null, fn: () => T) => T"} */
|
|
98
|
+
export function runWithBoundary(boundary, fn) {
|
|
99
|
+
const previousContext = currentBoundaryContext;
|
|
100
|
+
currentBoundaryContext = boundary;
|
|
101
|
+
try {
|
|
102
|
+
return fn();
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
currentBoundaryContext = previousContext;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function patchTimersOnce() {
|
|
109
|
+
if (timersPatched)
|
|
110
|
+
return;
|
|
111
|
+
timersPatched = true;
|
|
112
|
+
// Patch setTimeout
|
|
113
|
+
const originalSetTimeout = window.setTimeout;
|
|
114
|
+
window.setTimeout = ((callback, delay, ...args) => {
|
|
115
|
+
// Don't wrap string callbacks; let the browser handle them
|
|
116
|
+
if (typeof callback !== 'function') {
|
|
117
|
+
return originalSetTimeout(callback, delay, ...args);
|
|
118
|
+
}
|
|
119
|
+
const capturedBoundary = currentBoundaryContext;
|
|
120
|
+
const fn = callback;
|
|
121
|
+
const wrappedCallback = (...callbackArgs) => {
|
|
122
|
+
return runWithBoundary(capturedBoundary, () => {
|
|
123
|
+
try {
|
|
124
|
+
return fn(...callbackArgs);
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
if (capturedBoundary) {
|
|
128
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
129
|
+
setBoundaryError(capturedBoundary, err);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
return originalSetTimeout(wrappedCallback, delay, ...args);
|
|
138
|
+
});
|
|
139
|
+
// Patch setInterval
|
|
140
|
+
const originalSetInterval = window.setInterval;
|
|
141
|
+
window.setInterval = ((callback, delay, ...args) => {
|
|
142
|
+
// Don't wrap string callbacks; let the browser handle them
|
|
143
|
+
if (typeof callback !== 'function') {
|
|
144
|
+
return originalSetInterval(callback, delay, ...args);
|
|
145
|
+
}
|
|
146
|
+
const capturedBoundary = currentBoundaryContext;
|
|
147
|
+
const fn = callback;
|
|
148
|
+
const wrappedCallback = (...callbackArgs) => {
|
|
149
|
+
return runWithBoundary(capturedBoundary, () => {
|
|
150
|
+
try {
|
|
151
|
+
return fn(...callbackArgs);
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
if (capturedBoundary) {
|
|
155
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
156
|
+
setBoundaryError(capturedBoundary, err);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
return originalSetInterval(wrappedCallback, delay, ...args);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Finds the fallback element within a boundary
|
|
169
|
+
* @param boundaryEl - The boundary element to search within
|
|
170
|
+
* @returns The fallback element or null if not found
|
|
171
|
+
*/
|
|
172
|
+
function findFallbackElement(boundaryEl) {
|
|
173
|
+
// Look through direct children first to avoid nested boundary fallbacks
|
|
174
|
+
for (const child of Array.from(boundaryEl.children)) {
|
|
175
|
+
if (child.hasAttribute('data-fallback')) {
|
|
176
|
+
// Double-check that this fallback belongs to this boundary
|
|
177
|
+
const fallbackBoundary = child.closest('[data-error]');
|
|
178
|
+
if (fallbackBoundary === boundaryEl) {
|
|
179
|
+
return child;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// If no direct child fallback found, search deeper but be more careful
|
|
184
|
+
const allFallbacks = Array.from(boundaryEl.querySelectorAll('[data-fallback]'));
|
|
185
|
+
for (const fallback of allFallbacks) {
|
|
186
|
+
const fallbackBoundary = fallback.closest('[data-error]');
|
|
187
|
+
if (fallbackBoundary === boundaryEl) {
|
|
188
|
+
return fallback;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (import.meta.env?.DEV) {
|
|
192
|
+
console.warn(`[ErrorBoundary] No fallback element found for boundary`, boundaryEl.tagName, 'Available children:', Array.from(boundaryEl.children).map(c => c.tagName +
|
|
193
|
+
(c.hasAttribute('data-fallback') ? '[fallback]' : '') +
|
|
194
|
+
(c.hasAttribute('data-error') ? '[boundary]' : '')));
|
|
195
|
+
}
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Gets current content nodes (excluding fallback) - recomputed each time
|
|
200
|
+
* @param boundaryEl - The boundary element
|
|
201
|
+
* @param fallbackEl - The fallback element to exclude
|
|
202
|
+
* @returns Array of content nodes
|
|
203
|
+
*/
|
|
204
|
+
function getCurrentContentNodes(boundaryEl, fallbackEl) {
|
|
205
|
+
return Array.from(boundaryEl.childNodes).filter(n => {
|
|
206
|
+
// Exclude the fallback element for this boundary
|
|
207
|
+
if (n === fallbackEl)
|
|
208
|
+
return false;
|
|
209
|
+
// Exclude placeholder comments from other boundaries
|
|
210
|
+
if (n.nodeType === Node.COMMENT_NODE &&
|
|
211
|
+
n.data === 'pithy-boundary-hidden') {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
// Don't hide nested boundary elements that are currently showing their fallback
|
|
215
|
+
if (n.nodeType === Node.ELEMENT_NODE) {
|
|
216
|
+
const element = n;
|
|
217
|
+
if (element.hasAttribute('data-error')) {
|
|
218
|
+
// This is a nested boundary - check if it's currently in error state
|
|
219
|
+
const nestedBoundary = activeBoundaries.find(b => b.element === element);
|
|
220
|
+
if (nestedBoundary && nestedBoundary.isActive) {
|
|
221
|
+
// If a nested boundary is already active, keep it visible instead of replacing with our fallback
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return true;
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Hides content by replacing nodes with comment placeholders
|
|
231
|
+
* @param boundary - The boundary info
|
|
232
|
+
*/
|
|
233
|
+
function hideContent(boundary) {
|
|
234
|
+
const { element, fallbackElement, contentPlaceholders } = boundary;
|
|
235
|
+
const nodes = getCurrentContentNodes(element, fallbackElement);
|
|
236
|
+
for (const node of nodes) {
|
|
237
|
+
if (contentPlaceholders.has(node))
|
|
238
|
+
continue;
|
|
239
|
+
const placeholder = document.createComment('pithy-boundary-hidden');
|
|
240
|
+
node.parentNode?.replaceChild(placeholder, node);
|
|
241
|
+
contentPlaceholders.set(node, placeholder);
|
|
242
|
+
}
|
|
243
|
+
// Always show the fallback element if it exists
|
|
244
|
+
if (fallbackElement) {
|
|
245
|
+
fallbackElement.style.display = '';
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Restores content by replacing comment placeholders with original nodes
|
|
250
|
+
* @param boundary - The boundary info
|
|
251
|
+
*/
|
|
252
|
+
function restoreContent(boundary) {
|
|
253
|
+
const { fallbackElement, contentPlaceholders } = boundary;
|
|
254
|
+
for (const [node, placeholder] of Array.from(contentPlaceholders.entries())) {
|
|
255
|
+
placeholder.parentNode?.replaceChild(node, placeholder);
|
|
256
|
+
contentPlaceholders.delete(node);
|
|
257
|
+
}
|
|
258
|
+
if (fallbackElement) {
|
|
259
|
+
fallbackElement.style.display = 'none';
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Hides the fallback element
|
|
264
|
+
* @param fallbackEl - The fallback element to hide
|
|
265
|
+
*/
|
|
266
|
+
function hideFallback(fallbackEl) {
|
|
267
|
+
fallbackEl.style.display = 'none';
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Creates and registers an error boundary
|
|
271
|
+
* @param boundaryEl - The boundary element
|
|
272
|
+
* @param errorSignal - The error signal from context
|
|
273
|
+
* @param disposers - Array to add cleanup functions to
|
|
274
|
+
* @returns The created BoundaryInfo
|
|
275
|
+
*/
|
|
276
|
+
function createBoundary(boundaryEl, errorSignal, disposers) {
|
|
277
|
+
const fallbackEl = findFallbackElement(boundaryEl);
|
|
278
|
+
const boundary = {
|
|
279
|
+
element: boundaryEl,
|
|
280
|
+
errorSignal,
|
|
281
|
+
fallbackElement: fallbackEl,
|
|
282
|
+
contentPlaceholders: new Map(),
|
|
283
|
+
isActive: false,
|
|
284
|
+
};
|
|
285
|
+
// Register BEFORE effect so nested lookups can find us
|
|
286
|
+
activeBoundaries.push(boundary);
|
|
287
|
+
// Initially hide fallback
|
|
288
|
+
if (fallbackEl) {
|
|
289
|
+
hideFallback(fallbackEl);
|
|
290
|
+
}
|
|
291
|
+
// Set up reactive effect to toggle content/fallback based on error state
|
|
292
|
+
const dispose = effect(() => {
|
|
293
|
+
const error = errorSignal();
|
|
294
|
+
const hasError = error !== null;
|
|
295
|
+
if (hasError && !boundary.isActive) {
|
|
296
|
+
// Show error state
|
|
297
|
+
boundary.isActive = true;
|
|
298
|
+
hideContent(boundary);
|
|
299
|
+
}
|
|
300
|
+
else if (!hasError && boundary.isActive) {
|
|
301
|
+
// Show normal state
|
|
302
|
+
boundary.isActive = false;
|
|
303
|
+
restoreContent(boundary);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
// Add cleanup function
|
|
307
|
+
disposers.push(() => {
|
|
308
|
+
dispose();
|
|
309
|
+
// Restore any hidden content
|
|
310
|
+
if (boundary.isActive) {
|
|
311
|
+
restoreContent(boundary);
|
|
312
|
+
}
|
|
313
|
+
// Remove from registry
|
|
314
|
+
const index = activeBoundaries.indexOf(boundary);
|
|
315
|
+
if (index >= 0) {
|
|
316
|
+
activeBoundaries.splice(index, 1);
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
return boundary;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Register a single element as an error boundary.
|
|
323
|
+
* Used by AOT applyBindings where the boundary element is known directly
|
|
324
|
+
* (unlike bindErrorBoundary which scans children via querySelectorAll).
|
|
325
|
+
*
|
|
326
|
+
* @param boundaryEl - The element with data-error attribute
|
|
327
|
+
* @param context - Reactive context containing error signals
|
|
328
|
+
* @param disposers - Array to add cleanup functions to
|
|
329
|
+
*/
|
|
330
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"registerBoundary","stability":"stable","signature":"(boundaryEl: Element, context: Record<string, unknown>, disposers: (() => void)[]) => void"} */
|
|
331
|
+
export function registerBoundary(boundaryEl, context, disposers) {
|
|
332
|
+
patchTimersOnce();
|
|
333
|
+
const signalName = boundaryEl.getAttribute('data-error');
|
|
334
|
+
if (!signalName)
|
|
335
|
+
return;
|
|
336
|
+
const errorSignal = context[signalName];
|
|
337
|
+
if (!errorSignal || typeof errorSignal !== 'function') {
|
|
338
|
+
if (import.meta.env?.DEV) {
|
|
339
|
+
console.warn(`[ErrorBoundary] Signal "${signalName}" not found in context for boundary ${boundaryEl.tagName}`);
|
|
340
|
+
}
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
// Validate that the signal is writable — computed signals or non-signal
|
|
344
|
+
// functions will throw at runtime when setBoundaryError calls .set()
|
|
345
|
+
if (typeof errorSignal.set !== 'function') {
|
|
346
|
+
if (import.meta.env?.DEV) {
|
|
347
|
+
console.warn(`[ErrorBoundary] Signal "${signalName}" is not writable (no .set method) for boundary ${boundaryEl.tagName}`);
|
|
348
|
+
}
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
createBoundary(boundaryEl, errorSignal, disposers);
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Binds error boundaries in the DOM fragment
|
|
355
|
+
* Scans for [data-error] elements and sets up error boundary behavior
|
|
356
|
+
*
|
|
357
|
+
* @param fragment - DOM fragment to scan
|
|
358
|
+
* @param context - Reactive context containing error signals
|
|
359
|
+
* @param disposers - Array to add cleanup functions to
|
|
360
|
+
*/
|
|
361
|
+
/** @codexApi {"parent":"pithy.feature.error-boundary","name":"bindErrorBoundary","stability":"stable","signature":"(fragment: Element | DocumentFragment, context: Record<string, unknown>, disposers: (() => void)[]) => void"} */
|
|
362
|
+
export function bindErrorBoundary(fragment, context, disposers) {
|
|
363
|
+
// Patch timers on first boundary registration
|
|
364
|
+
patchTimersOnce();
|
|
365
|
+
const boundaryElements = Array.from(fragment.querySelectorAll('[data-error]'));
|
|
366
|
+
for (const boundaryEl of boundaryElements) {
|
|
367
|
+
const signalName = boundaryEl.getAttribute('data-error');
|
|
368
|
+
if (!signalName)
|
|
369
|
+
continue;
|
|
370
|
+
const errorSignal = context[signalName];
|
|
371
|
+
if (!errorSignal || typeof errorSignal !== 'function') {
|
|
372
|
+
if (import.meta.env?.DEV) {
|
|
373
|
+
console.warn(`[ErrorBoundary] Signal "${signalName}" not found in context for boundary ${boundaryEl.tagName}`);
|
|
374
|
+
}
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
// Validate that the signal is writable — computed signals or non-signal
|
|
378
|
+
// functions will throw at runtime when setBoundaryError calls .set()
|
|
379
|
+
if (typeof errorSignal.set !== 'function') {
|
|
380
|
+
if (import.meta.env?.DEV) {
|
|
381
|
+
console.warn(`[ErrorBoundary] Signal "${signalName}" is not writable (no .set method) for boundary ${boundaryEl.tagName}`);
|
|
382
|
+
}
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
// Create and register the boundary (registration happens inside createBoundary)
|
|
386
|
+
createBoundary(boundaryEl, errorSignal, disposers);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
//# sourceMappingURL=bindErrorBoundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindErrorBoundary.js","sourceRoot":"","sources":["../../../src/compile/binds/bindErrorBoundary.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAA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
3
|
+
"id": "pithy.runtime.events",
|
|
4
|
+
"title": "Event Handler Binding System",
|
|
5
|
+
"category": "runtime"
|
|
6
|
+
}
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Binds DOM event handlers within `root`.
|
|
10
|
+
* - Uses nearest element context (e.g., loop item ctx) when present.
|
|
11
|
+
* - Idempotent: won't re-bind the same element/event/expression+modifiers combo.
|
|
12
|
+
* - Supports modifiers: .once .prevent .stop .self .capture .passive
|
|
13
|
+
* - Injects `$event` and `$el` for expression handlers (e.g., @click="doThing($event)")
|
|
14
|
+
*/
|
|
15
|
+
/** @codexApi {"parent":"pithy.runtime.events","name":"bindEventHandlers","stability":"stable","signature":"(root: Element | DocumentFragment, rootCtx: Record<string, unknown>, disposers: (() => void)[]) => void"} */
|
|
16
|
+
export declare function bindEventHandlers(root: Element | DocumentFragment, rootCtx: Record<string, unknown>, disposers: (() => void)[]): void;
|
|
17
|
+
//# sourceMappingURL=bindEventHandlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindEventHandlers.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/bindEventHandlers.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAyGF;;;;;;GAMG;AACH,wNAAwN;AACxN,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,OAAO,GAAG,gBAAgB,EAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAgFN"}
|