@pithyjs/core 0.1.0-beta.2 → 0.1.0-beta.21
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 +46 -8
- package/dist/a11y/focus-trap.d.ts +11 -3
- package/dist/a11y/focus-trap.d.ts.map +1 -1
- package/dist/a11y/focus-trap.js +55 -10
- package/dist/a11y/focus-trap.js.map +1 -1
- package/dist/a11y/index.d.ts +4 -4
- package/dist/a11y/index.js +4 -4
- package/dist/a11y/index.js.map +1 -1
- package/dist/a11y/keyboard-utils.js.map +1 -1
- package/dist/a11y/roving-tabindex.js.map +1 -1
- package/dist/a11y/skip-link.js.map +1 -1
- package/dist/compile/bindSwitchCases.d.ts +8 -3
- package/dist/compile/bindSwitchCases.d.ts.map +1 -1
- package/dist/compile/bindSwitchCases.js +137 -183
- package/dist/compile/bindSwitchCases.js.map +1 -1
- package/dist/compile/binds/bindAfterComponents.d.ts +4 -0
- package/dist/compile/binds/bindAfterComponents.d.ts.map +1 -0
- package/dist/compile/binds/bindAfterComponents.js +26 -0
- package/dist/compile/binds/bindAfterComponents.js.map +1 -0
- package/dist/compile/binds/bindAfterProjection.d.ts +7 -0
- package/dist/compile/binds/bindAfterProjection.d.ts.map +1 -0
- package/dist/compile/binds/bindAfterProjection.js +15 -0
- package/dist/compile/binds/bindAfterProjection.js.map +1 -0
- package/dist/compile/binds/bindBoundAttributes.d.ts +8 -0
- package/dist/compile/binds/bindBoundAttributes.d.ts.map +1 -1
- package/dist/compile/binds/bindBoundAttributes.js +227 -21
- package/dist/compile/binds/bindBoundAttributes.js.map +1 -1
- package/dist/compile/binds/bindClassDirectives.d.ts +3 -2
- package/dist/compile/binds/bindClassDirectives.d.ts.map +1 -1
- package/dist/compile/binds/bindClassDirectives.js +58 -21
- package/dist/compile/binds/bindClassDirectives.js.map +1 -1
- package/dist/compile/binds/bindComponentsTags.d.ts +2 -0
- package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
- package/dist/compile/binds/bindComponentsTags.js +186 -74
- package/dist/compile/binds/bindComponentsTags.js.map +1 -1
- package/dist/compile/binds/bindConditionals.d.ts +2 -2
- package/dist/compile/binds/bindConditionals.d.ts.map +1 -1
- package/dist/compile/binds/bindConditionals.js +22 -5
- package/dist/compile/binds/bindConditionals.js.map +1 -1
- package/dist/compile/binds/bindDefaultTwoWay.d.ts.map +1 -1
- package/dist/compile/binds/bindDefaultTwoWay.js +2 -1
- package/dist/compile/binds/bindDefaultTwoWay.js.map +1 -1
- package/dist/compile/binds/bindDeferDirectives.d.ts.map +1 -1
- package/dist/compile/binds/bindDeferDirectives.js +21 -19
- package/dist/compile/binds/bindDeferDirectives.js.map +1 -1
- package/dist/compile/binds/bindErrorBoundary.d.ts +61 -0
- package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
- package/dist/compile/binds/bindErrorBoundary.js +272 -16
- package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
- package/dist/compile/binds/bindEventHandlers.d.ts.map +1 -1
- package/dist/compile/binds/bindEventHandlers.js +15 -5
- package/dist/compile/binds/bindEventHandlers.js.map +1 -1
- package/dist/compile/binds/bindRefDirectives.d.ts.map +1 -1
- package/dist/compile/binds/bindRefDirectives.js +2 -1
- package/dist/compile/binds/bindRefDirectives.js.map +1 -1
- package/dist/compile/binds/bindStyleDirectives.d.ts +17 -0
- package/dist/compile/binds/bindStyleDirectives.d.ts.map +1 -0
- package/dist/compile/binds/bindStyleDirectives.js +48 -0
- package/dist/compile/binds/bindStyleDirectives.js.map +1 -0
- package/dist/compile/binds/bindTextInterpolations.d.ts +4 -2
- package/dist/compile/binds/bindTextInterpolations.d.ts.map +1 -1
- package/dist/compile/binds/bindTextInterpolations.js +87 -35
- package/dist/compile/binds/bindTextInterpolations.js.map +1 -1
- package/dist/compile/binds/declaredDirective.d.ts +12 -0
- package/dist/compile/binds/declaredDirective.d.ts.map +1 -0
- package/dist/compile/binds/declaredDirective.js +42 -0
- package/dist/compile/binds/declaredDirective.js.map +1 -0
- package/dist/compile/binds/directiveRegistry.js.map +1 -1
- package/dist/compile/binds/forwardedAttrs.d.ts +4 -2
- package/dist/compile/binds/forwardedAttrs.d.ts.map +1 -1
- package/dist/compile/binds/forwardedAttrs.js +10 -2
- package/dist/compile/binds/forwardedAttrs.js.map +1 -1
- package/dist/compile/binds/propNames.d.ts +14 -0
- package/dist/compile/binds/propNames.d.ts.map +1 -0
- package/dist/compile/binds/propNames.js +116 -0
- package/dist/compile/binds/propNames.js.map +1 -0
- package/dist/compile/binds/staleRowProps.d.ts +9 -0
- package/dist/compile/binds/staleRowProps.d.ts.map +1 -0
- package/dist/compile/binds/staleRowProps.js +86 -0
- package/dist/compile/binds/staleRowProps.js.map +1 -0
- package/dist/compile/compileExpression.js.map +1 -1
- package/dist/compile/compileNodes.d.ts.map +1 -1
- package/dist/compile/compileNodes.js +16 -7
- package/dist/compile/compileNodes.js.map +1 -1
- package/dist/compile/compileTemplate.d.ts +3 -4
- package/dist/compile/compileTemplate.d.ts.map +1 -1
- package/dist/compile/compileTemplate.js +36 -54
- package/dist/compile/compileTemplate.js.map +1 -1
- package/dist/compile/componentResult.js.map +1 -1
- package/dist/compile/contentProjection.d.ts +15 -3
- package/dist/compile/contentProjection.d.ts.map +1 -1
- package/dist/compile/contentProjection.js +90 -9
- package/dist/compile/contentProjection.js.map +1 -1
- package/dist/compile/disposeOrder.d.ts +35 -0
- package/dist/compile/disposeOrder.d.ts.map +1 -0
- package/dist/compile/disposeOrder.js +81 -0
- package/dist/compile/disposeOrder.js.map +1 -0
- 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/bindForLoops.d.ts +3 -3
- package/dist/compile/forLoops/bindForLoops.d.ts.map +1 -1
- package/dist/compile/forLoops/bindForLoops.js +18 -13
- package/dist/compile/forLoops/bindForLoops.js.map +1 -1
- package/dist/compile/forLoops/createLoopManager.d.ts +3 -3
- package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -1
- package/dist/compile/forLoops/createLoopManager.js +44 -26
- package/dist/compile/forLoops/createLoopManager.js.map +1 -1
- package/dist/compile/forLoops/index.d.ts +5 -5
- package/dist/compile/forLoops/index.js +5 -5
- package/dist/compile/forLoops/index.js.map +1 -1
- package/dist/compile/forLoops/loopHelpers.js.map +1 -1
- package/dist/compile/forLoops/loopSignals.d.ts.map +1 -1
- package/dist/compile/forLoops/loopSignals.js +15 -1
- package/dist/compile/forLoops/loopSignals.js.map +1 -1
- package/dist/compile/forLoops/loopTraversal.js +2 -2
- package/dist/compile/forLoops/loopTraversal.js.map +1 -1
- package/dist/compile/handleConditionalChain.d.ts +2 -2
- package/dist/compile/handleConditionalChain.d.ts.map +1 -1
- package/dist/compile/handleConditionalChain.js +23 -89
- package/dist/compile/handleConditionalChain.js.map +1 -1
- package/dist/compile/index.d.ts +17 -17
- package/dist/compile/index.js +14 -14
- package/dist/compile/index.js.map +1 -1
- package/dist/compile/injectScopedStyle.js.map +1 -1
- package/dist/compile/nodeExpando.d.ts +28 -0
- package/dist/compile/nodeExpando.d.ts.map +1 -1
- package/dist/compile/nodeExpando.js +12 -0
- package/dist/compile/nodeExpando.js.map +1 -1
- package/dist/compile/parseHtml.js +12 -6
- package/dist/compile/parseHtml.js.map +1 -1
- package/dist/compile/pithyTreeToDom.d.ts.map +1 -1
- package/dist/compile/pithyTreeToDom.js +17 -12
- package/dist/compile/pithyTreeToDom.js.map +1 -1
- package/dist/compile/renderBranch.d.ts +13 -0
- package/dist/compile/renderBranch.d.ts.map +1 -0
- package/dist/compile/renderBranch.js +72 -0
- package/dist/compile/renderBranch.js.map +1 -0
- package/dist/compile/renderChildren.d.ts +12 -2
- package/dist/compile/renderChildren.d.ts.map +1 -1
- package/dist/compile/renderChildren.js +33 -4
- package/dist/compile/renderChildren.js.map +1 -1
- package/dist/compile/ssrCrashes.d.ts +65 -37
- package/dist/compile/ssrCrashes.d.ts.map +1 -1
- package/dist/compile/ssrCrashes.js +344 -39
- package/dist/compile/ssrCrashes.js.map +1 -1
- package/dist/compile/ssrMode.js +1 -1
- package/dist/compile/ssrMode.js.map +1 -1
- package/dist/compile/textValue.js.map +1 -1
- package/dist/compile/trimBlankEdges.d.ts +2 -0
- package/dist/compile/trimBlankEdges.d.ts.map +1 -0
- package/dist/compile/trimBlankEdges.js +15 -0
- package/dist/compile/trimBlankEdges.js.map +1 -0
- package/dist/config/index.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/interfaces/index.d.ts +2 -2
- package/dist/interfaces/index.js +2 -2
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/ref-signal.interface.js.map +1 -1
- package/dist/interfaces/ref.interface.js.map +1 -1
- package/dist/runtime/applyBindings.d.ts +9 -5
- package/dist/runtime/applyBindings.d.ts.map +1 -1
- package/dist/runtime/applyBindings.js +130 -43
- package/dist/runtime/applyBindings.js.map +1 -1
- package/dist/runtime/bindings/applyComponent.d.ts +2 -2
- package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
- package/dist/runtime/bindings/applyComponent.js +143 -87
- package/dist/runtime/bindings/applyComponent.js.map +1 -1
- package/dist/runtime/bindings/applyDefer.d.ts +1 -1
- package/dist/runtime/bindings/applyDefer.d.ts.map +1 -1
- package/dist/runtime/bindings/applyDefer.js +16 -15
- package/dist/runtime/bindings/applyDefer.js.map +1 -1
- package/dist/runtime/bindings/applySimple.d.ts +10 -1
- package/dist/runtime/bindings/applySimple.d.ts.map +1 -1
- package/dist/runtime/bindings/applySimple.js +117 -46
- package/dist/runtime/bindings/applySimple.js.map +1 -1
- package/dist/runtime/bindings/applyStructural.d.ts +1 -1
- package/dist/runtime/bindings/applyStructural.d.ts.map +1 -1
- package/dist/runtime/bindings/applyStructural.js +140 -124
- package/dist/runtime/bindings/applyStructural.js.map +1 -1
- package/dist/runtime/bindings/helpers.d.ts +8 -1
- package/dist/runtime/bindings/helpers.d.ts.map +1 -1
- package/dist/runtime/bindings/helpers.js +36 -2
- package/dist/runtime/bindings/helpers.js.map +1 -1
- package/dist/runtime/bindings/index.d.ts +6 -6
- package/dist/runtime/bindings/index.d.ts.map +1 -1
- package/dist/runtime/bindings/index.js +5 -5
- package/dist/runtime/bindings/index.js.map +1 -1
- package/dist/runtime/bindings/types.d.ts +2 -0
- package/dist/runtime/bindings/types.d.ts.map +1 -1
- package/dist/runtime/bindings/types.js.map +1 -1
- package/dist/runtime/bootstrap.d.ts +1 -1
- package/dist/runtime/bootstrap.js +1 -1
- package/dist/runtime/bootstrap.js.map +1 -1
- package/dist/runtime/createContextProxy.js.map +1 -1
- package/dist/runtime/deferHelpers.d.ts +1 -1
- package/dist/runtime/deferHelpers.js.map +1 -1
- package/dist/runtime/html.js +7 -7
- package/dist/runtime/html.js.map +1 -1
- package/dist/runtime/index.d.ts +6 -6
- package/dist/runtime/index.js +6 -6
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/lazy.js +1 -1
- package/dist/runtime/lazy.js.map +1 -1
- package/dist/runtime/module-cache.js.map +1 -1
- package/dist/runtime/onDestroy.d.ts +7 -0
- package/dist/runtime/onDestroy.d.ts.map +1 -1
- package/dist/runtime/onDestroy.js +16 -1
- package/dist/runtime/onDestroy.js.map +1 -1
- package/dist/runtime/parseIdentifiersFromTemplate.js +1 -1
- package/dist/runtime/parseIdentifiersFromTemplate.js.map +1 -1
- package/dist/runtime/resource/createAction.d.ts +1 -1
- package/dist/runtime/resource/createAction.js +1 -1
- package/dist/runtime/resource/createAction.js.map +1 -1
- package/dist/runtime/resource/createResource.d.ts +1 -1
- package/dist/runtime/resource/createResource.d.ts.map +1 -1
- package/dist/runtime/resource/createResource.js +3 -4
- package/dist/runtime/resource/createResource.js.map +1 -1
- package/dist/runtime/resource/engine.d.ts +1 -1
- package/dist/runtime/resource/engine.js.map +1 -1
- package/dist/runtime/resource/index.d.ts +3 -3
- package/dist/runtime/resource/index.js +2 -2
- package/dist/runtime/resource/index.js.map +1 -1
- package/dist/runtime/resource/types.js.map +1 -1
- package/dist/types/globals.d.ts +10 -2
- package/dist/types/globals.d.ts.map +1 -1
- package/dist/types/globals.js.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/index.d.ts +2 -2
- package/dist/utilities/index.js +2 -2
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/ref-signal.utility.d.ts +1 -1
- package/dist/utilities/ref-signal.utility.js.map +1 -1
- package/dist/utilities/ref.untility.d.ts +1 -1
- package/dist/utilities/ref.untility.js.map +1 -1
- package/package.json +11 -6
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
"risk": "high"
|
|
7
7
|
}
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { untrack } from '@pithyjs/signals';
|
|
10
|
+
import { pithyGlobals } from '../types/globals.js';
|
|
11
|
+
import { isSSRMode } from './ssrMode.js';
|
|
12
|
+
import { boundaryContext, findParentBoundary, isInHiddenContent, registeredClosest, setBoundaryError, slotOwnerOf, } from './binds/bindErrorBoundary.js';
|
|
12
13
|
/**
|
|
13
14
|
* Crashes recorded during the current server render, keyed by the placeholder
|
|
14
15
|
* element so a later binding pass over the same element can retract its own
|
|
@@ -49,26 +50,8 @@ function crashRegistry() {
|
|
|
49
50
|
* `bindComponentTags`, `fragment.contains(el)` in `applyBindings`). It can
|
|
50
51
|
* no longer contribute to the output, so any record for it is stale.
|
|
51
52
|
*
|
|
52
|
-
* Retraction matters because the JIT `@if` path really does attempt the same tag
|
|
53
|
-
* twice, measured by counting component invocations:
|
|
54
|
-
*
|
|
55
|
-
* 1. `bindStructuralDirectives` runs first and `handleConditionalChain` binds
|
|
56
|
-
* the chosen branch while it is still DETACHED, so `el.closest('[data-error]')`
|
|
57
|
-
* finds nothing and the crash is recorded.
|
|
58
|
-
* 2. The branch is inserted, and `bindTemplateDirectives` then reaches the
|
|
59
|
-
* still-raw tag on the assembled tree, where the boundary is visible and
|
|
60
|
-
* accepts — retracting via case 1 above.
|
|
61
|
-
*
|
|
62
|
-
* Case 3 exists because accepting is synchronous: it immediately hides the
|
|
63
|
-
* boundary's content, so a SECOND crashing component in that branch is detached
|
|
64
|
-
* before it can be retried, and its detached-pass record would otherwise stand
|
|
65
|
-
* and fail a route whose fallback rendered correctly.
|
|
66
|
-
*
|
|
67
53
|
* Every one of these is mutation-tested; removing any of them turns a correct
|
|
68
54
|
* render into a failed route, or a broken one into a silent success.
|
|
69
|
-
*
|
|
70
|
-
* AOT invokes `applyComponent` once per `pid` and never retries, which is why
|
|
71
|
-
* the equivalent AOT boundary case behaves differently — see BUG-023.
|
|
72
55
|
*/
|
|
73
56
|
/** @codexApi {"parent":"pithy.runtime.ssr-crashes","name":"clearSSRRenderCrash","stability":"internal","signature":"(el: Element) => void"} */
|
|
74
57
|
export function clearSSRRenderCrash(el) {
|
|
@@ -106,6 +89,25 @@ function recordSSRRenderCrash(el, tag, error) {
|
|
|
106
89
|
/** @codexApi {"parent":"pithy.runtime.ssr-crashes","name":"resetSSRRenderCrashes","stability":"stable","signature":"() => void"} */
|
|
107
90
|
export function resetSSRRenderCrashes() {
|
|
108
91
|
crashRegistry().clear();
|
|
92
|
+
const g = pithyGlobals();
|
|
93
|
+
g.__pithyAttributedCrashes = [];
|
|
94
|
+
g.__pithyRenderDepth = 0;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* An element that left the tree being bound contributes nothing to the output:
|
|
98
|
+
* its recorded crash is stale, and an attributed one is only logged.
|
|
99
|
+
*/
|
|
100
|
+
/** @codexApi {"parent":"pithy.runtime.ssr-crashes","name":"forgetCrash","stability":"internal","signature":"(el: Element) => void"} */
|
|
101
|
+
export function forgetCrash(el) {
|
|
102
|
+
clearSSRRenderCrash(el);
|
|
103
|
+
const crash = takeAttributedCrash(el);
|
|
104
|
+
if (crash)
|
|
105
|
+
logCrash(crash);
|
|
106
|
+
}
|
|
107
|
+
function takeAttributedCrash(el) {
|
|
108
|
+
const list = heldCrashes();
|
|
109
|
+
const at = list?.findIndex(crash => crash.el === el) ?? -1;
|
|
110
|
+
return at >= 0 ? list?.splice(at, 1)[0] : undefined;
|
|
109
111
|
}
|
|
110
112
|
/**
|
|
111
113
|
* Return the crashes still recorded once the render has finished, and empty
|
|
@@ -118,26 +120,19 @@ export function resetSSRRenderCrashes() {
|
|
|
118
120
|
* An earlier draft re-resolved each record's boundary here, dropping any crash
|
|
119
121
|
* whose element had ended up inside an `@error-boundary`. That is unsound,
|
|
120
122
|
* because a boundary *existing* above an element is not the same as that
|
|
121
|
-
* boundary having *handled* the crash
|
|
123
|
+
* boundary having *handled* the crash. A crash that a boundary rejected, or
|
|
124
|
+
* that ran where no boundary resolved, is placed under one afterwards just the
|
|
125
|
+
* same. Re-resolution dropped such a record: the boundary signal stayed null,
|
|
126
|
+
* its fallback never activated, the raw component tag shipped, and the build
|
|
127
|
+
* went green — the exact BUG-018 symptom, reintroduced by its own fix.
|
|
122
128
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* there is nothing left to re-resolve.
|
|
127
|
-
* - AOT was actively broken by it. A branch factory binds its subtree while
|
|
128
|
-
* detached, so `applyComponent`'s `el.closest('[data-error]')` finds
|
|
129
|
-
* nothing and the boundary never receives the error — but the nodes are
|
|
130
|
-
* then inserted *under* that boundary, so re-resolution saw one and
|
|
131
|
-
* dropped the record. The boundary signal stayed null, its fallback never
|
|
132
|
-
* activated, the raw component tag shipped, and the build went green: the
|
|
133
|
-
* exact BUG-018 symptom, reintroduced by its own fix.
|
|
134
|
-
*
|
|
135
|
-
* That AOT boundary gap is real but predates this collector and is tracked
|
|
136
|
-
* separately as BUG-023. Until it is fixed, such a crash fails its route, which
|
|
137
|
-
* is the safe direction: a loud failure rather than silently truncated HTML.
|
|
129
|
+
* A crash in a branch, slot or component built detached is attributed to its
|
|
130
|
+
* boundary instead (`deferCrash`); whatever is still attributed here is
|
|
131
|
+
* recorded.
|
|
138
132
|
*/
|
|
139
133
|
/** @codexApi {"parent":"pithy.runtime.ssr-crashes","name":"collectUnhandledSSRRenderCrashes","stability":"stable","signature":"() => SSRRenderCrash[]"} */
|
|
140
134
|
export function collectUnhandledSSRRenderCrashes() {
|
|
135
|
+
resolveAttributedCrashes('collect');
|
|
141
136
|
const registry = crashRegistry();
|
|
142
137
|
const unhandled = [...registry.values()];
|
|
143
138
|
registry.clear();
|
|
@@ -155,10 +150,19 @@ export function collectUnhandledSSRRenderCrashes() {
|
|
|
155
150
|
* the boundary signal null, rendered no fallback, and failed the route, even
|
|
156
151
|
* though the code called it "the same content loss as a crash".
|
|
157
152
|
*
|
|
153
|
+
* With no `boundary`, a failure in a branch, slot or component built detached
|
|
154
|
+
* is attributed to the boundary its render sits under (`deferCrash`) and counts
|
|
155
|
+
* as handled here; `attribution` says how it is logged if no boundary takes it.
|
|
156
|
+
*
|
|
158
157
|
* Callers still do their own logging, since the wording differs per failure.
|
|
159
158
|
*/
|
|
160
|
-
/** @codexApi {"parent":"pithy.runtime.ssr-crashes","name":"reportComponentFailure","stability":"internal","signature":"(el: Element, tag: string, error: Error, boundary: BoundaryInfo | null) => boolean"} */
|
|
161
|
-
export function reportComponentFailure(el, tag, error, boundary) {
|
|
159
|
+
/** @codexApi {"parent":"pithy.runtime.ssr-crashes","name":"reportComponentFailure","stability":"internal","signature":"(el: Element, tag: string, error: Error, boundary: BoundaryInfo | null, attribution?: Attribution) => boolean"} */
|
|
160
|
+
export function reportComponentFailure(el, tag, error, boundary, attribution = {}) {
|
|
161
|
+
if (!boundary && deferCrash(el, tag, error, attribution))
|
|
162
|
+
return true;
|
|
163
|
+
return settleFailure(el, tag, error, boundary);
|
|
164
|
+
}
|
|
165
|
+
function settleFailure(el, tag, error, boundary) {
|
|
162
166
|
// A boundary in scope is not a boundary that accepted: an already-active one
|
|
163
167
|
// with no free ancestor rejects, and that is as unhandled as having none.
|
|
164
168
|
const accepted = boundary ? setBoundaryError(boundary, error) : false;
|
|
@@ -170,4 +174,305 @@ export function reportComponentFailure(el, tag, error, boundary) {
|
|
|
170
174
|
}
|
|
171
175
|
return accepted;
|
|
172
176
|
}
|
|
177
|
+
const ops = {
|
|
178
|
+
locate: registeredClosest,
|
|
179
|
+
owner: slotOwnerOf,
|
|
180
|
+
hidden: isInHiddenContent,
|
|
181
|
+
parent: findParentBoundary,
|
|
182
|
+
settle: settleFailure,
|
|
183
|
+
};
|
|
184
|
+
let taskEndQueued = false;
|
|
185
|
+
// A crash that is neither in place nor hidden when a render ends may belong to
|
|
186
|
+
// content its caller inserts right after (a slot rendered from an effect): it
|
|
187
|
+
// waits once, to the end of the task, before it is reported.
|
|
188
|
+
function resolveAtTaskEnd() {
|
|
189
|
+
if (taskEndQueued)
|
|
190
|
+
return;
|
|
191
|
+
taskEndQueued = true;
|
|
192
|
+
queueMicrotask(() => {
|
|
193
|
+
taskEndQueued = false;
|
|
194
|
+
resolveAttributedCrashes('task');
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
// Shared on `globalThis` for the reason the registry is: a second copy of core
|
|
198
|
+
// must neither miss these nor resolve them in the middle of a render.
|
|
199
|
+
function heldCrashes() {
|
|
200
|
+
return pithyGlobals().__pithyAttributedCrashes;
|
|
201
|
+
}
|
|
202
|
+
function renderDepth(change = 0) {
|
|
203
|
+
const g = pithyGlobals();
|
|
204
|
+
return (g.__pithyRenderDepth = (g.__pithyRenderDepth ?? 0) + change);
|
|
205
|
+
}
|
|
206
|
+
function currentRender() {
|
|
207
|
+
return renderDepth() > 0 ? (pithyGlobals().__pithyRenderId ?? 0) : 0;
|
|
208
|
+
}
|
|
209
|
+
function crashedElements() {
|
|
210
|
+
const g = pithyGlobals();
|
|
211
|
+
return (g.__pithyCrashedElements ?? (g.__pithyCrashedElements = new WeakSet()));
|
|
212
|
+
}
|
|
213
|
+
/** Whether `el` crashed and was attributed; a retry would run its setup twice, which a build never does. */
|
|
214
|
+
/** @codexApi {"parent":"pithy.runtime.ssr-crashes","name":"hasCrashed","stability":"internal","signature":"(el: Element) => boolean"} */
|
|
215
|
+
export function hasCrashed(el) {
|
|
216
|
+
return crashedElements().has(el);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Brackets a render transaction: a template bind, or one structural update
|
|
220
|
+
* that builds a branch and inserts it. Attributed crashes are resolved when the
|
|
221
|
+
* outermost one ends, so a boundary hides its content only once everything in
|
|
222
|
+
* it is bound and in place.
|
|
223
|
+
*/
|
|
224
|
+
/** @codexApi {"parent":"pithy.runtime.ssr-crashes","name":"withinRender","stability":"internal","signature":"<T>(fn: () => T) => T"} */
|
|
225
|
+
export function withinRender(fn) {
|
|
226
|
+
const g = pithyGlobals();
|
|
227
|
+
if (renderDepth() === 0)
|
|
228
|
+
g.__pithyRenderId = (g.__pithyRenderId ?? 0) + 1;
|
|
229
|
+
const render = g.__pithyRenderId ?? 0;
|
|
230
|
+
renderDepth(1);
|
|
231
|
+
let failed = false;
|
|
232
|
+
try {
|
|
233
|
+
return fn();
|
|
234
|
+
}
|
|
235
|
+
catch (err) {
|
|
236
|
+
failed = true;
|
|
237
|
+
throw err;
|
|
238
|
+
}
|
|
239
|
+
finally {
|
|
240
|
+
renderDepth(-1);
|
|
241
|
+
// Never throws, so a failed render keeps its own error. Its caller disposes
|
|
242
|
+
// what it bound, boundaries included, so its own crashes are only reported.
|
|
243
|
+
if (failed && renderDepth() === 0)
|
|
244
|
+
reportCrashesOf(render);
|
|
245
|
+
else
|
|
246
|
+
resolveAttributedCrashes();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Attributes a crash that reached no boundary through the DOM to the boundary
|
|
251
|
+
* its render sits under (`boundaryContext`): a branch, slot or component built
|
|
252
|
+
* detached. Returns `false` with no such context, so the caller handles the
|
|
253
|
+
* crash as before.
|
|
254
|
+
*/
|
|
255
|
+
/** @codexApi {"parent":"pithy.runtime.ssr-crashes","name":"deferCrash","stability":"internal","signature":"(el: Element, tag: string, error: Error, attribution?: Attribution) => boolean"} */
|
|
256
|
+
export function deferCrash(el, tag, error, { message = null, onCaptured } = {}) {
|
|
257
|
+
var _a;
|
|
258
|
+
const boundaryEl = boundaryContext();
|
|
259
|
+
if (!boundaryEl)
|
|
260
|
+
return false;
|
|
261
|
+
crashedElements().add(el);
|
|
262
|
+
takeAttributedCrash(el);
|
|
263
|
+
((_a = pithyGlobals()).__pithyAttributedCrashes ?? (_a.__pithyAttributedCrashes = [])).push({
|
|
264
|
+
el,
|
|
265
|
+
tag,
|
|
266
|
+
error,
|
|
267
|
+
boundaryEl,
|
|
268
|
+
message,
|
|
269
|
+
onCaptured,
|
|
270
|
+
ops,
|
|
271
|
+
render: currentRender(),
|
|
272
|
+
});
|
|
273
|
+
if (renderDepth() === 0)
|
|
274
|
+
resolveAtTaskEnd();
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
function reportCrashesOf(render) {
|
|
278
|
+
const list = heldCrashes();
|
|
279
|
+
if (!list?.length)
|
|
280
|
+
return;
|
|
281
|
+
for (const crash of list.splice(0)) {
|
|
282
|
+
if (crash.render !== render)
|
|
283
|
+
list.push(crash);
|
|
284
|
+
else
|
|
285
|
+
try {
|
|
286
|
+
unhandled(crash);
|
|
287
|
+
}
|
|
288
|
+
catch (err) {
|
|
289
|
+
reportResolveFailure([crash], err);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
function logCrash(crash) {
|
|
294
|
+
if (crash.message)
|
|
295
|
+
console.error(crash.message, crash.error);
|
|
296
|
+
}
|
|
297
|
+
function unhandled(crash) {
|
|
298
|
+
crash.ops.settle(crash.el, crash.tag, crash.error, null);
|
|
299
|
+
logCrash(crash);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Resolves attributed crashes once they are in place. Each goes to the nearest
|
|
303
|
+
* registered boundary at its final position, exactly as a crash placed there
|
|
304
|
+
* would, and within one resolution a boundary takes at most one error. In the
|
|
305
|
+
* browser this waits for the
|
|
306
|
+
* outermost render to end. A static render binds text once, so there the
|
|
307
|
+
* component pass of the template that owns a boundary resolves its crashes
|
|
308
|
+
* (`scope`), before that template's text is bound and after its components
|
|
309
|
+
* ran. `task` runs at the end of the task; `collect` after the HTML is
|
|
310
|
+
* serialized, and only records.
|
|
311
|
+
*/
|
|
312
|
+
/** @codexApi {"parent":"pithy.runtime.ssr-crashes","name":"resolveAttributedCrashes","stability":"internal","signature":"(mode?: 'render' | 'task' | 'collect', scope?: ParentNode) => void"} */
|
|
313
|
+
export function resolveAttributedCrashes(mode = 'render', scope) {
|
|
314
|
+
const list = heldCrashes();
|
|
315
|
+
if (!list?.length)
|
|
316
|
+
return;
|
|
317
|
+
const midRender = mode === 'render' && renderDepth() > 0;
|
|
318
|
+
if (midRender && (!scope || !isSSRMode()))
|
|
319
|
+
return;
|
|
320
|
+
const groups = new Map();
|
|
321
|
+
const into = (boundary, crash) => {
|
|
322
|
+
const group = groups.get(boundary);
|
|
323
|
+
if (group)
|
|
324
|
+
group.push(crash);
|
|
325
|
+
else
|
|
326
|
+
groups.set(boundary, [crash]);
|
|
327
|
+
};
|
|
328
|
+
let waiting = false;
|
|
329
|
+
for (const crash of list.splice(0)) {
|
|
330
|
+
try {
|
|
331
|
+
if (mode === 'collect') {
|
|
332
|
+
unhandled(crash);
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
if (midRender && !scope?.contains(crash.boundaryEl)) {
|
|
336
|
+
list.push(crash);
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
const target = placedAt(crash);
|
|
340
|
+
if (partOfShown(crash, target)) {
|
|
341
|
+
logCrash(crash);
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
if (target)
|
|
345
|
+
into(target, crash);
|
|
346
|
+
// In its boundary with no registered one around it, or out of time.
|
|
347
|
+
else if (mode === 'task' ||
|
|
348
|
+
(!midRender && crash.boundaryEl.contains(crash.el)))
|
|
349
|
+
unhandled(crash);
|
|
350
|
+
else {
|
|
351
|
+
// Not inserted yet: its caller may insert it right after.
|
|
352
|
+
list.push(crash);
|
|
353
|
+
waiting || (waiting = !midRender);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
catch (err) {
|
|
357
|
+
reportResolveFailure([crash], err);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (waiting)
|
|
361
|
+
resolveAtTaskEnd();
|
|
362
|
+
const innermostFirst = [...groups.entries()]
|
|
363
|
+
.map(entry => ({ entry, depth: depthOf(entry[0].element) }))
|
|
364
|
+
.sort((a, b) => b.depth - a.depth)
|
|
365
|
+
.map(({ entry }) => entry);
|
|
366
|
+
const handled = new Set();
|
|
367
|
+
for (const [boundary, group] of innermostFirst) {
|
|
368
|
+
try {
|
|
369
|
+
resolveGroup(boundary, group, handled);
|
|
370
|
+
}
|
|
371
|
+
catch (err) {
|
|
372
|
+
reportResolveFailure(group, err);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
function reportResolveFailure(crashes, err) {
|
|
377
|
+
for (const crash of crashes)
|
|
378
|
+
if (isSSRMode())
|
|
379
|
+
recordSSRRenderCrash(crash.el, crash.tag, crash.error);
|
|
380
|
+
console.error('❌ Resolving a component crash failed:', err);
|
|
381
|
+
}
|
|
382
|
+
function depthOf(node) {
|
|
383
|
+
let depth = 0;
|
|
384
|
+
for (let at = node.parentNode; at; at = at.parentNode)
|
|
385
|
+
depth++;
|
|
386
|
+
return depth;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* One boundary's crashes, content before fallback, so the outcome does not
|
|
390
|
+
* depend on the order they happened in. Each is handled as a crash placed there
|
|
391
|
+
* directly: a content crash goes to the boundary, a fallback crash too unless
|
|
392
|
+
* the boundary already shows its fallback, in which case it goes further out.
|
|
393
|
+
*/
|
|
394
|
+
function resolveGroup(boundary, group, handled) {
|
|
395
|
+
const inFallback = (crash) => !!boundary.fallbackElement?.contains(crash.el);
|
|
396
|
+
for (const crash of group.filter(crash => !inFallback(crash)))
|
|
397
|
+
if (partOfShown(crash, boundary))
|
|
398
|
+
logCrash(crash);
|
|
399
|
+
else
|
|
400
|
+
deliver(crash, boundary, handled);
|
|
401
|
+
for (const crash of group.filter(inFallback)) {
|
|
402
|
+
if (partOfShown(crash, boundary))
|
|
403
|
+
logCrash(crash);
|
|
404
|
+
else
|
|
405
|
+
deliver(crash, showsError(boundary) ? crash.ops.parent(boundary) : boundary, handled);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
// Slot content a portal moves out of its boundary goes to that boundary, as a
|
|
409
|
+
// component crash in it does through the slot frame. Only the nodes a slot
|
|
410
|
+
// rendered carry an owner: a root a component mounts during setup has none.
|
|
411
|
+
function placedAt(crash) {
|
|
412
|
+
const { el, ops } = crash;
|
|
413
|
+
const at = ops.locate(el);
|
|
414
|
+
if (at || !el.isConnected)
|
|
415
|
+
return at;
|
|
416
|
+
const owner = ops.owner(el);
|
|
417
|
+
return owner && !owner.contains(el) ? ops.locate(owner) : null;
|
|
418
|
+
}
|
|
419
|
+
// A delivery earlier in the resolution can hide it. A nearest boundary still
|
|
420
|
+
// free takes it, though an ancestor hides both, as it would a crash placed there.
|
|
421
|
+
function partOfShown(crash, nearest) {
|
|
422
|
+
return crash.ops.hidden(crash.el) && (!nearest || showsError(nearest));
|
|
423
|
+
}
|
|
424
|
+
// As `setBoundaryError` decides: by the signal, which a `batch()` sets before
|
|
425
|
+
// the boundary's effect updates `isActive`.
|
|
426
|
+
function showsError(boundary) {
|
|
427
|
+
return untrack(() => boundary.errorSignal()) !== null;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Hands a crash to the first boundary from `from` outward that is not already
|
|
431
|
+
* showing an error, as `setBoundaryError` escalates a crash placed there. One
|
|
432
|
+
* that reaches a boundary showing an error from this resolution is part of it.
|
|
433
|
+
*/
|
|
434
|
+
function deliver(crash, from, handled) {
|
|
435
|
+
for (let at = from; at; at = crash.ops.parent(at)) {
|
|
436
|
+
if (handled.has(at)) {
|
|
437
|
+
logCrash(crash);
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
if (showsError(at))
|
|
441
|
+
continue;
|
|
442
|
+
let accepted = false;
|
|
443
|
+
try {
|
|
444
|
+
accepted = crash.ops.settle(crash.el, crash.tag, crash.error, at);
|
|
445
|
+
}
|
|
446
|
+
catch (err) {
|
|
447
|
+
// An effect of the boundary threw; the crash is settled only if it took it.
|
|
448
|
+
if (!showsError(at))
|
|
449
|
+
reportResolveFailure([crash], err);
|
|
450
|
+
else
|
|
451
|
+
console.error('❌ Resolving a component crash failed:', err);
|
|
452
|
+
handled.add(at);
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
if (accepted) {
|
|
456
|
+
handled.add(at);
|
|
457
|
+
crash.onCaptured?.();
|
|
458
|
+
}
|
|
459
|
+
else
|
|
460
|
+
logCrash(crash);
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
unhandled(crash);
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Before a component inside a boundary's fallback renders in a static render,
|
|
467
|
+
* that boundary takes its crashes, so content the component renders from the
|
|
468
|
+
* error (text is bound once there) has it.
|
|
469
|
+
*/
|
|
470
|
+
/** @codexApi {"parent":"pithy.runtime.ssr-crashes","name":"resolveBeforeFallback","stability":"internal","signature":"(el: Element) => void"} */
|
|
471
|
+
export function resolveBeforeFallback(el) {
|
|
472
|
+
if (!isSSRMode() || !heldCrashes()?.length)
|
|
473
|
+
return;
|
|
474
|
+
const owner = el.closest('[data-fallback]')?.closest('[data-error]');
|
|
475
|
+
if (owner)
|
|
476
|
+
resolveAttributedCrashes('render', owner);
|
|
477
|
+
}
|
|
173
478
|
//# sourceMappingURL=ssrCrashes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssrCrashes.js","sourceRoot":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,KAAK,EAAE,EAAE,CAAC,CAAC;QACpE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,4EAA4E;YAC5E,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;gBAAE,oBAAoB,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;;gBACnD,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,GAAG,CAAC,CAAC;YACjE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,OAAO;QACT,CAAC;QACD,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC;QACvB,CAAC;;YAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;QACvB,OAAO;IACT,CAAC;IACD,SAAS,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,iJAAiJ;AACjJ,MAAM,UAAU,qBAAqB,CAAC,EAAW;IAC/C,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,MAAM;QAAE,OAAO;IACnD,MAAM,KAAK,GAAG,EAAE,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACrE,IAAI,KAAK;QAAE,wBAAwB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AACvD,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.ssr-crashes\",\n \"title\": \"SSR Unhandled Component Crash Collector\",\n \"category\": \"runtime\",\n \"risk\": \"high\"\n}\n*/\n\nimport { untrack } from '@pithyjs/signals';\nimport { pithyGlobals } from '../types/globals';\nimport { isSSRMode } from './ssrMode';\nimport {\n boundaryContext,\n findParentBoundary,\n isInHiddenContent,\n registeredClosest,\n setBoundaryError,\n slotOwnerOf,\n type BoundaryInfo,\n} from './binds/bindErrorBoundary';\n\n/**\n * A component render crash recorded during a static/server render.\n */\nexport interface SSRRenderCrash {\n /** The custom-element placeholder the crashed component was to replace. */\n el: Element;\n /** Authored tag name, for the failure message. */\n tag: string;\n /** The error the component threw. */\n error: Error;\n}\n\n/**\n * Crashes recorded during the current server render, keyed by the placeholder\n * element so a later binding pass over the same element can retract its own\n * earlier record (see `clearSSRRenderCrash`).\n *\n * Held on `globalThis`, not in this module. `@pithyjs/ssr` depends on\n * `@pithyjs/core` as a regular dependency, so an app and the SSR package can\n * resolve two physical copies: `html()` would record into the app's copy while\n * `renderToString()` collected and reset the SSR package's, reintroducing\n * BUG-018 *and* leaking the app copy's DOM records for the life of the process.\n * The same reasoning already puts `__PITHY_SSR__` and `__getComponentContext`\n * on this bridge.\n *\n * A `Map` (not a `WeakMap`) because the collector must be enumerable at flush\n * time. `resetSSRRenderCrashes()` is what keeps it from retaining DOM across\n * renders — the SSR renderer calls it in a `finally`.\n */\nfunction crashRegistry(): Map<Element, SSRRenderCrash> {\n const g = pithyGlobals();\n return (g.__pithySSRCrashes ??= new Map()) as Map<Element, SSRRenderCrash>;\n}\n\n/**\n * Forget any crash previously recorded for `el`.\n *\n * Called only at points where the record is provably no longer the outcome, and\n * NEVER before invoking a component. Retracting eagerly at the top of an attempt\n * hides a failed retry: a component that throws detached and then returns\n * something unusable would have its only record erased, shipping a page with a\n * missing subtree and a green build. The three call sites are:\n *\n * 1. A boundary ACCEPTING the error (`setBoundaryError()` returning `true`).\n * A boundary merely being in scope is not enough — an already-active one\n * with no free ancestor rejects the error, and that is as unhandled as\n * having no boundary at all.\n * 2. A component returning a usable node that then successfully reaches the\n * document, i.e. after `replaceWith` has not thrown.\n * 3. An element that has left the tree being bound (`scope.contains(el)` in\n * `bindComponentTags`, `fragment.contains(el)` in `applyBindings`). It can\n * no longer contribute to the output, so any record for it is stale.\n *\n * Every one of these is mutation-tested; removing any of them turns a correct\n * render into a failed route, or a broken one into a silent success.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"clearSSRRenderCrash\",\"stability\":\"internal\",\"signature\":\"(el: Element) => void\"} */\nexport function clearSSRRenderCrash(el: Element): void {\n crashRegistry().delete(el);\n}\n\n/**\n * Record a component failure that no error boundary took ownership of.\n *\n * The precondition is **not** \"no boundary was in scope\". It is that no boundary\n * ACCEPTED the error, which is a strictly weaker thing: `setBoundaryError()`\n * rejects an error when the nearest boundary is already showing one and no\n * ancestor is free, and both binders call this on that path with a boundary\n * very much present. Getting the two confused is what this whole module exists\n * to prevent.\n *\n * Nor is \"crash\" limited to a thrown error. The binders also record a component\n * that returned an unusable result, and one whose rendered node failed to reach\n * the document — both leave the raw tag exactly where a throw would, which is\n * the same content loss from the page's point of view.\n *\n * Callers must have established `isSSRMode()` themselves; this does not\n * re-check.\n */\nfunction recordSSRRenderCrash(el: Element, tag: string, error: unknown): void {\n crashRegistry().set(el, {\n el,\n tag,\n error: error instanceof Error ? error : new Error(String(error)),\n });\n}\n\n/**\n * Drop every recorded crash. Called by the SSR renderer before a render starts\n * and again in its `finally`, so one route's crash can never fail the next.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"resetSSRRenderCrashes\",\"stability\":\"stable\",\"signature\":\"() => void\"} */\nexport function resetSSRRenderCrashes(): void {\n crashRegistry().clear();\n const g = pithyGlobals();\n g.__pithyAttributedCrashes = [];\n g.__pithyRenderDepth = 0;\n}\n\n/**\n * An element that left the tree being bound contributes nothing to the output:\n * its recorded crash is stale, and an attributed one is only logged.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"forgetCrash\",\"stability\":\"internal\",\"signature\":\"(el: Element) => void\"} */\nexport function forgetCrash(el: Element): void {\n clearSSRRenderCrash(el);\n const crash = takeAttributedCrash(el);\n if (crash) logCrash(crash);\n}\n\nfunction takeAttributedCrash(el: Element): AttributedCrash | undefined {\n const list = heldCrashes();\n const at = list?.findIndex(crash => crash.el === el) ?? -1;\n return at >= 0 ? list?.splice(at, 1)[0] : undefined;\n}\n\n/**\n * Return the crashes still recorded once the render has finished, and empty\n * the collector.\n *\n * Every surviving record is a failure. A record is only ever retracted by\n * `clearSSRRenderCrash`, i.e. by a genuine re-attempt at the same element that\n * then went better — never by inspecting the finished tree.\n *\n * An earlier draft re-resolved each record's boundary here, dropping any crash\n * whose element had ended up inside an `@error-boundary`. That is unsound,\n * because a boundary *existing* above an element is not the same as that\n * boundary having *handled* the crash. A crash that a boundary rejected, or\n * that ran where no boundary resolved, is placed under one afterwards just the\n * same. Re-resolution dropped such a record: the boundary signal stayed null,\n * its fallback never activated, the raw component tag shipped, and the build\n * went green — the exact BUG-018 symptom, reintroduced by its own fix.\n *\n * A crash in a branch, slot or component built detached is attributed to its\n * boundary instead (`deferCrash`); whatever is still attributed here is\n * recorded.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"collectUnhandledSSRRenderCrashes\",\"stability\":\"stable\",\"signature\":\"() => SSRRenderCrash[]\"} */\nexport function collectUnhandledSSRRenderCrashes(): SSRRenderCrash[] {\n resolveAttributedCrashes('collect');\n const registry = crashRegistry();\n const unhandled = [...registry.values()];\n registry.clear();\n return unhandled;\n}\n\n/**\n * Hand a component failure to its `@error-boundary`, or record it if none takes\n * it. Returns whether a boundary accepted ownership.\n *\n * The single funnel for every way a component can fail to produce content: a\n * thrown error, an unusable return value, and a rendered node that never reached\n * the document. They were handled in five separate places and drifted — the\n * throw paths consulted the boundary while the malformed paths recorded\n * directly, so a component under `@error-boundary` that returned garbage left\n * the boundary signal null, rendered no fallback, and failed the route, even\n * though the code called it \"the same content loss as a crash\".\n *\n * With no `boundary`, a failure in a branch, slot or component built detached\n * is attributed to the boundary its render sits under (`deferCrash`) and counts\n * as handled here; `attribution` says how it is logged if no boundary takes it.\n *\n * Callers still do their own logging, since the wording differs per failure.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"reportComponentFailure\",\"stability\":\"internal\",\"signature\":\"(el: Element, tag: string, error: Error, boundary: BoundaryInfo | null, attribution?: Attribution) => boolean\"} */\nexport function reportComponentFailure(\n el: Element,\n tag: string,\n error: Error,\n boundary: BoundaryInfo | null,\n attribution: Attribution = {}\n): boolean {\n if (!boundary && deferCrash(el, tag, error, attribution)) return true;\n return settleFailure(el, tag, error, boundary);\n}\n\n/** How an attributed crash is logged: `message` if no boundary takes it, `onCaptured` if one does. */\nexport interface Attribution {\n message?: string | null;\n onCaptured?: () => void;\n}\n\nfunction settleFailure(\n el: Element,\n tag: string,\n error: Error,\n boundary: BoundaryInfo | null\n): boolean {\n // A boundary in scope is not a boundary that accepted: an already-active one\n // with no free ancestor rejects, and that is as unhandled as having none.\n const accepted = boundary ? setBoundaryError(boundary, error) : false;\n\n if (isSSRMode()) {\n if (accepted) clearSSRRenderCrash(el);\n else recordSSRRenderCrash(el, tag, error);\n }\n\n return accepted;\n}\n\n/** A crash raised where no boundary was reachable, owned by the boundary its render sat under. */\ninterface AttributedCrash extends SSRRenderCrash {\n /** The boundary the branch, slot or component was built for: the crash waits until it is inside. */\n boundaryEl: Element;\n message: string | null;\n onCaptured?: () => void;\n ops: CrashOps;\n /** The outermost render it was attributed in; `0` outside any. */\n render: number;\n}\n\n/** The copy of core that attributed a crash answers these, against its own boundaries. */\ninterface CrashOps {\n locate: (el: Element) => BoundaryInfo | null;\n owner: (node: Node) => Element | null;\n hidden: (node: Node) => boolean;\n parent: (boundary: BoundaryInfo) => BoundaryInfo | null;\n settle: typeof settleFailure;\n}\n\nconst ops: CrashOps = {\n locate: registeredClosest,\n owner: slotOwnerOf,\n hidden: isInHiddenContent,\n parent: findParentBoundary,\n settle: settleFailure,\n};\n\nlet taskEndQueued = false;\n\n// A crash that is neither in place nor hidden when a render ends may belong to\n// content its caller inserts right after (a slot rendered from an effect): it\n// waits once, to the end of the task, before it is reported.\nfunction resolveAtTaskEnd(): void {\n if (taskEndQueued) return;\n taskEndQueued = true;\n queueMicrotask(() => {\n taskEndQueued = false;\n resolveAttributedCrashes('task');\n });\n}\n\n// Shared on `globalThis` for the reason the registry is: a second copy of core\n// must neither miss these nor resolve them in the middle of a render.\n\nfunction heldCrashes(): AttributedCrash[] | undefined {\n return pithyGlobals().__pithyAttributedCrashes as\n | AttributedCrash[]\n | undefined;\n}\n\nfunction renderDepth(change = 0): number {\n const g = pithyGlobals();\n return (g.__pithyRenderDepth = (g.__pithyRenderDepth ?? 0) + change);\n}\n\nfunction currentRender(): number {\n return renderDepth() > 0 ? (pithyGlobals().__pithyRenderId ?? 0) : 0;\n}\n\nfunction crashedElements(): WeakSet<Element> {\n const g = pithyGlobals();\n return (g.__pithyCrashedElements ??= new WeakSet()) as WeakSet<Element>;\n}\n\n/** Whether `el` crashed and was attributed; a retry would run its setup twice, which a build never does. */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"hasCrashed\",\"stability\":\"internal\",\"signature\":\"(el: Element) => boolean\"} */\nexport function hasCrashed(el: Element): boolean {\n return crashedElements().has(el);\n}\n\n/**\n * Brackets a render transaction: a template bind, or one structural update\n * that builds a branch and inserts it. Attributed crashes are resolved when the\n * outermost one ends, so a boundary hides its content only once everything in\n * it is bound and in place.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"withinRender\",\"stability\":\"internal\",\"signature\":\"<T>(fn: () => T) => T\"} */\nexport function withinRender<T>(fn: () => T): T {\n const g = pithyGlobals();\n if (renderDepth() === 0) g.__pithyRenderId = (g.__pithyRenderId ?? 0) + 1;\n const render = g.__pithyRenderId ?? 0;\n renderDepth(1);\n let failed = false;\n try {\n return fn();\n } catch (err) {\n failed = true;\n throw err;\n } finally {\n renderDepth(-1);\n // Never throws, so a failed render keeps its own error. Its caller disposes\n // what it bound, boundaries included, so its own crashes are only reported.\n if (failed && renderDepth() === 0) reportCrashesOf(render);\n else resolveAttributedCrashes();\n }\n}\n\n/**\n * Attributes a crash that reached no boundary through the DOM to the boundary\n * its render sits under (`boundaryContext`): a branch, slot or component built\n * detached. Returns `false` with no such context, so the caller handles the\n * crash as before.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"deferCrash\",\"stability\":\"internal\",\"signature\":\"(el: Element, tag: string, error: Error, attribution?: Attribution) => boolean\"} */\nexport function deferCrash(\n el: Element,\n tag: string,\n error: Error,\n { message = null, onCaptured }: Attribution = {}\n): boolean {\n const boundaryEl = boundaryContext();\n if (!boundaryEl) return false;\n crashedElements().add(el);\n takeAttributedCrash(el);\n (pithyGlobals().__pithyAttributedCrashes ??= []).push({\n el,\n tag,\n error,\n boundaryEl,\n message,\n onCaptured,\n ops,\n render: currentRender(),\n });\n if (renderDepth() === 0) resolveAtTaskEnd();\n return true;\n}\n\nfunction reportCrashesOf(render: number): void {\n const list = heldCrashes();\n if (!list?.length) return;\n for (const crash of list.splice(0)) {\n if (crash.render !== render) list.push(crash);\n else\n try {\n unhandled(crash);\n } catch (err) {\n reportResolveFailure([crash], err);\n }\n }\n}\n\nfunction logCrash(crash: AttributedCrash): void {\n if (crash.message) console.error(crash.message, crash.error);\n}\n\nfunction unhandled(crash: AttributedCrash): void {\n crash.ops.settle(crash.el, crash.tag, crash.error, null);\n logCrash(crash);\n}\n\n/**\n * Resolves attributed crashes once they are in place. Each goes to the nearest\n * registered boundary at its final position, exactly as a crash placed there\n * would, and within one resolution a boundary takes at most one error. In the\n * browser this waits for the\n * outermost render to end. A static render binds text once, so there the\n * component pass of the template that owns a boundary resolves its crashes\n * (`scope`), before that template's text is bound and after its components\n * ran. `task` runs at the end of the task; `collect` after the HTML is\n * serialized, and only records.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"resolveAttributedCrashes\",\"stability\":\"internal\",\"signature\":\"(mode?: 'render' | 'task' | 'collect', scope?: ParentNode) => void\"} */\nexport function resolveAttributedCrashes(\n mode: 'render' | 'task' | 'collect' = 'render',\n scope?: ParentNode\n): void {\n const list = heldCrashes();\n if (!list?.length) return;\n const midRender = mode === 'render' && renderDepth() > 0;\n if (midRender && (!scope || !isSSRMode())) return;\n const groups = new Map<BoundaryInfo, AttributedCrash[]>();\n const into = (boundary: BoundaryInfo, crash: AttributedCrash) => {\n const group = groups.get(boundary);\n if (group) group.push(crash);\n else groups.set(boundary, [crash]);\n };\n let waiting = false;\n for (const crash of list.splice(0)) {\n try {\n if (mode === 'collect') {\n unhandled(crash);\n continue;\n }\n if (midRender && !scope?.contains(crash.boundaryEl)) {\n list.push(crash);\n continue;\n }\n const target = placedAt(crash);\n if (partOfShown(crash, target)) {\n logCrash(crash);\n continue;\n }\n if (target) into(target, crash);\n // In its boundary with no registered one around it, or out of time.\n else if (\n mode === 'task' ||\n (!midRender && crash.boundaryEl.contains(crash.el))\n )\n unhandled(crash);\n else {\n // Not inserted yet: its caller may insert it right after.\n list.push(crash);\n waiting ||= !midRender;\n }\n } catch (err) {\n reportResolveFailure([crash], err);\n }\n }\n if (waiting) resolveAtTaskEnd();\n const innermostFirst = [...groups.entries()]\n .map(entry => ({ entry, depth: depthOf(entry[0].element) }))\n .sort((a, b) => b.depth - a.depth)\n .map(({ entry }) => entry);\n const handled = new Set<BoundaryInfo>();\n for (const [boundary, group] of innermostFirst) {\n try {\n resolveGroup(boundary, group, handled);\n } catch (err) {\n reportResolveFailure(group, err);\n }\n }\n}\n\nfunction reportResolveFailure(crashes: AttributedCrash[], err: unknown): void {\n for (const crash of crashes)\n if (isSSRMode()) recordSSRRenderCrash(crash.el, crash.tag, crash.error);\n console.error('❌ Resolving a component crash failed:', err);\n}\n\nfunction depthOf(node: Node): number {\n let depth = 0;\n for (let at = node.parentNode; at; at = at.parentNode) depth++;\n return depth;\n}\n\n/**\n * One boundary's crashes, content before fallback, so the outcome does not\n * depend on the order they happened in. Each is handled as a crash placed there\n * directly: a content crash goes to the boundary, a fallback crash too unless\n * the boundary already shows its fallback, in which case it goes further out.\n */\nfunction resolveGroup(\n boundary: BoundaryInfo,\n group: AttributedCrash[],\n handled: Set<BoundaryInfo>\n): void {\n const inFallback = (crash: AttributedCrash) =>\n !!boundary.fallbackElement?.contains(crash.el);\n for (const crash of group.filter(crash => !inFallback(crash)))\n if (partOfShown(crash, boundary)) logCrash(crash);\n else deliver(crash, boundary, handled);\n for (const crash of group.filter(inFallback)) {\n if (partOfShown(crash, boundary)) logCrash(crash);\n else\n deliver(\n crash,\n showsError(boundary) ? crash.ops.parent(boundary) : boundary,\n handled\n );\n }\n}\n\n// Slot content a portal moves out of its boundary goes to that boundary, as a\n// component crash in it does through the slot frame. Only the nodes a slot\n// rendered carry an owner: a root a component mounts during setup has none.\nfunction placedAt(crash: AttributedCrash): BoundaryInfo | null {\n const { el, ops } = crash;\n const at = ops.locate(el);\n if (at || !el.isConnected) return at;\n const owner = ops.owner(el);\n return owner && !owner.contains(el) ? ops.locate(owner) : null;\n}\n\n// A delivery earlier in the resolution can hide it. A nearest boundary still\n// free takes it, though an ancestor hides both, as it would a crash placed there.\nfunction partOfShown(\n crash: AttributedCrash,\n nearest: BoundaryInfo | null\n): boolean {\n return crash.ops.hidden(crash.el) && (!nearest || showsError(nearest));\n}\n\n// As `setBoundaryError` decides: by the signal, which a `batch()` sets before\n// the boundary's effect updates `isActive`.\nfunction showsError(boundary: BoundaryInfo): boolean {\n return untrack(() => boundary.errorSignal()) !== null;\n}\n\n/**\n * Hands a crash to the first boundary from `from` outward that is not already\n * showing an error, as `setBoundaryError` escalates a crash placed there. One\n * that reaches a boundary showing an error from this resolution is part of it.\n */\nfunction deliver(\n crash: AttributedCrash,\n from: BoundaryInfo | null,\n handled: Set<BoundaryInfo>\n): void {\n for (let at = from; at; at = crash.ops.parent(at)) {\n if (handled.has(at)) {\n logCrash(crash);\n return;\n }\n if (showsError(at)) continue;\n let accepted = false;\n try {\n accepted = crash.ops.settle(crash.el, crash.tag, crash.error, at);\n } catch (err) {\n // An effect of the boundary threw; the crash is settled only if it took it.\n if (!showsError(at)) reportResolveFailure([crash], err);\n else console.error('❌ Resolving a component crash failed:', err);\n handled.add(at);\n return;\n }\n if (accepted) {\n handled.add(at);\n crash.onCaptured?.();\n } else logCrash(crash);\n return;\n }\n unhandled(crash);\n}\n\n/**\n * Before a component inside a boundary's fallback renders in a static render,\n * that boundary takes its crashes, so content the component renders from the\n * error (text is bound once there) has it.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"resolveBeforeFallback\",\"stability\":\"internal\",\"signature\":\"(el: Element) => void\"} */\nexport function resolveBeforeFallback(el: Element): void {\n if (!isSSRMode() || !heldCrashes()?.length) return;\n const owner = el.closest('[data-fallback]')?.closest('[data-error]');\n if (owner) resolveAttributedCrashes('render', owner);\n}\n"]}
|
package/dist/compile/ssrMode.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssrMode.js","sourceRoot":"","sources":["../../src/compile/ssrMode.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;;;;GAMG;AACH,wHAAwH;AACxH,MAAM,UAAU,SAAS;IACvB,OAAO,CAAC,CAAC,YAAY,EAAE,CAAC,aAAa,CAAC;AACxC,CAAC"}
|
|
1
|
+
{"version":3,"file":"ssrMode.js","sourceRoot":"","sources":["../../src/compile/ssrMode.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;;;;GAMG;AACH,wHAAwH;AACxH,MAAM,UAAU,SAAS;IACvB,OAAO,CAAC,CAAC,YAAY,EAAE,CAAC,aAAa,CAAC;AACxC,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.ssr-mode\",\n \"title\": \"SSR Mode Detection\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { pithyGlobals } from '../types/globals';\n\n/**\n * Checks if the current execution is in SSR (Server-Side Rendering) mode.\n *\n * The SSR package sets `globalThis.__PITHY_SSR__` when the environment is active.\n * Core binding functions check this flag to skip reactive effects and evaluate\n * directives synchronously during SSR.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-mode\",\"name\":\"isSSRMode\",\"stability\":\"stable\",\"signature\":\"() => boolean\"} */\nexport function isSSRMode(): boolean {\n return !!pithyGlobals().__PITHY_SSR__;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textValue.js","sourceRoot":"","sources":["../../src/compile/textValue.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,2IAA2I;AAC3I,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
|
|
1
|
+
{"version":3,"file":"textValue.js","sourceRoot":"","sources":["../../src/compile/textValue.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,2IAA2I;AAC3I,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.dom-safety\",\n \"title\": \"DOM Text Safety\",\n \"category\": \"runtime\"\n}\n*/\n\n/**\n * Coerce an interpolated value to display text for a DOM **text node**\n * (`.nodeValue` / `.textContent`).\n *\n * Text nodes are inherently XSS-safe: the browser stores the string as literal\n * character data and never parses it as markup. So `{{ expr }}` interpolations\n * must NOT be HTML-escaped — escaping turns `>` into `>`, which then renders\n * as the *visible* text `>` (e.g. a TS signature `() => Promise<void>` shows\n * as `() => Promise<void>`). Assigning the raw string is both correct\n * and safe: `textNode.nodeValue = '<img onerror=…>'` creates a text node, not\n * an element.\n *\n * Internal helper — not part of the public package API (intentionally absent\n * from the barrel / package exports).\n *\n * @param input - Any value being interpolated into a text node\n * @returns The value as a plain string (no HTML escaping)\n */\n/** @codexApi {\"parent\":\"pithy.runtime.dom-safety\",\"name\":\"toTextValue\",\"stability\":\"internal\",\"signature\":\"(input: unknown) => string\"} */\nexport function toTextValue(input: unknown): string {\n return String(input);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trimBlankEdges.d.ts","sourceRoot":"","sources":["../../src/compile/trimBlankEdges.ts"],"names":[],"mappings":"AAEA,wBAAgB,cAAc,CAAC,CAAC,EAC9B,KAAK,EAAE,CAAC,EAAE,EACV,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,GACjC,CAAC,EAAE,CAUL"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const ASCII_WHITESPACE = /^[ \t\n\f\r]*$/;
|
|
2
|
+
export function trimBlankEdges(nodes, textOf) {
|
|
3
|
+
const blank = (node) => {
|
|
4
|
+
const text = textOf(node);
|
|
5
|
+
return text !== null && ASCII_WHITESPACE.test(text);
|
|
6
|
+
};
|
|
7
|
+
let start = 0;
|
|
8
|
+
let end = nodes.length;
|
|
9
|
+
while (start < end && blank(nodes[start]))
|
|
10
|
+
start++;
|
|
11
|
+
while (end > start && blank(nodes[end - 1]))
|
|
12
|
+
end--;
|
|
13
|
+
return nodes.slice(start, end);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=trimBlankEdges.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trimBlankEdges.js","sourceRoot":"","sources":["../../src/compile/trimBlankEdges.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAE1C,MAAM,UAAU,cAAc,CAC5B,KAAU,EACV,MAAkC;IAElC,MAAM,KAAK,GAAG,CAAC,IAAO,EAAE,EAAE;QACxB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAC1B,OAAO,IAAI,KAAK,IAAI,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC,CAAC;IACF,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC;IACvB,OAAO,KAAK,GAAG,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAAE,KAAK,EAAE,CAAC;IACnD,OAAO,GAAG,GAAG,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QAAE,GAAG,EAAE,CAAC;IACnD,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC","sourcesContent":["const ASCII_WHITESPACE = /^[ \\t\\n\\f\\r]*$/;\n\nexport function trimBlankEdges<T>(\n nodes: T[],\n textOf: (node: T) => string | null\n): T[] {\n const blank = (node: T) => {\n const text = textOf(node);\n return text !== null && ASCII_WHITESPACE.test(text);\n };\n let start = 0;\n let end = nodes.length;\n while (start < end && blank(nodes[start])) start++;\n while (end > start && blank(nodes[end - 1])) end--;\n return nodes.slice(start, end);\n}\n"]}
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAkCF,uHAAuH;AACvH,MAAM,CAAC,MAAM,aAAa,GAAgB;IACxC,sBAAsB,EAAE,IAAI;IAC5B,cAAc,EAAE,yBAAyB;IACzC,iBAAiB,EAAE,GAAG;IACtB,eAAe,EAAE,KAAK,EAAE,uDAAuD;IAC/E,qBAAqB,EAAE,WAAW,EAAE,+EAA+E;CACpH,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAkCF,uHAAuH;AACvH,MAAM,CAAC,MAAM,aAAa,GAAgB;IACxC,sBAAsB,EAAE,IAAI;IAC5B,cAAc,EAAE,yBAAyB;IACzC,iBAAiB,EAAE,GAAG;IACtB,eAAe,EAAE,KAAK,EAAE,uDAAuD;IAC/E,qBAAqB,EAAE,WAAW,EAAE,+EAA+E;CACpH,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.config.system\",\n \"title\": \"Framework Configuration System\", \n \"category\": \"runtime\"\n}\n*/\n\nexport interface PithyConfig {\n /**\n * Enable visual highlighting of DOM updates in development mode.\n * NOTE: Only works with span-wrapped interpolations (textInterpolationMode: 'span' or 'auto').\n * Text nodes cannot be styled, so no visual feedback in 'text-node' mode.\n * @default true\n */\n devHighlightDomUpdates?: boolean;\n\n /** Color for update highlights @default 'rgba(11, 205, 118, 0.8)' */\n highlightColor?: string;\n\n /** Duration of highlight animation in seconds @default 0.3 */\n highlightDuration?: number;\n\n /**\n * Automatically wrap signal expressions in <span> for visual feedback.\n * Only applies when textInterpolationMode is 'auto'.\n * @default false\n */\n autoWrapSignals?: boolean;\n\n /**\n * How to render text interpolations:\n * - 'text-node': Maximum performance, bare text nodes (no visual feedback)\n * - 'span': Wrapped in spans, visual feedback enabled (extra DOM nodes)\n * - 'auto': Smart mode - respects autoWrapSignals setting\n * @default 'text-node'\n */\n textInterpolationMode?: 'text-node' | 'span' | 'auto';\n}\n\n/** @codexApi {\"parent\":\"pithy.config.system\",\"name\":\"defaultConfig\",\"stability\":\"stable\",\"signature\":\"PithyConfig\"} */\nexport const defaultConfig: PithyConfig = {\n devHighlightDomUpdates: true,\n highlightColor: 'rgba(11, 205, 118, 0.8)',\n highlightDuration: 0.3,\n autoWrapSignals: false, // Keep false for maximum performance (text nodes only)\n textInterpolationMode: 'text-node', // Use text nodes with comment anchors (Solid.js approach) for best performance\n};\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './compile';
|
|
3
|
-
export * from './runtime';
|
|
4
|
-
export * from './utilities';
|
|
5
|
-
export * from './interfaces';
|
|
6
|
-
export * from './a11y';
|
|
1
|
+
export * from './types/index.js';
|
|
2
|
+
export * from './compile/index.js';
|
|
3
|
+
export * from './runtime/index.js';
|
|
4
|
+
export * from './utilities/index.js';
|
|
5
|
+
export * from './interfaces/index.js';
|
|
6
|
+
export * from './a11y/index.js';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './compile';
|
|
3
|
-
export * from './runtime';
|
|
4
|
-
export * from './utilities';
|
|
5
|
-
export * from './interfaces';
|
|
6
|
-
export * from './a11y';
|
|
1
|
+
export * from './types/index.js';
|
|
2
|
+
export * from './compile/index.js';
|
|
3
|
+
export * from './runtime/index.js';
|
|
4
|
+
export * from './utilities/index.js';
|
|
5
|
+
export * from './interfaces/index.js';
|
|
6
|
+
export * from './a11y/index.js';
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC","sourcesContent":["export * from './types';\nexport * from './compile';\nexport * from './runtime';\nexport * from './utilities';\nexport * from './interfaces';\nexport * from './a11y';\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './ref.interface';
|
|
2
|
-
export * from './ref-signal.interface';
|
|
1
|
+
export * from './ref.interface.js';
|
|
2
|
+
export * from './ref-signal.interface.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/interfaces/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './ref.interface';
|
|
2
|
-
export * from './ref-signal.interface';
|
|
1
|
+
export * from './ref.interface.js';
|
|
2
|
+
export * from './ref-signal.interface.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC","sourcesContent":["export * from './ref.interface';\nexport * from './ref-signal.interface';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref-signal.interface.js","sourceRoot":"","sources":["../../src/interfaces/ref-signal.interface.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ref-signal.interface.js","sourceRoot":"","sources":["../../src/interfaces/ref-signal.interface.ts"],"names":[],"mappings":"","sourcesContent":["export interface RefSignal<T extends HTMLElement = HTMLElement> {\n (): T | null;\n set: (el: T | null) => void;\n current: T | null;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.interface.js","sourceRoot":"","sources":["../../src/interfaces/ref.interface.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ref.interface.js","sourceRoot":"","sources":["../../src/interfaces/ref.interface.ts"],"names":[],"mappings":"","sourcesContent":["export interface Ref<T> {\n readonly current: T | null;\n set: (el: T | null) => void;\n}\n"]}
|