vinext 1.3.1 → 1.4.1
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 +25 -22
- package/THIRD_PARTY_LICENSES.md +47 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -2
- package/dist/build/prerender.js +4 -3
- package/dist/build/report.d.ts +0 -14
- package/dist/build/report.js +1 -51
- package/dist/check.js +4 -7
- package/dist/cli.js +3 -0
- package/dist/client/dev-error-overlay-store.d.ts +1 -0
- package/dist/client/dev-error-overlay.d.ts +2 -0
- package/dist/client/dev-error-overlay.js +20 -4
- package/dist/client/navigation-runtime.d.ts +13 -1
- package/dist/client/navigation-runtime.js +1 -1
- package/dist/config/config-matchers.js +2 -0
- package/dist/config/destination-params.d.ts +2 -1
- package/dist/config/destination-params.js +52 -2
- package/dist/config/next-config.d.ts +25 -0
- package/dist/config/next-config.js +82 -4
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/dbcs-codec.js +327 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/dbcs-data.js +123 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/index.js +29 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/internal.js +134 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-codec.js +50 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-data-generated.js +455 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-data.js +147 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/big5-added.json.js +169 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp936.json.js +2584 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp949.json.js +2220 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp950.json.js +227 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/eucjp.json.js +425 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/gb18030-ranges.json.js +427 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/gbk-added.json.js +229 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/shiftjis.json.js +292 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/utf16.js +106 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/utf7.js +182 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/bom-handling.js +42 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/extend-node.js +147 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/index.js +94 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/streams.js +95 -0
- package/dist/deps/.pnpm/safer-buffer@2.1.2/deps/safer-buffer/safer.js +45 -0
- package/dist/entries/app-rsc-entry.js +17 -49
- package/dist/entries/app-rsc-manifest.js +3 -4
- package/dist/entries/app-ssr-entry.js +1 -0
- package/dist/entries/pages-server-entry.js +36 -9
- package/dist/index.js +112 -90
- package/dist/init-cloudflare.d.ts +1 -3
- package/dist/init-cloudflare.js +10 -48
- package/dist/init-platform.d.ts +2 -0
- package/dist/init-platform.js +4 -0
- package/dist/plugins/extensionless-dynamic-import.js +6 -2
- package/dist/plugins/next-intl-catalog.d.ts +12 -0
- package/dist/plugins/next-intl-catalog.js +85 -0
- package/dist/plugins/pages-node-externals.d.ts +1 -0
- package/dist/plugins/pages-node-externals.js +1 -1
- package/dist/plugins/strip-server-exports.js +2 -1
- package/dist/plugins/use-cache-callable.d.ts +1 -1
- package/dist/plugins/use-cache-callable.js +136 -94
- package/dist/routing/app-route-graph.d.ts +6 -0
- package/dist/routing/app-route-graph.js +9 -1
- package/dist/server/api-handler.js +21 -5
- package/dist/server/app-bfcache-identity.js +1 -1
- package/dist/server/app-browser-entry.js +86 -66
- package/dist/server/app-browser-history-controller.d.ts +5 -4
- package/dist/server/app-browser-history-controller.js +93 -15
- package/dist/server/app-browser-navigation-controller.d.ts +2 -2
- package/dist/server/app-browser-navigation-controller.js +1 -2
- package/dist/server/app-browser-rsc-redirect.js +7 -7
- package/dist/server/app-browser-server-action-client.d.ts +2 -0
- package/dist/server/app-browser-server-action-client.js +5 -4
- package/dist/server/app-browser-state.d.ts +2 -4
- package/dist/server/app-browser-state.js +9 -4
- package/dist/server/app-browser-supplemental-refresh.js +16 -1
- package/dist/server/app-browser-visible-commit.d.ts +1 -1
- package/dist/server/app-browser-visible-commit.js +4 -14
- package/dist/server/app-elements-wire.d.ts +6 -38
- package/dist/server/app-elements-wire.js +4 -41
- package/dist/server/app-elements.d.ts +2 -2
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-history-state.d.ts +2 -2
- package/dist/server/app-history-state.js +5 -2
- package/dist/server/app-mounted-layouts.d.ts +21 -0
- package/dist/server/app-mounted-layouts.js +67 -0
- package/dist/server/app-optimistic-routing.d.ts +19 -1
- package/dist/server/app-optimistic-routing.js +43 -4
- package/dist/server/app-page-boundary-render.js +10 -14
- package/dist/server/app-page-boundary.js +2 -2
- package/dist/server/app-page-cache-finalizer.d.ts +12 -1
- package/dist/server/app-page-cache-finalizer.js +70 -29
- package/dist/server/app-page-cache.d.ts +13 -1
- package/dist/server/app-page-cache.js +31 -9
- package/dist/server/app-page-dispatch.d.ts +5 -11
- package/dist/server/app-page-dispatch.js +84 -155
- package/dist/server/app-page-element-builder.d.ts +2 -2
- package/dist/server/app-page-element-builder.js +13 -12
- package/dist/server/app-page-execution.d.ts +17 -52
- package/dist/server/app-page-execution.js +102 -95
- package/dist/server/app-page-head.d.ts +13 -0
- package/dist/server/app-page-head.js +44 -16
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +1 -0
- package/dist/server/app-page-http-access-fallback-metadata.js +2 -2
- package/dist/server/app-page-layout-gate.d.ts +35 -0
- package/dist/server/app-page-layout-gate.js +50 -0
- package/dist/server/app-page-params.d.ts +0 -1
- package/dist/server/app-page-params.js +1 -14
- package/dist/server/app-page-probe.d.ts +3 -21
- package/dist/server/app-page-probe.js +4 -37
- package/dist/server/app-page-render.d.ts +2 -13
- package/dist/server/app-page-render.js +103 -234
- package/dist/server/app-page-request.d.ts +1 -3
- package/dist/server/app-page-request.js +1 -1
- package/dist/server/app-page-response.js +3 -3
- package/dist/server/app-page-route-wiring.d.ts +13 -6
- package/dist/server/app-page-route-wiring.js +86 -63
- package/dist/server/app-page-rsc-render-status.d.ts +27 -1
- package/dist/server/app-page-rsc-render-status.js +121 -13
- package/dist/server/app-page-stream.d.ts +12 -8
- package/dist/server/app-page-stream.js +4 -3
- package/dist/server/app-pages-bridge.d.ts +4 -0
- package/dist/server/app-pages-bridge.js +7 -3
- package/dist/server/app-render-dependency.d.ts +11 -4
- package/dist/server/app-render-dependency.js +86 -38
- package/dist/server/app-request-stage-dispatch.js +1 -1
- package/dist/server/app-request-stage-independent-entry.js +1 -1
- package/dist/server/app-route-handler-cache.js +2 -2
- package/dist/server/app-route-handler-dispatch.js +14 -9
- package/dist/server/app-route-handler-execution.js +11 -5
- package/dist/server/app-route-handler-policy.d.ts +1 -1
- package/dist/server/app-route-handler-policy.js +3 -3
- package/dist/server/app-route-handler-response.js +1 -1
- package/dist/server/app-route-handler-runtime.d.ts +1 -1
- package/dist/server/app-route-handler-runtime.js +28 -11
- package/dist/server/app-router-entry.js +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +12 -12
- package/dist/server/app-rsc-cache-busting.js +31 -72
- package/dist/server/app-rsc-error-handler.d.ts +2 -1
- package/dist/server/app-rsc-error-handler.js +10 -2
- package/dist/server/app-rsc-errors.d.ts +8 -0
- package/dist/server/app-rsc-errors.js +11 -1
- package/dist/server/app-rsc-handler.d.ts +5 -5
- package/dist/server/app-rsc-handler.js +80 -83
- package/dist/server/app-rsc-request-normalization.d.ts +10 -16
- package/dist/server/app-rsc-request-normalization.js +12 -18
- package/dist/server/app-rsc-response-finalizer.js +2 -2
- package/dist/server/app-rsc-response-stage.js +9 -15
- package/dist/server/app-server-action-execution.d.ts +3 -1
- package/dist/server/app-server-action-execution.js +15 -8
- package/dist/server/app-ssr-entry.d.ts +8 -0
- package/dist/server/app-ssr-entry.js +22 -16
- package/dist/server/app-ssr-stream.js +1 -1
- package/dist/server/app-visited-response-cache.d.ts +36 -1
- package/dist/server/app-visited-response-cache.js +46 -5
- package/dist/server/app-worker-stages.d.ts +37 -6
- package/dist/server/app-worker-stages.js +81 -9
- package/dist/server/artifact-compatibility.d.ts +0 -1
- package/dist/server/artifact-compatibility.js +1 -10
- package/dist/server/bfcache-identity.d.ts +7 -0
- package/dist/server/bfcache-identity.js +10 -1
- package/dist/server/cache-proof.d.ts +1 -115
- package/dist/server/cache-proof.js +1 -544
- package/dist/server/cacheability-manifest.js +1 -2
- package/dist/server/cacheability-request.js +13 -8
- package/dist/server/dev-origin-check.d.ts +2 -1
- package/dist/server/dev-origin-check.js +2 -1
- package/dist/server/dev-server.js +6 -4
- package/dist/server/headers.d.ts +6 -3
- package/dist/server/headers.js +9 -5
- package/dist/server/image-optimization.d.ts +5 -0
- package/dist/server/image-optimization.js +6 -1
- package/dist/server/isr-cache.d.ts +8 -2
- package/dist/server/isr-cache.js +30 -2
- package/dist/server/metadata-route-response.js +32 -15
- package/dist/server/middleware-matcher.js +19 -6
- package/dist/server/middleware-runtime.js +6 -2
- package/dist/server/multi-stage.d.ts +57 -12
- package/dist/server/multi-stage.js +13 -1
- package/dist/server/navigation-planner.js +1 -1
- package/dist/server/pages-api-route.js +28 -19
- package/dist/server/pages-media-type.d.ts +21 -1
- package/dist/server/pages-media-type.js +69 -5
- package/dist/server/pages-node-compat.d.ts +1 -1
- package/dist/server/pages-node-compat.js +54 -27
- package/dist/server/pages-page-data.js +2 -1
- package/dist/server/pages-page-handler.js +28 -26
- package/dist/server/pages-page-response.d.ts +9 -0
- package/dist/server/pages-page-response.js +18 -4
- package/dist/server/pages-request-pipeline.d.ts +8 -0
- package/dist/server/pages-request-pipeline.js +2 -2
- package/dist/server/pages-request-stage-entry.js +36 -14
- package/dist/server/pages-response-stage-entry.js +9 -3
- package/dist/server/pages-router-entry.js +3 -2
- package/dist/server/prod-server.d.ts +2 -2
- package/dist/server/prod-server.js +47 -9
- package/dist/server/request-error-log.d.ts +9 -0
- package/dist/server/request-error-log.js +13 -0
- package/dist/server/request-pipeline.d.ts +15 -4
- package/dist/server/request-pipeline.js +43 -15
- package/dist/server/rsc-completion-metadata.js +3 -0
- package/dist/server/shared-cache-identity.d.ts +23 -0
- package/dist/server/shared-cache-identity.js +36 -0
- package/dist/server/static-file-cache.d.ts +9 -0
- package/dist/server/static-file-cache.js +13 -2
- package/dist/server/worker-stages.d.ts +16 -3
- package/dist/server/worker-stages.js +23 -4
- package/dist/shims/cache-handler.js +2 -2
- package/dist/shims/cache-request-state.d.ts +23 -26
- package/dist/shims/cache-request-state.js +22 -57
- package/dist/shims/cache-runtime.d.ts +3 -1
- package/dist/shims/cache-runtime.js +94 -48
- package/dist/shims/cache.d.ts +16 -10
- package/dist/shims/cache.js +47 -36
- package/dist/shims/cacheability-classification.d.ts +2 -0
- package/dist/shims/cdn-cache.d.ts +22 -5
- package/dist/shims/client-hook-error.d.ts +2 -0
- package/dist/shims/client-hook-error.js +16 -1
- package/dist/shims/client-page-root.js +2 -2
- package/dist/shims/dynamic.js +9 -6
- package/dist/shims/error-boundary.js +2 -2
- package/dist/shims/fetch-cache-state.d.ts +5 -1
- package/dist/shims/fetch-cache-state.js +1 -3
- package/dist/shims/fetch-cache.d.ts +2 -1
- package/dist/shims/fetch-cache.js +39 -25
- package/dist/shims/form.js +2 -2
- package/dist/shims/headers.d.ts +10 -24
- package/dist/shims/headers.js +22 -70
- package/dist/shims/internal/cache-context-accessor.d.ts +1 -1
- package/dist/shims/internal/navigation-untracked.js +1 -1
- package/dist/shims/link.js +8 -11
- package/dist/shims/metadata.d.ts +23 -21
- package/dist/shims/metadata.js +62 -24
- package/dist/shims/navigation-server.js +1 -1
- package/dist/shims/navigation.d.ts +74 -7
- package/dist/shims/navigation.js +184 -31
- package/dist/shims/navigation.react-server.js +2 -2
- package/dist/shims/request-state-types.d.ts +3 -2
- package/dist/shims/slot.d.ts +16 -0
- package/dist/shims/slot.js +44 -9
- package/dist/shims/unified-request-context.d.ts +7 -1
- package/dist/shims/unified-request-context.js +3 -3
- package/dist/utils/cache-control-metadata.d.ts +5 -0
- package/dist/utils/cache-control-metadata.js +9 -1
- package/dist/utils/cache-life-profiles.d.ts +33 -0
- package/dist/utils/cache-life-profiles.js +111 -0
- package/dist/utils/middleware-request-headers.d.ts +14 -3
- package/dist/utils/middleware-request-headers.js +54 -7
- package/dist/utils/project.d.ts +2 -2
- package/dist/utils/project.js +3 -16
- package/dist/utils/regex.d.ts +5 -0
- package/dist/utils/regex.js +11 -1
- package/dist/utils/text-stream.d.ts +10 -5
- package/dist/utils/text-stream.js +6 -6
- package/package.json +2 -1
- package/dist/build/layout-classification-types.d.ts +0 -60
- package/dist/build/layout-classification-types.js +0 -1
- package/dist/build/layout-classification.d.ts +0 -62
- package/dist/build/layout-classification.js +0 -98
- package/dist/build/route-classification-injector.d.ts +0 -33
- package/dist/build/route-classification-injector.js +0 -59
- package/dist/build/route-classification-manifest.d.ts +0 -54
- package/dist/build/route-classification-manifest.js +0 -143
- package/dist/server/app-browser-client-reuse-manifest.d.ts +0 -11
- package/dist/server/app-browser-client-reuse-manifest.js +0 -101
- package/dist/server/app-layout-param-observation.d.ts +0 -42
- package/dist/server/app-layout-param-observation.js +0 -168
- package/dist/server/client-reuse-manifest.d.ts +0 -103
- package/dist/server/client-reuse-manifest.js +0 -209
- package/dist/server/skip-cache-proof.d.ts +0 -60
- package/dist/server/skip-cache-proof.js +0 -168
- package/dist/server/static-layout-client-reuse-proof.d.ts +0 -14
- package/dist/server/static-layout-client-reuse-proof.js +0 -33
- package/dist/utils/sorted-array.d.ts +0 -8
- package/dist/utils/sorted-array.js +0 -20
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isPromiseLike } from "../utils/promise.js";
|
|
2
|
-
import { probeAppPageLayouts } from "./app-page-execution.js";
|
|
3
2
|
import { Fragment, isValidElement } from "react";
|
|
4
3
|
//#region src/server/app-page-probe.ts
|
|
5
4
|
const DEFAULT_SUBTREE_PROBE_MAX_DEPTH = 32;
|
|
@@ -63,10 +62,9 @@ async function resolveReactLazyType(lazyType) {
|
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
64
|
/**
|
|
66
|
-
* Invokes server
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* failures only make static-layout skip fall back to render-and-send.
|
|
65
|
+
* Invokes the server components a layout renders, so the error-path layout
|
|
66
|
+
* probe sees an HTTP access fallback thrown below the layout's own function
|
|
67
|
+
* body. The real RSC render remains authoritative.
|
|
70
68
|
*/
|
|
71
69
|
async function probeReactServerSubtree(node, options = {}) {
|
|
72
70
|
const maxDepth = options.maxDepth ?? DEFAULT_SUBTREE_PROBE_MAX_DEPTH;
|
|
@@ -118,36 +116,5 @@ async function probeReactServerSubtree(node, options = {}) {
|
|
|
118
116
|
};
|
|
119
117
|
await visit(node, 0);
|
|
120
118
|
}
|
|
121
|
-
async function probeAppPageBeforeRender(options) {
|
|
122
|
-
let layoutFlags = {};
|
|
123
|
-
if (options.skipProbes) return {
|
|
124
|
-
response: null,
|
|
125
|
-
layoutFlags
|
|
126
|
-
};
|
|
127
|
-
if (options.layoutCount > 0) {
|
|
128
|
-
const layoutProbeResult = await probeAppPageLayouts({
|
|
129
|
-
layoutCount: options.layoutCount,
|
|
130
|
-
async onLayoutError(layoutError, layoutIndex) {
|
|
131
|
-
const specialError = options.resolveSpecialError(layoutError);
|
|
132
|
-
if (!specialError) return null;
|
|
133
|
-
return options.renderLayoutSpecialError(specialError, layoutIndex);
|
|
134
|
-
},
|
|
135
|
-
probeLayoutAt: options.probeLayoutAt,
|
|
136
|
-
runWithSuppressedHookWarning(probe) {
|
|
137
|
-
return options.runWithSuppressedHookWarning(probe);
|
|
138
|
-
},
|
|
139
|
-
classification: options.classification
|
|
140
|
-
});
|
|
141
|
-
layoutFlags = layoutProbeResult.layoutFlags;
|
|
142
|
-
if (layoutProbeResult.response) return {
|
|
143
|
-
response: layoutProbeResult.response,
|
|
144
|
-
layoutFlags
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
return {
|
|
148
|
-
response: null,
|
|
149
|
-
layoutFlags
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
119
|
//#endregion
|
|
153
|
-
export {
|
|
120
|
+
export { probeReactServerSubtree };
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { ClientReuseManifestParseResult, ClientReuseManifestSkipDisposition } from "./client-reuse-manifest.js";
|
|
2
1
|
import { AppOutgoingElements } from "./app-elements-wire.js";
|
|
3
2
|
import "./app-elements.js";
|
|
4
3
|
import { AppRscRenderMode } from "./app-rsc-render-mode.js";
|
|
5
4
|
import { NavigationContext } from "../shims/navigation-context-state.js";
|
|
6
5
|
import "../shims/navigation.js";
|
|
7
|
-
import { AppPageFontPreload, AppPageSpecialError
|
|
6
|
+
import { AppPageFontPreload, AppPageSpecialError } from "./app-page-execution.js";
|
|
8
7
|
import { AppPageMiddlewareContext } from "./app-page-response.js";
|
|
9
|
-
import { AppLayoutParamAccessTracker } from "./app-layout-param-observation.js";
|
|
10
8
|
import { RootParams } from "../shims/root-params.js";
|
|
11
9
|
import { AppPageSsrHandler } from "./app-page-stream.js";
|
|
12
10
|
import { AppRenderErrorContextOverrides } from "./app-rsc-error-handler.js";
|
|
@@ -74,7 +72,6 @@ type RenderAppPageLifecycleOptionsBase = {
|
|
|
74
72
|
peekRequestCacheLife?: () => AppPageRequestCacheLife | null;
|
|
75
73
|
getDraftModeCookieHeader: () => string | null | undefined;
|
|
76
74
|
handlerStart: number;
|
|
77
|
-
hasCustomGlobalError?: boolean;
|
|
78
75
|
dynamicStaleTimeSeconds?: number;
|
|
79
76
|
isDynamicError: boolean;
|
|
80
77
|
isDraftMode: boolean;
|
|
@@ -110,7 +107,6 @@ type RenderAppPageLifecycleOptionsBase = {
|
|
|
110
107
|
isrSet: AppPageCacheSetter;
|
|
111
108
|
interceptionContext?: string | null;
|
|
112
109
|
interceptionId?: string | null;
|
|
113
|
-
layoutCount: number;
|
|
114
110
|
loadSsrHandler: () => Promise<AppPageSsrHandler>;
|
|
115
111
|
middlewareContext: AppPageMiddlewareContext;
|
|
116
112
|
navigationParams: Record<string, unknown>;
|
|
@@ -120,12 +116,10 @@ type RenderAppPageLifecycleOptionsBase = {
|
|
|
120
116
|
abortPprFallbackShell?: () => void;
|
|
121
117
|
rootParams?: RootParams;
|
|
122
118
|
peekRenderObservationState?: () => AppPageRenderObservationState;
|
|
123
|
-
probeLayoutAt: (layoutIndex: number) => unknown;
|
|
124
119
|
expireSeconds?: number;
|
|
125
120
|
formState?: ReactFormState | null;
|
|
126
121
|
revalidateSeconds: number | null;
|
|
127
122
|
renderErrorBoundaryResponse: (error: unknown, errorOrigin: "rsc" | "ssr") => Promise<Response | null>;
|
|
128
|
-
renderLayoutSpecialError: (specialError: AppPageSpecialError, layoutIndex: number) => Promise<Response>;
|
|
129
123
|
renderPageSpecialError: (specialError: AppPageSpecialError, renderOptions?: AppPageSpecialErrorRenderOptions) => Promise<Response>;
|
|
130
124
|
renderToReadableStream: (element: ReactNode | AppOutgoingElements, options: {
|
|
131
125
|
onError: AppPageBoundaryOnError;
|
|
@@ -138,16 +132,11 @@ type RenderAppPageLifecycleOptionsBase = {
|
|
|
138
132
|
prelude: ReadableStream<Uint8Array>;
|
|
139
133
|
}>;
|
|
140
134
|
routePattern: string;
|
|
141
|
-
runWithSuppressedHookWarning<T>(probe: () => Promise<T>): Promise<T>;
|
|
142
135
|
scriptNonce?: string;
|
|
143
|
-
clientReuseManifest?: ClientReuseManifestParseResult;
|
|
144
|
-
skipDisposition?: ClientReuseManifestSkipDisposition;
|
|
145
136
|
mountedSlotsHeader?: string | null;
|
|
146
137
|
renderedPathAndSearch?: string | null;
|
|
147
138
|
renderMode?: AppRscRenderMode;
|
|
148
139
|
waitUntil?: (promise: Promise<void>) => void;
|
|
149
|
-
layoutParamAccess?: AppLayoutParamAccessTracker;
|
|
150
|
-
classification?: LayoutClassificationOptions | null;
|
|
151
140
|
};
|
|
152
141
|
type RenderAppPageLifecycleOptions = RenderAppPageLifecycleOptionsBase & ({
|
|
153
142
|
element: AppPageRenderableElement;
|
|
@@ -163,7 +152,7 @@ type RenderAppPageLifecycleOptions = RenderAppPageLifecycleOptionsBase & ({
|
|
|
163
152
|
* its response policy, such as error boundaries and special errors, get the
|
|
164
153
|
* same header as the normal render.
|
|
165
154
|
*/
|
|
166
|
-
export declare function applyIneligibleRouteCachePolicy(response: Response, options: Pick<RenderAppPageLifecycleOptions, "dynamicStaleTimeSeconds" | "isDraftMode" | "isDynamicError" | "isForceDynamic" | "isForceStatic" | "isProduction" | "isProgressiveActionRender" | "isRscRequest" | "isStaticEligible" | "middlewareContext" | "peekDynamicUsage" | "revalidateSeconds" | "scriptNonce">,
|
|
155
|
+
export declare function applyIneligibleRouteCachePolicy(response: Response, options: Pick<RenderAppPageLifecycleOptions, "dynamicStaleTimeSeconds" | "isDraftMode" | "isDynamicError" | "isForceDynamic" | "isForceStatic" | "isProduction" | "isProgressiveActionRender" | "isRscRequest" | "isStaticEligible" | "middlewareContext" | "peekDynamicUsage" | "revalidateSeconds" | "scriptNonce">, requestCacheLife?: AppPageRequestCacheLife | null): Response;
|
|
167
156
|
export declare function renderAppPageLifecycle(options: RenderAppPageLifecycleOptions): Promise<Response>;
|
|
168
157
|
//#endregion
|
|
169
158
|
export {};
|
|
@@ -4,36 +4,33 @@ import { bindRequestContext } from "../shims/unified-request-context.js";
|
|
|
4
4
|
import { VINEXT_DYNAMIC_STALE_TIME_HEADER, VINEXT_RSC_COMPLETION_METADATA_HEADER } from "./headers.js";
|
|
5
5
|
import { internalServerErrorResponse } from "./http-error-responses.js";
|
|
6
6
|
import { getRequestExecutionContext } from "../shims/request-context.js";
|
|
7
|
-
import {
|
|
7
|
+
import { getCdnCacheAdapter } from "../shims/cdn-cache.js";
|
|
8
|
+
import { getRouteCacheabilityCaptureOptions, isRouteCacheabilityEvaluation, recordRouteCacheabilityClientTraceMetadataMarker } from "../shims/cacheability-classification.js";
|
|
8
9
|
import { NEVER_CACHE_CONTROL, NO_STORE_CACHE_CONTROL, applyCdnResponseHeaders, isCdnResponsePolicyHeader } from "./cache-control.js";
|
|
9
10
|
import "./app-rsc-render-mode.js";
|
|
10
11
|
import { resolveClientStaleTimeSeconds } from "../utils/cache-control-metadata.js";
|
|
11
|
-
import { isRenderDynamicLatched
|
|
12
|
-
import { peekDynamicUsage
|
|
12
|
+
import { isRenderDynamicLatched } from "../shims/internal/headers-state.js";
|
|
13
|
+
import { peekDynamicUsage } from "../shims/headers.js";
|
|
13
14
|
import { runWithFetchDedupe } from "../shims/fetch-cache.js";
|
|
14
15
|
import { setCacheStateHeaders } from "./cache-headers.js";
|
|
16
|
+
import { applyPrerenderCacheLifeHeader, applyPrerenderCacheTagsHeader } from "./prerender-cache-life-header.js";
|
|
17
|
+
import { copyLinkHeaderProvenance, getFrameworkLinkHeader } from "./app-response-header-provenance.js";
|
|
18
|
+
import { traceResponseStartWithCompletion } from "./response-start-tracing.js";
|
|
19
|
+
import { mergeMiddlewareResponseHeaders } from "./middleware-response-headers.js";
|
|
15
20
|
import { createArtifactCompatibilityEnvelope, createArtifactCompatibilityGraphVersion } from "./artifact-compatibility.js";
|
|
16
21
|
import { AppElementsWire, isAppElementsRecord } from "./app-elements-wire.js";
|
|
17
22
|
import "./app-elements.js";
|
|
23
|
+
import { appendRscCompletionMetadata } from "./rsc-completion-metadata.js";
|
|
18
24
|
import { isBailoutToCSRError } from "../shims/navigation-errors.js";
|
|
19
|
-
import { mergeMiddlewareResponseHeaders } from "./middleware-response-headers.js";
|
|
20
|
-
import { applyPrerenderCacheLifeHeader, applyPrerenderCacheTagsHeader } from "./prerender-cache-life-header.js";
|
|
21
|
-
import { copyLinkHeaderProvenance, getFrameworkLinkHeader } from "./app-response-header-provenance.js";
|
|
22
25
|
import { applyClientStaleTimeHeader, applyEdgeRuntimeHeader, buildAppPageHtmlResponse, buildAppPageRscResponse, resolveAppPageHtmlResponsePolicy, resolveAppPageRscResponsePolicy, resolveUncacheableCacheControl } from "./app-page-response.js";
|
|
23
26
|
import { buildAppPageFontLinkHeader, readAppPageBinaryStream, resolveAppPageCaughtNotFoundBoundaries, resolveAppPageShellSpecialError, resolveAppPageSpecialError, resolveAppPageSpecialErrorStoredHeaders, teeAppPageRscStreamForCapture } from "./app-page-execution.js";
|
|
24
|
-
import {
|
|
27
|
+
import { getAppPageLayoutGate } from "./app-page-layout-gate.js";
|
|
25
28
|
import { hasDigest } from "./app-rsc-errors.js";
|
|
26
29
|
import { recordAppPageRenderError, traceAppPageRender } from "./app-page-tracing.js";
|
|
27
|
-
import { traceResponseStartWithCompletion } from "./response-start-tracing.js";
|
|
28
|
-
import { DEFAULT_CACHE_VARIANT_BUDGET, buildCacheVariantWithRouteBudget, buildRenderObservation, buildRenderRequestApiObservations, createStaticLayoutArtifactReuseDecision } from "./cache-proof.js";
|
|
29
|
-
import { createStaticLayoutClientReuseArtifactCompatibility, createStaticLayoutClientReusePayloadHash, createStaticLayoutClientReuseRouteId } from "./static-layout-client-reuse-proof.js";
|
|
30
|
-
import { appendRscCompletionMetadata } from "./rsc-completion-metadata.js";
|
|
31
30
|
import { buildAppPageHtmlDocumentResponse, buildAppPageLinkHeader, createAppPageFontData, createAppPageRscErrorTracker, createAppPageSsrErrorHandler, renderAppPageHtmlStream, renderAppPageHtmlStreamWithRecovery } from "./app-page-stream.js";
|
|
32
|
-
import { getStaticLayoutObservationSkipRejection } from "./app-layout-param-observation.js";
|
|
33
31
|
import { createAppPageHtmlOutputScope, createAppPageRenderObservation, createAppPageRscOutputScope } from "./app-page-render-observation.js";
|
|
34
32
|
import { createAppPageRscRenderStatusResolver } from "./app-page-rsc-render-status.js";
|
|
35
33
|
import { finalizeAppPageCacheabilityEvaluationResponse, finalizeAppPageHtmlCacheResponse, finalizeAppPageRscCacheResponse } from "./app-page-cache-finalizer.js";
|
|
36
|
-
import { createClientReuseSkipTransportPlan, crossCheckClientReuseManifestEntryWithCache } from "./skip-cache-proof.js";
|
|
37
34
|
//#region src/server/app-page-render.ts
|
|
38
35
|
function buildResponseTiming(options) {
|
|
39
36
|
if (options.isProduction) return;
|
|
@@ -75,11 +72,11 @@ function applyRequestCacheLife(options) {
|
|
|
75
72
|
* its response policy, such as error boundaries and special errors, get the
|
|
76
73
|
* same header as the normal render.
|
|
77
74
|
*/
|
|
78
|
-
function applyIneligibleRouteCachePolicy(response, options,
|
|
75
|
+
function applyIneligibleRouteCachePolicy(response, options, requestCacheLife = null) {
|
|
79
76
|
const cacheControl = resolveEarlyResponseCacheControl(options);
|
|
80
77
|
const isRscRedirect = options.isRscRequest && response.headers.has("X-Vinext-Rsc-Redirect");
|
|
81
78
|
if (!cacheControl) {
|
|
82
|
-
const staleTimeSeconds = isRscRedirect ? resolveClientStaleTimeSeconds(
|
|
79
|
+
const staleTimeSeconds = isRscRedirect ? resolveClientStaleTimeSeconds(requestCacheLife) : void 0;
|
|
83
80
|
if (staleTimeSeconds === void 0) return response;
|
|
84
81
|
const stamped = cloneForStamping(response);
|
|
85
82
|
applyClientStaleTimeHeader(stamped.headers, staleTimeSeconds);
|
|
@@ -116,18 +113,6 @@ function resolveAppPageCacheWriteRevalidateSeconds(options) {
|
|
|
116
113
|
if (options.revalidateSeconds === null && (options.isForceStatic || options.isDynamicError)) return Infinity;
|
|
117
114
|
return options.revalidateSeconds;
|
|
118
115
|
}
|
|
119
|
-
/**
|
|
120
|
-
* A loading-shell prefetch without a loading boundary that can never be stored
|
|
121
|
-
* renders only the route tree (see buildAppPageElements), so no layout runs and
|
|
122
|
-
* none is probed. Next.js runs no layout for its no-loading prefetch either.
|
|
123
|
-
*/
|
|
124
|
-
function isRouteTreeOnlyLoadingShell(options) {
|
|
125
|
-
if (options.renderMode !== "prefetch-loading-shell") return false;
|
|
126
|
-
if (options.isCacheCandidate === true) return false;
|
|
127
|
-
if (!isAppElementsRecord(options.element)) return false;
|
|
128
|
-
const routeId = options.element[AppElementsWire.keys.route];
|
|
129
|
-
return typeof routeId === "string" && options.element[routeId] === null;
|
|
130
|
-
}
|
|
131
116
|
function readRootBoundaryId(element) {
|
|
132
117
|
const rootLayoutTreePath = element[AppElementsWire.keys.rootLayout];
|
|
133
118
|
return typeof rootLayoutTreePath === "string" ? rootLayoutTreePath : null;
|
|
@@ -144,146 +129,6 @@ function createAppPageArtifactCompatibility(element, routePattern) {
|
|
|
144
129
|
rootBoundaryId
|
|
145
130
|
});
|
|
146
131
|
}
|
|
147
|
-
function readStringMetadata(element, key) {
|
|
148
|
-
const value = element[key];
|
|
149
|
-
return typeof value === "string" ? value : null;
|
|
150
|
-
}
|
|
151
|
-
function createStaticLayoutOutputScope(input) {
|
|
152
|
-
const routeId = readStringMetadata(input.element, AppElementsWire.keys.route);
|
|
153
|
-
if (routeId === null) return null;
|
|
154
|
-
return {
|
|
155
|
-
kind: "layout",
|
|
156
|
-
layoutId: input.layoutId,
|
|
157
|
-
rootBoundaryId: input.artifactCompatibility.rootBoundaryId,
|
|
158
|
-
routeId
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
function createRenderAndSendSkipDisposition() {
|
|
162
|
-
return {
|
|
163
|
-
code: "SKIP_MODEL_DISABLED",
|
|
164
|
-
enabled: false,
|
|
165
|
-
mode: "renderAndSend"
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
function rejectStaticLayoutObservation(entry, code, fields = {}) {
|
|
169
|
-
return {
|
|
170
|
-
kind: "rejected",
|
|
171
|
-
rejection: {
|
|
172
|
-
code,
|
|
173
|
-
entryId: entry.id,
|
|
174
|
-
fields
|
|
175
|
-
},
|
|
176
|
-
skipDisposition: createRenderAndSendSkipDisposition()
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
function rejectUnsafeStaticLayoutObservation(entry, layoutParamAccess) {
|
|
180
|
-
const observation = layoutParamAccess?.getLayoutObservation(entry.id);
|
|
181
|
-
if (!observation) return rejectStaticLayoutObservation(entry, "SKIP_LAYOUT_PARAMS_OBSERVATION_INCOMPLETE");
|
|
182
|
-
const observationRejection = getStaticLayoutObservationSkipRejection(observation);
|
|
183
|
-
if (observationRejection) return rejectStaticLayoutObservation(entry, observationRejection.code, observationRejection.fields);
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
|
-
function createRenderLifecycleSkipDisposition(input) {
|
|
187
|
-
if (!input.isRscRequest || input.clientReuseManifest === void 0) return;
|
|
188
|
-
const clientReuseManifest = input.clientReuseManifest;
|
|
189
|
-
if (clientReuseManifest.kind !== "parsed" || clientReuseManifest.manifest.entries.length === 0) return;
|
|
190
|
-
if (!isAppElementsRecord(input.element) || input.artifactCompatibility === void 0) return {
|
|
191
|
-
code: "SKIP_MODEL_DISABLED",
|
|
192
|
-
enabled: false,
|
|
193
|
-
mode: "renderAndSend"
|
|
194
|
-
};
|
|
195
|
-
const element = input.element;
|
|
196
|
-
const artifactCompatibility = input.artifactCompatibility;
|
|
197
|
-
const staticLayoutIds = new Set(Object.entries(input.layoutFlags).filter(([, flag]) => flag === "s").map(([layoutId]) => layoutId));
|
|
198
|
-
return createClientReuseSkipTransportPlan({
|
|
199
|
-
manifest: clientReuseManifest,
|
|
200
|
-
verifyEntry(entry) {
|
|
201
|
-
if (entry.kind !== "layout" || !staticLayoutIds.has(entry.id) || AppElementsWire.parseElementKey(entry.id)?.kind !== "layout") return crossCheckClientReuseManifestEntryWithCache({
|
|
202
|
-
artifact: {
|
|
203
|
-
compatibility: artifactCompatibility,
|
|
204
|
-
invalidation: { kind: "unknown" },
|
|
205
|
-
payloadHash: null
|
|
206
|
-
},
|
|
207
|
-
cacheDecision: null,
|
|
208
|
-
entry
|
|
209
|
-
});
|
|
210
|
-
const currentOutput = createStaticLayoutOutputScope({
|
|
211
|
-
artifactCompatibility,
|
|
212
|
-
element,
|
|
213
|
-
layoutId: entry.id
|
|
214
|
-
});
|
|
215
|
-
if (currentOutput === null) return crossCheckClientReuseManifestEntryWithCache({
|
|
216
|
-
artifact: {
|
|
217
|
-
compatibility: artifactCompatibility,
|
|
218
|
-
invalidation: { kind: "unknown" },
|
|
219
|
-
payloadHash: null
|
|
220
|
-
},
|
|
221
|
-
cacheDecision: null,
|
|
222
|
-
entry
|
|
223
|
-
});
|
|
224
|
-
const observationRejection = rejectUnsafeStaticLayoutObservation(entry, input.layoutParamAccess);
|
|
225
|
-
if (observationRejection) return observationRejection;
|
|
226
|
-
const candidateRouteId = createStaticLayoutClientReuseRouteId(entry.id);
|
|
227
|
-
const candidateOutput = {
|
|
228
|
-
...currentOutput,
|
|
229
|
-
routeId: candidateRouteId
|
|
230
|
-
};
|
|
231
|
-
const candidateVariant = buildCacheVariantWithRouteBudget({
|
|
232
|
-
budget: DEFAULT_CACHE_VARIANT_BUDGET,
|
|
233
|
-
dimensions: [],
|
|
234
|
-
output: candidateOutput,
|
|
235
|
-
routeBudget: {
|
|
236
|
-
routeId: candidateRouteId,
|
|
237
|
-
variantCacheKeys: []
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
const skipArtifactCompatibility = candidateVariant.kind === "variant" ? createStaticLayoutClientReuseArtifactCompatibility({
|
|
241
|
-
artifactCompatibility,
|
|
242
|
-
layoutId: entry.id,
|
|
243
|
-
rootBoundaryId: candidateOutput.rootBoundaryId,
|
|
244
|
-
routeId: candidateOutput.routeId,
|
|
245
|
-
variantCacheKey: candidateVariant.variant.cacheKey
|
|
246
|
-
}) : artifactCompatibility;
|
|
247
|
-
const cacheDecision = createStaticLayoutArtifactReuseDecision({
|
|
248
|
-
candidateArtifactCompatibility: skipArtifactCompatibility,
|
|
249
|
-
candidateObservation: buildRenderObservation({
|
|
250
|
-
boundaryOutcome: { kind: "success" },
|
|
251
|
-
cacheability: "public",
|
|
252
|
-
cacheTags: [],
|
|
253
|
-
completeness: "complete",
|
|
254
|
-
dynamicFetches: [],
|
|
255
|
-
output: candidateOutput,
|
|
256
|
-
pathTags: [input.cleanPathname],
|
|
257
|
-
requestApis: buildRenderRequestApiObservations({
|
|
258
|
-
completeness: "complete",
|
|
259
|
-
observed: []
|
|
260
|
-
})
|
|
261
|
-
}),
|
|
262
|
-
candidateVariant,
|
|
263
|
-
currentArtifactCompatibility: skipArtifactCompatibility,
|
|
264
|
-
currentOutput
|
|
265
|
-
});
|
|
266
|
-
return crossCheckClientReuseManifestEntryWithCache({
|
|
267
|
-
artifact: {
|
|
268
|
-
compatibility: skipArtifactCompatibility,
|
|
269
|
-
invalidation: { kind: "valid" },
|
|
270
|
-
payloadHash: candidateVariant.kind === "variant" ? createStaticLayoutClientReusePayloadHash({
|
|
271
|
-
artifactCompatibility: skipArtifactCompatibility,
|
|
272
|
-
layoutId: entry.id,
|
|
273
|
-
rootBoundaryId: candidateOutput.rootBoundaryId,
|
|
274
|
-
routeId: candidateOutput.routeId,
|
|
275
|
-
variantCacheKey: candidateVariant.variant.cacheKey
|
|
276
|
-
}) : null
|
|
277
|
-
},
|
|
278
|
-
cacheDecision,
|
|
279
|
-
entry
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
}).skipDisposition;
|
|
283
|
-
}
|
|
284
|
-
function isSkipTransportEnabled(skipDisposition) {
|
|
285
|
-
return skipDisposition?.enabled === true;
|
|
286
|
-
}
|
|
287
132
|
/**
|
|
288
133
|
* Wraps an RSC response body to report invalid dynamic usage errors after the
|
|
289
134
|
* stream is fully consumed. In dev mode, errors from cookies()/headers() inside
|
|
@@ -385,7 +230,6 @@ async function prepareAppPageElement(options) {
|
|
|
385
230
|
}
|
|
386
231
|
async function renderAppPageLifecycleImpl(options, renderSpan) {
|
|
387
232
|
let dynamicUsageObserved = false;
|
|
388
|
-
let dynamicUsageFinalized = false;
|
|
389
233
|
const isCacheCandidateHtmlRender = options.isCacheCandidate === true && options.isPrerender !== true && !options.isRscRequest;
|
|
390
234
|
const readsRenderDynamicLatch = isCacheCandidateHtmlRender || !options.isRscRequest && options.pprFallbackShellSignal === void 0 && (options.isPrerender === true || isRouteCacheabilityEvaluation());
|
|
391
235
|
const readDynamicUsage = bindRequestContext(() => options.consumeDynamicUsage() || readsRenderDynamicLatch && isRenderDynamicLatched());
|
|
@@ -395,34 +239,6 @@ async function renderAppPageLifecycleImpl(options, renderSpan) {
|
|
|
395
239
|
if (!dynamicUsageObserved) dynamicUsageObserved = readDynamicUsage();
|
|
396
240
|
return dynamicUsageObserved;
|
|
397
241
|
};
|
|
398
|
-
const finalizeRenderDynamicUsage = () => {
|
|
399
|
-
if (!dynamicUsageFinalized) {
|
|
400
|
-
consumeRenderDynamicUsage();
|
|
401
|
-
dynamicUsageFinalized = true;
|
|
402
|
-
}
|
|
403
|
-
return dynamicUsageObserved;
|
|
404
|
-
};
|
|
405
|
-
const probeOutcome = await runWithDetachedDynamicUsage(() => probeAppPageBeforeRender({
|
|
406
|
-
skipProbes: options.pprFallbackShellSignal !== void 0 || isRouteTreeOnlyLoadingShell(options),
|
|
407
|
-
layoutCount: options.layoutCount,
|
|
408
|
-
probeLayoutAt(layoutIndex) {
|
|
409
|
-
return options.probeLayoutAt(layoutIndex);
|
|
410
|
-
},
|
|
411
|
-
renderLayoutSpecialError(specialError, layoutIndex) {
|
|
412
|
-
return options.renderLayoutSpecialError(specialError, layoutIndex);
|
|
413
|
-
},
|
|
414
|
-
resolveSpecialError: resolveAppPageSpecialError,
|
|
415
|
-
runWithSuppressedHookWarning(probe) {
|
|
416
|
-
return options.runWithSuppressedHookWarning(probe);
|
|
417
|
-
},
|
|
418
|
-
classification: options.classification
|
|
419
|
-
}));
|
|
420
|
-
const preRenderResult = probeOutcome.result;
|
|
421
|
-
if (preRenderResult.response) {
|
|
422
|
-
if (probeOutcome.dynamicDetected) markDynamicUsage();
|
|
423
|
-
return applyIneligibleRouteCachePolicy(preRenderResult.response, options, probeOutcome.cacheLife);
|
|
424
|
-
}
|
|
425
|
-
const layoutFlags = preRenderResult.layoutFlags;
|
|
426
242
|
const artifactCompatibility = createAppPageArtifactCompatibility(options.element, options.routePattern);
|
|
427
243
|
const rootBoundaryId = artifactCompatibility?.rootBoundaryId ?? null;
|
|
428
244
|
const renderEpoch = artifactCompatibility?.renderEpoch ?? null;
|
|
@@ -439,23 +255,13 @@ async function renderAppPageLifecycleImpl(options, renderSpan) {
|
|
|
439
255
|
rootBoundaryId,
|
|
440
256
|
routePattern: options.routePattern
|
|
441
257
|
});
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
cleanPathname: options.cleanPathname,
|
|
445
|
-
clientReuseManifest: options.clientReuseManifest,
|
|
446
|
-
element: options.element,
|
|
447
|
-
isRscRequest: options.isRscRequest,
|
|
448
|
-
layoutFlags,
|
|
449
|
-
layoutParamAccess: options.layoutParamAccess
|
|
450
|
-
});
|
|
451
|
-
const shouldBypassRscCache = options.isRscRequest && isSkipTransportEnabled(skipDisposition) || options.bypassInterceptionContextCache === true;
|
|
258
|
+
const isPartialPayload = options.isRscRequest && isAppElementsRecord(options.element) && Object.hasOwn(options.element, AppElementsWire.keys.skippedLayoutIds);
|
|
259
|
+
const shouldBypassRscCache = options.bypassInterceptionContextCache === true || isPartialPayload;
|
|
452
260
|
const dynamicStaleTimeSeconds = options.dynamicStaleTimeSeconds ?? resolveConfiguredDynamicStaleTimeSeconds();
|
|
453
261
|
const outgoingElement = AppElementsWire.encodeOutgoingPayload({
|
|
454
262
|
element: options.element,
|
|
455
|
-
layoutFlags,
|
|
456
263
|
...dynamicStaleTimeSeconds !== void 0 && options.isPrerender !== true && !options.isForceStatic ? { dynamicStaleTimeSeconds } : {},
|
|
457
|
-
...artifactCompatibility ? { artifactCompatibility } : {}
|
|
458
|
-
skipDisposition: options.isRscRequest ? skipDisposition : void 0
|
|
264
|
+
...artifactCompatibility ? { artifactCompatibility } : {}
|
|
459
265
|
});
|
|
460
266
|
const compileEnd = options.isProduction ? void 0 : performance.now();
|
|
461
267
|
const errorContextOverrides = {
|
|
@@ -466,6 +272,7 @@ async function renderAppPageLifecycleImpl(options, renderSpan) {
|
|
|
466
272
|
...options.isPrerender ? { revalidateReason: "stale" } : {}
|
|
467
273
|
};
|
|
468
274
|
const baseOnError = options.createRscOnErrorHandler(options.cleanPathname, options.routePattern, errorContextOverrides);
|
|
275
|
+
const layoutGate = options.isRscRequest && options.isPrerender !== true && options.pprFallbackShellSignal === void 0 ? getAppPageLayoutGate(options.element) : null;
|
|
469
276
|
const rscErrorTracker = createAppPageRscErrorTracker((error, requestInfo, errorContext) => {
|
|
470
277
|
if (renderSpan) recordAppPageRenderError(renderSpan, error);
|
|
471
278
|
return baseOnError(error, requestInfo, errorContext);
|
|
@@ -484,6 +291,24 @@ async function renderAppPageLifecycleImpl(options, renderSpan) {
|
|
|
484
291
|
});
|
|
485
292
|
let pprFallbackShellRsc = null;
|
|
486
293
|
if (options.pprFallbackShellSignal) pprFallbackShellRsc = new Uint8Array(await readAppPageBinaryStream(rscStream));
|
|
294
|
+
if (layoutGate) {
|
|
295
|
+
const [heldStream, watchedStream] = rscStream.tee();
|
|
296
|
+
rscStream = heldStream;
|
|
297
|
+
const watchedReader = watchedStream.getReader();
|
|
298
|
+
const renderEnded = (async () => {
|
|
299
|
+
while (!(await watchedReader.read()).done);
|
|
300
|
+
})();
|
|
301
|
+
const layoutFailure = await layoutGate.wait((layoutId) => isAppElementsRecord(outgoingElement) && Object.hasOwn(outgoingElement, layoutId), renderEnded);
|
|
302
|
+
watchedReader.cancel().catch(() => {});
|
|
303
|
+
const layoutSpecialError = layoutFailure ? resolveAppPageSpecialError(layoutFailure.error) : null;
|
|
304
|
+
if (layoutFailure && layoutSpecialError) {
|
|
305
|
+
rscStream.cancel().catch(() => {});
|
|
306
|
+
return applyIneligibleRouteCachePolicy(await options.renderPageSpecialError(layoutSpecialError.kind === "http-access-fallback" ? {
|
|
307
|
+
...layoutSpecialError,
|
|
308
|
+
layoutIndex: layoutFailure.layoutIndex
|
|
309
|
+
} : layoutSpecialError), options, options.peekRequestCacheLife?.() ?? options.getRequestCacheLife());
|
|
310
|
+
}
|
|
311
|
+
}
|
|
487
312
|
let revalidateSeconds = options.revalidateSeconds;
|
|
488
313
|
let expireSeconds = options.expireSeconds;
|
|
489
314
|
const shouldWaitForAllReady = options.isPrerender === true && options.isSpeculativePrerender !== true || options.renderWholeDocument === true;
|
|
@@ -501,10 +326,47 @@ async function renderAppPageLifecycleImpl(options, renderSpan) {
|
|
|
501
326
|
const rscForResponse = rscCapture.ssrStream;
|
|
502
327
|
const capturedRscDataRef = { value: null };
|
|
503
328
|
if (rscCapture.sideStream && options.isRscRequest) capturedRscDataRef.value = readAppPageBinaryStream(rscCapture.sideStream);
|
|
329
|
+
const resolveInitialNavigationCacheMetadata = (dynamicUsed, requestCacheLife) => {
|
|
330
|
+
let kind;
|
|
331
|
+
if (options.isForceStatic) kind = "static";
|
|
332
|
+
else if (options.isForceDynamic || dynamicUsed) kind = "dynamic";
|
|
333
|
+
else {
|
|
334
|
+
const observation = options.peekRenderObservationState?.();
|
|
335
|
+
kind = observation && (observation.dynamicFetches.length > 0 || observation.requestApis.length > 0) ? "dynamic" : "static";
|
|
336
|
+
}
|
|
337
|
+
const staleTimeSeconds = resolveClientStaleTimeSeconds(requestCacheLife);
|
|
338
|
+
return {
|
|
339
|
+
kind,
|
|
340
|
+
...kind === "dynamic" && dynamicStaleTimeSeconds !== void 0 && options.isPrerender !== true ? { dynamicStaleTimeSeconds } : {},
|
|
341
|
+
...staleTimeSeconds === void 0 ? {} : { staleTimeSeconds: Math.floor(staleTimeSeconds) }
|
|
342
|
+
};
|
|
343
|
+
};
|
|
504
344
|
if (options.isRscRequest) {
|
|
505
|
-
const
|
|
345
|
+
const capturedRscData = capturedRscDataRef.value;
|
|
346
|
+
const resolvesRscRenderStatus = options.isProduction && shouldCaptureRscForCacheMetadata && capturedRscData !== null && options.isPrerender !== true && options.isRoutePPREnabled !== true;
|
|
347
|
+
const isPageDocumentRender = options.isCacheCandidate === true && !options.scriptNonce && !options.mountedSlotsHeader && !options.interceptionContext && !options.interceptionId && (options.renderMode === void 0 || options.renderMode === "navigation");
|
|
348
|
+
const cdnCacheAdapter = getCdnCacheAdapter();
|
|
349
|
+
const captureAdmittedDocument = resolvesRscRenderStatus && isPageDocumentRender && !cdnCacheAdapter.ownsBackgroundRevalidation ? cdnCacheAdapter.captureAppPageDocument?.() : void 0;
|
|
350
|
+
const rendersDocument = isPageDocumentRender && (cdnCacheAdapter.ownsBackgroundRevalidation || captureAdmittedDocument !== void 0);
|
|
351
|
+
const resolveRscRenderStatus = resolvesRscRenderStatus ? createAppPageRscRenderStatusResolver({
|
|
506
352
|
basePath: options.basePath,
|
|
507
|
-
capturedRscData
|
|
353
|
+
capturedRscData,
|
|
354
|
+
...rendersDocument ? { document: {
|
|
355
|
+
clientTraceMetadata: options.clientTraceMetadata,
|
|
356
|
+
...captureAdmittedDocument ? { deadlineAt: getRouteCacheabilityCaptureOptions()?.captureDeadlineAt } : {},
|
|
357
|
+
getFontData: () => createAppPageFontData({
|
|
358
|
+
getLinks: options.getFontLinks,
|
|
359
|
+
getPreloads: options.getFontPreloads,
|
|
360
|
+
getStyles: options.getFontStyles
|
|
361
|
+
}),
|
|
362
|
+
getInitialNavigationCacheMetadata: () => resolveInitialNavigationCacheMetadata(peekDynamicUsage(), options.peekRequestCacheLife?.()),
|
|
363
|
+
mirrorNextFlight: () => rscErrorTracker.getCapturedSpecialError() !== null,
|
|
364
|
+
onSsrError: createAppPageSsrErrorHandler(options.createRscOnErrorHandler(options.cleanPathname, options.routePattern, {
|
|
365
|
+
...errorContextOverrides,
|
|
366
|
+
renderSource: "server-rendering"
|
|
367
|
+
}), rscErrorTracker.isCapturedError),
|
|
368
|
+
reactMaxHeadersLength: options.reactMaxHeadersLength
|
|
369
|
+
} } : {},
|
|
508
370
|
getCapturedSpecialError: rscErrorTracker.getCapturedSpecialError,
|
|
509
371
|
getCapturedSpecialErrors: rscErrorTracker.getCapturedSpecialErrors,
|
|
510
372
|
isForceStatic: options.isForceStatic,
|
|
@@ -524,7 +386,7 @@ async function renderAppPageLifecycleImpl(options, renderSpan) {
|
|
|
524
386
|
}));
|
|
525
387
|
}
|
|
526
388
|
const dynamicUsedDuringBuild = consumeRenderDynamicUsage();
|
|
527
|
-
const rscResponsePolicy = shouldBypassRscCache ? { cacheControl: NO_STORE_CACHE_CONTROL } : resolveAppPageRscResponsePolicy({
|
|
389
|
+
const rscResponsePolicy = isPartialPayload ? { cacheControl: resolveUncacheableCacheControl(options.isProduction) } : shouldBypassRscCache ? { cacheControl: NO_STORE_CACHE_CONTROL } : resolveAppPageRscResponsePolicy({
|
|
528
390
|
dynamicUsedDuringBuild,
|
|
529
391
|
isDraftMode: options.isDraftMode,
|
|
530
392
|
isDynamicError: options.isDynamicError,
|
|
@@ -535,7 +397,7 @@ async function renderAppPageLifecycleImpl(options, renderSpan) {
|
|
|
535
397
|
expireSeconds,
|
|
536
398
|
revalidateSeconds
|
|
537
399
|
});
|
|
538
|
-
if (shouldBypassRscCache) options.isrDebug?.(
|
|
400
|
+
if (shouldBypassRscCache) options.isrDebug?.(isPartialPayload ? "RSC cache write skipped (partial payload)" : "RSC cache write skipped (unverified interception context)", options.cleanPathname);
|
|
539
401
|
const shouldEmitDynamicStaleTime = dynamicStaleTimeSeconds !== void 0 && options.isPrerender !== true && !options.isForceStatic && (dynamicUsedDuringBuild || options.isForceDynamic);
|
|
540
402
|
const staleTimePending = options.isPrerender !== true && mayResolveCacheLifeAfterHeaders && !dynamicUsedDuringBuild;
|
|
541
403
|
const rscResponse = buildAppPageRscResponse(rscForResponse, {
|
|
@@ -559,7 +421,7 @@ async function renderAppPageLifecycleImpl(options, renderSpan) {
|
|
|
559
421
|
const completionHeaders = new Headers(rscResponse.headers);
|
|
560
422
|
completionHeaders.set(VINEXT_RSC_COMPLETION_METADATA_HEADER, "1");
|
|
561
423
|
const completionResponse = dynamicStaleTimeSeconds !== void 0 && options.isPrerender !== true && !options.isForceStatic && rscResponse.body ? new Response(appendRscCompletionMetadata(rscResponse.body, () => {
|
|
562
|
-
if (!
|
|
424
|
+
if (!consumeRenderDynamicUsage()) return void 0;
|
|
563
425
|
const completedServerStaleTimeSeconds = resolveClientStaleTimeSeconds(options.peekRequestCacheLife?.());
|
|
564
426
|
if (shouldEmitDynamicStaleTime && completedServerStaleTimeSeconds === void 0) return;
|
|
565
427
|
return {
|
|
@@ -575,9 +437,22 @@ async function renderAppPageLifecycleImpl(options, renderSpan) {
|
|
|
575
437
|
return finalizeAppPageRscCacheResponse(devRscResponse, {
|
|
576
438
|
capturedRscDataPromise: options.isProduction && shouldCaptureRscForCacheMetadata ? capturedRscDataRef.value : null,
|
|
577
439
|
bypassInterceptionContextCache: options.bypassInterceptionContextCache,
|
|
440
|
+
captureAdmittedDocument,
|
|
578
441
|
cleanPathname: options.cleanPathname,
|
|
579
|
-
consumeDynamicUsage:
|
|
442
|
+
consumeDynamicUsage: consumeRenderDynamicUsage,
|
|
580
443
|
consumeRenderObservationState,
|
|
444
|
+
createHtmlRenderObservation(input) {
|
|
445
|
+
return createAppPageRenderObservation({
|
|
446
|
+
boundaryOutcome: { kind: "success" },
|
|
447
|
+
cacheability: "public",
|
|
448
|
+
cacheTags: input.cacheTags,
|
|
449
|
+
cleanPathname: options.cleanPathname,
|
|
450
|
+
completeness: "complete",
|
|
451
|
+
output: htmlOutputScope,
|
|
452
|
+
params: options.navigationParams,
|
|
453
|
+
state: input.state
|
|
454
|
+
});
|
|
455
|
+
},
|
|
581
456
|
createRscRenderObservation(input) {
|
|
582
457
|
return createAppPageRenderObservation({
|
|
583
458
|
boundaryOutcome: { kind: "success" },
|
|
@@ -598,6 +473,7 @@ async function renderAppPageLifecycleImpl(options, renderSpan) {
|
|
|
598
473
|
return readRequestCacheLifeForCachePolicy(options);
|
|
599
474
|
},
|
|
600
475
|
isrDebug: options.isrDebug,
|
|
476
|
+
isrHtmlKey: options.isrHtmlKey,
|
|
601
477
|
isrRscKey: options.isrRscKey,
|
|
602
478
|
isrSet: options.isrSet,
|
|
603
479
|
interceptionContext: options.interceptionContext,
|
|
@@ -746,6 +622,12 @@ async function renderAppPageLifecycleImpl(options, renderSpan) {
|
|
|
746
622
|
copyLinkHeaderProvenance(response.headers, prerenderResponse.headers);
|
|
747
623
|
return prerenderResponse;
|
|
748
624
|
};
|
|
625
|
+
const markPrerenderedDynamicShellSpecialError = (response, specialError) => {
|
|
626
|
+
if (options.isPrerender === true && response.status === specialError.statusCode && resolveEarlyResponseCacheControl(options) !== null && response.headers.get("cache-control")?.includes("no-store")) getRequestExecutionContext()?.recordPrerenderSpecialError?.({
|
|
627
|
+
headers: resolveAppPageSpecialErrorStoredHeaders(specialError, options.basePath) ?? {},
|
|
628
|
+
status: response.status
|
|
629
|
+
});
|
|
630
|
+
};
|
|
749
631
|
const finalizeShellSpecialErrorResponse = (response, specialError) => {
|
|
750
632
|
if (response.status !== specialError.statusCode) return applyIneligibleRouteCachePolicy(response, options);
|
|
751
633
|
const dynamicUsedDuringRender = consumeRenderDynamicUsage();
|
|
@@ -801,24 +683,8 @@ async function renderAppPageLifecycleImpl(options, renderSpan) {
|
|
|
801
683
|
};
|
|
802
684
|
return renderAppPageHtmlStream({
|
|
803
685
|
capturedRscDataRef,
|
|
804
|
-
getInitialNavigationCacheMetadata: () =>
|
|
805
|
-
let kind;
|
|
806
|
-
if (options.isForceStatic) kind = "static";
|
|
807
|
-
else if (options.isForceDynamic || dynamicUsedDuringHtmlRender || peekDynamicUsage()) kind = "dynamic";
|
|
808
|
-
else {
|
|
809
|
-
const observation = options.peekRenderObservationState?.();
|
|
810
|
-
kind = observation && (observation.dynamicFetches.length > 0 || observation.requestApis.length > 0) ? "dynamic" : "static";
|
|
811
|
-
}
|
|
812
|
-
const requestCacheLife = options.isPrerender === true ? requestCacheLifeForPrerender ?? options.peekRequestCacheLife?.() : options.peekRequestCacheLife?.();
|
|
813
|
-
const staleTimeSeconds = resolveClientStaleTimeSeconds(requestCacheLife);
|
|
814
|
-
return {
|
|
815
|
-
kind,
|
|
816
|
-
...kind === "dynamic" && dynamicStaleTimeSeconds !== void 0 && options.isPrerender !== true ? { dynamicStaleTimeSeconds } : {},
|
|
817
|
-
...staleTimeSeconds === void 0 ? {} : { staleTimeSeconds: Math.floor(staleTimeSeconds) }
|
|
818
|
-
};
|
|
819
|
-
},
|
|
686
|
+
getInitialNavigationCacheMetadata: () => resolveInitialNavigationCacheMetadata(dynamicUsedDuringHtmlRender || peekDynamicUsage(), options.isPrerender === true ? requestCacheLifeForPrerender ?? options.peekRequestCacheLife?.() : options.peekRequestCacheLife?.()),
|
|
820
687
|
fontData,
|
|
821
|
-
hasCustomGlobalError: options.hasCustomGlobalError,
|
|
822
688
|
navigationContext: options.getNavigationContext(),
|
|
823
689
|
basePath: options.basePath,
|
|
824
690
|
clientTraceMetadata: options.clientTraceMetadata,
|
|
@@ -832,7 +698,8 @@ async function renderAppPageLifecycleImpl(options, renderSpan) {
|
|
|
832
698
|
scriptNonce: options.scriptNonce,
|
|
833
699
|
sideStream: rscCapture.sideStream,
|
|
834
700
|
ssrHandler,
|
|
835
|
-
fallbackToErrorDocumentOnShellError: options.isPrerender === true && options.isSpeculativePrerender === true
|
|
701
|
+
fallbackToErrorDocumentOnShellError: !(options.isPrerender === true && options.isSpeculativePrerender === true),
|
|
702
|
+
isServerComponentError: rscErrorTracker.isCapturedError,
|
|
836
703
|
waitForAllReady: shouldWaitForAllReady,
|
|
837
704
|
isStaticGeneration: options.isPrerender === true,
|
|
838
705
|
isForceStatic: options.isForceStatic,
|
|
@@ -871,7 +738,9 @@ async function renderAppPageLifecycleImpl(options, renderSpan) {
|
|
|
871
738
|
if (htmlRender.response) {
|
|
872
739
|
if (shellSpecialError && options.isProduction && options.isPrerender !== true && resolveEarlyResponseCacheControl(options) === null) return finalizeShellSpecialErrorResponse(htmlRender.response, shellSpecialError);
|
|
873
740
|
if (shellSpecialError && prerenderedSpecialError) return finalizePrerenderedShellSpecialErrorResponse(htmlRender.response, shellSpecialError, prerenderedSpecialError);
|
|
874
|
-
|
|
741
|
+
const response = applyIneligibleRouteCachePolicy(htmlRender.response, options);
|
|
742
|
+
if (shellSpecialError) markPrerenderedDynamicShellSpecialError(response, shellSpecialError);
|
|
743
|
+
return response;
|
|
875
744
|
}
|
|
876
745
|
let htmlStream = htmlRender.htmlStream;
|
|
877
746
|
if (!htmlStream) throw new Error("[vinext] Expected an HTML stream when no fallback response was returned");
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AppPageSpecialError } from "./app-page-execution.js";
|
|
2
|
-
import { AppLayoutParamAccessTracker } from "./app-layout-param-observation.js";
|
|
3
2
|
//#region src/server/app-page-request.d.ts
|
|
4
3
|
type AppPageParams = Record<string, string | string[]>;
|
|
5
4
|
type GenerateStaticParams = (args: {
|
|
@@ -120,7 +119,7 @@ type ResolveAppPageInterceptionRerenderTargetResult<TRoute, TInterceptOpts> = {
|
|
|
120
119
|
type ResolveAppPageActionRerenderTargetOptions<TRoute, TPage, TInterceptOpts> = ResolveAppPageInterceptionRerenderTargetOptions<TRoute, TPage, TInterceptOpts>;
|
|
121
120
|
type ResolveAppPageActionRerenderTargetResult<TRoute, TInterceptOpts> = ResolveAppPageInterceptionRerenderTargetResult<TRoute, TInterceptOpts>;
|
|
122
121
|
type ResolveAppPageInterceptOptions<TRoute, TPage, TInterceptOpts, TElement> = {
|
|
123
|
-
buildPageElement: (route: TRoute, params: AppPageParams, interceptOpts: TInterceptOpts | undefined, searchParams: URLSearchParams,
|
|
122
|
+
buildPageElement: (route: TRoute, params: AppPageParams, interceptOpts: TInterceptOpts | undefined, searchParams: URLSearchParams, buildOptions?: {
|
|
124
123
|
observeMetadataSearchParamsAccess?: boolean;
|
|
125
124
|
observePageSearchParamsAccess?: boolean;
|
|
126
125
|
}) => Promise<TElement>;
|
|
@@ -130,7 +129,6 @@ type ResolveAppPageInterceptOptions<TRoute, TPage, TInterceptOpts, TElement> = {
|
|
|
130
129
|
getRouteParamNames: (route: TRoute) => readonly string[];
|
|
131
130
|
getSourceRoute: (sourceRouteIndex: number) => Awaitable<TRoute | undefined>;
|
|
132
131
|
isRscRequest: boolean;
|
|
133
|
-
layoutParamAccess?: AppLayoutParamAccessTracker;
|
|
134
132
|
resolveNavigationParams: (route: TRoute, params: AppPageParams, pathname: string, interceptOpts: TInterceptOpts) => AppPageParams;
|
|
135
133
|
renderInterceptResponse: (route: TRoute, element: TElement) => Promise<Response> | Response;
|
|
136
134
|
resolveSearchParams?: (route: TRoute, searchParams: URLSearchParams) => Awaitable<URLSearchParams>;
|
|
@@ -353,7 +353,7 @@ async function resolveAppPageIntercept(options) {
|
|
|
353
353
|
pathname: options.cleanPathname,
|
|
354
354
|
searchParams: renderSearchParams
|
|
355
355
|
});
|
|
356
|
-
const interceptElement = await options.buildPageElement(renderRoute, renderParams, interceptOpts, renderSearchParams
|
|
356
|
+
const interceptElement = await options.buildPageElement(renderRoute, renderParams, interceptOpts, renderSearchParams);
|
|
357
357
|
return {
|
|
358
358
|
interceptOpts: void 0,
|
|
359
359
|
response: await options.renderInterceptResponse(renderRoute, interceptElement)
|