/** * errorScope — setup-time error boundary for the calling component's subtree * (docs/rfc-async.md §4). Not a wrapper component: call it inside setup and * the component's own subtree is scoped. * * const Widget = component((ctx) => { * errorScope({ fallback: (e, retry) => }); * return () => ; * }); * * Catches: the component's own render throws, and descendant setup / render / * reactive re-render throws (routed here by handleComponentError's parent- * chain walk). Also receives unhandled data errors bubbled by `match()` * (a cell errored with no `error` arm). * * Does NOT catch: fetcher rejections (they land on the cell's `.error` — * value-first), or DOM event-handler throws (those go to app `onError`). * * `retry` is a real teardown: the subtree renders under a keyed Fragment * whose key bumps on retry, forcing unmount (every descendant effect * stopped, onUnmounted run) + fresh mount — not a flag flip over stale state. */ import { type JSXElement } from './jsx-runtime.js'; import type { ViewFn } from './component-types.js'; import type { ComponentInstance } from './app-types.js'; export interface ErrorScopeOptions { /** Rendered in place of the subtree while errored. Omitted ⇒ renders nothing. */ fallback?: (error: Error, retry: () => void) => JSXElement; /** Observer — called before the fallback renders. Its own throws are swallowed. */ onError?: (error: Error, instance: ComponentInstance | null, info: string) => void; } /** DI token under which a scope's handle lives on the owning ctx. @internal */ export declare const ERROR_SCOPE_TOKEN: import("./internals.js").InjectionToken; /** Stage (or clear, with null) the server-caught error for the next scope. @internal */ export declare function seedErrorScopeError(error: Error | null): void; /** @internal */ export interface ErrorScopeHandle { /** Returns true when this scope takes the error (renders its fallback). */ handle(err: Error, instance: ComponentInstance | null, info: string): boolean; } interface InternalErrorScope { state: { error: Error | null; generation: number; }; retry: () => void; fallback?: (error: Error, retry: () => void) => JSXElement; } /** * Scope the calling component's subtree. Setup-only. */ export declare function errorScope(options: ErrorScopeOptions): void; /** * Wrap a component's render fn with its errorScope view: fallback while * errored, otherwise the subtree under the generation-keyed Fragment. * Called by the renderer after setup returns (renderFn exists only then). * * @internal */ export declare function wrapErrorScopeRender(original: ViewFn, es: InternalErrorScope): ViewFn; /** @internal — renderer hook: wrap if the ctx carries a scope. */ export declare function applyErrorScope(ctx: unknown, renderFn: ViewFn): ViewFn; export {}; //# sourceMappingURL=error-scope.d.ts.map