/** * Router Loader Resolution * * Loader execution, memoization, and error handling utilities. */ import type { ReactNode } from "react"; import type { EntryData } from "../server/context"; import type { HandlerContext, LoaderDataResult, ErrorBoundaryHandler, ErrorInfo } from "../types"; /** * Internal callback signature for loader error notifications. * This is a simplified callback for internal use in wrapLoaderWithErrorHandling. * The caller (wrapLoaderPromise in router.ts) bridges this to the full OnErrorCallback. */ export type LoaderErrorCallback = (error: unknown, context: { segmentId: string; loaderName: string; handledByBoundary: boolean; }) => void; /** * Wrap a loader promise with error handling for deferred client-side resolution. * Catches errors and converts them to LoaderDataResult objects that include * error info and pre-rendered fallback UI when an error boundary is available. * * @param onError - Optional callback invoked when loader errors occur. * This has a simplified signature for internal use - the caller (typically * wrapLoaderPromise in router.ts) is responsible for bridging to the full * OnErrorCallback with complete request context (request, url, env, etc.). */ export declare function wrapLoaderWithErrorHandling(promise: Promise, entry: EntryData, segmentId: string, pathname: string, findNearestErrorBoundary: (entry: EntryData | null) => ReactNode | ErrorBoundaryHandler | null, createErrorInfo: (error: unknown, segmentId: string, segmentType: ErrorInfo["segmentType"]) => ErrorInfo, onError?: LoaderErrorCallback): Promise>; /** * Set up the use() method on handler context to access loaders and handles. * * For loaders: Lazily runs loaders, memoizes results per request. * For handles: Returns a push function bound to the current segment. * * Includes cycle detection: tracks dependency edges between loaders and * throws on circular dependencies to prevent deadlocks. */ export declare function setupLoaderAccess(ctx: HandlerContext, loaderPromises: Map>): void; /** * Set up ctx.use() for pre-rendering (build-time). * Handles push to HandleStore; loaders throw with a clear error. */ export declare function setupBuildUse(ctx: HandlerContext): void; /** * Set up ctx.use() for proactive caching (silent mode). * Handles are silently ignored (no push to HandleStore). * Loaders work normally but with fresh memoization and cycle detection. * * This prevents duplicate handle data (breadcrumbs, meta) from being * pushed to the response stream during background proactive caching. */ export declare function setupLoaderAccessSilent(ctx: HandlerContext, loaderPromises: Map>): void; /** * Conditional execution based on revalidation * Evaluates revalidation logic lazily, then executes appropriate callback * * @param shouldRevalidate - Async function that determines if revalidation is needed * @param onRevalidate - Callback executed if revalidation returns true * @param onSkip - Callback executed if revalidation returns false * @returns Result from either onRevalidate or onSkip */ export declare function revalidate(shouldRevalidate: () => Promise, onRevalidate: () => Promise, onSkip: () => T): Promise; //# sourceMappingURL=loader-resolution.d.ts.map