vinext 0.0.50 → 0.0.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/google-fonts/fallback-metrics-data.js +14031 -0
- package/dist/build/google-fonts/fallback-metrics-data.js.map +1 -0
- package/dist/build/google-fonts/fallback-metrics.d.ts +13 -0
- package/dist/build/google-fonts/fallback-metrics.js +46 -0
- package/dist/build/google-fonts/fallback-metrics.js.map +1 -0
- package/dist/build/precompress.d.ts +13 -2
- package/dist/build/precompress.js +12 -3
- package/dist/build/precompress.js.map +1 -1
- package/dist/build/prerender.d.ts +1 -1
- package/dist/build/prerender.js +44 -14
- package/dist/build/prerender.js.map +1 -1
- package/dist/build/report.d.ts +5 -4
- package/dist/build/report.js +196 -348
- package/dist/build/report.js.map +1 -1
- package/dist/check.js +1 -0
- package/dist/check.js.map +1 -1
- package/dist/cli.js +60 -3
- package/dist/cli.js.map +1 -1
- package/dist/client/window-next.d.ts +3 -1
- package/dist/client/window-next.js.map +1 -1
- package/dist/config/dotenv.d.ts +11 -1
- package/dist/config/dotenv.js.map +1 -1
- package/dist/config/next-config.d.ts +87 -3
- package/dist/config/next-config.js +222 -6
- package/dist/config/next-config.js.map +1 -1
- package/dist/config/tsconfig-paths.d.ts +13 -0
- package/dist/config/tsconfig-paths.js +117 -0
- package/dist/config/tsconfig-paths.js.map +1 -0
- package/dist/deploy.js +3 -2
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.d.ts +2 -2
- package/dist/entries/app-browser-entry.js +26 -1
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.d.ts +19 -1
- package/dist/entries/app-rsc-entry.js +38 -12
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-rsc-manifest.d.ts +9 -0
- package/dist/entries/app-rsc-manifest.js +4 -1
- package/dist/entries/app-rsc-manifest.js.map +1 -1
- package/dist/entries/pages-client-entry.js +3 -5
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-server-entry.js +19 -1
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/index.js +130 -37
- package/dist/index.js.map +1 -1
- package/dist/plugins/client-reference-dedup.d.ts +15 -2
- package/dist/plugins/client-reference-dedup.js +138 -16
- package/dist/plugins/client-reference-dedup.js.map +1 -1
- package/dist/plugins/fonts.d.ts +2 -2
- package/dist/plugins/fonts.js +15 -6
- package/dist/plugins/fonts.js.map +1 -1
- package/dist/plugins/sass.d.ts +34 -0
- package/dist/plugins/sass.js +22 -0
- package/dist/plugins/sass.js.map +1 -0
- package/dist/routing/app-route-graph.d.ts +31 -2
- package/dist/routing/app-route-graph.js +82 -10
- package/dist/routing/app-route-graph.js.map +1 -1
- package/dist/routing/route-pattern.d.ts +56 -1
- package/dist/routing/route-pattern.js +60 -1
- package/dist/routing/route-pattern.js.map +1 -1
- package/dist/server/app-browser-action-result.d.ts +27 -2
- package/dist/server/app-browser-action-result.js +63 -2
- package/dist/server/app-browser-action-result.js.map +1 -1
- package/dist/server/app-browser-entry.js +262 -108
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-browser-hydration.d.ts +13 -1
- package/dist/server/app-browser-hydration.js +9 -1
- package/dist/server/app-browser-hydration.js.map +1 -1
- package/dist/server/app-browser-navigation-controller.d.ts +14 -1
- package/dist/server/app-browser-navigation-controller.js +28 -9
- package/dist/server/app-browser-navigation-controller.js.map +1 -1
- package/dist/server/app-browser-popstate.d.ts +16 -0
- package/dist/server/app-browser-popstate.js +17 -0
- package/dist/server/app-browser-popstate.js.map +1 -0
- package/dist/server/app-browser-rsc-redirect.d.ts +28 -0
- package/dist/server/app-browser-rsc-redirect.js +37 -0
- package/dist/server/app-browser-rsc-redirect.js.map +1 -0
- package/dist/server/app-browser-state.d.ts +11 -7
- package/dist/server/app-browser-state.js +45 -27
- package/dist/server/app-browser-state.js.map +1 -1
- package/dist/server/app-browser-stream.d.ts +5 -4
- package/dist/server/app-browser-stream.js +5 -6
- package/dist/server/app-browser-stream.js.map +1 -1
- package/dist/server/app-browser-visible-commit.d.ts +5 -0
- package/dist/server/app-browser-visible-commit.js +38 -5
- package/dist/server/app-browser-visible-commit.js.map +1 -1
- package/dist/server/app-elements-wire.d.ts +38 -6
- package/dist/server/app-elements-wire.js +106 -6
- 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 +10 -1
- package/dist/server/app-fallback-renderer.js +37 -1
- package/dist/server/app-fallback-renderer.js.map +1 -1
- package/dist/server/app-history-state.d.ts +26 -0
- package/dist/server/app-history-state.js +53 -0
- package/dist/server/app-history-state.js.map +1 -0
- package/dist/server/app-page-boundary-render.d.ts +10 -1
- package/dist/server/app-page-boundary-render.js +13 -6
- package/dist/server/app-page-boundary-render.js.map +1 -1
- package/dist/server/app-page-boundary.js +3 -2
- package/dist/server/app-page-boundary.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +13 -0
- package/dist/server/app-page-cache.js +25 -8
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +5 -0
- package/dist/server/app-page-dispatch.js +68 -11
- package/dist/server/app-page-dispatch.js.map +1 -1
- package/dist/server/app-page-element-builder.d.ts +7 -0
- package/dist/server/app-page-element-builder.js +32 -4
- package/dist/server/app-page-element-builder.js.map +1 -1
- package/dist/server/app-page-execution.js +2 -3
- package/dist/server/app-page-execution.js.map +1 -1
- package/dist/server/app-page-head.d.ts +7 -0
- package/dist/server/app-page-head.js +2 -1
- package/dist/server/app-page-head.js.map +1 -1
- package/dist/server/app-page-probe.d.ts +23 -1
- package/dist/server/app-page-probe.js +29 -1
- package/dist/server/app-page-probe.js.map +1 -1
- package/dist/server/app-page-render-observation.d.ts +35 -0
- package/dist/server/app-page-render-observation.js +68 -0
- package/dist/server/app-page-render-observation.js.map +1 -0
- package/dist/server/app-page-render.d.ts +5 -1
- package/dist/server/app-page-render.js +79 -3
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-request.d.ts +1 -0
- package/dist/server/app-page-request.js.map +1 -1
- package/dist/server/app-page-response.js +3 -2
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +3 -1
- package/dist/server/app-page-route-wiring.js +42 -14
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-stream.d.ts +2 -0
- package/dist/server/app-page-stream.js +1 -0
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-router-entry.js +1 -13
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +19 -1
- package/dist/server/app-rsc-cache-busting.js +36 -1
- package/dist/server/app-rsc-cache-busting.js.map +1 -1
- package/dist/server/app-rsc-embedded-chunks.d.ts +9 -0
- package/dist/server/app-rsc-embedded-chunks.js +34 -0
- package/dist/server/app-rsc-embedded-chunks.js.map +1 -0
- package/dist/server/app-rsc-errors.d.ts +4 -1
- package/dist/server/app-rsc-errors.js +1 -1
- package/dist/server/app-rsc-errors.js.map +1 -1
- package/dist/server/app-rsc-handler.d.ts +12 -4
- package/dist/server/app-rsc-handler.js +6 -1
- package/dist/server/app-rsc-handler.js.map +1 -1
- package/dist/server/app-rsc-route-matching.d.ts +23 -0
- package/dist/server/app-rsc-route-matching.js +45 -23
- package/dist/server/app-rsc-route-matching.js.map +1 -1
- package/dist/server/app-server-action-execution.d.ts +35 -3
- package/dist/server/app-server-action-execution.js +87 -33
- package/dist/server/app-server-action-execution.js.map +1 -1
- package/dist/server/app-ssr-entry.d.ts +1 -0
- package/dist/server/app-ssr-entry.js +37 -13
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-error-meta.d.ts +14 -0
- package/dist/server/app-ssr-error-meta.js +50 -0
- package/dist/server/app-ssr-error-meta.js.map +1 -0
- package/dist/server/app-ssr-stream.d.ts +1 -1
- package/dist/server/app-ssr-stream.js +9 -12
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/artifact-compatibility.d.ts +12 -2
- package/dist/server/artifact-compatibility.js +12 -8
- package/dist/server/artifact-compatibility.js.map +1 -1
- package/dist/server/cache-proof.d.ts +124 -5
- package/dist/server/cache-proof.js +416 -18
- package/dist/server/cache-proof.js.map +1 -1
- package/dist/server/dev-lockfile.d.ts +110 -0
- package/dist/server/dev-lockfile.js +180 -0
- package/dist/server/dev-lockfile.js.map +1 -0
- package/dist/server/dev-server.js +15 -5
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/file-based-metadata.d.ts +13 -0
- package/dist/server/file-based-metadata.js +49 -2
- package/dist/server/file-based-metadata.js.map +1 -1
- package/dist/server/headers.d.ts +3 -1
- package/dist/server/headers.js +5 -2
- package/dist/server/headers.js.map +1 -1
- package/dist/server/html.js +1 -1
- package/dist/server/html.js.map +1 -1
- package/dist/server/http-error-responses.d.ts +10 -0
- package/dist/server/http-error-responses.js +11 -1
- package/dist/server/http-error-responses.js.map +1 -1
- package/dist/server/isr-cache.d.ts +2 -1
- package/dist/server/isr-cache.js +4 -2
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/metadata-route-response.js +22 -5
- package/dist/server/metadata-route-response.js.map +1 -1
- package/dist/server/metadata-routes.js +27 -8
- package/dist/server/metadata-routes.js.map +1 -1
- package/dist/server/middleware-runtime.js +1 -0
- package/dist/server/middleware-runtime.js.map +1 -1
- package/dist/server/middleware.d.ts +12 -0
- package/dist/server/middleware.js +12 -0
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/navigation-planner.d.ts +19 -5
- package/dist/server/navigation-planner.js +278 -17
- package/dist/server/navigation-planner.js.map +1 -1
- package/dist/server/navigation-trace.d.ts +8 -1
- package/dist/server/navigation-trace.js +7 -0
- package/dist/server/navigation-trace.js.map +1 -1
- package/dist/server/normalize-path.d.ts +2 -1
- package/dist/server/normalize-path.js +4 -1
- package/dist/server/normalize-path.js.map +1 -1
- package/dist/server/pages-api-route.js +1 -0
- package/dist/server/pages-api-route.js.map +1 -1
- package/dist/server/pages-page-data.d.ts +3 -2
- package/dist/server/pages-page-data.js +22 -3
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-response.js +1 -1
- package/dist/server/prod-server.d.ts +28 -1
- package/dist/server/prod-server.js +62 -9
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/server-action-not-found.d.ts +16 -3
- package/dist/server/server-action-not-found.js +19 -1
- package/dist/server/server-action-not-found.js.map +1 -1
- package/dist/server/server-globals.d.ts +5 -0
- package/dist/server/server-globals.js +37 -0
- package/dist/server/server-globals.js.map +1 -0
- package/dist/server/static-file-cache.js +1 -1
- package/dist/server/static-file-cache.js.map +1 -1
- package/dist/shims/cache-runtime.d.ts +19 -2
- package/dist/shims/cache-runtime.js +67 -11
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/cache.d.ts +5 -18
- package/dist/shims/cache.js +2 -0
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/error-boundary.js +6 -8
- package/dist/shims/error-boundary.js.map +1 -1
- package/dist/shims/error.d.ts +18 -1
- package/dist/shims/error.js +56 -1
- package/dist/shims/error.js.map +1 -1
- package/dist/shims/fetch-cache.d.ts +4 -1
- package/dist/shims/fetch-cache.js +40 -5
- package/dist/shims/fetch-cache.js.map +1 -1
- package/dist/shims/font-google-base.d.ts +22 -8
- package/dist/shims/font-google-base.js +41 -71
- package/dist/shims/font-google-base.js.map +1 -1
- package/dist/shims/font-local.d.ts +3 -20
- package/dist/shims/font-local.js +23 -75
- package/dist/shims/font-local.js.map +1 -1
- package/dist/shims/font-utils.d.ts +51 -0
- package/dist/shims/font-utils.js +97 -0
- package/dist/shims/font-utils.js.map +1 -0
- package/dist/shims/hash-scroll.d.ts +7 -0
- package/dist/shims/hash-scroll.js +30 -0
- package/dist/shims/hash-scroll.js.map +1 -0
- package/dist/shims/headers.d.ts +8 -11
- package/dist/shims/headers.js +22 -2
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/image.d.ts +1 -0
- package/dist/shims/image.js +144 -78
- package/dist/shims/image.js.map +1 -1
- package/dist/shims/internal/app-router-context.d.ts +6 -6
- package/dist/shims/internal/app-router-context.js +17 -6
- package/dist/shims/internal/app-router-context.js.map +1 -1
- package/dist/shims/link-prefetch.d.ts +9 -1
- package/dist/shims/link-prefetch.js +11 -6
- package/dist/shims/link-prefetch.js.map +1 -1
- package/dist/shims/link.d.ts +12 -2
- package/dist/shims/link.js +78 -32
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +16 -30
- package/dist/shims/metadata.js +87 -28
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation.d.ts +158 -17
- package/dist/shims/navigation.js +324 -74
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/navigation.react-server.d.ts +3 -2
- package/dist/shims/navigation.react-server.js +5 -2
- package/dist/shims/navigation.react-server.js.map +1 -1
- package/dist/shims/pages-router-runtime.d.ts +7 -0
- package/dist/shims/pages-router-runtime.js +16 -0
- package/dist/shims/pages-router-runtime.js.map +1 -0
- package/dist/shims/router.d.ts +32 -6
- package/dist/shims/router.js +197 -242
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script.js +110 -32
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server.js +2 -1
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/slot.d.ts +1 -0
- package/dist/shims/slot.js +41 -1
- package/dist/shims/slot.js.map +1 -1
- package/dist/shims/unified-request-context.js +2 -0
- package/dist/shims/unified-request-context.js.map +1 -1
- package/dist/shims/unrecognized-action-error.d.ts +35 -0
- package/dist/shims/unrecognized-action-error.js +41 -0
- package/dist/shims/unrecognized-action-error.js.map +1 -0
- package/dist/shims/url-utils.d.ts +21 -1
- package/dist/shims/url-utils.js +67 -3
- package/dist/shims/url-utils.js.map +1 -1
- package/dist/utils/asset-prefix.d.ts +69 -0
- package/dist/utils/asset-prefix.js +91 -0
- package/dist/utils/asset-prefix.js.map +1 -0
- package/dist/utils/base-path.d.ts +7 -1
- package/dist/utils/base-path.js +10 -1
- package/dist/utils/base-path.js.map +1 -1
- package/dist/utils/navigation-signal.d.ts +1 -2
- package/dist/utils/navigation-signal.js +1 -1
- package/dist/utils/navigation-signal.js.map +1 -1
- package/dist/utils/sorted-array.d.ts +9 -0
- package/dist/utils/sorted-array.js +22 -0
- package/dist/utils/sorted-array.js.map +1 -0
- package/package.json +3 -3
|
@@ -129,13 +129,15 @@ async function renderAppPageHttpAccessFallback(options) {
|
|
|
129
129
|
});
|
|
130
130
|
if (!boundaryComponent) return null;
|
|
131
131
|
const layoutModules = options.layoutModules ?? options.route?.layouts ?? options.rootLayouts;
|
|
132
|
+
const pathname = new URL(options.requestUrl).pathname;
|
|
132
133
|
const routeSegments = resolveHttpAccessFallbackHeadRouteSegments(options.route, layoutModules);
|
|
133
134
|
const { metadata, viewport } = await resolveAppPageHead({
|
|
135
|
+
basePath: options.basePath ?? "",
|
|
134
136
|
layoutModules,
|
|
135
137
|
layoutTreePositions: resolveHttpAccessFallbackHeadLayoutTreePositions(options.route, layoutModules),
|
|
136
138
|
metadataRoutes: options.metadataRoutes,
|
|
137
139
|
params: options.matchedParams,
|
|
138
|
-
routePath: options.route?.pattern ??
|
|
140
|
+
routePath: options.route?.pattern ?? pathname,
|
|
139
141
|
routeSegments
|
|
140
142
|
});
|
|
141
143
|
const headElements = [createElement("meta", {
|
|
@@ -148,12 +150,14 @@ async function renderAppPageHttpAccessFallback(options) {
|
|
|
148
150
|
})];
|
|
149
151
|
if (metadata) headElements.push(createElement(MetadataHead, {
|
|
150
152
|
key: "metadata",
|
|
151
|
-
metadata
|
|
153
|
+
metadata,
|
|
154
|
+
pathname
|
|
152
155
|
}));
|
|
153
156
|
headElements.push(createElement(ViewportHead, {
|
|
154
157
|
key: "viewport",
|
|
155
158
|
viewport
|
|
156
159
|
}));
|
|
160
|
+
const skipLayoutWrapping = options.skipLayoutWrapping ?? false;
|
|
157
161
|
const element = wrapRenderedBoundaryElement({
|
|
158
162
|
element: createElement(Fragment, null, ...headElements, createElement(boundaryComponent)),
|
|
159
163
|
globalErrorModule: options.globalErrorModule,
|
|
@@ -164,13 +168,14 @@ async function renderAppPageHttpAccessFallback(options) {
|
|
|
164
168
|
makeThenableParams: options.makeThenableParams,
|
|
165
169
|
matchedParams: options.matchedParams,
|
|
166
170
|
resolveChildSegments: options.resolveChildSegments,
|
|
167
|
-
routeSegments: options.route?.routeSegments
|
|
171
|
+
routeSegments: options.route?.routeSegments,
|
|
172
|
+
skipLayoutWrapping
|
|
168
173
|
});
|
|
169
174
|
return renderAppPageBoundaryElementResponse({
|
|
170
175
|
...options,
|
|
171
176
|
element,
|
|
172
|
-
layoutModules,
|
|
173
|
-
route: options.route,
|
|
177
|
+
layoutModules: skipLayoutWrapping ? [] : layoutModules,
|
|
178
|
+
route: skipLayoutWrapping ? null : options.route,
|
|
174
179
|
routePattern: options.route?.pattern,
|
|
175
180
|
status: options.statusCode
|
|
176
181
|
});
|
|
@@ -196,6 +201,7 @@ async function renderAppPageErrorBoundary(options) {
|
|
|
196
201
|
})];
|
|
197
202
|
if (!errorBoundary.isGlobalError) try {
|
|
198
203
|
const { metadata, viewport } = await resolveAppPageHead({
|
|
204
|
+
basePath: options.basePath ?? "",
|
|
199
205
|
fallbackOnFileMetadataError: true,
|
|
200
206
|
layoutModules,
|
|
201
207
|
layoutTreePositions: options.route?.layoutTreePositions,
|
|
@@ -206,7 +212,8 @@ async function renderAppPageErrorBoundary(options) {
|
|
|
206
212
|
});
|
|
207
213
|
if (metadata) headElements.push(createElement(MetadataHead, {
|
|
208
214
|
key: "metadata",
|
|
209
|
-
metadata
|
|
215
|
+
metadata,
|
|
216
|
+
pathname
|
|
210
217
|
}));
|
|
211
218
|
headElements.push(createElement(ViewportHead, {
|
|
212
219
|
key: "viewport",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-page-boundary-render.js","names":[],"sources":["../../src/server/app-page-boundary-render.ts"],"sourcesContent":["import { Fragment, createElement, type ComponentType, type ReactNode } from \"react\";\nimport { buildClientHookErrorMessage } from \"vinext/shims/client-hook-error\";\nimport { ErrorBoundary } from \"vinext/shims/error-boundary\";\nimport { LayoutSegmentProvider } from \"vinext/shims/layout-segment-context\";\nimport { MetadataHead, ViewportHead } from \"vinext/shims/metadata\";\nimport type { AppPageFontPreload } from \"./app-page-execution.js\";\nimport type { AppPageMiddlewareContext } from \"./app-page-response.js\";\nimport type { MetadataFileRoute } from \"./metadata-routes.js\";\nimport { resolveAppPageHead } from \"./app-page-head.js\";\nimport {\n renderAppPageBoundaryResponse,\n resolveAppPageErrorBoundary,\n resolveAppPageHttpAccessBoundaryComponent,\n wrapAppPageBoundaryElement,\n type AppPageParams,\n} from \"./app-page-boundary.js\";\nimport {\n createAppPageFontData,\n renderAppPageHtmlResponse,\n type AppPageSsrHandler,\n} from \"./app-page-stream.js\";\nimport { AppElementsWire, type AppElements } from \"./app-elements.js\";\nimport { createAppPageLayoutEntries } from \"./app-page-route-wiring.js\";\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\ntype AppPageComponent = ComponentType<any>;\ntype AppPageModule = Record<string, unknown> & {\n default?: AppPageComponent | null | undefined;\n};\ntype AppPageBoundaryOnError = (\n error: unknown,\n requestInfo: unknown,\n errorContext: unknown,\n) => unknown;\n\ntype AppPageBoundaryRscPayloadOptions<TModule extends AppPageModule = AppPageModule> = {\n element: ReactNode;\n layoutModules: readonly (TModule | null | undefined)[];\n pathname: string;\n route?: AppPageBoundaryRoute<TModule> | null;\n};\n\ntype AppPageBoundaryLayoutEntry = {\n id: string;\n treePath: string;\n};\n\nexport type AppPageBoundaryRoute<TModule extends AppPageModule = AppPageModule> = {\n error?: TModule | null;\n errorPaths?: readonly TModule[] | null;\n errors?: readonly (TModule | null | undefined)[] | null;\n forbidden?: TModule | null;\n layoutTreePositions?: readonly number[] | null;\n layouts?: readonly (TModule | null | undefined)[];\n notFound?: TModule | null;\n params?: AppPageParams;\n pattern?: string;\n routeSegments?: readonly string[];\n unauthorized?: TModule | null;\n};\n\ntype AppPageBoundaryRenderCommonOptions<TModule extends AppPageModule = AppPageModule> = {\n buildFontLinkHeader: (preloads: readonly AppPageFontPreload[] | null | undefined) => string;\n clearRequestContext: () => void;\n createRscOnErrorHandler: (pathname: string, routePath: string) => AppPageBoundaryOnError;\n getFontLinks: () => string[];\n getFontPreloads: () => AppPageFontPreload[];\n getFontStyles: () => string[];\n getNavigationContext: () => unknown;\n globalErrorModule?: TModule | null;\n isRscRequest: boolean;\n loadSsrHandler: () => Promise<AppPageSsrHandler>;\n makeThenableParams: (params: AppPageParams) => unknown;\n middlewareContext: AppPageMiddlewareContext;\n metadataRoutes: MetadataFileRoute[];\n renderToReadableStream: (\n element: ReactNode | AppElements,\n options: { onError: AppPageBoundaryOnError },\n ) => ReadableStream<Uint8Array>;\n requestUrl: string;\n resolveChildSegments: (\n routeSegments: readonly string[],\n treePosition: number,\n params: AppPageParams,\n ) => string[];\n rootLayouts: readonly (TModule | null | undefined)[];\n scriptNonce?: string;\n};\n\ntype RenderAppPageHttpAccessFallbackOptions<TModule extends AppPageModule = AppPageModule> = {\n boundaryComponent?: AppPageComponent | null;\n layoutModules?: readonly (TModule | null | undefined)[] | null;\n matchedParams: AppPageParams;\n rootForbiddenModule?: TModule | null;\n rootNotFoundModule?: TModule | null;\n rootUnauthorizedModule?: TModule | null;\n route?: AppPageBoundaryRoute<TModule> | null;\n statusCode: number;\n} & AppPageBoundaryRenderCommonOptions<TModule>;\n\ntype RenderAppPageErrorBoundaryOptions<TModule extends AppPageModule = AppPageModule> = {\n error: unknown;\n matchedParams?: AppPageParams | null;\n route?: AppPageBoundaryRoute<TModule> | null;\n sanitizeErrorForClient: (error: Error) => Error;\n} & AppPageBoundaryRenderCommonOptions<TModule>;\n\nfunction getDefaultExport<TModule extends AppPageModule>(\n module: TModule | null | undefined,\n): AppPageComponent | null {\n return module?.default ?? null;\n}\n\nfunction wrapRenderedBoundaryElement<TModule extends AppPageModule>(\n options: Pick<\n AppPageBoundaryRenderCommonOptions<TModule>,\n \"globalErrorModule\" | \"isRscRequest\" | \"makeThenableParams\" | \"resolveChildSegments\"\n > & {\n element: ReactNode;\n includeGlobalErrorBoundary: boolean;\n layoutModules: readonly (TModule | null | undefined)[];\n layoutTreePositions?: readonly number[] | null;\n matchedParams: AppPageParams;\n routeSegments?: readonly string[];\n skipLayoutWrapping?: boolean;\n },\n): ReactNode {\n return wrapAppPageBoundaryElement({\n element: options.element,\n getDefaultExport,\n globalErrorComponent: getDefaultExport(options.globalErrorModule),\n includeGlobalErrorBoundary: options.includeGlobalErrorBoundary,\n isRscRequest: options.isRscRequest,\n layoutModules: options.layoutModules,\n layoutTreePositions: options.layoutTreePositions,\n makeThenableParams: options.makeThenableParams,\n matchedParams: options.matchedParams,\n renderErrorBoundary(GlobalErrorComponent, children) {\n return createElement(ErrorBoundary, {\n fallback: GlobalErrorComponent,\n // oxlint-disable-next-line react/no-children-prop\n children,\n });\n },\n renderLayout(LayoutComponent, children, asyncParams) {\n return createElement(LayoutComponent as AppPageComponent, {\n // oxlint-disable-next-line react/no-children-prop\n children,\n params: asyncParams,\n });\n },\n renderLayoutSegmentProvider(segmentMap, children) {\n return createElement(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n LayoutSegmentProvider as ComponentType<any>,\n { segmentMap },\n children,\n );\n },\n resolveChildSegments: options.resolveChildSegments,\n routeSegments: options.routeSegments ?? [],\n skipLayoutWrapping: options.skipLayoutWrapping,\n });\n}\n\nfunction createAppPageBoundaryLayoutEntries<TModule extends AppPageModule>(\n route: AppPageBoundaryRoute<TModule> | null | undefined,\n layoutModules: readonly (TModule | null | undefined)[],\n): readonly AppPageBoundaryLayoutEntry[] {\n if (!route || layoutModules.length === 0) return [];\n\n return createAppPageLayoutEntries({\n errors: route.errors,\n layoutTreePositions: route.layoutTreePositions,\n layouts: layoutModules,\n notFounds: null,\n routeSegments: route.routeSegments,\n });\n}\n\nfunction resolveHttpAccessFallbackHeadRouteSegments<TModule extends AppPageModule>(\n route: AppPageBoundaryRoute<TModule> | null | undefined,\n layoutModules: readonly (TModule | null | undefined)[],\n): readonly string[] | undefined {\n if (!route?.routeSegments) {\n return undefined;\n }\n\n if (!route.layouts || layoutModules.length >= route.layouts.length) {\n return route.routeSegments;\n }\n\n const lastIncludedLayoutIndex = layoutModules.length - 1;\n if (lastIncludedLayoutIndex < 0) {\n return [];\n }\n\n const segmentCount = route.layoutTreePositions?.[lastIncludedLayoutIndex] ?? 0;\n return route.routeSegments.slice(0, segmentCount);\n}\n\nfunction resolveHttpAccessFallbackHeadLayoutTreePositions<TModule extends AppPageModule>(\n route: AppPageBoundaryRoute<TModule> | null | undefined,\n layoutModules: readonly (TModule | null | undefined)[],\n): readonly number[] | null | undefined {\n if (!route?.layouts || layoutModules.length >= route.layouts.length) {\n return route?.layoutTreePositions;\n }\n\n return route.layoutTreePositions?.slice(0, layoutModules.length);\n}\n\nfunction createAppPageBoundaryRscPayload<TModule extends AppPageModule>(\n options: AppPageBoundaryRscPayloadOptions<TModule>,\n): AppElements {\n const routeId = AppElementsWire.encodeRouteId(options.pathname, null);\n const layoutEntries = createAppPageBoundaryLayoutEntries(options.route, options.layoutModules);\n\n return {\n ...AppElementsWire.createMetadataEntries({\n interceptionContext: null,\n layoutIds: layoutEntries.map((entry) => entry.id),\n rootLayoutTreePath: layoutEntries[0]?.treePath ?? null,\n routeId,\n }),\n [routeId]: options.element,\n };\n}\n\nasync function renderAppPageBoundaryElementResponse<TModule extends AppPageModule>(\n options: AppPageBoundaryRenderCommonOptions<TModule> & {\n element: ReactNode;\n layoutModules: readonly (TModule | null | undefined)[];\n route?: AppPageBoundaryRoute<TModule> | null;\n routePattern?: string;\n status: number;\n },\n): Promise<Response> {\n const pathname = new URL(options.requestUrl).pathname;\n const payload = createAppPageBoundaryRscPayload({\n element: options.element,\n layoutModules: options.layoutModules,\n pathname,\n route: options.route,\n });\n\n return renderAppPageBoundaryResponse({\n async createHtmlResponse(rscStream, responseStatus) {\n const fontData = createAppPageFontData({\n getLinks: options.getFontLinks,\n getPreloads: options.getFontPreloads,\n getStyles: options.getFontStyles,\n });\n const ssrHandler = await options.loadSsrHandler();\n return renderAppPageHtmlResponse({\n clearRequestContext: options.clearRequestContext,\n fontData,\n fontLinkHeader: options.buildFontLinkHeader(fontData.preloads),\n middlewareHeaders: options.middlewareContext.headers,\n navigationContext: options.getNavigationContext(),\n rscStream,\n scriptNonce: options.scriptNonce,\n ssrHandler,\n status: responseStatus,\n });\n },\n createRscOnErrorHandler() {\n return options.createRscOnErrorHandler(pathname, options.routePattern ?? pathname);\n },\n element: payload,\n isRscRequest: options.isRscRequest,\n middlewareHeaders: options.middlewareContext.headers,\n renderToReadableStream: options.renderToReadableStream,\n status: options.status,\n });\n}\n\nexport async function renderAppPageHttpAccessFallback<TModule extends AppPageModule>(\n options: RenderAppPageHttpAccessFallbackOptions<TModule>,\n): Promise<Response | null> {\n const boundaryComponent =\n options.boundaryComponent ??\n resolveAppPageHttpAccessBoundaryComponent({\n getDefaultExport,\n rootForbiddenModule: options.rootForbiddenModule,\n rootNotFoundModule: options.rootNotFoundModule,\n rootUnauthorizedModule: options.rootUnauthorizedModule,\n routeForbiddenModule: options.route?.forbidden,\n routeNotFoundModule: options.route?.notFound,\n routeUnauthorizedModule: options.route?.unauthorized,\n statusCode: options.statusCode,\n });\n if (!boundaryComponent) {\n return null;\n }\n\n const layoutModules = options.layoutModules ?? options.route?.layouts ?? options.rootLayouts;\n const routeSegments = resolveHttpAccessFallbackHeadRouteSegments(options.route, layoutModules);\n const { metadata, viewport } = await resolveAppPageHead({\n layoutModules,\n layoutTreePositions: resolveHttpAccessFallbackHeadLayoutTreePositions(\n options.route,\n layoutModules,\n ),\n metadataRoutes: options.metadataRoutes,\n params: options.matchedParams,\n routePath: options.route?.pattern ?? new URL(options.requestUrl).pathname,\n routeSegments,\n });\n\n const headElements: ReactNode[] = [\n createElement(\"meta\", { charSet: \"utf-8\", key: \"charset\" }),\n createElement(\"meta\", { content: \"noindex\", key: \"robots\", name: \"robots\" }),\n ];\n if (metadata) {\n headElements.push(createElement(MetadataHead, { key: \"metadata\", metadata }));\n }\n headElements.push(createElement(ViewportHead, { key: \"viewport\", viewport }));\n\n const element = wrapRenderedBoundaryElement({\n element: createElement(Fragment, null, ...headElements, createElement(boundaryComponent)),\n globalErrorModule: options.globalErrorModule,\n includeGlobalErrorBoundary: true,\n isRscRequest: options.isRscRequest,\n layoutModules,\n layoutTreePositions: options.route?.layoutTreePositions,\n makeThenableParams: options.makeThenableParams,\n matchedParams: options.matchedParams,\n resolveChildSegments: options.resolveChildSegments,\n routeSegments: options.route?.routeSegments,\n });\n\n return renderAppPageBoundaryElementResponse({\n ...options,\n element,\n layoutModules,\n route: options.route,\n routePattern: options.route?.pattern,\n status: options.statusCode,\n });\n}\n\nexport async function renderAppPageErrorBoundary<TModule extends AppPageModule>(\n options: RenderAppPageErrorBoundaryOptions<TModule>,\n): Promise<Response | null> {\n const errorBoundary = resolveAppPageErrorBoundary({\n getDefaultExport,\n errorModules: options.route?.errorPaths,\n globalErrorModule: options.globalErrorModule,\n layoutErrorModules: options.route?.errors,\n pageErrorModule: options.route?.error,\n });\n if (!errorBoundary.component) {\n return null;\n }\n\n const rawError =\n options.error instanceof Error ? options.error : new Error(String(options.error));\n rewriteClientHookError(rawError);\n const errorObject = options.sanitizeErrorForClient(rawError);\n const matchedParams = options.matchedParams ?? options.route?.params ?? {};\n const layoutModules = options.route?.layouts ?? options.rootLayouts;\n const pathname = new URL(options.requestUrl).pathname;\n\n const headElements: ReactNode[] = [createElement(\"meta\", { charSet: \"utf-8\", key: \"charset\" })];\n if (!errorBoundary.isGlobalError) {\n try {\n const { metadata, viewport } = await resolveAppPageHead({\n fallbackOnFileMetadataError: true,\n layoutModules,\n layoutTreePositions: options.route?.layoutTreePositions,\n metadataRoutes: options.metadataRoutes,\n params: matchedParams,\n routePath: options.route?.pattern ?? pathname,\n routeSegments: options.route?.routeSegments,\n });\n if (metadata) {\n headElements.push(createElement(MetadataHead, { key: \"metadata\", metadata }));\n }\n headElements.push(createElement(ViewportHead, { key: \"viewport\", viewport }));\n } catch (error) {\n console.error(\n `[vinext] App page error boundary head resolution failed for ${options.route?.pattern ?? pathname}:`,\n error,\n );\n }\n }\n\n const element = wrapRenderedBoundaryElement({\n element: createElement(\n Fragment,\n null,\n ...headElements,\n createElement(errorBoundary.component, {\n error: errorObject,\n }),\n ),\n globalErrorModule: options.globalErrorModule,\n includeGlobalErrorBoundary: !errorBoundary.isGlobalError,\n isRscRequest: options.isRscRequest,\n layoutModules,\n layoutTreePositions: options.route?.layoutTreePositions,\n makeThenableParams: options.makeThenableParams,\n matchedParams,\n resolveChildSegments: options.resolveChildSegments,\n routeSegments: options.route?.routeSegments,\n skipLayoutWrapping: errorBoundary.isGlobalError,\n });\n\n return renderAppPageBoundaryElementResponse({\n ...options,\n element,\n layoutModules,\n route: options.route,\n routePattern: options.route?.pattern,\n status: 200,\n });\n}\n\n// React client-only hooks that are absent from the `react-server` export\n// condition. When called in a Server Component they produce a TypeError like\n// \"useState is not a function\". Rewrite into an actionable message matching\n// the format used by the next/navigation shims (see client-hook-error.ts).\nconst _clientHookPattern =\n /\\b(useState|useEffect|useReducer|useRef|useContext|useLayoutEffect|useInsertionEffect|useSyncExternalStore|useTransition|useImperativeHandle|useDeferredValue|useActionState|useOptimistic|useEffectEvent)\\b.*is not a function/;\n\nfunction rewriteClientHookError(error: Error): void {\n const match = error.message.match(_clientHookPattern);\n if (match) {\n error.message = buildClientHookErrorMessage(`${match[1]}()`);\n }\n}\n"],"mappings":";;;;;;;;;;;;AA2GA,SAAS,iBACP,QACyB;CACzB,OAAO,QAAQ,WAAW;;AAG5B,SAAS,4BACP,SAYW;CACX,OAAO,2BAA2B;EAChC,SAAS,QAAQ;EACjB;EACA,sBAAsB,iBAAiB,QAAQ,kBAAkB;E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AAc,QAAQ,OAAO;EAC7B,QAAQ;EACT,CAAC;;AAOJ,MAAM,qBACJ;AAEF,SAAS,uBAAuB,OAAoB;CAClD,MAAM,QAAQ,MAAM,QAAQ,MAAM,mBAAmB;CACrD,IAAI,OACF,MAAM,UAAU,4BAA4B,GAAG,MAAM,GAAG,IAAI"}
|
|
1
|
+
{"version":3,"file":"app-page-boundary-render.js","names":[],"sources":["../../src/server/app-page-boundary-render.ts"],"sourcesContent":["import { Fragment, createElement, type ComponentType, type ReactNode } from \"react\";\nimport { buildClientHookErrorMessage } from \"vinext/shims/client-hook-error\";\nimport { ErrorBoundary } from \"vinext/shims/error-boundary\";\nimport { LayoutSegmentProvider } from \"vinext/shims/layout-segment-context\";\nimport { MetadataHead, ViewportHead } from \"vinext/shims/metadata\";\nimport type { AppPageFontPreload } from \"./app-page-execution.js\";\nimport type { AppPageMiddlewareContext } from \"./app-page-response.js\";\nimport type { MetadataFileRoute } from \"./metadata-routes.js\";\nimport { resolveAppPageHead } from \"./app-page-head.js\";\nimport {\n renderAppPageBoundaryResponse,\n resolveAppPageErrorBoundary,\n resolveAppPageHttpAccessBoundaryComponent,\n wrapAppPageBoundaryElement,\n type AppPageParams,\n} from \"./app-page-boundary.js\";\nimport {\n createAppPageFontData,\n renderAppPageHtmlResponse,\n type AppPageSsrHandler,\n} from \"./app-page-stream.js\";\nimport { AppElementsWire, type AppElements } from \"./app-elements.js\";\nimport { createAppPageLayoutEntries } from \"./app-page-route-wiring.js\";\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\ntype AppPageComponent = ComponentType<any>;\ntype AppPageModule = Record<string, unknown> & {\n default?: AppPageComponent | null | undefined;\n};\ntype AppPageBoundaryOnError = (\n error: unknown,\n requestInfo: unknown,\n errorContext: unknown,\n) => unknown;\n\ntype AppPageBoundaryRscPayloadOptions<TModule extends AppPageModule = AppPageModule> = {\n element: ReactNode;\n layoutModules: readonly (TModule | null | undefined)[];\n pathname: string;\n route?: AppPageBoundaryRoute<TModule> | null;\n};\n\ntype AppPageBoundaryLayoutEntry = {\n id: string;\n treePath: string;\n};\n\nexport type AppPageBoundaryRoute<TModule extends AppPageModule = AppPageModule> = {\n error?: TModule | null;\n errorPaths?: readonly TModule[] | null;\n errors?: readonly (TModule | null | undefined)[] | null;\n forbidden?: TModule | null;\n layoutTreePositions?: readonly number[] | null;\n layouts?: readonly (TModule | null | undefined)[];\n notFound?: TModule | null;\n params?: AppPageParams;\n pattern?: string;\n routeSegments?: readonly string[];\n unauthorized?: TModule | null;\n};\n\ntype AppPageBoundaryRenderCommonOptions<TModule extends AppPageModule = AppPageModule> = {\n buildFontLinkHeader: (preloads: readonly AppPageFontPreload[] | null | undefined) => string;\n clearRequestContext: () => void;\n createRscOnErrorHandler: (pathname: string, routePath: string) => AppPageBoundaryOnError;\n getFontLinks: () => string[];\n getFontPreloads: () => AppPageFontPreload[];\n getFontStyles: () => string[];\n getNavigationContext: () => unknown;\n globalErrorModule?: TModule | null;\n isRscRequest: boolean;\n loadSsrHandler: () => Promise<AppPageSsrHandler>;\n makeThenableParams: (params: AppPageParams) => unknown;\n middlewareContext: AppPageMiddlewareContext;\n metadataRoutes: MetadataFileRoute[];\n /** Configured next.config `basePath`, threaded into file-based metadata href emission. */\n basePath?: string;\n renderToReadableStream: (\n element: ReactNode | AppElements,\n options: { onError: AppPageBoundaryOnError },\n ) => ReadableStream<Uint8Array>;\n requestUrl: string;\n resolveChildSegments: (\n routeSegments: readonly string[],\n treePosition: number,\n params: AppPageParams,\n ) => string[];\n rootLayouts: readonly (TModule | null | undefined)[];\n scriptNonce?: string;\n};\n\ntype RenderAppPageHttpAccessFallbackOptions<TModule extends AppPageModule = AppPageModule> = {\n boundaryComponent?: AppPageComponent | null;\n layoutModules?: readonly (TModule | null | undefined)[] | null;\n matchedParams: AppPageParams;\n rootForbiddenModule?: TModule | null;\n rootNotFoundModule?: TModule | null;\n rootUnauthorizedModule?: TModule | null;\n route?: AppPageBoundaryRoute<TModule> | null;\n /**\n * When true, the resolved boundary is rendered without wrapping it in the\n * route's layouts. Used by `global-not-found.tsx`, which provides its own\n * `<html>`/`<body>` and intentionally replaces the root layout.\n * Mirrors Next.js's `createNotFoundLoaderTree` behavior for `hasGlobalNotFound`.\n * @see https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/app-render.tsx#L495-L520\n */\n skipLayoutWrapping?: boolean;\n statusCode: number;\n} & AppPageBoundaryRenderCommonOptions<TModule>;\n\ntype RenderAppPageErrorBoundaryOptions<TModule extends AppPageModule = AppPageModule> = {\n error: unknown;\n matchedParams?: AppPageParams | null;\n route?: AppPageBoundaryRoute<TModule> | null;\n sanitizeErrorForClient: (error: Error) => Error;\n} & AppPageBoundaryRenderCommonOptions<TModule>;\n\nfunction getDefaultExport<TModule extends AppPageModule>(\n module: TModule | null | undefined,\n): AppPageComponent | null {\n return module?.default ?? null;\n}\n\nfunction wrapRenderedBoundaryElement<TModule extends AppPageModule>(\n options: Pick<\n AppPageBoundaryRenderCommonOptions<TModule>,\n \"globalErrorModule\" | \"isRscRequest\" | \"makeThenableParams\" | \"resolveChildSegments\"\n > & {\n element: ReactNode;\n includeGlobalErrorBoundary: boolean;\n layoutModules: readonly (TModule | null | undefined)[];\n layoutTreePositions?: readonly number[] | null;\n matchedParams: AppPageParams;\n routeSegments?: readonly string[];\n skipLayoutWrapping?: boolean;\n },\n): ReactNode {\n return wrapAppPageBoundaryElement({\n element: options.element,\n getDefaultExport,\n globalErrorComponent: getDefaultExport(options.globalErrorModule),\n includeGlobalErrorBoundary: options.includeGlobalErrorBoundary,\n isRscRequest: options.isRscRequest,\n layoutModules: options.layoutModules,\n layoutTreePositions: options.layoutTreePositions,\n makeThenableParams: options.makeThenableParams,\n matchedParams: options.matchedParams,\n renderErrorBoundary(GlobalErrorComponent, children) {\n return createElement(ErrorBoundary, {\n fallback: GlobalErrorComponent,\n // oxlint-disable-next-line react/no-children-prop\n children,\n });\n },\n renderLayout(LayoutComponent, children, asyncParams) {\n return createElement(LayoutComponent as AppPageComponent, {\n // oxlint-disable-next-line react/no-children-prop\n children,\n params: asyncParams,\n });\n },\n renderLayoutSegmentProvider(segmentMap, children) {\n return createElement(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n LayoutSegmentProvider as ComponentType<any>,\n { segmentMap },\n children,\n );\n },\n resolveChildSegments: options.resolveChildSegments,\n routeSegments: options.routeSegments ?? [],\n skipLayoutWrapping: options.skipLayoutWrapping,\n });\n}\n\nfunction createAppPageBoundaryLayoutEntries<TModule extends AppPageModule>(\n route: AppPageBoundaryRoute<TModule> | null | undefined,\n layoutModules: readonly (TModule | null | undefined)[],\n): readonly AppPageBoundaryLayoutEntry[] {\n if (!route || layoutModules.length === 0) return [];\n\n return createAppPageLayoutEntries({\n errors: route.errors,\n layoutTreePositions: route.layoutTreePositions,\n layouts: layoutModules,\n notFounds: null,\n routeSegments: route.routeSegments,\n });\n}\n\nfunction resolveHttpAccessFallbackHeadRouteSegments<TModule extends AppPageModule>(\n route: AppPageBoundaryRoute<TModule> | null | undefined,\n layoutModules: readonly (TModule | null | undefined)[],\n): readonly string[] | undefined {\n if (!route?.routeSegments) {\n return undefined;\n }\n\n if (!route.layouts || layoutModules.length >= route.layouts.length) {\n return route.routeSegments;\n }\n\n const lastIncludedLayoutIndex = layoutModules.length - 1;\n if (lastIncludedLayoutIndex < 0) {\n return [];\n }\n\n const segmentCount = route.layoutTreePositions?.[lastIncludedLayoutIndex] ?? 0;\n return route.routeSegments.slice(0, segmentCount);\n}\n\nfunction resolveHttpAccessFallbackHeadLayoutTreePositions<TModule extends AppPageModule>(\n route: AppPageBoundaryRoute<TModule> | null | undefined,\n layoutModules: readonly (TModule | null | undefined)[],\n): readonly number[] | null | undefined {\n if (!route?.layouts || layoutModules.length >= route.layouts.length) {\n return route?.layoutTreePositions;\n }\n\n return route.layoutTreePositions?.slice(0, layoutModules.length);\n}\n\nfunction createAppPageBoundaryRscPayload<TModule extends AppPageModule>(\n options: AppPageBoundaryRscPayloadOptions<TModule>,\n): AppElements {\n const routeId = AppElementsWire.encodeRouteId(options.pathname, null);\n const layoutEntries = createAppPageBoundaryLayoutEntries(options.route, options.layoutModules);\n\n return {\n ...AppElementsWire.createMetadataEntries({\n interceptionContext: null,\n layoutIds: layoutEntries.map((entry) => entry.id),\n rootLayoutTreePath: layoutEntries[0]?.treePath ?? null,\n routeId,\n }),\n [routeId]: options.element,\n };\n}\n\nasync function renderAppPageBoundaryElementResponse<TModule extends AppPageModule>(\n options: AppPageBoundaryRenderCommonOptions<TModule> & {\n element: ReactNode;\n layoutModules: readonly (TModule | null | undefined)[];\n route?: AppPageBoundaryRoute<TModule> | null;\n routePattern?: string;\n status: number;\n },\n): Promise<Response> {\n const pathname = new URL(options.requestUrl).pathname;\n const payload = createAppPageBoundaryRscPayload({\n element: options.element,\n layoutModules: options.layoutModules,\n pathname,\n route: options.route,\n });\n\n return renderAppPageBoundaryResponse({\n async createHtmlResponse(rscStream, responseStatus) {\n const fontData = createAppPageFontData({\n getLinks: options.getFontLinks,\n getPreloads: options.getFontPreloads,\n getStyles: options.getFontStyles,\n });\n const ssrHandler = await options.loadSsrHandler();\n return renderAppPageHtmlResponse({\n clearRequestContext: options.clearRequestContext,\n fontData,\n fontLinkHeader: options.buildFontLinkHeader(fontData.preloads),\n middlewareHeaders: options.middlewareContext.headers,\n navigationContext: options.getNavigationContext(),\n rscStream,\n scriptNonce: options.scriptNonce,\n ssrHandler,\n status: responseStatus,\n });\n },\n createRscOnErrorHandler() {\n return options.createRscOnErrorHandler(pathname, options.routePattern ?? pathname);\n },\n element: payload,\n isRscRequest: options.isRscRequest,\n middlewareHeaders: options.middlewareContext.headers,\n renderToReadableStream: options.renderToReadableStream,\n status: options.status,\n });\n}\n\nexport async function renderAppPageHttpAccessFallback<TModule extends AppPageModule>(\n options: RenderAppPageHttpAccessFallbackOptions<TModule>,\n): Promise<Response | null> {\n const boundaryComponent =\n options.boundaryComponent ??\n resolveAppPageHttpAccessBoundaryComponent({\n getDefaultExport,\n rootForbiddenModule: options.rootForbiddenModule,\n rootNotFoundModule: options.rootNotFoundModule,\n rootUnauthorizedModule: options.rootUnauthorizedModule,\n routeForbiddenModule: options.route?.forbidden,\n routeNotFoundModule: options.route?.notFound,\n routeUnauthorizedModule: options.route?.unauthorized,\n statusCode: options.statusCode,\n });\n if (!boundaryComponent) {\n return null;\n }\n\n const layoutModules = options.layoutModules ?? options.route?.layouts ?? options.rootLayouts;\n const pathname = new URL(options.requestUrl).pathname;\n const routeSegments = resolveHttpAccessFallbackHeadRouteSegments(options.route, layoutModules);\n const { metadata, viewport } = await resolveAppPageHead({\n basePath: options.basePath ?? \"\",\n layoutModules,\n layoutTreePositions: resolveHttpAccessFallbackHeadLayoutTreePositions(\n options.route,\n layoutModules,\n ),\n metadataRoutes: options.metadataRoutes,\n params: options.matchedParams,\n routePath: options.route?.pattern ?? pathname,\n routeSegments,\n });\n\n const headElements: ReactNode[] = [\n createElement(\"meta\", { charSet: \"utf-8\", key: \"charset\" }),\n createElement(\"meta\", { content: \"noindex\", key: \"robots\", name: \"robots\" }),\n ];\n if (metadata) {\n headElements.push(createElement(MetadataHead, { key: \"metadata\", metadata, pathname }));\n }\n headElements.push(createElement(ViewportHead, { key: \"viewport\", viewport }));\n\n const skipLayoutWrapping = options.skipLayoutWrapping ?? false;\n const element = wrapRenderedBoundaryElement({\n element: createElement(Fragment, null, ...headElements, createElement(boundaryComponent)),\n globalErrorModule: options.globalErrorModule,\n includeGlobalErrorBoundary: true,\n isRscRequest: options.isRscRequest,\n layoutModules,\n layoutTreePositions: options.route?.layoutTreePositions,\n makeThenableParams: options.makeThenableParams,\n matchedParams: options.matchedParams,\n resolveChildSegments: options.resolveChildSegments,\n routeSegments: options.route?.routeSegments,\n skipLayoutWrapping,\n });\n\n return renderAppPageBoundaryElementResponse({\n ...options,\n // When global-not-found owns the document, no layouts should contribute to\n // the RSC payload's layout entries either — otherwise the SSR pipeline\n // would expect a root-layout tree path that doesn't exist in the markup.\n element,\n layoutModules: skipLayoutWrapping ? [] : layoutModules,\n route: skipLayoutWrapping ? null : options.route,\n routePattern: options.route?.pattern,\n status: options.statusCode,\n });\n}\n\nexport async function renderAppPageErrorBoundary<TModule extends AppPageModule>(\n options: RenderAppPageErrorBoundaryOptions<TModule>,\n): Promise<Response | null> {\n const errorBoundary = resolveAppPageErrorBoundary({\n getDefaultExport,\n errorModules: options.route?.errorPaths,\n globalErrorModule: options.globalErrorModule,\n layoutErrorModules: options.route?.errors,\n pageErrorModule: options.route?.error,\n });\n if (!errorBoundary.component) {\n return null;\n }\n\n const rawError =\n options.error instanceof Error ? options.error : new Error(String(options.error));\n rewriteClientHookError(rawError);\n const errorObject = options.sanitizeErrorForClient(rawError);\n const matchedParams = options.matchedParams ?? options.route?.params ?? {};\n const layoutModules = options.route?.layouts ?? options.rootLayouts;\n const pathname = new URL(options.requestUrl).pathname;\n\n const headElements: ReactNode[] = [createElement(\"meta\", { charSet: \"utf-8\", key: \"charset\" })];\n if (!errorBoundary.isGlobalError) {\n try {\n const { metadata, viewport } = await resolveAppPageHead({\n basePath: options.basePath ?? \"\",\n fallbackOnFileMetadataError: true,\n layoutModules,\n layoutTreePositions: options.route?.layoutTreePositions,\n metadataRoutes: options.metadataRoutes,\n params: matchedParams,\n routePath: options.route?.pattern ?? pathname,\n routeSegments: options.route?.routeSegments,\n });\n if (metadata) {\n headElements.push(createElement(MetadataHead, { key: \"metadata\", metadata, pathname }));\n }\n headElements.push(createElement(ViewportHead, { key: \"viewport\", viewport }));\n } catch (error) {\n console.error(\n `[vinext] App page error boundary head resolution failed for ${options.route?.pattern ?? pathname}:`,\n error,\n );\n }\n }\n\n const element = wrapRenderedBoundaryElement({\n element: createElement(\n Fragment,\n null,\n ...headElements,\n createElement(errorBoundary.component, {\n error: errorObject,\n }),\n ),\n globalErrorModule: options.globalErrorModule,\n includeGlobalErrorBoundary: !errorBoundary.isGlobalError,\n isRscRequest: options.isRscRequest,\n layoutModules,\n layoutTreePositions: options.route?.layoutTreePositions,\n makeThenableParams: options.makeThenableParams,\n matchedParams,\n resolveChildSegments: options.resolveChildSegments,\n routeSegments: options.route?.routeSegments,\n skipLayoutWrapping: errorBoundary.isGlobalError,\n });\n\n return renderAppPageBoundaryElementResponse({\n ...options,\n element,\n layoutModules,\n route: options.route,\n routePattern: options.route?.pattern,\n status: 200,\n });\n}\n\n// React client-only hooks that are absent from the `react-server` export\n// condition. When called in a Server Component they produce a TypeError like\n// \"useState is not a function\". Rewrite into an actionable message matching\n// the format used by the next/navigation shims (see client-hook-error.ts).\nconst _clientHookPattern =\n /\\b(useState|useEffect|useReducer|useRef|useContext|useLayoutEffect|useInsertionEffect|useSyncExternalStore|useTransition|useImperativeHandle|useDeferredValue|useActionState|useOptimistic|useEffectEvent)\\b.*is not a function/;\n\nfunction rewriteClientHookError(error: Error): void {\n const match = error.message.match(_clientHookPattern);\n if (match) {\n error.message = buildClientHookErrorMessage(`${match[1]}()`);\n }\n}\n"],"mappings":";;;;;;;;;;;;AAqHA,SAAS,iBACP,QACyB;CACzB,OAAO,QAAQ,WAAW;;AAG5B,SAAS,4BACP,SAYW;CACX,OAAO,2BAA2B;EAChC,SAAS,QAAQ;EACjB;EACA,sBAAsB,iBAAiB,QAAQ,kBAAkB;EACjE,4BAA4B,QAAQ;EACpC,cAAc,QAAQ;EACtB,eAAe,QAAQ;EACvB,qBAAqB,QAAQ;EAC7B,oBAAoB,QAAQ;EAC5B,eAAe,QAAQ;EACvB,oBAAoB,sBAAsB,UAAU;GAClD,OAAO,cAAc,eAAe;IAClC,UAAU;IAEV;IACD,CAAC;;EAEJ,aAAa,iBAAiB,UAAU,aAAa;GACnD,OAAO,cAAc,iBAAqC;IAExD;IACA,QAAQ;IACT,CAAC;;EAEJ,4BAA4B,YAAY,UAAU;GAChD,OAAO,cAEL,uBACA,EAAE,YAAY,EACd,SACD;;EAEH,sBAAsB,QAAQ;EAC9B,eAAe,QAAQ,iBAAiB,EAAE;EAC1C,oBAAoB,QAAQ;EAC7B,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
import { VINEXT_RSC_VARY_HEADER } from "./app-rsc-cache-busting.js";
|
|
2
|
+
import { VINEXT_RSC_CONTENT_TYPE, VINEXT_RSC_VARY_HEADER, applyRscCompatibilityIdHeader } from "./app-rsc-cache-busting.js";
|
|
3
3
|
import { resolveAppPageSegmentParams } from "./app-page-params.js";
|
|
4
4
|
import { mergeMiddlewareResponseHeaders } from "./middleware-response-headers.js";
|
|
5
5
|
//#region src/server/app-page-boundary.ts
|
|
@@ -66,10 +66,11 @@ async function renderAppPageBoundaryResponse(options) {
|
|
|
66
66
|
const rscStream = runWithFetchDedupe(() => options.renderToReadableStream(options.element, { onError: options.createRscOnErrorHandler() }));
|
|
67
67
|
if (options.isRscRequest) {
|
|
68
68
|
const headers = new Headers({
|
|
69
|
-
"Content-Type":
|
|
69
|
+
"Content-Type": VINEXT_RSC_CONTENT_TYPE,
|
|
70
70
|
Vary: VINEXT_RSC_VARY_HEADER
|
|
71
71
|
});
|
|
72
72
|
mergeMiddlewareResponseHeaders(headers, options.middlewareHeaders ?? null);
|
|
73
|
+
applyRscCompatibilityIdHeader(headers);
|
|
73
74
|
return new Response(rscStream, {
|
|
74
75
|
status: options.status,
|
|
75
76
|
headers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-page-boundary.js","names":[],"sources":["../../src/server/app-page-boundary.ts"],"sourcesContent":["import { runWithFetchDedupe } from \"vinext/shims/fetch-cache\";\nimport { mergeMiddlewareResponseHeaders } from \"./middleware-response-headers.js\";\nimport { VINEXT_RSC_VARY_HEADER } from \"./app-rsc-cache-busting.js\";\nimport { resolveAppPageSegmentParams } from \"./app-page-params.js\";\n\nexport type AppPageParams = Record<string, string | string[]>;\n\ntype ResolveAppPageHttpAccessBoundaryComponentOptions<TModule, TComponent> = {\n getDefaultExport: (module: TModule | null | undefined) => TComponent | null | undefined;\n rootForbiddenModule?: TModule | null;\n rootNotFoundModule?: TModule | null;\n rootUnauthorizedModule?: TModule | null;\n routeForbiddenModule?: TModule | null;\n routeNotFoundModule?: TModule | null;\n routeUnauthorizedModule?: TModule | null;\n statusCode: number;\n};\n\ntype ResolveAppPageParentHttpAccessBoundaryModuleOptions<TModule> = {\n layoutIndex: number;\n rootForbiddenModule?: TModule | null;\n rootNotFoundModule?: TModule | null;\n rootUnauthorizedModule?: TModule | null;\n routeForbiddenModules?: readonly (TModule | null | undefined)[] | null;\n routeNotFoundModules?: readonly (TModule | null | undefined)[] | null;\n routeUnauthorizedModules?: readonly (TModule | null | undefined)[] | null;\n statusCode: number;\n};\n\ntype ResolveAppPageErrorBoundaryOptions<TModule, TComponent> = {\n getDefaultExport: (module: TModule | null | undefined) => TComponent | null | undefined;\n globalErrorModule?: TModule | null;\n errorModules?: readonly (TModule | null | undefined)[] | null;\n layoutErrorModules?: readonly (TModule | null | undefined)[] | null;\n pageErrorModule?: TModule | null;\n};\n\ntype ResolveAppPageErrorBoundaryResult<TComponent> = {\n component: TComponent | null;\n isGlobalError: boolean;\n};\n\ntype WrapAppPageBoundaryElementOptions<\n TElement,\n TLayoutModule,\n TLayoutComponent,\n TChildSegments,\n TGlobalErrorComponent,\n> = {\n element: TElement;\n getDefaultExport: (\n module: TLayoutModule | null | undefined,\n ) => TLayoutComponent | null | undefined;\n globalErrorComponent?: TGlobalErrorComponent | null;\n includeGlobalErrorBoundary: boolean;\n isRscRequest: boolean;\n layoutModules: readonly (TLayoutModule | null | undefined)[];\n layoutTreePositions?: readonly number[] | null;\n makeThenableParams: (params: AppPageParams) => unknown;\n matchedParams: AppPageParams;\n renderErrorBoundary: (component: TGlobalErrorComponent, children: TElement) => TElement;\n renderLayout: (component: TLayoutComponent, children: TElement, params: unknown) => TElement;\n renderLayoutSegmentProvider?: (\n segmentMap: { children: TChildSegments },\n children: TElement,\n ) => TElement;\n resolveChildSegments?: (\n routeSegments: readonly string[],\n treePosition: number,\n params: AppPageParams,\n ) => TChildSegments;\n routeSegments?: readonly string[];\n skipLayoutWrapping?: boolean;\n};\n\ntype AppPageBoundaryOnError = (\n error: unknown,\n requestInfo: unknown,\n errorContext: unknown,\n) => unknown;\n\ntype RenderAppPageBoundaryResponseOptions<TElement> = {\n createHtmlResponse: (rscStream: ReadableStream<Uint8Array>, status: number) => Promise<Response>;\n createRscOnErrorHandler: () => AppPageBoundaryOnError;\n element: TElement;\n isRscRequest: boolean;\n middlewareHeaders?: Headers | null;\n renderToReadableStream: (\n element: TElement,\n options: { onError: AppPageBoundaryOnError },\n ) => ReadableStream<Uint8Array>;\n status: number;\n};\n\nexport function resolveAppPageHttpAccessBoundaryComponent<TModule, TComponent>(\n options: ResolveAppPageHttpAccessBoundaryComponentOptions<TModule, TComponent>,\n): TComponent | null {\n let boundaryModule: TModule | null | undefined;\n\n if (options.statusCode === 403) {\n boundaryModule = options.routeForbiddenModule ?? options.rootForbiddenModule;\n } else if (options.statusCode === 401) {\n boundaryModule = options.routeUnauthorizedModule ?? options.rootUnauthorizedModule;\n } else {\n boundaryModule = options.routeNotFoundModule ?? options.rootNotFoundModule;\n }\n\n return options.getDefaultExport(boundaryModule) ?? null;\n}\n\nexport function resolveAppPageParentHttpAccessBoundaryModule<TModule>(\n options: ResolveAppPageParentHttpAccessBoundaryModuleOptions<TModule>,\n): TModule | null {\n let routeModules = options.routeNotFoundModules;\n let rootModule = options.rootNotFoundModule;\n\n if (options.statusCode === 403) {\n routeModules = options.routeForbiddenModules;\n rootModule = options.rootForbiddenModule;\n } else if (options.statusCode === 401) {\n routeModules = options.routeUnauthorizedModules;\n rootModule = options.rootUnauthorizedModule;\n }\n\n if (routeModules) {\n for (let index = options.layoutIndex - 1; index >= 0; index--) {\n const module = routeModules[index];\n if (module) {\n return module;\n }\n }\n }\n\n return rootModule ?? null;\n}\n\nexport function resolveAppPageErrorBoundary<TModule, TComponent>(\n options: ResolveAppPageErrorBoundaryOptions<TModule, TComponent>,\n): ResolveAppPageErrorBoundaryResult<TComponent> {\n const pageErrorComponent = options.getDefaultExport(options.pageErrorModule);\n if (pageErrorComponent) {\n return {\n component: pageErrorComponent,\n isGlobalError: false,\n };\n }\n\n const segmentErrorModules = options.errorModules ?? options.layoutErrorModules;\n if (segmentErrorModules) {\n for (let index = segmentErrorModules.length - 1; index >= 0; index--) {\n const segmentErrorComponent = options.getDefaultExport(segmentErrorModules[index]);\n if (segmentErrorComponent) {\n return {\n component: segmentErrorComponent,\n isGlobalError: false,\n };\n }\n }\n }\n\n const globalErrorComponent = options.getDefaultExport(options.globalErrorModule);\n return {\n component: globalErrorComponent ?? null,\n isGlobalError: Boolean(globalErrorComponent),\n };\n}\n\nexport function wrapAppPageBoundaryElement<\n TElement,\n TLayoutModule,\n TLayoutComponent,\n TChildSegments,\n TGlobalErrorComponent,\n>(\n options: WrapAppPageBoundaryElementOptions<\n TElement,\n TLayoutModule,\n TLayoutComponent,\n TChildSegments,\n TGlobalErrorComponent\n >,\n): TElement {\n let element = options.element;\n\n if (!options.skipLayoutWrapping) {\n for (let index = options.layoutModules.length - 1; index >= 0; index--) {\n const layoutComponent = options.getDefaultExport(options.layoutModules[index]);\n if (!layoutComponent) {\n continue;\n }\n\n const treePosition = options.layoutTreePositions ? options.layoutTreePositions[index] : 0;\n const asyncParams = options.makeThenableParams(\n resolveAppPageSegmentParams(options.routeSegments, treePosition, options.matchedParams),\n );\n element = options.renderLayout(layoutComponent, element, asyncParams);\n\n if (\n options.isRscRequest &&\n options.renderLayoutSegmentProvider &&\n options.resolveChildSegments\n ) {\n const childSegments = options.resolveChildSegments(\n options.routeSegments ?? [],\n treePosition,\n options.matchedParams,\n );\n element = options.renderLayoutSegmentProvider({ children: childSegments }, element);\n }\n }\n }\n\n if (options.isRscRequest && options.includeGlobalErrorBoundary && options.globalErrorComponent) {\n element = options.renderErrorBoundary(options.globalErrorComponent, element);\n }\n\n return element;\n}\n\nexport async function renderAppPageBoundaryResponse<TElement>(\n options: RenderAppPageBoundaryResponseOptions<TElement>,\n): Promise<Response> {\n // Defensive wrap for standalone callers; idempotent under dispatchAppPage.\n // The async stream consumption that follows relies on the surrounding\n // runWithRequestContext to keep ALS state alive after this synchronous call\n // returns. See app-page-render.ts for the same pattern.\n const rscStream = runWithFetchDedupe(() =>\n options.renderToReadableStream(options.element, {\n onError: options.createRscOnErrorHandler(),\n }),\n );\n\n if (options.isRscRequest) {\n // Do NOT clear request-scoped context here. RSC responses are consumed lazily\n // by the client, so headers()/cookies() and async server components still need\n // their ALS-backed state while the stream is being read.\n const headers = new Headers({\n \"Content-Type\": \"text/x-component; charset=utf-8\",\n Vary: VINEXT_RSC_VARY_HEADER,\n });\n mergeMiddlewareResponseHeaders(headers, options.middlewareHeaders ?? null);\n\n return new Response(rscStream, {\n status: options.status,\n headers,\n });\n }\n\n return options.createHtmlResponse(rscStream, options.status);\n}\n"],"mappings":";;;;;AA8FA,SAAgB,0CACd,SACmB;CACnB,IAAI;CAEJ,IAAI,QAAQ,eAAe,KACzB,iBAAiB,QAAQ,wBAAwB,QAAQ;MACpD,IAAI,QAAQ,eAAe,KAChC,iBAAiB,QAAQ,2BAA2B,QAAQ;MAE5D,iBAAiB,QAAQ,uBAAuB,QAAQ;CAG1D,OAAO,QAAQ,iBAAiB,eAAe,IAAI;;AAGrD,SAAgB,6CACd,SACgB;CAChB,IAAI,eAAe,QAAQ;CAC3B,IAAI,aAAa,QAAQ;CAEzB,IAAI,QAAQ,eAAe,KAAK;EAC9B,eAAe,QAAQ;EACvB,aAAa,QAAQ;QAChB,IAAI,QAAQ,eAAe,KAAK;EACrC,eAAe,QAAQ;EACvB,aAAa,QAAQ;;CAGvB,IAAI,cACF,KAAK,IAAI,QAAQ,QAAQ,cAAc,GAAG,SAAS,GAAG,SAAS;EAC7D,MAAM,SAAS,aAAa;EAC5B,IAAI,QACF,OAAO;;CAKb,OAAO,cAAc;;AAGvB,SAAgB,4BACd,SAC+C;CAC/C,MAAM,qBAAqB,QAAQ,iBAAiB,QAAQ,gBAAgB;CAC5E,IAAI,oBACF,OAAO;EACL,WAAW;EACX,eAAe;EAChB;CAGH,MAAM,sBAAsB,QAA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gB;GAChB,MAAM;GACP,CAAC;EACF,+BAA+B,SAAS,QAAQ,qBAAqB,KAAK;EAE1E,OAAO,IAAI,SAAS,WAAW;GAC7B,QAAQ,QAAQ;GAChB;GACD,CAAC;;CAGJ,OAAO,QAAQ,mBAAmB,WAAW,QAAQ,OAAO"}
|
|
1
|
+
{"version":3,"file":"app-page-boundary.js","names":[],"sources":["../../src/server/app-page-boundary.ts"],"sourcesContent":["import { runWithFetchDedupe } from \"vinext/shims/fetch-cache\";\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\";\nimport { resolveAppPageSegmentParams } from \"./app-page-params.js\";\n\nexport type AppPageParams = Record<string, string | string[]>;\n\ntype ResolveAppPageHttpAccessBoundaryComponentOptions<TModule, TComponent> = {\n getDefaultExport: (module: TModule | null | undefined) => TComponent | null | undefined;\n rootForbiddenModule?: TModule | null;\n rootNotFoundModule?: TModule | null;\n rootUnauthorizedModule?: TModule | null;\n routeForbiddenModule?: TModule | null;\n routeNotFoundModule?: TModule | null;\n routeUnauthorizedModule?: TModule | null;\n statusCode: number;\n};\n\ntype ResolveAppPageParentHttpAccessBoundaryModuleOptions<TModule> = {\n layoutIndex: number;\n rootForbiddenModule?: TModule | null;\n rootNotFoundModule?: TModule | null;\n rootUnauthorizedModule?: TModule | null;\n routeForbiddenModules?: readonly (TModule | null | undefined)[] | null;\n routeNotFoundModules?: readonly (TModule | null | undefined)[] | null;\n routeUnauthorizedModules?: readonly (TModule | null | undefined)[] | null;\n statusCode: number;\n};\n\ntype ResolveAppPageErrorBoundaryOptions<TModule, TComponent> = {\n getDefaultExport: (module: TModule | null | undefined) => TComponent | null | undefined;\n globalErrorModule?: TModule | null;\n errorModules?: readonly (TModule | null | undefined)[] | null;\n layoutErrorModules?: readonly (TModule | null | undefined)[] | null;\n pageErrorModule?: TModule | null;\n};\n\ntype ResolveAppPageErrorBoundaryResult<TComponent> = {\n component: TComponent | null;\n isGlobalError: boolean;\n};\n\ntype WrapAppPageBoundaryElementOptions<\n TElement,\n TLayoutModule,\n TLayoutComponent,\n TChildSegments,\n TGlobalErrorComponent,\n> = {\n element: TElement;\n getDefaultExport: (\n module: TLayoutModule | null | undefined,\n ) => TLayoutComponent | null | undefined;\n globalErrorComponent?: TGlobalErrorComponent | null;\n includeGlobalErrorBoundary: boolean;\n isRscRequest: boolean;\n layoutModules: readonly (TLayoutModule | null | undefined)[];\n layoutTreePositions?: readonly number[] | null;\n makeThenableParams: (params: AppPageParams) => unknown;\n matchedParams: AppPageParams;\n renderErrorBoundary: (component: TGlobalErrorComponent, children: TElement) => TElement;\n renderLayout: (component: TLayoutComponent, children: TElement, params: unknown) => TElement;\n renderLayoutSegmentProvider?: (\n segmentMap: { children: TChildSegments },\n children: TElement,\n ) => TElement;\n resolveChildSegments?: (\n routeSegments: readonly string[],\n treePosition: number,\n params: AppPageParams,\n ) => TChildSegments;\n routeSegments?: readonly string[];\n skipLayoutWrapping?: boolean;\n};\n\ntype AppPageBoundaryOnError = (\n error: unknown,\n requestInfo: unknown,\n errorContext: unknown,\n) => unknown;\n\ntype RenderAppPageBoundaryResponseOptions<TElement> = {\n createHtmlResponse: (rscStream: ReadableStream<Uint8Array>, status: number) => Promise<Response>;\n createRscOnErrorHandler: () => AppPageBoundaryOnError;\n element: TElement;\n isRscRequest: boolean;\n middlewareHeaders?: Headers | null;\n renderToReadableStream: (\n element: TElement,\n options: { onError: AppPageBoundaryOnError },\n ) => ReadableStream<Uint8Array>;\n status: number;\n};\n\nexport function resolveAppPageHttpAccessBoundaryComponent<TModule, TComponent>(\n options: ResolveAppPageHttpAccessBoundaryComponentOptions<TModule, TComponent>,\n): TComponent | null {\n let boundaryModule: TModule | null | undefined;\n\n if (options.statusCode === 403) {\n boundaryModule = options.routeForbiddenModule ?? options.rootForbiddenModule;\n } else if (options.statusCode === 401) {\n boundaryModule = options.routeUnauthorizedModule ?? options.rootUnauthorizedModule;\n } else {\n boundaryModule = options.routeNotFoundModule ?? options.rootNotFoundModule;\n }\n\n return options.getDefaultExport(boundaryModule) ?? null;\n}\n\nexport function resolveAppPageParentHttpAccessBoundaryModule<TModule>(\n options: ResolveAppPageParentHttpAccessBoundaryModuleOptions<TModule>,\n): TModule | null {\n let routeModules = options.routeNotFoundModules;\n let rootModule = options.rootNotFoundModule;\n\n if (options.statusCode === 403) {\n routeModules = options.routeForbiddenModules;\n rootModule = options.rootForbiddenModule;\n } else if (options.statusCode === 401) {\n routeModules = options.routeUnauthorizedModules;\n rootModule = options.rootUnauthorizedModule;\n }\n\n if (routeModules) {\n for (let index = options.layoutIndex - 1; index >= 0; index--) {\n const module = routeModules[index];\n if (module) {\n return module;\n }\n }\n }\n\n return rootModule ?? null;\n}\n\nexport function resolveAppPageErrorBoundary<TModule, TComponent>(\n options: ResolveAppPageErrorBoundaryOptions<TModule, TComponent>,\n): ResolveAppPageErrorBoundaryResult<TComponent> {\n const pageErrorComponent = options.getDefaultExport(options.pageErrorModule);\n if (pageErrorComponent) {\n return {\n component: pageErrorComponent,\n isGlobalError: false,\n };\n }\n\n const segmentErrorModules = options.errorModules ?? options.layoutErrorModules;\n if (segmentErrorModules) {\n for (let index = segmentErrorModules.length - 1; index >= 0; index--) {\n const segmentErrorComponent = options.getDefaultExport(segmentErrorModules[index]);\n if (segmentErrorComponent) {\n return {\n component: segmentErrorComponent,\n isGlobalError: false,\n };\n }\n }\n }\n\n const globalErrorComponent = options.getDefaultExport(options.globalErrorModule);\n return {\n component: globalErrorComponent ?? null,\n isGlobalError: Boolean(globalErrorComponent),\n };\n}\n\nexport function wrapAppPageBoundaryElement<\n TElement,\n TLayoutModule,\n TLayoutComponent,\n TChildSegments,\n TGlobalErrorComponent,\n>(\n options: WrapAppPageBoundaryElementOptions<\n TElement,\n TLayoutModule,\n TLayoutComponent,\n TChildSegments,\n TGlobalErrorComponent\n >,\n): TElement {\n let element = options.element;\n\n if (!options.skipLayoutWrapping) {\n for (let index = options.layoutModules.length - 1; index >= 0; index--) {\n const layoutComponent = options.getDefaultExport(options.layoutModules[index]);\n if (!layoutComponent) {\n continue;\n }\n\n const treePosition = options.layoutTreePositions ? options.layoutTreePositions[index] : 0;\n const asyncParams = options.makeThenableParams(\n resolveAppPageSegmentParams(options.routeSegments, treePosition, options.matchedParams),\n );\n element = options.renderLayout(layoutComponent, element, asyncParams);\n\n if (\n options.isRscRequest &&\n options.renderLayoutSegmentProvider &&\n options.resolveChildSegments\n ) {\n const childSegments = options.resolveChildSegments(\n options.routeSegments ?? [],\n treePosition,\n options.matchedParams,\n );\n element = options.renderLayoutSegmentProvider({ children: childSegments }, element);\n }\n }\n }\n\n if (options.isRscRequest && options.includeGlobalErrorBoundary && options.globalErrorComponent) {\n element = options.renderErrorBoundary(options.globalErrorComponent, element);\n }\n\n return element;\n}\n\nexport async function renderAppPageBoundaryResponse<TElement>(\n options: RenderAppPageBoundaryResponseOptions<TElement>,\n): Promise<Response> {\n // Defensive wrap for standalone callers; idempotent under dispatchAppPage.\n // The async stream consumption that follows relies on the surrounding\n // runWithRequestContext to keep ALS state alive after this synchronous call\n // returns. See app-page-render.ts for the same pattern.\n const rscStream = runWithFetchDedupe(() =>\n options.renderToReadableStream(options.element, {\n onError: options.createRscOnErrorHandler(),\n }),\n );\n\n if (options.isRscRequest) {\n // Do NOT clear request-scoped context here. RSC responses are consumed lazily\n // by the client, so headers()/cookies() and async server components still need\n // their ALS-backed state while the stream is being read.\n const headers = new Headers({\n \"Content-Type\": VINEXT_RSC_CONTENT_TYPE,\n Vary: VINEXT_RSC_VARY_HEADER,\n });\n mergeMiddlewareResponseHeaders(headers, options.middlewareHeaders ?? null);\n applyRscCompatibilityIdHeader(headers);\n\n return new Response(rscStream, {\n status: options.status,\n headers,\n });\n }\n\n return options.createHtmlResponse(rscStream, options.status);\n}\n"],"mappings":";;;;;AAkGA,SAAgB,0CACd,SACmB;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,iBAAiB,QAAQ,cAAc,OAAO;EAC9E,IAAI,CAAC,iBACH;EAGF,MAAM,eAAe,QAAQ,sBAAsB,QAAQ,oBAAoB,SAAS;EACxF,MAAM,cAAc,QAAQ,mBAC1B,4BAA4B,QAAQ,eAAe,cAAc,QAAQ,cAAc,CACxF;EACD,UAAU,QAAQ,aAAa,iBAAiB,SAAS,YAAY;EAErE,IACE,QAAQ,gBACR,QAAQ,+BACR,QAAQ,sBACR;GACA,MAAM,gBAAgB,QAAQ,qBAC5B,QAAQ,iBAAiB,EAAE,EAC3B,cACA,QAAQ,cACT;GACD,UAAU,QAAQ,4BAA4B,EAAE,UAAU,eAAe,EAAE,QAAQ;;;CAKzF,IAAI,QAAQ,gBAAgB,QAAQ,8BAA8B,QAAQ,sBACxE,UAAU,QAAQ,oBAAoB,QAAQ,sBAAsB,QAAQ;CAG9E,OAAO;;AAGT,eAAsB,8BACpB,SACmB;CAKnB,MAAM,YAAY,yBAChB,QAAQ,uBAAuB,QAAQ,SAAS,EAC9C,SAAS,QAAQ,yBAAyB,EAC3C,CAAC,CACH;CAED,IAAI,QAAQ,cAAc;EAIxB,MAAM,UAAU,IAAI,QAAQ;GAC1B,gBAAgB;GAChB,MAAM;GACP,CAAC;EACF,+BAA+B,SAAS,QAAQ,qBAAqB,KAAK;EAC1E,8BAA8B,QAAQ;EAEtC,OAAO,IAAI,SAAS,WAAW;GAC7B,QAAQ,QAAQ;GAChB;GACD,CAAC;;CAGJ,OAAO,QAAQ,mBAAmB,WAAW,QAAQ,OAAO"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { RenderObservation } from "./cache-proof.js";
|
|
1
2
|
import { CacheControlMetadata, CachedAppPageValue } from "../shims/cache.js";
|
|
2
3
|
import { AppRscRenderMode } from "./app-rsc-render-mode.js";
|
|
3
4
|
import { ISRCacheEntry } from "./isr-cache.js";
|
|
5
|
+
import { AppPageRenderObservationState } from "./app-page-render-observation.js";
|
|
4
6
|
|
|
5
7
|
//#region src/server/app-page-cache.d.ts
|
|
6
8
|
type AppPageDebugLogger = (event: string, detail: string) => void;
|
|
@@ -11,10 +13,16 @@ type AppPageRequestCacheLife = {
|
|
|
11
13
|
revalidate?: number;
|
|
12
14
|
expire?: number;
|
|
13
15
|
};
|
|
16
|
+
type BuildAppPageCacheRenderObservation = (input: {
|
|
17
|
+
cacheTags: readonly string[];
|
|
18
|
+
state: AppPageRenderObservationState;
|
|
19
|
+
}) => RenderObservation;
|
|
14
20
|
type AppPageCacheRenderResult = {
|
|
15
21
|
cacheControl?: CacheControlMetadata;
|
|
16
22
|
html: string;
|
|
23
|
+
htmlRenderObservation?: RenderObservation;
|
|
17
24
|
rscData: ArrayBuffer;
|
|
25
|
+
rscRenderObservation?: RenderObservation;
|
|
18
26
|
tags: string[];
|
|
19
27
|
};
|
|
20
28
|
type BuildAppPageCachedResponseOptions = {
|
|
@@ -50,6 +58,9 @@ type FinalizeAppPageHtmlCacheResponseOptions = {
|
|
|
50
58
|
capturedRscDataPromise: Promise<ArrayBuffer> | null;
|
|
51
59
|
cleanPathname: string;
|
|
52
60
|
consumeDynamicUsage: () => boolean;
|
|
61
|
+
consumeRenderObservationState?: () => AppPageRenderObservationState;
|
|
62
|
+
createHtmlRenderObservation?: BuildAppPageCacheRenderObservation;
|
|
63
|
+
createRscRenderObservation?: BuildAppPageCacheRenderObservation;
|
|
53
64
|
getPageTags: () => string[];
|
|
54
65
|
getRequestCacheLife?: () => AppPageRequestCacheLife | null;
|
|
55
66
|
isrDebug?: AppPageDebugLogger;
|
|
@@ -65,6 +76,8 @@ type ScheduleAppPageRscCacheWriteOptions = {
|
|
|
65
76
|
capturedRscDataPromise: Promise<ArrayBuffer> | null;
|
|
66
77
|
cleanPathname: string;
|
|
67
78
|
consumeDynamicUsage: () => boolean;
|
|
79
|
+
consumeRenderObservationState?: () => AppPageRenderObservationState;
|
|
80
|
+
createRscRenderObservation?: BuildAppPageCacheRenderObservation;
|
|
68
81
|
dynamicUsedDuringBuild: boolean;
|
|
69
82
|
getPageTags: () => string[];
|
|
70
83
|
getRequestCacheLife?: () => AppPageRequestCacheLife | null;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { VINEXT_CACHE_HEADER, VINEXT_MOUNTED_SLOTS_HEADER } from "./headers.js";
|
|
2
2
|
import { encodeCacheTag } from "../utils/encode-cache-tag.js";
|
|
3
3
|
import { buildAppPageCacheValue } from "./isr-cache.js";
|
|
4
|
-
import { VINEXT_RSC_VARY_HEADER } from "./app-rsc-cache-busting.js";
|
|
5
|
-
import { readStreamAsText } from "../utils/text-stream.js";
|
|
4
|
+
import { VINEXT_RSC_CONTENT_TYPE, VINEXT_RSC_VARY_HEADER, applyRscCompatibilityIdHeader } from "./app-rsc-cache-busting.js";
|
|
6
5
|
import { mergeMiddlewareResponseHeaders } from "./middleware-response-headers.js";
|
|
7
6
|
import { buildCachedRevalidateCacheControl } from "./cache-control.js";
|
|
7
|
+
import { readStreamAsText } from "../utils/text-stream.js";
|
|
8
|
+
import { createEmptyAppPageRenderObservationState } from "./app-page-render-observation.js";
|
|
8
9
|
//#region src/server/app-page-cache.ts
|
|
9
10
|
const NO_STORE_CACHE_CONTROL = "no-store, must-revalidate";
|
|
10
11
|
function buildAppPageCacheTags(pathname, extraTags) {
|
|
@@ -65,10 +66,11 @@ function buildAppPageCachedResponse(cachedValue, options) {
|
|
|
65
66
|
const rscHeaders = buildAppPageCachedHeaders({
|
|
66
67
|
cacheControl,
|
|
67
68
|
cacheState: options.cacheState,
|
|
68
|
-
contentType:
|
|
69
|
+
contentType: VINEXT_RSC_CONTENT_TYPE,
|
|
69
70
|
middlewareHeaders: options.middlewareHeaders,
|
|
70
71
|
mountedSlotsHeader: options.mountedSlotsHeader
|
|
71
72
|
});
|
|
73
|
+
applyRscCompatibilityIdHeader(rscHeaders);
|
|
72
74
|
return new Response(cachedValue.rscData, {
|
|
73
75
|
status,
|
|
74
76
|
headers: rscHeaders
|
|
@@ -115,8 +117,8 @@ async function readAppPageCacheResponse(options) {
|
|
|
115
117
|
const revalidatedPage = await options.renderFreshPageForCache();
|
|
116
118
|
const revalidateSeconds = revalidatedPage.cacheControl?.revalidate ?? options.revalidateSeconds;
|
|
117
119
|
const expireSeconds = revalidatedPage.cacheControl?.expire ?? options.expireSeconds;
|
|
118
|
-
const writes = [options.isrSet(options.isrRscKey(options.cleanPathname, options.mountedSlotsHeader, options.renderMode), buildAppPageCacheValue("", revalidatedPage.rscData, 200), revalidateSeconds, revalidatedPage.tags, expireSeconds)];
|
|
119
|
-
if (!options.isRscRequest) writes.push(options.isrSet(options.isrHtmlKey(options.cleanPathname), buildAppPageCacheValue(revalidatedPage.html, void 0, 200), revalidateSeconds, revalidatedPage.tags, expireSeconds));
|
|
120
|
+
const writes = [options.isrSet(options.isrRscKey(options.cleanPathname, options.mountedSlotsHeader, options.renderMode), buildAppPageCacheValue("", revalidatedPage.rscData, 200, revalidatedPage.rscRenderObservation), revalidateSeconds, revalidatedPage.tags, expireSeconds)];
|
|
121
|
+
if (!options.isRscRequest) writes.push(options.isrSet(options.isrHtmlKey(options.cleanPathname), buildAppPageCacheValue(revalidatedPage.html, void 0, 200, revalidatedPage.htmlRenderObservation), revalidateSeconds, revalidatedPage.tags, expireSeconds));
|
|
120
122
|
await Promise.all(writes);
|
|
121
123
|
options.isrDebug?.("regen complete", options.cleanPathname);
|
|
122
124
|
});
|
|
@@ -170,8 +172,17 @@ function finalizeAppPageHtmlCacheResponse(response, options) {
|
|
|
170
172
|
return;
|
|
171
173
|
}
|
|
172
174
|
const pageTags = options.getPageTags();
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
+
const observationState = options.consumeRenderObservationState?.() ?? createEmptyAppPageRenderObservationState();
|
|
176
|
+
const htmlRenderObservation = options.createHtmlRenderObservation?.({
|
|
177
|
+
cacheTags: pageTags,
|
|
178
|
+
state: observationState
|
|
179
|
+
});
|
|
180
|
+
const rscRenderObservation = options.createRscRenderObservation?.({
|
|
181
|
+
cacheTags: pageTags,
|
|
182
|
+
state: observationState
|
|
183
|
+
});
|
|
184
|
+
const writes = [options.isrSet(htmlKey, buildAppPageCacheValue(cachedHtml, void 0, 200, htmlRenderObservation), cachePolicy.revalidateSeconds, pageTags, cachePolicy.expireSeconds)];
|
|
185
|
+
if (options.capturedRscDataPromise) writes.push(options.capturedRscDataPromise.then((rscData) => options.isrSet(rscKey, buildAppPageCacheValue("", rscData, 200, rscRenderObservation), cachePolicy.revalidateSeconds, pageTags, cachePolicy.expireSeconds)));
|
|
175
186
|
await Promise.all(writes);
|
|
176
187
|
options.isrDebug?.("HTML cache written", htmlKey);
|
|
177
188
|
} catch (cacheError) {
|
|
@@ -217,7 +228,13 @@ function scheduleAppPageRscCacheWrite(options) {
|
|
|
217
228
|
options.isrDebug?.("RSC cache write skipped (no cache policy)", rscKey);
|
|
218
229
|
return;
|
|
219
230
|
}
|
|
220
|
-
|
|
231
|
+
const pageTags = options.getPageTags();
|
|
232
|
+
const observationState = options.consumeRenderObservationState?.() ?? createEmptyAppPageRenderObservationState();
|
|
233
|
+
const rscRenderObservation = options.createRscRenderObservation?.({
|
|
234
|
+
cacheTags: pageTags,
|
|
235
|
+
state: observationState
|
|
236
|
+
});
|
|
237
|
+
await options.isrSet(rscKey, buildAppPageCacheValue("", rscData, 200, rscRenderObservation), cachePolicy.revalidateSeconds, pageTags, cachePolicy.expireSeconds);
|
|
221
238
|
options.isrDebug?.("RSC cache written", rscKey);
|
|
222
239
|
} catch (cacheError) {
|
|
223
240
|
console.error("[vinext] ISR RSC cache write error:", cacheError);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-page-cache.js","names":[],"sources":["../../src/server/app-page-cache.ts"],"sourcesContent":["import type { CachedAppPageValue, CacheControlMetadata } from \"vinext/shims/cache\";\nimport { VINEXT_RSC_VARY_HEADER } from \"./app-rsc-cache-busting.js\";\nimport { buildCachedRevalidateCacheControl } from \"./cache-control.js\";\nimport { VINEXT_CACHE_HEADER, VINEXT_MOUNTED_SLOTS_HEADER } from \"./headers.js\";\nimport { buildAppPageCacheValue, type ISRCacheEntry } from \"./isr-cache.js\";\nimport { mergeMiddlewareResponseHeaders } from \"./middleware-response-headers.js\";\nimport { readStreamAsText } from \"../utils/text-stream.js\";\nimport { encodeCacheTag } from \"../utils/encode-cache-tag.js\";\nimport type { AppRscRenderMode } from \"./app-rsc-render-mode.js\";\n\ntype AppPageDebugLogger = (event: string, detail: string) => void;\ntype AppPageCacheGetter = (key: string) => Promise<ISRCacheEntry | null>;\ntype AppPageCacheSetter = (\n key: string,\n data: CachedAppPageValue,\n revalidateSeconds: number,\n tags: string[],\n expireSeconds?: number,\n) => Promise<void>;\ntype AppPageBackgroundRegenerator = (key: string, renderFn: () => Promise<void>) => void;\ntype AppPageRequestCacheLife = {\n revalidate?: number;\n expire?: number;\n};\n\ntype AppPageCacheRenderResult = {\n cacheControl?: CacheControlMetadata;\n html: string;\n rscData: ArrayBuffer;\n tags: string[];\n};\n\ntype BuildAppPageCachedResponseOptions = {\n cacheControl?: CacheControlMetadata;\n cacheState: \"HIT\" | \"STALE\";\n expireSeconds?: number;\n isRscRequest: boolean;\n middlewareHeaders?: Headers | null;\n middlewareStatus?: number | null;\n mountedSlotsHeader?: string | null;\n revalidateSeconds: number;\n};\n\ntype ReadAppPageCacheResponseOptions = {\n cleanPathname: string;\n clearRequestContext: () => void;\n isRscRequest: boolean;\n isrDebug?: AppPageDebugLogger;\n isrGet: AppPageCacheGetter;\n isrHtmlKey: (pathname: string) => string;\n isrRscKey: (\n pathname: string,\n mountedSlotsHeader?: string | null,\n renderMode?: AppRscRenderMode,\n ) => string;\n isrSet: AppPageCacheSetter;\n middlewareHeaders?: Headers | null;\n middlewareStatus?: number | null;\n mountedSlotsHeader?: string | null;\n renderMode?: AppRscRenderMode;\n expireSeconds?: number;\n revalidateSeconds: number;\n renderFreshPageForCache: () => Promise<AppPageCacheRenderResult>;\n scheduleBackgroundRegeneration: AppPageBackgroundRegenerator;\n};\n\ntype FinalizeAppPageHtmlCacheResponseOptions = {\n capturedDynamicUsageBeforeContextCleanup?: () => boolean;\n capturedRscDataPromise: Promise<ArrayBuffer> | null;\n cleanPathname: string;\n consumeDynamicUsage: () => boolean;\n getPageTags: () => string[];\n getRequestCacheLife?: () => AppPageRequestCacheLife | null;\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 preserveClientResponseHeaders?: boolean;\n expireSeconds?: number;\n revalidateSeconds: number | null;\n waitUntil?: (promise: Promise<void>) => void;\n};\n\ntype ScheduleAppPageRscCacheWriteOptions = {\n capturedRscDataPromise: Promise<ArrayBuffer> | null;\n cleanPathname: string;\n consumeDynamicUsage: () => boolean;\n dynamicUsedDuringBuild: boolean;\n getPageTags: () => string[];\n getRequestCacheLife?: () => AppPageRequestCacheLife | null;\n isrDebug?: AppPageDebugLogger;\n isrRscKey: (\n pathname: string,\n mountedSlotsHeader?: string | null,\n renderMode?: AppRscRenderMode,\n ) => string;\n isrSet: AppPageCacheSetter;\n mountedSlotsHeader?: string | null;\n renderMode?: AppRscRenderMode;\n preserveClientResponseHeaders?: boolean;\n expireSeconds?: number;\n revalidateSeconds: number | null;\n waitUntil?: (promise: Promise<void>) => void;\n};\n\nconst NO_STORE_CACHE_CONTROL = \"no-store, must-revalidate\";\n\nexport function buildAppPageCacheTags(pathname: string, extraTags: readonly string[]): string[] {\n const tags = [pathname, `_N_T_${pathname}`, \"_N_T_/layout\"];\n const segments = pathname.split(\"/\");\n let built = \"\";\n for (let index = 1; index < segments.length; index++) {\n const segment = segments[index];\n if (segment) {\n built += `/${segment}`;\n tags.push(`_N_T_${built}/layout`);\n }\n }\n\n tags.push(`_N_T_${built}/page`);\n for (const tag of extraTags) {\n if (!tags.includes(tag)) {\n tags.push(tag);\n }\n }\n // Canonicalise to ASCII-safe form so path-derived tags from non-ASCII\n // pathnames match what `revalidatePath`/`revalidateTag` produce after\n // their own encoding pass.\n return tags.map(encodeCacheTag);\n}\n\nfunction buildAppPageCacheControl(\n cacheState: BuildAppPageCachedResponseOptions[\"cacheState\"],\n revalidateSeconds: number,\n expireSeconds?: number,\n): string {\n return buildCachedRevalidateCacheControl(cacheState, revalidateSeconds, expireSeconds);\n}\n\nfunction buildAppPageCachedHeaders(options: {\n cacheControl: string;\n cacheState: BuildAppPageCachedResponseOptions[\"cacheState\"];\n contentType: string;\n middlewareHeaders?: Headers | null;\n mountedSlotsHeader?: string | null;\n}): Headers {\n const headers = new Headers({\n \"Cache-Control\": options.cacheControl,\n \"Content-Type\": options.contentType,\n Vary: VINEXT_RSC_VARY_HEADER,\n [VINEXT_CACHE_HEADER]: options.cacheState,\n });\n\n if (options.mountedSlotsHeader) {\n headers.set(VINEXT_MOUNTED_SLOTS_HEADER, options.mountedSlotsHeader);\n }\n\n mergeMiddlewareResponseHeaders(headers, options.middlewareHeaders ?? null);\n return headers;\n}\n\nfunction getCachedAppPageValue(entry: ISRCacheEntry | null): CachedAppPageValue | null {\n return entry?.value.value && entry.value.value.kind === \"APP_PAGE\" ? entry.value.value : null;\n}\n\nfunction resolveAppPageCacheWritePolicy(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 expireSeconds = requestCacheLife.expire;\n }\n\n if (revalidateSeconds === null || revalidateSeconds <= 0 || !Number.isFinite(revalidateSeconds)) {\n return null;\n }\n\n return { expireSeconds, revalidateSeconds };\n}\n\nexport function buildAppPageCachedResponse(\n cachedValue: CachedAppPageValue,\n options: BuildAppPageCachedResponseOptions,\n): Response | null {\n // Preserve the legacy fallback semantics from the generated entry: invalid\n // falsy statuses still fall back to 200 rather than being forwarded through.\n const status = options.middlewareStatus ?? (cachedValue.status || 200);\n const revalidateSeconds = options.cacheControl?.revalidate ?? options.revalidateSeconds;\n const expireSeconds =\n options.cacheControl === undefined\n ? undefined\n : (options.cacheControl.expire ?? options.expireSeconds);\n const cacheControl = buildAppPageCacheControl(\n options.cacheState,\n revalidateSeconds,\n expireSeconds,\n );\n if (options.isRscRequest) {\n if (!cachedValue.rscData) {\n return null;\n }\n\n const rscHeaders = buildAppPageCachedHeaders({\n cacheControl,\n cacheState: options.cacheState,\n contentType: \"text/x-component; charset=utf-8\",\n middlewareHeaders: options.middlewareHeaders,\n mountedSlotsHeader: options.mountedSlotsHeader,\n });\n\n return new Response(cachedValue.rscData, {\n status,\n headers: rscHeaders,\n });\n }\n\n if (typeof cachedValue.html !== \"string\" || cachedValue.html.length === 0) {\n return null;\n }\n\n const htmlHeaders = buildAppPageCachedHeaders({\n cacheControl,\n cacheState: options.cacheState,\n contentType: \"text/html; charset=utf-8\",\n middlewareHeaders: options.middlewareHeaders,\n });\n\n return new Response(cachedValue.html, {\n status,\n headers: htmlHeaders,\n });\n}\n\nexport async function readAppPageCacheResponse(\n options: ReadAppPageCacheResponseOptions,\n): Promise<Response | null> {\n const isrKey = options.isRscRequest\n ? options.isrRscKey(options.cleanPathname, options.mountedSlotsHeader, options.renderMode)\n : options.isrHtmlKey(options.cleanPathname);\n\n try {\n const cached = await options.isrGet(isrKey);\n const cachedValue = getCachedAppPageValue(cached);\n\n if (cachedValue && !cached?.isStale) {\n const hitResponse = buildAppPageCachedResponse(cachedValue, {\n cacheState: \"HIT\",\n cacheControl: cached?.value.cacheControl,\n expireSeconds: options.expireSeconds,\n isRscRequest: options.isRscRequest,\n middlewareHeaders: options.middlewareHeaders,\n middlewareStatus: options.middlewareStatus,\n mountedSlotsHeader: options.mountedSlotsHeader,\n revalidateSeconds: options.revalidateSeconds,\n });\n\n if (hitResponse) {\n options.isrDebug?.(\n options.isRscRequest ? \"HIT (RSC)\" : \"HIT (HTML)\",\n options.cleanPathname,\n );\n options.clearRequestContext();\n return hitResponse;\n }\n\n options.isrDebug?.(\"MISS (empty cached entry)\", options.cleanPathname);\n }\n\n if (cached?.isStale && cachedValue) {\n const regenerationKey = options.isRscRequest\n ? options.isrRscKey(options.cleanPathname, options.mountedSlotsHeader, options.renderMode)\n : options.isrHtmlKey(options.cleanPathname);\n\n // Preserve the legacy behavior from the inline generator: stale entries\n // still trigger background regeneration even if this request cannot use\n // the stale payload and will fall through to a fresh render.\n options.scheduleBackgroundRegeneration(regenerationKey, async () => {\n const revalidatedPage = await options.renderFreshPageForCache();\n const revalidateSeconds =\n revalidatedPage.cacheControl?.revalidate ?? options.revalidateSeconds;\n const expireSeconds = revalidatedPage.cacheControl?.expire ?? options.expireSeconds;\n const writes = [\n options.isrSet(\n options.isrRscKey(\n options.cleanPathname,\n options.mountedSlotsHeader,\n options.renderMode,\n ),\n buildAppPageCacheValue(\"\", revalidatedPage.rscData, 200),\n revalidateSeconds,\n revalidatedPage.tags,\n expireSeconds,\n ),\n ];\n\n if (!options.isRscRequest) {\n // HTML cache is slot-state-independent (canonical), so only refresh it\n // during HTML-triggered regens. RSC-triggered regens only update the\n // requesting client's RSC slot variant; a stale HTML cache entry will\n // be regenerated independently by the next full-page HTML request.\n writes.push(\n options.isrSet(\n options.isrHtmlKey(options.cleanPathname),\n buildAppPageCacheValue(revalidatedPage.html, undefined, 200),\n revalidateSeconds,\n revalidatedPage.tags,\n expireSeconds,\n ),\n );\n }\n\n await Promise.all(writes);\n options.isrDebug?.(\"regen complete\", options.cleanPathname);\n });\n\n const staleResponse = buildAppPageCachedResponse(cachedValue, {\n cacheState: \"STALE\",\n cacheControl: cached.value.cacheControl,\n expireSeconds: options.expireSeconds,\n isRscRequest: options.isRscRequest,\n middlewareHeaders: options.middlewareHeaders,\n middlewareStatus: options.middlewareStatus,\n mountedSlotsHeader: options.mountedSlotsHeader,\n revalidateSeconds: options.revalidateSeconds,\n });\n\n if (staleResponse) {\n options.isrDebug?.(\n options.isRscRequest ? \"STALE (RSC)\" : \"STALE (HTML)\",\n options.cleanPathname,\n );\n options.clearRequestContext();\n return staleResponse;\n }\n\n options.isrDebug?.(\"STALE MISS (empty stale entry)\", options.cleanPathname);\n }\n\n if (!cached) {\n options.isrDebug?.(\"MISS (no cache entry)\", options.cleanPathname);\n }\n } catch (isrReadError) {\n console.error(\"[vinext] ISR cache read error:\", isrReadError);\n }\n\n return null;\n}\n\nexport function finalizeAppPageHtmlCacheResponse(\n response: Response,\n options: FinalizeAppPageHtmlCacheResponseOptions,\n): Response {\n if (!response.body) {\n return response;\n }\n\n const [streamForClient, streamForCache] = response.body.tee();\n const htmlKey = options.isrHtmlKey(options.cleanPathname);\n const rscKey = options.isrRscKey(options.cleanPathname, null);\n const clientHeaders = new Headers(response.headers);\n if (options.preserveClientResponseHeaders !== true) {\n // HTML Server Components can access request APIs while the stream is being\n // consumed. Until that late dynamic check finishes, downstream shared caches\n // must not cache a response whose ISR policy was known before streaming.\n clientHeaders.set(\"Cache-Control\", NO_STORE_CACHE_CONTROL);\n clientHeaders.set(VINEXT_CACHE_HEADER, \"MISS\");\n }\n\n const cachePromise = (async () => {\n try {\n const cachedHtml = await readStreamAsText(streamForCache);\n\n if (\n options.capturedDynamicUsageBeforeContextCleanup?.() === true ||\n options.consumeDynamicUsage()\n ) {\n options.isrDebug?.(\"HTML cache write skipped (dynamic usage during render)\", htmlKey);\n return;\n }\n\n const cachePolicy = resolveAppPageCacheWritePolicy({\n expireSeconds: options.expireSeconds,\n requestCacheLife: options.getRequestCacheLife?.(),\n revalidateSeconds: options.revalidateSeconds,\n });\n if (!cachePolicy) {\n options.isrDebug?.(\"HTML cache write skipped (no cache policy)\", htmlKey);\n return;\n }\n\n const pageTags = options.getPageTags();\n const writes = [\n options.isrSet(\n htmlKey,\n buildAppPageCacheValue(cachedHtml, undefined, 200),\n cachePolicy.revalidateSeconds,\n pageTags,\n cachePolicy.expireSeconds,\n ),\n ];\n\n if (options.capturedRscDataPromise) {\n writes.push(\n options.capturedRscDataPromise.then((rscData) =>\n options.isrSet(\n rscKey,\n buildAppPageCacheValue(\"\", rscData, 200),\n cachePolicy.revalidateSeconds,\n pageTags,\n cachePolicy.expireSeconds,\n ),\n ),\n );\n }\n\n await Promise.all(writes);\n options.isrDebug?.(\"HTML cache written\", htmlKey);\n } catch (cacheError) {\n console.error(\"[vinext] ISR cache write error:\", cacheError);\n }\n })();\n\n options.waitUntil?.(cachePromise);\n\n return new Response(streamForClient, {\n status: response.status,\n statusText: response.statusText,\n headers: clientHeaders,\n });\n}\n\nexport function finalizeAppPageRscCacheResponse(\n response: Response,\n options: ScheduleAppPageRscCacheWriteOptions,\n): Response {\n const didSchedule = scheduleAppPageRscCacheWrite(options);\n if (!didSchedule) {\n return response;\n }\n\n if (options.preserveClientResponseHeaders === true) {\n return response;\n }\n\n const clientHeaders = new Headers(response.headers);\n // RSC payloads are also streamed lazily. Until the captured stream proves no\n // late request API was used, the client-facing MISS response must not enter a\n // shared cache when the ISR policy was known before streaming.\n clientHeaders.set(\"Cache-Control\", NO_STORE_CACHE_CONTROL);\n clientHeaders.set(VINEXT_CACHE_HEADER, \"MISS\");\n\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers: clientHeaders,\n });\n}\n\nexport function scheduleAppPageRscCacheWrite(\n options: ScheduleAppPageRscCacheWriteOptions,\n): boolean {\n const capturedRscDataPromise = options.capturedRscDataPromise;\n if (!capturedRscDataPromise || options.dynamicUsedDuringBuild) {\n return false;\n }\n\n const rscKey = options.isrRscKey(\n options.cleanPathname,\n options.mountedSlotsHeader,\n options.renderMode,\n );\n const cachePromise = (async () => {\n try {\n const rscData = await capturedRscDataPromise;\n\n // Two-phase dynamic detection:\n // 1. dynamicUsedDuringBuild catches searchParams-driven opt-in before the\n // RSC response is sent.\n // 2. consumeDynamicUsage() here catches APIs that fire while the RSC\n // stream is consumed (headers(), cookies(), noStore()).\n if (options.consumeDynamicUsage()) {\n options.isrDebug?.(\"RSC cache write skipped (dynamic usage during render)\", rscKey);\n return;\n }\n\n const cachePolicy = resolveAppPageCacheWritePolicy({\n expireSeconds: options.expireSeconds,\n requestCacheLife: options.getRequestCacheLife?.(),\n revalidateSeconds: options.revalidateSeconds,\n });\n if (!cachePolicy) {\n options.isrDebug?.(\"RSC cache write skipped (no cache policy)\", rscKey);\n return;\n }\n\n await options.isrSet(\n rscKey,\n buildAppPageCacheValue(\"\", rscData, 200),\n cachePolicy.revalidateSeconds,\n options.getPageTags(),\n cachePolicy.expireSeconds,\n );\n options.isrDebug?.(\"RSC cache written\", rscKey);\n } catch (cacheError) {\n console.error(\"[vinext] ISR RSC cache write error:\", cacheError);\n }\n })();\n\n options.waitUntil?.(cachePromise);\n return true;\n}\n"],"mappings":";;;;;;;;AA6GA,MAAM,yBAAyB;AAE/B,SAAgB,sBAAsB,UAAkB,WAAwC;CAC9F,MAAM,OAAO;EAAC;EAAU,QAAQ;EAAY;EAAe;CAC3D,MAAM,WAAW,SAAS,MAAM,IAAI;CACpC,IAAI,QAAQ;CACZ,KAAK,IAAI,QAAQ,GAAG,QAAQ,SAAS,QAAQ,SAAS;EACpD,MAAM,UAAU,SAAS;EACzB,IAAI,SAAS;GACX,SAAS,IAAI;GACb,KAAK,KAAK,QAAQ,MAAM,SAAS;;;CAIrC,KAAK,KAAK,QAAQ,MAAM,OAAO;CAC/B,KAAK,MAAM,OAAO,WAChB,IAAI,CAAC,KAAK,SAAS,IAAI,EACrB,KAAK,KAAK,IAAI;CAMlB,OAAO,KAAK,IAAI,eAAe;;AAGjC,SAAS,yBACP,YACA,mBACA,eACQ;CACR,OAAO,kCAAkC,YAAY,mBAAmB,cAAc;;AAGxF,SAAS,0BAA0B,SAMvB;CACV,MAAM,UAAU,IAAI,QAAQ;EAC1B,iBAAiB,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QAAQ;CACvC,IAAI,CAAC,0BAA0B,QAAQ,wBACrC,OAAO;CAGT,MAAM,SAAS,QAAQ,UACrB,QAAQ,eACR,QAAQ,oBACR,QAAQ,WACT;CACD,MAAM,gBAAgB,YAAY;EAChC,IAAI;GACF,MAAM,UAAU,MAAM;GAOtB,IAAI,QAAQ,qBAAqB,EAAE;IACjC,QAAQ,WAAW,yDAAyD,OAAO;IACnF;;GAGF,MAAM,cAAc,+BAA+B;IACjD,eAAe,QAAQ;IACvB,kBAAkB,QAAQ,uBAAuB;IACjD,mBAAmB,QAAQ;IAC5B,CAAC;GACF,IAAI,CAAC,aAAa;IAChB,QAAQ,WAAW,6CAA6C,OAAO;IACvE;;GAGF,MAAM,QAAQ,OACZ,QACA,uBAAuB,IAAI,SAAS,IAAI,EACxC,YAAY,mBACZ,QAAQ,aAAa,EACrB,YAAY,cACb;GACD,QAAQ,WAAW,qBAAqB,OAAO;WACxC,YAAY;GACnB,QAAQ,MAAM,uCAAuC,WAAW;;KAEhE;CAEJ,QAAQ,YAAY,aAAa;CACjC,OAAO"}
|
|
1
|
+
{"version":3,"file":"app-page-cache.js","names":[],"sources":["../../src/server/app-page-cache.ts"],"sourcesContent":["import type { CachedAppPageValue, CacheControlMetadata } from \"vinext/shims/cache\";\nimport {\n VINEXT_RSC_CONTENT_TYPE,\n VINEXT_RSC_VARY_HEADER,\n applyRscCompatibilityIdHeader,\n} from \"./app-rsc-cache-busting.js\";\nimport { buildCachedRevalidateCacheControl } from \"./cache-control.js\";\nimport { VINEXT_CACHE_HEADER, VINEXT_MOUNTED_SLOTS_HEADER } from \"./headers.js\";\nimport { buildAppPageCacheValue, type ISRCacheEntry } from \"./isr-cache.js\";\nimport { mergeMiddlewareResponseHeaders } from \"./middleware-response-headers.js\";\nimport { readStreamAsText } from \"../utils/text-stream.js\";\nimport { encodeCacheTag } from \"../utils/encode-cache-tag.js\";\nimport type { AppRscRenderMode } from \"./app-rsc-render-mode.js\";\nimport {\n createEmptyAppPageRenderObservationState,\n type AppPageRenderObservationState,\n} from \"./app-page-render-observation.js\";\nimport type { RenderObservation } from \"./cache-proof.js\";\n\ntype AppPageDebugLogger = (event: string, detail: string) => void;\ntype AppPageCacheGetter = (key: string) => Promise<ISRCacheEntry | null>;\ntype AppPageCacheSetter = (\n key: string,\n data: CachedAppPageValue,\n revalidateSeconds: number,\n tags: string[],\n expireSeconds?: number,\n) => Promise<void>;\ntype AppPageBackgroundRegenerator = (key: string, renderFn: () => Promise<void>) => void;\ntype AppPageRequestCacheLife = {\n revalidate?: number;\n expire?: number;\n};\n\ntype BuildAppPageCacheRenderObservation = (input: {\n cacheTags: readonly string[];\n state: AppPageRenderObservationState;\n}) => RenderObservation;\n\ntype AppPageCacheRenderResult = {\n cacheControl?: CacheControlMetadata;\n html: string;\n htmlRenderObservation?: RenderObservation;\n rscData: ArrayBuffer;\n rscRenderObservation?: RenderObservation;\n tags: string[];\n};\n\ntype BuildAppPageCachedResponseOptions = {\n cacheControl?: CacheControlMetadata;\n cacheState: \"HIT\" | \"STALE\";\n expireSeconds?: number;\n isRscRequest: boolean;\n middlewareHeaders?: Headers | null;\n middlewareStatus?: number | null;\n mountedSlotsHeader?: string | null;\n revalidateSeconds: number;\n};\n\ntype ReadAppPageCacheResponseOptions = {\n cleanPathname: string;\n clearRequestContext: () => void;\n isRscRequest: boolean;\n isrDebug?: AppPageDebugLogger;\n isrGet: AppPageCacheGetter;\n isrHtmlKey: (pathname: string) => string;\n isrRscKey: (\n pathname: string,\n mountedSlotsHeader?: string | null,\n renderMode?: AppRscRenderMode,\n ) => string;\n isrSet: AppPageCacheSetter;\n middlewareHeaders?: Headers | null;\n middlewareStatus?: number | null;\n mountedSlotsHeader?: string | null;\n renderMode?: AppRscRenderMode;\n expireSeconds?: number;\n revalidateSeconds: number;\n renderFreshPageForCache: () => Promise<AppPageCacheRenderResult>;\n scheduleBackgroundRegeneration: AppPageBackgroundRegenerator;\n};\n\ntype FinalizeAppPageHtmlCacheResponseOptions = {\n capturedDynamicUsageBeforeContextCleanup?: () => boolean;\n capturedRscDataPromise: Promise<ArrayBuffer> | null;\n cleanPathname: string;\n consumeDynamicUsage: () => boolean;\n consumeRenderObservationState?: () => AppPageRenderObservationState;\n createHtmlRenderObservation?: BuildAppPageCacheRenderObservation;\n createRscRenderObservation?: BuildAppPageCacheRenderObservation;\n getPageTags: () => string[];\n getRequestCacheLife?: () => AppPageRequestCacheLife | null;\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 preserveClientResponseHeaders?: boolean;\n expireSeconds?: number;\n revalidateSeconds: number | null;\n waitUntil?: (promise: Promise<void>) => void;\n};\n\ntype ScheduleAppPageRscCacheWriteOptions = {\n capturedRscDataPromise: Promise<ArrayBuffer> | null;\n cleanPathname: string;\n consumeDynamicUsage: () => boolean;\n consumeRenderObservationState?: () => AppPageRenderObservationState;\n createRscRenderObservation?: BuildAppPageCacheRenderObservation;\n dynamicUsedDuringBuild: boolean;\n getPageTags: () => string[];\n getRequestCacheLife?: () => AppPageRequestCacheLife | null;\n isrDebug?: AppPageDebugLogger;\n isrRscKey: (\n pathname: string,\n mountedSlotsHeader?: string | null,\n renderMode?: AppRscRenderMode,\n ) => string;\n isrSet: AppPageCacheSetter;\n mountedSlotsHeader?: string | null;\n renderMode?: AppRscRenderMode;\n preserveClientResponseHeaders?: boolean;\n expireSeconds?: number;\n revalidateSeconds: number | null;\n waitUntil?: (promise: Promise<void>) => void;\n};\n\nconst NO_STORE_CACHE_CONTROL = \"no-store, must-revalidate\";\n\nexport function buildAppPageCacheTags(pathname: string, extraTags: readonly string[]): string[] {\n const tags = [pathname, `_N_T_${pathname}`, \"_N_T_/layout\"];\n const segments = pathname.split(\"/\");\n let built = \"\";\n for (let index = 1; index < segments.length; index++) {\n const segment = segments[index];\n if (segment) {\n built += `/${segment}`;\n tags.push(`_N_T_${built}/layout`);\n }\n }\n\n tags.push(`_N_T_${built}/page`);\n for (const tag of extraTags) {\n if (!tags.includes(tag)) {\n tags.push(tag);\n }\n }\n // Canonicalise to ASCII-safe form so path-derived tags from non-ASCII\n // pathnames match what `revalidatePath`/`revalidateTag` produce after\n // their own encoding pass.\n return tags.map(encodeCacheTag);\n}\n\nfunction buildAppPageCacheControl(\n cacheState: BuildAppPageCachedResponseOptions[\"cacheState\"],\n revalidateSeconds: number,\n expireSeconds?: number,\n): string {\n return buildCachedRevalidateCacheControl(cacheState, revalidateSeconds, expireSeconds);\n}\n\nfunction buildAppPageCachedHeaders(options: {\n cacheControl: string;\n cacheState: BuildAppPageCachedResponseOptions[\"cacheState\"];\n contentType: string;\n middlewareHeaders?: Headers | null;\n mountedSlotsHeader?: string | null;\n}): Headers {\n const headers = new Headers({\n \"Cache-Control\": options.cacheControl,\n \"Content-Type\": options.contentType,\n Vary: VINEXT_RSC_VARY_HEADER,\n [VINEXT_CACHE_HEADER]: options.cacheState,\n });\n\n if (options.mountedSlotsHeader) {\n headers.set(VINEXT_MOUNTED_SLOTS_HEADER, options.mountedSlotsHeader);\n }\n\n mergeMiddlewareResponseHeaders(headers, options.middlewareHeaders ?? null);\n return headers;\n}\n\nfunction getCachedAppPageValue(entry: ISRCacheEntry | null): CachedAppPageValue | null {\n return entry?.value.value && entry.value.value.kind === \"APP_PAGE\" ? entry.value.value : null;\n}\n\nfunction resolveAppPageCacheWritePolicy(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 expireSeconds = requestCacheLife.expire;\n }\n\n if (revalidateSeconds === null || revalidateSeconds <= 0 || !Number.isFinite(revalidateSeconds)) {\n return null;\n }\n\n return { expireSeconds, revalidateSeconds };\n}\n\nexport function buildAppPageCachedResponse(\n cachedValue: CachedAppPageValue,\n options: BuildAppPageCachedResponseOptions,\n): Response | null {\n // Preserve the legacy fallback semantics from the generated entry: invalid\n // falsy statuses still fall back to 200 rather than being forwarded through.\n const status = options.middlewareStatus ?? (cachedValue.status || 200);\n const revalidateSeconds = options.cacheControl?.revalidate ?? options.revalidateSeconds;\n const expireSeconds =\n options.cacheControl === undefined\n ? undefined\n : (options.cacheControl.expire ?? options.expireSeconds);\n const cacheControl = buildAppPageCacheControl(\n options.cacheState,\n revalidateSeconds,\n expireSeconds,\n );\n if (options.isRscRequest) {\n if (!cachedValue.rscData) {\n return null;\n }\n\n const rscHeaders = buildAppPageCachedHeaders({\n cacheControl,\n cacheState: options.cacheState,\n contentType: VINEXT_RSC_CONTENT_TYPE,\n middlewareHeaders: options.middlewareHeaders,\n mountedSlotsHeader: options.mountedSlotsHeader,\n });\n applyRscCompatibilityIdHeader(rscHeaders);\n\n return new Response(cachedValue.rscData, {\n status,\n headers: rscHeaders,\n });\n }\n\n if (typeof cachedValue.html !== \"string\" || cachedValue.html.length === 0) {\n return null;\n }\n\n const htmlHeaders = buildAppPageCachedHeaders({\n cacheControl,\n cacheState: options.cacheState,\n contentType: \"text/html; charset=utf-8\",\n middlewareHeaders: options.middlewareHeaders,\n });\n\n return new Response(cachedValue.html, {\n status,\n headers: htmlHeaders,\n });\n}\n\nexport async function readAppPageCacheResponse(\n options: ReadAppPageCacheResponseOptions,\n): Promise<Response | null> {\n const isrKey = options.isRscRequest\n ? options.isrRscKey(options.cleanPathname, options.mountedSlotsHeader, options.renderMode)\n : options.isrHtmlKey(options.cleanPathname);\n\n try {\n const cached = await options.isrGet(isrKey);\n const cachedValue = getCachedAppPageValue(cached);\n\n if (cachedValue && !cached?.isStale) {\n const hitResponse = buildAppPageCachedResponse(cachedValue, {\n cacheState: \"HIT\",\n cacheControl: cached?.value.cacheControl,\n expireSeconds: options.expireSeconds,\n isRscRequest: options.isRscRequest,\n middlewareHeaders: options.middlewareHeaders,\n middlewareStatus: options.middlewareStatus,\n mountedSlotsHeader: options.mountedSlotsHeader,\n revalidateSeconds: options.revalidateSeconds,\n });\n\n if (hitResponse) {\n options.isrDebug?.(\n options.isRscRequest ? \"HIT (RSC)\" : \"HIT (HTML)\",\n options.cleanPathname,\n );\n options.clearRequestContext();\n return hitResponse;\n }\n\n options.isrDebug?.(\"MISS (empty cached entry)\", options.cleanPathname);\n }\n\n if (cached?.isStale && cachedValue) {\n const regenerationKey = options.isRscRequest\n ? options.isrRscKey(options.cleanPathname, options.mountedSlotsHeader, options.renderMode)\n : options.isrHtmlKey(options.cleanPathname);\n\n // Preserve the legacy behavior from the inline generator: stale entries\n // still trigger background regeneration even if this request cannot use\n // the stale payload and will fall through to a fresh render.\n options.scheduleBackgroundRegeneration(regenerationKey, async () => {\n const revalidatedPage = await options.renderFreshPageForCache();\n const revalidateSeconds =\n revalidatedPage.cacheControl?.revalidate ?? options.revalidateSeconds;\n const expireSeconds = revalidatedPage.cacheControl?.expire ?? options.expireSeconds;\n const writes = [\n options.isrSet(\n options.isrRscKey(\n options.cleanPathname,\n options.mountedSlotsHeader,\n options.renderMode,\n ),\n buildAppPageCacheValue(\n \"\",\n revalidatedPage.rscData,\n 200,\n revalidatedPage.rscRenderObservation,\n ),\n revalidateSeconds,\n revalidatedPage.tags,\n expireSeconds,\n ),\n ];\n\n if (!options.isRscRequest) {\n // HTML cache is slot-state-independent (canonical), so only refresh it\n // during HTML-triggered regens. RSC-triggered regens only update the\n // requesting client's RSC slot variant; a stale HTML cache entry will\n // be regenerated independently by the next full-page HTML request.\n writes.push(\n options.isrSet(\n options.isrHtmlKey(options.cleanPathname),\n buildAppPageCacheValue(\n revalidatedPage.html,\n undefined,\n 200,\n revalidatedPage.htmlRenderObservation,\n ),\n revalidateSeconds,\n revalidatedPage.tags,\n expireSeconds,\n ),\n );\n }\n\n await Promise.all(writes);\n options.isrDebug?.(\"regen complete\", options.cleanPathname);\n });\n\n const staleResponse = buildAppPageCachedResponse(cachedValue, {\n cacheState: \"STALE\",\n cacheControl: cached.value.cacheControl,\n expireSeconds: options.expireSeconds,\n isRscRequest: options.isRscRequest,\n middlewareHeaders: options.middlewareHeaders,\n middlewareStatus: options.middlewareStatus,\n mountedSlotsHeader: options.mountedSlotsHeader,\n revalidateSeconds: options.revalidateSeconds,\n });\n\n if (staleResponse) {\n options.isrDebug?.(\n options.isRscRequest ? \"STALE (RSC)\" : \"STALE (HTML)\",\n options.cleanPathname,\n );\n options.clearRequestContext();\n return staleResponse;\n }\n\n options.isrDebug?.(\"STALE MISS (empty stale entry)\", options.cleanPathname);\n }\n\n if (!cached) {\n options.isrDebug?.(\"MISS (no cache entry)\", options.cleanPathname);\n }\n } catch (isrReadError) {\n console.error(\"[vinext] ISR cache read error:\", isrReadError);\n }\n\n return null;\n}\n\nexport function finalizeAppPageHtmlCacheResponse(\n response: Response,\n options: FinalizeAppPageHtmlCacheResponseOptions,\n): Response {\n if (!response.body) {\n return response;\n }\n\n const [streamForClient, streamForCache] = response.body.tee();\n const htmlKey = options.isrHtmlKey(options.cleanPathname);\n const rscKey = options.isrRscKey(options.cleanPathname, null);\n const clientHeaders = new Headers(response.headers);\n if (options.preserveClientResponseHeaders !== true) {\n // HTML Server Components can access request APIs while the stream is being\n // consumed. Until that late dynamic check finishes, downstream shared caches\n // must not cache a response whose ISR policy was known before streaming.\n clientHeaders.set(\"Cache-Control\", NO_STORE_CACHE_CONTROL);\n clientHeaders.set(VINEXT_CACHE_HEADER, \"MISS\");\n }\n\n const cachePromise = (async () => {\n try {\n const cachedHtml = await readStreamAsText(streamForCache);\n\n if (\n options.capturedDynamicUsageBeforeContextCleanup?.() === true ||\n options.consumeDynamicUsage()\n ) {\n options.isrDebug?.(\"HTML cache write skipped (dynamic usage during render)\", htmlKey);\n return;\n }\n\n const cachePolicy = resolveAppPageCacheWritePolicy({\n expireSeconds: options.expireSeconds,\n requestCacheLife: options.getRequestCacheLife?.(),\n revalidateSeconds: options.revalidateSeconds,\n });\n if (!cachePolicy) {\n options.isrDebug?.(\"HTML cache write skipped (no cache policy)\", htmlKey);\n return;\n }\n\n const pageTags = options.getPageTags();\n // This continuation is scheduled while the request ALS scope is active.\n // It intentionally consumes observation state only after the HTML stream\n // drains, so late Server Component request API usage is included.\n // Consume once: HTML and captured RSC artifacts come from the same render\n // pass, so both cache artifacts share the same observation snapshot.\n const observationState =\n options.consumeRenderObservationState?.() ?? createEmptyAppPageRenderObservationState();\n const htmlRenderObservation = options.createHtmlRenderObservation?.({\n cacheTags: pageTags,\n state: observationState,\n });\n const rscRenderObservation = options.createRscRenderObservation?.({\n cacheTags: pageTags,\n state: observationState,\n });\n const writes = [\n options.isrSet(\n htmlKey,\n buildAppPageCacheValue(cachedHtml, undefined, 200, htmlRenderObservation),\n cachePolicy.revalidateSeconds,\n pageTags,\n cachePolicy.expireSeconds,\n ),\n ];\n\n if (options.capturedRscDataPromise) {\n writes.push(\n options.capturedRscDataPromise.then((rscData) =>\n options.isrSet(\n rscKey,\n buildAppPageCacheValue(\"\", rscData, 200, rscRenderObservation),\n cachePolicy.revalidateSeconds,\n pageTags,\n cachePolicy.expireSeconds,\n ),\n ),\n );\n }\n\n await Promise.all(writes);\n options.isrDebug?.(\"HTML cache written\", htmlKey);\n } catch (cacheError) {\n console.error(\"[vinext] ISR cache write error:\", cacheError);\n }\n })();\n\n options.waitUntil?.(cachePromise);\n\n return new Response(streamForClient, {\n status: response.status,\n statusText: response.statusText,\n headers: clientHeaders,\n });\n}\n\nexport function finalizeAppPageRscCacheResponse(\n response: Response,\n options: ScheduleAppPageRscCacheWriteOptions,\n): Response {\n const didSchedule = scheduleAppPageRscCacheWrite(options);\n if (!didSchedule) {\n return response;\n }\n\n if (options.preserveClientResponseHeaders === true) {\n return response;\n }\n\n const clientHeaders = new Headers(response.headers);\n // RSC payloads are also streamed lazily. Until the captured stream proves no\n // late request API was used, the client-facing MISS response must not enter a\n // shared cache when the ISR policy was known before streaming.\n clientHeaders.set(\"Cache-Control\", NO_STORE_CACHE_CONTROL);\n clientHeaders.set(VINEXT_CACHE_HEADER, \"MISS\");\n\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers: clientHeaders,\n });\n}\n\nexport function scheduleAppPageRscCacheWrite(\n options: ScheduleAppPageRscCacheWriteOptions,\n): boolean {\n const capturedRscDataPromise = options.capturedRscDataPromise;\n if (!capturedRscDataPromise || options.dynamicUsedDuringBuild) {\n return false;\n }\n\n const rscKey = options.isrRscKey(\n options.cleanPathname,\n options.mountedSlotsHeader,\n options.renderMode,\n );\n const cachePromise = (async () => {\n try {\n const rscData = await capturedRscDataPromise;\n\n // Two-phase dynamic detection:\n // 1. dynamicUsedDuringBuild catches searchParams-driven opt-in before the\n // RSC response is sent.\n // 2. consumeDynamicUsage() here catches APIs that fire while the RSC\n // stream is consumed (headers(), cookies(), noStore()).\n if (options.consumeDynamicUsage()) {\n options.isrDebug?.(\"RSC cache write skipped (dynamic usage during render)\", rscKey);\n return;\n }\n\n const cachePolicy = resolveAppPageCacheWritePolicy({\n expireSeconds: options.expireSeconds,\n requestCacheLife: options.getRequestCacheLife?.(),\n revalidateSeconds: options.revalidateSeconds,\n });\n if (!cachePolicy) {\n options.isrDebug?.(\"RSC cache write skipped (no cache policy)\", rscKey);\n return;\n }\n\n const pageTags = options.getPageTags();\n // This continuation is scheduled while the request ALS scope is active.\n // It intentionally consumes observation state only after the captured RSC\n // stream resolves, so late Server Component request API usage is included.\n const observationState =\n options.consumeRenderObservationState?.() ?? createEmptyAppPageRenderObservationState();\n const rscRenderObservation = options.createRscRenderObservation?.({\n cacheTags: pageTags,\n state: observationState,\n });\n await options.isrSet(\n rscKey,\n buildAppPageCacheValue(\"\", rscData, 200, rscRenderObservation),\n cachePolicy.revalidateSeconds,\n pageTags,\n cachePolicy.expireSeconds,\n );\n options.isrDebug?.(\"RSC cache written\", rscKey);\n } catch (cacheError) {\n console.error(\"[vinext] ISR RSC cache write error:\", cacheError);\n }\n })();\n\n options.waitUntil?.(cachePromise);\n return true;\n}\n"],"mappings":";;;;;;;;;AAkIA,MAAM,yBAAyB;AAE/B,SAAgB,sBAAsB,UAAkB,WAAwC;CAC9F,MAAM,OAAO;EAAC;EAAU,QAAQ;EAAY;EAAe;CAC3D,MAAM,WAAW,SAAS,MAAM,IAAI;CACpC,IAAI,QAAQ;CACZ,KAAK,IAAI,QAAQ,GAAG,QAAQ,SAAS,QAAQ,SAAS;EACpD,MAAM,UAAU,SAAS;EACzB,IAAI,SAAS;GACX,SAAS,IAAI;GACb,KAAK,KAAK,QAAQ,MAAM,SAAS;;;CAIrC,KAAK,KAAK,QAAQ,MAAM,OAAO;CAC/B,KAAK,MAAM,OAAO,WAChB,IAAI,CAAC,KAAK,SAAS,IAAI,EACrB,KAAK,KAAK,IAAI;CAMlB,OAAO,KAAK,IAAI,eAAe;;AAGjC,SAAS,yBACP,YACA,mBACA,eACQ;CACR,OAAO,kCAAkC,YAAY,mBAAmB,cAAc;;AAGxF,SAAS,0BAA0B,SAMvB;CACV,MAAM,UAAU,IAAI,QAAQ;EAC1B,iBAAiB,QAAQ;EACzB,gBAAgB,QAAQ;EACxB,MAAM;GACL,sBAAsB,QAAQ;EAChC,CAAC;CAEF,IAAI,QAAQ,oBACV,QAAQ,IAAI,6BAA6B,QAAQ,mBAAmB;CAGtE,+BAA+B,SAAS,QAAQ,qBAAqB,KAAK;CAC1E,OAAO;;AAGT,SAAS,sBAAsB,OAAwD;CACrF,OAAO,OAAO,MAAM,SAAS,MAAM,MAAM,MAAM,SAAS,aAAa,MAAM,MAAM,QAAQ;;AAG3F,SAAS,+BAA+B,SAIyB;CAC/D,IAAI,oBAAoB,QAAQ;CAChC,IAAI,gBAAgB,QAAQ;CAC5B,MAAM,mBAAmB,QAAQ;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AAU,MAAM;GAOtB,IAAI,QAAQ,qBAAqB,EAAE;IACjC,QAAQ,WAAW,yDAAyD,OAAO;IACnF;;GAGF,MAAM,cAAc,+BAA+B;IACjD,eAAe,QAAQ;IACvB,kBAAkB,QAAQ,uBAAuB;IACjD,mBAAmB,QAAQ;IAC5B,CAAC;GACF,IAAI,CAAC,aAAa;IAChB,QAAQ,WAAW,6CAA6C,OAAO;IACvE;;GAGF,MAAM,WAAW,QAAQ,aAAa;GAItC,MAAM,mBACJ,QAAQ,iCAAiC,IAAI,0CAA0C;GACzF,MAAM,uBAAuB,QAAQ,6BAA6B;IAChE,WAAW;IACX,OAAO;IACR,CAAC;GACF,MAAM,QAAQ,OACZ,QACA,uBAAuB,IAAI,SAAS,KAAK,qBAAqB,EAC9D,YAAY,mBACZ,UACA,YAAY,cACb;GACD,QAAQ,WAAW,qBAAqB,OAAO;WACxC,YAAY;GACnB,QAAQ,MAAM,uCAAuC,WAAW;;KAEhE;CAEJ,QAAQ,YAAY,aAAa;CACjC,OAAO"}
|
|
@@ -29,6 +29,7 @@ type AppPageDispatchIntercept<TPage = unknown> = {
|
|
|
29
29
|
interceptLayouts?: readonly AppPageModule[] | null;
|
|
30
30
|
matchedParams: AppPageParams;
|
|
31
31
|
page: TPage;
|
|
32
|
+
slotId?: string | null;
|
|
32
33
|
slotKey: string;
|
|
33
34
|
sourceRouteIndex: number;
|
|
34
35
|
};
|
|
@@ -37,7 +38,9 @@ type AppPageDispatchInterceptOptions<TPage = unknown> = {
|
|
|
37
38
|
interceptLayouts?: readonly AppPageModule[] | null;
|
|
38
39
|
interceptPage: TPage;
|
|
39
40
|
interceptParams: AppPageParams;
|
|
41
|
+
interceptSlotId?: string | null;
|
|
40
42
|
interceptSlotKey: string;
|
|
43
|
+
interceptSourceMatchedUrl?: string | null;
|
|
41
44
|
};
|
|
42
45
|
type AppPageModule = {
|
|
43
46
|
default?: unknown;
|
|
@@ -70,6 +73,8 @@ type DispatchAppPageOptions<TRoute extends AppPageDispatchRoute> = {
|
|
|
70
73
|
fetchCache?: FetchCacheMode | null;
|
|
71
74
|
findIntercept: (pathname: string) => AppPageDispatchIntercept | null;
|
|
72
75
|
formState?: ReactFormState | null;
|
|
76
|
+
actionError?: unknown;
|
|
77
|
+
actionFailed?: boolean;
|
|
73
78
|
generateStaticParams?: ValidateAppPageDynamicParamsOptions["generateStaticParams"];
|
|
74
79
|
getFontLinks: () => string[];
|
|
75
80
|
getFontPreloads: () => AppPageFontPreload[];
|