UNPKG

next

Version:

The React Framework

46 lines (45 loc) 3.39 kB
import type { CacheNodeSeedData, FlightRouterState, ScrollRef } from '../../../shared/lib/app-router-types'; import type { CacheNode } from '../../../shared/lib/app-router-types'; import type { HeadData } from '../../../shared/lib/app-router-types'; import type { NormalizedFlightData } from '../../flight-data-helpers'; import { FreshnessPolicy } from '../router-reducer/ppr-navigations'; import { type RouteTree, type FulfilledRouteCacheEntry } from './cache'; import type { PageVaryPath } from './vary-path'; import type { AppRouterState } from '../router-reducer/router-reducer-types'; import { ScrollBehavior } from '../router-reducer/router-reducer-types'; /** * Navigate to a new URL, using the Segment Cache to construct a response. * * To allow for synchronous navigations whenever possible, this is not an async * function. It returns a promise only if there's no matching prefetch in * the cache. Otherwise it returns an immediate result and uses Suspense/RSC to * stream in any missing data. */ export declare function navigate(state: AppRouterState, url: URL, currentUrl: URL, currentRenderedSearch: string, currentCacheNode: CacheNode | null, currentFlightRouterState: FlightRouterState, nextUrl: string | null, freshnessPolicy: FreshnessPolicy, scrollBehavior: ScrollBehavior, navigateType: 'push' | 'replace'): AppRouterState | Promise<AppRouterState>; export declare function navigateToKnownRoute(now: number, state: AppRouterState, url: URL, canonicalUrl: string, navigationSeed: NavigationSeed, currentUrl: URL, currentRenderedSearch: string, currentCacheNode: CacheNode | null, currentFlightRouterState: FlightRouterState, freshnessPolicy: FreshnessPolicy, nextUrl: string | null, scrollBehavior: ScrollBehavior, navigateType: 'push' | 'replace', debugInfo: Array<unknown> | null, routeCacheEntry: FulfilledRouteCacheEntry | null): AppRouterState; export declare function completeHardNavigation(state: AppRouterState, url: URL, navigateType: 'push' | 'replace'): AppRouterState; export declare function completeSoftNavigation(oldState: AppRouterState, url: URL, referringNextUrl: string | null, tree: FlightRouterState, cache: CacheNode, renderedSearch: string, canonicalUrl: string, navigateType: 'push' | 'replace', scrollBehavior: ScrollBehavior, scrollRef: ScrollRef | null, collectedDebugInfo: Array<unknown> | null): AppRouterState; export declare function completeTraverseNavigation(state: AppRouterState, url: URL, renderedSearch: string, cache: CacheNode, tree: FlightRouterState, nextUrl: string | null): { canonicalUrl: string; renderedSearch: string; pushRef: { pendingPush: boolean; mpaNavigation: boolean; preserveCustomHistoryState: boolean; }; focusAndScrollRef: import("../router-reducer/router-reducer-types").FocusAndScrollRef; cache: CacheNode; tree: FlightRouterState; nextUrl: string | null; previousNextUrl: null; debugInfo: null; }; export type NavigationSeed = { renderedSearch: string; routeTree: RouteTree; metadataVaryPath: PageVaryPath | null; data: CacheNodeSeedData | null; head: HeadData | null; dynamicStaleAt: number; }; export declare function convertServerPatchToFullTree(now: number, currentTree: FlightRouterState, flightData: Array<NormalizedFlightData> | null, renderedSearch: string, dynamicStaleTimeSeconds: number): NavigationSeed;