72 lines
3.0 KiB
TypeScript
72 lines
3.0 KiB
TypeScript
import type { DynamicParamTypesShort, PrefetchHints } from '../../shared/lib/app-router-types';
|
|
import type { ManifestNode } from '../../build/webpack/plugins/flight-manifest-plugin';
|
|
import { type SegmentRequestKey } from '../../shared/lib/segment-cache/segment-value-encoding';
|
|
export type RootTreePrefetch = {
|
|
buildId?: string;
|
|
tree: TreePrefetch;
|
|
staleTime: number;
|
|
};
|
|
export type TreePrefetchParam = {
|
|
type: DynamicParamTypesShort;
|
|
key: string | null;
|
|
siblings: readonly string[] | null;
|
|
};
|
|
export type TreePrefetch = {
|
|
name: string;
|
|
param: TreePrefetchParam | null;
|
|
slots: null | {
|
|
[parallelRouteKey: string]: TreePrefetch;
|
|
};
|
|
/** Bitmask of PrefetchHint flags for this segment and its subtree */
|
|
prefetchHints: number;
|
|
};
|
|
export type SegmentPrefetch = {
|
|
buildId?: string;
|
|
rsc: React.ReactNode | null;
|
|
isPartial: boolean;
|
|
staleTime: number;
|
|
/**
|
|
* The set of params that this segment's output depends on. Used by the client
|
|
* cache to determine which entries can be reused across different param
|
|
* values.
|
|
* - `null` means vary params were not tracked (conservative: assume all
|
|
* params matter)
|
|
* - Empty set means no params were accessed (segment is reusable for any
|
|
* param values)
|
|
*/
|
|
varyParams: Set<string> | null;
|
|
};
|
|
/**
|
|
* A node in the inlined prefetch tree. Wraps a SegmentPrefetch with child
|
|
* slots so all segments for a route can be bundled into a single response.
|
|
*
|
|
* This is a separate type from SegmentPrefetch because the inlined flow is
|
|
* still gated behind a feature flag. Eventually inlining will always be
|
|
* enabled, and the per-segment and inlined paths will merge.
|
|
*/
|
|
export type InlinedSegmentPrefetch = {
|
|
segment: SegmentPrefetch;
|
|
slots: null | {
|
|
[parallelRouteKey: string]: InlinedSegmentPrefetch;
|
|
};
|
|
};
|
|
/**
|
|
* The response shape for the /_inlined prefetch endpoint. Contains all segment
|
|
* data for a route bundled into a single tree structure, plus the head segment.
|
|
*/
|
|
export type InlinedPrefetchResponse = {
|
|
tree: InlinedSegmentPrefetch;
|
|
head: SegmentPrefetch;
|
|
};
|
|
export declare function collectSegmentData(isCacheComponentsEnabled: boolean, fullPageDataBuffer: Buffer, staleTime: number, clientModules: ManifestNode, serverConsumerManifest: any, prefetchInlining: boolean, hints: PrefetchHints | null): Promise<Map<SegmentRequestKey, Buffer>>;
|
|
/**
|
|
* Compute prefetch hints for a route by measuring segment sizes and deciding
|
|
* which segments should be inlined. Only runs at build time. The results are
|
|
* written to prefetch-hints.json and loaded at server startup.
|
|
*
|
|
* This is a separate pass from collectSegmentData so that the inlining
|
|
* decisions can be fed back into collectSegmentData to control which segments
|
|
* are output as separate entries vs. inlined into their parent.
|
|
*/
|
|
export declare function collectPrefetchHints(fullPageDataBuffer: Buffer, staleTime: number, clientModules: ManifestNode, serverConsumerManifest: any, maxSize: number, maxBundleSize: number): Promise<PrefetchHints>;
|