import type { InitialRSCPayload, Segment } from '../../../shared/lib/app-router-types'; import { RenderStage } from '../staged-rendering'; import type { ValidationBoundaryTracking } from './boundary-tracking'; import { type LoaderTree } from '../../lib/app-dir-module'; import type { GetDynamicParamFromSegment } from '../app-render'; import type { Instant } from '../../../build/segment-config/app/app-segment-config'; import { Readable } from 'node:stream'; import type { NextParsedUrlQuery } from '../../request-meta'; type ClientReferenceManifest = Record; /** Used to identify a segment. Conceptually similar to request keys in the Client Segment Cache. */ export type SegmentPath = string & { _tag: 'SegmentPath'; }; /** * Isomorphic to a FlightRouterState, but with extra data attached. * Carries the segment path for each segment so we can easily get it from the cache. * */ export type RouteTree = { path: SegmentPath; segment: Segment; module: null | { type: 'layout' | 'page'; instantConfig: Instant | null; conventionPath: string; createInstantStack: (() => Error) | null; }; slots: { [parallelRouteKey: string]: RouteTree; } | null; }; /** * The entrypoint. Traverses the loader tree, finds `unstable_instant` configs, * and determines what navigations we should validate. * */ export declare function findNavigationsToValidate(rootLoaderTree: LoaderTree, getDynamicParamFromSegment: GetDynamicParamFromSegment, query: NextParsedUrlQuery | null): Promise<{ tree: RouteTree; treeNodes: Map; validationTasks: { target: SegmentPath; parents: SegmentPath[]; }[]; segmentsWithInstantConfigs: SegmentPath[]; }>; export type SegmentStage = RenderStage.Static | RenderStage.Runtime | RenderStage.Dynamic; export type StageChunks = Record; export type StageEndTimes = { [RenderStage.Static]: number; [RenderStage.Runtime]: number; }; /** * Splits an existing staged stream (represented as arrays of chunks) * into separate staged streams (also in arrays-of-chunks form), one for each segment. * */ export declare function collectStagedSegmentData(fullPageChunks: StageChunks, fullPageDebugChunks: Uint8Array[] | null, startTime: number, hasRuntimePrefetch: boolean, clientReferenceManifest: ClientReferenceManifest): Promise<{ cache: SegmentCache; payload: InitialRSCPayload; stageEndTimes: StageEndTimes; }>; /** * Creates a late-release stream for a given payload. * When `renderSignal` is triggered, the stream will release late chunks * to provide extra debug info. * */ export declare function createCombinedPayloadStream(createPayload: (extraChunksReleaseSignal: AbortSignal) => Promise, renderSignal: AbortSignal, clientReferenceManifest: ClientReferenceManifest, startTime: number, isDebugChannelEnabled: boolean): Promise<{ stream: Readable; debugStream: Readable | null; }>; /** * Builds a combined RSC payload to represent what we'd render in the browser * when the specified navigation navigation is started, assuming that all the new segments * segments were prefetched. * * ### Background * * For a client navigation, we conceptually split the segments into two groups: * * #### Outer: the shared parent segments * These are common between the old view and the new one. * They're meant to be fully resolved, since the browser already loaded them before. * * #### Inner: the new subtree(s) * These segments are unique to the new view. For these segments, we first display * prefetched content (either static or runtime, depending on the configuration). * * When validating a navigation, we're validating that rendering the inner segments * (which are going to be partial) won't block, i.e. any holes are properly guarded with Suspense. * */ export declare function createCombinedPayload(initialRSCPayload: InitialRSCPayload, cache: SegmentCache, validationRouteTree: RouteTree, /** * The innermost segment that is shared. Anything below will be in the new subtree. * * TODO(instant-validation): * this is too limited, and cannot support multiple parallel slots * being in the new subtree at once. * */ navigationParent: SegmentPath, releaseSignal: AbortSignal, boundaryState: ValidationBoundaryTracking, clientReferenceManifest: ClientReferenceManifest, stageEndTimes: StageEndTimes, /** Only used when retrying a failed validation to see what caused a dynamic hole. */ useRuntimeStageForPartialSegments: boolean, /** mutable out-param - Which stages are actually used in the resulting payload */ usedSegmentKinds: Set): Promise; export type SegmentCache = Map; type SegmentCacheItem = { chunks: StageChunks; debugChunks: Uint8Array[] | null; }; export {};