vinext 0.0.53 → 0.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/inline-css.d.ts +7 -0
- package/dist/build/inline-css.js +50 -0
- package/dist/build/inline-css.js.map +1 -0
- package/dist/build/prerender.js +2 -1
- package/dist/build/prerender.js.map +1 -1
- package/dist/check.js +4 -0
- package/dist/check.js.map +1 -1
- package/dist/client/navigation-runtime.d.ts +2 -1
- package/dist/client/navigation-runtime.js.map +1 -1
- package/dist/client/window-next.d.ts +7 -0
- package/dist/client/window-next.js.map +1 -1
- package/dist/config/next-config.d.ts +83 -1
- package/dist/config/next-config.js +131 -2
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.js +13 -0
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.d.ts +11 -1
- package/dist/entries/app-browser-entry.js +16 -6
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.d.ts +8 -1
- package/dist/entries/app-rsc-entry.js +18 -5
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-rsc-manifest.d.ts +21 -1
- package/dist/entries/app-rsc-manifest.js +6 -4
- package/dist/entries/app-rsc-manifest.js.map +1 -1
- package/dist/entries/pages-client-entry.d.ts +4 -1
- package/dist/entries/pages-client-entry.js +18 -2
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-server-entry.js +82 -4
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/entries/runtime-entry-module.d.ts +1 -10
- package/dist/entries/runtime-entry-module.js +2 -12
- package/dist/entries/runtime-entry-module.js.map +1 -1
- package/dist/index.js +63 -5
- package/dist/index.js.map +1 -1
- package/dist/plugins/remove-console.d.ts +16 -0
- package/dist/plugins/remove-console.js +176 -0
- package/dist/plugins/remove-console.js.map +1 -0
- package/dist/routing/app-route-graph.d.ts +24 -1
- package/dist/routing/app-route-graph.js +52 -4
- package/dist/routing/app-route-graph.js.map +1 -1
- package/dist/routing/app-router.d.ts +2 -2
- package/dist/routing/app-router.js +2 -2
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/file-matcher.d.ts +21 -1
- package/dist/routing/file-matcher.js +39 -1
- package/dist/routing/file-matcher.js.map +1 -1
- package/dist/routing/pages-router.d.ts +1 -1
- package/dist/routing/pages-router.js +10 -3
- package/dist/routing/pages-router.js.map +1 -1
- package/dist/server/api-handler.js +1 -1
- package/dist/server/app-browser-entry.js +25 -16
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-browser-navigation-controller.d.ts +2 -0
- package/dist/server/app-browser-navigation-controller.js +4 -0
- package/dist/server/app-browser-navigation-controller.js.map +1 -1
- package/dist/server/app-elements-wire.d.ts +13 -4
- package/dist/server/app-elements-wire.js +10 -1
- package/dist/server/app-elements-wire.js.map +1 -1
- package/dist/server/app-elements.d.ts +2 -2
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-elements.js.map +1 -1
- package/dist/server/app-fallback-renderer.d.ts +15 -5
- package/dist/server/app-fallback-renderer.js +10 -4
- package/dist/server/app-fallback-renderer.js.map +1 -1
- package/dist/server/app-inline-css-client.d.ts +7 -0
- package/dist/server/app-inline-css-client.js +37 -0
- package/dist/server/app-inline-css-client.js.map +1 -0
- package/dist/server/app-page-boundary.d.ts +21 -1
- package/dist/server/app-page-boundary.js +28 -3
- package/dist/server/app-page-boundary.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +7 -3
- package/dist/server/app-page-cache.js +7 -7
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +10 -1
- package/dist/server/app-page-dispatch.js +126 -79
- package/dist/server/app-page-dispatch.js.map +1 -1
- package/dist/server/app-page-element-builder.js +12 -28
- package/dist/server/app-page-element-builder.js.map +1 -1
- package/dist/server/app-page-render-identity.d.ts +22 -0
- package/dist/server/app-page-render-identity.js +42 -0
- package/dist/server/app-page-render-identity.js.map +1 -0
- package/dist/server/app-page-render.d.ts +8 -1
- package/dist/server/app-page-render.js +4 -1
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-request.d.ts +6 -3
- package/dist/server/app-page-request.js +5 -2
- package/dist/server/app-page-request.js.map +1 -1
- package/dist/server/app-page-response.js +2 -2
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +15 -0
- package/dist/server/app-page-route-wiring.js +7 -5
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-stream.d.ts +11 -0
- package/dist/server/app-page-stream.js +1 -0
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-route-handler-response.js +37 -5
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-rsc-handler.d.ts +14 -3
- package/dist/server/app-rsc-handler.js +45 -5
- package/dist/server/app-rsc-handler.js.map +1 -1
- package/dist/server/app-rsc-request-normalization.d.ts +2 -1
- package/dist/server/app-rsc-request-normalization.js +3 -2
- package/dist/server/app-rsc-request-normalization.js.map +1 -1
- package/dist/server/app-server-action-execution.d.ts +21 -3
- package/dist/server/app-server-action-execution.js +42 -7
- package/dist/server/app-server-action-execution.js.map +1 -1
- package/dist/server/app-ssr-entry.d.ts +6 -0
- package/dist/server/app-ssr-entry.js +22 -7
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-error-meta.js +3 -3
- package/dist/server/app-ssr-error-meta.js.map +1 -1
- package/dist/server/app-ssr-stream.d.ts +2 -1
- package/dist/server/app-ssr-stream.js +176 -31
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/client-trace-metadata.d.ts +31 -0
- package/dist/server/client-trace-metadata.js +83 -0
- package/dist/server/client-trace-metadata.js.map +1 -0
- package/dist/server/cookie-utils.d.ts +13 -0
- package/dist/server/cookie-utils.js +20 -0
- package/dist/server/cookie-utils.js.map +1 -0
- package/dist/server/dev-server.d.ts +8 -1
- package/dist/server/dev-server.js +34 -5
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/html.d.ts +2 -1
- package/dist/server/html.js +6 -1
- package/dist/server/html.js.map +1 -1
- package/dist/server/isr-cache.d.ts +7 -5
- package/dist/server/isr-cache.js +17 -6
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/middleware-runtime.js +1 -2
- package/dist/server/middleware-runtime.js.map +1 -1
- package/dist/server/pages-document-initial-props.d.ts +7 -0
- package/dist/server/pages-document-initial-props.js +14 -0
- package/dist/server/pages-document-initial-props.js.map +1 -0
- package/dist/server/pages-page-data.js +3 -0
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-method.d.ts +48 -0
- package/dist/server/pages-page-method.js +19 -0
- package/dist/server/pages-page-method.js.map +1 -0
- package/dist/server/pages-page-response.d.ts +6 -0
- package/dist/server/pages-page-response.js +10 -3
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/pages-serializable-props.d.ts +25 -0
- package/dist/server/pages-serializable-props.js +69 -0
- package/dist/server/pages-serializable-props.js.map +1 -0
- package/dist/server/prod-server.js +3 -0
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/server-action-not-found.js +3 -2
- package/dist/server/server-action-not-found.js.map +1 -1
- package/dist/server/static-file-cache.js +2 -1
- package/dist/server/static-file-cache.js.map +1 -1
- package/dist/shims/app-router-scroll-state.d.ts +4 -2
- package/dist/shims/app-router-scroll-state.js +16 -3
- package/dist/shims/app-router-scroll-state.js.map +1 -1
- package/dist/shims/app-router-scroll.d.ts +16 -2
- package/dist/shims/app-router-scroll.js +18 -3
- package/dist/shims/app-router-scroll.js.map +1 -1
- package/dist/shims/cache.d.ts +6 -0
- package/dist/shims/cache.js +7 -0
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/error.js +3 -0
- package/dist/shims/error.js.map +1 -1
- package/dist/shims/headers.d.ts +7 -0
- package/dist/shims/headers.js +9 -1
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/internal/app-route-detection.d.ts +37 -0
- package/dist/shims/internal/app-route-detection.js +69 -0
- package/dist/shims/internal/app-route-detection.js.map +1 -0
- package/dist/shims/link.d.ts +18 -2
- package/dist/shims/link.js +70 -6
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +7 -6
- package/dist/shims/metadata.js +9 -5
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation.d.ts +1 -2
- package/dist/shims/navigation.js +63 -12
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/router.d.ts +5 -0
- package/dist/shims/router.js +14 -4
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script.d.ts +11 -1
- package/dist/shims/script.js +75 -6
- package/dist/shims/script.js.map +1 -1
- package/dist/utils/path.d.ts +13 -0
- package/dist/utils/path.js +16 -0
- package/dist/utils/path.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-page-element-builder.js","names":[],"sources":["../../src/server/app-page-element-builder.ts"],"sourcesContent":["import { createElement } from \"react\";\nimport { markDynamicUsage, markRenderRequestApiUsage } from \"vinext/shims/headers\";\nimport { makeThenableParams } from \"vinext/shims/thenable-params\";\nimport { resolveActiveParallelRouteHeadInputs, resolveAppPageHead } from \"./app-page-head.js\";\nimport {\n buildAppPageElements,\n createAppPageTreePath,\n type AppPageErrorModule,\n type AppPageModule,\n type AppPageRouteWiringRoute,\n type AppPageSlotOverride,\n} from \"./app-page-route-wiring.js\";\nimport { AppElementsWire, type AppElements, type AppElementsInterception } from \"./app-elements.js\";\nimport type { AppPageParams } from \"./app-page-boundary.js\";\nimport { DEFAULT_GLOBAL_ERROR_MODULE } from \"./default-global-error-module.js\";\nimport { matchRoutePattern } from \"../routing/route-pattern.js\";\nimport { normalizePathnameForRouteMatch } from \"../routing/utils.js\";\nimport type { MetadataFileRoute } from \"./metadata-routes.js\";\nimport { APP_RSC_RENDER_MODE_NAVIGATION, type AppRscRenderMode } from \"./app-rsc-render-mode.js\";\nimport { isInterceptionMatchedUrlPath, normalizePath } from \"./normalize-path.js\";\nimport { shouldServeStreamingMetadata } from \"./streaming-metadata.js\";\n\nexport type { AppPageErrorModule, AppPageRouteWiringRoute } from \"./app-page-route-wiring.js\";\n\n/**\n * Route shape passed from the generated entry. Extends the wiring route with\n * the page module reference (used to extract the default export for the page\n * element) and the URL pattern (used as the route path in head resolution).\n */\nexport type AppPageBuildRoute<\n TModule extends AppPageModule = AppPageModule,\n TErrorModule extends AppPageErrorModule = AppPageErrorModule,\n> = AppPageRouteWiringRoute<TModule, TErrorModule> & {\n page?: TModule | null;\n pattern: string;\n /** Param names captured by the route's URL pattern, in order. */\n params?: readonly string[] | null;\n};\n\nexport type AppPageInterceptOptions<TModule extends AppPageModule = AppPageModule> = {\n interceptionContext?: string | null;\n interceptLayouts?: readonly (TModule | null | undefined)[] | null;\n interceptPage?: TModule | null;\n interceptParams?: AppPageParams | null;\n interceptSlotId?: string | null;\n interceptSlotKey?: string | null;\n interceptSourceMatchedUrl?: string | null;\n};\n\nexport type AppPagePageRequest<TModule extends AppPageModule = AppPageModule> = {\n /** Interception context from current-route navigation (null for direct visits). */\n opts?: AppPageInterceptOptions<TModule> | null;\n /** URL search params from the incoming request (null when unavailable). */\n searchParams?: URLSearchParams | null;\n /** Whether the incoming request is an RSC (client-side navigation) request. */\n isRscRequest: boolean;\n /** The incoming HTTP request (available but unused by this module). */\n request: Request;\n /** Normalized x-vinext-mounted-slots header value. */\n mountedSlotsHeader: string | null;\n /** Semantic RSC payload mode for this page render. */\n renderMode?: AppRscRenderMode;\n};\n\nexport type BuildPageElementsOptions<\n TModule extends AppPageModule = AppPageModule,\n TErrorModule extends AppPageErrorModule = AppPageErrorModule,\n> = {\n route: AppPageBuildRoute<TModule, TErrorModule>;\n params: AppPageParams;\n routePath: string;\n pageRequest: AppPagePageRequest<TModule>;\n /** Root-level global-error.tsx module. Present when the app defines this file. */\n globalErrorModule?: TErrorModule | null;\n /** Root-level not-found.tsx module. Present when the app defines this file. */\n rootNotFoundModule?: TModule | null;\n /** Root-level forbidden.tsx module. Present when the app defines this file. */\n rootForbiddenModule?: TModule | null;\n /** Root-level unauthorized.tsx module. Present when the app defines this file. */\n rootUnauthorizedModule?: TModule | null;\n /** File-based metadata routes (favicon, manifest, sitemap, etc.). */\n metadataRoutes: readonly MetadataFileRoute[];\n /**\n * Configured next.config `basePath`. Threaded through `resolveAppPageHead`\n * so file-based metadata route URLs emitted in <head> are prefixed.\n */\n basePath?: string;\n /** Serialized next.config `htmlLimitedBots` regexp source. */\n htmlLimitedBots?: string;\n};\n\n/**\n * Build the App Router element tree for a matched route.\n *\n * This is the central element-construction path for the App Router RSC\n * handler. It resolves page head metadata (including parallel route metadata),\n * creates the page React element, and wires it into the nested layout +\n * boundary tree via {@link buildAppPageElements}.\n *\n * The function is extracted from the generated RSC entry template so it can\n * be unit-tested independently of the code-generation machinery.\n *\n * Next.js equivalent: the component tree construction in\n * {@link https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/create-component-tree.tsx|create-component-tree.tsx}\n * and the page head resolution in\n * {@link https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/create-metadata.tsx|create-metadata.tsx}.\n */\nexport async function buildPageElements<\n TModule extends AppPageModule = AppPageModule,\n TErrorModule extends AppPageErrorModule = AppPageErrorModule,\n>(options: BuildPageElementsOptions<TModule, TErrorModule>): Promise<AppElements> {\n const {\n route,\n params,\n routePath,\n pageRequest,\n globalErrorModule,\n rootNotFoundModule,\n rootForbiddenModule,\n rootUnauthorizedModule,\n metadataRoutes,\n } = options;\n const {\n opts,\n searchParams,\n isRscRequest,\n mountedSlotsHeader,\n renderMode = APP_RSC_RENDER_MODE_NAVIGATION,\n } = pageRequest;\n\n const pageModule: AppPageModule | null | undefined = route.page;\n const PageComponent = pageModule?.default;\n const hasPageModule = !!pageModule;\n const interception = createAppPageInterceptionProof(routePath, opts);\n\n if (hasPageModule && !PageComponent) {\n const interceptionContext = opts?.interceptionContext ?? null;\n const noExportRouteId = AppElementsWire.encodeRouteId(routePath, interceptionContext);\n let noExportRootLayout: string | null = null;\n const noExportLayoutIds =\n route.ids?.layouts ??\n route.layouts.map((_, index) =>\n AppElementsWire.encodeLayoutId(\n createAppPageTreePath(route.routeSegments, route.layoutTreePositions?.[index] ?? 0),\n ),\n );\n if (route.layouts?.length > 0) {\n const treePosition = route.layoutTreePositions?.[0] ?? 0;\n noExportRootLayout = createAppPageTreePath(route.routeSegments, treePosition);\n }\n return {\n ...AppElementsWire.createMetadataEntries({\n interception,\n interceptionContext,\n layoutIds: noExportLayoutIds,\n rootLayoutTreePath: noExportRootLayout,\n routeId: noExportRouteId,\n }),\n [noExportRouteId]: createElement(\"div\", null, \"Page has no default export\"),\n };\n }\n\n const {\n hasSearchParams,\n hasDynamicMetadata,\n metadata: resolvedMetadata,\n pageSearchParams,\n viewport: resolvedViewport,\n } = await resolveAppPageHead({\n basePath: options.basePath ?? \"\",\n layoutModules: route.layouts,\n layoutTreePositions: route.layoutTreePositions,\n metadataRoutes,\n pageModule: route.page ?? null,\n parallelRoutes: resolveActiveParallelRouteHeadInputs({\n interceptLayouts: opts?.interceptLayouts ?? null,\n interceptPage: opts?.interceptPage ?? null,\n interceptParams: opts?.interceptParams ?? null,\n interceptSlotKey: opts?.interceptSlotKey ?? null,\n params,\n routeSegments: route.routeSegments ?? [],\n slots: route.slots ?? null,\n }),\n params,\n routePath: route.pattern,\n routeSegments: route.routeSegments ?? null,\n searchParams,\n });\n\n const pageProps: Record<string, unknown> = { params: makeThenableParams(params) };\n if (searchParams) {\n pageProps.searchParams = makeThenableParams(pageSearchParams);\n if (hasSearchParams) {\n markDynamicUsage();\n markRenderRequestApiUsage(\"searchParams\");\n }\n }\n\n const mountedSlotIds = mountedSlotsHeader ? new Set(mountedSlotsHeader.split(\" \")) : null;\n\n const slotOverrides = buildSlotOverrides(route, params, routePath, opts);\n const metadataPlacement =\n hasDynamicMetadata &&\n shouldServeStreamingMetadata(\n pageRequest.request.headers.get(\"user-agent\") ?? \"\",\n options.htmlLimitedBots,\n )\n ? \"body\"\n : \"head\";\n\n return buildAppPageElements({\n element: PageComponent ? createElement(PageComponent, pageProps) : null,\n // Fall back to vinext's built-in default global error module so that\n // uncaught client render errors are caught by the route-level\n // <ErrorBoundary> wrapper in app-page-route-wiring.tsx, mirroring\n // Next.js's behavior when the user has not defined app/global-error.tsx.\n globalErrorModule:\n globalErrorModule ?? (DEFAULT_GLOBAL_ERROR_MODULE as unknown as TErrorModule),\n isRscRequest,\n mountedSlotIds,\n makeThenableParams,\n matchedParams: params,\n metadataPlacement,\n resolvedMetadata,\n resolvedMetadataPathname: routePath,\n resolvedViewport,\n interceptionContext: opts?.interceptionContext ?? null,\n interception,\n routePath,\n rootNotFoundModule: rootNotFoundModule ?? null,\n rootForbiddenModule: rootForbiddenModule ?? null,\n rootUnauthorizedModule: rootUnauthorizedModule ?? null,\n route,\n slotOverrides,\n renderMode,\n });\n}\n\nfunction createAppPageInterceptionProof<TModule extends AppPageModule>(\n routePath: string,\n opts?: AppPageInterceptOptions<TModule> | null,\n): AppElementsInterception | null {\n const sourceMatchedUrl = normalizeInterceptionProofMatchedUrl(\n opts?.interceptSourceMatchedUrl ?? null,\n );\n const targetMatchedUrl = normalizeInterceptionProofMatchedUrl(routePath);\n const slotId = opts?.interceptSlotId ?? null;\n if (sourceMatchedUrl === null || targetMatchedUrl === null || slotId === null) return null;\n\n return {\n sourceMatchedUrl,\n sourceRouteId: AppElementsWire.encodeRouteId(sourceMatchedUrl, null),\n slotId,\n targetMatchedUrl,\n targetRouteId: AppElementsWire.encodeRouteId(targetMatchedUrl, null),\n };\n}\n\nfunction normalizeInterceptionProofMatchedUrl(value: string | null): string | null {\n if (value === null || !isInterceptionMatchedUrlPath(value)) return null;\n\n return normalizePath(normalizePathnameForRouteMatch(value));\n}\n\n/**\n * Build the per-request `slotOverrides` map. Combines:\n * - Interception overrides (existing behavior — swap in the intercepting page\n * and its layouts when the request is intercepted into this slot).\n * - Slot-specific param extraction for inherited slots whose URL pattern\n * has different param names than the route's. The runtime matches the\n * cleaned request path against `slot.slotPatternParts` to produce\n * slot-scoped params, which `app-page-route-wiring` then hands to the\n * slot page instead of the route's matched params.\n *\n * `routePath` is the already-normalized request pathname (basePath stripped,\n * RSC suffix removed). Re-parsing `request.url` here would re-introduce the\n * basePath and silently break the match for any app that configures one.\n */\nfunction buildSlotOverrides<TModule extends AppPageModule, TErrorModule extends AppPageErrorModule>(\n route: AppPageBuildRoute<TModule, TErrorModule>,\n routeParams: AppPageParams,\n routePath: string,\n opts?: AppPageInterceptOptions<TModule> | null,\n): Readonly<Record<string, AppPageSlotOverride<TModule>>> | null {\n const overrides: Record<string, AppPageSlotOverride<TModule>> = {};\n\n if (opts && opts.interceptSlotKey && opts.interceptPage) {\n overrides[opts.interceptSlotKey] = {\n layoutModules: opts.interceptLayouts || null,\n pageModule: opts.interceptPage,\n params: opts.interceptParams || routeParams,\n };\n }\n\n const slots = route.slots;\n if (slots) {\n let urlParts: string[] | null = null;\n const routeParamSet = collectParamNameSet(route.params);\n for (const [slotKey, slot] of Object.entries(slots)) {\n const patternParts = slot.slotPatternParts;\n const paramNames = slot.slotParamNames;\n if (!patternParts || patternParts.length === 0) continue;\n // Skip when every slot param is already a route param — the route's\n // matched params already carry the values the slot page expects.\n // Empty `paramNames` (slot pattern has no dynamic markers) also skips:\n // there's nothing to extract, so the route's matched params suffice.\n if (paramNames && paramNames.every((name) => routeParamSet.has(name))) continue;\n\n if (urlParts === null) {\n urlParts = routePath.split(\"/\").filter(Boolean);\n }\n const matched = matchRoutePattern(urlParts, patternParts);\n if (!matched) continue;\n\n const existing = overrides[slotKey];\n overrides[slotKey] = existing ? { ...existing, params: matched } : { params: matched };\n }\n }\n\n return Object.keys(overrides).length > 0 ? overrides : null;\n}\n\nfunction collectParamNameSet(params: readonly string[] | undefined | null): Set<string> {\n const set = new Set<string>();\n if (params) {\n for (const name of params) set.add(name);\n }\n return set;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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,YAA0D,EAAE;CAElE,IAAI,QAAQ,KAAK,oBAAoB,KAAK,eACxC,UAAU,KAAK,oBAAoB;EACjC,eAAe,KAAK,oBAAoB;EACxC,YAAY,KAAK;EACjB,QAAQ,KAAK,mBAAmB;EACjC;CAGH,MAAM,QAAQ,MAAM;CACpB,IAAI,OAAO;EACT,IAAI,WAA4B;EAChC,MAAM,gBAAgB,oBAAoB,MAAM,OAAO;EACvD,KAAK,MAAM,CAAC,SAAS,SAAS,OAAO,QAAQ,MAAM,EAAE;GACnD,MAAM,eAAe,KAAK;GAC1B,MAAM,aAAa,KAAK;GACxB,IAAI,CAAC,gBAAgB,aAAa,WAAW,GAAG;GAKhD,IAAI,cAAc,WAAW,OAAO,SAAS,cAAc,IAAI,KAAK,CAAC,EAAE;GAEvE,IAAI,aAAa,MACf,WAAW,UAAU,MAAM,IAAI,CAAC,OAAO,QAAQ;GAEjD,MAAM,UAAU,kBAAkB,UAAU,aAAa;GACzD,IAAI,CAAC,SAAS;GAEd,MAAM,WAAW,UAAU;GAC3B,UAAU,WAAW,WAAW;IAAE,GAAG;IAAU,QAAQ;IAAS,GAAG,EAAE,QAAQ,SAAS;;;CAI1F,OAAO,OAAO,KAAK,UAAU,CAAC,SAAS,IAAI,YAAY;;AAGzD,SAAS,oBAAoB,QAA2D;CACtF,MAAM,sBAAM,IAAI,KAAa;CAC7B,IAAI,QACF,KAAK,MAAM,QAAQ,QAAQ,IAAI,IAAI,KAAK;CAE1C,OAAO"}
|
|
1
|
+
{"version":3,"file":"app-page-element-builder.js","names":[],"sources":["../../src/server/app-page-element-builder.ts"],"sourcesContent":["import { createElement } from \"react\";\nimport { markDynamicUsage, markRenderRequestApiUsage } from \"vinext/shims/headers\";\nimport { makeThenableParams } from \"vinext/shims/thenable-params\";\nimport { resolveActiveParallelRouteHeadInputs, resolveAppPageHead } from \"./app-page-head.js\";\nimport {\n buildAppPageElements,\n createAppPageTreePath,\n type AppPageErrorModule,\n type AppPageModule,\n type AppPageRouteWiringRoute,\n type AppPageSlotOverride,\n} from \"./app-page-route-wiring.js\";\nimport { AppElementsWire, type AppElements } from \"./app-elements.js\";\nimport type { AppPageParams } from \"./app-page-boundary.js\";\nimport { DEFAULT_GLOBAL_ERROR_MODULE } from \"./default-global-error-module.js\";\nimport { matchRoutePattern } from \"../routing/route-pattern.js\";\nimport type { MetadataFileRoute } from \"./metadata-routes.js\";\nimport { APP_RSC_RENDER_MODE_NAVIGATION, type AppRscRenderMode } from \"./app-rsc-render-mode.js\";\nimport { createAppPageRenderIdentity } from \"./app-page-render-identity.js\";\nimport { shouldServeStreamingMetadata } from \"./streaming-metadata.js\";\n\nexport type { AppPageErrorModule, AppPageRouteWiringRoute } from \"./app-page-route-wiring.js\";\n\n/**\n * Route shape passed from the generated entry. Extends the wiring route with\n * the page module reference (used to extract the default export for the page\n * element) and the URL pattern (used as the route path in head resolution).\n */\nexport type AppPageBuildRoute<\n TModule extends AppPageModule = AppPageModule,\n TErrorModule extends AppPageErrorModule = AppPageErrorModule,\n> = AppPageRouteWiringRoute<TModule, TErrorModule> & {\n page?: TModule | null;\n pattern: string;\n /** Param names captured by the route's URL pattern, in order. */\n params?: readonly string[] | null;\n};\n\nexport type AppPageInterceptOptions<TModule extends AppPageModule = AppPageModule> = {\n interceptionContext?: string | null;\n interceptLayouts?: readonly (TModule | null | undefined)[] | null;\n interceptPage?: TModule | null;\n interceptParams?: AppPageParams | null;\n interceptSlotId?: string | null;\n interceptSlotKey?: string | null;\n interceptSourceMatchedUrl?: string | null;\n};\n\nexport type AppPagePageRequest<TModule extends AppPageModule = AppPageModule> = {\n /** Interception context from current-route navigation (null for direct visits). */\n opts?: AppPageInterceptOptions<TModule> | null;\n /** URL search params from the incoming request (null when unavailable). */\n searchParams?: URLSearchParams | null;\n /** Whether the incoming request is an RSC (client-side navigation) request. */\n isRscRequest: boolean;\n /** The incoming HTTP request (available but unused by this module). */\n request: Request;\n /** Normalized x-vinext-mounted-slots header value. */\n mountedSlotsHeader: string | null;\n /** Semantic RSC payload mode for this page render. */\n renderMode?: AppRscRenderMode;\n};\n\nexport type BuildPageElementsOptions<\n TModule extends AppPageModule = AppPageModule,\n TErrorModule extends AppPageErrorModule = AppPageErrorModule,\n> = {\n route: AppPageBuildRoute<TModule, TErrorModule>;\n params: AppPageParams;\n routePath: string;\n pageRequest: AppPagePageRequest<TModule>;\n /** Root-level global-error.tsx module. Present when the app defines this file. */\n globalErrorModule?: TErrorModule | null;\n /** Root-level not-found.tsx module. Present when the app defines this file. */\n rootNotFoundModule?: TModule | null;\n /** Root-level forbidden.tsx module. Present when the app defines this file. */\n rootForbiddenModule?: TModule | null;\n /** Root-level unauthorized.tsx module. Present when the app defines this file. */\n rootUnauthorizedModule?: TModule | null;\n /** File-based metadata routes (favicon, manifest, sitemap, etc.). */\n metadataRoutes: readonly MetadataFileRoute[];\n /**\n * Configured next.config `basePath`. Threaded through `resolveAppPageHead`\n * so file-based metadata route URLs emitted in <head> are prefixed.\n */\n basePath?: string;\n /** Serialized next.config `htmlLimitedBots` regexp source. */\n htmlLimitedBots?: string;\n};\n\n/**\n * Build the App Router element tree for a matched route.\n *\n * This is the central element-construction path for the App Router RSC\n * handler. It resolves page head metadata (including parallel route metadata),\n * creates the page React element, and wires it into the nested layout +\n * boundary tree via {@link buildAppPageElements}.\n *\n * The function is extracted from the generated RSC entry template so it can\n * be unit-tested independently of the code-generation machinery.\n *\n * Next.js equivalent: the component tree construction in\n * {@link https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/create-component-tree.tsx|create-component-tree.tsx}\n * and the page head resolution in\n * {@link https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/create-metadata.tsx|create-metadata.tsx}.\n */\nexport async function buildPageElements<\n TModule extends AppPageModule = AppPageModule,\n TErrorModule extends AppPageErrorModule = AppPageErrorModule,\n>(options: BuildPageElementsOptions<TModule, TErrorModule>): Promise<AppElements> {\n const {\n route,\n params,\n routePath,\n pageRequest,\n globalErrorModule,\n rootNotFoundModule,\n rootForbiddenModule,\n rootUnauthorizedModule,\n metadataRoutes,\n } = options;\n const {\n opts,\n searchParams,\n isRscRequest,\n mountedSlotsHeader,\n renderMode = APP_RSC_RENDER_MODE_NAVIGATION,\n } = pageRequest;\n\n const pageModule: AppPageModule | null | undefined = route.page;\n const PageComponent = pageModule?.default;\n const hasPageModule = !!pageModule;\n const renderIdentity = createAppPageRenderIdentity({\n displayPathname: routePath,\n interceptionContext: opts?.interceptionContext ?? null,\n interceptSourceMatchedUrl: opts?.interceptSourceMatchedUrl ?? null,\n interceptSlotId: opts?.interceptSlotId ?? null,\n });\n\n if (hasPageModule && !PageComponent) {\n let noExportRootLayout: string | null = null;\n const noExportLayoutIds =\n route.ids?.layouts ??\n route.layouts.map((_, index) =>\n AppElementsWire.encodeLayoutId(\n createAppPageTreePath(route.routeSegments, route.layoutTreePositions?.[index] ?? 0),\n ),\n );\n if (route.layouts?.length > 0) {\n const treePosition = route.layoutTreePositions?.[0] ?? 0;\n noExportRootLayout = createAppPageTreePath(route.routeSegments, treePosition);\n }\n return {\n ...AppElementsWire.createMetadataEntries({\n interception: renderIdentity.interception,\n interceptionContext: renderIdentity.interceptionContext,\n layoutIds: noExportLayoutIds,\n rootLayoutTreePath: noExportRootLayout,\n routeId: renderIdentity.routeId,\n }),\n [renderIdentity.routeId]: createElement(\"div\", null, \"Page has no default export\"),\n };\n }\n\n const {\n hasSearchParams,\n hasDynamicMetadata,\n metadata: resolvedMetadata,\n pageSearchParams,\n viewport: resolvedViewport,\n } = await resolveAppPageHead({\n basePath: options.basePath ?? \"\",\n layoutModules: route.layouts,\n layoutTreePositions: route.layoutTreePositions,\n metadataRoutes,\n pageModule: route.page ?? null,\n parallelRoutes: resolveActiveParallelRouteHeadInputs({\n interceptLayouts: opts?.interceptLayouts ?? null,\n interceptPage: opts?.interceptPage ?? null,\n interceptParams: opts?.interceptParams ?? null,\n interceptSlotKey: opts?.interceptSlotKey ?? null,\n params,\n routeSegments: route.routeSegments ?? [],\n slots: route.slots ?? null,\n }),\n params,\n routePath: route.pattern,\n routeSegments: route.routeSegments ?? null,\n searchParams,\n });\n\n const pageProps: Record<string, unknown> = { params: makeThenableParams(params) };\n if (searchParams) {\n pageProps.searchParams = makeThenableParams(pageSearchParams);\n if (hasSearchParams) {\n markDynamicUsage();\n markRenderRequestApiUsage(\"searchParams\");\n }\n }\n\n const mountedSlotIds = mountedSlotsHeader ? new Set(mountedSlotsHeader.split(\" \")) : null;\n\n const slotOverrides = buildSlotOverrides(route, params, routePath, opts);\n const metadataPlacement =\n hasDynamicMetadata &&\n shouldServeStreamingMetadata(\n pageRequest.request.headers.get(\"user-agent\") ?? \"\",\n options.htmlLimitedBots,\n )\n ? \"body\"\n : \"head\";\n\n return buildAppPageElements({\n element: PageComponent ? createElement(PageComponent, pageProps) : null,\n // Fall back to vinext's built-in default global error module so that\n // uncaught client render errors are caught by the route-level\n // <ErrorBoundary> wrapper in app-page-route-wiring.tsx, mirroring\n // Next.js's behavior when the user has not defined app/global-error.tsx.\n globalErrorModule:\n globalErrorModule ?? (DEFAULT_GLOBAL_ERROR_MODULE as unknown as TErrorModule),\n isRscRequest,\n mountedSlotIds,\n makeThenableParams,\n matchedParams: params,\n metadataPlacement,\n resolvedMetadata,\n resolvedMetadataPathname: routePath,\n resolvedViewport,\n renderIdentity,\n routePath,\n rootNotFoundModule: rootNotFoundModule ?? null,\n rootForbiddenModule: rootForbiddenModule ?? null,\n rootUnauthorizedModule: rootUnauthorizedModule ?? null,\n route,\n slotOverrides,\n renderMode,\n });\n}\n\n/**\n * Build the per-request `slotOverrides` map. Combines:\n * - Interception overrides (existing behavior — swap in the intercepting page\n * and its layouts when the request is intercepted into this slot).\n * - Slot-specific param extraction for inherited slots whose URL pattern\n * has different param names than the route's. The runtime matches the\n * cleaned request path against `slot.slotPatternParts` to produce\n * slot-scoped params, which `app-page-route-wiring` then hands to the\n * slot page instead of the route's matched params.\n *\n * `routePath` is the already-normalized request pathname (basePath stripped,\n * RSC suffix removed). Re-parsing `request.url` here would re-introduce the\n * basePath and silently break the match for any app that configures one.\n */\nfunction buildSlotOverrides<TModule extends AppPageModule, TErrorModule extends AppPageErrorModule>(\n route: AppPageBuildRoute<TModule, TErrorModule>,\n routeParams: AppPageParams,\n routePath: string,\n opts?: AppPageInterceptOptions<TModule> | null,\n): Readonly<Record<string, AppPageSlotOverride<TModule>>> | null {\n const overrides: Record<string, AppPageSlotOverride<TModule>> = {};\n\n if (opts && opts.interceptSlotKey && opts.interceptPage) {\n overrides[opts.interceptSlotKey] = {\n layoutModules: opts.interceptLayouts || null,\n pageModule: opts.interceptPage,\n params: opts.interceptParams || routeParams,\n };\n }\n\n const slots = route.slots;\n if (slots) {\n let urlParts: string[] | null = null;\n const routeParamSet = collectParamNameSet(route.params);\n for (const [slotKey, slot] of Object.entries(slots)) {\n const patternParts = slot.slotPatternParts;\n const paramNames = slot.slotParamNames;\n if (!patternParts || patternParts.length === 0) continue;\n // Skip when every slot param is already a route param — the route's\n // matched params already carry the values the slot page expects.\n // Empty `paramNames` (slot pattern has no dynamic markers) also skips:\n // there's nothing to extract, so the route's matched params suffice.\n if (paramNames && paramNames.every((name) => routeParamSet.has(name))) continue;\n\n if (urlParts === null) {\n urlParts = routePath.split(\"/\").filter(Boolean);\n }\n const matched = matchRoutePattern(urlParts, patternParts);\n if (!matched) continue;\n\n const existing = overrides[slotKey];\n overrides[slotKey] = existing ? { ...existing, params: matched } : { params: matched };\n }\n }\n\n return Object.keys(overrides).length > 0 ? overrides : null;\n}\n\nfunction collectParamNameSet(params: readonly string[] | undefined | null): Set<string> {\n const set = new Set<string>();\n if (params) {\n for (const name of params) set.add(name);\n }\n return set;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0GA,eAAsB,kBAGpB,SAAgF;CAChF,MAAM,EACJ,OACA,QACA,WACA,aACA,mBACA,oBACA,qBACA,wBACA,mBACE;CACJ,MAAM,EACJ,MACA,cACA,cACA,oBACA,aAAa,mCACX;CAEJ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UAAU,aAAa;GACzD,IAAI,CAAC,SAAS;GAEd,MAAM,WAAW,UAAU;GAC3B,UAAU,WAAW,WAAW;IAAE,GAAG;IAAU,QAAQ;IAAS,GAAG,EAAE,QAAQ,SAAS;;;CAI1F,OAAO,OAAO,KAAK,UAAU,CAAC,SAAS,IAAI,YAAY;;AAGzD,SAAS,oBAAoB,QAA2D;CACtF,MAAM,sBAAM,IAAI,KAAa;CAC7B,IAAI,QACF,KAAK,MAAM,QAAQ,QAAQ,IAAI,IAAI,KAAK;CAE1C,OAAO"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AppElementsInterception } from "./app-elements-wire.js";
|
|
2
|
+
//#region src/server/app-page-render-identity.d.ts
|
|
3
|
+
type AppPageRenderIdentityInput = {
|
|
4
|
+
displayPathname: string;
|
|
5
|
+
interceptionContext?: string | null;
|
|
6
|
+
interceptSourceMatchedUrl?: string | null;
|
|
7
|
+
interceptSlotId?: string | null;
|
|
8
|
+
};
|
|
9
|
+
type AppPageRenderIdentity = {
|
|
10
|
+
displayPathname: string;
|
|
11
|
+
interception: AppElementsInterception | null;
|
|
12
|
+
interceptionContext: string | null;
|
|
13
|
+
matchedRoutePathname: string;
|
|
14
|
+
pageId: string;
|
|
15
|
+
routeId: string;
|
|
16
|
+
targetMatchedPathname: string;
|
|
17
|
+
};
|
|
18
|
+
declare function normalizeAppPageInterceptionProofPathname(pathname: string | null): string | null;
|
|
19
|
+
declare function createAppPageRenderIdentity(input: AppPageRenderIdentityInput): AppPageRenderIdentity;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { AppPageRenderIdentity, createAppPageRenderIdentity, normalizeAppPageInterceptionProofPathname };
|
|
22
|
+
//# sourceMappingURL=app-page-render-identity.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { normalizePathnameForRouteMatch } from "../routing/utils.js";
|
|
2
|
+
import { isInterceptionMatchedUrlPath, normalizePath } from "./normalize-path.js";
|
|
3
|
+
import { AppElementsWire } from "./app-elements-wire.js";
|
|
4
|
+
import "./app-elements.js";
|
|
5
|
+
//#region src/server/app-page-render-identity.ts
|
|
6
|
+
function normalizeAppPageRenderMatchedPathname(pathname) {
|
|
7
|
+
if (!pathname.startsWith("/")) throw new Error(`[vinext] App Router render pathname must be absolute: ${pathname}`);
|
|
8
|
+
return normalizePath(normalizePathnameForRouteMatch(pathname));
|
|
9
|
+
}
|
|
10
|
+
function normalizeAppPageInterceptionProofPathname(pathname) {
|
|
11
|
+
if (pathname === null || !isInterceptionMatchedUrlPath(pathname)) return null;
|
|
12
|
+
return normalizeAppPageRenderMatchedPathname(pathname);
|
|
13
|
+
}
|
|
14
|
+
function createAppPageRenderIdentity(input) {
|
|
15
|
+
const interceptionContext = input.interceptionContext ?? null;
|
|
16
|
+
const targetMatchedPathname = normalizeAppPageRenderMatchedPathname(input.displayPathname);
|
|
17
|
+
const sourceMatchedPathname = normalizeAppPageInterceptionProofPathname(input.interceptSourceMatchedUrl ?? null);
|
|
18
|
+
const slotId = input.interceptSlotId ?? null;
|
|
19
|
+
const matchedRoutePathname = sourceMatchedPathname ?? targetMatchedPathname;
|
|
20
|
+
const routeId = AppElementsWire.encodeRouteId(matchedRoutePathname, null);
|
|
21
|
+
const pageId = AppElementsWire.encodePageId(matchedRoutePathname, null);
|
|
22
|
+
const interception = sourceMatchedPathname === null || slotId === null ? null : {
|
|
23
|
+
sourceMatchedUrl: sourceMatchedPathname,
|
|
24
|
+
sourceRouteId: AppElementsWire.encodeRouteId(sourceMatchedPathname, null),
|
|
25
|
+
slotId,
|
|
26
|
+
targetMatchedUrl: targetMatchedPathname,
|
|
27
|
+
targetRouteId: AppElementsWire.encodeRouteId(targetMatchedPathname, null)
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
displayPathname: input.displayPathname,
|
|
31
|
+
interception,
|
|
32
|
+
interceptionContext,
|
|
33
|
+
matchedRoutePathname,
|
|
34
|
+
pageId,
|
|
35
|
+
routeId,
|
|
36
|
+
targetMatchedPathname
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { createAppPageRenderIdentity, normalizeAppPageInterceptionProofPathname };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=app-page-render-identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-page-render-identity.js","names":[],"sources":["../../src/server/app-page-render-identity.ts"],"sourcesContent":["import { normalizePathnameForRouteMatch } from \"../routing/utils.js\";\nimport { AppElementsWire, type AppElementsInterception } from \"./app-elements.js\";\nimport { isInterceptionMatchedUrlPath, normalizePath } from \"./normalize-path.js\";\n\ntype AppPageRenderIdentityInput = {\n displayPathname: string;\n interceptionContext?: string | null;\n interceptSourceMatchedUrl?: string | null;\n interceptSlotId?: string | null;\n};\n\nexport type AppPageRenderIdentity = {\n displayPathname: string;\n interception: AppElementsInterception | null;\n interceptionContext: string | null;\n matchedRoutePathname: string;\n pageId: string;\n routeId: string;\n targetMatchedPathname: string;\n};\n\nfunction normalizeAppPageRenderMatchedPathname(pathname: string): string {\n if (!pathname.startsWith(\"/\")) {\n throw new Error(`[vinext] App Router render pathname must be absolute: ${pathname}`);\n }\n return normalizePath(normalizePathnameForRouteMatch(pathname));\n}\n\nexport function normalizeAppPageInterceptionProofPathname(pathname: string | null): string | null {\n if (pathname === null || !isInterceptionMatchedUrlPath(pathname)) return null;\n return normalizeAppPageRenderMatchedPathname(pathname);\n}\n\nexport function createAppPageRenderIdentity(\n input: AppPageRenderIdentityInput,\n): AppPageRenderIdentity {\n const interceptionContext = input.interceptionContext ?? null;\n const targetMatchedPathname = normalizeAppPageRenderMatchedPathname(input.displayPathname);\n const sourceMatchedPathname = normalizeAppPageInterceptionProofPathname(\n input.interceptSourceMatchedUrl ?? null,\n );\n const slotId = input.interceptSlotId ?? null;\n const matchedRoutePathname = sourceMatchedPathname ?? targetMatchedPathname;\n const routeId = AppElementsWire.encodeRouteId(matchedRoutePathname, null);\n const pageId = AppElementsWire.encodePageId(matchedRoutePathname, null);\n const interception =\n sourceMatchedPathname === null || slotId === null\n ? null\n : {\n sourceMatchedUrl: sourceMatchedPathname,\n sourceRouteId: AppElementsWire.encodeRouteId(sourceMatchedPathname, null),\n slotId,\n targetMatchedUrl: targetMatchedPathname,\n targetRouteId: AppElementsWire.encodeRouteId(targetMatchedPathname, null),\n };\n\n return {\n displayPathname: input.displayPathname,\n interception,\n interceptionContext,\n matchedRoutePathname,\n pageId,\n routeId,\n targetMatchedPathname,\n };\n}\n"],"mappings":";;;;;AAqBA,SAAS,sCAAsC,UAA0B;CACvE,IAAI,CAAC,SAAS,WAAW,IAAI,EAC3B,MAAM,IAAI,MAAM,yDAAyD,WAAW;CAEtF,OAAO,cAAc,+BAA+B,SAAS,CAAC;;AAGhE,SAAgB,0CAA0C,UAAwC;CAChG,IAAI,aAAa,QAAQ,CAAC,6BAA6B,SAAS,EAAE,OAAO;CACzE,OAAO,sCAAsC,SAAS;;AAGxD,SAAgB,4BACd,OACuB;CACvB,MAAM,sBAAsB,MAAM,uBAAuB;CACzD,MAAM,wBAAwB,sCAAsC,MAAM,gBAAgB;CAC1F,MAAM,wBAAwB,0CAC5B,MAAM,6BAA6B,KACpC;CACD,MAAM,SAAS,MAAM,mBAAmB;CACxC,MAAM,uBAAuB,yBAAyB;CACtD,MAAM,UAAU,gBAAgB,cAAc,sBAAsB,KAAK;CACzE,MAAM,SAAS,gBAAgB,aAAa,sBAAsB,KAAK;CACvE,MAAM,eACJ,0BAA0B,QAAQ,WAAW,OACzC,OACA;EACE,kBAAkB;EAClB,eAAe,gBAAgB,cAAc,uBAAuB,KAAK;EACzE;EACA,kBAAkB;EAClB,eAAe,gBAAgB,cAAc,uBAAuB,KAAK;EAC1E;CAEP,OAAO;EACL,iBAAiB,MAAM;EACvB;EACA;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -19,6 +19,12 @@ type AppPageRequestCacheLife = {
|
|
|
19
19
|
};
|
|
20
20
|
type RenderAppPageLifecycleOptions = {
|
|
21
21
|
basePath?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Allow-list of OpenTelemetry propagation keys to emit as `<meta>` tags in
|
|
24
|
+
* the SSR head. From `experimental.clientTraceMetadata` in `next.config`.
|
|
25
|
+
* Undefined or empty disables emission.
|
|
26
|
+
*/
|
|
27
|
+
clientTraceMetadata?: readonly string[];
|
|
22
28
|
cleanPathname: string;
|
|
23
29
|
clearRequestContext: () => void;
|
|
24
30
|
consumeDynamicUsage: () => boolean;
|
|
@@ -46,8 +52,9 @@ type RenderAppPageLifecycleOptions = {
|
|
|
46
52
|
isRscRequest: boolean;
|
|
47
53
|
isrDebug?: AppPageDebugLogger;
|
|
48
54
|
isrHtmlKey: (pathname: string) => string;
|
|
49
|
-
isrRscKey: (pathname: string, mountedSlotsHeader?: string | null, renderMode?: AppRscRenderMode) => string;
|
|
55
|
+
isrRscKey: (pathname: string, mountedSlotsHeader?: string | null, renderMode?: AppRscRenderMode, interceptionContext?: string | null) => string;
|
|
50
56
|
isrSet: AppPageCacheSetter;
|
|
57
|
+
interceptionContext?: string | null;
|
|
51
58
|
layoutCount: number;
|
|
52
59
|
loadSsrHandler: () => Promise<AppPageSsrHandler>;
|
|
53
60
|
middlewareContext: AppPageMiddlewareContext;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createArtifactCompatibilityEnvelope, createArtifactCompatibilityGraphVersion } from "./artifact-compatibility.js";
|
|
2
2
|
import { AppElementsWire, isAppElementsRecord } from "./app-elements-wire.js";
|
|
3
|
-
import { runWithFetchDedupe } from "../shims/fetch-cache.js";
|
|
4
3
|
import "./app-elements.js";
|
|
4
|
+
import { runWithFetchDedupe } from "../shims/fetch-cache.js";
|
|
5
5
|
import { buildAppPageHtmlResponse, buildAppPageRscResponse, resolveAppPageHtmlResponsePolicy, resolveAppPageRscResponsePolicy } from "./app-page-response.js";
|
|
6
6
|
import { buildAppPageFontLinkHeader, readAppPageBinaryStream, resolveAppPageSpecialError, teeAppPageRscStreamForCapture } from "./app-page-execution.js";
|
|
7
7
|
import { createAppPageFontData, createAppPageRscErrorTracker, deferUntilStreamConsumed, renderAppPageHtmlStream, renderAppPageHtmlStreamWithRecovery, shouldRerenderAppPageWithGlobalError } from "./app-page-stream.js";
|
|
@@ -227,6 +227,7 @@ async function renderAppPageLifecycle(options) {
|
|
|
227
227
|
isrDebug: options.isrDebug,
|
|
228
228
|
isrRscKey: options.isrRscKey,
|
|
229
229
|
isrSet: options.isrSet,
|
|
230
|
+
interceptionContext: options.interceptionContext,
|
|
230
231
|
mountedSlotsHeader: options.mountedSlotsHeader,
|
|
231
232
|
renderMode: options.renderMode,
|
|
232
233
|
preserveClientResponseHeaders: rscResponsePolicy.cacheState !== "MISS",
|
|
@@ -258,6 +259,7 @@ async function renderAppPageLifecycle(options) {
|
|
|
258
259
|
fontData,
|
|
259
260
|
navigationContext: options.getNavigationContext(),
|
|
260
261
|
basePath: options.basePath,
|
|
262
|
+
clientTraceMetadata: options.clientTraceMetadata,
|
|
261
263
|
rootParams: options.rootParams,
|
|
262
264
|
formState: options.formState ?? null,
|
|
263
265
|
rscStream: rscForResponse,
|
|
@@ -379,6 +381,7 @@ async function renderAppPageLifecycle(options) {
|
|
|
379
381
|
isrHtmlKey: options.isrHtmlKey,
|
|
380
382
|
isrRscKey: options.isrRscKey,
|
|
381
383
|
isrSet: options.isrSet,
|
|
384
|
+
interceptionContext: options.interceptionContext,
|
|
382
385
|
preserveClientResponseHeaders: !htmlResponsePolicy.shouldWriteToCache,
|
|
383
386
|
expireSeconds,
|
|
384
387
|
revalidateSeconds,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-page-render.js","names":[],"sources":["../../src/server/app-page-render.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { ReactFormState } from \"react-dom/client\";\nimport type { CachedAppPageValue } from \"vinext/shims/cache\";\nimport type { RootParams } from \"vinext/shims/root-params\";\nimport { runWithFetchDedupe } from \"vinext/shims/fetch-cache\";\nimport { AppElementsWire, isAppElementsRecord, type AppOutgoingElements } from \"./app-elements.js\";\nimport { hasDigest } from \"./app-rsc-errors.js\";\nimport {\n finalizeAppPageHtmlCacheResponse,\n finalizeAppPageRscCacheResponse,\n} from \"./app-page-cache.js\";\nimport {\n buildAppPageFontLinkHeader,\n readAppPageBinaryStream,\n resolveAppPageSpecialError,\n teeAppPageRscStreamForCapture,\n type AppPageFontPreload,\n type AppPageSpecialError,\n type LayoutClassificationOptions,\n} from \"./app-page-execution.js\";\nimport { probeAppPageBeforeRender } from \"./app-page-probe.js\";\nimport {\n buildAppPageHtmlResponse,\n buildAppPageRscResponse,\n resolveAppPageHtmlResponsePolicy,\n resolveAppPageRscResponsePolicy,\n type AppPageMiddlewareContext,\n type AppPageResponseTiming,\n} from \"./app-page-response.js\";\nimport {\n createAppPageFontData,\n createAppPageRscErrorTracker,\n deferUntilStreamConsumed,\n renderAppPageHtmlStream,\n renderAppPageHtmlStreamWithRecovery,\n shouldRerenderAppPageWithGlobalError,\n type AppPageSsrHandler,\n} from \"./app-page-stream.js\";\nimport type { AppRscRenderMode } from \"./app-rsc-render-mode.js\";\nimport {\n createArtifactCompatibilityEnvelope,\n createArtifactCompatibilityGraphVersion,\n type ArtifactCompatibilityEnvelope,\n} from \"./artifact-compatibility.js\";\nimport {\n createAppPageHtmlOutputScope,\n createAppPageRenderObservation,\n createAppPageRscOutputScope,\n createEmptyAppPageRenderObservationState,\n type AppPageRenderObservationState,\n} from \"./app-page-render-observation.js\";\n\ntype AppPageBoundaryOnError = (\n error: unknown,\n requestInfo: unknown,\n errorContext: unknown,\n) => unknown;\ntype AppPageDebugLogger = (event: string, detail: string) => void;\ntype AppPageCacheSetter = (\n key: string,\n data: CachedAppPageValue,\n revalidateSeconds: number,\n tags: string[],\n expireSeconds?: number,\n) => Promise<void>;\n\ntype AppPageRequestCacheLife = {\n revalidate?: number;\n expire?: number;\n};\n\ntype RenderAppPageLifecycleOptions = {\n basePath?: string;\n cleanPathname: string;\n clearRequestContext: () => void;\n consumeDynamicUsage: () => boolean;\n consumeRenderObservationState?: () => AppPageRenderObservationState;\n /** Read and clear any invalid dynamic usage error recorded during render (dev-only). */\n consumeInvalidDynamicUsageError?: () => unknown;\n createRscOnErrorHandler: (pathname: string, routePath: string) => AppPageBoundaryOnError;\n getFontLinks: () => string[];\n getFontPreloads: () => AppPageFontPreload[];\n getFontStyles: () => string[];\n getNavigationContext: () => unknown;\n getPageTags: () => string[];\n getRequestCacheLife: () => AppPageRequestCacheLife | null;\n peekRequestCacheLife?: () => AppPageRequestCacheLife | null;\n getDraftModeCookieHeader: () => string | null | undefined;\n handlerStart: number;\n hasLoadingBoundary: boolean;\n isDynamicError: boolean;\n isDraftMode: boolean;\n isEdgeRuntime?: boolean;\n isForceDynamic: boolean;\n isForceStatic: boolean;\n isProgressiveActionRender?: boolean;\n isPrerender?: boolean;\n isProduction: boolean;\n isRscRequest: boolean;\n isrDebug?: AppPageDebugLogger;\n isrHtmlKey: (pathname: string) => string;\n isrRscKey: (\n pathname: string,\n mountedSlotsHeader?: string | null,\n renderMode?: AppRscRenderMode,\n ) => string;\n isrSet: AppPageCacheSetter;\n layoutCount: number;\n loadSsrHandler: () => Promise<AppPageSsrHandler>;\n middlewareContext: AppPageMiddlewareContext;\n params: Record<string, unknown>;\n rootParams?: RootParams;\n peekRenderObservationState?: () => AppPageRenderObservationState;\n probeLayoutAt: (layoutIndex: number) => unknown;\n probePage: () => unknown;\n expireSeconds?: number;\n formState?: ReactFormState | null;\n revalidateSeconds: number | null;\n renderErrorBoundaryResponse: (error: unknown) => Promise<Response | null>;\n renderLayoutSpecialError: (\n specialError: AppPageSpecialError,\n layoutIndex: number,\n ) => Promise<Response>;\n renderPageSpecialError: (specialError: AppPageSpecialError) => Promise<Response>;\n renderToReadableStream: (\n element: ReactNode | AppOutgoingElements,\n options: { onError: AppPageBoundaryOnError },\n ) => ReadableStream<Uint8Array>;\n routeHasLocalBoundary: boolean;\n routePattern: string;\n runWithSuppressedHookWarning<T>(probe: () => Promise<T>): Promise<T>;\n scriptNonce?: string;\n mountedSlotsHeader?: string | null;\n renderMode?: AppRscRenderMode;\n waitUntil?: (promise: Promise<void>) => void;\n element: ReactNode | Readonly<Record<string, ReactNode>>;\n classification?: LayoutClassificationOptions | null;\n};\n\nfunction buildResponseTiming(\n options: Pick<RenderAppPageLifecycleOptions, \"handlerStart\" | \"isProduction\"> & {\n compileEnd?: number;\n renderEnd?: number;\n responseKind: AppPageResponseTiming[\"responseKind\"];\n },\n): AppPageResponseTiming | undefined {\n if (options.isProduction) {\n return undefined;\n }\n\n return {\n compileEnd: options.compileEnd,\n handlerStart: options.handlerStart,\n renderEnd: options.renderEnd,\n responseKind: options.responseKind,\n };\n}\n\nfunction readRequestCacheLifeForPrerender(\n options: Pick<RenderAppPageLifecycleOptions, \"getRequestCacheLife\" | \"peekRequestCacheLife\">,\n): AppPageRequestCacheLife | null {\n // Prefer the non-destructive reader so prerender.ts can consume metadata\n // after the handler returns. The consume fallback supports older entry glue\n // and is only safe because this path reads at most once per prerender.\n return options.peekRequestCacheLife?.() ?? options.getRequestCacheLife();\n}\n\nfunction applyRequestCacheLife(options: {\n expireSeconds?: number;\n requestCacheLife: AppPageRequestCacheLife | null;\n revalidateSeconds: number | null;\n}): { expireSeconds?: number; revalidateSeconds: number | null } {\n let revalidateSeconds = options.revalidateSeconds;\n let expireSeconds = options.expireSeconds;\n const requestCacheLife = options.requestCacheLife;\n\n if (requestCacheLife?.revalidate !== undefined) {\n revalidateSeconds =\n revalidateSeconds === null\n ? requestCacheLife.revalidate\n : Math.min(revalidateSeconds, requestCacheLife.revalidate);\n }\n if (requestCacheLife?.expire !== undefined) {\n // cacheLife() supplies the effective hard-expire ceiling for this render,\n // so it replaces the config fallback instead of min-merging with it.\n expireSeconds = requestCacheLife.expire;\n }\n\n return { expireSeconds, revalidateSeconds };\n}\n\nfunction readRootBoundaryId(element: Readonly<Record<string, unknown>>): string | null {\n const rootLayoutTreePath = element[AppElementsWire.keys.rootLayout];\n return typeof rootLayoutTreePath === \"string\" ? rootLayoutTreePath : null;\n}\n\nfunction createAppPageArtifactCompatibility(\n element: ReactNode | Readonly<Record<string, ReactNode>>,\n routePattern: string,\n): ArtifactCompatibilityEnvelope | undefined {\n if (!isAppElementsRecord(element)) {\n return undefined;\n }\n\n const rootBoundaryId = readRootBoundaryId(element);\n return createArtifactCompatibilityEnvelope({\n graphVersion: createArtifactCompatibilityGraphVersion({\n routePattern,\n rootBoundaryId,\n }),\n deploymentVersion: process.env.__VINEXT_BUILD_ID ?? null,\n rootBoundaryId,\n });\n}\n\n/**\n * Wraps an RSC response body to report invalid dynamic usage errors after the\n * stream is fully consumed. In dev mode, errors from cookies()/headers() inside\n * \"use cache\" may be caught by user try/catch and silently swallowed — this\n * wrapper waits for the stream to drain and surfaces any recorded error to the\n * terminal (and, via HMR, the browser dev overlay).\n *\n * Dedups against React's Flight error chunk: if the recorded error already\n * carries a `digest`, React's serverComponentsErrorHandler has already stamped\n * it and emitted it into the RSC stream. Skipping `console.error` prevents\n * double-logging. Caught cases (no digest) still surface here.\n *\n * Ported from Next.js:\n * https://github.com/vercel/next.js/commit/f5e54c06726b571a042fce67417e40a29f6b8689\n * https://github.com/vercel/next.js/pull/93706\n */\nfunction wrapRscResponseForDevErrorReporting(\n response: Response,\n consumeInvalidDynamicUsageError: () => unknown,\n): Response {\n const originalBody = response.body;\n if (!originalBody) return response;\n\n let consumed = false;\n const onConsumed = () => {\n if (consumed) return;\n consumed = true;\n const error = consumeInvalidDynamicUsageError();\n if (!error) return;\n // Dedup: React already emitted this error as a Flight error chunk.\n if (!hasDigest(error)) {\n console.error(\"[vinext] Invalid dynamic usage:\", error);\n }\n };\n\n const cleanup = new TransformStream<Uint8Array, Uint8Array>({\n flush() {\n onConsumed();\n },\n });\n\n const piped = originalBody.pipeThrough(cleanup);\n const reader = piped.getReader();\n const wrappedStream = new ReadableStream<Uint8Array>({\n pull(controller) {\n return reader.read().then(\n ({ done, value }) => {\n if (done) {\n controller.close();\n } else {\n controller.enqueue(value);\n }\n },\n (streamError) => {\n onConsumed();\n controller.error(streamError);\n },\n );\n },\n cancel(reason) {\n onConsumed();\n return reader.cancel(reason);\n },\n });\n\n return new Response(wrappedStream, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n}\n\nexport async function renderAppPageLifecycle(\n options: RenderAppPageLifecycleOptions,\n): Promise<Response> {\n const preRenderResult = await probeAppPageBeforeRender({\n hasLoadingBoundary: options.hasLoadingBoundary,\n layoutCount: options.layoutCount,\n probeLayoutAt(layoutIndex) {\n return options.probeLayoutAt(layoutIndex);\n },\n probePage() {\n return options.probePage();\n },\n renderLayoutSpecialError(specialError, layoutIndex) {\n return options.renderLayoutSpecialError(specialError, layoutIndex);\n },\n renderPageSpecialError(specialError) {\n return options.renderPageSpecialError(specialError);\n },\n resolveSpecialError: resolveAppPageSpecialError,\n runWithSuppressedHookWarning(probe) {\n return options.runWithSuppressedHookWarning(probe);\n },\n classification: options.classification,\n });\n if (preRenderResult.response) {\n return preRenderResult.response;\n }\n\n const layoutFlags = preRenderResult.layoutFlags;\n\n // Render the CANONICAL element. The outgoing payload carries per-layout\n // static/dynamic flags under `__layoutFlags` so the client can later tell\n // which layouts are safe to skip on subsequent navigations.\n const artifactCompatibility = createAppPageArtifactCompatibility(\n options.element,\n options.routePattern,\n );\n const rootBoundaryId = artifactCompatibility?.rootBoundaryId ?? null;\n const renderEpoch = artifactCompatibility?.renderEpoch ?? null;\n const rscOutputScope = createAppPageRscOutputScope({\n element: options.element,\n mountedSlotsHeader: options.mountedSlotsHeader,\n renderEpoch,\n rootBoundaryId,\n routePattern: options.routePattern,\n });\n const htmlOutputScope = createAppPageHtmlOutputScope({\n element: options.element,\n renderEpoch,\n rootBoundaryId,\n routePattern: options.routePattern,\n });\n // Partial payload metadata is a pre-stream snapshot. Fetch tags may still\n // accumulate while the RSC/HTML streams are consumed; complete cache artifact\n // observations below rebuild this field after the stream drains.\n const payloadRenderObservation = createAppPageRenderObservation({\n boundaryOutcome: { kind: \"unknown\" },\n cacheability: \"unknown\",\n cacheTags: options.getPageTags(),\n cleanPathname: options.cleanPathname,\n completeness: \"partial\",\n output: rscOutputScope,\n params: options.params,\n state: options.peekRenderObservationState?.() ?? createEmptyAppPageRenderObservationState(),\n });\n const outgoingElement = AppElementsWire.encodeOutgoingPayload({\n element: options.element,\n layoutFlags,\n ...(artifactCompatibility ? { artifactCompatibility } : {}),\n renderObservation: payloadRenderObservation,\n });\n\n const compileEnd = options.isProduction ? undefined : performance.now();\n const baseOnError = options.createRscOnErrorHandler(options.cleanPathname, options.routePattern);\n const rscErrorTracker = createAppPageRscErrorTracker(baseOnError);\n // Defensive wrap for standalone callers. In the normal dispatch path this is\n // a no-op since dispatchAppPage already activated dedupe. Note that\n // renderToReadableStream returns synchronously — the actual fetch calls\n // happen later during async stream consumption — so the dedupe map a\n // standalone call would establish here is only effective if the caller has\n // an outer runWithRequestContext / runWithFetchDedupe scope keeping the ALS\n // store alive across that consumption.\n const rscStream = runWithFetchDedupe(() =>\n options.renderToReadableStream(outgoingElement, {\n onError: rscErrorTracker.onRenderError,\n }),\n );\n\n let revalidateSeconds = options.revalidateSeconds;\n let expireSeconds = options.expireSeconds;\n const shouldCaptureRscForCacheMetadata =\n options.isProgressiveActionRender !== true &&\n (options.isProduction || options.isPrerender === true) &&\n (revalidateSeconds === null || (revalidateSeconds > 0 && revalidateSeconds !== Infinity)) &&\n !options.isDraftMode &&\n !options.isForceDynamic;\n const rscCapture = teeAppPageRscStreamForCapture(rscStream, shouldCaptureRscForCacheMetadata);\n const rscForResponse = rscCapture.ssrStream;\n\n // When the fused tee (#981) is active, the sideStream carries both the embed\n // transform AND the raw RSC byte accumulation. For RSC requests, we consume\n // the sideStream directly. For HTML requests, handleSsr creates an embed\n // transform from it and fills capturedRscDataRef. The ref object is threaded\n // through so .value is read lazily after handleSsr completes.\n const capturedRscDataRef: { value: Promise<ArrayBuffer> | null } = { value: null };\n if (rscCapture.sideStream && options.isRscRequest) {\n capturedRscDataRef.value = readAppPageBinaryStream(rscCapture.sideStream);\n }\n\n if (options.isRscRequest) {\n if (options.isPrerender === true) {\n await settleCapturedRscRenderForCacheMetadata(capturedRscDataRef.value);\n ({ expireSeconds, revalidateSeconds } = applyRequestCacheLife({\n expireSeconds,\n requestCacheLife: readRequestCacheLifeForPrerender(options),\n revalidateSeconds,\n }));\n }\n\n const dynamicUsedDuringBuild = options.consumeDynamicUsage();\n const rscResponsePolicy = resolveAppPageRscResponsePolicy({\n dynamicUsedDuringBuild,\n isDraftMode: options.isDraftMode,\n isDynamicError: options.isDynamicError,\n isForceDynamic: options.isForceDynamic,\n isForceStatic: options.isForceStatic,\n isProduction: options.isProduction,\n expireSeconds,\n revalidateSeconds,\n });\n const rscResponse = buildAppPageRscResponse(rscForResponse, {\n isEdgeRuntime: options.isEdgeRuntime,\n middlewareContext: options.middlewareContext,\n mountedSlotsHeader: options.mountedSlotsHeader,\n params: options.params,\n policy: rscResponsePolicy,\n timing: buildResponseTiming({\n compileEnd,\n handlerStart: options.handlerStart,\n isProduction: options.isProduction,\n responseKind: \"rsc\",\n }),\n });\n\n // In dev mode, wrap the RSC response body to forward invalid dynamic usage\n // errors after the stream is consumed. This mirrors Next.js behavior where\n // workStore.invalidDynamicUsageError is checked after the accumulated chunks\n // promise resolves (app-render.tsx generateDynamicFlightRenderResultWithStagesInDev).\n // Ported from Next.js: https://github.com/vercel/next.js/commit/f5e54c06726b571a042fce67417e40a29f6b8689\n //\n // Note: This only covers RSC responses (client-side navigations). The HTML path\n // (initial page loads) intentionally defers this coverage — the error is still\n // thrown through the RSC pipeline and captured by rscErrorTracker.onRenderError\n // if uncaught by user code. Full parity with Next.js would require checking\n // invalidDynamicUsageError after SSR rendering, which is deferred as out of scope\n // for this PR focused on client-side navigations.\n const devRscResponse =\n !options.isProduction && rscResponse.body && options.consumeInvalidDynamicUsageError\n ? wrapRscResponseForDevErrorReporting(rscResponse, options.consumeInvalidDynamicUsageError)\n : rscResponse;\n\n return finalizeAppPageRscCacheResponse(devRscResponse, {\n capturedRscDataPromise:\n options.isProduction && shouldCaptureRscForCacheMetadata ? capturedRscDataRef.value : null,\n cleanPathname: options.cleanPathname,\n consumeDynamicUsage: options.consumeDynamicUsage,\n consumeRenderObservationState: options.consumeRenderObservationState,\n createRscRenderObservation(input) {\n return createAppPageRenderObservation({\n boundaryOutcome: { kind: \"success\" },\n cacheability: \"public\",\n cacheTags: input.cacheTags,\n cleanPathname: options.cleanPathname,\n completeness: \"complete\",\n output: rscOutputScope,\n params: options.params,\n state: input.state,\n });\n },\n dynamicUsedDuringBuild,\n getPageTags() {\n return options.getPageTags();\n },\n getRequestCacheLife() {\n return options.getRequestCacheLife();\n },\n isrDebug: options.isrDebug,\n isrRscKey: options.isrRscKey,\n isrSet: options.isrSet,\n mountedSlotsHeader: options.mountedSlotsHeader,\n renderMode: options.renderMode,\n preserveClientResponseHeaders: rscResponsePolicy.cacheState !== \"MISS\",\n expireSeconds,\n revalidateSeconds,\n waitUntil(promise) {\n options.waitUntil?.(promise);\n },\n });\n }\n\n const fontData = createAppPageFontData({\n getLinks: options.getFontLinks,\n getPreloads: options.getFontPreloads,\n getStyles: options.getFontStyles,\n });\n const fontLinkHeader = buildAppPageFontLinkHeader(fontData.preloads);\n let renderEnd: number | undefined;\n\n const htmlRender = await renderAppPageHtmlStreamWithRecovery({\n onShellRendered() {\n if (!options.isProduction) {\n renderEnd = performance.now();\n }\n },\n renderErrorBoundaryResponse(error) {\n return options.renderErrorBoundaryResponse(error);\n },\n async renderHtmlStream() {\n const ssrHandler = await options.loadSsrHandler();\n return renderAppPageHtmlStream({\n capturedRscDataRef,\n fontData,\n navigationContext: options.getNavigationContext(),\n basePath: options.basePath,\n rootParams: options.rootParams,\n formState: options.formState ?? null,\n rscStream: rscForResponse,\n scriptNonce: options.scriptNonce,\n sideStream: rscCapture.sideStream,\n ssrHandler,\n waitForAllReady: options.isPrerender,\n });\n },\n renderSpecialErrorResponse(specialError) {\n return options.renderPageSpecialError(specialError);\n },\n resolveSpecialError: resolveAppPageSpecialError,\n });\n if (htmlRender.response) {\n return htmlRender.response;\n }\n const htmlStream = htmlRender.htmlStream;\n if (!htmlStream) {\n throw new Error(\"[vinext] Expected an HTML stream when no fallback response was returned\");\n }\n\n // Routes with a route-level Suspense boundary (loading.tsx) skip the page\n // probe — the page render happens once, inside the RSC stream. Mirror\n // Next.js's `app-render.tsx:4293` catch shape: by the time the SSR shell\n // promise has resolved, any redirect()/notFound() throw whose async work\n // settles in microtasks during shell rendering has already fired through\n // React's onError and been captured by the tracker. Convert that to a\n // 307/404 before any bytes are flushed.\n //\n // Late rejections — ones that settle after macrotask boundaries (real\n // I/O, setTimeout, etc.) — fall through to the streamed body, exactly\n // as Next.js does. The digest survives in the Flight payload for the\n // client router to consume.\n if (options.hasLoadingBoundary) {\n const captured = rscErrorTracker.getCapturedSpecialError();\n if (captured) {\n const specialError = resolveAppPageSpecialError(captured);\n if (specialError) {\n void htmlStream.cancel().catch(() => {});\n return options.renderPageSpecialError(specialError);\n }\n }\n }\n\n if (\n shouldRerenderAppPageWithGlobalError({\n capturedError: rscErrorTracker.getCapturedError(),\n hasLocalBoundary: options.routeHasLocalBoundary,\n })\n ) {\n const cleanResponse = await options.renderErrorBoundaryResponse(\n rscErrorTracker.getCapturedError(),\n );\n if (cleanResponse) {\n return cleanResponse;\n }\n }\n\n // Eagerly read values that must be captured before the stream is consumed.\n if (options.isPrerender === true) {\n await settleCapturedRscRenderForCacheMetadata(capturedRscDataRef.value);\n ({ expireSeconds, revalidateSeconds } = applyRequestCacheLife({\n expireSeconds,\n requestCacheLife: readRequestCacheLifeForPrerender(options),\n revalidateSeconds,\n }));\n }\n const draftCookie = options.getDraftModeCookieHeader();\n const dynamicUsedDuringRender = options.consumeDynamicUsage();\n let dynamicUsedBeforeContextCleanup = dynamicUsedDuringRender;\n\n // Defer clearRequestContext() until the HTML stream is fully consumed by the\n // HTTP layer. The RSC/SSR pipeline is lazy — Server Components execute while\n // the response body is being pulled, not when the stream handle is returned.\n // Clearing the context synchronously here would race those executions, causing\n // headers()/cookies() to see a null context on warm (module-cached) requests.\n // See: https://github.com/cloudflare/vinext/issues/660\n const safeHtmlStream = deferUntilStreamConsumed(htmlStream, () => {\n dynamicUsedBeforeContextCleanup =\n dynamicUsedBeforeContextCleanup || options.consumeDynamicUsage();\n options.clearRequestContext();\n });\n\n const htmlResponsePolicy = resolveAppPageHtmlResponsePolicy({\n dynamicUsedDuringRender,\n isProgressiveActionRender: options.isProgressiveActionRender === true,\n hasScriptNonce: Boolean(options.scriptNonce),\n isDraftMode: options.isDraftMode,\n isDynamicError: options.isDynamicError,\n isForceDynamic: options.isForceDynamic,\n isForceStatic: options.isForceStatic,\n isProduction: options.isProduction,\n expireSeconds,\n revalidateSeconds,\n });\n const htmlResponseTiming = buildResponseTiming({\n compileEnd,\n handlerStart: options.handlerStart,\n isProduction: options.isProduction,\n renderEnd,\n responseKind: \"html\",\n });\n\n const shouldSpeculativelyWriteCache =\n options.isProduction &&\n shouldCaptureRscForCacheMetadata &&\n revalidateSeconds === null &&\n !options.isDynamicError &&\n !options.isForceStatic &&\n !options.scriptNonce &&\n options.isProgressiveActionRender !== true &&\n !dynamicUsedDuringRender;\n\n if (htmlResponsePolicy.shouldWriteToCache || shouldSpeculativelyWriteCache) {\n const isrResponse = buildAppPageHtmlResponse(safeHtmlStream, {\n draftCookie,\n fontLinkHeader,\n isEdgeRuntime: options.isEdgeRuntime,\n middlewareContext: options.middlewareContext,\n policy: htmlResponsePolicy,\n timing: htmlResponseTiming,\n });\n\n if (options.isPrerender === true) {\n return isrResponse;\n }\n\n return finalizeAppPageHtmlCacheResponse(isrResponse, {\n capturedDynamicUsageBeforeContextCleanup() {\n return dynamicUsedBeforeContextCleanup;\n },\n capturedRscDataPromise: capturedRscDataRef.value,\n cleanPathname: options.cleanPathname,\n consumeDynamicUsage: options.consumeDynamicUsage,\n consumeRenderObservationState: options.consumeRenderObservationState,\n createHtmlRenderObservation(input) {\n return createAppPageRenderObservation({\n boundaryOutcome: { kind: \"success\" },\n cacheability: \"public\",\n cacheTags: input.cacheTags,\n cleanPathname: options.cleanPathname,\n completeness: \"complete\",\n output: htmlOutputScope,\n params: options.params,\n state: input.state,\n });\n },\n createRscRenderObservation(input) {\n return createAppPageRenderObservation({\n boundaryOutcome: { kind: \"success\" },\n cacheability: \"public\",\n cacheTags: input.cacheTags,\n cleanPathname: options.cleanPathname,\n completeness: \"complete\",\n output: rscOutputScope,\n params: options.params,\n state: input.state,\n });\n },\n getPageTags() {\n return options.getPageTags();\n },\n getRequestCacheLife() {\n return options.getRequestCacheLife();\n },\n isrDebug: options.isrDebug,\n isrHtmlKey: options.isrHtmlKey,\n isrRscKey: options.isrRscKey,\n isrSet: options.isrSet,\n preserveClientResponseHeaders: !htmlResponsePolicy.shouldWriteToCache,\n expireSeconds,\n revalidateSeconds,\n waitUntil(cachePromise) {\n options.waitUntil?.(cachePromise);\n },\n });\n }\n\n return buildAppPageHtmlResponse(safeHtmlStream, {\n draftCookie,\n fontLinkHeader,\n isEdgeRuntime: options.isEdgeRuntime,\n middlewareContext: options.middlewareContext,\n policy: htmlResponsePolicy,\n timing: htmlResponseTiming,\n });\n}\n\nasync function settleCapturedRscRenderForCacheMetadata(\n capturedRscDataPromise: Promise<ArrayBuffer> | null,\n): Promise<void> {\n if (!capturedRscDataPromise) {\n return;\n }\n\n try {\n await capturedRscDataPromise;\n } catch {\n // The response stream and cache-write path own render error propagation.\n // This pre-read only makes \"use cache\" metadata available before headers\n // and ISR seed metadata are finalized.\n }\n}\n"],"mappings":";;;;;;;;;;;;AA2IA,SAAS,oBACP,SAKmC;CACnC,IAAI,QAAQ,cACV;CAGF,OAAO;EACL,YAAY,QAAQ;EACpB,cAAc,QAAQ;EACtB,WAAW,QAAQ;EACnB,cAAc,QAAQ;EACvB;;AAGH,SAAS,iCACP,SACgC;CAIhC,OAAO,QAAQ,wBAAwB,IAAI,QAAQ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;GAClB,YAAY,QAAQ;GACpB,WAAW,QAAQ;GACnB,QAAQ,QAAQ;GAChB,+BAA+B,CAAC,mBAAmB;GACnD;GACA;GACA,UAAU,cAAc;IACtB,QAAQ,YAAY,aAAa;;GAEpC,CAAC;;CAGJ,OAAO,yBAAyB,gBAAgB;EAC9C;EACA;EACA,eAAe,QAAQ;EACvB,mBAAmB,QAAQ;EAC3B,QAAQ;EACR,QAAQ;EACT,CAAC;;AAGJ,eAAe,wCACb,wBACe;CACf,IAAI,CAAC,wBACH;CAGF,IAAI;EACF,MAAM;SACA"}
|
|
1
|
+
{"version":3,"file":"app-page-render.js","names":[],"sources":["../../src/server/app-page-render.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { ReactFormState } from \"react-dom/client\";\nimport type { CachedAppPageValue } from \"vinext/shims/cache\";\nimport type { RootParams } from \"vinext/shims/root-params\";\nimport { runWithFetchDedupe } from \"vinext/shims/fetch-cache\";\nimport { AppElementsWire, isAppElementsRecord, type AppOutgoingElements } from \"./app-elements.js\";\nimport { hasDigest } from \"./app-rsc-errors.js\";\nimport {\n finalizeAppPageHtmlCacheResponse,\n finalizeAppPageRscCacheResponse,\n} from \"./app-page-cache.js\";\nimport {\n buildAppPageFontLinkHeader,\n readAppPageBinaryStream,\n resolveAppPageSpecialError,\n teeAppPageRscStreamForCapture,\n type AppPageFontPreload,\n type AppPageSpecialError,\n type LayoutClassificationOptions,\n} from \"./app-page-execution.js\";\nimport { probeAppPageBeforeRender } from \"./app-page-probe.js\";\nimport {\n buildAppPageHtmlResponse,\n buildAppPageRscResponse,\n resolveAppPageHtmlResponsePolicy,\n resolveAppPageRscResponsePolicy,\n type AppPageMiddlewareContext,\n type AppPageResponseTiming,\n} from \"./app-page-response.js\";\nimport {\n createAppPageFontData,\n createAppPageRscErrorTracker,\n deferUntilStreamConsumed,\n renderAppPageHtmlStream,\n renderAppPageHtmlStreamWithRecovery,\n shouldRerenderAppPageWithGlobalError,\n type AppPageSsrHandler,\n} from \"./app-page-stream.js\";\nimport type { AppRscRenderMode } from \"./app-rsc-render-mode.js\";\nimport {\n createArtifactCompatibilityEnvelope,\n createArtifactCompatibilityGraphVersion,\n type ArtifactCompatibilityEnvelope,\n} from \"./artifact-compatibility.js\";\nimport {\n createAppPageHtmlOutputScope,\n createAppPageRenderObservation,\n createAppPageRscOutputScope,\n createEmptyAppPageRenderObservationState,\n type AppPageRenderObservationState,\n} from \"./app-page-render-observation.js\";\n\ntype AppPageBoundaryOnError = (\n error: unknown,\n requestInfo: unknown,\n errorContext: unknown,\n) => unknown;\ntype AppPageDebugLogger = (event: string, detail: string) => void;\ntype AppPageCacheSetter = (\n key: string,\n data: CachedAppPageValue,\n revalidateSeconds: number,\n tags: string[],\n expireSeconds?: number,\n) => Promise<void>;\n\ntype AppPageRequestCacheLife = {\n revalidate?: number;\n expire?: number;\n};\n\ntype RenderAppPageLifecycleOptions = {\n basePath?: string;\n /**\n * Allow-list of OpenTelemetry propagation keys to emit as `<meta>` tags in\n * the SSR head. From `experimental.clientTraceMetadata` in `next.config`.\n * Undefined or empty disables emission.\n */\n clientTraceMetadata?: readonly string[];\n cleanPathname: string;\n clearRequestContext: () => void;\n consumeDynamicUsage: () => boolean;\n consumeRenderObservationState?: () => AppPageRenderObservationState;\n /** Read and clear any invalid dynamic usage error recorded during render (dev-only). */\n consumeInvalidDynamicUsageError?: () => unknown;\n createRscOnErrorHandler: (pathname: string, routePath: string) => AppPageBoundaryOnError;\n getFontLinks: () => string[];\n getFontPreloads: () => AppPageFontPreload[];\n getFontStyles: () => string[];\n getNavigationContext: () => unknown;\n getPageTags: () => string[];\n getRequestCacheLife: () => AppPageRequestCacheLife | null;\n peekRequestCacheLife?: () => AppPageRequestCacheLife | null;\n getDraftModeCookieHeader: () => string | null | undefined;\n handlerStart: number;\n hasLoadingBoundary: boolean;\n isDynamicError: boolean;\n isDraftMode: boolean;\n isEdgeRuntime?: boolean;\n isForceDynamic: boolean;\n isForceStatic: boolean;\n isProgressiveActionRender?: boolean;\n isPrerender?: boolean;\n isProduction: boolean;\n isRscRequest: boolean;\n isrDebug?: AppPageDebugLogger;\n isrHtmlKey: (pathname: string) => string;\n isrRscKey: (\n pathname: string,\n mountedSlotsHeader?: string | null,\n renderMode?: AppRscRenderMode,\n interceptionContext?: string | null,\n ) => string;\n isrSet: AppPageCacheSetter;\n interceptionContext?: string | null;\n layoutCount: number;\n loadSsrHandler: () => Promise<AppPageSsrHandler>;\n middlewareContext: AppPageMiddlewareContext;\n params: Record<string, unknown>;\n rootParams?: RootParams;\n peekRenderObservationState?: () => AppPageRenderObservationState;\n probeLayoutAt: (layoutIndex: number) => unknown;\n probePage: () => unknown;\n expireSeconds?: number;\n formState?: ReactFormState | null;\n revalidateSeconds: number | null;\n renderErrorBoundaryResponse: (error: unknown) => Promise<Response | null>;\n renderLayoutSpecialError: (\n specialError: AppPageSpecialError,\n layoutIndex: number,\n ) => Promise<Response>;\n renderPageSpecialError: (specialError: AppPageSpecialError) => Promise<Response>;\n renderToReadableStream: (\n element: ReactNode | AppOutgoingElements,\n options: { onError: AppPageBoundaryOnError },\n ) => ReadableStream<Uint8Array>;\n routeHasLocalBoundary: boolean;\n routePattern: string;\n runWithSuppressedHookWarning<T>(probe: () => Promise<T>): Promise<T>;\n scriptNonce?: string;\n mountedSlotsHeader?: string | null;\n renderMode?: AppRscRenderMode;\n waitUntil?: (promise: Promise<void>) => void;\n element: ReactNode | Readonly<Record<string, ReactNode>>;\n classification?: LayoutClassificationOptions | null;\n};\n\nfunction buildResponseTiming(\n options: Pick<RenderAppPageLifecycleOptions, \"handlerStart\" | \"isProduction\"> & {\n compileEnd?: number;\n renderEnd?: number;\n responseKind: AppPageResponseTiming[\"responseKind\"];\n },\n): AppPageResponseTiming | undefined {\n if (options.isProduction) {\n return undefined;\n }\n\n return {\n compileEnd: options.compileEnd,\n handlerStart: options.handlerStart,\n renderEnd: options.renderEnd,\n responseKind: options.responseKind,\n };\n}\n\nfunction readRequestCacheLifeForPrerender(\n options: Pick<RenderAppPageLifecycleOptions, \"getRequestCacheLife\" | \"peekRequestCacheLife\">,\n): AppPageRequestCacheLife | null {\n // Prefer the non-destructive reader so prerender.ts can consume metadata\n // after the handler returns. The consume fallback supports older entry glue\n // and is only safe because this path reads at most once per prerender.\n return options.peekRequestCacheLife?.() ?? options.getRequestCacheLife();\n}\n\nfunction applyRequestCacheLife(options: {\n expireSeconds?: number;\n requestCacheLife: AppPageRequestCacheLife | null;\n revalidateSeconds: number | null;\n}): { expireSeconds?: number; revalidateSeconds: number | null } {\n let revalidateSeconds = options.revalidateSeconds;\n let expireSeconds = options.expireSeconds;\n const requestCacheLife = options.requestCacheLife;\n\n if (requestCacheLife?.revalidate !== undefined) {\n revalidateSeconds =\n revalidateSeconds === null\n ? requestCacheLife.revalidate\n : Math.min(revalidateSeconds, requestCacheLife.revalidate);\n }\n if (requestCacheLife?.expire !== undefined) {\n // cacheLife() supplies the effective hard-expire ceiling for this render,\n // so it replaces the config fallback instead of min-merging with it.\n expireSeconds = requestCacheLife.expire;\n }\n\n return { expireSeconds, revalidateSeconds };\n}\n\nfunction readRootBoundaryId(element: Readonly<Record<string, unknown>>): string | null {\n const rootLayoutTreePath = element[AppElementsWire.keys.rootLayout];\n return typeof rootLayoutTreePath === \"string\" ? rootLayoutTreePath : null;\n}\n\nfunction createAppPageArtifactCompatibility(\n element: ReactNode | Readonly<Record<string, ReactNode>>,\n routePattern: string,\n): ArtifactCompatibilityEnvelope | undefined {\n if (!isAppElementsRecord(element)) {\n return undefined;\n }\n\n const rootBoundaryId = readRootBoundaryId(element);\n return createArtifactCompatibilityEnvelope({\n graphVersion: createArtifactCompatibilityGraphVersion({\n routePattern,\n rootBoundaryId,\n }),\n deploymentVersion: process.env.__VINEXT_BUILD_ID ?? null,\n rootBoundaryId,\n });\n}\n\n/**\n * Wraps an RSC response body to report invalid dynamic usage errors after the\n * stream is fully consumed. In dev mode, errors from cookies()/headers() inside\n * \"use cache\" may be caught by user try/catch and silently swallowed — this\n * wrapper waits for the stream to drain and surfaces any recorded error to the\n * terminal (and, via HMR, the browser dev overlay).\n *\n * Dedups against React's Flight error chunk: if the recorded error already\n * carries a `digest`, React's serverComponentsErrorHandler has already stamped\n * it and emitted it into the RSC stream. Skipping `console.error` prevents\n * double-logging. Caught cases (no digest) still surface here.\n *\n * Ported from Next.js:\n * https://github.com/vercel/next.js/commit/f5e54c06726b571a042fce67417e40a29f6b8689\n * https://github.com/vercel/next.js/pull/93706\n */\nfunction wrapRscResponseForDevErrorReporting(\n response: Response,\n consumeInvalidDynamicUsageError: () => unknown,\n): Response {\n const originalBody = response.body;\n if (!originalBody) return response;\n\n let consumed = false;\n const onConsumed = () => {\n if (consumed) return;\n consumed = true;\n const error = consumeInvalidDynamicUsageError();\n if (!error) return;\n // Dedup: React already emitted this error as a Flight error chunk.\n if (!hasDigest(error)) {\n console.error(\"[vinext] Invalid dynamic usage:\", error);\n }\n };\n\n const cleanup = new TransformStream<Uint8Array, Uint8Array>({\n flush() {\n onConsumed();\n },\n });\n\n const piped = originalBody.pipeThrough(cleanup);\n const reader = piped.getReader();\n const wrappedStream = new ReadableStream<Uint8Array>({\n pull(controller) {\n return reader.read().then(\n ({ done, value }) => {\n if (done) {\n controller.close();\n } else {\n controller.enqueue(value);\n }\n },\n (streamError) => {\n onConsumed();\n controller.error(streamError);\n },\n );\n },\n cancel(reason) {\n onConsumed();\n return reader.cancel(reason);\n },\n });\n\n return new Response(wrappedStream, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n}\n\nexport async function renderAppPageLifecycle(\n options: RenderAppPageLifecycleOptions,\n): Promise<Response> {\n const preRenderResult = await probeAppPageBeforeRender({\n hasLoadingBoundary: options.hasLoadingBoundary,\n layoutCount: options.layoutCount,\n probeLayoutAt(layoutIndex) {\n return options.probeLayoutAt(layoutIndex);\n },\n probePage() {\n return options.probePage();\n },\n renderLayoutSpecialError(specialError, layoutIndex) {\n return options.renderLayoutSpecialError(specialError, layoutIndex);\n },\n renderPageSpecialError(specialError) {\n return options.renderPageSpecialError(specialError);\n },\n resolveSpecialError: resolveAppPageSpecialError,\n runWithSuppressedHookWarning(probe) {\n return options.runWithSuppressedHookWarning(probe);\n },\n classification: options.classification,\n });\n if (preRenderResult.response) {\n return preRenderResult.response;\n }\n\n const layoutFlags = preRenderResult.layoutFlags;\n\n // Render the CANONICAL element. The outgoing payload carries per-layout\n // static/dynamic flags under `__layoutFlags` so the client can later tell\n // which layouts are safe to skip on subsequent navigations.\n const artifactCompatibility = createAppPageArtifactCompatibility(\n options.element,\n options.routePattern,\n );\n const rootBoundaryId = artifactCompatibility?.rootBoundaryId ?? null;\n const renderEpoch = artifactCompatibility?.renderEpoch ?? null;\n const rscOutputScope = createAppPageRscOutputScope({\n element: options.element,\n mountedSlotsHeader: options.mountedSlotsHeader,\n renderEpoch,\n rootBoundaryId,\n routePattern: options.routePattern,\n });\n const htmlOutputScope = createAppPageHtmlOutputScope({\n element: options.element,\n renderEpoch,\n rootBoundaryId,\n routePattern: options.routePattern,\n });\n // Partial payload metadata is a pre-stream snapshot. Fetch tags may still\n // accumulate while the RSC/HTML streams are consumed; complete cache artifact\n // observations below rebuild this field after the stream drains.\n const payloadRenderObservation = createAppPageRenderObservation({\n boundaryOutcome: { kind: \"unknown\" },\n cacheability: \"unknown\",\n cacheTags: options.getPageTags(),\n cleanPathname: options.cleanPathname,\n completeness: \"partial\",\n output: rscOutputScope,\n params: options.params,\n state: options.peekRenderObservationState?.() ?? createEmptyAppPageRenderObservationState(),\n });\n const outgoingElement = AppElementsWire.encodeOutgoingPayload({\n element: options.element,\n layoutFlags,\n ...(artifactCompatibility ? { artifactCompatibility } : {}),\n renderObservation: payloadRenderObservation,\n });\n\n const compileEnd = options.isProduction ? undefined : performance.now();\n const baseOnError = options.createRscOnErrorHandler(options.cleanPathname, options.routePattern);\n const rscErrorTracker = createAppPageRscErrorTracker(baseOnError);\n // Defensive wrap for standalone callers. In the normal dispatch path this is\n // a no-op since dispatchAppPage already activated dedupe. Note that\n // renderToReadableStream returns synchronously — the actual fetch calls\n // happen later during async stream consumption — so the dedupe map a\n // standalone call would establish here is only effective if the caller has\n // an outer runWithRequestContext / runWithFetchDedupe scope keeping the ALS\n // store alive across that consumption.\n const rscStream = runWithFetchDedupe(() =>\n options.renderToReadableStream(outgoingElement, {\n onError: rscErrorTracker.onRenderError,\n }),\n );\n\n let revalidateSeconds = options.revalidateSeconds;\n let expireSeconds = options.expireSeconds;\n const shouldCaptureRscForCacheMetadata =\n options.isProgressiveActionRender !== true &&\n (options.isProduction || options.isPrerender === true) &&\n (revalidateSeconds === null || (revalidateSeconds > 0 && revalidateSeconds !== Infinity)) &&\n !options.isDraftMode &&\n !options.isForceDynamic;\n const rscCapture = teeAppPageRscStreamForCapture(rscStream, shouldCaptureRscForCacheMetadata);\n const rscForResponse = rscCapture.ssrStream;\n\n // When the fused tee (#981) is active, the sideStream carries both the embed\n // transform AND the raw RSC byte accumulation. For RSC requests, we consume\n // the sideStream directly. For HTML requests, handleSsr creates an embed\n // transform from it and fills capturedRscDataRef. The ref object is threaded\n // through so .value is read lazily after handleSsr completes.\n const capturedRscDataRef: { value: Promise<ArrayBuffer> | null } = { value: null };\n if (rscCapture.sideStream && options.isRscRequest) {\n capturedRscDataRef.value = readAppPageBinaryStream(rscCapture.sideStream);\n }\n\n if (options.isRscRequest) {\n if (options.isPrerender === true) {\n await settleCapturedRscRenderForCacheMetadata(capturedRscDataRef.value);\n ({ expireSeconds, revalidateSeconds } = applyRequestCacheLife({\n expireSeconds,\n requestCacheLife: readRequestCacheLifeForPrerender(options),\n revalidateSeconds,\n }));\n }\n\n const dynamicUsedDuringBuild = options.consumeDynamicUsage();\n const rscResponsePolicy = resolveAppPageRscResponsePolicy({\n dynamicUsedDuringBuild,\n isDraftMode: options.isDraftMode,\n isDynamicError: options.isDynamicError,\n isForceDynamic: options.isForceDynamic,\n isForceStatic: options.isForceStatic,\n isProduction: options.isProduction,\n expireSeconds,\n revalidateSeconds,\n });\n const rscResponse = buildAppPageRscResponse(rscForResponse, {\n isEdgeRuntime: options.isEdgeRuntime,\n middlewareContext: options.middlewareContext,\n mountedSlotsHeader: options.mountedSlotsHeader,\n params: options.params,\n policy: rscResponsePolicy,\n timing: buildResponseTiming({\n compileEnd,\n handlerStart: options.handlerStart,\n isProduction: options.isProduction,\n responseKind: \"rsc\",\n }),\n });\n\n // In dev mode, wrap the RSC response body to forward invalid dynamic usage\n // errors after the stream is consumed. This mirrors Next.js behavior where\n // workStore.invalidDynamicUsageError is checked after the accumulated chunks\n // promise resolves (app-render.tsx generateDynamicFlightRenderResultWithStagesInDev).\n // Ported from Next.js: https://github.com/vercel/next.js/commit/f5e54c06726b571a042fce67417e40a29f6b8689\n //\n // Note: This only covers RSC responses (client-side navigations). The HTML path\n // (initial page loads) intentionally defers this coverage — the error is still\n // thrown through the RSC pipeline and captured by rscErrorTracker.onRenderError\n // if uncaught by user code. Full parity with Next.js would require checking\n // invalidDynamicUsageError after SSR rendering, which is deferred as out of scope\n // for this PR focused on client-side navigations.\n const devRscResponse =\n !options.isProduction && rscResponse.body && options.consumeInvalidDynamicUsageError\n ? wrapRscResponseForDevErrorReporting(rscResponse, options.consumeInvalidDynamicUsageError)\n : rscResponse;\n\n return finalizeAppPageRscCacheResponse(devRscResponse, {\n capturedRscDataPromise:\n options.isProduction && shouldCaptureRscForCacheMetadata ? capturedRscDataRef.value : null,\n cleanPathname: options.cleanPathname,\n consumeDynamicUsage: options.consumeDynamicUsage,\n consumeRenderObservationState: options.consumeRenderObservationState,\n createRscRenderObservation(input) {\n return createAppPageRenderObservation({\n boundaryOutcome: { kind: \"success\" },\n cacheability: \"public\",\n cacheTags: input.cacheTags,\n cleanPathname: options.cleanPathname,\n completeness: \"complete\",\n output: rscOutputScope,\n params: options.params,\n state: input.state,\n });\n },\n dynamicUsedDuringBuild,\n getPageTags() {\n return options.getPageTags();\n },\n getRequestCacheLife() {\n return options.getRequestCacheLife();\n },\n isrDebug: options.isrDebug,\n isrRscKey: options.isrRscKey,\n isrSet: options.isrSet,\n interceptionContext: options.interceptionContext,\n mountedSlotsHeader: options.mountedSlotsHeader,\n renderMode: options.renderMode,\n preserveClientResponseHeaders: rscResponsePolicy.cacheState !== \"MISS\",\n expireSeconds,\n revalidateSeconds,\n waitUntil(promise) {\n options.waitUntil?.(promise);\n },\n });\n }\n\n const fontData = createAppPageFontData({\n getLinks: options.getFontLinks,\n getPreloads: options.getFontPreloads,\n getStyles: options.getFontStyles,\n });\n const fontLinkHeader = buildAppPageFontLinkHeader(fontData.preloads);\n let renderEnd: number | undefined;\n\n const htmlRender = await renderAppPageHtmlStreamWithRecovery({\n onShellRendered() {\n if (!options.isProduction) {\n renderEnd = performance.now();\n }\n },\n renderErrorBoundaryResponse(error) {\n return options.renderErrorBoundaryResponse(error);\n },\n async renderHtmlStream() {\n const ssrHandler = await options.loadSsrHandler();\n return renderAppPageHtmlStream({\n capturedRscDataRef,\n fontData,\n navigationContext: options.getNavigationContext(),\n basePath: options.basePath,\n clientTraceMetadata: options.clientTraceMetadata,\n rootParams: options.rootParams,\n formState: options.formState ?? null,\n rscStream: rscForResponse,\n scriptNonce: options.scriptNonce,\n sideStream: rscCapture.sideStream,\n ssrHandler,\n waitForAllReady: options.isPrerender,\n });\n },\n renderSpecialErrorResponse(specialError) {\n return options.renderPageSpecialError(specialError);\n },\n resolveSpecialError: resolveAppPageSpecialError,\n });\n if (htmlRender.response) {\n return htmlRender.response;\n }\n const htmlStream = htmlRender.htmlStream;\n if (!htmlStream) {\n throw new Error(\"[vinext] Expected an HTML stream when no fallback response was returned\");\n }\n\n // Routes with a route-level Suspense boundary (loading.tsx) skip the page\n // probe — the page render happens once, inside the RSC stream. Mirror\n // Next.js's `app-render.tsx:4293` catch shape: by the time the SSR shell\n // promise has resolved, any redirect()/notFound() throw whose async work\n // settles in microtasks during shell rendering has already fired through\n // React's onError and been captured by the tracker. Convert that to a\n // 307/404 before any bytes are flushed.\n //\n // Late rejections — ones that settle after macrotask boundaries (real\n // I/O, setTimeout, etc.) — fall through to the streamed body, exactly\n // as Next.js does. The digest survives in the Flight payload for the\n // client router to consume.\n if (options.hasLoadingBoundary) {\n const captured = rscErrorTracker.getCapturedSpecialError();\n if (captured) {\n const specialError = resolveAppPageSpecialError(captured);\n if (specialError) {\n void htmlStream.cancel().catch(() => {});\n return options.renderPageSpecialError(specialError);\n }\n }\n }\n\n if (\n shouldRerenderAppPageWithGlobalError({\n capturedError: rscErrorTracker.getCapturedError(),\n hasLocalBoundary: options.routeHasLocalBoundary,\n })\n ) {\n const cleanResponse = await options.renderErrorBoundaryResponse(\n rscErrorTracker.getCapturedError(),\n );\n if (cleanResponse) {\n return cleanResponse;\n }\n }\n\n // Eagerly read values that must be captured before the stream is consumed.\n if (options.isPrerender === true) {\n await settleCapturedRscRenderForCacheMetadata(capturedRscDataRef.value);\n ({ expireSeconds, revalidateSeconds } = applyRequestCacheLife({\n expireSeconds,\n requestCacheLife: readRequestCacheLifeForPrerender(options),\n revalidateSeconds,\n }));\n }\n const draftCookie = options.getDraftModeCookieHeader();\n const dynamicUsedDuringRender = options.consumeDynamicUsage();\n let dynamicUsedBeforeContextCleanup = dynamicUsedDuringRender;\n\n // Defer clearRequestContext() until the HTML stream is fully consumed by the\n // HTTP layer. The RSC/SSR pipeline is lazy — Server Components execute while\n // the response body is being pulled, not when the stream handle is returned.\n // Clearing the context synchronously here would race those executions, causing\n // headers()/cookies() to see a null context on warm (module-cached) requests.\n // See: https://github.com/cloudflare/vinext/issues/660\n const safeHtmlStream = deferUntilStreamConsumed(htmlStream, () => {\n dynamicUsedBeforeContextCleanup =\n dynamicUsedBeforeContextCleanup || options.consumeDynamicUsage();\n options.clearRequestContext();\n });\n\n const htmlResponsePolicy = resolveAppPageHtmlResponsePolicy({\n dynamicUsedDuringRender,\n isProgressiveActionRender: options.isProgressiveActionRender === true,\n hasScriptNonce: Boolean(options.scriptNonce),\n isDraftMode: options.isDraftMode,\n isDynamicError: options.isDynamicError,\n isForceDynamic: options.isForceDynamic,\n isForceStatic: options.isForceStatic,\n isProduction: options.isProduction,\n expireSeconds,\n revalidateSeconds,\n });\n const htmlResponseTiming = buildResponseTiming({\n compileEnd,\n handlerStart: options.handlerStart,\n isProduction: options.isProduction,\n renderEnd,\n responseKind: \"html\",\n });\n\n const shouldSpeculativelyWriteCache =\n options.isProduction &&\n shouldCaptureRscForCacheMetadata &&\n revalidateSeconds === null &&\n !options.isDynamicError &&\n !options.isForceStatic &&\n !options.scriptNonce &&\n options.isProgressiveActionRender !== true &&\n !dynamicUsedDuringRender;\n\n if (htmlResponsePolicy.shouldWriteToCache || shouldSpeculativelyWriteCache) {\n const isrResponse = buildAppPageHtmlResponse(safeHtmlStream, {\n draftCookie,\n fontLinkHeader,\n isEdgeRuntime: options.isEdgeRuntime,\n middlewareContext: options.middlewareContext,\n policy: htmlResponsePolicy,\n timing: htmlResponseTiming,\n });\n\n if (options.isPrerender === true) {\n return isrResponse;\n }\n\n return finalizeAppPageHtmlCacheResponse(isrResponse, {\n capturedDynamicUsageBeforeContextCleanup() {\n return dynamicUsedBeforeContextCleanup;\n },\n capturedRscDataPromise: capturedRscDataRef.value,\n cleanPathname: options.cleanPathname,\n consumeDynamicUsage: options.consumeDynamicUsage,\n consumeRenderObservationState: options.consumeRenderObservationState,\n createHtmlRenderObservation(input) {\n return createAppPageRenderObservation({\n boundaryOutcome: { kind: \"success\" },\n cacheability: \"public\",\n cacheTags: input.cacheTags,\n cleanPathname: options.cleanPathname,\n completeness: \"complete\",\n output: htmlOutputScope,\n params: options.params,\n state: input.state,\n });\n },\n createRscRenderObservation(input) {\n return createAppPageRenderObservation({\n boundaryOutcome: { kind: \"success\" },\n cacheability: \"public\",\n cacheTags: input.cacheTags,\n cleanPathname: options.cleanPathname,\n completeness: \"complete\",\n output: rscOutputScope,\n params: options.params,\n state: input.state,\n });\n },\n getPageTags() {\n return options.getPageTags();\n },\n getRequestCacheLife() {\n return options.getRequestCacheLife();\n },\n isrDebug: options.isrDebug,\n isrHtmlKey: options.isrHtmlKey,\n isrRscKey: options.isrRscKey,\n isrSet: options.isrSet,\n interceptionContext: options.interceptionContext,\n preserveClientResponseHeaders: !htmlResponsePolicy.shouldWriteToCache,\n expireSeconds,\n revalidateSeconds,\n waitUntil(cachePromise) {\n options.waitUntil?.(cachePromise);\n },\n });\n }\n\n return buildAppPageHtmlResponse(safeHtmlStream, {\n draftCookie,\n fontLinkHeader,\n isEdgeRuntime: options.isEdgeRuntime,\n middlewareContext: options.middlewareContext,\n policy: htmlResponsePolicy,\n timing: htmlResponseTiming,\n });\n}\n\nasync function settleCapturedRscRenderForCacheMetadata(\n capturedRscDataPromise: Promise<ArrayBuffer> | null,\n): Promise<void> {\n if (!capturedRscDataPromise) {\n return;\n }\n\n try {\n await capturedRscDataPromise;\n } catch {\n // The response stream and cache-write path own render error propagation.\n // This pre-read only makes \"use cache\" metadata available before headers\n // and ISR seed metadata are finalized.\n }\n}\n"],"mappings":";;;;;;;;;;;;AAmJA,SAAS,oBACP,SAKmC;CACnC,IAAI,QAAQ,cACV;CAGF,OAAO;EACL,YAAY,QAAQ;EACpB,cAAc,QAAQ;EACtB,WAAW,QAAQ;EACnB,cAAc,QAAQ;EACvB;;AAGH,SAAS,iCACP,SACgC;CAIhC,OAAO,QAAQ,wBAAwB,IAAI,QAAQ,qBAAqB;;AAG1E,SAAS,sBAAsB,SAIkC;CAC/D,IAAI,oBAAoB,QAAQ;CAChC,IAAI,gBAAgB,QAAQ;CAC5B,MAAM,mBAAmB,QAAQ;CAEjC,IAAI,kBAAkB,eAAe,KAAA,GACnC,oBACE,sBAAsB,OAClB,iBAAiB,aACjB,KAAK,IAAI,mBAAmB,iBAAiB,WAAW;CAEhE,IAAI,kBAAkB,WAAW,KAAA,GAG/B,gBAAgB,iBAAiB;CAGnC,OAAO;EAAE;EAAe;EAAmB;;AAG7C,SAAS,mBAAmB,SAA2D;CACrF,MAAM,qBAAqB,QAAQ,gBAAgB,KAAK;CACxD,OAAO,OAA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MAAM;SACA"}
|
|
@@ -57,7 +57,7 @@ type ResolveAppPageInterceptMatchResult<TRoute, TInterceptOpts> = {
|
|
|
57
57
|
sourceParams: AppPageParams;
|
|
58
58
|
sourceRoute: TRoute;
|
|
59
59
|
};
|
|
60
|
-
type
|
|
60
|
+
type ResolveAppPageInterceptionRerenderTargetOptions<TRoute, TPage, TInterceptOpts> = {
|
|
61
61
|
cleanPathname: string;
|
|
62
62
|
currentParams: AppPageParams;
|
|
63
63
|
currentRoute: TRoute;
|
|
@@ -67,12 +67,14 @@ type ResolveAppPageActionRerenderTargetOptions<TRoute, TPage, TInterceptOpts> =
|
|
|
67
67
|
isRscRequest: boolean;
|
|
68
68
|
toInterceptOpts: (intercept: AppPageInterceptMatch<TPage>) => TInterceptOpts;
|
|
69
69
|
};
|
|
70
|
-
type
|
|
70
|
+
type ResolveAppPageInterceptionRerenderTargetResult<TRoute, TInterceptOpts> = {
|
|
71
71
|
interceptOpts: TInterceptOpts | undefined;
|
|
72
72
|
navigationParams: AppPageParams;
|
|
73
73
|
params: AppPageParams;
|
|
74
74
|
route: TRoute;
|
|
75
75
|
};
|
|
76
|
+
type ResolveAppPageActionRerenderTargetOptions<TRoute, TPage, TInterceptOpts> = ResolveAppPageInterceptionRerenderTargetOptions<TRoute, TPage, TInterceptOpts>;
|
|
77
|
+
type ResolveAppPageActionRerenderTargetResult<TRoute, TInterceptOpts> = ResolveAppPageInterceptionRerenderTargetResult<TRoute, TInterceptOpts>;
|
|
76
78
|
type ResolveAppPageInterceptOptions<TRoute, TPage, TInterceptOpts, TElement> = {
|
|
77
79
|
buildPageElement: (route: TRoute, params: AppPageParams, interceptOpts: TInterceptOpts | undefined, searchParams: URLSearchParams) => Promise<TElement>;
|
|
78
80
|
cleanPathname: string;
|
|
@@ -113,9 +115,10 @@ declare function validateAppPageDynamicParams(options: ValidateAppPageDynamicPar
|
|
|
113
115
|
* POST path (entries/app-rsc-entry.ts), which runs its own response pipeline.
|
|
114
116
|
*/
|
|
115
117
|
declare function resolveAppPageInterceptMatch<TRoute, TPage, TInterceptOpts>(options: ResolveAppPageInterceptMatchOptions<TRoute, TPage, TInterceptOpts>): ResolveAppPageInterceptMatchResult<TRoute, TInterceptOpts> | null;
|
|
118
|
+
declare function resolveAppPageInterceptionRerenderTarget<TRoute, TPage, TInterceptOpts>(options: ResolveAppPageInterceptionRerenderTargetOptions<TRoute, TPage, TInterceptOpts>): ResolveAppPageInterceptionRerenderTargetResult<TRoute, TInterceptOpts>;
|
|
116
119
|
declare function resolveAppPageActionRerenderTarget<TRoute, TPage, TInterceptOpts>(options: ResolveAppPageActionRerenderTargetOptions<TRoute, TPage, TInterceptOpts>): ResolveAppPageActionRerenderTargetResult<TRoute, TInterceptOpts>;
|
|
117
120
|
declare function resolveAppPageIntercept<TRoute, TPage, TInterceptOpts, TElement>(options: ResolveAppPageInterceptOptions<TRoute, TPage, TInterceptOpts, TElement>): Promise<ResolveAppPageInterceptResult<TInterceptOpts>>;
|
|
118
121
|
declare function buildAppPageElement<TElement>(options: BuildAppPageElementOptions<TElement>): Promise<BuildAppPageElementResult<TElement>>;
|
|
119
122
|
//#endregion
|
|
120
|
-
export { ValidateAppPageDynamicParamsOptions, buildAppPageElement, resolveAppPageActionRerenderTarget, resolveAppPageGenerateStaticParamsSources, resolveAppPageIntercept, resolveAppPageInterceptMatch, validateAppPageDynamicParams };
|
|
123
|
+
export { ValidateAppPageDynamicParamsOptions, buildAppPageElement, resolveAppPageActionRerenderTarget, resolveAppPageGenerateStaticParamsSources, resolveAppPageIntercept, resolveAppPageInterceptMatch, resolveAppPageInterceptionRerenderTarget, validateAppPageDynamicParams };
|
|
121
124
|
//# sourceMappingURL=app-page-request.d.ts.map
|
|
@@ -116,7 +116,7 @@ function resolveAppPageInterceptState(options) {
|
|
|
116
116
|
sourceRoute
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
|
-
function
|
|
119
|
+
function resolveAppPageInterceptionRerenderTarget(options) {
|
|
120
120
|
const interceptState = resolveAppPageInterceptState({
|
|
121
121
|
cleanPathname: options.cleanPathname,
|
|
122
122
|
currentRoute: options.currentRoute,
|
|
@@ -139,6 +139,9 @@ function resolveAppPageActionRerenderTarget(options) {
|
|
|
139
139
|
route: options.currentRoute
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
|
+
function resolveAppPageActionRerenderTarget(options) {
|
|
143
|
+
return resolveAppPageInterceptionRerenderTarget(options);
|
|
144
|
+
}
|
|
142
145
|
async function resolveAppPageIntercept(options) {
|
|
143
146
|
const interceptState = resolveAppPageInterceptState({
|
|
144
147
|
cleanPathname: options.cleanPathname,
|
|
@@ -187,6 +190,6 @@ async function buildAppPageElement(options) {
|
|
|
187
190
|
}
|
|
188
191
|
}
|
|
189
192
|
//#endregion
|
|
190
|
-
export { buildAppPageElement, resolveAppPageActionRerenderTarget, resolveAppPageGenerateStaticParamsSources, resolveAppPageIntercept, resolveAppPageInterceptMatch, validateAppPageDynamicParams };
|
|
193
|
+
export { buildAppPageElement, resolveAppPageActionRerenderTarget, resolveAppPageGenerateStaticParamsSources, resolveAppPageIntercept, resolveAppPageInterceptMatch, resolveAppPageInterceptionRerenderTarget, validateAppPageDynamicParams };
|
|
191
194
|
|
|
192
195
|
//# sourceMappingURL=app-page-request.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-page-request.js","names":[],"sources":["../../src/server/app-page-request.ts"],"sourcesContent":["import type { AppPageSpecialError } from \"./app-page-execution.js\";\nimport { runWithFetchDedupe } from \"vinext/shims/fetch-cache\";\nimport { getAppPageSegmentParamName } from \"./app-page-params.js\";\nimport { notFoundResponse } from \"./http-error-responses.js\";\n\ntype AppPageParams = Record<string, string | string[]>;\ntype GenerateStaticParams = (args: { params: AppPageParams }) => unknown;\n\ntype GenerateStaticParamsModule = {\n generateStaticParams?: GenerateStaticParams | null;\n};\n\ntype GenerateStaticParamsSource = {\n generateStaticParams: GenerateStaticParams;\n parentParamNames: readonly string[];\n};\n\nexport type ValidateAppPageDynamicParamsOptions = {\n clearRequestContext: () => void;\n enforceStaticParamsOnly: boolean;\n generateStaticParams?:\n | GenerateStaticParams\n | GenerateStaticParamsSource\n | readonly (GenerateStaticParams | GenerateStaticParamsSource | null | undefined)[]\n | null;\n isDynamicRoute: boolean;\n params: AppPageParams;\n};\n\ntype ResolveAppPageGenerateStaticParamsSourcesOptions = {\n layouts?: readonly (GenerateStaticParamsModule | null | undefined)[];\n layoutTreePositions?: readonly number[];\n page?: GenerateStaticParamsModule | null;\n routeSegments: readonly string[];\n};\n\ntype BuildAppPageElementOptions<TElement> = {\n buildPageElement: () => Promise<TElement>;\n renderErrorBoundaryPage: (error: unknown) => Promise<Response | null>;\n renderSpecialError: (specialError: AppPageSpecialError) => Promise<Response>;\n resolveSpecialError: (error: unknown) => AppPageSpecialError | null;\n};\n\ntype BuildAppPageElementResult<TElement> = {\n element: TElement | null;\n response: Response | null;\n};\n\ntype AppPageInterceptMatch<TPage = unknown> = {\n matchedParams: AppPageParams;\n page: TPage;\n slotId?: string | null;\n slotKey: string;\n sourceRouteIndex: number;\n};\n\ntype ResolveAppPageInterceptMatchOptions<TRoute, TPage, TInterceptOpts> = {\n cleanPathname: string;\n currentRoute: TRoute;\n findIntercept: (pathname: string) => AppPageInterceptMatch<TPage> | null;\n getRouteParamNames: (route: TRoute) => readonly string[];\n getSourceRoute: (sourceRouteIndex: number) => TRoute | undefined;\n isRscRequest: boolean;\n toInterceptOpts: (intercept: AppPageInterceptMatch<TPage>) => TInterceptOpts;\n};\n\ntype ResolveAppPageInterceptMatchResult<TRoute, TInterceptOpts> = {\n interceptOpts: TInterceptOpts;\n matchedParams: AppPageParams;\n sourceParams: AppPageParams;\n sourceRoute: TRoute;\n};\n\ntype AppPageInterceptState<TRoute, TPage> =\n | { kind: \"none\" }\n | { kind: \"current-route\"; intercept: AppPageInterceptMatch<TPage> }\n | { kind: \"source-route\"; intercept: AppPageInterceptMatch<TPage>; sourceRoute: TRoute };\n\ntype ResolveAppPageActionRerenderTargetOptions<TRoute, TPage, TInterceptOpts> = {\n cleanPathname: string;\n currentParams: AppPageParams;\n currentRoute: TRoute;\n findIntercept: (pathname: string) => AppPageInterceptMatch<TPage> | null;\n getRouteParamNames: (route: TRoute) => readonly string[];\n getSourceRoute: (sourceRouteIndex: number) => TRoute | undefined;\n isRscRequest: boolean;\n toInterceptOpts: (intercept: AppPageInterceptMatch<TPage>) => TInterceptOpts;\n};\n\ntype ResolveAppPageActionRerenderTargetResult<TRoute, TInterceptOpts> = {\n interceptOpts: TInterceptOpts | undefined;\n navigationParams: AppPageParams;\n params: AppPageParams;\n route: TRoute;\n};\n\ntype ResolveAppPageInterceptOptions<TRoute, TPage, TInterceptOpts, TElement> = {\n buildPageElement: (\n route: TRoute,\n params: AppPageParams,\n interceptOpts: TInterceptOpts | undefined,\n searchParams: URLSearchParams,\n ) => Promise<TElement>;\n cleanPathname: string;\n currentRoute: TRoute;\n findIntercept: (pathname: string) => AppPageInterceptMatch<TPage> | null;\n getRouteParamNames: (route: TRoute) => readonly string[];\n getSourceRoute: (sourceRouteIndex: number) => TRoute | undefined;\n isRscRequest: boolean;\n renderInterceptResponse: (route: TRoute, element: TElement) => Promise<Response> | Response;\n searchParams: URLSearchParams;\n setNavigationContext: (context: {\n params: AppPageParams;\n pathname: string;\n searchParams: URLSearchParams;\n }) => void;\n toInterceptOpts: (intercept: AppPageInterceptMatch<TPage>) => TInterceptOpts;\n};\n\ntype ResolveAppPageInterceptResult<TInterceptOpts> = {\n interceptOpts: TInterceptOpts | undefined;\n response: Response | null;\n};\n\nfunction pickRouteParams(\n matchedParams: AppPageParams,\n routeParamNames: readonly string[],\n): AppPageParams {\n const params: AppPageParams = {};\n\n for (const paramName of routeParamNames) {\n const value = matchedParams[paramName];\n if (value !== undefined) {\n params[paramName] = value;\n }\n }\n\n return params;\n}\n\nfunction collectParentParamNames(\n routeSegments: readonly string[],\n boundaryPosition: number,\n): string[] {\n const limit = Math.max(0, Math.min(boundaryPosition, routeSegments.length));\n const names: string[] = [];\n\n for (const segment of routeSegments.slice(0, limit)) {\n const name = getAppPageSegmentParamName(segment);\n if (name && !names.includes(name)) {\n names.push(name);\n }\n }\n\n return names;\n}\n\nfunction getLayoutGenerateStaticParamsBoundary(layoutTreePosition: number | undefined): number {\n // A layout at app/[id]/layout.tsx has tree position 1, but its\n // generateStaticParams belongs to the [id] segment and receives only parent\n // params from segments before [id].\n return (layoutTreePosition ?? 0) - 1;\n}\n\nexport function resolveAppPageGenerateStaticParamsSources(\n options: ResolveAppPageGenerateStaticParamsSourcesOptions,\n): GenerateStaticParamsSource[] {\n const sources: GenerateStaticParamsSource[] = [];\n\n options.layouts?.forEach((layout, index) => {\n if (typeof layout?.generateStaticParams !== \"function\") return;\n\n sources.push({\n generateStaticParams: layout.generateStaticParams,\n parentParamNames: collectParentParamNames(\n options.routeSegments,\n getLayoutGenerateStaticParamsBoundary(options.layoutTreePositions?.[index]),\n ),\n });\n });\n\n if (typeof options.page?.generateStaticParams === \"function\") {\n sources.push({\n generateStaticParams: options.page.generateStaticParams,\n parentParamNames: collectParentParamNames(\n options.routeSegments,\n Math.max(0, options.routeSegments.length - 1),\n ),\n });\n }\n\n return sources;\n}\n\nfunction areStaticParamsAllowed(\n params: AppPageParams,\n staticParams: readonly Record<string, unknown>[],\n): boolean {\n const paramKeys = Object.keys(params);\n\n return staticParams.some((staticParamSet) =>\n paramKeys.every((key) => {\n const value = params[key];\n const staticValue = staticParamSet[key];\n\n // Parent params may not appear in the leaf route's returned set because\n // Next.js passes them top-down through nested generateStaticParams calls.\n if (staticValue === undefined) {\n return true;\n }\n\n if (Array.isArray(value)) {\n return JSON.stringify(value) === JSON.stringify(staticValue);\n }\n\n if (\n typeof staticValue === \"string\" ||\n typeof staticValue === \"number\" ||\n typeof staticValue === \"boolean\"\n ) {\n return String(value) === String(staticValue);\n }\n\n return JSON.stringify(value) === JSON.stringify(staticValue);\n }),\n );\n}\n\nfunction normalizeGenerateStaticParams(\n generateStaticParams: ValidateAppPageDynamicParamsOptions[\"generateStaticParams\"],\n): GenerateStaticParamsSource[] {\n const sources = Array.isArray(generateStaticParams)\n ? generateStaticParams\n : [generateStaticParams];\n\n return sources.flatMap((source) => {\n if (typeof source === \"function\") {\n return [{ generateStaticParams: source, parentParamNames: [] }];\n }\n\n if (typeof source?.generateStaticParams === \"function\") {\n return [source];\n }\n\n return [];\n });\n}\n\nexport async function validateAppPageDynamicParams(\n options: ValidateAppPageDynamicParamsOptions,\n): Promise<Response | null> {\n if (!options.enforceStaticParamsOnly || !options.isDynamicRoute) {\n return null;\n }\n\n const generateStaticParamsSources = normalizeGenerateStaticParams(options.generateStaticParams);\n if (generateStaticParamsSources.length === 0) {\n options.clearRequestContext();\n return notFoundResponse();\n }\n\n for (const source of generateStaticParamsSources) {\n const staticParams = await runWithFetchDedupe(() =>\n source.generateStaticParams({\n params: pickRouteParams(options.params, source.parentParamNames),\n }),\n );\n if (Array.isArray(staticParams) && !areStaticParamsAllowed(options.params, staticParams)) {\n options.clearRequestContext();\n return notFoundResponse();\n }\n }\n\n return null;\n}\n\n/**\n * Pure: decides whether the incoming request should re-render an intercepted\n * source-route tree, and if so returns the source route, the source-route's\n * param slice, the full matched param set (the URL params the client sees),\n * and an opaque `interceptOpts` bag for the caller's render pipeline.\n *\n * Returns `null` in three decision-fallthrough cases:\n * - non-RSC requests (server rendering the direct page for a full HTML load)\n * - no intercepting route matches the path\n * - the match's source route IS the current route (the same branch today\n * returns `interceptOpts` for the direct render)\n *\n * Shared by both the GET path (resolveAppPageIntercept, which layers on\n * `setNavigationContext` + element build + Response wrap) and the server-action\n * POST path (entries/app-rsc-entry.ts), which runs its own response pipeline.\n */\nexport function resolveAppPageInterceptMatch<TRoute, TPage, TInterceptOpts>(\n options: ResolveAppPageInterceptMatchOptions<TRoute, TPage, TInterceptOpts>,\n): ResolveAppPageInterceptMatchResult<TRoute, TInterceptOpts> | null {\n const interceptState = resolveAppPageInterceptState(options);\n if (interceptState.kind !== \"source-route\") {\n return null;\n }\n\n return {\n interceptOpts: options.toInterceptOpts(interceptState.intercept),\n matchedParams: interceptState.intercept.matchedParams,\n sourceParams: pickRouteParams(\n interceptState.intercept.matchedParams,\n options.getRouteParamNames(interceptState.sourceRoute),\n ),\n sourceRoute: interceptState.sourceRoute,\n };\n}\n\nfunction resolveAppPageInterceptState<TRoute, TPage, TInterceptOpts>(\n options: ResolveAppPageInterceptMatchOptions<TRoute, TPage, TInterceptOpts>,\n): AppPageInterceptState<TRoute, TPage> {\n if (!options.isRscRequest) {\n return { kind: \"none\" };\n }\n\n const intercept = options.findIntercept(options.cleanPathname);\n if (!intercept) {\n return { kind: \"none\" };\n }\n\n const sourceRoute = options.getSourceRoute(intercept.sourceRouteIndex);\n if (!sourceRoute) {\n return { kind: \"none\" };\n }\n\n if (sourceRoute === options.currentRoute) {\n return { kind: \"current-route\", intercept };\n }\n\n return { kind: \"source-route\", intercept, sourceRoute };\n}\n\nexport function resolveAppPageActionRerenderTarget<TRoute, TPage, TInterceptOpts>(\n options: ResolveAppPageActionRerenderTargetOptions<TRoute, TPage, TInterceptOpts>,\n): ResolveAppPageActionRerenderTargetResult<TRoute, TInterceptOpts> {\n const interceptState = resolveAppPageInterceptState({\n cleanPathname: options.cleanPathname,\n currentRoute: options.currentRoute,\n findIntercept: options.findIntercept,\n getRouteParamNames: options.getRouteParamNames,\n getSourceRoute: options.getSourceRoute,\n isRscRequest: options.isRscRequest,\n toInterceptOpts: options.toInterceptOpts,\n });\n\n if (interceptState.kind === \"source-route\") {\n return {\n interceptOpts: options.toInterceptOpts(interceptState.intercept),\n navigationParams: interceptState.intercept.matchedParams,\n params: pickRouteParams(\n interceptState.intercept.matchedParams,\n options.getRouteParamNames(interceptState.sourceRoute),\n ),\n route: interceptState.sourceRoute,\n };\n }\n\n return {\n interceptOpts:\n interceptState.kind === \"current-route\"\n ? options.toInterceptOpts(interceptState.intercept)\n : undefined,\n navigationParams: options.currentParams,\n params: options.currentParams,\n route: options.currentRoute,\n };\n}\n\nexport async function resolveAppPageIntercept<TRoute, TPage, TInterceptOpts, TElement>(\n options: ResolveAppPageInterceptOptions<TRoute, TPage, TInterceptOpts, TElement>,\n): Promise<ResolveAppPageInterceptResult<TInterceptOpts>> {\n const interceptState = resolveAppPageInterceptState({\n cleanPathname: options.cleanPathname,\n currentRoute: options.currentRoute,\n findIntercept: options.findIntercept,\n getRouteParamNames: options.getRouteParamNames,\n getSourceRoute: options.getSourceRoute,\n isRscRequest: options.isRscRequest,\n toInterceptOpts: options.toInterceptOpts,\n });\n\n if (interceptState.kind === \"source-route\") {\n options.setNavigationContext({\n params: interceptState.intercept.matchedParams,\n pathname: options.cleanPathname,\n searchParams: options.searchParams,\n });\n const interceptElement = await options.buildPageElement(\n interceptState.sourceRoute,\n pickRouteParams(\n interceptState.intercept.matchedParams,\n options.getRouteParamNames(interceptState.sourceRoute),\n ),\n options.toInterceptOpts(interceptState.intercept),\n options.searchParams,\n );\n\n return {\n interceptOpts: undefined,\n response: await options.renderInterceptResponse(interceptState.sourceRoute, interceptElement),\n };\n }\n\n // Reproduce the current-route-is-source branch where we still need the opts\n // bag even though we did not render a separate intercepted response.\n return {\n interceptOpts:\n interceptState.kind === \"current-route\"\n ? options.toInterceptOpts(interceptState.intercept)\n : undefined,\n response: null,\n };\n}\n\nexport async function buildAppPageElement<TElement>(\n options: BuildAppPageElementOptions<TElement>,\n): Promise<BuildAppPageElementResult<TElement>> {\n try {\n return {\n element: await options.buildPageElement(),\n response: null,\n };\n } catch (error) {\n const specialError = options.resolveSpecialError(error);\n if (specialError) {\n return {\n element: null,\n response: await options.renderSpecialError(specialError),\n };\n }\n\n const errorBoundaryResponse = await options.renderErrorBoundaryPage(error);\n if (errorBoundaryResponse) {\n return {\n element: null,\n response: errorBoundaryResponse,\n };\n }\n\n throw error;\n }\n}\n"],"mappings":";;;;AA4HA,SAAS,gBACP,eACA,iBACe;CACf,MAAM,SAAwB,EAAE;CAEhC,KAAK,MAAM,aAAa,iBAAiB;EACvC,M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B,cAAc,QAAQ;GACvB,CAAC;EACF,MAAM,mBAAmB,MAAM,QAAQ,iBACrC,eAAe,aACf,gBACE,eAAe,UAAU,eACzB,QAAQ,mBAAmB,eAAe,YAAY,CACvD,EACD,QAAQ,gBAAgB,eAAe,UAAU,EACjD,QAAQ,aACT;EAED,OAAO;GACL,eAAe,KAAA;GACf,UAAU,MAAM,QAAQ,wBAAwB,eAAe,aAAa,iBAAiB;GAC9F;;CAKH,OAAO;EACL,eACE,eAAe,SAAS,kBACpB,QAAQ,gBAAgB,eAAe,UAAU,GACjD,KAAA;EACN,UAAU;EACX;;AAGH,eAAsB,oBACpB,SAC8C;CAC9C,IAAI;EACF,OAAO;GACL,SAAS,MAAM,QAAQ,kBAAkB;GACzC,UAAU;GACX;UACM,OAAO;EACd,MAAM,eAAe,QAAQ,oBAAoB,MAAM;EACvD,IAAI,cACF,OAAO;GACL,SAAS;GACT,UAAU,MAAM,QAAQ,mBAAmB,aAAa;GACzD;EAGH,MAAM,wBAAwB,MAAM,QAAQ,wBAAwB,MAAM;EAC1E,IAAI,uBACF,OAAO;GACL,SAAS;GACT,UAAU;GACX;EAGH,MAAM"}
|
|
1
|
+
{"version":3,"file":"app-page-request.js","names":[],"sources":["../../src/server/app-page-request.ts"],"sourcesContent":["import type { AppPageSpecialError } from \"./app-page-execution.js\";\nimport { runWithFetchDedupe } from \"vinext/shims/fetch-cache\";\nimport { getAppPageSegmentParamName } from \"./app-page-params.js\";\nimport { notFoundResponse } from \"./http-error-responses.js\";\n\ntype AppPageParams = Record<string, string | string[]>;\ntype GenerateStaticParams = (args: { params: AppPageParams }) => unknown;\n\ntype GenerateStaticParamsModule = {\n generateStaticParams?: GenerateStaticParams | null;\n};\n\ntype GenerateStaticParamsSource = {\n generateStaticParams: GenerateStaticParams;\n parentParamNames: readonly string[];\n};\n\nexport type ValidateAppPageDynamicParamsOptions = {\n clearRequestContext: () => void;\n enforceStaticParamsOnly: boolean;\n generateStaticParams?:\n | GenerateStaticParams\n | GenerateStaticParamsSource\n | readonly (GenerateStaticParams | GenerateStaticParamsSource | null | undefined)[]\n | null;\n isDynamicRoute: boolean;\n params: AppPageParams;\n};\n\ntype ResolveAppPageGenerateStaticParamsSourcesOptions = {\n layouts?: readonly (GenerateStaticParamsModule | null | undefined)[];\n layoutTreePositions?: readonly number[];\n page?: GenerateStaticParamsModule | null;\n routeSegments: readonly string[];\n};\n\ntype BuildAppPageElementOptions<TElement> = {\n buildPageElement: () => Promise<TElement>;\n renderErrorBoundaryPage: (error: unknown) => Promise<Response | null>;\n renderSpecialError: (specialError: AppPageSpecialError) => Promise<Response>;\n resolveSpecialError: (error: unknown) => AppPageSpecialError | null;\n};\n\ntype BuildAppPageElementResult<TElement> = {\n element: TElement | null;\n response: Response | null;\n};\n\ntype AppPageInterceptMatch<TPage = unknown> = {\n matchedParams: AppPageParams;\n page: TPage;\n slotId?: string | null;\n slotKey: string;\n sourceRouteIndex: number;\n};\n\ntype ResolveAppPageInterceptMatchOptions<TRoute, TPage, TInterceptOpts> = {\n cleanPathname: string;\n currentRoute: TRoute;\n findIntercept: (pathname: string) => AppPageInterceptMatch<TPage> | null;\n getRouteParamNames: (route: TRoute) => readonly string[];\n getSourceRoute: (sourceRouteIndex: number) => TRoute | undefined;\n isRscRequest: boolean;\n toInterceptOpts: (intercept: AppPageInterceptMatch<TPage>) => TInterceptOpts;\n};\n\ntype ResolveAppPageInterceptMatchResult<TRoute, TInterceptOpts> = {\n interceptOpts: TInterceptOpts;\n matchedParams: AppPageParams;\n sourceParams: AppPageParams;\n sourceRoute: TRoute;\n};\n\ntype AppPageInterceptState<TRoute, TPage> =\n | { kind: \"none\" }\n | { kind: \"current-route\"; intercept: AppPageInterceptMatch<TPage> }\n | { kind: \"source-route\"; intercept: AppPageInterceptMatch<TPage>; sourceRoute: TRoute };\n\ntype ResolveAppPageInterceptionRerenderTargetOptions<TRoute, TPage, TInterceptOpts> = {\n cleanPathname: string;\n currentParams: AppPageParams;\n currentRoute: TRoute;\n findIntercept: (pathname: string) => AppPageInterceptMatch<TPage> | null;\n getRouteParamNames: (route: TRoute) => readonly string[];\n getSourceRoute: (sourceRouteIndex: number) => TRoute | undefined;\n isRscRequest: boolean;\n toInterceptOpts: (intercept: AppPageInterceptMatch<TPage>) => TInterceptOpts;\n};\n\ntype ResolveAppPageInterceptionRerenderTargetResult<TRoute, TInterceptOpts> = {\n interceptOpts: TInterceptOpts | undefined;\n navigationParams: AppPageParams;\n params: AppPageParams;\n route: TRoute;\n};\n\ntype ResolveAppPageActionRerenderTargetOptions<TRoute, TPage, TInterceptOpts> =\n ResolveAppPageInterceptionRerenderTargetOptions<TRoute, TPage, TInterceptOpts>;\n\ntype ResolveAppPageActionRerenderTargetResult<TRoute, TInterceptOpts> =\n ResolveAppPageInterceptionRerenderTargetResult<TRoute, TInterceptOpts>;\n\ntype ResolveAppPageInterceptOptions<TRoute, TPage, TInterceptOpts, TElement> = {\n buildPageElement: (\n route: TRoute,\n params: AppPageParams,\n interceptOpts: TInterceptOpts | undefined,\n searchParams: URLSearchParams,\n ) => Promise<TElement>;\n cleanPathname: string;\n currentRoute: TRoute;\n findIntercept: (pathname: string) => AppPageInterceptMatch<TPage> | null;\n getRouteParamNames: (route: TRoute) => readonly string[];\n getSourceRoute: (sourceRouteIndex: number) => TRoute | undefined;\n isRscRequest: boolean;\n renderInterceptResponse: (route: TRoute, element: TElement) => Promise<Response> | Response;\n searchParams: URLSearchParams;\n setNavigationContext: (context: {\n params: AppPageParams;\n pathname: string;\n searchParams: URLSearchParams;\n }) => void;\n toInterceptOpts: (intercept: AppPageInterceptMatch<TPage>) => TInterceptOpts;\n};\n\ntype ResolveAppPageInterceptResult<TInterceptOpts> = {\n interceptOpts: TInterceptOpts | undefined;\n response: Response | null;\n};\n\nfunction pickRouteParams(\n matchedParams: AppPageParams,\n routeParamNames: readonly string[],\n): AppPageParams {\n const params: AppPageParams = {};\n\n for (const paramName of routeParamNames) {\n const value = matchedParams[paramName];\n if (value !== undefined) {\n params[paramName] = value;\n }\n }\n\n return params;\n}\n\nfunction collectParentParamNames(\n routeSegments: readonly string[],\n boundaryPosition: number,\n): string[] {\n const limit = Math.max(0, Math.min(boundaryPosition, routeSegments.length));\n const names: string[] = [];\n\n for (const segment of routeSegments.slice(0, limit)) {\n const name = getAppPageSegmentParamName(segment);\n if (name && !names.includes(name)) {\n names.push(name);\n }\n }\n\n return names;\n}\n\nfunction getLayoutGenerateStaticParamsBoundary(layoutTreePosition: number | undefined): number {\n // A layout at app/[id]/layout.tsx has tree position 1, but its\n // generateStaticParams belongs to the [id] segment and receives only parent\n // params from segments before [id].\n return (layoutTreePosition ?? 0) - 1;\n}\n\nexport function resolveAppPageGenerateStaticParamsSources(\n options: ResolveAppPageGenerateStaticParamsSourcesOptions,\n): GenerateStaticParamsSource[] {\n const sources: GenerateStaticParamsSource[] = [];\n\n options.layouts?.forEach((layout, index) => {\n if (typeof layout?.generateStaticParams !== \"function\") return;\n\n sources.push({\n generateStaticParams: layout.generateStaticParams,\n parentParamNames: collectParentParamNames(\n options.routeSegments,\n getLayoutGenerateStaticParamsBoundary(options.layoutTreePositions?.[index]),\n ),\n });\n });\n\n if (typeof options.page?.generateStaticParams === \"function\") {\n sources.push({\n generateStaticParams: options.page.generateStaticParams,\n parentParamNames: collectParentParamNames(\n options.routeSegments,\n Math.max(0, options.routeSegments.length - 1),\n ),\n });\n }\n\n return sources;\n}\n\nfunction areStaticParamsAllowed(\n params: AppPageParams,\n staticParams: readonly Record<string, unknown>[],\n): boolean {\n const paramKeys = Object.keys(params);\n\n return staticParams.some((staticParamSet) =>\n paramKeys.every((key) => {\n const value = params[key];\n const staticValue = staticParamSet[key];\n\n // Parent params may not appear in the leaf route's returned set because\n // Next.js passes them top-down through nested generateStaticParams calls.\n if (staticValue === undefined) {\n return true;\n }\n\n if (Array.isArray(value)) {\n return JSON.stringify(value) === JSON.stringify(staticValue);\n }\n\n if (\n typeof staticValue === \"string\" ||\n typeof staticValue === \"number\" ||\n typeof staticValue === \"boolean\"\n ) {\n return String(value) === String(staticValue);\n }\n\n return JSON.stringify(value) === JSON.stringify(staticValue);\n }),\n );\n}\n\nfunction normalizeGenerateStaticParams(\n generateStaticParams: ValidateAppPageDynamicParamsOptions[\"generateStaticParams\"],\n): GenerateStaticParamsSource[] {\n const sources = Array.isArray(generateStaticParams)\n ? generateStaticParams\n : [generateStaticParams];\n\n return sources.flatMap((source) => {\n if (typeof source === \"function\") {\n return [{ generateStaticParams: source, parentParamNames: [] }];\n }\n\n if (typeof source?.generateStaticParams === \"function\") {\n return [source];\n }\n\n return [];\n });\n}\n\nexport async function validateAppPageDynamicParams(\n options: ValidateAppPageDynamicParamsOptions,\n): Promise<Response | null> {\n if (!options.enforceStaticParamsOnly || !options.isDynamicRoute) {\n return null;\n }\n\n const generateStaticParamsSources = normalizeGenerateStaticParams(options.generateStaticParams);\n if (generateStaticParamsSources.length === 0) {\n options.clearRequestContext();\n return notFoundResponse();\n }\n\n for (const source of generateStaticParamsSources) {\n const staticParams = await runWithFetchDedupe(() =>\n source.generateStaticParams({\n params: pickRouteParams(options.params, source.parentParamNames),\n }),\n );\n if (Array.isArray(staticParams) && !areStaticParamsAllowed(options.params, staticParams)) {\n options.clearRequestContext();\n return notFoundResponse();\n }\n }\n\n return null;\n}\n\n/**\n * Pure: decides whether the incoming request should re-render an intercepted\n * source-route tree, and if so returns the source route, the source-route's\n * param slice, the full matched param set (the URL params the client sees),\n * and an opaque `interceptOpts` bag for the caller's render pipeline.\n *\n * Returns `null` in three decision-fallthrough cases:\n * - non-RSC requests (server rendering the direct page for a full HTML load)\n * - no intercepting route matches the path\n * - the match's source route IS the current route (the same branch today\n * returns `interceptOpts` for the direct render)\n *\n * Shared by both the GET path (resolveAppPageIntercept, which layers on\n * `setNavigationContext` + element build + Response wrap) and the server-action\n * POST path (entries/app-rsc-entry.ts), which runs its own response pipeline.\n */\nexport function resolveAppPageInterceptMatch<TRoute, TPage, TInterceptOpts>(\n options: ResolveAppPageInterceptMatchOptions<TRoute, TPage, TInterceptOpts>,\n): ResolveAppPageInterceptMatchResult<TRoute, TInterceptOpts> | null {\n const interceptState = resolveAppPageInterceptState(options);\n if (interceptState.kind !== \"source-route\") {\n return null;\n }\n\n return {\n interceptOpts: options.toInterceptOpts(interceptState.intercept),\n matchedParams: interceptState.intercept.matchedParams,\n sourceParams: pickRouteParams(\n interceptState.intercept.matchedParams,\n options.getRouteParamNames(interceptState.sourceRoute),\n ),\n sourceRoute: interceptState.sourceRoute,\n };\n}\n\nfunction resolveAppPageInterceptState<TRoute, TPage, TInterceptOpts>(\n options: ResolveAppPageInterceptMatchOptions<TRoute, TPage, TInterceptOpts>,\n): AppPageInterceptState<TRoute, TPage> {\n if (!options.isRscRequest) {\n return { kind: \"none\" };\n }\n\n const intercept = options.findIntercept(options.cleanPathname);\n if (!intercept) {\n return { kind: \"none\" };\n }\n\n const sourceRoute = options.getSourceRoute(intercept.sourceRouteIndex);\n if (!sourceRoute) {\n return { kind: \"none\" };\n }\n\n if (sourceRoute === options.currentRoute) {\n return { kind: \"current-route\", intercept };\n }\n\n return { kind: \"source-route\", intercept, sourceRoute };\n}\n\nexport function resolveAppPageInterceptionRerenderTarget<TRoute, TPage, TInterceptOpts>(\n options: ResolveAppPageInterceptionRerenderTargetOptions<TRoute, TPage, TInterceptOpts>,\n): ResolveAppPageInterceptionRerenderTargetResult<TRoute, TInterceptOpts> {\n const interceptState = resolveAppPageInterceptState({\n cleanPathname: options.cleanPathname,\n currentRoute: options.currentRoute,\n findIntercept: options.findIntercept,\n getRouteParamNames: options.getRouteParamNames,\n getSourceRoute: options.getSourceRoute,\n isRscRequest: options.isRscRequest,\n toInterceptOpts: options.toInterceptOpts,\n });\n\n if (interceptState.kind === \"source-route\") {\n return {\n interceptOpts: options.toInterceptOpts(interceptState.intercept),\n navigationParams: interceptState.intercept.matchedParams,\n params: pickRouteParams(\n interceptState.intercept.matchedParams,\n options.getRouteParamNames(interceptState.sourceRoute),\n ),\n route: interceptState.sourceRoute,\n };\n }\n\n return {\n interceptOpts:\n interceptState.kind === \"current-route\"\n ? options.toInterceptOpts(interceptState.intercept)\n : undefined,\n navigationParams: options.currentParams,\n params: options.currentParams,\n route: options.currentRoute,\n };\n}\n\nexport function resolveAppPageActionRerenderTarget<TRoute, TPage, TInterceptOpts>(\n options: ResolveAppPageActionRerenderTargetOptions<TRoute, TPage, TInterceptOpts>,\n): ResolveAppPageActionRerenderTargetResult<TRoute, TInterceptOpts> {\n return resolveAppPageInterceptionRerenderTarget(options);\n}\n\nexport async function resolveAppPageIntercept<TRoute, TPage, TInterceptOpts, TElement>(\n options: ResolveAppPageInterceptOptions<TRoute, TPage, TInterceptOpts, TElement>,\n): Promise<ResolveAppPageInterceptResult<TInterceptOpts>> {\n const interceptState = resolveAppPageInterceptState({\n cleanPathname: options.cleanPathname,\n currentRoute: options.currentRoute,\n findIntercept: options.findIntercept,\n getRouteParamNames: options.getRouteParamNames,\n getSourceRoute: options.getSourceRoute,\n isRscRequest: options.isRscRequest,\n toInterceptOpts: options.toInterceptOpts,\n });\n\n if (interceptState.kind === \"source-route\") {\n options.setNavigationContext({\n params: interceptState.intercept.matchedParams,\n pathname: options.cleanPathname,\n searchParams: options.searchParams,\n });\n const interceptElement = await options.buildPageElement(\n interceptState.sourceRoute,\n pickRouteParams(\n interceptState.intercept.matchedParams,\n options.getRouteParamNames(interceptState.sourceRoute),\n ),\n options.toInterceptOpts(interceptState.intercept),\n options.searchParams,\n );\n\n return {\n interceptOpts: undefined,\n response: await options.renderInterceptResponse(interceptState.sourceRoute, interceptElement),\n };\n }\n\n // Reproduce the current-route-is-source branch where we still need the opts\n // bag even though we did not render a separate intercepted response.\n return {\n interceptOpts:\n interceptState.kind === \"current-route\"\n ? options.toInterceptOpts(interceptState.intercept)\n : undefined,\n response: null,\n };\n}\n\nexport async function buildAppPageElement<TElement>(\n options: BuildAppPageElementOptions<TElement>,\n): Promise<BuildAppPageElementResult<TElement>> {\n try {\n return {\n element: await options.buildPageElement(),\n response: null,\n };\n } catch (error) {\n const specialError = options.resolveSpecialError(error);\n if (specialError) {\n return {\n element: null,\n response: await options.renderSpecialError(specialError),\n };\n }\n\n const errorBoundaryResponse = await options.renderErrorBoundaryPage(error);\n if (errorBoundaryResponse) {\n return {\n element: null,\n response: errorBoundaryResponse,\n };\n }\n\n throw error;\n }\n}\n"],"mappings":";;;;AAkIA,SAAS,gBACP,eACA,iBACe;CACf,MAAM,SAAwB,EAAE;CAEhC,KAAK,MAAM,aAAa,iBAAiB;EACvC,MAAM,QAAQ,cAAc;EAC5B,IAAI,UAAU,KAAA,GACZ,OAAO,aAAa;;CAIxB,OAAO;;AAGT,SAAS,wBACP,eACA,kBACU;CACV,MAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,kBAAkB,cAAc,OAAO,CAAC;CAC3E,MAAM,QAAkB,EAAE;CAE1B,KAAK,MAAM,WAAW,cAAc,MAAM,GAAG,MAAM,EAAE;EACnD,MAAM,OAAO,2BAA2B,QAAQ;EAChD,IAAI,QAAQ,CAAC,MAAM,SAAS,KAAK,EAC/B,MAAM,KAAK,KAAK;;CAIpB,OAAO;;AAGT,SAAS,sCAAsC,oBAAgD;CAI7F,QAAQ,sBAAsB,KAAK;;AAGrC,SAAgB,0CACd,SAC8B;CAC9B,MAAM,UAAwC,EAAE;CAEhD,QAAQ,SAAS,SAAS,QAAQ,UAAU;EAC1C,IAAI,OAAO,QAAQ,yBAAyB,YAAY;EAExD,QAAQ,KAAK;GACX,sBAAsB,OAAO;GAC7B,kBAAkB,wBAChB,QAAQ,eACR,sCAAsC,QAAQ,sBAAsB,OAAO,CAC5E;GACF,CAAC;GACF;CAEF,IAAI,OAAO,QAAQ,MAAM,yBAAyB,YAChD,QAAQ,KAAK;EACX,sBAAsB,QAAQ,KAAK;EACnC,kBAAkB,wBAChB,QAAQ,eACR,KAAK,IAAI,GAAG,QAAQ,cAAc,SAAS,EAAE,CAC9C;EACF,CAAC;CAGJ,OAAO;;AAGT,SAAS,uBAC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ChB;;AAGH,SAAgB,mCACd,SACkE;CAClE,OAAO,yCAAyC,QAAQ;;AAG1D,eAAsB,wBACpB,SACwD;CACxD,MAAM,iBAAiB,6BAA6B;EAClD,eAAe,QAAQ;EACvB,cAAc,QAAQ;EACtB,eAAe,QAAQ;EACvB,oBAAoB,QAAQ;EAC5B,gBAAgB,QAAQ;EACxB,cAAc,QAAQ;EACtB,iBAAiB,QAAQ;EAC1B,CAAC;CAEF,IAAI,eAAe,SAAS,gBAAgB;EAC1C,QAAQ,qBAAqB;GAC3B,QAAQ,eAAe,UAAU;GACjC,UAAU,QAAQ;GAClB,cAAc,QAAQ;GACvB,CAAC;EACF,MAAM,mBAAmB,MAAM,QAAQ,iBACrC,eAAe,aACf,gBACE,eAAe,UAAU,eACzB,QAAQ,mBAAmB,eAAe,YAAY,CACvD,EACD,QAAQ,gBAAgB,eAAe,UAAU,EACjD,QAAQ,aACT;EAED,OAAO;GACL,eAAe,KAAA;GACf,UAAU,MAAM,QAAQ,wBAAwB,eAAe,aAAa,iBAAiB;GAC9F;;CAKH,OAAO;EACL,eACE,eAAe,SAAS,kBACpB,QAAQ,gBAAgB,eAAe,UAAU,GACjD,KAAA;EACN,UAAU;EACX;;AAGH,eAAsB,oBACpB,SAC8C;CAC9C,IAAI;EACF,OAAO;GACL,SAAS,MAAM,QAAQ,kBAAkB;GACzC,UAAU;GACX;UACM,OAAO;EACd,MAAM,eAAe,QAAQ,oBAAoB,MAAM;EACvD,IAAI,cACF,OAAO;GACL,SAAS;GACT,UAAU,MAAM,QAAQ,mBAAmB,aAAa;GACzD;EAGH,MAAM,wBAAwB,MAAM,QAAQ,wBAAwB,MAAM;EAC1E,IAAI,uBACF,OAAO;GACL,SAAS;GACT,UAAU;GACX;EAGH,MAAM"}
|
|
@@ -62,8 +62,8 @@ function resolveAppPageHtmlResponsePolicy(options) {
|
|
|
62
62
|
};
|
|
63
63
|
if (options.revalidateSeconds === Infinity) return {
|
|
64
64
|
cacheControl: STATIC_CACHE_CONTROL,
|
|
65
|
-
cacheState: "STATIC",
|
|
66
|
-
shouldWriteToCache:
|
|
65
|
+
cacheState: options.isProduction ? "MISS" : "STATIC",
|
|
66
|
+
shouldWriteToCache: options.isProduction
|
|
67
67
|
};
|
|
68
68
|
return { shouldWriteToCache: false };
|
|
69
69
|
}
|