vinext 0.0.52 → 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/README.md +1 -1
- package/dist/build/clean-output.d.ts +14 -0
- package/dist/build/clean-output.js +36 -0
- package/dist/build/clean-output.js.map +1 -0
- 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.d.ts +6 -2
- package/dist/build/prerender.js +51 -12
- package/dist/build/prerender.js.map +1 -1
- package/dist/build/run-prerender.js +10 -1
- package/dist/build/run-prerender.js.map +1 -1
- package/dist/build/static-export.d.ts +5 -0
- package/dist/build/static-export.js +8 -3
- package/dist/build/static-export.js.map +1 -1
- package/dist/check.js +4 -0
- package/dist/check.js.map +1 -1
- package/dist/cli.js +19 -4
- package/dist/cli.js.map +1 -1
- package/dist/client/instrumentation-client-inject.d.ts +34 -0
- package/dist/client/instrumentation-client-inject.js +57 -0
- package/dist/client/instrumentation-client-inject.js.map +1 -0
- package/dist/client/navigation-runtime.d.ts +16 -2
- package/dist/client/navigation-runtime.js +16 -1
- package/dist/client/navigation-runtime.js.map +1 -1
- package/dist/client/vinext-next-data.d.ts +2 -1
- package/dist/client/vinext-next-data.js.map +1 -1
- package/dist/client/window-next.d.ts +17 -2
- package/dist/client/window-next.js.map +1 -1
- package/dist/cloudflare/tpr.js +1 -1
- package/dist/cloudflare/tpr.js.map +1 -1
- package/dist/config/config-matchers.js +2 -1
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/next-config.d.ts +95 -4
- package/dist/config/next-config.js +173 -14
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.js +42 -7
- 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 +12 -3
- package/dist/entries/app-rsc-entry.js +41 -8
- 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 +40 -3
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-server-entry.js +292 -34
- 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 +91 -10
- package/dist/index.js.map +1 -1
- package/dist/plugins/fonts.js +25 -2
- package/dist/plugins/fonts.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/routing/route-trie.js +13 -18
- package/dist/routing/route-trie.js.map +1 -1
- package/dist/routing/utils.d.ts +11 -1
- package/dist/routing/utils.js +15 -1
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/api-handler.js +19 -10
- package/dist/server/api-handler.js.map +1 -1
- package/dist/server/app-browser-action-result.d.ts +16 -1
- package/dist/server/app-browser-action-result.js +15 -1
- package/dist/server/app-browser-action-result.js.map +1 -1
- package/dist/server/app-browser-entry.js +47 -28
- 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 +27 -8
- package/dist/server/app-fallback-renderer.js +19 -8
- package/dist/server/app-fallback-renderer.js.map +1 -1
- package/dist/server/app-history-state.js +6 -2
- package/dist/server/app-history-state.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-interception-context-header.d.ts +33 -0
- package/dist/server/app-interception-context-header.js +44 -0
- package/dist/server/app-interception-context-header.js.map +1 -0
- package/dist/server/app-mounted-slots-header.d.ts +19 -0
- package/dist/server/app-mounted-slots-header.js +40 -1
- package/dist/server/app-mounted-slots-header.js.map +1 -1
- package/dist/server/app-optimistic-routing.js +26 -18
- package/dist/server/app-optimistic-routing.js.map +1 -1
- package/dist/server/app-page-boundary-render.d.ts +1 -0
- package/dist/server/app-page-boundary-render.js +2 -0
- package/dist/server/app-page-boundary-render.js.map +1 -1
- package/dist/server/app-page-boundary.d.ts +22 -1
- package/dist/server/app-page-boundary.js +30 -3
- package/dist/server/app-page-boundary.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +9 -3
- package/dist/server/app-page-cache.js +14 -8
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +13 -1
- package/dist/server/app-page-dispatch.js +136 -82
- package/dist/server/app-page-dispatch.js.map +1 -1
- package/dist/server/app-page-element-builder.d.ts +2 -1
- package/dist/server/app-page-element-builder.js +17 -30
- package/dist/server/app-page-element-builder.js.map +1 -1
- package/dist/server/app-page-execution.d.ts +1 -0
- package/dist/server/app-page-execution.js +2 -0
- package/dist/server/app-page-execution.js.map +1 -1
- package/dist/server/app-page-head.d.ts +1 -0
- package/dist/server/app-page-head.js +8 -0
- package/dist/server/app-page-head.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-observation.js +1 -1
- package/dist/server/app-page-render.d.ts +9 -1
- package/dist/server/app-page-render.js +8 -2
- 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.d.ts +11 -1
- package/dist/server/app-page-response.js +16 -4
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +16 -0
- package/dist/server/app-page-route-wiring.js +25 -10
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-stream.d.ts +12 -0
- package/dist/server/app-page-stream.js +3 -0
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-route-handler-dispatch.d.ts +1 -0
- package/dist/server/app-route-handler-dispatch.js +3 -0
- package/dist/server/app-route-handler-dispatch.js.map +1 -1
- package/dist/server/app-route-handler-execution.d.ts +1 -0
- package/dist/server/app-route-handler-execution.js +1 -0
- package/dist/server/app-route-handler-execution.js.map +1 -1
- package/dist/server/app-route-handler-response.js +38 -6
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-rsc-handler.d.ts +16 -3
- package/dist/server/app-rsc-handler.js +60 -11
- 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 +6 -4
- package/dist/server/app-rsc-request-normalization.js.map +1 -1
- package/dist/server/app-segment-config.d.ts +4 -1
- package/dist/server/app-segment-config.js +6 -1
- package/dist/server/app-segment-config.js.map +1 -1
- package/dist/server/app-server-action-execution.d.ts +22 -3
- package/dist/server/app-server-action-execution.js +46 -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 +57 -6
- 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 +25 -1
- package/dist/server/app-ssr-stream.js +237 -19
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/app-static-generation.d.ts +1 -0
- package/dist/server/app-static-generation.js +2 -1
- package/dist/server/app-static-generation.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/default-not-found-module.d.ts +20 -0
- package/dist/server/default-not-found-module.js +20 -0
- package/dist/server/default-not-found-module.js.map +1 -0
- package/dist/server/dev-server.d.ts +8 -1
- package/dist/server/dev-server.js +56 -11
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/headers.d.ts +5 -1
- package/dist/server/headers.js +5 -1
- package/dist/server/headers.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/image-optimization.d.ts +13 -4
- package/dist/server/image-optimization.js +15 -4
- package/dist/server/image-optimization.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/middleware.js +1 -1
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/pages-api-route.d.ts +18 -0
- package/dist/server/pages-api-route.js +3 -1
- package/dist/server/pages-api-route.js.map +1 -1
- package/dist/server/pages-body-parser-config.d.ts +60 -0
- package/dist/server/pages-body-parser-config.js +79 -0
- package/dist/server/pages-body-parser-config.js.map +1 -0
- package/dist/server/pages-data-route.js +1 -0
- package/dist/server/pages-data-route.js.map +1 -1
- package/dist/server/pages-default-404.d.ts +31 -0
- package/dist/server/pages-default-404.js +40 -0
- package/dist/server/pages-default-404.js.map +1 -0
- 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-node-compat.d.ts +10 -0
- package/dist/server/pages-node-compat.js +12 -1
- package/dist/server/pages-node-compat.js.map +1 -1
- package/dist/server/pages-page-data.d.ts +40 -0
- package/dist/server/pages-page-data.js +19 -14
- 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 +8 -0
- package/dist/server/pages-page-response.js +21 -11
- 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/prerender-route-params.d.ts +14 -0
- package/dist/server/prerender-route-params.js +94 -0
- package/dist/server/prerender-route-params.js.map +1 -0
- package/dist/server/prod-server.d.ts +3 -23
- package/dist/server/prod-server.js +43 -57
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/proxy-trust.d.ts +41 -0
- package/dist/server/proxy-trust.js +70 -0
- package/dist/server/proxy-trust.js.map +1 -0
- package/dist/server/request-pipeline.d.ts +3 -3
- package/dist/server/request-pipeline.js +5 -4
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/seed-cache.js +12 -6
- package/dist/server/seed-cache.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/server/streaming-metadata.d.ts +5 -0
- package/dist/server/streaming-metadata.js +10 -0
- package/dist/server/streaming-metadata.js.map +1 -0
- package/dist/shims/app-router-scroll-state.d.ts +14 -0
- package/dist/shims/app-router-scroll-state.js +51 -0
- package/dist/shims/app-router-scroll-state.js.map +1 -0
- package/dist/shims/app-router-scroll.d.ts +28 -0
- package/dist/shims/app-router-scroll.js +115 -0
- package/dist/shims/app-router-scroll.js.map +1 -0
- package/dist/shims/before-interactive-context.d.ts +30 -0
- package/dist/shims/before-interactive-context.js +10 -0
- package/dist/shims/before-interactive-context.js.map +1 -0
- package/dist/shims/cache-runtime.d.ts +1 -1
- package/dist/shims/cache-runtime.js +14 -1
- package/dist/shims/cache-runtime.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/default-not-found.d.ts +12 -0
- package/dist/shims/default-not-found.js +61 -0
- package/dist/shims/default-not-found.js.map +1 -0
- package/dist/shims/error.js +3 -0
- package/dist/shims/error.js.map +1 -1
- package/dist/shims/font-local.d.ts +5 -0
- package/dist/shims/font-local.js +6 -2
- package/dist/shims/font-local.js.map +1 -1
- package/dist/shims/head.js +4 -4
- package/dist/shims/head.js.map +1 -1
- package/dist/shims/headers.d.ts +13 -2
- package/dist/shims/headers.js +73 -22
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/image.d.ts +1 -1
- package/dist/shims/image.js +4 -4
- package/dist/shims/image.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/internal/pages-data-target.d.ts +58 -0
- package/dist/shims/internal/pages-data-target.js +91 -0
- package/dist/shims/internal/pages-data-target.js.map +1 -0
- package/dist/shims/internal/pages-data-url.d.ts +42 -0
- package/dist/shims/internal/pages-data-url.js +73 -0
- package/dist/shims/internal/pages-data-url.js.map +1 -0
- package/dist/shims/link.d.ts +18 -2
- package/dist/shims/link.js +129 -15
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +9 -7
- package/dist/shims/metadata.js +70 -7
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation.d.ts +1 -2
- package/dist/shims/navigation.js +94 -20
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/router.d.ts +5 -0
- package/dist/shims/router.js +389 -80
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script.d.ts +11 -1
- package/dist/shims/script.js +158 -15
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server.js +1 -0
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/url-utils.d.ts +2 -1
- package/dist/shims/url-utils.js +15 -4
- package/dist/shims/url-utils.js.map +1 -1
- package/dist/utils/html-limited-bots.d.ts +5 -0
- package/dist/utils/html-limited-bots.js +15 -0
- package/dist/utils/html-limited-bots.js.map +1 -0
- package/dist/utils/path.d.ts +13 -0
- package/dist/utils/path.js +16 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/utils/query.d.ts +6 -0
- package/dist/utils/query.js +10 -1
- package/dist/utils/query.js.map +1 -1
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -37,6 +43,7 @@ type RenderAppPageLifecycleOptions = {
|
|
|
37
43
|
hasLoadingBoundary: boolean;
|
|
38
44
|
isDynamicError: boolean;
|
|
39
45
|
isDraftMode: boolean;
|
|
46
|
+
isEdgeRuntime?: boolean;
|
|
40
47
|
isForceDynamic: boolean;
|
|
41
48
|
isForceStatic: boolean;
|
|
42
49
|
isProgressiveActionRender?: boolean;
|
|
@@ -45,8 +52,9 @@ type RenderAppPageLifecycleOptions = {
|
|
|
45
52
|
isRscRequest: boolean;
|
|
46
53
|
isrDebug?: AppPageDebugLogger;
|
|
47
54
|
isrHtmlKey: (pathname: string) => string;
|
|
48
|
-
isrRscKey: (pathname: string, mountedSlotsHeader?: string | null, renderMode?: AppRscRenderMode) => string;
|
|
55
|
+
isrRscKey: (pathname: string, mountedSlotsHeader?: string | null, renderMode?: AppRscRenderMode, interceptionContext?: string | null) => string;
|
|
49
56
|
isrSet: AppPageCacheSetter;
|
|
57
|
+
interceptionContext?: string | null;
|
|
50
58
|
layoutCount: number;
|
|
51
59
|
loadSsrHandler: () => Promise<AppPageSsrHandler>;
|
|
52
60
|
middlewareContext: AppPageMiddlewareContext;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { runWithFetchDedupe } from "../shims/fetch-cache.js";
|
|
2
1
|
import { createArtifactCompatibilityEnvelope, createArtifactCompatibilityGraphVersion } from "./artifact-compatibility.js";
|
|
3
2
|
import { AppElementsWire, isAppElementsRecord } from "./app-elements-wire.js";
|
|
4
3
|
import "./app-elements.js";
|
|
4
|
+
import { runWithFetchDedupe } from "../shims/fetch-cache.js";
|
|
5
|
+
import { buildAppPageHtmlResponse, buildAppPageRscResponse, resolveAppPageHtmlResponsePolicy, resolveAppPageRscResponsePolicy } from "./app-page-response.js";
|
|
5
6
|
import { buildAppPageFontLinkHeader, readAppPageBinaryStream, resolveAppPageSpecialError, teeAppPageRscStreamForCapture } from "./app-page-execution.js";
|
|
6
7
|
import { createAppPageFontData, createAppPageRscErrorTracker, deferUntilStreamConsumed, renderAppPageHtmlStream, renderAppPageHtmlStreamWithRecovery, shouldRerenderAppPageWithGlobalError } from "./app-page-stream.js";
|
|
7
8
|
import { createAppPageHtmlOutputScope, createAppPageRenderObservation, createAppPageRscOutputScope, createEmptyAppPageRenderObservationState } from "./app-page-render-observation.js";
|
|
8
9
|
import { finalizeAppPageHtmlCacheResponse, finalizeAppPageRscCacheResponse } from "./app-page-cache.js";
|
|
9
10
|
import { hasDigest } from "./app-rsc-errors.js";
|
|
10
11
|
import { probeAppPageBeforeRender } from "./app-page-probe.js";
|
|
11
|
-
import { buildAppPageHtmlResponse, buildAppPageRscResponse, resolveAppPageHtmlResponsePolicy, resolveAppPageRscResponsePolicy } from "./app-page-response.js";
|
|
12
12
|
//#region src/server/app-page-render.ts
|
|
13
13
|
function buildResponseTiming(options) {
|
|
14
14
|
if (options.isProduction) return;
|
|
@@ -188,6 +188,7 @@ async function renderAppPageLifecycle(options) {
|
|
|
188
188
|
revalidateSeconds
|
|
189
189
|
});
|
|
190
190
|
const rscResponse = buildAppPageRscResponse(rscForResponse, {
|
|
191
|
+
isEdgeRuntime: options.isEdgeRuntime,
|
|
191
192
|
middlewareContext: options.middlewareContext,
|
|
192
193
|
mountedSlotsHeader: options.mountedSlotsHeader,
|
|
193
194
|
params: options.params,
|
|
@@ -226,6 +227,7 @@ async function renderAppPageLifecycle(options) {
|
|
|
226
227
|
isrDebug: options.isrDebug,
|
|
227
228
|
isrRscKey: options.isrRscKey,
|
|
228
229
|
isrSet: options.isrSet,
|
|
230
|
+
interceptionContext: options.interceptionContext,
|
|
229
231
|
mountedSlotsHeader: options.mountedSlotsHeader,
|
|
230
232
|
renderMode: options.renderMode,
|
|
231
233
|
preserveClientResponseHeaders: rscResponsePolicy.cacheState !== "MISS",
|
|
@@ -257,6 +259,7 @@ async function renderAppPageLifecycle(options) {
|
|
|
257
259
|
fontData,
|
|
258
260
|
navigationContext: options.getNavigationContext(),
|
|
259
261
|
basePath: options.basePath,
|
|
262
|
+
clientTraceMetadata: options.clientTraceMetadata,
|
|
260
263
|
rootParams: options.rootParams,
|
|
261
264
|
formState: options.formState ?? null,
|
|
262
265
|
rscStream: rscForResponse,
|
|
@@ -330,6 +333,7 @@ async function renderAppPageLifecycle(options) {
|
|
|
330
333
|
const isrResponse = buildAppPageHtmlResponse(safeHtmlStream, {
|
|
331
334
|
draftCookie,
|
|
332
335
|
fontLinkHeader,
|
|
336
|
+
isEdgeRuntime: options.isEdgeRuntime,
|
|
333
337
|
middlewareContext: options.middlewareContext,
|
|
334
338
|
policy: htmlResponsePolicy,
|
|
335
339
|
timing: htmlResponseTiming
|
|
@@ -377,6 +381,7 @@ async function renderAppPageLifecycle(options) {
|
|
|
377
381
|
isrHtmlKey: options.isrHtmlKey,
|
|
378
382
|
isrRscKey: options.isrRscKey,
|
|
379
383
|
isrSet: options.isrSet,
|
|
384
|
+
interceptionContext: options.interceptionContext,
|
|
380
385
|
preserveClientResponseHeaders: !htmlResponsePolicy.shouldWriteToCache,
|
|
381
386
|
expireSeconds,
|
|
382
387
|
revalidateSeconds,
|
|
@@ -388,6 +393,7 @@ async function renderAppPageLifecycle(options) {
|
|
|
388
393
|
return buildAppPageHtmlResponse(safeHtmlStream, {
|
|
389
394
|
draftCookie,
|
|
390
395
|
fontLinkHeader,
|
|
396
|
+
isEdgeRuntime: options.isEdgeRuntime,
|
|
391
397
|
middlewareContext: options.middlewareContext,
|
|
392
398
|
policy: htmlResponsePolicy,
|
|
393
399
|
timing: htmlResponseTiming
|
|
@@ -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 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 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 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 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":";;;;;;;;;;;;AA0IA,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,I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yBAAyB,gBAAgB;EAC9C;EACA;EACA,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,OAAO,uBAAuB,WAAW,qBAAqB;;AAGvE,SAAS,mCACP,SACA,cAC2C;CAC3C,IAAI,CAAC,oBAAoB,QAAQ,EAC/B;CAGF,MAAM,iBAAiB,mBAAmB,QAAQ;CAClD,OAAO,oCAAoC;EACzC,cAAc,wCAAwC;GACpD;GACA;GACD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InterceptionRerenderTargetOptions<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,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,MAA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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 };\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Q;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"}
|
|
@@ -36,6 +36,7 @@ type AppPageHtmlResponsePolicy = {
|
|
|
36
36
|
shouldWriteToCache: boolean;
|
|
37
37
|
} & AppPageResponsePolicy;
|
|
38
38
|
type BuildAppPageRscResponseOptions = {
|
|
39
|
+
isEdgeRuntime?: boolean;
|
|
39
40
|
middlewareContext: AppPageMiddlewareContext;
|
|
40
41
|
mountedSlotsHeader?: string | null;
|
|
41
42
|
params?: Record<string, unknown>;
|
|
@@ -45,14 +46,23 @@ type BuildAppPageRscResponseOptions = {
|
|
|
45
46
|
type BuildAppPageHtmlResponseOptions = {
|
|
46
47
|
draftCookie?: string | null;
|
|
47
48
|
fontLinkHeader?: string;
|
|
49
|
+
isEdgeRuntime?: boolean;
|
|
48
50
|
middlewareContext: AppPageMiddlewareContext;
|
|
49
51
|
policy: AppPageResponsePolicy;
|
|
50
52
|
timing?: AppPageResponseTiming;
|
|
51
53
|
};
|
|
52
54
|
declare function resolveAppPageRscResponsePolicy(options: ResolveAppPageRscResponsePolicyOptions): AppPageResponsePolicy;
|
|
53
55
|
declare function resolveAppPageHtmlResponsePolicy(options: ResolveAppPageHtmlResponsePolicyOptions): AppPageHtmlResponsePolicy;
|
|
56
|
+
/**
|
|
57
|
+
* Mirror Next.js' edge-runtime marker (set in edge-ssr-app.ts). Only routes
|
|
58
|
+
* whose resolved segment config is `runtime = "edge"` should advertise it —
|
|
59
|
+
* nodejs-runtime routes must not, otherwise downstream consumers can't tell
|
|
60
|
+
* the configured runtime from the response. Centralized so every response
|
|
61
|
+
* construction site can opt in without re-deriving the header name.
|
|
62
|
+
*/
|
|
63
|
+
declare function applyEdgeRuntimeHeader(headers: Headers, isEdgeRuntime: boolean | undefined): void;
|
|
54
64
|
declare function buildAppPageRscResponse(body: ReadableStream, options: BuildAppPageRscResponseOptions): Response;
|
|
55
65
|
declare function buildAppPageHtmlResponse(body: ReadableStream, options: BuildAppPageHtmlResponseOptions): Response;
|
|
56
66
|
//#endregion
|
|
57
|
-
export { AppPageMiddlewareContext, AppPageResponseTiming, buildAppPageHtmlResponse, buildAppPageRscResponse, mergeMiddlewareResponseHeaders, resolveAppPageHtmlResponsePolicy, resolveAppPageRscResponsePolicy };
|
|
67
|
+
export { AppPageMiddlewareContext, AppPageResponseTiming, applyEdgeRuntimeHeader, buildAppPageHtmlResponse, buildAppPageRscResponse, mergeMiddlewareResponseHeaders, resolveAppPageHtmlResponsePolicy, resolveAppPageRscResponsePolicy };
|
|
58
68
|
//# sourceMappingURL=app-page-response.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_PARAMS_HEADER, VINEXT_TIMING_HEADER } from "./headers.js";
|
|
2
2
|
import { setCacheStateHeaders } from "./cache-headers.js";
|
|
3
3
|
import { VINEXT_RSC_CONTENT_TYPE, VINEXT_RSC_VARY_HEADER, applyRscCompatibilityIdHeader } from "./app-rsc-cache-busting.js";
|
|
4
|
-
import { mergeMiddlewareResponseHeaders } from "./middleware-response-headers.js";
|
|
5
4
|
import { NO_STORE_CACHE_CONTROL, STATIC_CACHE_CONTROL, buildRevalidateCacheControl } from "./cache-control.js";
|
|
5
|
+
import { mergeMiddlewareResponseHeaders } from "./middleware-response-headers.js";
|
|
6
6
|
//#region src/server/app-page-response.ts
|
|
7
7
|
function applyTimingHeader(headers, timing) {
|
|
8
8
|
if (!timing) return;
|
|
@@ -62,16 +62,27 @@ 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
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Mirror Next.js' edge-runtime marker (set in edge-ssr-app.ts). Only routes
|
|
72
|
+
* whose resolved segment config is `runtime = "edge"` should advertise it —
|
|
73
|
+
* nodejs-runtime routes must not, otherwise downstream consumers can't tell
|
|
74
|
+
* the configured runtime from the response. Centralized so every response
|
|
75
|
+
* construction site can opt in without re-deriving the header name.
|
|
76
|
+
*/
|
|
77
|
+
function applyEdgeRuntimeHeader(headers, isEdgeRuntime) {
|
|
78
|
+
if (isEdgeRuntime) headers.set("x-edge-runtime", "1");
|
|
79
|
+
}
|
|
70
80
|
function buildAppPageRscResponse(body, options) {
|
|
71
81
|
const headers = new Headers({
|
|
72
82
|
"Content-Type": VINEXT_RSC_CONTENT_TYPE,
|
|
73
83
|
Vary: VINEXT_RSC_VARY_HEADER
|
|
74
84
|
});
|
|
85
|
+
applyEdgeRuntimeHeader(headers, options.isEdgeRuntime);
|
|
75
86
|
if (options.params && Object.keys(options.params).length > 0) headers.set(VINEXT_PARAMS_HEADER, encodeURIComponent(JSON.stringify(options.params)));
|
|
76
87
|
if (options.mountedSlotsHeader) headers.set(VINEXT_MOUNTED_SLOTS_HEADER, options.mountedSlotsHeader);
|
|
77
88
|
if (options.policy.cacheControl) headers.set("Cache-Control", options.policy.cacheControl);
|
|
@@ -89,6 +100,7 @@ function buildAppPageHtmlResponse(body, options) {
|
|
|
89
100
|
"Content-Type": "text/html; charset=utf-8",
|
|
90
101
|
Vary: VINEXT_RSC_VARY_HEADER
|
|
91
102
|
});
|
|
103
|
+
applyEdgeRuntimeHeader(headers, options.isEdgeRuntime);
|
|
92
104
|
if (options.policy.cacheControl) headers.set("Cache-Control", options.policy.cacheControl);
|
|
93
105
|
if (options.policy.cacheState) setCacheStateHeaders(headers, options.policy.cacheState);
|
|
94
106
|
if (options.draftCookie) headers.append("Set-Cookie", options.draftCookie);
|
|
@@ -101,6 +113,6 @@ function buildAppPageHtmlResponse(body, options) {
|
|
|
101
113
|
});
|
|
102
114
|
}
|
|
103
115
|
//#endregion
|
|
104
|
-
export { buildAppPageHtmlResponse, buildAppPageRscResponse, mergeMiddlewareResponseHeaders, resolveAppPageHtmlResponsePolicy, resolveAppPageRscResponsePolicy };
|
|
116
|
+
export { applyEdgeRuntimeHeader, buildAppPageHtmlResponse, buildAppPageRscResponse, mergeMiddlewareResponseHeaders, resolveAppPageHtmlResponsePolicy, resolveAppPageRscResponsePolicy };
|
|
105
117
|
|
|
106
118
|
//# sourceMappingURL=app-page-response.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-page-response.js","names":[],"sources":["../../src/server/app-page-response.ts"],"sourcesContent":["import {\n buildRevalidateCacheControl,\n NO_STORE_CACHE_CONTROL,\n STATIC_CACHE_CONTROL,\n} from \"./cache-control.js\";\nimport {\n VINEXT_MOUNTED_SLOTS_HEADER,\n VINEXT_PARAMS_HEADER,\n VINEXT_TIMING_HEADER,\n} from \"./headers.js\";\nimport { setCacheStateHeaders } from \"./cache-headers.js\";\nimport { mergeMiddlewareResponseHeaders } from \"./middleware-response-headers.js\";\nimport {\n VINEXT_RSC_CONTENT_TYPE,\n VINEXT_RSC_VARY_HEADER,\n applyRscCompatibilityIdHeader,\n} from \"./app-rsc-cache-busting.js\";\n\nexport type AppPageMiddlewareContext = {\n headers: Headers | null;\n status: number | null;\n};\n\nexport type AppPageResponseTiming = {\n compileEnd?: number;\n handlerStart: number;\n renderEnd?: number;\n responseKind: \"html\" | \"rsc\";\n};\n\ntype AppPageResponsePolicy = {\n cacheControl?: string;\n cacheState?: \"MISS\" | \"STATIC\";\n};\n\ntype ResolveAppPageResponsePolicyBaseOptions = {\n isDraftMode: boolean;\n isDynamicError: boolean;\n isForceDynamic: boolean;\n isForceStatic: boolean;\n isProduction: boolean;\n expireSeconds?: number;\n revalidateSeconds: number | null;\n};\n\ntype ResolveAppPageRscResponsePolicyOptions = {\n dynamicUsedDuringBuild: boolean;\n} & ResolveAppPageResponsePolicyBaseOptions;\n\ntype ResolveAppPageHtmlResponsePolicyOptions = {\n dynamicUsedDuringRender: boolean;\n isProgressiveActionRender?: boolean;\n hasScriptNonce: boolean;\n} & ResolveAppPageResponsePolicyBaseOptions;\n\ntype AppPageHtmlResponsePolicy = {\n shouldWriteToCache: boolean;\n} & AppPageResponsePolicy;\n\ntype BuildAppPageRscResponseOptions = {\n middlewareContext: AppPageMiddlewareContext;\n mountedSlotsHeader?: string | null;\n params?: Record<string, unknown>;\n policy: AppPageResponsePolicy;\n timing?: AppPageResponseTiming;\n};\n\ntype BuildAppPageHtmlResponseOptions = {\n draftCookie?: string | null;\n fontLinkHeader?: string;\n middlewareContext: AppPageMiddlewareContext;\n policy: AppPageResponsePolicy;\n timing?: AppPageResponseTiming;\n};\n\nfunction applyTimingHeader(headers: Headers, timing?: AppPageResponseTiming): void {\n if (!timing) {\n return;\n }\n\n const handlerStart = Math.round(timing.handlerStart);\n const compileMs =\n timing.compileEnd !== undefined ? Math.round(timing.compileEnd - timing.handlerStart) : -1;\n const renderMs =\n timing.responseKind === \"html\" &&\n timing.renderEnd !== undefined &&\n timing.compileEnd !== undefined\n ? Math.round(timing.renderEnd - timing.compileEnd)\n : -1;\n\n headers.set(VINEXT_TIMING_HEADER, `${handlerStart},${compileMs},${renderMs}`);\n}\n\nexport function resolveAppPageRscResponsePolicy(\n options: ResolveAppPageRscResponsePolicyOptions,\n): AppPageResponsePolicy {\n if (options.isDraftMode) {\n return { cacheControl: NO_STORE_CACHE_CONTROL };\n }\n\n if (options.isForceDynamic || options.dynamicUsedDuringBuild) {\n return { cacheControl: NO_STORE_CACHE_CONTROL };\n }\n\n // revalidate = 0 means \"always dynamic, never cache\" — equivalent to\n // force-dynamic for caching purposes. Must be checked before the\n // isForceStatic/isDynamicError branch below, which uses !revalidateSeconds\n // and would incorrectly catch 0 as a falsy value.\n if (options.revalidateSeconds === 0) {\n return { cacheControl: NO_STORE_CACHE_CONTROL };\n }\n\n if (\n ((options.isForceStatic || options.isDynamicError) && !options.revalidateSeconds) ||\n options.revalidateSeconds === Infinity\n ) {\n return {\n cacheControl: STATIC_CACHE_CONTROL,\n cacheState: \"STATIC\",\n };\n }\n\n if (options.revalidateSeconds) {\n return {\n cacheControl: buildRevalidateCacheControl(options.revalidateSeconds, options.expireSeconds),\n // Emit MISS as part of the initial RSC response shape rather than bolting\n // it on later in the cache-write block so response construction stays\n // centralized in this helper. This matches the eventual write path: the\n // first ISR-eligible production response is a cache miss.\n cacheState: options.isProduction ? \"MISS\" : undefined,\n };\n }\n\n return {};\n}\n\nexport function resolveAppPageHtmlResponsePolicy(\n options: ResolveAppPageHtmlResponsePolicyOptions,\n): AppPageHtmlResponsePolicy {\n if (options.isDraftMode) {\n return {\n cacheControl: NO_STORE_CACHE_CONTROL,\n shouldWriteToCache: false,\n };\n }\n\n if (options.isForceDynamic) {\n return {\n cacheControl: NO_STORE_CACHE_CONTROL,\n shouldWriteToCache: false,\n };\n }\n\n if (options.hasScriptNonce) {\n return {\n cacheControl: NO_STORE_CACHE_CONTROL,\n shouldWriteToCache: false,\n };\n }\n\n if (options.isProgressiveActionRender) {\n return {\n cacheControl: NO_STORE_CACHE_CONTROL,\n shouldWriteToCache: false,\n };\n }\n\n // revalidate = 0 means \"always dynamic, never cache\" — equivalent to\n // force-dynamic for caching purposes. Must be checked before the\n // isForceStatic/isDynamicError branch below, which matches revalidateSeconds\n // === 0 and would incorrectly return a static Cache-Control.\n if (options.revalidateSeconds === 0) {\n return {\n cacheControl: NO_STORE_CACHE_CONTROL,\n shouldWriteToCache: false,\n };\n }\n\n if ((options.isForceStatic || options.isDynamicError) && options.revalidateSeconds === null) {\n return {\n cacheControl: STATIC_CACHE_CONTROL,\n cacheState: \"STATIC\",\n shouldWriteToCache: false,\n };\n }\n\n if (options.dynamicUsedDuringRender) {\n return {\n cacheControl: NO_STORE_CACHE_CONTROL,\n shouldWriteToCache: false,\n };\n }\n\n if (\n options.revalidateSeconds !== null &&\n options.revalidateSeconds > 0 &&\n options.revalidateSeconds !== Infinity\n ) {\n return {\n cacheControl: buildRevalidateCacheControl(options.revalidateSeconds, options.expireSeconds),\n cacheState: options.isProduction ? \"MISS\" : undefined,\n shouldWriteToCache: options.isProduction,\n };\n }\n\n if (options.revalidateSeconds === Infinity) {\n return {\n cacheControl: STATIC_CACHE_CONTROL,\n cacheState: \"STATIC\",\n shouldWriteToCache: false,\n };\n }\n\n return { shouldWriteToCache: false };\n}\n\nexport { mergeMiddlewareResponseHeaders };\n\nexport function buildAppPageRscResponse(\n body: ReadableStream,\n options: BuildAppPageRscResponseOptions,\n): Response {\n const headers = new Headers({\n \"Content-Type\": VINEXT_RSC_CONTENT_TYPE,\n Vary: VINEXT_RSC_VARY_HEADER,\n });\n\n if (options.params && Object.keys(options.params).length > 0) {\n // encodeURIComponent so non-ASCII params (e.g. Korean slugs) survive the\n // HTTP ByteString constraint — Headers.set() rejects chars above U+00FF.\n headers.set(VINEXT_PARAMS_HEADER, encodeURIComponent(JSON.stringify(options.params)));\n }\n if (options.mountedSlotsHeader) {\n headers.set(VINEXT_MOUNTED_SLOTS_HEADER, options.mountedSlotsHeader);\n }\n if (options.policy.cacheControl) {\n headers.set(\"Cache-Control\", options.policy.cacheControl);\n }\n if (options.policy.cacheState) {\n setCacheStateHeaders(headers, options.policy.cacheState);\n }\n mergeMiddlewareResponseHeaders(headers, options.middlewareContext.headers);\n applyRscCompatibilityIdHeader(headers);\n\n applyTimingHeader(headers, options.timing);\n\n return new Response(body, {\n status: options.middlewareContext.status ?? 200,\n headers,\n });\n}\n\nexport function buildAppPageHtmlResponse(\n body: ReadableStream,\n options: BuildAppPageHtmlResponseOptions,\n): Response {\n const headers = new Headers({\n \"Content-Type\": \"text/html; charset=utf-8\",\n Vary: VINEXT_RSC_VARY_HEADER,\n });\n\n if (options.policy.cacheControl) {\n headers.set(\"Cache-Control\", options.policy.cacheControl);\n }\n if (options.policy.cacheState) {\n setCacheStateHeaders(headers, options.policy.cacheState);\n }\n if (options.draftCookie) {\n headers.append(\"Set-Cookie\", options.draftCookie);\n }\n if (options.fontLinkHeader) {\n headers.set(\"Link\", options.fontLinkHeader);\n }\n\n mergeMiddlewareResponseHeaders(headers, options.middlewareContext.headers);\n\n applyTimingHeader(headers, options.timing);\n\n return new Response(body, {\n status: options.middlewareContext.status ?? 200,\n headers,\n });\n}\n"],"mappings":";;;;;;AA2EA,SAAS,kBAAkB,SAAkB,QAAsC;CACjF,IAAI,CAAC,QACH;CAGF,MAAM,eAAe,KAAK,MAAM,OAAO,aAAa;CACpD,MAAM,YACJ,OAAO,eAAe,KAAA,IAAY,KAAK,MAAM,OAAO,a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,gBACV,QAAQ,IAAI,QAAQ,QAAQ,eAAe;CAG7C,+BAA+B,SAAS,QAAQ,kBAAkB,QAAQ;CAE1E,kBAAkB,SAAS,QAAQ,OAAO;CAE1C,OAAO,IAAI,SAAS,MAAM;EACxB,QAAQ,QAAQ,kBAAkB,UAAU;EAC5C;EACD,CAAC"}
|
|
1
|
+
{"version":3,"file":"app-page-response.js","names":[],"sources":["../../src/server/app-page-response.ts"],"sourcesContent":["import {\n buildRevalidateCacheControl,\n NO_STORE_CACHE_CONTROL,\n STATIC_CACHE_CONTROL,\n} from \"./cache-control.js\";\nimport {\n VINEXT_MOUNTED_SLOTS_HEADER,\n VINEXT_PARAMS_HEADER,\n VINEXT_TIMING_HEADER,\n} from \"./headers.js\";\nimport { setCacheStateHeaders } from \"./cache-headers.js\";\nimport { mergeMiddlewareResponseHeaders } from \"./middleware-response-headers.js\";\nimport {\n VINEXT_RSC_CONTENT_TYPE,\n VINEXT_RSC_VARY_HEADER,\n applyRscCompatibilityIdHeader,\n} from \"./app-rsc-cache-busting.js\";\n\nexport type AppPageMiddlewareContext = {\n headers: Headers | null;\n status: number | null;\n};\n\nexport type AppPageResponseTiming = {\n compileEnd?: number;\n handlerStart: number;\n renderEnd?: number;\n responseKind: \"html\" | \"rsc\";\n};\n\ntype AppPageResponsePolicy = {\n cacheControl?: string;\n cacheState?: \"MISS\" | \"STATIC\";\n};\n\ntype ResolveAppPageResponsePolicyBaseOptions = {\n isDraftMode: boolean;\n isDynamicError: boolean;\n isForceDynamic: boolean;\n isForceStatic: boolean;\n isProduction: boolean;\n expireSeconds?: number;\n revalidateSeconds: number | null;\n};\n\ntype ResolveAppPageRscResponsePolicyOptions = {\n dynamicUsedDuringBuild: boolean;\n} & ResolveAppPageResponsePolicyBaseOptions;\n\ntype ResolveAppPageHtmlResponsePolicyOptions = {\n dynamicUsedDuringRender: boolean;\n isProgressiveActionRender?: boolean;\n hasScriptNonce: boolean;\n} & ResolveAppPageResponsePolicyBaseOptions;\n\ntype AppPageHtmlResponsePolicy = {\n shouldWriteToCache: boolean;\n} & AppPageResponsePolicy;\n\ntype BuildAppPageRscResponseOptions = {\n isEdgeRuntime?: boolean;\n middlewareContext: AppPageMiddlewareContext;\n mountedSlotsHeader?: string | null;\n params?: Record<string, unknown>;\n policy: AppPageResponsePolicy;\n timing?: AppPageResponseTiming;\n};\n\ntype BuildAppPageHtmlResponseOptions = {\n draftCookie?: string | null;\n fontLinkHeader?: string;\n isEdgeRuntime?: boolean;\n middlewareContext: AppPageMiddlewareContext;\n policy: AppPageResponsePolicy;\n timing?: AppPageResponseTiming;\n};\n\nfunction applyTimingHeader(headers: Headers, timing?: AppPageResponseTiming): void {\n if (!timing) {\n return;\n }\n\n const handlerStart = Math.round(timing.handlerStart);\n const compileMs =\n timing.compileEnd !== undefined ? Math.round(timing.compileEnd - timing.handlerStart) : -1;\n const renderMs =\n timing.responseKind === \"html\" &&\n timing.renderEnd !== undefined &&\n timing.compileEnd !== undefined\n ? Math.round(timing.renderEnd - timing.compileEnd)\n : -1;\n\n headers.set(VINEXT_TIMING_HEADER, `${handlerStart},${compileMs},${renderMs}`);\n}\n\nexport function resolveAppPageRscResponsePolicy(\n options: ResolveAppPageRscResponsePolicyOptions,\n): AppPageResponsePolicy {\n if (options.isDraftMode) {\n return { cacheControl: NO_STORE_CACHE_CONTROL };\n }\n\n if (options.isForceDynamic || options.dynamicUsedDuringBuild) {\n return { cacheControl: NO_STORE_CACHE_CONTROL };\n }\n\n // revalidate = 0 means \"always dynamic, never cache\" — equivalent to\n // force-dynamic for caching purposes. Must be checked before the\n // isForceStatic/isDynamicError branch below, which uses !revalidateSeconds\n // and would incorrectly catch 0 as a falsy value.\n if (options.revalidateSeconds === 0) {\n return { cacheControl: NO_STORE_CACHE_CONTROL };\n }\n\n if (\n ((options.isForceStatic || options.isDynamicError) && !options.revalidateSeconds) ||\n options.revalidateSeconds === Infinity\n ) {\n return {\n cacheControl: STATIC_CACHE_CONTROL,\n cacheState: \"STATIC\",\n };\n }\n\n if (options.revalidateSeconds) {\n return {\n cacheControl: buildRevalidateCacheControl(options.revalidateSeconds, options.expireSeconds),\n // Emit MISS as part of the initial RSC response shape rather than bolting\n // it on later in the cache-write block so response construction stays\n // centralized in this helper. This matches the eventual write path: the\n // first ISR-eligible production response is a cache miss.\n cacheState: options.isProduction ? \"MISS\" : undefined,\n };\n }\n\n return {};\n}\n\nexport function resolveAppPageHtmlResponsePolicy(\n options: ResolveAppPageHtmlResponsePolicyOptions,\n): AppPageHtmlResponsePolicy {\n if (options.isDraftMode) {\n return {\n cacheControl: NO_STORE_CACHE_CONTROL,\n shouldWriteToCache: false,\n };\n }\n\n if (options.isForceDynamic) {\n return {\n cacheControl: NO_STORE_CACHE_CONTROL,\n shouldWriteToCache: false,\n };\n }\n\n if (options.hasScriptNonce) {\n return {\n cacheControl: NO_STORE_CACHE_CONTROL,\n shouldWriteToCache: false,\n };\n }\n\n if (options.isProgressiveActionRender) {\n return {\n cacheControl: NO_STORE_CACHE_CONTROL,\n shouldWriteToCache: false,\n };\n }\n\n // revalidate = 0 means \"always dynamic, never cache\" — equivalent to\n // force-dynamic for caching purposes. Must be checked before the\n // isForceStatic/isDynamicError branch below, which matches revalidateSeconds\n // === 0 and would incorrectly return a static Cache-Control.\n if (options.revalidateSeconds === 0) {\n return {\n cacheControl: NO_STORE_CACHE_CONTROL,\n shouldWriteToCache: false,\n };\n }\n\n if ((options.isForceStatic || options.isDynamicError) && options.revalidateSeconds === null) {\n return {\n cacheControl: STATIC_CACHE_CONTROL,\n cacheState: \"STATIC\",\n shouldWriteToCache: false,\n };\n }\n\n if (options.dynamicUsedDuringRender) {\n return {\n cacheControl: NO_STORE_CACHE_CONTROL,\n shouldWriteToCache: false,\n };\n }\n\n if (\n options.revalidateSeconds !== null &&\n options.revalidateSeconds > 0 &&\n options.revalidateSeconds !== Infinity\n ) {\n return {\n cacheControl: buildRevalidateCacheControl(options.revalidateSeconds, options.expireSeconds),\n cacheState: options.isProduction ? \"MISS\" : undefined,\n shouldWriteToCache: options.isProduction,\n };\n }\n\n if (options.revalidateSeconds === Infinity) {\n // `revalidate = false` / `revalidate = Infinity` ask for indefinite caching.\n // The downstream Cache-Control header remains STATIC (1y s-maxage), but we\n // also write to the ISR cache so repeated requests inside the same vinext\n // process return identical bytes instead of re-rendering on every hit.\n // This matches Next.js: indefinite-revalidate pages cache their rendered\n // output and only re-render when their tags are explicitly invalidated.\n return {\n cacheControl: STATIC_CACHE_CONTROL,\n cacheState: options.isProduction ? \"MISS\" : \"STATIC\",\n shouldWriteToCache: options.isProduction,\n };\n }\n\n return { shouldWriteToCache: false };\n}\n\nexport { mergeMiddlewareResponseHeaders };\n\n/**\n * Mirror Next.js' edge-runtime marker (set in edge-ssr-app.ts). Only routes\n * whose resolved segment config is `runtime = \"edge\"` should advertise it —\n * nodejs-runtime routes must not, otherwise downstream consumers can't tell\n * the configured runtime from the response. Centralized so every response\n * construction site can opt in without re-deriving the header name.\n */\nexport function applyEdgeRuntimeHeader(headers: Headers, isEdgeRuntime: boolean | undefined): void {\n if (isEdgeRuntime) {\n headers.set(\"x-edge-runtime\", \"1\");\n }\n}\n\nexport function buildAppPageRscResponse(\n body: ReadableStream,\n options: BuildAppPageRscResponseOptions,\n): Response {\n const headers = new Headers({\n \"Content-Type\": VINEXT_RSC_CONTENT_TYPE,\n Vary: VINEXT_RSC_VARY_HEADER,\n });\n\n applyEdgeRuntimeHeader(headers, options.isEdgeRuntime);\n\n if (options.params && Object.keys(options.params).length > 0) {\n // encodeURIComponent so non-ASCII params (e.g. Korean slugs) survive the\n // HTTP ByteString constraint — Headers.set() rejects chars above U+00FF.\n headers.set(VINEXT_PARAMS_HEADER, encodeURIComponent(JSON.stringify(options.params)));\n }\n if (options.mountedSlotsHeader) {\n headers.set(VINEXT_MOUNTED_SLOTS_HEADER, options.mountedSlotsHeader);\n }\n if (options.policy.cacheControl) {\n headers.set(\"Cache-Control\", options.policy.cacheControl);\n }\n if (options.policy.cacheState) {\n setCacheStateHeaders(headers, options.policy.cacheState);\n }\n mergeMiddlewareResponseHeaders(headers, options.middlewareContext.headers);\n applyRscCompatibilityIdHeader(headers);\n\n applyTimingHeader(headers, options.timing);\n\n return new Response(body, {\n status: options.middlewareContext.status ?? 200,\n headers,\n });\n}\n\nexport function buildAppPageHtmlResponse(\n body: ReadableStream,\n options: BuildAppPageHtmlResponseOptions,\n): Response {\n const headers = new Headers({\n \"Content-Type\": \"text/html; charset=utf-8\",\n Vary: VINEXT_RSC_VARY_HEADER,\n });\n\n applyEdgeRuntimeHeader(headers, options.isEdgeRuntime);\n\n if (options.policy.cacheControl) {\n headers.set(\"Cache-Control\", options.policy.cacheControl);\n }\n if (options.policy.cacheState) {\n setCacheStateHeaders(headers, options.policy.cacheState);\n }\n if (options.draftCookie) {\n headers.append(\"Set-Cookie\", options.draftCookie);\n }\n if (options.fontLinkHeader) {\n headers.set(\"Link\", options.fontLinkHeader);\n }\n\n mergeMiddlewareResponseHeaders(headers, options.middlewareContext.headers);\n\n applyTimingHeader(headers, options.timing);\n\n return new Response(body, {\n status: options.middlewareContext.status ?? 200,\n headers,\n });\n}\n"],"mappings":";;;;;;AA6EA,SAAS,kBAAkB,SAAkB,QAAsC;CACjF,IAAI,CAAC,QACH;CAGF,MAAM,eAAe,KAAK,MAAM,OAAO,aAAa;CACpD,MAAM,YACJ,OAAO,eAAe,KAAA,IAAY,KAAK,MAAM,OAAO,aAAa,OAAO,aAAa,GAAG;CAC1F,MAAM,WACJ,OAAO,iBAAiB,UACxB,OAAO,cAAc,KAAA,KACrB,OAAO,eAAe,KAAA,IAClB,KAAK,MAAM,OAAO,YAAY,OAAO,WAAW,GAChD;CAEN,QAAQ,IAAI,sBAAsB,GAAG,aAAa,GAAG,UAAU,GAAG,WAAW;;AAG/E,SAAgB,gCACd,SACuB;CACvB,IAAI,QAAQ,aACV,OAAO,EAAE,cAAc,wBAAwB;CAGjD,IAAI,QAAQ,kBAAkB,QAAQ,wBACpC,OAAO,EAAE,cA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Q,QAAQ,kBAAkB,UAAU;EAC5C;EACD,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { AppElements, AppElementsInterception } from "./app-elements-wire.js";
|
|
|
3
3
|
import { AppPageParams } from "./app-page-boundary.js";
|
|
4
4
|
import { AppRscRenderMode } from "./app-rsc-render-mode.js";
|
|
5
5
|
import { Metadata, Viewport } from "../shims/metadata.js";
|
|
6
|
+
import { AppPageRenderIdentity } from "./app-page-render-identity.js";
|
|
6
7
|
import { resolveAppPageChildSegments } from "./app-page-segment-state.js";
|
|
7
8
|
import { ComponentType, ReactNode } from "react";
|
|
8
9
|
|
|
@@ -63,6 +64,19 @@ type AppPageRouteWiringRoute<TModule extends AppPageModule = AppPageModule, TErr
|
|
|
63
64
|
* Keyed by stable slot id (name + owner path), not necessarily the slot prop name.
|
|
64
65
|
*/
|
|
65
66
|
slots?: Readonly<Record<string, AppPageRouteWiringSlot<TModule, TErrorModule>>> | null;
|
|
67
|
+
/**
|
|
68
|
+
* Static sibling segment names at each dynamic URL level for this route. Used
|
|
69
|
+
* by the client router to determine if a cached prefetch of the dynamic
|
|
70
|
+
* route can be reused when navigating to a static sibling URL.
|
|
71
|
+
*
|
|
72
|
+
* Mirrors Next.js's `staticSiblings` tuple element on the loader-tree
|
|
73
|
+
* dynamic segments — see `.nextjs-ref/packages/next/src/shared/lib/app-router-types.ts`
|
|
74
|
+
* (DynamicSegmentTuple) and the loader emit in
|
|
75
|
+
* `packages/next/src/build/webpack/loaders/next-app-loader/index.ts`.
|
|
76
|
+
*
|
|
77
|
+
* Issue: https://github.com/cloudflare/vinext/issues/1525
|
|
78
|
+
*/
|
|
79
|
+
staticSiblings?: readonly string[] | null;
|
|
66
80
|
templateTreePositions?: readonly number[] | null;
|
|
67
81
|
templates?: readonly (TModule | null | undefined)[] | null;
|
|
68
82
|
};
|
|
@@ -92,6 +106,7 @@ type BuildAppPageRouteElementOptions<TModule extends AppPageModule = AppPageModu
|
|
|
92
106
|
globalErrorModule?: TErrorModule | null;
|
|
93
107
|
makeThenableParams: (params: AppPageParams) => unknown;
|
|
94
108
|
matchedParams: AppPageParams;
|
|
109
|
+
metadataPlacement?: "body" | "head";
|
|
95
110
|
resolvedMetadata: Metadata | null;
|
|
96
111
|
resolvedMetadataPathname?: string;
|
|
97
112
|
resolvedViewport: Viewport;
|
|
@@ -106,6 +121,7 @@ type BuildAppPageElementsOptions<TModule extends AppPageModule = AppPageModule,
|
|
|
106
121
|
interceptionContext?: string | null;
|
|
107
122
|
isRscRequest?: boolean;
|
|
108
123
|
mountedSlotIds?: ReadonlySet<string> | null;
|
|
124
|
+
renderIdentity?: AppPageRenderIdentity;
|
|
109
125
|
renderMode?: AppRscRenderMode;
|
|
110
126
|
routePath: string;
|
|
111
127
|
};
|