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
|
@@ -23,7 +23,7 @@ const appPageExecutionPath = resolveEntryPath("../server/app-page-execution.js",
|
|
|
23
23
|
const appFallbackRendererPath = resolveEntryPath("../server/app-fallback-renderer.js", import.meta.url);
|
|
24
24
|
const appElementsPath = resolveEntryPath("../server/app-elements.js", import.meta.url);
|
|
25
25
|
const appPageRouteWiringPath = resolveEntryPath("../server/app-page-route-wiring.js", import.meta.url);
|
|
26
|
-
const
|
|
26
|
+
const appPageProbePath = resolveEntryPath("../server/app-page-probe.js", import.meta.url);
|
|
27
27
|
const appPageParamsPath = resolveEntryPath("../server/app-page-params.js", import.meta.url);
|
|
28
28
|
const appPageDispatchPath = resolveEntryPath("../server/app-page-dispatch.js", import.meta.url);
|
|
29
29
|
const appPageRequestPath = resolveEntryPath("../server/app-page-request.js", import.meta.url);
|
|
@@ -37,6 +37,7 @@ const instrumentationRuntimePath = resolveEntryPath("../server/instrumentation-r
|
|
|
37
37
|
const appRscErrorHandlerPath = resolveEntryPath("../server/app-rsc-error-handler.js", import.meta.url);
|
|
38
38
|
const appRequestContextPath = resolveEntryPath("../server/app-request-context.js", import.meta.url);
|
|
39
39
|
const appHookWarningSuppressionPath = resolveEntryPath("../server/app-hook-warning-suppression.js", import.meta.url);
|
|
40
|
+
const serverGlobalsPath = resolveEntryPath("../server/server-globals.js", import.meta.url);
|
|
40
41
|
/**
|
|
41
42
|
* Generate the virtual RSC entry module.
|
|
42
43
|
*
|
|
@@ -56,14 +57,16 @@ function generateRscEntry(appDir, routes, middlewarePath, metadataRoutes, global
|
|
|
56
57
|
const headers = config?.headers ?? [];
|
|
57
58
|
const allowedOrigins = config?.allowedOrigins ?? [];
|
|
58
59
|
const bodySizeLimit = config?.bodySizeLimit ?? 1 * 1024 * 1024;
|
|
60
|
+
const assetPrefix = config?.assetPrefix ?? "";
|
|
59
61
|
const expireTime = config?.expireTime ?? DEFAULT_EXPIRE_TIME;
|
|
60
62
|
const i18nConfig = config?.i18n ?? null;
|
|
61
63
|
const hasPagesDir = config?.hasPagesDir ?? false;
|
|
62
64
|
const publicFiles = config?.publicFiles ?? [];
|
|
63
|
-
const { imports, routeEntries, metaRouteEntries, generateStaticParamsEntries, rootNotFoundVar, rootForbiddenVar, rootUnauthorizedVar, rootLayoutVars, globalErrorVar } = buildAppRscManifestCode({
|
|
65
|
+
const { imports, routeEntries, metaRouteEntries, generateStaticParamsEntries, rootNotFoundVar, rootForbiddenVar, rootUnauthorizedVar, rootLayoutVars, globalErrorVar, globalNotFoundVar } = buildAppRscManifestCode({
|
|
64
66
|
routes,
|
|
65
67
|
metadataRoutes,
|
|
66
|
-
globalErrorPath
|
|
68
|
+
globalErrorPath,
|
|
69
|
+
globalNotFoundPath: config?.globalNotFoundPath ?? null
|
|
67
70
|
});
|
|
68
71
|
const loadPrerenderPagesRoutesCode = hasPagesDir ? `
|
|
69
72
|
async function __loadPrerenderPagesRoutes() {
|
|
@@ -72,6 +75,7 @@ async function __loadPrerenderPagesRoutes() {
|
|
|
72
75
|
}
|
|
73
76
|
` : "";
|
|
74
77
|
return `
|
|
78
|
+
import ${JSON.stringify(serverGlobalsPath)};
|
|
75
79
|
import {
|
|
76
80
|
renderToReadableStream as _renderToReadableStream,
|
|
77
81
|
decodeAction,
|
|
@@ -123,9 +127,7 @@ import { buildPageElements as __buildPageElements } from ${JSON.stringify(appPag
|
|
|
123
127
|
import {
|
|
124
128
|
resolveAppPageSegmentParams as __resolveAppPageSegmentParams,
|
|
125
129
|
} from ${JSON.stringify(appPageParamsPath)};
|
|
126
|
-
import {
|
|
127
|
-
collectAppPageSearchParams as __collectAppPageSearchParams,
|
|
128
|
-
} from ${JSON.stringify(appPageHeadPath)};
|
|
130
|
+
import { probeAppPage as __probeAppPage } from ${JSON.stringify(appPageProbePath)};
|
|
129
131
|
import {
|
|
130
132
|
dispatchAppPage as __dispatchAppPage,
|
|
131
133
|
} from ${JSON.stringify(appPageDispatchPath)};
|
|
@@ -232,15 +234,26 @@ const metadataRoutes = [
|
|
|
232
234
|
${metaRouteEntries.join(",\n")}
|
|
233
235
|
];
|
|
234
236
|
|
|
237
|
+
// Hoisted ahead of __fallbackRenderer / buildPageElements so both can thread
|
|
238
|
+
// the configured basePath through file-based metadata href emission.
|
|
239
|
+
const __basePath = ${JSON.stringify(bp)};
|
|
240
|
+
|
|
235
241
|
const rootNotFoundModule = ${rootNotFoundVar ? rootNotFoundVar : "null"};
|
|
236
242
|
const rootForbiddenModule = ${rootForbiddenVar ? rootForbiddenVar : "null"};
|
|
237
243
|
const rootUnauthorizedModule = ${rootUnauthorizedVar ? rootUnauthorizedVar : "null"};
|
|
238
244
|
const rootLayouts = [${rootLayoutVars.join(", ")}];
|
|
245
|
+
// Root-level app/global-not-found module. When present, route-miss 404s render
|
|
246
|
+
// this module standalone (it provides its own html/body) instead of wrapping
|
|
247
|
+
// the not-found.tsx boundary inside the root layout. Page-triggered notFound()
|
|
248
|
+
// calls still use the regular not-found.tsx boundary inside the layouts.
|
|
249
|
+
// See https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/app-render.tsx#L495-L520
|
|
250
|
+
const globalNotFoundModule = ${globalNotFoundVar ? globalNotFoundVar : "null"};
|
|
239
251
|
|
|
240
252
|
const createRscOnErrorHandler = (request, pathname, routePath) =>
|
|
241
253
|
createAppRscOnErrorHandler(_reportRequestError, request, pathname, routePath);
|
|
242
254
|
|
|
243
255
|
const __fallbackRenderer = __createAppFallbackRenderer({
|
|
256
|
+
basePath: __basePath,
|
|
244
257
|
rootBoundaries: {
|
|
245
258
|
rootForbiddenModule,
|
|
246
259
|
rootLayouts,
|
|
@@ -248,6 +261,7 @@ const __fallbackRenderer = __createAppFallbackRenderer({
|
|
|
248
261
|
rootUnauthorizedModule,
|
|
249
262
|
},
|
|
250
263
|
globalErrorModule: ${globalErrorVar ? globalErrorVar : "null"},
|
|
264
|
+
globalNotFoundModule,
|
|
251
265
|
metadataRoutes,
|
|
252
266
|
ssrLoader() {
|
|
253
267
|
return import.meta.viteRsc.loadModule("ssr", "index");
|
|
@@ -294,10 +308,10 @@ async function buildPageElements(route, params, routePath, pageRequest) {
|
|
|
294
308
|
rootForbiddenModule: ${rootForbiddenVar ? rootForbiddenVar : "null"},
|
|
295
309
|
rootUnauthorizedModule: ${rootUnauthorizedVar ? rootUnauthorizedVar : "null"},
|
|
296
310
|
metadataRoutes,
|
|
311
|
+
basePath: __basePath,
|
|
297
312
|
});
|
|
298
313
|
}
|
|
299
314
|
|
|
300
|
-
const __basePath = ${JSON.stringify(bp)};
|
|
301
315
|
const __trailingSlash = ${JSON.stringify(ts)};
|
|
302
316
|
const __i18nConfig = ${JSON.stringify(i18nConfig)};
|
|
303
317
|
const __configRedirects = ${JSON.stringify(redirects)};
|
|
@@ -306,6 +320,10 @@ const __configHeaders = ${JSON.stringify(headers)};
|
|
|
306
320
|
const __publicFiles = new Set(${JSON.stringify(publicFiles)});
|
|
307
321
|
const __allowedOrigins = ${JSON.stringify(allowedOrigins)};
|
|
308
322
|
const __expireTime = ${JSON.stringify(expireTime)};
|
|
323
|
+
// Re-exported for the App Router prod-server to consume at startup —
|
|
324
|
+
// mirrors the embedded \`__basePath\` pattern (and Pages Router's
|
|
325
|
+
// \`vinextConfig\` export). Empty string when unset.
|
|
326
|
+
export const __assetPrefix = ${JSON.stringify(assetPrefix)};
|
|
309
327
|
|
|
310
328
|
${generateDevOriginCheckCode(config?.allowedDevOrigins)}
|
|
311
329
|
|
|
@@ -344,6 +362,8 @@ export default __createAppRscHandler({
|
|
|
344
362
|
dispatchMatchedPage({
|
|
345
363
|
cleanPathname,
|
|
346
364
|
formState,
|
|
365
|
+
actionError,
|
|
366
|
+
actionFailed,
|
|
347
367
|
handlerStart,
|
|
348
368
|
interceptionContext,
|
|
349
369
|
isProgressiveActionRender,
|
|
@@ -410,6 +430,8 @@ export default __createAppRscHandler({
|
|
|
410
430
|
interceptionContext,
|
|
411
431
|
expireSeconds: __expireTime,
|
|
412
432
|
formState,
|
|
433
|
+
actionError,
|
|
434
|
+
actionFailed,
|
|
413
435
|
isProgressiveActionRender,
|
|
414
436
|
isProduction: process.env.NODE_ENV === "production",
|
|
415
437
|
isRscRequest,
|
|
@@ -437,11 +459,11 @@ export default __createAppRscHandler({
|
|
|
437
459
|
});
|
|
438
460
|
},
|
|
439
461
|
probePage() {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
462
|
+
return __probeAppPage({
|
|
463
|
+
pageComponent: PageComponent,
|
|
464
|
+
asyncRouteParams: _asyncRouteParams,
|
|
465
|
+
searchParams,
|
|
466
|
+
});
|
|
445
467
|
},
|
|
446
468
|
renderErrorBoundaryPage(renderErr) {
|
|
447
469
|
return __fallbackRenderer.renderErrorBoundary(route, renderErr, isRscRequest, request, params, scriptNonce, middlewareContext);
|
|
@@ -516,6 +538,7 @@ export default __createAppRscHandler({
|
|
|
516
538
|
return __handleProgressiveServerActionRequest({
|
|
517
539
|
actionId,
|
|
518
540
|
allowedOrigins: __allowedOrigins,
|
|
541
|
+
basePath: __basePath,
|
|
519
542
|
cleanPathname,
|
|
520
543
|
clearRequestContext() {
|
|
521
544
|
__clearRequestContext();
|
|
@@ -547,6 +570,7 @@ export default __createAppRscHandler({
|
|
|
547
570
|
return __handleServerActionRscRequest({
|
|
548
571
|
actionId,
|
|
549
572
|
allowedOrigins: __allowedOrigins,
|
|
573
|
+
basePath: __basePath,
|
|
550
574
|
buildPageElement({
|
|
551
575
|
route: actionRoute,
|
|
552
576
|
params: actionParams,
|
|
@@ -625,7 +649,9 @@ export default __createAppRscHandler({
|
|
|
625
649
|
return {
|
|
626
650
|
interceptionContext,
|
|
627
651
|
interceptLayouts: intercept.interceptLayouts,
|
|
652
|
+
interceptSlotId: intercept.slotId,
|
|
628
653
|
interceptSlotKey: intercept.slotKey,
|
|
654
|
+
interceptSourceMatchedUrl: interceptionContext,
|
|
629
655
|
interceptPage: intercept.page,
|
|
630
656
|
interceptParams: intercept.matchedParams,
|
|
631
657
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-rsc-entry.js","names":[],"sources":["../../src/entries/app-rsc-entry.ts"],"sourcesContent":["/**\n * App Router RSC entry generator.\n *\n * Generates the virtual RSC entry module for the App Router.\n * The RSC entry does route matching and renders the component tree,\n * then delegates to the SSR entry for HTML generation.\n *\n * Previously housed in server/app-dev-server.ts.\n */\nimport { buildAppRscManifestCode } from \"./app-rsc-manifest.js\";\nimport { resolveEntryPath, normalizePathSeparators } from \"./runtime-entry-module.js\";\nimport type {\n NextHeader,\n NextI18nConfig,\n NextRedirect,\n NextRewrite,\n} from \"../config/next-config.js\";\nimport type { AppRoute } from \"../routing/app-router.js\";\nimport { generateDevOriginCheckCode } from \"../server/dev-origin-check.js\";\nimport type { MetadataFileRoute } from \"../server/metadata-routes.js\";\nimport { isProxyFile } from \"../server/middleware.js\";\n\nconst DEFAULT_EXPIRE_TIME = 31_536_000;\n\n// Pre-computed absolute paths for generated-code imports. The virtual RSC\n// entry can't use relative imports (it has no real file location), so we\n// resolve these at code-generation time and embed them as absolute paths.\nconst middlewareRequestHeadersPath = resolveEntryPath(\n \"../server/middleware-request-headers.js\",\n import.meta.url,\n);\nconst normalizePathModulePath = resolveEntryPath(\"../server/normalize-path.js\", import.meta.url);\nconst appRscHandlerPath = resolveEntryPath(\"../server/app-rsc-handler.js\", import.meta.url);\nconst appRouteHandlerDispatchPath = resolveEntryPath(\n \"../server/app-route-handler-dispatch.js\",\n import.meta.url,\n);\nconst appServerActionExecutionPath = resolveEntryPath(\n \"../server/app-server-action-execution.js\",\n import.meta.url,\n);\nconst appRscErrorsPath = resolveEntryPath(\"../server/app-rsc-errors.js\", import.meta.url);\nconst appPageExecutionPath = resolveEntryPath(\"../server/app-page-execution.js\", import.meta.url);\nconst appFallbackRendererPath = resolveEntryPath(\n \"../server/app-fallback-renderer.js\",\n import.meta.url,\n);\nconst appElementsPath = resolveEntryPath(\"../server/app-elements.js\", import.meta.url);\nconst appPageRouteWiringPath = resolveEntryPath(\n \"../server/app-page-route-wiring.js\",\n import.meta.url,\n);\nconst appPageHeadPath = resolveEntryPath(\"../server/app-page-head.js\", import.meta.url);\nconst appPageParamsPath = resolveEntryPath(\"../server/app-page-params.js\", import.meta.url);\nconst appPageDispatchPath = resolveEntryPath(\"../server/app-page-dispatch.js\", import.meta.url);\nconst appPageRequestPath = resolveEntryPath(\"../server/app-page-request.js\", import.meta.url);\nconst appSegmentConfigPath = resolveEntryPath(\"../server/app-segment-config.js\", import.meta.url);\nconst appRscRouteMatchingPath = resolveEntryPath(\n \"../server/app-rsc-route-matching.js\",\n import.meta.url,\n);\nconst rscStreamHintsPath = resolveEntryPath(\"../server/rsc-stream-hints.js\", import.meta.url);\nconst isrCachePath = resolveEntryPath(\"../server/isr-cache.js\", import.meta.url);\nconst thenableParamsShimPath = resolveEntryPath(\"../shims/thenable-params.js\", import.meta.url);\nconst appPageElementBuilderPath = resolveEntryPath(\n \"../server/app-page-element-builder.js\",\n import.meta.url,\n);\nconst instrumentationRuntimePath = resolveEntryPath(\n \"../server/instrumentation-runtime.js\",\n import.meta.url,\n);\nconst appRscErrorHandlerPath = resolveEntryPath(\n \"../server/app-rsc-error-handler.js\",\n import.meta.url,\n);\nconst appRequestContextPath = resolveEntryPath(\"../server/app-request-context.js\", import.meta.url);\nconst appHookWarningSuppressionPath = resolveEntryPath(\n \"../server/app-hook-warning-suppression.js\",\n import.meta.url,\n);\n\n/**\n * Resolved config options relevant to App Router request handling.\n * Passed from the Vite plugin where the full next.config.js is loaded.\n */\ntype AppRouterConfig = {\n redirects?: NextRedirect[];\n rewrites?: {\n beforeFiles: NextRewrite[];\n afterFiles: NextRewrite[];\n fallback: NextRewrite[];\n };\n headers?: NextHeader[];\n /** Extra origins allowed for server action CSRF checks (from experimental.serverActions.allowedOrigins). */\n allowedOrigins?: string[];\n /** Extra origins allowed for dev server access (from allowedDevOrigins). */\n allowedDevOrigins?: string[];\n /** Body size limit for server actions in bytes (from experimental.serverActions.bodySizeLimit). */\n bodySizeLimit?: number;\n /** Route-level expire fallback in seconds for ISR entries with numeric revalidate. */\n expireTime?: number;\n /** Internationalization routing config for middleware matcher locale handling. */\n i18n?: NextI18nConfig | null;\n /**\n * When true, the project has a `pages/` directory alongside the App Router.\n * The generated RSC entry exposes `/__vinext/prerender/pages-static-paths`\n * so `prerenderPages` can call `getStaticPaths` via `wrangler unstable_startWorker`\n * in CF Workers builds. `pageRoutes` is loaded from the SSR environment via\n * `import(\"./ssr/index.js\")`, which re-exports it from\n * `virtual:vinext-server-entry` when this flag is set.\n */\n hasPagesDir?: boolean;\n /** Exact public/ file routes, using normalized leading-slash pathnames. */\n publicFiles?: string[];\n};\n\n/**\n * Generate the virtual RSC entry module.\n *\n * This runs in the `rsc` Vite environment (react-server condition).\n * It matches the incoming request URL to an app route, builds the\n * nested layout + page tree, and renders it to an RSC stream.\n */\nexport function generateRscEntry(\n appDir: string,\n routes: AppRoute[],\n middlewarePath?: string | null,\n metadataRoutes?: MetadataFileRoute[],\n globalErrorPath?: string | null,\n basePath?: string,\n trailingSlash?: boolean,\n config?: AppRouterConfig,\n instrumentationPath?: string | null,\n): string {\n const bp = basePath ?? \"\";\n const ts = trailingSlash ?? false;\n const redirects = config?.redirects ?? [];\n const rewrites = config?.rewrites ?? { beforeFiles: [], afterFiles: [], fallback: [] };\n const headers = config?.headers ?? [];\n const allowedOrigins = config?.allowedOrigins ?? [];\n const bodySizeLimit = config?.bodySizeLimit ?? 1 * 1024 * 1024;\n const expireTime = config?.expireTime ?? DEFAULT_EXPIRE_TIME;\n const i18nConfig = config?.i18n ?? null;\n const hasPagesDir = config?.hasPagesDir ?? false;\n const publicFiles = config?.publicFiles ?? [];\n const manifestCode = buildAppRscManifestCode({ routes, metadataRoutes, globalErrorPath });\n const {\n imports,\n routeEntries,\n metaRouteEntries,\n generateStaticParamsEntries,\n rootNotFoundVar,\n rootForbiddenVar,\n rootUnauthorizedVar,\n rootLayoutVars,\n globalErrorVar,\n } = manifestCode;\n const loadPrerenderPagesRoutesCode = hasPagesDir\n ? `\nasync function __loadPrerenderPagesRoutes() {\n const __gspSsrEntry = await import.meta.viteRsc.loadModule(\"ssr\", \"index\");\n return __gspSsrEntry.pageRoutes;\n}\n`\n : \"\";\n\n return `\nimport {\n renderToReadableStream as _renderToReadableStream,\n decodeAction,\n decodeFormState,\n decodeReply,\n loadServerAction,\n createTemporaryReferenceSet,\n} from \"@vitejs/plugin-rsc/rsc\";\nimport { createRscRenderer } from ${JSON.stringify(rscStreamHintsPath)};\n\nconst renderToReadableStream = createRscRenderer(_renderToReadableStream);\nimport { createElement } from \"react\";\nimport { getNavigationContext as _getNavigationContext } from \"next/navigation\";\nimport { headersContextFromRequest, getDraftModeCookieHeader, getAndClearPendingCookies, consumeDynamicUsage, consumeInvalidDynamicUsageError, setHeadersAccessPhase } from \"next/headers\";\nimport { mergeMetadata, resolveModuleMetadata, mergeViewport, resolveModuleViewport } from \"vinext/metadata\";\n${middlewarePath ? `import * as middlewareModule from ${JSON.stringify(normalizePathSeparators(middlewarePath))};` : \"\"}\n${\n instrumentationPath\n ? `import * as _instrumentation from ${JSON.stringify(normalizePathSeparators(instrumentationPath))};\nimport { ensureInstrumentationRegistered as __ensureInstrumentationRegistered } from ${JSON.stringify(instrumentationRuntimePath)};`\n : \"\"\n}\nimport { createAppRscHandler as __createAppRscHandler } from ${JSON.stringify(appRscHandlerPath)};\nimport { decodePathParams as __decodePathParams } from ${JSON.stringify(normalizePathModulePath)};\nimport { buildRequestHeadersFromMiddlewareResponse as __buildRequestHeadersFromMiddlewareResponse } from ${JSON.stringify(middlewareRequestHeadersPath)};\nimport {\n dispatchAppRouteHandler as __dispatchAppRouteHandler,\n} from ${JSON.stringify(appRouteHandlerDispatchPath)};\nimport {\n handleProgressiveServerActionRequest as __handleProgressiveServerActionRequest,\n handleServerActionRscRequest as __handleServerActionRscRequest,\n readActionBodyWithLimit as __readBodyWithLimit,\n readActionFormDataWithLimit as __readFormDataWithLimit,\n} from ${JSON.stringify(appServerActionExecutionPath)};\nimport {\n sanitizeErrorForClient as __sanitizeErrorForClient,\n} from ${JSON.stringify(appRscErrorsPath)};\nimport { createAppRscOnErrorHandler } from ${JSON.stringify(appRscErrorHandlerPath)};\nimport {\n buildAppPageFontLinkHeader as __buildAppPageFontLinkHeader,\n resolveAppPageSpecialError as __resolveAppPageSpecialError,\n} from ${JSON.stringify(appPageExecutionPath)};\nimport {\n createAppFallbackRenderer as __createAppFallbackRenderer,\n} from ${JSON.stringify(appFallbackRendererPath)};\nimport {\n AppElementsWire as __AppElementsWire,\n} from ${JSON.stringify(appElementsPath)};\nimport {\n resolveAppPageChildSegments as __resolveAppPageChildSegments,\n} from ${JSON.stringify(appPageRouteWiringPath)};\nimport { buildPageElements as __buildPageElements } from ${JSON.stringify(appPageElementBuilderPath)};\nimport {\n resolveAppPageSegmentParams as __resolveAppPageSegmentParams,\n} from ${JSON.stringify(appPageParamsPath)};\nimport {\n collectAppPageSearchParams as __collectAppPageSearchParams,\n} from ${JSON.stringify(appPageHeadPath)};\nimport {\n dispatchAppPage as __dispatchAppPage,\n} from ${JSON.stringify(appPageDispatchPath)};\nimport {\n resolveAppPageGenerateStaticParamsSources as __resolveAppPageGenerateStaticParamsSources,\n} from ${JSON.stringify(appPageRequestPath)};\nimport {\n resolveAppPageFetchCacheMode as __resolveAppPageFetchCacheMode,\n resolveAppPageSegmentConfig as __resolveAppPageSegmentConfig,\n} from ${JSON.stringify(appSegmentConfigPath)};\nimport { makeThenableParams } from ${JSON.stringify(thenableParamsShimPath)};\nimport {\n createAppRscRouteMatcher as __createAppRscRouteMatcher,\n} from ${JSON.stringify(appRscRouteMatchingPath)};\nimport {\n appIsrHtmlKey as __isrHtmlKey,\n appIsrRscKey as __isrRscKey,\n appIsrRouteKey as __isrRouteKey,\n isrGet as __isrGet,\n isrSet as __isrSet,\n triggerBackgroundRegeneration as __triggerBackgroundRegeneration,\n} from ${JSON.stringify(isrCachePath)};\n// Import server-only state module to register ALS-backed accessors.\nimport \"vinext/navigation-state\";\nimport { reportRequestError as _reportRequestError } from \"vinext/instrumentation\";\nimport { getSSRFontLinks as _getSSRFontLinks, getSSRFontStyles as _getSSRFontStylesGoogle, getSSRFontPreloads as _getSSRFontPreloadsGoogle } from \"next/font/google\";\nimport { getSSRFontStyles as _getSSRFontStylesLocal, getSSRFontPreloads as _getSSRFontPreloadsLocal } from \"next/font/local\";\nfunction _getSSRFontStyles() { return [..._getSSRFontStylesGoogle(), ..._getSSRFontStylesLocal()]; }\nfunction _getSSRFontPreloads() { return [..._getSSRFontPreloadsGoogle(), ..._getSSRFontPreloadsLocal()]; }\n${hasPagesDir ? `// Pages Router routes are loaded lazily from the SSR environment for internal prerender requests.` : \"\"}\n\n// Suppress expected \"Invalid hook call\" dev warning when layout/page\n// components are probed outside React's render cycle. The import patches\n// console.error once at module load (side-effect) and exposes the ALS\n// so per-route dispatch can opt into suppression via .run(true, ...).\nimport { suppressHookWarningAls } from ${JSON.stringify(appHookWarningSuppressionPath)};\nimport { clearAppRequestContext as __clearRequestContext, setAppNavigationContext as setNavigationContext } from ${JSON.stringify(appRequestContextPath)};\n\n// Note: cache entries are written with \\`headers: undefined\\`. Next.js stores\n// response headers (e.g. set-cookie from cookies().set() during render) in the\n// cache entry so they can be replayed on HIT. We don't do this because:\n// 1. Pages that call cookies().set() during render trigger dynamicUsedDuringRender,\n// which opts them out of ISR caching before we reach the write path.\n// 2. Custom response headers set via next/headers are not yet captured separately\n// from the live Response object in vinext's server pipeline.\n// In practice this means ISR-cached responses won't replay render-time set-cookie\n// headers — but that case is already prevented by the dynamic-usage opt-out.\n// TODO: capture render-time response headers for full Next.js parity.\n// Verbose cache logging — opt in with NEXT_PRIVATE_DEBUG_CACHE=1.\n// Matches the env var Next.js uses for its own cache debug output so operators\n// have a single knob for all cache tracing.\nconst __isrDebug = process.env.NEXT_PRIVATE_DEBUG_CACHE\n ? console.debug.bind(console, \"[vinext] ISR:\")\n : undefined;\n\n// Classification debug — opt in with VINEXT_DEBUG_CLASSIFICATION=1. Gated on\n// the env var so the hot path pays no overhead unless an operator is actively\n// tracing why a layout was flagged static or dynamic. The reason payload is\n// carried by __VINEXT_CLASS_REASONS and consumed inside probeAppPageLayouts.\nconst __classDebug = process.env.VINEXT_DEBUG_CLASSIFICATION\n ? function(layoutId, reason) {\n console.debug(\"[vinext] CLS:\", layoutId, reason);\n }\n : undefined;\n\nfunction __resolveRouteFetchCacheMode(route) {\n return __resolveAppPageFetchCacheMode({\n layouts: route.layouts,\n page: route.page,\n });\n}\n\n${imports.join(\"\\n\")}\n\n${\n instrumentationPath\n ? `// Lazy instrumentation initialisation is handled by ensureInstrumentationRegistered\n// (imported from vinext/instrumentation-runtime). The generated entry only passes\n// the user module in; all bookkeeping (initialized flag, shared promise, prerender\n// skip) lives in the typed helper so it can be unit-tested independently.`\n : \"\"\n}\n\n// Build-time layout classification dispatch. Replaced in generateBundle\n// with a switch statement that returns a pre-computed per-layout\n// Map<layoutIndex, \"static\" | \"dynamic\"> for each route. Until the\n// plugin patches this stub, every route falls back to the Layer 3\n// runtime probe, which is the current (slow) behaviour.\nfunction __VINEXT_CLASS(routeIdx) {\n return null;\n}\n\n// Build-time layout classification reasons dispatch. Sibling of\n// __VINEXT_CLASS, returning a per-route Map<layoutIndex, ClassificationReason>\n// that feeds the debug channel when VINEXT_DEBUG_CLASSIFICATION is active.\n// Replaced in generateBundle with a real dispatch table; the stub returns\n// null so the hot path never allocates reason maps when debug is off.\nfunction __VINEXT_CLASS_REASONS(routeIdx) {\n return null;\n}\n\nconst routes = [\n${routeEntries.join(\",\\n\")}\n];\nconst __routeMatcher = __createAppRscRouteMatcher(routes);\n\nconst metadataRoutes = [\n${metaRouteEntries.join(\",\\n\")}\n];\n\nconst rootNotFoundModule = ${rootNotFoundVar ? rootNotFoundVar : \"null\"};\nconst rootForbiddenModule = ${rootForbiddenVar ? rootForbiddenVar : \"null\"};\nconst rootUnauthorizedModule = ${rootUnauthorizedVar ? rootUnauthorizedVar : \"null\"};\nconst rootLayouts = [${rootLayoutVars.join(\", \")}];\n\nconst createRscOnErrorHandler = (request, pathname, routePath) =>\n createAppRscOnErrorHandler(_reportRequestError, request, pathname, routePath);\n\nconst __fallbackRenderer = __createAppFallbackRenderer({\n rootBoundaries: {\n rootForbiddenModule,\n rootLayouts,\n rootNotFoundModule,\n rootUnauthorizedModule,\n },\n globalErrorModule: ${globalErrorVar ? globalErrorVar : \"null\"},\n metadataRoutes,\n ssrLoader() {\n return import.meta.viteRsc.loadModule(\"ssr\", \"index\");\n },\n fontProviders: {\n buildFontLinkHeader: __buildAppPageFontLinkHeader,\n getFontLinks: _getSSRFontLinks,\n getFontPreloads: _getSSRFontPreloads,\n getFontStyles: _getSSRFontStyles,\n },\n makeThenableParams,\n sanitizer: __sanitizeErrorForClient,\n rscRenderer: renderToReadableStream,\n getNavigationContext: _getNavigationContext,\n resolveChildSegments: __resolveAppPageChildSegments,\n clearRequestContext() {\n __clearRequestContext();\n },\n createRscOnErrorHandler(request, pathname, routePath) {\n return createRscOnErrorHandler(request, pathname, routePath);\n },\n});\n\nfunction matchRoute(url) {\n return __routeMatcher.matchRoute(url);\n}\n\n/**\n * Check if a pathname matches any intercepting route.\n * Returns the match info or null.\n */\nfunction findIntercept(pathname, sourcePathname = null) {\n return __routeMatcher.findIntercept(pathname, sourcePathname);\n}\n\nasync function buildPageElements(route, params, routePath, pageRequest) {\n return __buildPageElements({\n route,\n params,\n routePath,\n pageRequest,\n globalErrorModule: ${globalErrorVar ? globalErrorVar : \"null\"},\n rootNotFoundModule: ${rootNotFoundVar ? rootNotFoundVar : \"null\"},\n rootForbiddenModule: ${rootForbiddenVar ? rootForbiddenVar : \"null\"},\n rootUnauthorizedModule: ${rootUnauthorizedVar ? rootUnauthorizedVar : \"null\"},\n metadataRoutes,\n });\n}\n\nconst __basePath = ${JSON.stringify(bp)};\nconst __trailingSlash = ${JSON.stringify(ts)};\nconst __i18nConfig = ${JSON.stringify(i18nConfig)};\nconst __configRedirects = ${JSON.stringify(redirects)};\nconst __configRewrites = ${JSON.stringify(rewrites)};\nconst __configHeaders = ${JSON.stringify(headers)};\nconst __publicFiles = new Set(${JSON.stringify(publicFiles)});\nconst __allowedOrigins = ${JSON.stringify(allowedOrigins)};\nconst __expireTime = ${JSON.stringify(expireTime)};\n\n${generateDevOriginCheckCode(config?.allowedDevOrigins)}\n\n/**\n * Maximum server-action request body size.\n * Configurable via experimental.serverActions.bodySizeLimit in next.config.\n * Defaults to 1MB, matching the Next.js default.\n * @see https://nextjs.org/docs/app/api-reference/config/next-config-js/serverActions#bodysizelimit\n * Prevents unbounded request body buffering.\n */\nvar __MAX_ACTION_BODY_SIZE = ${JSON.stringify(bodySizeLimit)};\n\n// Map from route pattern to generateStaticParams function.\n// Used by the prerender phase to enumerate dynamic route URLs without\n// loading route modules via the dev server.\nexport const generateStaticParamsMap = {\n// TODO: layout-level generateStaticParams — this map only includes routes that\n// have a pagePath (leaf pages). Layout segments can also export generateStaticParams\n// to provide parent params for nested dynamic routes, but they don't have a pagePath\n// so they are excluded here. Supporting layout-level generateStaticParams requires\n// scanning layout.tsx files separately and including them in this map.\n${generateStaticParamsEntries.join(\"\\n\")}\n};${loadPrerenderPagesRoutesCode}\nconst rootParamNamesMap = {\n${routes\n .filter((r) => r.isDynamic && r.pagePath && r.rootParamNames && r.rootParamNames.length > 0)\n .map((r) => ` ${JSON.stringify(r.pattern)}: ${JSON.stringify(r.rootParamNames)},`)\n .join(\"\\n\")}\n};\n\nexport default __createAppRscHandler({\n basePath: __basePath,\n clearRequestContext() {\n __clearRequestContext();\n },\n configHeaders: __configHeaders,\n configRedirects: __configRedirects,\n configRewrites: __configRewrites,\n dispatchMatchedPage({\n cleanPathname,\n formState,\n handlerStart,\n interceptionContext,\n isProgressiveActionRender,\n isRscRequest,\n middlewareContext,\n mountedSlotsHeader,\n params,\n request,\n route,\n scriptNonce,\n searchParams,\n renderMode,\n }) {\n const PageComponent = route.page?.default;\n const __segmentConfig = __resolveAppPageSegmentConfig({\n layouts: route.layouts,\n page: route.page,\n });\n const __generateStaticParams = __resolveAppPageGenerateStaticParamsSources({\n layouts: route.layouts,\n layoutTreePositions: route.layoutTreePositions,\n page: route.page,\n routeSegments: route.routeSegments,\n });\n const _asyncRouteParams = makeThenableParams(params);\n return __dispatchAppPage({\n basePath: __basePath,\n buildPageElement(targetRoute, targetParams, targetOpts, targetSearchParams) {\n return buildPageElements(targetRoute, targetParams, cleanPathname, {\n opts: targetOpts,\n searchParams: targetSearchParams,\n isRscRequest,\n request,\n mountedSlotsHeader,\n renderMode,\n });\n },\n cleanPathname,\n clearRequestContext() {\n __clearRequestContext();\n },\n createRscOnErrorHandler(pathname, routePath) {\n return createRscOnErrorHandler(request, pathname, routePath);\n },\n debugClassification: __classDebug,\n dynamicConfig: __segmentConfig.dynamicConfig,\n dynamicParamsConfig: __segmentConfig.dynamicParamsConfig,\n fetchCache: __segmentConfig.fetchCache ?? null,\n findIntercept(pathname) {\n return findIntercept(pathname, interceptionContext);\n },\n generateStaticParams: __generateStaticParams,\n getFontLinks: _getSSRFontLinks,\n getFontPreloads: _getSSRFontPreloads,\n getFontStyles: _getSSRFontStyles,\n getNavigationContext: _getNavigationContext,\n getSourceRoute(sourceRouteIndex) {\n return routes[sourceRouteIndex];\n },\n hasGenerateStaticParams: __generateStaticParams.length > 0,\n hasPageDefaultExport: !!PageComponent,\n hasPageModule: !!route.page,\n handlerStart,\n interceptionContext,\n expireSeconds: __expireTime,\n formState,\n isProgressiveActionRender,\n isProduction: process.env.NODE_ENV === \"production\",\n isRscRequest,\n isrDebug: __isrDebug,\n isrGet: __isrGet,\n isrHtmlKey: __isrHtmlKey,\n isrRscKey: __isrRscKey,\n isrSet: __isrSet,\n loadSsrHandler() {\n return import.meta.viteRsc.loadModule(\"ssr\", \"index\");\n },\n middlewareContext,\n mountedSlotsHeader,\n params,\n probeLayoutAt(li) {\n const LayoutComp = route.layouts[li]?.default;\n if (!LayoutComp) return null;\n return LayoutComp({\n params: makeThenableParams(__resolveAppPageSegmentParams(\n route.routeSegments,\n route.layoutTreePositions?.[li] ?? 0,\n params,\n )),\n children: null,\n });\n },\n probePage() {\n if (!PageComponent) return null;\n const _asyncSearchParams = makeThenableParams(\n __collectAppPageSearchParams(searchParams).searchParamsObject,\n );\n return PageComponent({ params: _asyncRouteParams, searchParams: _asyncSearchParams });\n },\n renderErrorBoundaryPage(renderErr) {\n return __fallbackRenderer.renderErrorBoundary(route, renderErr, isRscRequest, request, params, scriptNonce, middlewareContext);\n },\n renderHttpAccessFallbackPage(statusCode, opts, currentMiddlewareContext) {\n return __fallbackRenderer.renderHttpAccessFallback(route, statusCode, isRscRequest, request, opts, scriptNonce, currentMiddlewareContext);\n },\n renderToReadableStream,\n request,\n revalidateSeconds: __segmentConfig.revalidateSeconds,\n resolveRouteFetchCacheMode(targetRoute) {\n return __resolveRouteFetchCacheMode(targetRoute);\n },\n rootForbiddenModule,\n rootNotFoundModule,\n rootUnauthorizedModule,\n route,\n runWithSuppressedHookWarning(probe) {\n return suppressHookWarningAls.run(true, probe);\n },\n scheduleBackgroundRegeneration(key, renderFn, errorContext) {\n __triggerBackgroundRegeneration(key, renderFn, errorContext);\n },\n scriptNonce,\n searchParams,\n setNavigationContext,\n renderMode,\n });\n },\n dispatchMatchedRouteHandler({\n cleanPathname,\n middlewareContext,\n params,\n request,\n route,\n searchParams,\n }) {\n return __dispatchAppRouteHandler({\n basePath: __basePath,\n cleanPathname,\n clearRequestContext() {\n __clearRequestContext();\n },\n i18n: __i18nConfig,\n isrDebug: __isrDebug,\n isrGet: __isrGet,\n isrRouteKey: __isrRouteKey,\n isrSet: __isrSet,\n middlewareContext,\n middlewareRequestHeaders: middlewareContext.requestHeaders,\n params,\n request,\n route: {\n pattern: route.pattern,\n routeHandler: route.routeHandler,\n routeSegments: route.routeSegments,\n },\n scheduleBackgroundRegeneration: __triggerBackgroundRegeneration,\n searchParams,\n });\n },\n ${\n instrumentationPath\n ? `ensureInstrumentation() {\n return __ensureInstrumentationRegistered(_instrumentation);\n },`\n : \"\"\n }\n handleProgressiveActionRequest({\n actionId,\n cleanPathname,\n contentType,\n middlewareContext,\n request,\n }) {\n return __handleProgressiveServerActionRequest({\n actionId,\n allowedOrigins: __allowedOrigins,\n cleanPathname,\n clearRequestContext() {\n __clearRequestContext();\n },\n contentType,\n decodeAction,\n decodeFormState,\n getAndClearPendingCookies,\n getDraftModeCookieHeader,\n maxActionBodySize: __MAX_ACTION_BODY_SIZE,\n middlewareHeaders: middlewareContext.headers,\n readFormDataWithLimit: __readFormDataWithLimit,\n reportRequestError: _reportRequestError,\n request,\n setHeadersAccessPhase,\n });\n },\n handleServerActionRequest({\n actionId,\n cleanPathname,\n contentType,\n interceptionContext,\n isRscRequest,\n middlewareContext,\n mountedSlotsHeader,\n request,\n searchParams,\n }) {\n return __handleServerActionRscRequest({\n actionId,\n allowedOrigins: __allowedOrigins,\n buildPageElement({\n route: actionRoute,\n params: actionParams,\n cleanPathname: actionCleanPathname,\n interceptOpts,\n searchParams: actionSearchParams,\n isRscRequest: actionIsRscRequest,\n request: actionRequest,\n mountedSlotsHeader: actionMountedSlotsHeader,\n renderMode: actionRenderMode,\n }) {\n return buildPageElements(actionRoute, actionParams, actionCleanPathname, {\n opts: interceptOpts,\n searchParams: actionSearchParams,\n isRscRequest: actionIsRscRequest,\n request: actionRequest,\n mountedSlotsHeader: actionMountedSlotsHeader,\n renderMode: actionRenderMode,\n });\n },\n cleanPathname,\n clearRequestContext() {\n __clearRequestContext();\n },\n contentType,\n createNotFoundElement(actionRouteId) {\n return {\n ...__AppElementsWire.createMetadataEntries({\n interceptionContext: null,\n rootLayoutTreePath: null,\n routeId: actionRouteId,\n }),\n [actionRouteId]: createElement(\"div\", null, \"Page not found\"),\n };\n },\n createPayloadRouteId(pathnameToRender, currentInterceptionContext) {\n return __AppElementsWire.encodeRouteId(pathnameToRender, currentInterceptionContext);\n },\n createRscOnErrorHandler(actionRequest, actionPathname, routePattern) {\n return createRscOnErrorHandler(actionRequest, actionPathname, routePattern);\n },\n createTemporaryReferenceSet,\n decodeReply,\n findIntercept(pathnameToMatch) {\n return findIntercept(pathnameToMatch, interceptionContext);\n },\n getAndClearPendingCookies,\n getDraftModeCookieHeader,\n getRouteParamNames(sourceRoute) {\n return sourceRoute.params;\n },\n getSourceRoute(sourceRouteIndex) {\n return routes[sourceRouteIndex];\n },\n isRscRequest,\n loadServerAction,\n matchRoute(pathnameToMatch) {\n return matchRoute(pathnameToMatch);\n },\n maxActionBodySize: __MAX_ACTION_BODY_SIZE,\n middlewareHeaders: middlewareContext.headers,\n middlewareStatus: middlewareContext.status,\n mountedSlotsHeader,\n readBodyWithLimit: __readBodyWithLimit,\n readFormDataWithLimit: __readFormDataWithLimit,\n renderToReadableStream,\n reportRequestError: _reportRequestError,\n request,\n sanitizeErrorForClient(error) {\n return __sanitizeErrorForClient(error);\n },\n searchParams,\n setHeadersAccessPhase,\n setNavigationContext,\n toInterceptOpts(intercept) {\n return {\n interceptionContext,\n interceptLayouts: intercept.interceptLayouts,\n interceptSlotKey: intercept.slotKey,\n interceptPage: intercept.page,\n interceptParams: intercept.matchedParams,\n };\n },\n });\n },\n i18nConfig: __i18nConfig,\n isMiddlewareProxy: ${JSON.stringify(middlewarePath ? isProxyFile(middlewarePath) : false)},\n ${hasPagesDir ? `loadPrerenderPagesRoutes: __loadPrerenderPagesRoutes,` : \"\"}\n makeThenableParams,\n matchRoute,\n metadataRoutes,\n middlewareModule: ${middlewarePath ? \"middlewareModule\" : \"null\"},\n publicFiles: __publicFiles,\n renderNotFound({ isRscRequest, matchedParams, middlewareContext, request, route, scriptNonce }) {\n return __fallbackRenderer.renderNotFound(route, isRscRequest, request, matchedParams, scriptNonce, middlewareContext);\n },\n ${\n hasPagesDir\n ? `async renderPagesFallback({ isRscRequest, middlewareContext, request, url }) {\n if (isRscRequest) return null;\n\n const __pagesEntry = await import.meta.viteRsc.loadModule(\"ssr\", \"index\");\n if (typeof __pagesEntry.renderPage !== \"function\") return null;\n\n const __pagesRequestHeaders = middlewareContext.requestHeaders\n ? __buildRequestHeadersFromMiddlewareResponse(request.headers, middlewareContext.requestHeaders)\n : null;\n const __pagesRequest = __pagesRequestHeaders\n ? new Request(request.url, { method: request.method, headers: __pagesRequestHeaders })\n : request;\n const __pagesRes = await __pagesEntry.renderPage(\n __pagesRequest,\n __decodePathParams(url.pathname) + (url.search || \"\"),\n {},\n undefined,\n middlewareContext.requestHeaders,\n );\n return __pagesRes.status !== 404 ? __pagesRes : null;\n },`\n : \"\"\n }\n rootParamNamesByPattern: rootParamNamesMap,\n setNavigationContext,\n staticParamsMap: generateStaticParamsMap,\n trailingSlash: __trailingSlash,\n validateDevRequestOrigin: __validateDevRequestOrigin,\n});\n\nif (import.meta.hot) {\n import.meta.hot.accept();\n}\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,MAAM,sBAAsB;AAK5B,MAAM,+BAA+B,iBACnC,2CACA,OAAO,KAAK,IACb;AACD,MAAM,0BAA0B,iBAAiB,+BAA+B,OAAO,KAAK,IAAI;AAChG,MAAM,oBAAoB,iBAAiB,gCAAgC,OAAO,KAAK,IAAI;AAC3F,MAAM,8BAA8B,iBAClC,2CACA,OAAO,KAAK,IACb;AACD,MAAM,+BAA+B,iBACnC,4CACA,OAAO,KAAK,IACb;AACD,MAAM,mBAAmB,iBAAiB,+BAA+B,OAAO,KAAK,IAAI;AACzF,MAAM,uBAAuB,iBAAiB,mCAAmC,OAAO,KAAK,IAAI;AACjG,MAAM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SAAS,EAAE,CAC3F,KAAK,MAAM,KAAK,KAAK,UAAU,EAAE,QAAQ,CAAC,IAAI,KAAK,UAAU,EAAE,eAAe,CAAC,GAAG,CAClF,KAAK,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA8KV,sBACI;;QAGA,GACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAgIoB,KAAK,UAAU,iBAAiB,YAAY,eAAe,GAAG,MAAM,CAAC;IACxF,cAAc,0DAA0D,GAAG;;;;sBAIzD,iBAAiB,qBAAqB,OAAO;;;;;IAM/D,cACI;;;;;;;;;;;;;;;;;;;;QAqBA,GACL"}
|
|
1
|
+
{"version":3,"file":"app-rsc-entry.js","names":[],"sources":["../../src/entries/app-rsc-entry.ts"],"sourcesContent":["/**\n * App Router RSC entry generator.\n *\n * Generates the virtual RSC entry module for the App Router.\n * The RSC entry does route matching and renders the component tree,\n * then delegates to the SSR entry for HTML generation.\n *\n * Previously housed in server/app-dev-server.ts.\n */\nimport { buildAppRscManifestCode } from \"./app-rsc-manifest.js\";\nimport { resolveEntryPath, normalizePathSeparators } from \"./runtime-entry-module.js\";\nimport type {\n NextHeader,\n NextI18nConfig,\n NextRedirect,\n NextRewrite,\n} from \"../config/next-config.js\";\nimport type { AppRoute } from \"../routing/app-router.js\";\nimport { generateDevOriginCheckCode } from \"../server/dev-origin-check.js\";\nimport type { MetadataFileRoute } from \"../server/metadata-routes.js\";\nimport { isProxyFile } from \"../server/middleware.js\";\n\nconst DEFAULT_EXPIRE_TIME = 31_536_000;\n\n// Pre-computed absolute paths for generated-code imports. The virtual RSC\n// entry can't use relative imports (it has no real file location), so we\n// resolve these at code-generation time and embed them as absolute paths.\nconst middlewareRequestHeadersPath = resolveEntryPath(\n \"../server/middleware-request-headers.js\",\n import.meta.url,\n);\nconst normalizePathModulePath = resolveEntryPath(\"../server/normalize-path.js\", import.meta.url);\nconst appRscHandlerPath = resolveEntryPath(\"../server/app-rsc-handler.js\", import.meta.url);\nconst appRouteHandlerDispatchPath = resolveEntryPath(\n \"../server/app-route-handler-dispatch.js\",\n import.meta.url,\n);\nconst appServerActionExecutionPath = resolveEntryPath(\n \"../server/app-server-action-execution.js\",\n import.meta.url,\n);\nconst appRscErrorsPath = resolveEntryPath(\"../server/app-rsc-errors.js\", import.meta.url);\nconst appPageExecutionPath = resolveEntryPath(\"../server/app-page-execution.js\", import.meta.url);\nconst appFallbackRendererPath = resolveEntryPath(\n \"../server/app-fallback-renderer.js\",\n import.meta.url,\n);\nconst appElementsPath = resolveEntryPath(\"../server/app-elements.js\", import.meta.url);\nconst appPageRouteWiringPath = resolveEntryPath(\n \"../server/app-page-route-wiring.js\",\n import.meta.url,\n);\nconst appPageProbePath = resolveEntryPath(\"../server/app-page-probe.js\", import.meta.url);\nconst appPageParamsPath = resolveEntryPath(\"../server/app-page-params.js\", import.meta.url);\nconst appPageDispatchPath = resolveEntryPath(\"../server/app-page-dispatch.js\", import.meta.url);\nconst appPageRequestPath = resolveEntryPath(\"../server/app-page-request.js\", import.meta.url);\nconst appSegmentConfigPath = resolveEntryPath(\"../server/app-segment-config.js\", import.meta.url);\nconst appRscRouteMatchingPath = resolveEntryPath(\n \"../server/app-rsc-route-matching.js\",\n import.meta.url,\n);\nconst rscStreamHintsPath = resolveEntryPath(\"../server/rsc-stream-hints.js\", import.meta.url);\nconst isrCachePath = resolveEntryPath(\"../server/isr-cache.js\", import.meta.url);\nconst thenableParamsShimPath = resolveEntryPath(\"../shims/thenable-params.js\", import.meta.url);\nconst appPageElementBuilderPath = resolveEntryPath(\n \"../server/app-page-element-builder.js\",\n import.meta.url,\n);\nconst instrumentationRuntimePath = resolveEntryPath(\n \"../server/instrumentation-runtime.js\",\n import.meta.url,\n);\nconst appRscErrorHandlerPath = resolveEntryPath(\n \"../server/app-rsc-error-handler.js\",\n import.meta.url,\n);\nconst appRequestContextPath = resolveEntryPath(\"../server/app-request-context.js\", import.meta.url);\nconst appHookWarningSuppressionPath = resolveEntryPath(\n \"../server/app-hook-warning-suppression.js\",\n import.meta.url,\n);\nconst serverGlobalsPath = resolveEntryPath(\"../server/server-globals.js\", import.meta.url);\n\n/**\n * Resolved config options relevant to App Router request handling.\n * Passed from the Vite plugin where the full next.config.js is loaded.\n */\ntype AppRouterConfig = {\n redirects?: NextRedirect[];\n rewrites?: {\n beforeFiles: NextRewrite[];\n afterFiles: NextRewrite[];\n fallback: NextRewrite[];\n };\n headers?: NextHeader[];\n /** Extra origins allowed for server action CSRF checks (from experimental.serverActions.allowedOrigins). */\n allowedOrigins?: string[];\n /** Extra origins allowed for dev server access (from allowedDevOrigins). */\n allowedDevOrigins?: string[];\n /** Body size limit for server actions in bytes (from experimental.serverActions.bodySizeLimit). */\n bodySizeLimit?: number;\n /**\n * Resolved `assetPrefix` from next.config. Empty string when unset.\n * Embedded in the generated entry so the App Router prod-server reads\n * it from the imported module instead of a sidecar JSON file —\n * matches how the Pages Router entry exposes `vinextConfig.assetPrefix`.\n *\n * @see https://nextjs.org/docs/app/api-reference/config/next-config-js/assetPrefix\n */\n assetPrefix?: string;\n /** Route-level expire fallback in seconds for ISR entries with numeric revalidate. */\n expireTime?: number;\n /** Internationalization routing config for middleware matcher locale handling. */\n i18n?: NextI18nConfig | null;\n /**\n * Absolute path to `app/global-not-found.{tsx,ts,js,jsx}` when present.\n * When provided, route-miss 404s render this module standalone (it owns its\n * own `<html>` and `<body>`) instead of wrapping the regular `not-found.tsx`\n * boundary inside the root layout. Mirrors Next.js 16's\n * `experimental.globalNotFound` behavior.\n * @see https://github.com/vercel/next.js/blob/canary/test/e2e/app-dir/global-not-found\n */\n globalNotFoundPath?: string | null;\n /**\n * When true, the project has a `pages/` directory alongside the App Router.\n * The generated RSC entry exposes `/__vinext/prerender/pages-static-paths`\n * so `prerenderPages` can call `getStaticPaths` via `wrangler unstable_startWorker`\n * in CF Workers builds. `pageRoutes` is loaded from the SSR environment via\n * `import(\"./ssr/index.js\")`, which re-exports it from\n * `virtual:vinext-server-entry` when this flag is set.\n */\n hasPagesDir?: boolean;\n /** Exact public/ file routes, using normalized leading-slash pathnames. */\n publicFiles?: string[];\n};\n\n/**\n * Generate the virtual RSC entry module.\n *\n * This runs in the `rsc` Vite environment (react-server condition).\n * It matches the incoming request URL to an app route, builds the\n * nested layout + page tree, and renders it to an RSC stream.\n */\nexport function generateRscEntry(\n appDir: string,\n routes: AppRoute[],\n middlewarePath?: string | null,\n metadataRoutes?: MetadataFileRoute[],\n globalErrorPath?: string | null,\n basePath?: string,\n trailingSlash?: boolean,\n config?: AppRouterConfig,\n instrumentationPath?: string | null,\n): string {\n const bp = basePath ?? \"\";\n const ts = trailingSlash ?? false;\n const redirects = config?.redirects ?? [];\n const rewrites = config?.rewrites ?? { beforeFiles: [], afterFiles: [], fallback: [] };\n const headers = config?.headers ?? [];\n const allowedOrigins = config?.allowedOrigins ?? [];\n const bodySizeLimit = config?.bodySizeLimit ?? 1 * 1024 * 1024;\n const assetPrefix = config?.assetPrefix ?? \"\";\n const expireTime = config?.expireTime ?? DEFAULT_EXPIRE_TIME;\n const i18nConfig = config?.i18n ?? null;\n const hasPagesDir = config?.hasPagesDir ?? false;\n const publicFiles = config?.publicFiles ?? [];\n const manifestCode = buildAppRscManifestCode({\n routes,\n metadataRoutes,\n globalErrorPath,\n globalNotFoundPath: config?.globalNotFoundPath ?? null,\n });\n const {\n imports,\n routeEntries,\n metaRouteEntries,\n generateStaticParamsEntries,\n rootNotFoundVar,\n rootForbiddenVar,\n rootUnauthorizedVar,\n rootLayoutVars,\n globalErrorVar,\n globalNotFoundVar,\n } = manifestCode;\n const loadPrerenderPagesRoutesCode = hasPagesDir\n ? `\nasync function __loadPrerenderPagesRoutes() {\n const __gspSsrEntry = await import.meta.viteRsc.loadModule(\"ssr\", \"index\");\n return __gspSsrEntry.pageRoutes;\n}\n`\n : \"\";\n\n return `\nimport ${JSON.stringify(serverGlobalsPath)};\nimport {\n renderToReadableStream as _renderToReadableStream,\n decodeAction,\n decodeFormState,\n decodeReply,\n loadServerAction,\n createTemporaryReferenceSet,\n} from \"@vitejs/plugin-rsc/rsc\";\nimport { createRscRenderer } from ${JSON.stringify(rscStreamHintsPath)};\n\nconst renderToReadableStream = createRscRenderer(_renderToReadableStream);\nimport { createElement } from \"react\";\nimport { getNavigationContext as _getNavigationContext } from \"next/navigation\";\nimport { headersContextFromRequest, getDraftModeCookieHeader, getAndClearPendingCookies, consumeDynamicUsage, consumeInvalidDynamicUsageError, setHeadersAccessPhase } from \"next/headers\";\nimport { mergeMetadata, resolveModuleMetadata, mergeViewport, resolveModuleViewport } from \"vinext/metadata\";\n${middlewarePath ? `import * as middlewareModule from ${JSON.stringify(normalizePathSeparators(middlewarePath))};` : \"\"}\n${\n instrumentationPath\n ? `import * as _instrumentation from ${JSON.stringify(normalizePathSeparators(instrumentationPath))};\nimport { ensureInstrumentationRegistered as __ensureInstrumentationRegistered } from ${JSON.stringify(instrumentationRuntimePath)};`\n : \"\"\n}\nimport { createAppRscHandler as __createAppRscHandler } from ${JSON.stringify(appRscHandlerPath)};\nimport { decodePathParams as __decodePathParams } from ${JSON.stringify(normalizePathModulePath)};\nimport { buildRequestHeadersFromMiddlewareResponse as __buildRequestHeadersFromMiddlewareResponse } from ${JSON.stringify(middlewareRequestHeadersPath)};\nimport {\n dispatchAppRouteHandler as __dispatchAppRouteHandler,\n} from ${JSON.stringify(appRouteHandlerDispatchPath)};\nimport {\n handleProgressiveServerActionRequest as __handleProgressiveServerActionRequest,\n handleServerActionRscRequest as __handleServerActionRscRequest,\n readActionBodyWithLimit as __readBodyWithLimit,\n readActionFormDataWithLimit as __readFormDataWithLimit,\n} from ${JSON.stringify(appServerActionExecutionPath)};\nimport {\n sanitizeErrorForClient as __sanitizeErrorForClient,\n} from ${JSON.stringify(appRscErrorsPath)};\nimport { createAppRscOnErrorHandler } from ${JSON.stringify(appRscErrorHandlerPath)};\nimport {\n buildAppPageFontLinkHeader as __buildAppPageFontLinkHeader,\n resolveAppPageSpecialError as __resolveAppPageSpecialError,\n} from ${JSON.stringify(appPageExecutionPath)};\nimport {\n createAppFallbackRenderer as __createAppFallbackRenderer,\n} from ${JSON.stringify(appFallbackRendererPath)};\nimport {\n AppElementsWire as __AppElementsWire,\n} from ${JSON.stringify(appElementsPath)};\nimport {\n resolveAppPageChildSegments as __resolveAppPageChildSegments,\n} from ${JSON.stringify(appPageRouteWiringPath)};\nimport { buildPageElements as __buildPageElements } from ${JSON.stringify(appPageElementBuilderPath)};\nimport {\n resolveAppPageSegmentParams as __resolveAppPageSegmentParams,\n} from ${JSON.stringify(appPageParamsPath)};\nimport { probeAppPage as __probeAppPage } from ${JSON.stringify(appPageProbePath)};\nimport {\n dispatchAppPage as __dispatchAppPage,\n} from ${JSON.stringify(appPageDispatchPath)};\nimport {\n resolveAppPageGenerateStaticParamsSources as __resolveAppPageGenerateStaticParamsSources,\n} from ${JSON.stringify(appPageRequestPath)};\nimport {\n resolveAppPageFetchCacheMode as __resolveAppPageFetchCacheMode,\n resolveAppPageSegmentConfig as __resolveAppPageSegmentConfig,\n} from ${JSON.stringify(appSegmentConfigPath)};\nimport { makeThenableParams } from ${JSON.stringify(thenableParamsShimPath)};\nimport {\n createAppRscRouteMatcher as __createAppRscRouteMatcher,\n} from ${JSON.stringify(appRscRouteMatchingPath)};\nimport {\n appIsrHtmlKey as __isrHtmlKey,\n appIsrRscKey as __isrRscKey,\n appIsrRouteKey as __isrRouteKey,\n isrGet as __isrGet,\n isrSet as __isrSet,\n triggerBackgroundRegeneration as __triggerBackgroundRegeneration,\n} from ${JSON.stringify(isrCachePath)};\n// Import server-only state module to register ALS-backed accessors.\nimport \"vinext/navigation-state\";\nimport { reportRequestError as _reportRequestError } from \"vinext/instrumentation\";\nimport { getSSRFontLinks as _getSSRFontLinks, getSSRFontStyles as _getSSRFontStylesGoogle, getSSRFontPreloads as _getSSRFontPreloadsGoogle } from \"next/font/google\";\nimport { getSSRFontStyles as _getSSRFontStylesLocal, getSSRFontPreloads as _getSSRFontPreloadsLocal } from \"next/font/local\";\nfunction _getSSRFontStyles() { return [..._getSSRFontStylesGoogle(), ..._getSSRFontStylesLocal()]; }\nfunction _getSSRFontPreloads() { return [..._getSSRFontPreloadsGoogle(), ..._getSSRFontPreloadsLocal()]; }\n${hasPagesDir ? `// Pages Router routes are loaded lazily from the SSR environment for internal prerender requests.` : \"\"}\n\n// Suppress expected \"Invalid hook call\" dev warning when layout/page\n// components are probed outside React's render cycle. The import patches\n// console.error once at module load (side-effect) and exposes the ALS\n// so per-route dispatch can opt into suppression via .run(true, ...).\nimport { suppressHookWarningAls } from ${JSON.stringify(appHookWarningSuppressionPath)};\nimport { clearAppRequestContext as __clearRequestContext, setAppNavigationContext as setNavigationContext } from ${JSON.stringify(appRequestContextPath)};\n\n// Note: cache entries are written with \\`headers: undefined\\`. Next.js stores\n// response headers (e.g. set-cookie from cookies().set() during render) in the\n// cache entry so they can be replayed on HIT. We don't do this because:\n// 1. Pages that call cookies().set() during render trigger dynamicUsedDuringRender,\n// which opts them out of ISR caching before we reach the write path.\n// 2. Custom response headers set via next/headers are not yet captured separately\n// from the live Response object in vinext's server pipeline.\n// In practice this means ISR-cached responses won't replay render-time set-cookie\n// headers — but that case is already prevented by the dynamic-usage opt-out.\n// TODO: capture render-time response headers for full Next.js parity.\n// Verbose cache logging — opt in with NEXT_PRIVATE_DEBUG_CACHE=1.\n// Matches the env var Next.js uses for its own cache debug output so operators\n// have a single knob for all cache tracing.\nconst __isrDebug = process.env.NEXT_PRIVATE_DEBUG_CACHE\n ? console.debug.bind(console, \"[vinext] ISR:\")\n : undefined;\n\n// Classification debug — opt in with VINEXT_DEBUG_CLASSIFICATION=1. Gated on\n// the env var so the hot path pays no overhead unless an operator is actively\n// tracing why a layout was flagged static or dynamic. The reason payload is\n// carried by __VINEXT_CLASS_REASONS and consumed inside probeAppPageLayouts.\nconst __classDebug = process.env.VINEXT_DEBUG_CLASSIFICATION\n ? function(layoutId, reason) {\n console.debug(\"[vinext] CLS:\", layoutId, reason);\n }\n : undefined;\n\nfunction __resolveRouteFetchCacheMode(route) {\n return __resolveAppPageFetchCacheMode({\n layouts: route.layouts,\n page: route.page,\n });\n}\n\n${imports.join(\"\\n\")}\n\n${\n instrumentationPath\n ? `// Lazy instrumentation initialisation is handled by ensureInstrumentationRegistered\n// (imported from vinext/instrumentation-runtime). The generated entry only passes\n// the user module in; all bookkeeping (initialized flag, shared promise, prerender\n// skip) lives in the typed helper so it can be unit-tested independently.`\n : \"\"\n}\n\n// Build-time layout classification dispatch. Replaced in generateBundle\n// with a switch statement that returns a pre-computed per-layout\n// Map<layoutIndex, \"static\" | \"dynamic\"> for each route. Until the\n// plugin patches this stub, every route falls back to the Layer 3\n// runtime probe, which is the current (slow) behaviour.\nfunction __VINEXT_CLASS(routeIdx) {\n return null;\n}\n\n// Build-time layout classification reasons dispatch. Sibling of\n// __VINEXT_CLASS, returning a per-route Map<layoutIndex, ClassificationReason>\n// that feeds the debug channel when VINEXT_DEBUG_CLASSIFICATION is active.\n// Replaced in generateBundle with a real dispatch table; the stub returns\n// null so the hot path never allocates reason maps when debug is off.\nfunction __VINEXT_CLASS_REASONS(routeIdx) {\n return null;\n}\n\nconst routes = [\n${routeEntries.join(\",\\n\")}\n];\nconst __routeMatcher = __createAppRscRouteMatcher(routes);\n\nconst metadataRoutes = [\n${metaRouteEntries.join(\",\\n\")}\n];\n\n// Hoisted ahead of __fallbackRenderer / buildPageElements so both can thread\n// the configured basePath through file-based metadata href emission.\nconst __basePath = ${JSON.stringify(bp)};\n\nconst rootNotFoundModule = ${rootNotFoundVar ? rootNotFoundVar : \"null\"};\nconst rootForbiddenModule = ${rootForbiddenVar ? rootForbiddenVar : \"null\"};\nconst rootUnauthorizedModule = ${rootUnauthorizedVar ? rootUnauthorizedVar : \"null\"};\nconst rootLayouts = [${rootLayoutVars.join(\", \")}];\n// Root-level app/global-not-found module. When present, route-miss 404s render\n// this module standalone (it provides its own html/body) instead of wrapping\n// the not-found.tsx boundary inside the root layout. Page-triggered notFound()\n// calls still use the regular not-found.tsx boundary inside the layouts.\n// See https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/app-render.tsx#L495-L520\nconst globalNotFoundModule = ${globalNotFoundVar ? globalNotFoundVar : \"null\"};\n\nconst createRscOnErrorHandler = (request, pathname, routePath) =>\n createAppRscOnErrorHandler(_reportRequestError, request, pathname, routePath);\n\nconst __fallbackRenderer = __createAppFallbackRenderer({\n basePath: __basePath,\n rootBoundaries: {\n rootForbiddenModule,\n rootLayouts,\n rootNotFoundModule,\n rootUnauthorizedModule,\n },\n globalErrorModule: ${globalErrorVar ? globalErrorVar : \"null\"},\n globalNotFoundModule,\n metadataRoutes,\n ssrLoader() {\n return import.meta.viteRsc.loadModule(\"ssr\", \"index\");\n },\n fontProviders: {\n buildFontLinkHeader: __buildAppPageFontLinkHeader,\n getFontLinks: _getSSRFontLinks,\n getFontPreloads: _getSSRFontPreloads,\n getFontStyles: _getSSRFontStyles,\n },\n makeThenableParams,\n sanitizer: __sanitizeErrorForClient,\n rscRenderer: renderToReadableStream,\n getNavigationContext: _getNavigationContext,\n resolveChildSegments: __resolveAppPageChildSegments,\n clearRequestContext() {\n __clearRequestContext();\n },\n createRscOnErrorHandler(request, pathname, routePath) {\n return createRscOnErrorHandler(request, pathname, routePath);\n },\n});\n\nfunction matchRoute(url) {\n return __routeMatcher.matchRoute(url);\n}\n\n/**\n * Check if a pathname matches any intercepting route.\n * Returns the match info or null.\n */\nfunction findIntercept(pathname, sourcePathname = null) {\n return __routeMatcher.findIntercept(pathname, sourcePathname);\n}\n\nasync function buildPageElements(route, params, routePath, pageRequest) {\n return __buildPageElements({\n route,\n params,\n routePath,\n pageRequest,\n globalErrorModule: ${globalErrorVar ? globalErrorVar : \"null\"},\n rootNotFoundModule: ${rootNotFoundVar ? rootNotFoundVar : \"null\"},\n rootForbiddenModule: ${rootForbiddenVar ? rootForbiddenVar : \"null\"},\n rootUnauthorizedModule: ${rootUnauthorizedVar ? rootUnauthorizedVar : \"null\"},\n metadataRoutes,\n basePath: __basePath,\n });\n}\n\nconst __trailingSlash = ${JSON.stringify(ts)};\nconst __i18nConfig = ${JSON.stringify(i18nConfig)};\nconst __configRedirects = ${JSON.stringify(redirects)};\nconst __configRewrites = ${JSON.stringify(rewrites)};\nconst __configHeaders = ${JSON.stringify(headers)};\nconst __publicFiles = new Set(${JSON.stringify(publicFiles)});\nconst __allowedOrigins = ${JSON.stringify(allowedOrigins)};\nconst __expireTime = ${JSON.stringify(expireTime)};\n// Re-exported for the App Router prod-server to consume at startup —\n// mirrors the embedded \\`__basePath\\` pattern (and Pages Router's\n// \\`vinextConfig\\` export). Empty string when unset.\nexport const __assetPrefix = ${JSON.stringify(assetPrefix)};\n\n${generateDevOriginCheckCode(config?.allowedDevOrigins)}\n\n/**\n * Maximum server-action request body size.\n * Configurable via experimental.serverActions.bodySizeLimit in next.config.\n * Defaults to 1MB, matching the Next.js default.\n * @see https://nextjs.org/docs/app/api-reference/config/next-config-js/serverActions#bodysizelimit\n * Prevents unbounded request body buffering.\n */\nvar __MAX_ACTION_BODY_SIZE = ${JSON.stringify(bodySizeLimit)};\n\n// Map from route pattern to generateStaticParams function.\n// Used by the prerender phase to enumerate dynamic route URLs without\n// loading route modules via the dev server.\nexport const generateStaticParamsMap = {\n// TODO: layout-level generateStaticParams — this map only includes routes that\n// have a pagePath (leaf pages). Layout segments can also export generateStaticParams\n// to provide parent params for nested dynamic routes, but they don't have a pagePath\n// so they are excluded here. Supporting layout-level generateStaticParams requires\n// scanning layout.tsx files separately and including them in this map.\n${generateStaticParamsEntries.join(\"\\n\")}\n};${loadPrerenderPagesRoutesCode}\nconst rootParamNamesMap = {\n${routes\n .filter((r) => r.isDynamic && r.pagePath && r.rootParamNames && r.rootParamNames.length > 0)\n .map((r) => ` ${JSON.stringify(r.pattern)}: ${JSON.stringify(r.rootParamNames)},`)\n .join(\"\\n\")}\n};\n\nexport default __createAppRscHandler({\n basePath: __basePath,\n clearRequestContext() {\n __clearRequestContext();\n },\n configHeaders: __configHeaders,\n configRedirects: __configRedirects,\n configRewrites: __configRewrites,\n dispatchMatchedPage({\n cleanPathname,\n formState,\n actionError,\n actionFailed,\n handlerStart,\n interceptionContext,\n isProgressiveActionRender,\n isRscRequest,\n middlewareContext,\n mountedSlotsHeader,\n params,\n request,\n route,\n scriptNonce,\n searchParams,\n renderMode,\n }) {\n const PageComponent = route.page?.default;\n const __segmentConfig = __resolveAppPageSegmentConfig({\n layouts: route.layouts,\n page: route.page,\n });\n const __generateStaticParams = __resolveAppPageGenerateStaticParamsSources({\n layouts: route.layouts,\n layoutTreePositions: route.layoutTreePositions,\n page: route.page,\n routeSegments: route.routeSegments,\n });\n const _asyncRouteParams = makeThenableParams(params);\n return __dispatchAppPage({\n basePath: __basePath,\n buildPageElement(targetRoute, targetParams, targetOpts, targetSearchParams) {\n return buildPageElements(targetRoute, targetParams, cleanPathname, {\n opts: targetOpts,\n searchParams: targetSearchParams,\n isRscRequest,\n request,\n mountedSlotsHeader,\n renderMode,\n });\n },\n cleanPathname,\n clearRequestContext() {\n __clearRequestContext();\n },\n createRscOnErrorHandler(pathname, routePath) {\n return createRscOnErrorHandler(request, pathname, routePath);\n },\n debugClassification: __classDebug,\n dynamicConfig: __segmentConfig.dynamicConfig,\n dynamicParamsConfig: __segmentConfig.dynamicParamsConfig,\n fetchCache: __segmentConfig.fetchCache ?? null,\n findIntercept(pathname) {\n return findIntercept(pathname, interceptionContext);\n },\n generateStaticParams: __generateStaticParams,\n getFontLinks: _getSSRFontLinks,\n getFontPreloads: _getSSRFontPreloads,\n getFontStyles: _getSSRFontStyles,\n getNavigationContext: _getNavigationContext,\n getSourceRoute(sourceRouteIndex) {\n return routes[sourceRouteIndex];\n },\n hasGenerateStaticParams: __generateStaticParams.length > 0,\n hasPageDefaultExport: !!PageComponent,\n hasPageModule: !!route.page,\n handlerStart,\n interceptionContext,\n expireSeconds: __expireTime,\n formState,\n actionError,\n actionFailed,\n isProgressiveActionRender,\n isProduction: process.env.NODE_ENV === \"production\",\n isRscRequest,\n isrDebug: __isrDebug,\n isrGet: __isrGet,\n isrHtmlKey: __isrHtmlKey,\n isrRscKey: __isrRscKey,\n isrSet: __isrSet,\n loadSsrHandler() {\n return import.meta.viteRsc.loadModule(\"ssr\", \"index\");\n },\n middlewareContext,\n mountedSlotsHeader,\n params,\n probeLayoutAt(li) {\n const LayoutComp = route.layouts[li]?.default;\n if (!LayoutComp) return null;\n return LayoutComp({\n params: makeThenableParams(__resolveAppPageSegmentParams(\n route.routeSegments,\n route.layoutTreePositions?.[li] ?? 0,\n params,\n )),\n children: null,\n });\n },\n probePage() {\n return __probeAppPage({\n pageComponent: PageComponent,\n asyncRouteParams: _asyncRouteParams,\n searchParams,\n });\n },\n renderErrorBoundaryPage(renderErr) {\n return __fallbackRenderer.renderErrorBoundary(route, renderErr, isRscRequest, request, params, scriptNonce, middlewareContext);\n },\n renderHttpAccessFallbackPage(statusCode, opts, currentMiddlewareContext) {\n return __fallbackRenderer.renderHttpAccessFallback(route, statusCode, isRscRequest, request, opts, scriptNonce, currentMiddlewareContext);\n },\n renderToReadableStream,\n request,\n revalidateSeconds: __segmentConfig.revalidateSeconds,\n resolveRouteFetchCacheMode(targetRoute) {\n return __resolveRouteFetchCacheMode(targetRoute);\n },\n rootForbiddenModule,\n rootNotFoundModule,\n rootUnauthorizedModule,\n route,\n runWithSuppressedHookWarning(probe) {\n return suppressHookWarningAls.run(true, probe);\n },\n scheduleBackgroundRegeneration(key, renderFn, errorContext) {\n __triggerBackgroundRegeneration(key, renderFn, errorContext);\n },\n scriptNonce,\n searchParams,\n setNavigationContext,\n renderMode,\n });\n },\n dispatchMatchedRouteHandler({\n cleanPathname,\n middlewareContext,\n params,\n request,\n route,\n searchParams,\n }) {\n return __dispatchAppRouteHandler({\n basePath: __basePath,\n cleanPathname,\n clearRequestContext() {\n __clearRequestContext();\n },\n i18n: __i18nConfig,\n isrDebug: __isrDebug,\n isrGet: __isrGet,\n isrRouteKey: __isrRouteKey,\n isrSet: __isrSet,\n middlewareContext,\n middlewareRequestHeaders: middlewareContext.requestHeaders,\n params,\n request,\n route: {\n pattern: route.pattern,\n routeHandler: route.routeHandler,\n routeSegments: route.routeSegments,\n },\n scheduleBackgroundRegeneration: __triggerBackgroundRegeneration,\n searchParams,\n });\n },\n ${\n instrumentationPath\n ? `ensureInstrumentation() {\n return __ensureInstrumentationRegistered(_instrumentation);\n },`\n : \"\"\n }\n handleProgressiveActionRequest({\n actionId,\n cleanPathname,\n contentType,\n middlewareContext,\n request,\n }) {\n return __handleProgressiveServerActionRequest({\n actionId,\n allowedOrigins: __allowedOrigins,\n basePath: __basePath,\n cleanPathname,\n clearRequestContext() {\n __clearRequestContext();\n },\n contentType,\n decodeAction,\n decodeFormState,\n getAndClearPendingCookies,\n getDraftModeCookieHeader,\n maxActionBodySize: __MAX_ACTION_BODY_SIZE,\n middlewareHeaders: middlewareContext.headers,\n readFormDataWithLimit: __readFormDataWithLimit,\n reportRequestError: _reportRequestError,\n request,\n setHeadersAccessPhase,\n });\n },\n handleServerActionRequest({\n actionId,\n cleanPathname,\n contentType,\n interceptionContext,\n isRscRequest,\n middlewareContext,\n mountedSlotsHeader,\n request,\n searchParams,\n }) {\n return __handleServerActionRscRequest({\n actionId,\n allowedOrigins: __allowedOrigins,\n basePath: __basePath,\n buildPageElement({\n route: actionRoute,\n params: actionParams,\n cleanPathname: actionCleanPathname,\n interceptOpts,\n searchParams: actionSearchParams,\n isRscRequest: actionIsRscRequest,\n request: actionRequest,\n mountedSlotsHeader: actionMountedSlotsHeader,\n renderMode: actionRenderMode,\n }) {\n return buildPageElements(actionRoute, actionParams, actionCleanPathname, {\n opts: interceptOpts,\n searchParams: actionSearchParams,\n isRscRequest: actionIsRscRequest,\n request: actionRequest,\n mountedSlotsHeader: actionMountedSlotsHeader,\n renderMode: actionRenderMode,\n });\n },\n cleanPathname,\n clearRequestContext() {\n __clearRequestContext();\n },\n contentType,\n createNotFoundElement(actionRouteId) {\n return {\n ...__AppElementsWire.createMetadataEntries({\n interceptionContext: null,\n rootLayoutTreePath: null,\n routeId: actionRouteId,\n }),\n [actionRouteId]: createElement(\"div\", null, \"Page not found\"),\n };\n },\n createPayloadRouteId(pathnameToRender, currentInterceptionContext) {\n return __AppElementsWire.encodeRouteId(pathnameToRender, currentInterceptionContext);\n },\n createRscOnErrorHandler(actionRequest, actionPathname, routePattern) {\n return createRscOnErrorHandler(actionRequest, actionPathname, routePattern);\n },\n createTemporaryReferenceSet,\n decodeReply,\n findIntercept(pathnameToMatch) {\n return findIntercept(pathnameToMatch, interceptionContext);\n },\n getAndClearPendingCookies,\n getDraftModeCookieHeader,\n getRouteParamNames(sourceRoute) {\n return sourceRoute.params;\n },\n getSourceRoute(sourceRouteIndex) {\n return routes[sourceRouteIndex];\n },\n isRscRequest,\n loadServerAction,\n matchRoute(pathnameToMatch) {\n return matchRoute(pathnameToMatch);\n },\n maxActionBodySize: __MAX_ACTION_BODY_SIZE,\n middlewareHeaders: middlewareContext.headers,\n middlewareStatus: middlewareContext.status,\n mountedSlotsHeader,\n readBodyWithLimit: __readBodyWithLimit,\n readFormDataWithLimit: __readFormDataWithLimit,\n renderToReadableStream,\n reportRequestError: _reportRequestError,\n request,\n sanitizeErrorForClient(error) {\n return __sanitizeErrorForClient(error);\n },\n searchParams,\n setHeadersAccessPhase,\n setNavigationContext,\n toInterceptOpts(intercept) {\n return {\n interceptionContext,\n interceptLayouts: intercept.interceptLayouts,\n interceptSlotId: intercept.slotId,\n interceptSlotKey: intercept.slotKey,\n interceptSourceMatchedUrl: interceptionContext,\n interceptPage: intercept.page,\n interceptParams: intercept.matchedParams,\n };\n },\n });\n },\n i18nConfig: __i18nConfig,\n isMiddlewareProxy: ${JSON.stringify(middlewarePath ? isProxyFile(middlewarePath) : false)},\n ${hasPagesDir ? `loadPrerenderPagesRoutes: __loadPrerenderPagesRoutes,` : \"\"}\n makeThenableParams,\n matchRoute,\n metadataRoutes,\n middlewareModule: ${middlewarePath ? \"middlewareModule\" : \"null\"},\n publicFiles: __publicFiles,\n renderNotFound({ isRscRequest, matchedParams, middlewareContext, request, route, scriptNonce }) {\n return __fallbackRenderer.renderNotFound(route, isRscRequest, request, matchedParams, scriptNonce, middlewareContext);\n },\n ${\n hasPagesDir\n ? `async renderPagesFallback({ isRscRequest, middlewareContext, request, url }) {\n if (isRscRequest) return null;\n\n const __pagesEntry = await import.meta.viteRsc.loadModule(\"ssr\", \"index\");\n if (typeof __pagesEntry.renderPage !== \"function\") return null;\n\n const __pagesRequestHeaders = middlewareContext.requestHeaders\n ? __buildRequestHeadersFromMiddlewareResponse(request.headers, middlewareContext.requestHeaders)\n : null;\n const __pagesRequest = __pagesRequestHeaders\n ? new Request(request.url, { method: request.method, headers: __pagesRequestHeaders })\n : request;\n const __pagesRes = await __pagesEntry.renderPage(\n __pagesRequest,\n __decodePathParams(url.pathname) + (url.search || \"\"),\n {},\n undefined,\n middlewareContext.requestHeaders,\n );\n return __pagesRes.status !== 404 ? __pagesRes : null;\n },`\n : \"\"\n }\n rootParamNamesByPattern: rootParamNamesMap,\n setNavigationContext,\n staticParamsMap: generateStaticParamsMap,\n trailingSlash: __trailingSlash,\n validateDevRequestOrigin: __validateDevRequestOrigin,\n});\n\nif (import.meta.hot) {\n import.meta.hot.accept();\n}\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,MAAM,sBAAsB;AAK5B,MAAM,+BAA+B,iBACnC,2CACA,OAAO,KAAK,IACb;AACD,MAAM,0BAA0B,iBAAiB,+BAA+B,OAAO,KAAK,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@ type AppRscManifestCode = {
|
|
|
12
12
|
rootUnauthorizedVar: string | null;
|
|
13
13
|
rootLayoutVars: string[];
|
|
14
14
|
globalErrorVar: string | null;
|
|
15
|
+
globalNotFoundVar: string | null;
|
|
15
16
|
};
|
|
16
17
|
type BuildAppRscManifestCodeOptions = {
|
|
17
18
|
routes: AppRoute[];
|
|
18
19
|
metadataRoutes?: MetadataFileRoute[];
|
|
19
20
|
globalErrorPath?: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Optional `app/global-not-found.tsx` path. When present, route-miss 404s
|
|
23
|
+
* render this module standalone (it provides its own <html>/<body>) instead
|
|
24
|
+
* of wrapping the regular not-found boundary inside the root layout.
|
|
25
|
+
* Mirrors Next.js 16's `experimental.globalNotFound` behavior.
|
|
26
|
+
* @see https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/app-render.tsx
|
|
27
|
+
*/
|
|
28
|
+
globalNotFoundPath?: string | null;
|
|
20
29
|
};
|
|
21
30
|
declare function buildAppRscManifestCode(options: BuildAppRscManifestCodeOptions): AppRscManifestCode;
|
|
22
31
|
//#endregion
|
|
@@ -67,6 +67,7 @@ function buildRouteEntries(routes, imports) {
|
|
|
67
67
|
const interceptEntries = slot.interceptingRoutes.map((ir) => ` {
|
|
68
68
|
convention: ${JSON.stringify(ir.convention)},
|
|
69
69
|
targetPattern: ${JSON.stringify(ir.targetPattern)},
|
|
70
|
+
sourceMatchPattern: ${JSON.stringify(ir.sourceMatchPattern)},
|
|
70
71
|
interceptLayouts: [${ir.layoutPaths.map((layoutPath) => imports.getImportVar(layoutPath)).join(", ")}],
|
|
71
72
|
page: ${imports.getImportVar(ir.pagePath)},
|
|
72
73
|
params: ${JSON.stringify(ir.params)},
|
|
@@ -142,6 +143,7 @@ function buildAppRscManifestCode(options) {
|
|
|
142
143
|
const rootUnauthorizedVar = rootRoute?.unauthorizedPath ? imports.getImportVar(rootRoute.unauthorizedPath) : null;
|
|
143
144
|
const rootLayoutVars = rootRoute ? rootRoute.layouts.map((l) => imports.getImportVar(l)) : [];
|
|
144
145
|
const globalErrorVar = options.globalErrorPath ? imports.getImportVar(options.globalErrorPath) : null;
|
|
146
|
+
const globalNotFoundVar = options.globalNotFoundPath ? imports.getImportVar(options.globalNotFoundPath) : null;
|
|
145
147
|
const dynamicMetadataRoutes = metadataRoutes.filter((r) => r.isDynamic);
|
|
146
148
|
for (const route of dynamicMetadataRoutes) imports.getImportVar(route.filePath);
|
|
147
149
|
return {
|
|
@@ -153,7 +155,8 @@ function buildAppRscManifestCode(options) {
|
|
|
153
155
|
rootForbiddenVar,
|
|
154
156
|
rootUnauthorizedVar,
|
|
155
157
|
rootLayoutVars,
|
|
156
|
-
globalErrorVar
|
|
158
|
+
globalErrorVar,
|
|
159
|
+
globalNotFoundVar
|
|
157
160
|
};
|
|
158
161
|
}
|
|
159
162
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-rsc-manifest.js","names":[],"sources":["../../src/entries/app-rsc-manifest.ts"],"sourcesContent":["import type { AppRoute } from \"../routing/app-router.js\";\nimport { createMetadataRouteEntriesSource } from \"../server/metadata-route-build-data.js\";\nimport type { MetadataFileRoute } from \"../server/metadata-routes.js\";\nimport { normalizePathSeparators } from \"./runtime-entry-module.js\";\n\ntype AppRscManifestCode = {\n imports: string[];\n routeEntries: string[];\n metaRouteEntries: string[];\n generateStaticParamsEntries: string[];\n rootNotFoundVar: string | null;\n rootForbiddenVar: string | null;\n rootUnauthorizedVar: string | null;\n rootLayoutVars: string[];\n globalErrorVar: string | null;\n};\n\ntype BuildAppRscManifestCodeOptions = {\n routes: AppRoute[];\n metadataRoutes?: MetadataFileRoute[];\n globalErrorPath?: string | null;\n};\n\ntype ImportAllocator = {\n getImportVar(filePath: string): string;\n importMap: ReadonlyMap<string, string>;\n imports: string[];\n};\n\nfunction createImportAllocator(): ImportAllocator {\n const imports: string[] = [];\n const importMap = new Map<string, string>();\n let importIdx = 0;\n\n return {\n importMap,\n imports,\n getImportVar(filePath) {\n const existing = importMap.get(filePath);\n if (existing) return existing;\n\n const varName = `mod_${importIdx++}`;\n const absPath = normalizePathSeparators(filePath);\n imports.push(`import * as ${varName} from ${JSON.stringify(absPath)};`);\n importMap.set(filePath, varName);\n return varName;\n },\n };\n}\n\nfunction registerRouteModules(routes: AppRoute[], imports: ImportAllocator): void {\n for (const route of routes) {\n if (route.pagePath) imports.getImportVar(route.pagePath);\n if (route.routePath) imports.getImportVar(route.routePath);\n for (const layout of route.layouts) imports.getImportVar(layout);\n for (const tmpl of route.templates) imports.getImportVar(tmpl);\n if (route.loadingPath) imports.getImportVar(route.loadingPath);\n if (route.errorPath) imports.getImportVar(route.errorPath);\n if (route.layoutErrorPaths) {\n for (const ep of route.layoutErrorPaths) {\n if (ep) imports.getImportVar(ep);\n }\n }\n if (route.errorPaths) {\n for (const ep of route.errorPaths) {\n imports.getImportVar(ep);\n }\n }\n if (route.notFoundPath) imports.getImportVar(route.notFoundPath);\n if (route.notFoundPaths) {\n for (const nfp of route.notFoundPaths) {\n if (nfp) imports.getImportVar(nfp);\n }\n }\n if (route.forbiddenPath) imports.getImportVar(route.forbiddenPath);\n if (route.forbiddenPaths) {\n for (const fp of route.forbiddenPaths) {\n if (fp) imports.getImportVar(fp);\n }\n }\n if (route.unauthorizedPath) imports.getImportVar(route.unauthorizedPath);\n if (route.unauthorizedPaths) {\n for (const up of route.unauthorizedPaths) {\n if (up) imports.getImportVar(up);\n }\n }\n for (const slot of route.parallelSlots) {\n if (slot.pagePath) imports.getImportVar(slot.pagePath);\n if (slot.defaultPath) imports.getImportVar(slot.defaultPath);\n if (slot.layoutPath) imports.getImportVar(slot.layoutPath);\n if (slot.loadingPath) imports.getImportVar(slot.loadingPath);\n if (slot.errorPath) imports.getImportVar(slot.errorPath);\n for (const ir of slot.interceptingRoutes) {\n imports.getImportVar(ir.pagePath);\n for (const layoutPath of ir.layoutPaths) {\n imports.getImportVar(layoutPath);\n }\n }\n }\n }\n}\n\nfunction buildRouteEntries(routes: AppRoute[], imports: ImportAllocator): string[] {\n return routes.map((route, routeIdx) => {\n const layoutVars = route.layouts.map((l) => imports.getImportVar(l));\n const templateVars = route.templates.map((t) => imports.getImportVar(t));\n const notFoundVars = (route.notFoundPaths ?? []).map((nf) =>\n nf ? imports.getImportVar(nf) : \"null\",\n );\n const forbiddenVars = (route.forbiddenPaths ?? []).map((fp) =>\n fp ? imports.getImportVar(fp) : \"null\",\n );\n const unauthorizedVars = (route.unauthorizedPaths ?? []).map((up) =>\n up ? imports.getImportVar(up) : \"null\",\n );\n const slotEntries = route.parallelSlots.map((slot) => {\n const interceptEntries = slot.interceptingRoutes.map(\n (ir) => ` {\n convention: ${JSON.stringify(ir.convention)},\n targetPattern: ${JSON.stringify(ir.targetPattern)},\n interceptLayouts: [${ir.layoutPaths.map((layoutPath) => imports.getImportVar(layoutPath)).join(\", \")}],\n page: ${imports.getImportVar(ir.pagePath)},\n params: ${JSON.stringify(ir.params)},\n }`,\n );\n return ` ${JSON.stringify(slot.key)}: {\n id: ${JSON.stringify(slot.id ?? null)},\n name: ${JSON.stringify(slot.name)},\n page: ${slot.pagePath ? imports.getImportVar(slot.pagePath) : \"null\"},\n default: ${slot.defaultPath ? imports.getImportVar(slot.defaultPath) : \"null\"},\n layout: ${slot.layoutPath ? imports.getImportVar(slot.layoutPath) : \"null\"},\n loading: ${slot.loadingPath ? imports.getImportVar(slot.loadingPath) : \"null\"},\n error: ${slot.errorPath ? imports.getImportVar(slot.errorPath) : \"null\"},\n layoutIndex: ${slot.layoutIndex},\n routeSegments: ${JSON.stringify(slot.routeSegments)},\n slotPatternParts: ${slot.slotPatternParts ? JSON.stringify(slot.slotPatternParts) : \"null\"},\n slotParamNames: ${slot.slotParamNames ? JSON.stringify(slot.slotParamNames) : \"null\"},\n intercepts: [\n${interceptEntries.join(\",\\n\")}\n ],\n }`;\n });\n const layoutErrorVars = (route.layoutErrorPaths || []).map((ep) =>\n ep ? imports.getImportVar(ep) : \"null\",\n );\n const errorVars = (route.errorPaths ?? []).map((ep) => imports.getImportVar(ep));\n return ` {\n __buildTimeClassifications: __VINEXT_CLASS(${routeIdx}), // evaluated once at module load\n __buildTimeReasons: __classDebug ? __VINEXT_CLASS_REASONS(${routeIdx}) : null,\n ids: ${JSON.stringify(route.ids ?? null)},\n pattern: ${JSON.stringify(route.pattern)},\n patternParts: ${JSON.stringify(route.patternParts)},\n isDynamic: ${route.isDynamic},\n params: ${JSON.stringify(route.params)},\n rootParamNames: ${JSON.stringify(route.rootParamNames ?? [])},\n page: ${route.pagePath ? imports.getImportVar(route.pagePath) : \"null\"},\n routeHandler: ${route.routePath ? imports.getImportVar(route.routePath) : \"null\"},\n layouts: [${layoutVars.join(\", \")}],\n routeSegments: ${JSON.stringify(route.routeSegments)},\n templateTreePositions: ${JSON.stringify(route.templateTreePositions)},\n layoutTreePositions: ${JSON.stringify(route.layoutTreePositions)},\n templates: [${templateVars.join(\", \")}],\n errors: [${layoutErrorVars.join(\", \")}],\n errorPaths: [${errorVars.join(\", \")}],\n errorTreePositions: ${JSON.stringify(route.errorTreePositions ?? null)},\n slots: {\n${slotEntries.join(\",\\n\")}\n },\n loading: ${route.loadingPath ? imports.getImportVar(route.loadingPath) : \"null\"},\n error: ${route.errorPath ? imports.getImportVar(route.errorPath) : \"null\"},\n notFound: ${route.notFoundPath ? imports.getImportVar(route.notFoundPath) : \"null\"},\n notFounds: [${notFoundVars.join(\", \")}],\n forbidden: ${route.forbiddenPath ? imports.getImportVar(route.forbiddenPath) : \"null\"},\n forbiddens: [${forbiddenVars.join(\", \")}],\n unauthorized: ${route.unauthorizedPath ? imports.getImportVar(route.unauthorizedPath) : \"null\"},\n unauthorizeds: [${unauthorizedVars.join(\", \")}],\n }`;\n });\n}\n\nfunction buildGenerateStaticParamsEntries(routes: AppRoute[], imports: ImportAllocator): string[] {\n const entries: string[] = [];\n for (const route of routes) {\n if (!route.isDynamic || !route.pagePath) continue;\n entries.push(\n ` ${JSON.stringify(route.pattern)}: ${imports.getImportVar(route.pagePath)}?.generateStaticParams ?? null,`,\n );\n }\n return entries;\n}\n\nexport function buildAppRscManifestCode(\n options: BuildAppRscManifestCodeOptions,\n): AppRscManifestCode {\n const imports = createImportAllocator();\n const metadataRoutes = options.metadataRoutes ?? [];\n\n registerRouteModules(options.routes, imports);\n const routeEntries = buildRouteEntries(options.routes, imports);\n\n const rootRoute = options.routes.find((r) => r.pattern === \"/\");\n const rootNotFoundVar = rootRoute?.notFoundPath\n ? imports.getImportVar(rootRoute.notFoundPath)\n : null;\n const rootForbiddenVar = rootRoute?.forbiddenPath\n ? imports.getImportVar(rootRoute.forbiddenPath)\n : null;\n const rootUnauthorizedVar = rootRoute?.unauthorizedPath\n ? imports.getImportVar(rootRoute.unauthorizedPath)\n : null;\n const rootLayoutVars = rootRoute ? rootRoute.layouts.map((l) => imports.getImportVar(l)) : [];\n const globalErrorVar = options.globalErrorPath\n ? imports.getImportVar(options.globalErrorPath)\n : null;\n\n const dynamicMetadataRoutes = metadataRoutes.filter((r) => r.isDynamic);\n for (const route of dynamicMetadataRoutes) {\n imports.getImportVar(route.filePath);\n }\n\n return {\n imports: imports.imports,\n routeEntries,\n metaRouteEntries: createMetadataRouteEntriesSource(metadataRoutes, imports.importMap),\n generateStaticParamsEntries: buildGenerateStaticParamsEntries(options.routes, imports),\n rootNotFoundVar,\n rootForbiddenVar,\n rootUnauthorizedVar,\n rootLayoutVars,\n globalErrorVar,\n };\n}\n"],"mappings":";;;AA6BA,SAAS,wBAAyC;CAChD,MAAM,UAAoB,EAAE;CAC5B,MAAM,4BAAY,IAAI,KAAqB;CAC3C,IAAI,YAAY;CAEhB,OAAO;EACL;EACA;EACA,aAAa,UAAU;GACrB,MAAM,WAAW,UAAU,IAAI,SAAS;GACxC,IAAI,UAAU,OAAO;GAErB,MAAM,UAAU,OAAO;GACvB,MAAM,UAAU,wBAAwB,SAAS;GACjD,QAAQ,KAAK,eAAe,QAAQ,QAAQ,KAAK,UAAU,QAAQ,CAA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AE;CAC7F,MAAM,iBAAiB,QAAQ,kBAC3B,QAAQ,aAAa,QAAQ,gBAAgB,GAC7C;CAEJ,MAAM,wBAAwB,eAAe,QAAQ,MAAM,EAAE,UAAU;CACvE,KAAK,MAAM,SAAS,uBAClB,QAAQ,aAAa,MAAM,SAAS;CAGtC,OAAO;EACL,SAAS,QAAQ;EACjB;EACA,kBAAkB,iCAAiC,gBAAgB,QAAQ,UAAU;EACrF,6BAA6B,iCAAiC,QAAQ,QAAQ,QAAQ;EACtF;EACA;EACA;EACA;EACA;EACD"}
|
|
1
|
+
{"version":3,"file":"app-rsc-manifest.js","names":[],"sources":["../../src/entries/app-rsc-manifest.ts"],"sourcesContent":["import type { AppRoute } from \"../routing/app-router.js\";\nimport { createMetadataRouteEntriesSource } from \"../server/metadata-route-build-data.js\";\nimport type { MetadataFileRoute } from \"../server/metadata-routes.js\";\nimport { normalizePathSeparators } from \"./runtime-entry-module.js\";\n\ntype AppRscManifestCode = {\n imports: string[];\n routeEntries: string[];\n metaRouteEntries: string[];\n generateStaticParamsEntries: string[];\n rootNotFoundVar: string | null;\n rootForbiddenVar: string | null;\n rootUnauthorizedVar: string | null;\n rootLayoutVars: string[];\n globalErrorVar: string | null;\n globalNotFoundVar: string | null;\n};\n\ntype BuildAppRscManifestCodeOptions = {\n routes: AppRoute[];\n metadataRoutes?: MetadataFileRoute[];\n globalErrorPath?: string | null;\n /**\n * Optional `app/global-not-found.tsx` path. When present, route-miss 404s\n * render this module standalone (it provides its own <html>/<body>) instead\n * of wrapping the regular not-found boundary inside the root layout.\n * Mirrors Next.js 16's `experimental.globalNotFound` behavior.\n * @see https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/app-render.tsx\n */\n globalNotFoundPath?: string | null;\n};\n\ntype ImportAllocator = {\n getImportVar(filePath: string): string;\n importMap: ReadonlyMap<string, string>;\n imports: string[];\n};\n\nfunction createImportAllocator(): ImportAllocator {\n const imports: string[] = [];\n const importMap = new Map<string, string>();\n let importIdx = 0;\n\n return {\n importMap,\n imports,\n getImportVar(filePath) {\n const existing = importMap.get(filePath);\n if (existing) return existing;\n\n const varName = `mod_${importIdx++}`;\n const absPath = normalizePathSeparators(filePath);\n imports.push(`import * as ${varName} from ${JSON.stringify(absPath)};`);\n importMap.set(filePath, varName);\n return varName;\n },\n };\n}\n\nfunction registerRouteModules(routes: AppRoute[], imports: ImportAllocator): void {\n for (const route of routes) {\n if (route.pagePath) imports.getImportVar(route.pagePath);\n if (route.routePath) imports.getImportVar(route.routePath);\n for (const layout of route.layouts) imports.getImportVar(layout);\n for (const tmpl of route.templates) imports.getImportVar(tmpl);\n if (route.loadingPath) imports.getImportVar(route.loadingPath);\n if (route.errorPath) imports.getImportVar(route.errorPath);\n if (route.layoutErrorPaths) {\n for (const ep of route.layoutErrorPaths) {\n if (ep) imports.getImportVar(ep);\n }\n }\n if (route.errorPaths) {\n for (const ep of route.errorPaths) {\n imports.getImportVar(ep);\n }\n }\n if (route.notFoundPath) imports.getImportVar(route.notFoundPath);\n if (route.notFoundPaths) {\n for (const nfp of route.notFoundPaths) {\n if (nfp) imports.getImportVar(nfp);\n }\n }\n if (route.forbiddenPath) imports.getImportVar(route.forbiddenPath);\n if (route.forbiddenPaths) {\n for (const fp of route.forbiddenPaths) {\n if (fp) imports.getImportVar(fp);\n }\n }\n if (route.unauthorizedPath) imports.getImportVar(route.unauthorizedPath);\n if (route.unauthorizedPaths) {\n for (const up of route.unauthorizedPaths) {\n if (up) imports.getImportVar(up);\n }\n }\n for (const slot of route.parallelSlots) {\n if (slot.pagePath) imports.getImportVar(slot.pagePath);\n if (slot.defaultPath) imports.getImportVar(slot.defaultPath);\n if (slot.layoutPath) imports.getImportVar(slot.layoutPath);\n if (slot.loadingPath) imports.getImportVar(slot.loadingPath);\n if (slot.errorPath) imports.getImportVar(slot.errorPath);\n for (const ir of slot.interceptingRoutes) {\n imports.getImportVar(ir.pagePath);\n for (const layoutPath of ir.layoutPaths) {\n imports.getImportVar(layoutPath);\n }\n }\n }\n }\n}\n\nfunction buildRouteEntries(routes: AppRoute[], imports: ImportAllocator): string[] {\n return routes.map((route, routeIdx) => {\n const layoutVars = route.layouts.map((l) => imports.getImportVar(l));\n const templateVars = route.templates.map((t) => imports.getImportVar(t));\n const notFoundVars = (route.notFoundPaths ?? []).map((nf) =>\n nf ? imports.getImportVar(nf) : \"null\",\n );\n const forbiddenVars = (route.forbiddenPaths ?? []).map((fp) =>\n fp ? imports.getImportVar(fp) : \"null\",\n );\n const unauthorizedVars = (route.unauthorizedPaths ?? []).map((up) =>\n up ? imports.getImportVar(up) : \"null\",\n );\n const slotEntries = route.parallelSlots.map((slot) => {\n const interceptEntries = slot.interceptingRoutes.map(\n (ir) => ` {\n convention: ${JSON.stringify(ir.convention)},\n targetPattern: ${JSON.stringify(ir.targetPattern)},\n sourceMatchPattern: ${JSON.stringify(ir.sourceMatchPattern)},\n interceptLayouts: [${ir.layoutPaths.map((layoutPath) => imports.getImportVar(layoutPath)).join(\", \")}],\n page: ${imports.getImportVar(ir.pagePath)},\n params: ${JSON.stringify(ir.params)},\n }`,\n );\n return ` ${JSON.stringify(slot.key)}: {\n id: ${JSON.stringify(slot.id ?? null)},\n name: ${JSON.stringify(slot.name)},\n page: ${slot.pagePath ? imports.getImportVar(slot.pagePath) : \"null\"},\n default: ${slot.defaultPath ? imports.getImportVar(slot.defaultPath) : \"null\"},\n layout: ${slot.layoutPath ? imports.getImportVar(slot.layoutPath) : \"null\"},\n loading: ${slot.loadingPath ? imports.getImportVar(slot.loadingPath) : \"null\"},\n error: ${slot.errorPath ? imports.getImportVar(slot.errorPath) : \"null\"},\n layoutIndex: ${slot.layoutIndex},\n routeSegments: ${JSON.stringify(slot.routeSegments)},\n slotPatternParts: ${slot.slotPatternParts ? JSON.stringify(slot.slotPatternParts) : \"null\"},\n slotParamNames: ${slot.slotParamNames ? JSON.stringify(slot.slotParamNames) : \"null\"},\n intercepts: [\n${interceptEntries.join(\",\\n\")}\n ],\n }`;\n });\n const layoutErrorVars = (route.layoutErrorPaths || []).map((ep) =>\n ep ? imports.getImportVar(ep) : \"null\",\n );\n const errorVars = (route.errorPaths ?? []).map((ep) => imports.getImportVar(ep));\n return ` {\n __buildTimeClassifications: __VINEXT_CLASS(${routeIdx}), // evaluated once at module load\n __buildTimeReasons: __classDebug ? __VINEXT_CLASS_REASONS(${routeIdx}) : null,\n ids: ${JSON.stringify(route.ids ?? null)},\n pattern: ${JSON.stringify(route.pattern)},\n patternParts: ${JSON.stringify(route.patternParts)},\n isDynamic: ${route.isDynamic},\n params: ${JSON.stringify(route.params)},\n rootParamNames: ${JSON.stringify(route.rootParamNames ?? [])},\n page: ${route.pagePath ? imports.getImportVar(route.pagePath) : \"null\"},\n routeHandler: ${route.routePath ? imports.getImportVar(route.routePath) : \"null\"},\n layouts: [${layoutVars.join(\", \")}],\n routeSegments: ${JSON.stringify(route.routeSegments)},\n templateTreePositions: ${JSON.stringify(route.templateTreePositions)},\n layoutTreePositions: ${JSON.stringify(route.layoutTreePositions)},\n templates: [${templateVars.join(\", \")}],\n errors: [${layoutErrorVars.join(\", \")}],\n errorPaths: [${errorVars.join(\", \")}],\n errorTreePositions: ${JSON.stringify(route.errorTreePositions ?? null)},\n slots: {\n${slotEntries.join(\",\\n\")}\n },\n loading: ${route.loadingPath ? imports.getImportVar(route.loadingPath) : \"null\"},\n error: ${route.errorPath ? imports.getImportVar(route.errorPath) : \"null\"},\n notFound: ${route.notFoundPath ? imports.getImportVar(route.notFoundPath) : \"null\"},\n notFounds: [${notFoundVars.join(\", \")}],\n forbidden: ${route.forbiddenPath ? imports.getImportVar(route.forbiddenPath) : \"null\"},\n forbiddens: [${forbiddenVars.join(\", \")}],\n unauthorized: ${route.unauthorizedPath ? imports.getImportVar(route.unauthorizedPath) : \"null\"},\n unauthorizeds: [${unauthorizedVars.join(\", \")}],\n }`;\n });\n}\n\nfunction buildGenerateStaticParamsEntries(routes: AppRoute[], imports: ImportAllocator): string[] {\n const entries: string[] = [];\n for (const route of routes) {\n if (!route.isDynamic || !route.pagePath) continue;\n entries.push(\n ` ${JSON.stringify(route.pattern)}: ${imports.getImportVar(route.pagePath)}?.generateStaticParams ?? null,`,\n );\n }\n return entries;\n}\n\nexport function buildAppRscManifestCode(\n options: BuildAppRscManifestCodeOptions,\n): AppRscManifestCode {\n const imports = createImportAllocator();\n const metadataRoutes = options.metadataRoutes ?? [];\n\n registerRouteModules(options.routes, imports);\n const routeEntries = buildRouteEntries(options.routes, imports);\n\n const rootRoute = options.routes.find((r) => r.pattern === \"/\");\n const rootNotFoundVar = rootRoute?.notFoundPath\n ? imports.getImportVar(rootRoute.notFoundPath)\n : null;\n const rootForbiddenVar = rootRoute?.forbiddenPath\n ? imports.getImportVar(rootRoute.forbiddenPath)\n : null;\n const rootUnauthorizedVar = rootRoute?.unauthorizedPath\n ? imports.getImportVar(rootRoute.unauthorizedPath)\n : null;\n const rootLayoutVars = rootRoute ? rootRoute.layouts.map((l) => imports.getImportVar(l)) : [];\n const globalErrorVar = options.globalErrorPath\n ? imports.getImportVar(options.globalErrorPath)\n : null;\n const globalNotFoundVar = options.globalNotFoundPath\n ? imports.getImportVar(options.globalNotFoundPath)\n : null;\n\n const dynamicMetadataRoutes = metadataRoutes.filter((r) => r.isDynamic);\n for (const route of dynamicMetadataRoutes) {\n imports.getImportVar(route.filePath);\n }\n\n return {\n imports: imports.imports,\n routeEntries,\n metaRouteEntries: createMetadataRouteEntriesSource(metadataRoutes, imports.importMap),\n generateStaticParamsEntries: buildGenerateStaticParamsEntries(options.routes, imports),\n rootNotFoundVar,\n rootForbiddenVar,\n rootUnauthorizedVar,\n rootLayoutVars,\n globalErrorVar,\n globalNotFoundVar,\n };\n}\n"],"mappings":";;;AAsCA,SAAS,wBAAyC;CAChD,MAAM,UAAoB,EAAE;CAC5B,MAAM,4BAAY,IAAI,KAAqB;CAC3C,IAAI,YAAY;CAEhB,OAAO;EACL;EACA;EACA,aAAa,UAAU;GACrB,MAAM,WAAW,UAAU,IAAI,SA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,QAAQ,aAAa,UAAU,cAAc,GAC7C;CACJ,MAAM,sBAAsB,WAAW,mBACnC,QAAQ,aAAa,UAAU,iBAAiB,GAChD;CACJ,MAAM,iBAAiB,YAAY,UAAU,QAAQ,KAAK,MAAM,QAAQ,aAAa,EAAE,CAAC,GAAG,EAAE;CAC7F,MAAM,iBAAiB,QAAQ,kBAC3B,QAAQ,aAAa,QAAQ,gBAAgB,GAC7C;CACJ,MAAM,oBAAoB,QAAQ,qBAC9B,QAAQ,aAAa,QAAQ,mBAAmB,GAChD;CAEJ,MAAM,wBAAwB,eAAe,QAAQ,MAAM,EAAE,UAAU;CACvE,KAAK,MAAM,SAAS,uBAClB,QAAQ,aAAa,MAAM,SAAS;CAGtC,OAAO;EACL,SAAS,QAAQ;EACjB;EACA,kBAAkB,iCAAiC,gBAAgB,QAAQ,UAAU;EACrF,6BAA6B,iCAAiC,QAAQ,QAAQ,QAAQ;EACtF;EACA;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -28,10 +28,7 @@ async function generateClientEntry(pagesDir, nextConfig, fileMatcher) {
|
|
|
28
28
|
import "vinext/instrumentation-client";
|
|
29
29
|
import React from "react";
|
|
30
30
|
import { hydrateRoot } from "react-dom/client";
|
|
31
|
-
|
|
32
|
-
// registered. Without this, browser back/forward buttons do nothing because
|
|
33
|
-
// navigateClient() is never invoked on history changes.
|
|
34
|
-
import "next/router";
|
|
31
|
+
import { installPagesRouterRuntime } from "vinext/pages-router-runtime";
|
|
35
32
|
|
|
36
33
|
const pageLoaders = {
|
|
37
34
|
${loaderEntries.join(",\n")}
|
|
@@ -72,7 +69,7 @@ async function hydrate() {
|
|
|
72
69
|
element = React.createElement(PageComponent, pageProps);
|
|
73
70
|
`}
|
|
74
71
|
|
|
75
|
-
// Wrap with RouterContext.Provider so next/compat/router
|
|
72
|
+
// Wrap with RouterContext.Provider so next/router and next/compat/router work during hydration.
|
|
76
73
|
const { wrapWithRouterContext } = await import("next/router");
|
|
77
74
|
element = wrapWithRouterContext(element);
|
|
78
75
|
|
|
@@ -84,6 +81,7 @@ async function hydrate() {
|
|
|
84
81
|
|
|
85
82
|
const root = hydrateRoot(container, element);
|
|
86
83
|
window.__VINEXT_ROOT__ = root;
|
|
84
|
+
installPagesRouterRuntime();
|
|
87
85
|
window.__VINEXT_HYDRATED_AT = performance.now();
|
|
88
86
|
}
|
|
89
87
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pages-client-entry.js","names":["pagesPatternToNextFormat"],"sources":["../../src/entries/pages-client-entry.ts"],"sourcesContent":["/**\n * Pages Router client hydration entry generator.\n *\n * Generates the virtual client entry module (`virtual:vinext-client-entry`).\n * This is the entry point for `vite build` (client bundle). It maps route\n * patterns to dynamic imports of page modules so Vite code-splits each page\n * into its own chunk. At runtime it reads __NEXT_DATA__ to determine which\n * page to hydrate.\n *\n * Extracted from index.ts.\n */\nimport {\n pagesRouter,\n patternToNextFormat as pagesPatternToNextFormat,\n type Route,\n} from \"../routing/pages-router.js\";\nimport { createValidFileMatcher } from \"../routing/file-matcher.js\";\nimport { type ResolvedNextConfig } from \"../config/next-config.js\";\nimport { findFileWithExts } from \"./pages-entry-helpers.js\";\nimport { normalizePathSeparators } from \"./runtime-entry-module.js\";\n\nexport async function generateClientEntry(\n pagesDir: string,\n nextConfig: ResolvedNextConfig,\n fileMatcher: ReturnType<typeof createValidFileMatcher>,\n): Promise<string> {\n const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);\n\n const appFilePath = findFileWithExts(pagesDir, \"_app\", fileMatcher);\n const hasApp = appFilePath !== null;\n\n // Build a map of route pattern -> dynamic import.\n // Keys must use Next.js bracket format (e.g. \"/user/[id]\") to match\n // __NEXT_DATA__.page which is set via patternToNextFormat() during SSR.\n const loaderEntries = pageRoutes.map((r: Route) => {\n const absPath = normalizePathSeparators(r.filePath);\n const nextFormatPattern = pagesPatternToNextFormat(r.pattern);\n // JSON.stringify safely escapes quotes, backslashes, and special chars in\n // both the route pattern and the absolute file path.\n // lgtm[js/bad-code-sanitization]\n return ` ${JSON.stringify(nextFormatPattern)}: () => import(${JSON.stringify(absPath)})`;\n });\n\n const appFileBase = appFilePath ? normalizePathSeparators(appFilePath) : undefined;\n\n return `\nimport \"vinext/instrumentation-client\";\nimport React from \"react\";\nimport { hydrateRoot } from \"react-dom/client\";\
|
|
1
|
+
{"version":3,"file":"pages-client-entry.js","names":["pagesPatternToNextFormat"],"sources":["../../src/entries/pages-client-entry.ts"],"sourcesContent":["/**\n * Pages Router client hydration entry generator.\n *\n * Generates the virtual client entry module (`virtual:vinext-client-entry`).\n * This is the entry point for `vite build` (client bundle). It maps route\n * patterns to dynamic imports of page modules so Vite code-splits each page\n * into its own chunk. At runtime it reads __NEXT_DATA__ to determine which\n * page to hydrate.\n *\n * Extracted from index.ts.\n */\nimport {\n pagesRouter,\n patternToNextFormat as pagesPatternToNextFormat,\n type Route,\n} from \"../routing/pages-router.js\";\nimport { createValidFileMatcher } from \"../routing/file-matcher.js\";\nimport { type ResolvedNextConfig } from \"../config/next-config.js\";\nimport { findFileWithExts } from \"./pages-entry-helpers.js\";\nimport { normalizePathSeparators } from \"./runtime-entry-module.js\";\n\nexport async function generateClientEntry(\n pagesDir: string,\n nextConfig: ResolvedNextConfig,\n fileMatcher: ReturnType<typeof createValidFileMatcher>,\n): Promise<string> {\n const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);\n\n const appFilePath = findFileWithExts(pagesDir, \"_app\", fileMatcher);\n const hasApp = appFilePath !== null;\n\n // Build a map of route pattern -> dynamic import.\n // Keys must use Next.js bracket format (e.g. \"/user/[id]\") to match\n // __NEXT_DATA__.page which is set via patternToNextFormat() during SSR.\n const loaderEntries = pageRoutes.map((r: Route) => {\n const absPath = normalizePathSeparators(r.filePath);\n const nextFormatPattern = pagesPatternToNextFormat(r.pattern);\n // JSON.stringify safely escapes quotes, backslashes, and special chars in\n // both the route pattern and the absolute file path.\n // lgtm[js/bad-code-sanitization]\n return ` ${JSON.stringify(nextFormatPattern)}: () => import(${JSON.stringify(absPath)})`;\n });\n\n const appFileBase = appFilePath ? normalizePathSeparators(appFilePath) : undefined;\n\n return `\nimport \"vinext/instrumentation-client\";\nimport React from \"react\";\nimport { hydrateRoot } from \"react-dom/client\";\nimport { installPagesRouterRuntime } from \"vinext/pages-router-runtime\";\n\nconst pageLoaders = {\n${loaderEntries.join(\",\\n\")}\n};\n\nasync function hydrate() {\n const nextData = window.__NEXT_DATA__;\n if (!nextData) {\n console.error(\"[vinext] No __NEXT_DATA__ found\");\n return;\n }\n\n const { pageProps } = nextData.props;\n const loader = pageLoaders[nextData.page];\n if (!loader) {\n console.error(\"[vinext] No page loader for route:\", nextData.page);\n return;\n }\n\n const pageModule = await loader();\n const PageComponent = pageModule.default;\n if (!PageComponent) {\n console.error(\"[vinext] Page module has no default export\");\n return;\n }\n\n let element;\n ${\n hasApp\n ? `\n try {\n const appModule = await import(${JSON.stringify(appFileBase!)});\n const AppComponent = appModule.default;\n window.__VINEXT_APP__ = AppComponent;\n element = React.createElement(AppComponent, { Component: PageComponent, pageProps });\n } catch {\n element = React.createElement(PageComponent, pageProps);\n }\n `\n : `\n element = React.createElement(PageComponent, pageProps);\n `\n }\n\n // Wrap with RouterContext.Provider so next/router and next/compat/router work during hydration.\n const { wrapWithRouterContext } = await import(\"next/router\");\n element = wrapWithRouterContext(element);\n\n const container = document.getElementById(\"__next\");\n if (!container) {\n console.error(\"[vinext] No #__next element found\");\n return;\n }\n\n const root = hydrateRoot(container, element);\n window.__VINEXT_ROOT__ = root;\n installPagesRouterRuntime();\n window.__VINEXT_HYDRATED_AT = performance.now();\n}\n\nhydrate();\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAqBA,eAAsB,oBACpB,UACA,YACA,aACiB;CACjB,MAAM,aAAa,MAAM,YAAY,UAAU,YAAY,gBAAgB,YAAY;CAEvF,MAAM,cAAc,iBAAiB,UAAU,QAAQ,YAAY;CACnE,MAAM,SAAS,gBAAgB;CAK/B,MAAM,gBAAgB,WAAW,KAAK,MAAa;EACjD,MAAM,UAAU,wBAAwB,EAAE,SAAS;EACnD,MAAM,oBAAoBA,oBAAyB,EAAE,QAAQ;EAI7D,OAAO,KAAK,KAAK,UAAU,kBAAkB,CAAC,iBAAiB,KAAK,UAAU,QAAQ,CAAC;GACvF;CAEF,MAAM,cAAc,cAAc,wBAAwB,YAAY,GAAG,KAAA;CAEzE,OAAO;;;;;;;EAOP,cAAc,KAAK,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;IA0BxB,SACI;;qCAE6B,KAAK,UAAU,YAAa,CAAC;;;;;;;MAQ1D;;IAGL"}
|
|
@@ -22,6 +22,7 @@ const _pagesNodeCompatPath = resolveEntryPath("../server/pages-node-compat.js",
|
|
|
22
22
|
const _pagesApiRoutePath = resolveEntryPath("../server/pages-api-route.js", import.meta.url);
|
|
23
23
|
const _isrCachePath = resolveEntryPath("../server/isr-cache.js", import.meta.url);
|
|
24
24
|
const _cspPath = resolveEntryPath("../server/csp.js", import.meta.url);
|
|
25
|
+
const _serverGlobalsPath = resolveEntryPath("../server/server-globals.js", import.meta.url);
|
|
25
26
|
/**
|
|
26
27
|
* Generate the virtual SSR server entry module.
|
|
27
28
|
* This is the entry point for `vite build --ssr`.
|
|
@@ -44,6 +45,7 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
|
|
|
44
45
|
const apiRouteEntries = apiRoutes.map((r, i) => ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: api_${i} }`);
|
|
45
46
|
const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
|
|
46
47
|
const docFilePath = findFileWithExts(pagesDir, "_document", fileMatcher);
|
|
48
|
+
const appAssetPathJson = appFilePath !== null ? JSON.stringify(normalizePathSeparators(appFilePath)) : "null";
|
|
47
49
|
const appImportCode = appFilePath !== null ? `import { default as AppComponent } from ${JSON.stringify(normalizePathSeparators(appFilePath))};` : `const AppComponent = null;`;
|
|
48
50
|
const docImportCode = docFilePath !== null ? `import { default as DocumentComponent } from ${JSON.stringify(normalizePathSeparators(docFilePath))};` : `const DocumentComponent = null;`;
|
|
49
51
|
const i18nConfigJson = nextConfig?.i18n ? JSON.stringify({
|
|
@@ -55,6 +57,7 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
|
|
|
55
57
|
const buildIdJson = JSON.stringify(nextConfig?.buildId ?? null);
|
|
56
58
|
const vinextConfigJson = JSON.stringify({
|
|
57
59
|
basePath: nextConfig?.basePath ?? "",
|
|
60
|
+
assetPrefix: nextConfig?.assetPrefix ?? "",
|
|
58
61
|
trailingSlash: nextConfig?.trailingSlash ?? false,
|
|
59
62
|
redirects: nextConfig?.redirects ?? [],
|
|
60
63
|
rewrites: nextConfig?.rewrites ?? {
|
|
@@ -102,6 +105,7 @@ export async function runMiddleware(request, ctx) {
|
|
|
102
105
|
export async function runMiddleware() { return { continue: true }; }
|
|
103
106
|
`;
|
|
104
107
|
return `
|
|
108
|
+
import ${JSON.stringify(_serverGlobalsPath)};
|
|
105
109
|
import React from "react";
|
|
106
110
|
import { renderToReadableStream } from "react-dom/server.edge";
|
|
107
111
|
import { resetSSRHead, getSSRHeadHTML } from "next/head";
|
|
@@ -150,6 +154,11 @@ const buildId = ${buildIdJson};
|
|
|
150
154
|
// Full resolved config for production server (embedded at build time)
|
|
151
155
|
export const vinextConfig = ${vinextConfigJson};
|
|
152
156
|
|
|
157
|
+
// Path to the user's pages/_app file (or null). Used to look up the
|
|
158
|
+
// _app's CSS/JS chunks in the SSR manifest so any global styles imported
|
|
159
|
+
// by _app are included in every page's <link rel="stylesheet"> set.
|
|
160
|
+
const _appAssetPath = ${appAssetPathJson};
|
|
161
|
+
|
|
153
162
|
function isrGet(key) {
|
|
154
163
|
return __sharedIsrGet(key);
|
|
155
164
|
}
|
|
@@ -518,7 +527,16 @@ async function _renderPage(request, url, manifest, middlewareHeaders) {
|
|
|
518
527
|
var gsspRes = pageDataResult.gsspRes;
|
|
519
528
|
let isrRevalidateSeconds = pageDataResult.isrRevalidateSeconds;
|
|
520
529
|
|
|
521
|
-
|
|
530
|
+
// Include both the matched page module and the global _app module
|
|
531
|
+
// (if present). _app is wrapped around every page in Pages Router,
|
|
532
|
+
// and any CSS/JS it imports must be linked from the rendered HTML
|
|
533
|
+
// so the browser actually loads it. Without _app in this list, a
|
|
534
|
+
// global stylesheet imported via import "./globals.scss" in
|
|
535
|
+
// _app.tsx never reaches the page, producing the LHF-5 symptom
|
|
536
|
+
// where styled elements render with the browser default colour.
|
|
537
|
+
const pageModuleIds = [];
|
|
538
|
+
if (route.filePath) pageModuleIds.push(route.filePath);
|
|
539
|
+
if (_appAssetPath) pageModuleIds.push(_appAssetPath);
|
|
522
540
|
const assetTags = collectAssetTags(manifest, pageModuleIds, scriptNonce);
|
|
523
541
|
|
|
524
542
|
return __renderPagesPageResponse({
|