|
22 | 22 | * the platform/tier conditions pick the same build the app runs) and |
23 | 23 | * declared here with their signatures spelled out, because the main |
24 | 24 | * entries mark them `@internal` and strip them from their declarations. |
| 25 | + * The boundary primitives behind `Errored`, `Loading`, and `Reveal` are |
| 26 | + * read back the same way (real on both entries), for renderers that |
| 27 | + * build boundaries without the components. |
25 | 28 | */ |
26 | 29 | import * as core from "solid-js"; |
27 | | -import type { ServerErrorHook, ServerErrorSite } from "solid-js"; |
| 30 | +import type { Accessor, RevealOrder, ServerErrorHook, ServerErrorSite } from "solid-js"; |
28 | 31 |
|
29 | 32 | export { |
30 | 33 | mergeSources, |
@@ -117,3 +120,22 @@ export const materializeContainerTrace: (marker: { |
117 | 120 | $tr: AsyncIterable<any> | { __SEROVAL_STREAM__: true }; |
118 | 121 | $ta?: number; |
119 | 122 | }) => unknown = core.materializeContainerTrace as any; |
| 123 | + |
| 124 | +/** The primitive behind `<Errored>`: `fn()`, or `fallback(error, reset)` once something under it throws. */ |
| 125 | +export const createErrorBoundary: <T, U>( |
| 126 | + fn: () => T, |
| 127 | + fallback: (error: Accessor<unknown>, reset: () => void) => U |
| 128 | +) => Accessor<T | U> = core.createErrorBoundary; |
| 129 | + |
| 130 | +/** The primitive behind `<Loading>`: `fallback()` while async reads under `fn` are pending, else `fn()`. */ |
| 131 | +export const createLoadingBoundary: <T, U>( |
| 132 | + fn: () => T, |
| 133 | + fallback: () => U, |
| 134 | + options?: { on?: () => any } |
| 135 | +) => Accessor<T | U> = core.createLoadingBoundary; |
| 136 | + |
| 137 | +/** The primitive behind `<Reveal>`: coordinates when the loading boundaries under `fn` reveal. */ |
| 138 | +export const createRevealOrder: <T>( |
| 139 | + fn: () => T, |
| 140 | + options?: { order?: () => RevealOrder; collapsed?: () => boolean } |
| 141 | +) => T = core.createRevealOrder; |
0 commit comments