vinext 0.0.53 → 0.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/inline-css.d.ts +7 -0
- package/dist/build/inline-css.js +50 -0
- package/dist/build/inline-css.js.map +1 -0
- package/dist/build/prerender.js +2 -1
- package/dist/build/prerender.js.map +1 -1
- package/dist/check.js +4 -0
- package/dist/check.js.map +1 -1
- package/dist/client/navigation-runtime.d.ts +2 -1
- package/dist/client/navigation-runtime.js.map +1 -1
- package/dist/client/window-next.d.ts +7 -0
- package/dist/client/window-next.js.map +1 -1
- package/dist/config/next-config.d.ts +83 -1
- package/dist/config/next-config.js +131 -2
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.js +13 -0
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.d.ts +11 -1
- package/dist/entries/app-browser-entry.js +16 -6
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.d.ts +8 -1
- package/dist/entries/app-rsc-entry.js +18 -5
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-rsc-manifest.d.ts +21 -1
- package/dist/entries/app-rsc-manifest.js +6 -4
- package/dist/entries/app-rsc-manifest.js.map +1 -1
- package/dist/entries/pages-client-entry.d.ts +4 -1
- package/dist/entries/pages-client-entry.js +18 -2
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-server-entry.js +82 -4
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/entries/runtime-entry-module.d.ts +1 -10
- package/dist/entries/runtime-entry-module.js +2 -12
- package/dist/entries/runtime-entry-module.js.map +1 -1
- package/dist/index.js +63 -5
- package/dist/index.js.map +1 -1
- package/dist/plugins/remove-console.d.ts +16 -0
- package/dist/plugins/remove-console.js +176 -0
- package/dist/plugins/remove-console.js.map +1 -0
- package/dist/routing/app-route-graph.d.ts +24 -1
- package/dist/routing/app-route-graph.js +52 -4
- package/dist/routing/app-route-graph.js.map +1 -1
- package/dist/routing/app-router.d.ts +2 -2
- package/dist/routing/app-router.js +2 -2
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/file-matcher.d.ts +21 -1
- package/dist/routing/file-matcher.js +39 -1
- package/dist/routing/file-matcher.js.map +1 -1
- package/dist/routing/pages-router.d.ts +1 -1
- package/dist/routing/pages-router.js +10 -3
- package/dist/routing/pages-router.js.map +1 -1
- package/dist/server/api-handler.js +1 -1
- package/dist/server/app-browser-entry.js +25 -16
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-browser-navigation-controller.d.ts +2 -0
- package/dist/server/app-browser-navigation-controller.js +4 -0
- package/dist/server/app-browser-navigation-controller.js.map +1 -1
- package/dist/server/app-elements-wire.d.ts +13 -4
- package/dist/server/app-elements-wire.js +10 -1
- package/dist/server/app-elements-wire.js.map +1 -1
- package/dist/server/app-elements.d.ts +2 -2
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-elements.js.map +1 -1
- package/dist/server/app-fallback-renderer.d.ts +15 -5
- package/dist/server/app-fallback-renderer.js +10 -4
- package/dist/server/app-fallback-renderer.js.map +1 -1
- package/dist/server/app-inline-css-client.d.ts +7 -0
- package/dist/server/app-inline-css-client.js +37 -0
- package/dist/server/app-inline-css-client.js.map +1 -0
- package/dist/server/app-page-boundary.d.ts +21 -1
- package/dist/server/app-page-boundary.js +28 -3
- package/dist/server/app-page-boundary.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +7 -3
- package/dist/server/app-page-cache.js +7 -7
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +10 -1
- package/dist/server/app-page-dispatch.js +126 -79
- package/dist/server/app-page-dispatch.js.map +1 -1
- package/dist/server/app-page-element-builder.js +12 -28
- package/dist/server/app-page-element-builder.js.map +1 -1
- package/dist/server/app-page-render-identity.d.ts +22 -0
- package/dist/server/app-page-render-identity.js +42 -0
- package/dist/server/app-page-render-identity.js.map +1 -0
- package/dist/server/app-page-render.d.ts +8 -1
- package/dist/server/app-page-render.js +4 -1
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-request.d.ts +6 -3
- package/dist/server/app-page-request.js +5 -2
- package/dist/server/app-page-request.js.map +1 -1
- package/dist/server/app-page-response.js +2 -2
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +15 -0
- package/dist/server/app-page-route-wiring.js +7 -5
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-stream.d.ts +11 -0
- package/dist/server/app-page-stream.js +1 -0
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-route-handler-response.js +37 -5
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-rsc-handler.d.ts +14 -3
- package/dist/server/app-rsc-handler.js +45 -5
- package/dist/server/app-rsc-handler.js.map +1 -1
- package/dist/server/app-rsc-request-normalization.d.ts +2 -1
- package/dist/server/app-rsc-request-normalization.js +3 -2
- package/dist/server/app-rsc-request-normalization.js.map +1 -1
- package/dist/server/app-server-action-execution.d.ts +21 -3
- package/dist/server/app-server-action-execution.js +42 -7
- package/dist/server/app-server-action-execution.js.map +1 -1
- package/dist/server/app-ssr-entry.d.ts +6 -0
- package/dist/server/app-ssr-entry.js +22 -7
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-error-meta.js +3 -3
- package/dist/server/app-ssr-error-meta.js.map +1 -1
- package/dist/server/app-ssr-stream.d.ts +2 -1
- package/dist/server/app-ssr-stream.js +176 -31
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/client-trace-metadata.d.ts +31 -0
- package/dist/server/client-trace-metadata.js +83 -0
- package/dist/server/client-trace-metadata.js.map +1 -0
- package/dist/server/cookie-utils.d.ts +13 -0
- package/dist/server/cookie-utils.js +20 -0
- package/dist/server/cookie-utils.js.map +1 -0
- package/dist/server/dev-server.d.ts +8 -1
- package/dist/server/dev-server.js +34 -5
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/html.d.ts +2 -1
- package/dist/server/html.js +6 -1
- package/dist/server/html.js.map +1 -1
- package/dist/server/isr-cache.d.ts +7 -5
- package/dist/server/isr-cache.js +17 -6
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/middleware-runtime.js +1 -2
- package/dist/server/middleware-runtime.js.map +1 -1
- package/dist/server/pages-document-initial-props.d.ts +7 -0
- package/dist/server/pages-document-initial-props.js +14 -0
- package/dist/server/pages-document-initial-props.js.map +1 -0
- package/dist/server/pages-page-data.js +3 -0
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-method.d.ts +48 -0
- package/dist/server/pages-page-method.js +19 -0
- package/dist/server/pages-page-method.js.map +1 -0
- package/dist/server/pages-page-response.d.ts +6 -0
- package/dist/server/pages-page-response.js +10 -3
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/pages-serializable-props.d.ts +25 -0
- package/dist/server/pages-serializable-props.js +69 -0
- package/dist/server/pages-serializable-props.js.map +1 -0
- package/dist/server/prod-server.js +3 -0
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/server-action-not-found.js +3 -2
- package/dist/server/server-action-not-found.js.map +1 -1
- package/dist/server/static-file-cache.js +2 -1
- package/dist/server/static-file-cache.js.map +1 -1
- package/dist/shims/app-router-scroll-state.d.ts +4 -2
- package/dist/shims/app-router-scroll-state.js +16 -3
- package/dist/shims/app-router-scroll-state.js.map +1 -1
- package/dist/shims/app-router-scroll.d.ts +16 -2
- package/dist/shims/app-router-scroll.js +18 -3
- package/dist/shims/app-router-scroll.js.map +1 -1
- package/dist/shims/cache.d.ts +6 -0
- package/dist/shims/cache.js +7 -0
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/error.js +3 -0
- package/dist/shims/error.js.map +1 -1
- package/dist/shims/headers.d.ts +7 -0
- package/dist/shims/headers.js +9 -1
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/internal/app-route-detection.d.ts +37 -0
- package/dist/shims/internal/app-route-detection.js +69 -0
- package/dist/shims/internal/app-route-detection.js.map +1 -0
- package/dist/shims/link.d.ts +18 -2
- package/dist/shims/link.js +70 -6
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +7 -6
- package/dist/shims/metadata.js +9 -5
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation.d.ts +1 -2
- package/dist/shims/navigation.js +63 -12
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/router.d.ts +5 -0
- package/dist/shims/router.js +14 -4
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script.d.ts +11 -1
- package/dist/shims/script.js +75 -6
- package/dist/shims/script.js.map +1 -1
- package/dist/utils/path.d.ts +13 -0
- package/dist/utils/path.js +16 -0
- package/dist/utils/path.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { apiRouter, pagesRouter } from "../routing/pages-router.js";
|
|
2
|
-
import { normalizePathSeparators
|
|
2
|
+
import { normalizePathSeparators } from "../utils/path.js";
|
|
3
|
+
import { resolveEntryPath } from "./runtime-entry-module.js";
|
|
3
4
|
import { isProxyFile } from "../server/middleware.js";
|
|
4
5
|
import { findFileWithExts } from "./pages-entry-helpers.js";
|
|
5
6
|
//#region src/entries/pages-server-entry.ts
|
|
@@ -18,6 +19,7 @@ const _routeTriePath = resolveEntryPath("../routing/route-trie.js", import.meta.
|
|
|
18
19
|
const _pagesI18nPath = resolveEntryPath("../server/pages-i18n.js", import.meta.url);
|
|
19
20
|
const _pagesPageResponsePath = resolveEntryPath("../server/pages-page-response.js", import.meta.url);
|
|
20
21
|
const _pagesPageDataPath = resolveEntryPath("../server/pages-page-data.js", import.meta.url);
|
|
22
|
+
const _pagesPageMethodPath = resolveEntryPath("../server/pages-page-method.js", import.meta.url);
|
|
21
23
|
const _pagesDataRoutePath = resolveEntryPath("../server/pages-data-route.js", import.meta.url);
|
|
22
24
|
const _pagesDefault404Path = resolveEntryPath("../server/pages-default-404.js", import.meta.url);
|
|
23
25
|
const _pagesNodeCompatPath = resolveEntryPath("../server/pages-node-compat.js", import.meta.url);
|
|
@@ -73,6 +75,8 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
|
|
|
73
75
|
headers: nextConfig?.headers ?? [],
|
|
74
76
|
expireTime: nextConfig?.expireTime,
|
|
75
77
|
i18n: nextConfig?.i18n ?? null,
|
|
78
|
+
disableOptimizedLoading: nextConfig?.disableOptimizedLoading === true,
|
|
79
|
+
clientTraceMetadata: nextConfig?.clientTraceMetadata,
|
|
76
80
|
images: {
|
|
77
81
|
deviceSizes: nextConfig?.images?.deviceSizes,
|
|
78
82
|
imageSizes: nextConfig?.images?.imageSizes,
|
|
@@ -171,6 +175,7 @@ import {
|
|
|
171
175
|
} from ${JSON.stringify(_isrCachePath)};
|
|
172
176
|
import { getScriptNonceFromHeaderSources as __getScriptNonceFromHeaderSources } from ${JSON.stringify(_cspPath)};
|
|
173
177
|
import { resolvePagesPageData as __resolvePagesPageData } from ${JSON.stringify(_pagesPageDataPath)};
|
|
178
|
+
import { resolvePagesPageMethodResponse as __resolvePagesPageMethodResponse } from ${JSON.stringify(_pagesPageMethodPath)};
|
|
174
179
|
import { buildNextDataJsonResponse as __buildNextDataJsonResponse, buildNextDataNotFoundResponse as __buildNextDataNotFoundResponse, isNextDataPathname as __isNextDataPathname, parseNextDataPathname as __parseNextDataPathname } from ${JSON.stringify(_pagesDataRoutePath)};
|
|
175
180
|
import { buildDefaultPagesNotFoundResponse as __buildDefaultPagesNotFoundResponse } from ${JSON.stringify(_pagesDefault404Path)};
|
|
176
181
|
import { renderPagesPageResponse as __renderPagesPageResponse } from ${JSON.stringify(_pagesPageResponsePath)};
|
|
@@ -377,6 +382,13 @@ function collectAssetTags(manifest, moduleIds, scriptNonce) {
|
|
|
377
382
|
const tags = [];
|
|
378
383
|
const seen = new Set();
|
|
379
384
|
const nonceAttr = __createNonceAttribute(scriptNonce);
|
|
385
|
+
// Mirrors Next.js \`_document\` behaviour: when \`experimental.disableOptimizedLoading\`
|
|
386
|
+
// is false (the default), page scripts are emitted with \`defer\` in <head>. See
|
|
387
|
+
// .nextjs-ref/packages/next/src/pages/_document.tsx getScripts() — \`defer={!disableOptimizedLoading}\`.
|
|
388
|
+
// vinext always emits \`type="module"\` (which already defers implicitly), but
|
|
389
|
+
// upstream tests (e.g. test/e2e/optimized-loading) assert the literal \`defer\`
|
|
390
|
+
// attribute, and adding it preserves parity without changing browser behaviour.
|
|
391
|
+
const deferAttr = vinextConfig.disableOptimizedLoading ? "" : " defer";
|
|
380
392
|
|
|
381
393
|
// Load the set of lazy chunk filenames (only reachable via dynamic imports).
|
|
382
394
|
// These should NOT get <link rel="modulepreload"> or <script type="module">
|
|
@@ -390,7 +402,7 @@ function collectAssetTags(manifest, moduleIds, scriptNonce) {
|
|
|
390
402
|
const entry = globalThis.__VINEXT_CLIENT_ENTRY__;
|
|
391
403
|
seen.add(entry);
|
|
392
404
|
tags.push('<link rel="modulepreload"' + nonceAttr + ' href="/' + entry + '" />');
|
|
393
|
-
tags.push('<script type="module"' + nonceAttr + ' src="/' + entry + '" crossorigin><\/script>');
|
|
405
|
+
tags.push('<script type="module"' + deferAttr + nonceAttr + ' src="/' + entry + '" crossorigin><\/script>');
|
|
394
406
|
}
|
|
395
407
|
if (m) {
|
|
396
408
|
// Always inject shared chunks (framework, vinext runtime, entry) and
|
|
@@ -460,7 +472,7 @@ function collectAssetTags(manifest, moduleIds, scriptNonce) {
|
|
|
460
472
|
// (React.lazy, next/dynamic) and should only be fetched on demand.
|
|
461
473
|
if (lazySet && lazySet.has(tf)) continue;
|
|
462
474
|
tags.push('<link rel="modulepreload"' + nonceAttr + ' href="/' + tf + '" />');
|
|
463
|
-
tags.push('<script type="module"' + nonceAttr + ' src="/' + tf + '" crossorigin><\/script>');
|
|
475
|
+
tags.push('<script type="module"' + deferAttr + nonceAttr + ' src="/' + tf + '" crossorigin><\/script>');
|
|
464
476
|
}
|
|
465
477
|
}
|
|
466
478
|
}
|
|
@@ -504,6 +516,11 @@ async function _renderPage(request, url, manifest, middlewareHeaders, options) {
|
|
|
504
516
|
const statusCode = options && typeof options.statusCode === "number" ? options.statusCode : undefined;
|
|
505
517
|
const asPath = options && typeof options.asPath === "string" ? options.asPath : undefined;
|
|
506
518
|
const renderErrorPageOnMiss = !(options && options.renderErrorPageOnMiss === false);
|
|
519
|
+
// Guard against infinite recursion when the user's custom 500/error page
|
|
520
|
+
// itself throws during render. When this flag is set, the catch block below
|
|
521
|
+
// returns the plain "Internal Server Error" text response instead of trying
|
|
522
|
+
// to render an error page again. Fixes #1458.
|
|
523
|
+
const isInternalErrorRender = !!(options && options.__isInternalErrorRender);
|
|
507
524
|
const localeInfo = i18nConfig
|
|
508
525
|
? resolvePagesI18nRequest(
|
|
509
526
|
url,
|
|
@@ -525,7 +542,13 @@ async function _renderPage(request, url, manifest, middlewareHeaders, options) {
|
|
|
525
542
|
return new Response(null, { status: 307, headers: { Location: localeInfo.redirectUrl } });
|
|
526
543
|
}
|
|
527
544
|
|
|
528
|
-
|
|
545
|
+
// Internal error render path: caller has pinned a specific route (the
|
|
546
|
+
// user's pages/500 or pages/_error) to render in response to an SSR throw.
|
|
547
|
+
// Skip route matching so we don't accidentally double-route, and skip the
|
|
548
|
+
// missing-route 404 fallback. See catch block below. Fixes #1458.
|
|
549
|
+
let match = options && options.__forcedRoute
|
|
550
|
+
? { route: options.__forcedRoute, params: {} }
|
|
551
|
+
: matchRoute(routeUrl, pageRoutes);
|
|
529
552
|
let renderStatusCodeOverride = statusCode;
|
|
530
553
|
let renderAsPath = asPath;
|
|
531
554
|
if (!match) {
|
|
@@ -587,6 +610,29 @@ async function _renderPage(request, url, manifest, middlewareHeaders, options) {
|
|
|
587
610
|
if (!PageComponent) {
|
|
588
611
|
return new Response("Page has no default export", { status: 500 });
|
|
589
612
|
}
|
|
613
|
+
|
|
614
|
+
// Refs #1463: reject non-GET/HEAD methods on static (no
|
|
615
|
+
// getServerSideProps) Pages routes with 405 + Allow: GET, HEAD.
|
|
616
|
+
// Skip for error/status pages (/_error, /404, /500), data requests
|
|
617
|
+
// (those go through the JSON envelope path and have their own shape),
|
|
618
|
+
// and renders that are already an error-page miss-render override.
|
|
619
|
+
// Mirrors Next.js's base-server.ts L2277 carve-outs.
|
|
620
|
+
if (
|
|
621
|
+
!isDataReq &&
|
|
622
|
+
routePattern !== "/_error" &&
|
|
623
|
+
routePattern !== "/404" &&
|
|
624
|
+
routePattern !== "/500" &&
|
|
625
|
+
renderStatusCodeOverride === undefined
|
|
626
|
+
) {
|
|
627
|
+
const methodResponse = __resolvePagesPageMethodResponse({
|
|
628
|
+
hasGetServerSideProps: typeof pageModule.getServerSideProps === "function",
|
|
629
|
+
method: request.method,
|
|
630
|
+
});
|
|
631
|
+
if (methodResponse) {
|
|
632
|
+
return methodResponse;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
590
636
|
const pageModuleUrl = resolveClientModuleUrl(manifest, route.filePath);
|
|
591
637
|
const appModuleUrl = resolveClientModuleUrl(manifest, _appAssetPath);
|
|
592
638
|
const scriptNonce = __getScriptNonceFromHeaderSources(request.headers, middlewareHeaders);
|
|
@@ -798,6 +844,7 @@ async function _renderPage(request, url, manifest, middlewareHeaders, options) {
|
|
|
798
844
|
}
|
|
799
845
|
},
|
|
800
846
|
getSSRHeadHTML: typeof getSSRHeadHTML === "function" ? getSSRHeadHTML : undefined,
|
|
847
|
+
clientTraceMetadata: vinextConfig.clientTraceMetadata,
|
|
801
848
|
gsspRes,
|
|
802
849
|
isrCacheKey,
|
|
803
850
|
expireSeconds: vinextConfig.expireTime,
|
|
@@ -837,6 +884,37 @@ async function _renderPage(request, url, manifest, middlewareHeaders, options) {
|
|
|
837
884
|
{ path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },
|
|
838
885
|
{ routerKind: "Pages Router", routePath: route.pattern, routeType: "render" },
|
|
839
886
|
).catch(() => { /* ignore reporting errors */ });
|
|
887
|
+
// Data (_next/data) requests can't render HTML, and avoid recursion if
|
|
888
|
+
// we're already in the middle of rendering the error page itself.
|
|
889
|
+
// Mirrors Next.js base-server.ts which renders /500 (or _error) when
|
|
890
|
+
// SSR throws. Fixes #1458.
|
|
891
|
+
if (!isInternalErrorRender && !isDataReq) {
|
|
892
|
+
// Look for an explicit pages/500.tsx first, then fall back to _error.
|
|
893
|
+
// Only match the literal /500 pattern — never a catch-all/dynamic route.
|
|
894
|
+
let errorRoute = null;
|
|
895
|
+
for (var __i = 0; __i < pageRoutes.length; __i++) {
|
|
896
|
+
if (pageRoutes[__i].pattern === "/500") {
|
|
897
|
+
errorRoute = pageRoutes[__i];
|
|
898
|
+
break;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
if (!errorRoute && _errorPageRoute) {
|
|
902
|
+
errorRoute = _errorPageRoute;
|
|
903
|
+
}
|
|
904
|
+
if (errorRoute) {
|
|
905
|
+
try {
|
|
906
|
+
return await _renderPage(request, url, manifest, middlewareHeaders, {
|
|
907
|
+
statusCode: 500,
|
|
908
|
+
asPath: url,
|
|
909
|
+
renderErrorPageOnMiss: false,
|
|
910
|
+
__isInternalErrorRender: true,
|
|
911
|
+
__forcedRoute: errorRoute,
|
|
912
|
+
});
|
|
913
|
+
} catch (errorPageErr) {
|
|
914
|
+
console.error("[vinext] Error page render failed:", errorPageErr);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
}
|
|
840
918
|
return new Response("Internal Server Error", { status: 500 });
|
|
841
919
|
}
|
|
842
920
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pages-server-entry.js","names":[],"sources":["../../src/entries/pages-server-entry.ts"],"sourcesContent":["/**\n * Pages Router server entry generator.\n *\n * Generates the virtual SSR server entry module (`virtual:vinext-server-entry`).\n * This is the entry point for `vite build --ssr`. It handles SSR, API routes,\n * middleware, ISR, and i18n for the Pages Router.\n *\n * Extracted from index.ts.\n */\nimport { resolveEntryPath, normalizePathSeparators } from \"./runtime-entry-module.js\";\nimport { pagesRouter, apiRouter, type Route } from \"../routing/pages-router.js\";\nimport { createValidFileMatcher } from \"../routing/file-matcher.js\";\nimport { type ResolvedNextConfig } from \"../config/next-config.js\";\nimport { isProxyFile } from \"../server/middleware.js\";\nimport { findFileWithExts } from \"./pages-entry-helpers.js\";\n\nconst _requestContextShimPath = resolveEntryPath(\"../shims/request-context.js\", import.meta.url);\nconst _middlewareRuntimePath = resolveEntryPath(\"../server/middleware-runtime.js\", import.meta.url);\nconst _routeTriePath = resolveEntryPath(\"../routing/route-trie.js\", import.meta.url);\nconst _pagesI18nPath = resolveEntryPath(\"../server/pages-i18n.js\", import.meta.url);\nconst _pagesPageResponsePath = resolveEntryPath(\n \"../server/pages-page-response.js\",\n import.meta.url,\n);\nconst _pagesPageDataPath = resolveEntryPath(\"../server/pages-page-data.js\", import.meta.url);\nconst _pagesDataRoutePath = resolveEntryPath(\"../server/pages-data-route.js\", import.meta.url);\nconst _pagesDefault404Path = resolveEntryPath(\"../server/pages-default-404.js\", import.meta.url);\nconst _pagesNodeCompatPath = resolveEntryPath(\"../server/pages-node-compat.js\", import.meta.url);\nconst _pagesApiRoutePath = resolveEntryPath(\"../server/pages-api-route.js\", import.meta.url);\nconst _isrCachePath = resolveEntryPath(\"../server/isr-cache.js\", import.meta.url);\nconst _cspPath = resolveEntryPath(\"../server/csp.js\", import.meta.url);\nconst _serverGlobalsPath = resolveEntryPath(\"../server/server-globals.js\", import.meta.url);\n\n/**\n * Generate the virtual SSR server entry module.\n * This is the entry point for `vite build --ssr`.\n */\nexport async function generateServerEntry(\n pagesDir: string,\n nextConfig: ResolvedNextConfig,\n fileMatcher: ReturnType<typeof createValidFileMatcher>,\n middlewarePath: string | null,\n instrumentationPath: string | null,\n): Promise<string> {\n const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);\n const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);\n\n // Generate import statements using absolute paths since virtual\n // modules don't have a real file location for relative resolution.\n const pageImports = pageRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return `import * as page_${i} from ${JSON.stringify(absPath)};`;\n });\n\n const apiImports = apiRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return `import * as api_${i} from ${JSON.stringify(absPath)};`;\n });\n\n // Build the route table — include filePath for SSR manifest lookup\n const pageRouteEntries = pageRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: page_${i}, filePath: ${JSON.stringify(absPath)} }`;\n });\n\n const apiRouteEntries = apiRoutes.map(\n (r: Route, i: number) =>\n ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: api_${i} }`,\n );\n\n // Check for _app, _document, and _error.\n const appFilePath = findFileWithExts(pagesDir, \"_app\", fileMatcher);\n const docFilePath = findFileWithExts(pagesDir, \"_document\", fileMatcher);\n const errorFilePath = findFileWithExts(pagesDir, \"_error\", fileMatcher);\n // Embed the resolved _app path (or null) so the runtime can look it up\n // in the SSR manifest and include any CSS/JS chunks `_app` brings in\n // (e.g. global stylesheets imported by `_app.tsx`) alongside the page's\n // own assets. Without this, `_app`-imported CSS is emitted by Vite but\n // never `<link>`ed from the rendered HTML — see LHF-5 cluster.\n const appAssetPathJson =\n appFilePath !== null ? JSON.stringify(normalizePathSeparators(appFilePath)) : \"null\";\n const appImportCode =\n appFilePath !== null\n ? `import { default as AppComponent } from ${JSON.stringify(normalizePathSeparators(appFilePath))};`\n : `const AppComponent = null;`;\n\n const docImportCode =\n docFilePath !== null\n ? `import { default as DocumentComponent } from ${JSON.stringify(normalizePathSeparators(docFilePath))};`\n : `const DocumentComponent = null;`;\n\n const errorAssetPathJson =\n errorFilePath !== null ? JSON.stringify(normalizePathSeparators(errorFilePath)) : \"null\";\n const errorImportCode =\n errorFilePath !== null\n ? `import * as ErrorPageModule from ${JSON.stringify(normalizePathSeparators(errorFilePath))};`\n : `const ErrorPageModule = null;`;\n\n // Serialize i18n config for embedding in the server entry\n const i18nConfigJson = nextConfig?.i18n\n ? JSON.stringify({\n locales: nextConfig.i18n.locales,\n defaultLocale: nextConfig.i18n.defaultLocale,\n localeDetection: nextConfig.i18n.localeDetection,\n domains: nextConfig.i18n.domains,\n })\n : \"null\";\n\n // Embed the resolved build ID at build time\n const buildIdJson = JSON.stringify(nextConfig?.buildId ?? null);\n\n // Serialize the full resolved config for the production server.\n // This embeds redirects, rewrites, headers, basePath, trailingSlash\n // so prod-server.ts can apply them without loading next.config.js at runtime.\n const vinextConfigJson = JSON.stringify({\n basePath: nextConfig?.basePath ?? \"\",\n assetPrefix: nextConfig?.assetPrefix ?? \"\",\n trailingSlash: nextConfig?.trailingSlash ?? false,\n redirects: nextConfig?.redirects ?? [],\n rewrites: nextConfig?.rewrites ?? { beforeFiles: [], afterFiles: [], fallback: [] },\n headers: nextConfig?.headers ?? [],\n expireTime: nextConfig?.expireTime,\n i18n: nextConfig?.i18n ?? null,\n images: {\n deviceSizes: nextConfig?.images?.deviceSizes,\n imageSizes: nextConfig?.images?.imageSizes,\n dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,\n dangerouslyAllowLocalIP: nextConfig?.images?.dangerouslyAllowLocalIP,\n contentDispositionType: nextConfig?.images?.contentDispositionType,\n contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy,\n },\n });\n\n // Generate instrumentation code if instrumentation.ts exists.\n // For production (Cloudflare Workers), instrumentation.ts is bundled into the\n // Worker and register() is called as a top-level await at module evaluation time —\n // before any request is handled. This mirrors App Router behavior (generateRscEntry)\n // and matches Next.js semantics: register() runs once on startup in the process\n // that handles requests.\n //\n // The onRequestError handler is stored on globalThis so it is visible across\n // all code within the Worker (same global scope).\n const instrumentationImportCode = instrumentationPath\n ? `import * as _instrumentation from ${JSON.stringify(normalizePathSeparators(instrumentationPath))};`\n : \"\";\n\n const instrumentationInitCode = instrumentationPath\n ? `// Run instrumentation register() once at module evaluation time — before any\n// requests are handled. Matches Next.js semantics: register() is called once\n// on startup in the process that handles requests.\nif (typeof _instrumentation.register === \"function\") {\n await _instrumentation.register();\n}\n// Store the onRequestError handler on globalThis so it is visible to all\n// code within the Worker (same global scope).\nif (typeof _instrumentation.onRequestError === \"function\") {\n globalThis.__VINEXT_onRequestErrorHandler__ = _instrumentation.onRequestError;\n}`\n : \"\";\n\n // Generate middleware code if middleware.ts exists\n const middlewareImportCode = middlewarePath\n ? `import * as middlewareModule from ${JSON.stringify(normalizePathSeparators(middlewarePath))};`\n : \"\";\n\n // The matcher config is read from the middleware module at request time.\n // The generated entry only wires the user module into the shared runtime\n // helper; matcher, execution, waitUntil, and result shaping live in normal\n // TypeScript modules so dev/prod paths cannot drift.\n const middlewareExportCode = middlewarePath\n ? `\nexport async function runMiddleware(request, ctx, options) {\n // Auto-detect /_next/data/<buildId>/<page>.json requests so user-written\n // worker entries don't need to know about the data endpoint protocol.\n // Mismatched buildId → JSON 404 short-circuit. Matched → middleware sees\n // the normalized page path via the request URL, and the worker sees the\n // normalized URL via result.rewriteUrl (if middleware didn't already\n // rewrite to something else).\n const __dataNorm = __normalizePagesDataRequest(request);\n if (__dataNorm.notFoundResponse) {\n return { continue: false, response: __dataNorm.notFoundResponse };\n }\n const __result = await __runGeneratedMiddleware({\n basePath: vinextConfig.basePath,\n ctx,\n i18nConfig,\n isDataRequest: options?.isDataRequest === true || __dataNorm.isDataReq,\n isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},\n module: middlewareModule,\n request: __dataNorm.request,\n trailingSlash: vinextConfig.trailingSlash,\n });\n if (__dataNorm.isDataReq && __result.continue && !__result.rewriteUrl && !__result.redirectUrl) {\n return { ...__result, rewriteUrl: __dataNorm.normalizedPathname + __dataNorm.search };\n }\n return __result;\n}\n`\n : `\nexport async function runMiddleware(request) {\n // Even without user middleware, the data-endpoint URL must be normalized so\n // the worker pipeline sees the page path. Mismatched buildId → JSON 404.\n const __dataNorm = __normalizePagesDataRequest(request);\n if (__dataNorm.notFoundResponse) {\n return { continue: false, response: __dataNorm.notFoundResponse };\n }\n if (__dataNorm.isDataReq) {\n return { continue: true, rewriteUrl: __dataNorm.normalizedPathname + __dataNorm.search };\n }\n return { continue: true };\n}\n`;\n\n // The server entry is a self-contained module that uses Web-standard APIs\n // (Request/Response, renderToReadableStream) so it runs on Cloudflare Workers.\n return `\nimport ${JSON.stringify(_serverGlobalsPath)};\nimport React from \"react\";\nimport { renderToReadableStream } from \"react-dom/server.edge\";\nimport { resetSSRHead, getSSRHeadHTML } from \"next/head\";\nimport { flushPreloads } from \"next/dynamic\";\nimport { setSSRContext, wrapWithRouterContext } from \"next/router\";\nimport { _runWithCacheState } from \"next/cache\";\nimport { runWithPrivateCache } from \"vinext/cache-runtime\";\nimport { ensureFetchPatch, runWithFetchCache } from \"vinext/fetch-cache\";\nimport { runWithRequestContext as _runWithUnifiedCtx, createRequestContext as _createUnifiedCtx } from \"vinext/unified-request-context\";\nimport \"vinext/router-state\";\nimport { runWithServerInsertedHTMLState } from \"vinext/navigation-state\";\nimport { runWithHeadState } from \"vinext/head-state\";\nimport \"vinext/i18n-state\";\nimport { setI18nContext } from \"vinext/i18n-context\";\nimport { createNonceAttribute as __createNonceAttribute, safeJsonStringify } from \"vinext/html\";\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\";\nimport { sanitizeDestination as sanitizeDestinationLocal } from ${JSON.stringify(resolveEntryPath(\"../config/config-matchers.js\", import.meta.url))};\nimport { runWithExecutionContext as _runWithExecutionContext, getRequestExecutionContext as _getRequestExecutionContext } from ${JSON.stringify(_requestContextShimPath)};\nimport { runGeneratedMiddleware as __runGeneratedMiddleware } from ${JSON.stringify(_middlewareRuntimePath)};\nimport { buildRouteTrie as _buildRouteTrie, trieMatch as _trieMatch } from ${JSON.stringify(_routeTriePath)};\nimport { reportRequestError as _reportRequestError } from \"vinext/instrumentation\";\nimport { resolvePagesI18nRequest } from ${JSON.stringify(_pagesI18nPath)};\nimport { createPagesReqRes as __createPagesReqRes } from ${JSON.stringify(_pagesNodeCompatPath)};\nimport { handlePagesApiRoute as __handlePagesApiRoute } from ${JSON.stringify(_pagesApiRoutePath)};\nimport {\n isrGet as __sharedIsrGet,\n isrSet as __sharedIsrSet,\n isrCacheKey as __sharedIsrCacheKey,\n triggerBackgroundRegeneration as __sharedTriggerBackgroundRegeneration,\n} from ${JSON.stringify(_isrCachePath)};\nimport { getScriptNonceFromHeaderSources as __getScriptNonceFromHeaderSources } from ${JSON.stringify(_cspPath)};\nimport { resolvePagesPageData as __resolvePagesPageData } from ${JSON.stringify(_pagesPageDataPath)};\nimport { buildNextDataJsonResponse as __buildNextDataJsonResponse, buildNextDataNotFoundResponse as __buildNextDataNotFoundResponse, isNextDataPathname as __isNextDataPathname, parseNextDataPathname as __parseNextDataPathname } from ${JSON.stringify(_pagesDataRoutePath)};\nimport { buildDefaultPagesNotFoundResponse as __buildDefaultPagesNotFoundResponse } from ${JSON.stringify(_pagesDefault404Path)};\nimport { renderPagesPageResponse as __renderPagesPageResponse } from ${JSON.stringify(_pagesPageResponsePath)};\n${instrumentationImportCode}\n${middlewareImportCode}\n\n${instrumentationInitCode}\n\n// i18n config (embedded at build time)\nconst i18nConfig = ${i18nConfigJson};\n\n// Build ID (embedded at build time). Exported so the production server can\n// match _next/data requests against the embedded buildId without needing\n// to load next.config.js at runtime.\nexport const buildId = ${buildIdJson};\nconst __hasMiddleware = ${JSON.stringify(Boolean(middlewarePath))};\n\n// Full resolved config for production server (embedded at build time)\nexport const vinextConfig = ${vinextConfigJson};\n\n// Path to the user's pages/_app file (or null). Used to look up the\n// _app's CSS/JS chunks in the SSR manifest so any global styles imported\n// by _app are included in every page's <link rel=\"stylesheet\"> set.\nconst _appAssetPath = ${appAssetPathJson};\n\nfunction isrGet(key) {\n return __sharedIsrGet(key);\n}\nfunction isrSet(key, data, revalidateSeconds, tags, expireSeconds) {\n return __sharedIsrSet(key, data, revalidateSeconds, tags, expireSeconds);\n}\nfunction triggerBackgroundRegeneration(key, renderFn, errorContext) {\n return __sharedTriggerBackgroundRegeneration(key, renderFn, errorContext);\n}\nfunction isrCacheKey(router, pathname) {\n return __sharedIsrCacheKey(router, pathname, buildId || undefined);\n}\n\n/**\n * Detect and normalize /_next/data/<buildId>/<page>.json requests in one\n * place so user-written worker entries don't need to know about the data\n * endpoint protocol. Returns the normalized request (with the page path as\n * its URL), an isDataReq flag, and notFoundResponse when the buildId in\n * the URL does not match this server's buildId — callers should return that\n * response immediately so a stale client falls back to a hard navigation.\n */\nfunction __normalizePagesDataRequest(request) {\n const reqUrl = new URL(request.url);\n if (!__isNextDataPathname(reqUrl.pathname)) {\n return { isDataReq: false, request, normalizedPathname: null, search: \"\", notFoundResponse: null };\n }\n const dataMatch = buildId ? __parseNextDataPathname(reqUrl.pathname, buildId) : null;\n if (!dataMatch) {\n return {\n isDataReq: false,\n request,\n normalizedPathname: null,\n search: \"\",\n notFoundResponse: __buildNextDataNotFoundResponse(),\n };\n }\n const normalizedUrl = new URL(reqUrl);\n normalizedUrl.pathname = dataMatch.pagePathname;\n return {\n isDataReq: true,\n request: new Request(normalizedUrl, request),\n normalizedPathname: dataMatch.pagePathname,\n search: reqUrl.search,\n notFoundResponse: null,\n };\n}\n\nasync function renderToStringAsync(element) {\n const stream = await renderToReadableStream(element);\n await stream.allReady;\n return new Response(stream).text();\n}\n\nasync function renderIsrPassToStringAsync(element) {\n // The cache-fill render is a second render pass for the same request.\n // Reset render-scoped state so it cannot leak from the streamed response\n // render or affect async work that is still draining from that stream.\n // Keep request identity state (pathname/query/locale/executionContext)\n // intact: this second pass still belongs to the same request.\n return await runWithServerInsertedHTMLState(() =>\n runWithHeadState(() =>\n _runWithCacheState(() =>\n runWithPrivateCache(() => runWithFetchCache(async () => renderToStringAsync(element))),\n ),\n ),\n );\n}\n\n${pageImports.join(\"\\n\")}\n${apiImports.join(\"\\n\")}\n\n${appImportCode}\n${docImportCode}\n${errorImportCode}\n\nexport const pageRoutes = [\n${pageRouteEntries.join(\",\\n\")}\n];\nconst _pageRouteTrie = _buildRouteTrie(pageRoutes);\nconst _errorPageRoute = ErrorPageModule\n ? {\n pattern: \"/_error\",\n patternParts: [\"_error\"],\n isDynamic: false,\n params: [],\n module: ErrorPageModule,\n filePath: ${errorAssetPathJson},\n }\n : null;\n\nconst apiRoutes = [\n${apiRouteEntries.join(\",\\n\")}\n];\nconst _apiRouteTrie = _buildRouteTrie(apiRoutes);\n\nfunction matchRoute(url, routes) {\n const pathname = url.split(\"?\")[0];\n let normalizedUrl = pathname === \"/\" ? \"/\" : pathname.replace(/\\\\/$/, \"\");\n // NOTE: Do NOT decodeURIComponent here. The pathname is already decoded at\n // the entry point. Decoding again would create a double-decode vector.\n const urlParts = normalizedUrl.split(\"/\").filter(Boolean);\n const trie = routes === pageRoutes ? _pageRouteTrie : _apiRouteTrie;\n return _trieMatch(trie, urlParts);\n}\n\nexport function matchPageRoute(url, request) {\n const routeUrl = i18nConfig && request\n ? resolvePagesI18nRequest(\n url,\n i18nConfig,\n request.headers,\n new URL(request.url).hostname,\n vinextConfig.basePath,\n vinextConfig.trailingSlash,\n ).url\n : url;\n return matchRoute(routeUrl, pageRoutes);\n}\n\nfunction parseQuery(url) {\n // Per RFC 3986 only the first \"?\" separates path from query, so additional\n // \"?\" chars belong to the query string (e.g. /linker?href=/about?hello=world\n // has query \"href=/about?hello=world\"). split(\"?\")[1] would drop everything\n // after the second \"?\" and strip embedded query strings from values.\n const queryIndex = url.indexOf(\"?\");\n if (queryIndex === -1) return {};\n const hashIndex = url.indexOf(\"#\", queryIndex + 1);\n const qs = hashIndex === -1 ? url.slice(queryIndex + 1) : url.slice(queryIndex + 1, hashIndex);\n if (!qs) return {};\n const p = new URLSearchParams(qs);\n const q = {};\n for (const [k, v] of p) {\n if (k in q) {\n q[k] = Array.isArray(q[k]) ? q[k].concat(v) : [q[k], v];\n } else {\n q[k] = v;\n }\n }\n return q;\n}\n\nfunction mergeRouteParamsIntoQuery(query, params) {\n return Object.assign(query, params);\n}\n\nfunction patternToNextFormat(pattern) {\n // Match any non-/ param name. Non-greedy with lookahead prevents\n // the +/* suffix being consumed into the param name when the name\n // itself contains + or * internally (e.g. :c++lang → [c++lang]).\n return pattern\n .replace(/:([^\\\\/]+?)\\\\+(?=\\\\/|$)/g, \"[...$1]\")\n .replace(/:([^\\\\/]+?)\\\\*(?=\\\\/|$)/g, \"[[...$1]]\")\n .replace(/:([^\\\\/]+?)(?=\\\\/|$)/g, \"[$1]\");\n}\n\nfunction resolveSsrManifest(manifest) {\n // Fall back to embedded manifest (set by vinext:cloudflare-build for Workers)\n return (manifest && Object.keys(manifest).length > 0)\n ? manifest\n : (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_SSR_MANIFEST__) || null;\n}\n\nfunction getManifestFilesForModule(manifest, moduleId) {\n if (!manifest || !moduleId) return null;\n\n var files = manifest[moduleId];\n if (files) return files;\n\n for (var key in manifest) {\n if (moduleId.endsWith(\"/\" + key) || moduleId === key) {\n return manifest[key];\n }\n }\n return null;\n}\n\nfunction collectAssetTags(manifest, moduleIds, scriptNonce) {\n const m = resolveSsrManifest(manifest);\n const tags = [];\n const seen = new Set();\n const nonceAttr = __createNonceAttribute(scriptNonce);\n\n // Load the set of lazy chunk filenames (only reachable via dynamic imports).\n // These should NOT get <link rel=\"modulepreload\"> or <script type=\"module\">\n // tags — they are fetched on demand when the dynamic import() executes (e.g.\n // chunks behind React.lazy() or next/dynamic boundaries).\n var lazyChunks = (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_LAZY_CHUNKS__) || null;\n var lazySet = lazyChunks && lazyChunks.length > 0 ? new Set(lazyChunks) : null;\n\n // Inject the client entry script if embedded by vinext:cloudflare-build\n if (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_CLIENT_ENTRY__) {\n const entry = globalThis.__VINEXT_CLIENT_ENTRY__;\n seen.add(entry);\n tags.push('<link rel=\"modulepreload\"' + nonceAttr + ' href=\"/' + entry + '\" />');\n tags.push('<script type=\"module\"' + nonceAttr + ' src=\"/' + entry + '\" crossorigin></script>');\n }\n if (m) {\n // Always inject shared chunks (framework, vinext runtime, entry) and\n // page-specific chunks. The manifest maps module file paths to their\n // associated JS/CSS assets.\n //\n // For page-specific injection, the module IDs may be absolute paths\n // while the manifest uses relative paths. Try both the original ID\n // and a suffix match to find the correct manifest entry.\n var allFiles = [];\n\n if (moduleIds && moduleIds.length > 0) {\n // Collect assets for the requested page modules\n for (var mi = 0; mi < moduleIds.length; mi++) {\n var id = moduleIds[mi];\n var files = getManifestFilesForModule(m, id);\n if (files) {\n for (var fi = 0; fi < files.length; fi++) allFiles.push(files[fi]);\n }\n }\n\n // Also inject shared chunks that every page needs: framework,\n // vinext runtime, and the entry bootstrap. These are identified\n // by scanning all manifest values for chunk filenames containing\n // known prefixes.\n for (var key in m) {\n var vals = m[key];\n if (!vals) continue;\n for (var vi = 0; vi < vals.length; vi++) {\n var file = vals[vi];\n var basename = file.split(\"/\").pop() || \"\";\n if (\n basename.startsWith(\"framework-\") ||\n basename.startsWith(\"vinext-\") ||\n basename.includes(\"vinext-client-entry\") ||\n basename.includes(\"vinext-app-browser-entry\")\n ) {\n allFiles.push(file);\n }\n }\n }\n } else {\n // No specific modules — include all assets from manifest\n for (var akey in m) {\n var avals = m[akey];\n if (avals) {\n for (var ai = 0; ai < avals.length; ai++) allFiles.push(avals[ai]);\n }\n }\n }\n\n for (var ti = 0; ti < allFiles.length; ti++) {\n var tf = allFiles[ti];\n // Normalize: Vite's SSR manifest values include a leading '/'\n // (from base path), but we prepend '/' ourselves when building\n // href/src attributes. Strip any existing leading slash to avoid\n // producing protocol-relative URLs like \"//assets/chunk.js\".\n // This also ensures consistent keys for the seen-set dedup and\n // lazySet.has() checks (which use values without leading slash).\n if (tf.charAt(0) === '/') tf = tf.slice(1);\n if (seen.has(tf)) continue;\n seen.add(tf);\n if (tf.endsWith(\".css\")) {\n tags.push('<link rel=\"stylesheet\"' + nonceAttr + ' href=\"/' + tf + '\" />');\n } else if (tf.endsWith(\".js\")) {\n // Skip lazy chunks — they are behind dynamic import() boundaries\n // (React.lazy, next/dynamic) and should only be fetched on demand.\n if (lazySet && lazySet.has(tf)) continue;\n tags.push('<link rel=\"modulepreload\"' + nonceAttr + ' href=\"/' + tf + '\" />');\n tags.push('<script type=\"module\"' + nonceAttr + ' src=\"/' + tf + '\" crossorigin></script>');\n }\n }\n }\n return tags.join(\"\\\\n \");\n}\n\nfunction resolveClientModuleUrl(manifest, moduleId) {\n const files = getManifestFilesForModule(resolveSsrManifest(manifest), moduleId);\n if (!files) return undefined;\n for (var i = 0; i < files.length; i++) {\n var file = files[i];\n if (!file || !file.endsWith(\".js\")) continue;\n if (file.charAt(0) !== \"/\") file = \"/\" + file;\n return file;\n }\n return undefined;\n}\n\nexport async function renderPage(request, url, manifest, ctx, middlewareHeaders, options) {\n if (ctx) return _runWithExecutionContext(ctx, () => _renderPage(request, url, manifest, middlewareHeaders, options));\n return _renderPage(request, url, manifest, middlewareHeaders, options);\n}\n\nasync function _renderPage(request, url, manifest, middlewareHeaders, options) {\n let isDataReq = !!(options && options.isDataReq);\n // Auto-detect /_next/data/... requests by inspecting the incoming request\n // URL. The worker pipeline does not need to know about the data endpoint\n // protocol — when it forwards an unrewritten data URL as the url arg, we\n // normalize it to the page path here.\n if (!isDataReq) {\n const __dataNorm = __normalizePagesDataRequest(request);\n if (__dataNorm.notFoundResponse) return __dataNorm.notFoundResponse;\n if (__dataNorm.isDataReq) {\n isDataReq = true;\n if (url && url.startsWith(\"/_next/data/\")) {\n const __qs = url.includes(\"?\") ? url.slice(url.indexOf(\"?\")) : \"\";\n url = __dataNorm.normalizedPathname + __qs;\n }\n }\n }\n const statusCode = options && typeof options.statusCode === \"number\" ? options.statusCode : undefined;\n const asPath = options && typeof options.asPath === \"string\" ? options.asPath : undefined;\n const renderErrorPageOnMiss = !(options && options.renderErrorPageOnMiss === false);\n const localeInfo = i18nConfig\n ? resolvePagesI18nRequest(\n url,\n i18nConfig,\n request.headers,\n new URL(request.url).hostname,\n vinextConfig.basePath,\n vinextConfig.trailingSlash,\n )\n : { locale: undefined, url, hadPrefix: false, domainLocale: undefined, redirectUrl: undefined };\n const locale = localeInfo.locale;\n const routeUrl = localeInfo.url;\n const currentDefaultLocale = i18nConfig\n ? (localeInfo.domainLocale ? localeInfo.domainLocale.defaultLocale : i18nConfig.defaultLocale)\n : undefined;\n const domainLocales = i18nConfig ? i18nConfig.domains : undefined;\n\n if (localeInfo.redirectUrl) {\n return new Response(null, { status: 307, headers: { Location: localeInfo.redirectUrl } });\n }\n\n let match = matchRoute(routeUrl, pageRoutes);\n let renderStatusCodeOverride = statusCode;\n let renderAsPath = asPath;\n if (!match) {\n if (isDataReq) {\n return __buildNextDataNotFoundResponse();\n }\n if (!renderErrorPageOnMiss) {\n return __buildDefaultPagesNotFoundResponse();\n }\n const notFoundMatch = matchRoute(\"/404\", pageRoutes);\n // matchRoute may match a catch-all (e.g. [...slug]); only use the explicit pages/404 route.\n if (notFoundMatch && notFoundMatch.route.pattern === \"/404\") {\n match = notFoundMatch;\n renderStatusCodeOverride = 404;\n renderAsPath = routeUrl;\n } else if (_errorPageRoute) {\n match = { route: _errorPageRoute, params: {} };\n renderStatusCodeOverride = 404;\n renderAsPath = routeUrl;\n } else {\n return __buildDefaultPagesNotFoundResponse();\n }\n }\n\n const { route, params } = match;\n const __uCtx = _createUnifiedCtx({\n executionContext: _getRequestExecutionContext(),\n });\n return _runWithUnifiedCtx(__uCtx, async () => {\n ensureFetchPatch();\n try {\n const routePattern = patternToNextFormat(route.pattern);\n const renderStatusCode = renderStatusCodeOverride ?? (routePattern === \"/404\" ? 404 : undefined);\n const query = mergeRouteParamsIntoQuery(parseQuery(routeUrl), params);\n if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query,\n asPath: renderAsPath || routeUrl,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n });\n }\n\n if (i18nConfig) {\n setI18nContext({\n locale: locale,\n locales: i18nConfig.locales,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n hostname: new URL(request.url).hostname,\n });\n }\n\n const pageModule = route.module;\n const PageComponent = pageModule.default;\n if (!PageComponent) {\n return new Response(\"Page has no default export\", { status: 500 });\n }\n const pageModuleUrl = resolveClientModuleUrl(manifest, route.filePath);\n const appModuleUrl = resolveClientModuleUrl(manifest, _appAssetPath);\n const scriptNonce = __getScriptNonceFromHeaderSources(request.headers, middlewareHeaders);\n // Build font Link header early so it's available for ISR cached responses too.\n // Font preloads are module-level state populated at import time and persist across requests.\n var _fontLinkHeader = \"\";\n var _allFp = [];\n try {\n var _fpGoogle = typeof _getSSRFontPreloadsGoogle === \"function\" ? _getSSRFontPreloadsGoogle() : [];\n var _fpLocal = typeof _getSSRFontPreloadsLocal === \"function\" ? _getSSRFontPreloadsLocal() : [];\n _allFp = _fpGoogle.concat(_fpLocal);\n if (_allFp.length > 0) {\n _fontLinkHeader = _allFp.map(function(p) { return \"<\" + p.href + \">; rel=preload; as=font; type=\" + p.type + \"; crossorigin\"; }).join(\", \");\n }\n } catch (e) { /* font preloads not available */ }\n const pageDataResult = await __resolvePagesPageData({\n isDataReq,\n applyRequestContexts() {\n if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query,\n asPath: renderAsPath || routeUrl,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n });\n }\n if (i18nConfig) {\n setI18nContext({\n locale: locale,\n locales: i18nConfig.locales,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n hostname: new URL(request.url).hostname,\n });\n }\n },\n buildId,\n createGsspReqRes() {\n return __createPagesReqRes({ body: undefined, query, request, url: routeUrl });\n },\n createPageElement(currentPageProps) {\n var currentElement = AppComponent\n ? React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps })\n : React.createElement(PageComponent, currentPageProps);\n return wrapWithRouterContext(currentElement);\n },\n fontLinkHeader: _fontLinkHeader,\n i18n: {\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n },\n isrCacheKey,\n isrGet,\n isrSet,\n expireSeconds: vinextConfig.expireTime,\n // The vinext build phase boots the prod server with VINEXT_PRERENDER=1\n // and fetches every statically-generated page through it. That hit is\n // the \"build\" prerender for revalidateReason; runtime hits are not.\n // Mirrors Next.js's \\`renderOpts.isBuildTimePrerendering\\`. See\n // \\`.nextjs-ref/packages/next/src/server/render.tsx\\` and\n // \\`packages/vinext/src/build/prerender.ts\\`.\n isBuildTimePrerendering: typeof process !== \"undefined\" && process.env && process.env.VINEXT_PRERENDER === \"1\",\n pageModule,\n params,\n query,\n renderIsrPassToStringAsync,\n route: {\n isDynamic: route.isDynamic,\n },\n routePattern,\n routeUrl,\n runInFreshUnifiedContext(callback) {\n var revalCtx = _createUnifiedCtx({\n executionContext: _getRequestExecutionContext(),\n });\n return _runWithUnifiedCtx(revalCtx, async () => {\n ensureFetchPatch();\n return callback();\n });\n },\n safeJsonStringify,\n sanitizeDestination: sanitizeDestinationLocal,\n scriptNonce,\n statusCode: renderStatusCode,\n triggerBackgroundRegeneration,\n vinext: {\n pageModuleUrl,\n appModuleUrl,\n hasMiddleware: __hasMiddleware,\n },\n });\n if (pageDataResult.kind === \"response\") {\n return pageDataResult.response;\n }\n let pageProps = pageDataResult.pageProps;\n if (routePattern === \"/_error\" && typeof renderStatusCode === \"number\") {\n pageProps = { ...pageProps, statusCode: renderStatusCode };\n }\n var gsspRes = pageDataResult.gsspRes;\n let isrRevalidateSeconds = pageDataResult.isrRevalidateSeconds;\n const isFallbackRender = pageDataResult.isFallback === true;\n\n // Republish the SSR context with isFallback flipped on so the page's\n // \\`useRouter().isFallback\\` returns true during render, matching Next.js's\n // \\`render.tsx\\` fallback shell. Without this, the page would still see\n // \\`isFallback: false\\` and run the non-fallback branch.\n if (isFallbackRender && typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query,\n asPath: renderAsPath || routeUrl,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n isFallback: true,\n });\n }\n\n // ── _next/data JSON envelope short-circuit ───────────────────────\n // For client-side navigations Next.js fetches /_next/data/<buildId>/<page>.json\n // and expects { pageProps } as JSON instead of the full HTML page. Skip\n // rendering the React tree and emit the JSON envelope directly via the\n // typed helper so the envelope shape stays in one place. Headers and\n // cookies set on the gsspRes by getServerSideProps are forwarded so\n // middleware/auth flows work the same as the HTML page.\n if (isDataReq) {\n const init = { headers: {} };\n if (gsspRes && typeof gsspRes.getHeaders === \"function\") {\n const gsspHeaders = gsspRes.getHeaders();\n for (const k of Object.keys(gsspHeaders)) {\n const v = gsspHeaders[k];\n if (v === undefined || v === null) continue;\n init.headers[k] = Array.isArray(v) ? v.join(\", \") : String(v);\n }\n }\n if (gsspRes) {\n // Default Cache-Control for gSSP-driven _next/data responses,\n // matching Next.js's pages-handler.ts (revalidate: 0 →\n // getCacheControlHeader). Skip when gSSP already set one via\n // res.setHeader (case-insensitive). Mirrors the HTML branch in\n // pages-page-response.ts and the dev-server branch. Fixes #1461.\n var hasUserCacheControl = false;\n for (const headerKey of Object.keys(init.headers)) {\n if (headerKey.toLowerCase() === \"cache-control\") {\n hasUserCacheControl = true;\n break;\n }\n }\n if (!hasUserCacheControl) {\n init.headers[\"Cache-Control\"] =\n \"private, no-cache, no-store, max-age=0, must-revalidate\";\n }\n }\n return __buildNextDataJsonResponse(pageProps, safeJsonStringify, init);\n }\n\n // Include both the matched page module and the global _app module\n // (if present). _app is wrapped around every page in Pages Router,\n // and any CSS/JS it imports must be linked from the rendered HTML\n // so the browser actually loads it. Without _app in this list, a\n // global stylesheet imported via import \"./globals.scss\" in\n // _app.tsx never reaches the page, producing the LHF-5 symptom\n // where styled elements render with the browser default colour.\n const pageModuleIds = [];\n if (route.filePath) pageModuleIds.push(route.filePath);\n if (_appAssetPath) pageModuleIds.push(_appAssetPath);\n const assetTags = collectAssetTags(manifest, pageModuleIds, scriptNonce);\n\n return __renderPagesPageResponse({\n assetTags,\n buildId,\n clearSsrContext() {\n if (typeof setSSRContext === \"function\") setSSRContext(null);\n },\n createPageElement(currentPageProps) {\n var currentElement;\n if (AppComponent) {\n currentElement = React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps });\n } else {\n currentElement = React.createElement(PageComponent, currentPageProps);\n }\n return wrapWithRouterContext(currentElement);\n },\n DocumentComponent,\n flushPreloads: typeof flushPreloads === \"function\" ? flushPreloads : undefined,\n fontLinkHeader: _fontLinkHeader,\n fontPreloads: _allFp,\n getFontLinks() {\n try {\n return typeof _getSSRFontLinks === \"function\" ? _getSSRFontLinks() : [];\n } catch (e) {\n return [];\n }\n },\n getFontStyles() {\n try {\n var allFontStyles = [];\n if (typeof _getSSRFontStylesGoogle === \"function\") allFontStyles.push(..._getSSRFontStylesGoogle());\n if (typeof _getSSRFontStylesLocal === \"function\") allFontStyles.push(..._getSSRFontStylesLocal());\n return allFontStyles;\n } catch (e) {\n return [];\n }\n },\n getSSRHeadHTML: typeof getSSRHeadHTML === \"function\" ? getSSRHeadHTML : undefined,\n gsspRes,\n isrCacheKey,\n expireSeconds: vinextConfig.expireTime,\n isrRevalidateSeconds,\n isrSet,\n i18n: {\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n },\n isFallback: isFallbackRender,\n pageProps,\n params,\n renderDocumentToString(element) {\n return renderToStringAsync(element);\n },\n renderToReadableStream(element) {\n return renderToReadableStream(element);\n },\n resetSSRHead: typeof resetSSRHead === \"function\" ? resetSSRHead : undefined,\n routePattern,\n routeUrl,\n safeJsonStringify,\n scriptNonce,\n statusCode: renderStatusCode,\n vinext: {\n pageModuleUrl,\n appModuleUrl,\n hasMiddleware: __hasMiddleware,\n },\n });\n } catch (e) {\n console.error(\"[vinext] SSR error:\", e);\n _reportRequestError(\n e instanceof Error ? e : new Error(String(e)),\n { path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },\n { routerKind: \"Pages Router\", routePath: route.pattern, routeType: \"render\" },\n ).catch(() => { /* ignore reporting errors */ });\n return new Response(\"Internal Server Error\", { status: 500 });\n }\n });\n}\n\nexport async function handleApiRoute(request, url, ctx) {\n const match = matchRoute(url, apiRoutes);\n return __handlePagesApiRoute({\n ctx,\n match,\n request,\n url,\n reportRequestError(error, routePattern) {\n console.error(\"[vinext] API error:\", error);\n void _reportRequestError(\n error,\n { path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },\n { routerKind: \"Pages Router\", routePath: routePattern, routeType: \"route\" },\n );\n },\n });\n}\n\n${middlewareExportCode}\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAM,0BAA0B,iBAAiB,+BAA+B,OAAO,KAAK,IAAI;AAChG,MAAM,yBAAyB,iBAAiB,mCAAmC,OAAO,KAAK,IAAI;AACnG,MAAM,iBAAiB,iBAAiB,4BAA4B,OAAO,KAAK,IAAI;AACpF,MAAM,iBAAiB,iBAAiB,2BAA2B,OAAO,KAAK,IAAI;AACnF,MAAM,yBAAyB,iBAC7B,oCACA,OAAO,KAAK,IACb;AACD,MAAM,qBAAqB,iBAAiB,gCAAgC,OAAO,KAAK,IAAI;AAC5F,MAAM,sBAAsB,iBAAiB,iCAAiC,O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ACvB,WAAW,KAAK,KAAK,CAAC;;EAEtB,cAAc;EACd,cAAc;EACd,gBAAgB;;;EAGhB,iBAAiB,KAAK,MAAM,CAAC;;;;;;;;;;kBAUb,mBAAmB;;;;;EAKnC,gBAAgB,KAAK,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6jB5B,qBAAqB"}
|
|
1
|
+
{"version":3,"file":"pages-server-entry.js","names":[],"sources":["../../src/entries/pages-server-entry.ts"],"sourcesContent":["/**\n * Pages Router server entry generator.\n *\n * Generates the virtual SSR server entry module (`virtual:vinext-server-entry`).\n * This is the entry point for `vite build --ssr`. It handles SSR, API routes,\n * middleware, ISR, and i18n for the Pages Router.\n *\n * Extracted from index.ts.\n */\nimport { resolveEntryPath } from \"./runtime-entry-module.js\";\nimport { normalizePathSeparators } from \"../utils/path.js\";\nimport { pagesRouter, apiRouter, type Route } from \"../routing/pages-router.js\";\nimport { createValidFileMatcher } from \"../routing/file-matcher.js\";\nimport { type ResolvedNextConfig } from \"../config/next-config.js\";\nimport { isProxyFile } from \"../server/middleware.js\";\nimport { findFileWithExts } from \"./pages-entry-helpers.js\";\n\nconst _requestContextShimPath = resolveEntryPath(\"../shims/request-context.js\", import.meta.url);\nconst _middlewareRuntimePath = resolveEntryPath(\"../server/middleware-runtime.js\", import.meta.url);\nconst _routeTriePath = resolveEntryPath(\"../routing/route-trie.js\", import.meta.url);\nconst _pagesI18nPath = resolveEntryPath(\"../server/pages-i18n.js\", import.meta.url);\nconst _pagesPageResponsePath = resolveEntryPath(\n \"../server/pages-page-response.js\",\n import.meta.url,\n);\nconst _pagesPageDataPath = resolveEntryPath(\"../server/pages-page-data.js\", import.meta.url);\nconst _pagesPageMethodPath = resolveEntryPath(\"../server/pages-page-method.js\", import.meta.url);\nconst _pagesDataRoutePath = resolveEntryPath(\"../server/pages-data-route.js\", import.meta.url);\nconst _pagesDefault404Path = resolveEntryPath(\"../server/pages-default-404.js\", import.meta.url);\nconst _pagesNodeCompatPath = resolveEntryPath(\"../server/pages-node-compat.js\", import.meta.url);\nconst _pagesApiRoutePath = resolveEntryPath(\"../server/pages-api-route.js\", import.meta.url);\nconst _isrCachePath = resolveEntryPath(\"../server/isr-cache.js\", import.meta.url);\nconst _cspPath = resolveEntryPath(\"../server/csp.js\", import.meta.url);\nconst _serverGlobalsPath = resolveEntryPath(\"../server/server-globals.js\", import.meta.url);\n\n/**\n * Generate the virtual SSR server entry module.\n * This is the entry point for `vite build --ssr`.\n */\nexport async function generateServerEntry(\n pagesDir: string,\n nextConfig: ResolvedNextConfig,\n fileMatcher: ReturnType<typeof createValidFileMatcher>,\n middlewarePath: string | null,\n instrumentationPath: string | null,\n): Promise<string> {\n const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);\n const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);\n\n // Generate import statements using absolute paths since virtual\n // modules don't have a real file location for relative resolution.\n const pageImports = pageRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return `import * as page_${i} from ${JSON.stringify(absPath)};`;\n });\n\n const apiImports = apiRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return `import * as api_${i} from ${JSON.stringify(absPath)};`;\n });\n\n // Build the route table — include filePath for SSR manifest lookup\n const pageRouteEntries = pageRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: page_${i}, filePath: ${JSON.stringify(absPath)} }`;\n });\n\n const apiRouteEntries = apiRoutes.map(\n (r: Route, i: number) =>\n ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: api_${i} }`,\n );\n\n // Check for _app, _document, and _error.\n const appFilePath = findFileWithExts(pagesDir, \"_app\", fileMatcher);\n const docFilePath = findFileWithExts(pagesDir, \"_document\", fileMatcher);\n const errorFilePath = findFileWithExts(pagesDir, \"_error\", fileMatcher);\n // Embed the resolved _app path (or null) so the runtime can look it up\n // in the SSR manifest and include any CSS/JS chunks `_app` brings in\n // (e.g. global stylesheets imported by `_app.tsx`) alongside the page's\n // own assets. Without this, `_app`-imported CSS is emitted by Vite but\n // never `<link>`ed from the rendered HTML — see LHF-5 cluster.\n const appAssetPathJson =\n appFilePath !== null ? JSON.stringify(normalizePathSeparators(appFilePath)) : \"null\";\n const appImportCode =\n appFilePath !== null\n ? `import { default as AppComponent } from ${JSON.stringify(normalizePathSeparators(appFilePath))};`\n : `const AppComponent = null;`;\n\n const docImportCode =\n docFilePath !== null\n ? `import { default as DocumentComponent } from ${JSON.stringify(normalizePathSeparators(docFilePath))};`\n : `const DocumentComponent = null;`;\n\n const errorAssetPathJson =\n errorFilePath !== null ? JSON.stringify(normalizePathSeparators(errorFilePath)) : \"null\";\n const errorImportCode =\n errorFilePath !== null\n ? `import * as ErrorPageModule from ${JSON.stringify(normalizePathSeparators(errorFilePath))};`\n : `const ErrorPageModule = null;`;\n\n // Serialize i18n config for embedding in the server entry\n const i18nConfigJson = nextConfig?.i18n\n ? JSON.stringify({\n locales: nextConfig.i18n.locales,\n defaultLocale: nextConfig.i18n.defaultLocale,\n localeDetection: nextConfig.i18n.localeDetection,\n domains: nextConfig.i18n.domains,\n })\n : \"null\";\n\n // Embed the resolved build ID at build time\n const buildIdJson = JSON.stringify(nextConfig?.buildId ?? null);\n\n // Serialize the full resolved config for the production server.\n // This embeds redirects, rewrites, headers, basePath, trailingSlash\n // so prod-server.ts can apply them without loading next.config.js at runtime.\n const vinextConfigJson = JSON.stringify({\n basePath: nextConfig?.basePath ?? \"\",\n assetPrefix: nextConfig?.assetPrefix ?? \"\",\n trailingSlash: nextConfig?.trailingSlash ?? false,\n redirects: nextConfig?.redirects ?? [],\n rewrites: nextConfig?.rewrites ?? { beforeFiles: [], afterFiles: [], fallback: [] },\n headers: nextConfig?.headers ?? [],\n expireTime: nextConfig?.expireTime,\n i18n: nextConfig?.i18n ?? null,\n // Mirrors Next.js `experimental.disableOptimizedLoading` — when false\n // (the default), page scripts are emitted with `defer` in <head>. See\n // `.nextjs-ref/packages/next/src/pages/_document.tsx` getScripts().\n disableOptimizedLoading: nextConfig?.disableOptimizedLoading === true,\n clientTraceMetadata: nextConfig?.clientTraceMetadata,\n images: {\n deviceSizes: nextConfig?.images?.deviceSizes,\n imageSizes: nextConfig?.images?.imageSizes,\n dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,\n dangerouslyAllowLocalIP: nextConfig?.images?.dangerouslyAllowLocalIP,\n contentDispositionType: nextConfig?.images?.contentDispositionType,\n contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy,\n },\n });\n\n // Generate instrumentation code if instrumentation.ts exists.\n // For production (Cloudflare Workers), instrumentation.ts is bundled into the\n // Worker and register() is called as a top-level await at module evaluation time —\n // before any request is handled. This mirrors App Router behavior (generateRscEntry)\n // and matches Next.js semantics: register() runs once on startup in the process\n // that handles requests.\n //\n // The onRequestError handler is stored on globalThis so it is visible across\n // all code within the Worker (same global scope).\n const instrumentationImportCode = instrumentationPath\n ? `import * as _instrumentation from ${JSON.stringify(normalizePathSeparators(instrumentationPath))};`\n : \"\";\n\n const instrumentationInitCode = instrumentationPath\n ? `// Run instrumentation register() once at module evaluation time — before any\n// requests are handled. Matches Next.js semantics: register() is called once\n// on startup in the process that handles requests.\nif (typeof _instrumentation.register === \"function\") {\n await _instrumentation.register();\n}\n// Store the onRequestError handler on globalThis so it is visible to all\n// code within the Worker (same global scope).\nif (typeof _instrumentation.onRequestError === \"function\") {\n globalThis.__VINEXT_onRequestErrorHandler__ = _instrumentation.onRequestError;\n}`\n : \"\";\n\n // Generate middleware code if middleware.ts exists\n const middlewareImportCode = middlewarePath\n ? `import * as middlewareModule from ${JSON.stringify(normalizePathSeparators(middlewarePath))};`\n : \"\";\n\n // The matcher config is read from the middleware module at request time.\n // The generated entry only wires the user module into the shared runtime\n // helper; matcher, execution, waitUntil, and result shaping live in normal\n // TypeScript modules so dev/prod paths cannot drift.\n const middlewareExportCode = middlewarePath\n ? `\nexport async function runMiddleware(request, ctx, options) {\n // Auto-detect /_next/data/<buildId>/<page>.json requests so user-written\n // worker entries don't need to know about the data endpoint protocol.\n // Mismatched buildId → JSON 404 short-circuit. Matched → middleware sees\n // the normalized page path via the request URL, and the worker sees the\n // normalized URL via result.rewriteUrl (if middleware didn't already\n // rewrite to something else).\n const __dataNorm = __normalizePagesDataRequest(request);\n if (__dataNorm.notFoundResponse) {\n return { continue: false, response: __dataNorm.notFoundResponse };\n }\n const __result = await __runGeneratedMiddleware({\n basePath: vinextConfig.basePath,\n ctx,\n i18nConfig,\n isDataRequest: options?.isDataRequest === true || __dataNorm.isDataReq,\n isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},\n module: middlewareModule,\n request: __dataNorm.request,\n trailingSlash: vinextConfig.trailingSlash,\n });\n if (__dataNorm.isDataReq && __result.continue && !__result.rewriteUrl && !__result.redirectUrl) {\n return { ...__result, rewriteUrl: __dataNorm.normalizedPathname + __dataNorm.search };\n }\n return __result;\n}\n`\n : `\nexport async function runMiddleware(request) {\n // Even without user middleware, the data-endpoint URL must be normalized so\n // the worker pipeline sees the page path. Mismatched buildId → JSON 404.\n const __dataNorm = __normalizePagesDataRequest(request);\n if (__dataNorm.notFoundResponse) {\n return { continue: false, response: __dataNorm.notFoundResponse };\n }\n if (__dataNorm.isDataReq) {\n return { continue: true, rewriteUrl: __dataNorm.normalizedPathname + __dataNorm.search };\n }\n return { continue: true };\n}\n`;\n\n // The server entry is a self-contained module that uses Web-standard APIs\n // (Request/Response, renderToReadableStream) so it runs on Cloudflare Workers.\n return `\nimport ${JSON.stringify(_serverGlobalsPath)};\nimport React from \"react\";\nimport { renderToReadableStream } from \"react-dom/server.edge\";\nimport { resetSSRHead, getSSRHeadHTML } from \"next/head\";\nimport { flushPreloads } from \"next/dynamic\";\nimport { setSSRContext, wrapWithRouterContext } from \"next/router\";\nimport { _runWithCacheState } from \"next/cache\";\nimport { runWithPrivateCache } from \"vinext/cache-runtime\";\nimport { ensureFetchPatch, runWithFetchCache } from \"vinext/fetch-cache\";\nimport { runWithRequestContext as _runWithUnifiedCtx, createRequestContext as _createUnifiedCtx } from \"vinext/unified-request-context\";\nimport \"vinext/router-state\";\nimport { runWithServerInsertedHTMLState } from \"vinext/navigation-state\";\nimport { runWithHeadState } from \"vinext/head-state\";\nimport \"vinext/i18n-state\";\nimport { setI18nContext } from \"vinext/i18n-context\";\nimport { createNonceAttribute as __createNonceAttribute, safeJsonStringify } from \"vinext/html\";\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\";\nimport { sanitizeDestination as sanitizeDestinationLocal } from ${JSON.stringify(resolveEntryPath(\"../config/config-matchers.js\", import.meta.url))};\nimport { runWithExecutionContext as _runWithExecutionContext, getRequestExecutionContext as _getRequestExecutionContext } from ${JSON.stringify(_requestContextShimPath)};\nimport { runGeneratedMiddleware as __runGeneratedMiddleware } from ${JSON.stringify(_middlewareRuntimePath)};\nimport { buildRouteTrie as _buildRouteTrie, trieMatch as _trieMatch } from ${JSON.stringify(_routeTriePath)};\nimport { reportRequestError as _reportRequestError } from \"vinext/instrumentation\";\nimport { resolvePagesI18nRequest } from ${JSON.stringify(_pagesI18nPath)};\nimport { createPagesReqRes as __createPagesReqRes } from ${JSON.stringify(_pagesNodeCompatPath)};\nimport { handlePagesApiRoute as __handlePagesApiRoute } from ${JSON.stringify(_pagesApiRoutePath)};\nimport {\n isrGet as __sharedIsrGet,\n isrSet as __sharedIsrSet,\n isrCacheKey as __sharedIsrCacheKey,\n triggerBackgroundRegeneration as __sharedTriggerBackgroundRegeneration,\n} from ${JSON.stringify(_isrCachePath)};\nimport { getScriptNonceFromHeaderSources as __getScriptNonceFromHeaderSources } from ${JSON.stringify(_cspPath)};\nimport { resolvePagesPageData as __resolvePagesPageData } from ${JSON.stringify(_pagesPageDataPath)};\nimport { resolvePagesPageMethodResponse as __resolvePagesPageMethodResponse } from ${JSON.stringify(_pagesPageMethodPath)};\nimport { buildNextDataJsonResponse as __buildNextDataJsonResponse, buildNextDataNotFoundResponse as __buildNextDataNotFoundResponse, isNextDataPathname as __isNextDataPathname, parseNextDataPathname as __parseNextDataPathname } from ${JSON.stringify(_pagesDataRoutePath)};\nimport { buildDefaultPagesNotFoundResponse as __buildDefaultPagesNotFoundResponse } from ${JSON.stringify(_pagesDefault404Path)};\nimport { renderPagesPageResponse as __renderPagesPageResponse } from ${JSON.stringify(_pagesPageResponsePath)};\n${instrumentationImportCode}\n${middlewareImportCode}\n\n${instrumentationInitCode}\n\n// i18n config (embedded at build time)\nconst i18nConfig = ${i18nConfigJson};\n\n// Build ID (embedded at build time). Exported so the production server can\n// match _next/data requests against the embedded buildId without needing\n// to load next.config.js at runtime.\nexport const buildId = ${buildIdJson};\nconst __hasMiddleware = ${JSON.stringify(Boolean(middlewarePath))};\n\n// Full resolved config for production server (embedded at build time)\nexport const vinextConfig = ${vinextConfigJson};\n\n// Path to the user's pages/_app file (or null). Used to look up the\n// _app's CSS/JS chunks in the SSR manifest so any global styles imported\n// by _app are included in every page's <link rel=\"stylesheet\"> set.\nconst _appAssetPath = ${appAssetPathJson};\n\nfunction isrGet(key) {\n return __sharedIsrGet(key);\n}\nfunction isrSet(key, data, revalidateSeconds, tags, expireSeconds) {\n return __sharedIsrSet(key, data, revalidateSeconds, tags, expireSeconds);\n}\nfunction triggerBackgroundRegeneration(key, renderFn, errorContext) {\n return __sharedTriggerBackgroundRegeneration(key, renderFn, errorContext);\n}\nfunction isrCacheKey(router, pathname) {\n return __sharedIsrCacheKey(router, pathname, buildId || undefined);\n}\n\n/**\n * Detect and normalize /_next/data/<buildId>/<page>.json requests in one\n * place so user-written worker entries don't need to know about the data\n * endpoint protocol. Returns the normalized request (with the page path as\n * its URL), an isDataReq flag, and notFoundResponse when the buildId in\n * the URL does not match this server's buildId — callers should return that\n * response immediately so a stale client falls back to a hard navigation.\n */\nfunction __normalizePagesDataRequest(request) {\n const reqUrl = new URL(request.url);\n if (!__isNextDataPathname(reqUrl.pathname)) {\n return { isDataReq: false, request, normalizedPathname: null, search: \"\", notFoundResponse: null };\n }\n const dataMatch = buildId ? __parseNextDataPathname(reqUrl.pathname, buildId) : null;\n if (!dataMatch) {\n return {\n isDataReq: false,\n request,\n normalizedPathname: null,\n search: \"\",\n notFoundResponse: __buildNextDataNotFoundResponse(),\n };\n }\n const normalizedUrl = new URL(reqUrl);\n normalizedUrl.pathname = dataMatch.pagePathname;\n return {\n isDataReq: true,\n request: new Request(normalizedUrl, request),\n normalizedPathname: dataMatch.pagePathname,\n search: reqUrl.search,\n notFoundResponse: null,\n };\n}\n\nasync function renderToStringAsync(element) {\n const stream = await renderToReadableStream(element);\n await stream.allReady;\n return new Response(stream).text();\n}\n\nasync function renderIsrPassToStringAsync(element) {\n // The cache-fill render is a second render pass for the same request.\n // Reset render-scoped state so it cannot leak from the streamed response\n // render or affect async work that is still draining from that stream.\n // Keep request identity state (pathname/query/locale/executionContext)\n // intact: this second pass still belongs to the same request.\n return await runWithServerInsertedHTMLState(() =>\n runWithHeadState(() =>\n _runWithCacheState(() =>\n runWithPrivateCache(() => runWithFetchCache(async () => renderToStringAsync(element))),\n ),\n ),\n );\n}\n\n${pageImports.join(\"\\n\")}\n${apiImports.join(\"\\n\")}\n\n${appImportCode}\n${docImportCode}\n${errorImportCode}\n\nexport const pageRoutes = [\n${pageRouteEntries.join(\",\\n\")}\n];\nconst _pageRouteTrie = _buildRouteTrie(pageRoutes);\nconst _errorPageRoute = ErrorPageModule\n ? {\n pattern: \"/_error\",\n patternParts: [\"_error\"],\n isDynamic: false,\n params: [],\n module: ErrorPageModule,\n filePath: ${errorAssetPathJson},\n }\n : null;\n\nconst apiRoutes = [\n${apiRouteEntries.join(\",\\n\")}\n];\nconst _apiRouteTrie = _buildRouteTrie(apiRoutes);\n\nfunction matchRoute(url, routes) {\n const pathname = url.split(\"?\")[0];\n let normalizedUrl = pathname === \"/\" ? \"/\" : pathname.replace(/\\\\/$/, \"\");\n // NOTE: Do NOT decodeURIComponent here. The pathname is already decoded at\n // the entry point. Decoding again would create a double-decode vector.\n const urlParts = normalizedUrl.split(\"/\").filter(Boolean);\n const trie = routes === pageRoutes ? _pageRouteTrie : _apiRouteTrie;\n return _trieMatch(trie, urlParts);\n}\n\nexport function matchPageRoute(url, request) {\n const routeUrl = i18nConfig && request\n ? resolvePagesI18nRequest(\n url,\n i18nConfig,\n request.headers,\n new URL(request.url).hostname,\n vinextConfig.basePath,\n vinextConfig.trailingSlash,\n ).url\n : url;\n return matchRoute(routeUrl, pageRoutes);\n}\n\nfunction parseQuery(url) {\n // Per RFC 3986 only the first \"?\" separates path from query, so additional\n // \"?\" chars belong to the query string (e.g. /linker?href=/about?hello=world\n // has query \"href=/about?hello=world\"). split(\"?\")[1] would drop everything\n // after the second \"?\" and strip embedded query strings from values.\n const queryIndex = url.indexOf(\"?\");\n if (queryIndex === -1) return {};\n const hashIndex = url.indexOf(\"#\", queryIndex + 1);\n const qs = hashIndex === -1 ? url.slice(queryIndex + 1) : url.slice(queryIndex + 1, hashIndex);\n if (!qs) return {};\n const p = new URLSearchParams(qs);\n const q = {};\n for (const [k, v] of p) {\n if (k in q) {\n q[k] = Array.isArray(q[k]) ? q[k].concat(v) : [q[k], v];\n } else {\n q[k] = v;\n }\n }\n return q;\n}\n\nfunction mergeRouteParamsIntoQuery(query, params) {\n return Object.assign(query, params);\n}\n\nfunction patternToNextFormat(pattern) {\n // Match any non-/ param name. Non-greedy with lookahead prevents\n // the +/* suffix being consumed into the param name when the name\n // itself contains + or * internally (e.g. :c++lang → [c++lang]).\n return pattern\n .replace(/:([^\\\\/]+?)\\\\+(?=\\\\/|$)/g, \"[...$1]\")\n .replace(/:([^\\\\/]+?)\\\\*(?=\\\\/|$)/g, \"[[...$1]]\")\n .replace(/:([^\\\\/]+?)(?=\\\\/|$)/g, \"[$1]\");\n}\n\nfunction resolveSsrManifest(manifest) {\n // Fall back to embedded manifest (set by vinext:cloudflare-build for Workers)\n return (manifest && Object.keys(manifest).length > 0)\n ? manifest\n : (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_SSR_MANIFEST__) || null;\n}\n\nfunction getManifestFilesForModule(manifest, moduleId) {\n if (!manifest || !moduleId) return null;\n\n var files = manifest[moduleId];\n if (files) return files;\n\n for (var key in manifest) {\n if (moduleId.endsWith(\"/\" + key) || moduleId === key) {\n return manifest[key];\n }\n }\n return null;\n}\n\nfunction collectAssetTags(manifest, moduleIds, scriptNonce) {\n const m = resolveSsrManifest(manifest);\n const tags = [];\n const seen = new Set();\n const nonceAttr = __createNonceAttribute(scriptNonce);\n // Mirrors Next.js \\`_document\\` behaviour: when \\`experimental.disableOptimizedLoading\\`\n // is false (the default), page scripts are emitted with \\`defer\\` in <head>. See\n // .nextjs-ref/packages/next/src/pages/_document.tsx getScripts() — \\`defer={!disableOptimizedLoading}\\`.\n // vinext always emits \\`type=\"module\"\\` (which already defers implicitly), but\n // upstream tests (e.g. test/e2e/optimized-loading) assert the literal \\`defer\\`\n // attribute, and adding it preserves parity without changing browser behaviour.\n const deferAttr = vinextConfig.disableOptimizedLoading ? \"\" : \" defer\";\n\n // Load the set of lazy chunk filenames (only reachable via dynamic imports).\n // These should NOT get <link rel=\"modulepreload\"> or <script type=\"module\">\n // tags — they are fetched on demand when the dynamic import() executes (e.g.\n // chunks behind React.lazy() or next/dynamic boundaries).\n var lazyChunks = (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_LAZY_CHUNKS__) || null;\n var lazySet = lazyChunks && lazyChunks.length > 0 ? new Set(lazyChunks) : null;\n\n // Inject the client entry script if embedded by vinext:cloudflare-build\n if (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_CLIENT_ENTRY__) {\n const entry = globalThis.__VINEXT_CLIENT_ENTRY__;\n seen.add(entry);\n tags.push('<link rel=\"modulepreload\"' + nonceAttr + ' href=\"/' + entry + '\" />');\n tags.push('<script type=\"module\"' + deferAttr + nonceAttr + ' src=\"/' + entry + '\" crossorigin></script>');\n }\n if (m) {\n // Always inject shared chunks (framework, vinext runtime, entry) and\n // page-specific chunks. The manifest maps module file paths to their\n // associated JS/CSS assets.\n //\n // For page-specific injection, the module IDs may be absolute paths\n // while the manifest uses relative paths. Try both the original ID\n // and a suffix match to find the correct manifest entry.\n var allFiles = [];\n\n if (moduleIds && moduleIds.length > 0) {\n // Collect assets for the requested page modules\n for (var mi = 0; mi < moduleIds.length; mi++) {\n var id = moduleIds[mi];\n var files = getManifestFilesForModule(m, id);\n if (files) {\n for (var fi = 0; fi < files.length; fi++) allFiles.push(files[fi]);\n }\n }\n\n // Also inject shared chunks that every page needs: framework,\n // vinext runtime, and the entry bootstrap. These are identified\n // by scanning all manifest values for chunk filenames containing\n // known prefixes.\n for (var key in m) {\n var vals = m[key];\n if (!vals) continue;\n for (var vi = 0; vi < vals.length; vi++) {\n var file = vals[vi];\n var basename = file.split(\"/\").pop() || \"\";\n if (\n basename.startsWith(\"framework-\") ||\n basename.startsWith(\"vinext-\") ||\n basename.includes(\"vinext-client-entry\") ||\n basename.includes(\"vinext-app-browser-entry\")\n ) {\n allFiles.push(file);\n }\n }\n }\n } else {\n // No specific modules — include all assets from manifest\n for (var akey in m) {\n var avals = m[akey];\n if (avals) {\n for (var ai = 0; ai < avals.length; ai++) allFiles.push(avals[ai]);\n }\n }\n }\n\n for (var ti = 0; ti < allFiles.length; ti++) {\n var tf = allFiles[ti];\n // Normalize: Vite's SSR manifest values include a leading '/'\n // (from base path), but we prepend '/' ourselves when building\n // href/src attributes. Strip any existing leading slash to avoid\n // producing protocol-relative URLs like \"//assets/chunk.js\".\n // This also ensures consistent keys for the seen-set dedup and\n // lazySet.has() checks (which use values without leading slash).\n if (tf.charAt(0) === '/') tf = tf.slice(1);\n if (seen.has(tf)) continue;\n seen.add(tf);\n if (tf.endsWith(\".css\")) {\n tags.push('<link rel=\"stylesheet\"' + nonceAttr + ' href=\"/' + tf + '\" />');\n } else if (tf.endsWith(\".js\")) {\n // Skip lazy chunks — they are behind dynamic import() boundaries\n // (React.lazy, next/dynamic) and should only be fetched on demand.\n if (lazySet && lazySet.has(tf)) continue;\n tags.push('<link rel=\"modulepreload\"' + nonceAttr + ' href=\"/' + tf + '\" />');\n tags.push('<script type=\"module\"' + deferAttr + nonceAttr + ' src=\"/' + tf + '\" crossorigin></script>');\n }\n }\n }\n return tags.join(\"\\\\n \");\n}\n\nfunction resolveClientModuleUrl(manifest, moduleId) {\n const files = getManifestFilesForModule(resolveSsrManifest(manifest), moduleId);\n if (!files) return undefined;\n for (var i = 0; i < files.length; i++) {\n var file = files[i];\n if (!file || !file.endsWith(\".js\")) continue;\n if (file.charAt(0) !== \"/\") file = \"/\" + file;\n return file;\n }\n return undefined;\n}\n\nexport async function renderPage(request, url, manifest, ctx, middlewareHeaders, options) {\n if (ctx) return _runWithExecutionContext(ctx, () => _renderPage(request, url, manifest, middlewareHeaders, options));\n return _renderPage(request, url, manifest, middlewareHeaders, options);\n}\n\nasync function _renderPage(request, url, manifest, middlewareHeaders, options) {\n let isDataReq = !!(options && options.isDataReq);\n // Auto-detect /_next/data/... requests by inspecting the incoming request\n // URL. The worker pipeline does not need to know about the data endpoint\n // protocol — when it forwards an unrewritten data URL as the url arg, we\n // normalize it to the page path here.\n if (!isDataReq) {\n const __dataNorm = __normalizePagesDataRequest(request);\n if (__dataNorm.notFoundResponse) return __dataNorm.notFoundResponse;\n if (__dataNorm.isDataReq) {\n isDataReq = true;\n if (url && url.startsWith(\"/_next/data/\")) {\n const __qs = url.includes(\"?\") ? url.slice(url.indexOf(\"?\")) : \"\";\n url = __dataNorm.normalizedPathname + __qs;\n }\n }\n }\n const statusCode = options && typeof options.statusCode === \"number\" ? options.statusCode : undefined;\n const asPath = options && typeof options.asPath === \"string\" ? options.asPath : undefined;\n const renderErrorPageOnMiss = !(options && options.renderErrorPageOnMiss === false);\n // Guard against infinite recursion when the user's custom 500/error page\n // itself throws during render. When this flag is set, the catch block below\n // returns the plain \"Internal Server Error\" text response instead of trying\n // to render an error page again. Fixes #1458.\n const isInternalErrorRender = !!(options && options.__isInternalErrorRender);\n const localeInfo = i18nConfig\n ? resolvePagesI18nRequest(\n url,\n i18nConfig,\n request.headers,\n new URL(request.url).hostname,\n vinextConfig.basePath,\n vinextConfig.trailingSlash,\n )\n : { locale: undefined, url, hadPrefix: false, domainLocale: undefined, redirectUrl: undefined };\n const locale = localeInfo.locale;\n const routeUrl = localeInfo.url;\n const currentDefaultLocale = i18nConfig\n ? (localeInfo.domainLocale ? localeInfo.domainLocale.defaultLocale : i18nConfig.defaultLocale)\n : undefined;\n const domainLocales = i18nConfig ? i18nConfig.domains : undefined;\n\n if (localeInfo.redirectUrl) {\n return new Response(null, { status: 307, headers: { Location: localeInfo.redirectUrl } });\n }\n\n // Internal error render path: caller has pinned a specific route (the\n // user's pages/500 or pages/_error) to render in response to an SSR throw.\n // Skip route matching so we don't accidentally double-route, and skip the\n // missing-route 404 fallback. See catch block below. Fixes #1458.\n let match = options && options.__forcedRoute\n ? { route: options.__forcedRoute, params: {} }\n : matchRoute(routeUrl, pageRoutes);\n let renderStatusCodeOverride = statusCode;\n let renderAsPath = asPath;\n if (!match) {\n if (isDataReq) {\n return __buildNextDataNotFoundResponse();\n }\n if (!renderErrorPageOnMiss) {\n return __buildDefaultPagesNotFoundResponse();\n }\n const notFoundMatch = matchRoute(\"/404\", pageRoutes);\n // matchRoute may match a catch-all (e.g. [...slug]); only use the explicit pages/404 route.\n if (notFoundMatch && notFoundMatch.route.pattern === \"/404\") {\n match = notFoundMatch;\n renderStatusCodeOverride = 404;\n renderAsPath = routeUrl;\n } else if (_errorPageRoute) {\n match = { route: _errorPageRoute, params: {} };\n renderStatusCodeOverride = 404;\n renderAsPath = routeUrl;\n } else {\n return __buildDefaultPagesNotFoundResponse();\n }\n }\n\n const { route, params } = match;\n const __uCtx = _createUnifiedCtx({\n executionContext: _getRequestExecutionContext(),\n });\n return _runWithUnifiedCtx(__uCtx, async () => {\n ensureFetchPatch();\n try {\n const routePattern = patternToNextFormat(route.pattern);\n const renderStatusCode = renderStatusCodeOverride ?? (routePattern === \"/404\" ? 404 : undefined);\n const query = mergeRouteParamsIntoQuery(parseQuery(routeUrl), params);\n if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query,\n asPath: renderAsPath || routeUrl,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n });\n }\n\n if (i18nConfig) {\n setI18nContext({\n locale: locale,\n locales: i18nConfig.locales,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n hostname: new URL(request.url).hostname,\n });\n }\n\n const pageModule = route.module;\n const PageComponent = pageModule.default;\n if (!PageComponent) {\n return new Response(\"Page has no default export\", { status: 500 });\n }\n\n // Refs #1463: reject non-GET/HEAD methods on static (no\n // getServerSideProps) Pages routes with 405 + Allow: GET, HEAD.\n // Skip for error/status pages (/_error, /404, /500), data requests\n // (those go through the JSON envelope path and have their own shape),\n // and renders that are already an error-page miss-render override.\n // Mirrors Next.js's base-server.ts L2277 carve-outs.\n if (\n !isDataReq &&\n routePattern !== \"/_error\" &&\n routePattern !== \"/404\" &&\n routePattern !== \"/500\" &&\n renderStatusCodeOverride === undefined\n ) {\n const methodResponse = __resolvePagesPageMethodResponse({\n hasGetServerSideProps: typeof pageModule.getServerSideProps === \"function\",\n method: request.method,\n });\n if (methodResponse) {\n return methodResponse;\n }\n }\n\n const pageModuleUrl = resolveClientModuleUrl(manifest, route.filePath);\n const appModuleUrl = resolveClientModuleUrl(manifest, _appAssetPath);\n const scriptNonce = __getScriptNonceFromHeaderSources(request.headers, middlewareHeaders);\n // Build font Link header early so it's available for ISR cached responses too.\n // Font preloads are module-level state populated at import time and persist across requests.\n var _fontLinkHeader = \"\";\n var _allFp = [];\n try {\n var _fpGoogle = typeof _getSSRFontPreloadsGoogle === \"function\" ? _getSSRFontPreloadsGoogle() : [];\n var _fpLocal = typeof _getSSRFontPreloadsLocal === \"function\" ? _getSSRFontPreloadsLocal() : [];\n _allFp = _fpGoogle.concat(_fpLocal);\n if (_allFp.length > 0) {\n _fontLinkHeader = _allFp.map(function(p) { return \"<\" + p.href + \">; rel=preload; as=font; type=\" + p.type + \"; crossorigin\"; }).join(\", \");\n }\n } catch (e) { /* font preloads not available */ }\n const pageDataResult = await __resolvePagesPageData({\n isDataReq,\n applyRequestContexts() {\n if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query,\n asPath: renderAsPath || routeUrl,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n });\n }\n if (i18nConfig) {\n setI18nContext({\n locale: locale,\n locales: i18nConfig.locales,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n hostname: new URL(request.url).hostname,\n });\n }\n },\n buildId,\n createGsspReqRes() {\n return __createPagesReqRes({ body: undefined, query, request, url: routeUrl });\n },\n createPageElement(currentPageProps) {\n var currentElement = AppComponent\n ? React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps })\n : React.createElement(PageComponent, currentPageProps);\n return wrapWithRouterContext(currentElement);\n },\n fontLinkHeader: _fontLinkHeader,\n i18n: {\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n },\n isrCacheKey,\n isrGet,\n isrSet,\n expireSeconds: vinextConfig.expireTime,\n // The vinext build phase boots the prod server with VINEXT_PRERENDER=1\n // and fetches every statically-generated page through it. That hit is\n // the \"build\" prerender for revalidateReason; runtime hits are not.\n // Mirrors Next.js's \\`renderOpts.isBuildTimePrerendering\\`. See\n // \\`.nextjs-ref/packages/next/src/server/render.tsx\\` and\n // \\`packages/vinext/src/build/prerender.ts\\`.\n isBuildTimePrerendering: typeof process !== \"undefined\" && process.env && process.env.VINEXT_PRERENDER === \"1\",\n pageModule,\n params,\n query,\n renderIsrPassToStringAsync,\n route: {\n isDynamic: route.isDynamic,\n },\n routePattern,\n routeUrl,\n runInFreshUnifiedContext(callback) {\n var revalCtx = _createUnifiedCtx({\n executionContext: _getRequestExecutionContext(),\n });\n return _runWithUnifiedCtx(revalCtx, async () => {\n ensureFetchPatch();\n return callback();\n });\n },\n safeJsonStringify,\n sanitizeDestination: sanitizeDestinationLocal,\n scriptNonce,\n statusCode: renderStatusCode,\n triggerBackgroundRegeneration,\n vinext: {\n pageModuleUrl,\n appModuleUrl,\n hasMiddleware: __hasMiddleware,\n },\n });\n if (pageDataResult.kind === \"response\") {\n return pageDataResult.response;\n }\n let pageProps = pageDataResult.pageProps;\n if (routePattern === \"/_error\" && typeof renderStatusCode === \"number\") {\n pageProps = { ...pageProps, statusCode: renderStatusCode };\n }\n var gsspRes = pageDataResult.gsspRes;\n let isrRevalidateSeconds = pageDataResult.isrRevalidateSeconds;\n const isFallbackRender = pageDataResult.isFallback === true;\n\n // Republish the SSR context with isFallback flipped on so the page's\n // \\`useRouter().isFallback\\` returns true during render, matching Next.js's\n // \\`render.tsx\\` fallback shell. Without this, the page would still see\n // \\`isFallback: false\\` and run the non-fallback branch.\n if (isFallbackRender && typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query,\n asPath: renderAsPath || routeUrl,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n isFallback: true,\n });\n }\n\n // ── _next/data JSON envelope short-circuit ───────────────────────\n // For client-side navigations Next.js fetches /_next/data/<buildId>/<page>.json\n // and expects { pageProps } as JSON instead of the full HTML page. Skip\n // rendering the React tree and emit the JSON envelope directly via the\n // typed helper so the envelope shape stays in one place. Headers and\n // cookies set on the gsspRes by getServerSideProps are forwarded so\n // middleware/auth flows work the same as the HTML page.\n if (isDataReq) {\n const init = { headers: {} };\n if (gsspRes && typeof gsspRes.getHeaders === \"function\") {\n const gsspHeaders = gsspRes.getHeaders();\n for (const k of Object.keys(gsspHeaders)) {\n const v = gsspHeaders[k];\n if (v === undefined || v === null) continue;\n init.headers[k] = Array.isArray(v) ? v.join(\", \") : String(v);\n }\n }\n if (gsspRes) {\n // Default Cache-Control for gSSP-driven _next/data responses,\n // matching Next.js's pages-handler.ts (revalidate: 0 →\n // getCacheControlHeader). Skip when gSSP already set one via\n // res.setHeader (case-insensitive). Mirrors the HTML branch in\n // pages-page-response.ts and the dev-server branch. Fixes #1461.\n var hasUserCacheControl = false;\n for (const headerKey of Object.keys(init.headers)) {\n if (headerKey.toLowerCase() === \"cache-control\") {\n hasUserCacheControl = true;\n break;\n }\n }\n if (!hasUserCacheControl) {\n init.headers[\"Cache-Control\"] =\n \"private, no-cache, no-store, max-age=0, must-revalidate\";\n }\n }\n return __buildNextDataJsonResponse(pageProps, safeJsonStringify, init);\n }\n\n // Include both the matched page module and the global _app module\n // (if present). _app is wrapped around every page in Pages Router,\n // and any CSS/JS it imports must be linked from the rendered HTML\n // so the browser actually loads it. Without _app in this list, a\n // global stylesheet imported via import \"./globals.scss\" in\n // _app.tsx never reaches the page, producing the LHF-5 symptom\n // where styled elements render with the browser default colour.\n const pageModuleIds = [];\n if (route.filePath) pageModuleIds.push(route.filePath);\n if (_appAssetPath) pageModuleIds.push(_appAssetPath);\n const assetTags = collectAssetTags(manifest, pageModuleIds, scriptNonce);\n\n return __renderPagesPageResponse({\n assetTags,\n buildId,\n clearSsrContext() {\n if (typeof setSSRContext === \"function\") setSSRContext(null);\n },\n createPageElement(currentPageProps) {\n var currentElement;\n if (AppComponent) {\n currentElement = React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps });\n } else {\n currentElement = React.createElement(PageComponent, currentPageProps);\n }\n return wrapWithRouterContext(currentElement);\n },\n DocumentComponent,\n flushPreloads: typeof flushPreloads === \"function\" ? flushPreloads : undefined,\n fontLinkHeader: _fontLinkHeader,\n fontPreloads: _allFp,\n getFontLinks() {\n try {\n return typeof _getSSRFontLinks === \"function\" ? _getSSRFontLinks() : [];\n } catch (e) {\n return [];\n }\n },\n getFontStyles() {\n try {\n var allFontStyles = [];\n if (typeof _getSSRFontStylesGoogle === \"function\") allFontStyles.push(..._getSSRFontStylesGoogle());\n if (typeof _getSSRFontStylesLocal === \"function\") allFontStyles.push(..._getSSRFontStylesLocal());\n return allFontStyles;\n } catch (e) {\n return [];\n }\n },\n getSSRHeadHTML: typeof getSSRHeadHTML === \"function\" ? getSSRHeadHTML : undefined,\n clientTraceMetadata: vinextConfig.clientTraceMetadata,\n gsspRes,\n isrCacheKey,\n expireSeconds: vinextConfig.expireTime,\n isrRevalidateSeconds,\n isrSet,\n i18n: {\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n },\n isFallback: isFallbackRender,\n pageProps,\n params,\n renderDocumentToString(element) {\n return renderToStringAsync(element);\n },\n renderToReadableStream(element) {\n return renderToReadableStream(element);\n },\n resetSSRHead: typeof resetSSRHead === \"function\" ? resetSSRHead : undefined,\n routePattern,\n routeUrl,\n safeJsonStringify,\n scriptNonce,\n statusCode: renderStatusCode,\n vinext: {\n pageModuleUrl,\n appModuleUrl,\n hasMiddleware: __hasMiddleware,\n },\n });\n } catch (e) {\n console.error(\"[vinext] SSR error:\", e);\n _reportRequestError(\n e instanceof Error ? e : new Error(String(e)),\n { path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },\n { routerKind: \"Pages Router\", routePath: route.pattern, routeType: \"render\" },\n ).catch(() => { /* ignore reporting errors */ });\n // Data (_next/data) requests can't render HTML, and avoid recursion if\n // we're already in the middle of rendering the error page itself.\n // Mirrors Next.js base-server.ts which renders /500 (or _error) when\n // SSR throws. Fixes #1458.\n if (!isInternalErrorRender && !isDataReq) {\n // Look for an explicit pages/500.tsx first, then fall back to _error.\n // Only match the literal /500 pattern — never a catch-all/dynamic route.\n let errorRoute = null;\n for (var __i = 0; __i < pageRoutes.length; __i++) {\n if (pageRoutes[__i].pattern === \"/500\") {\n errorRoute = pageRoutes[__i];\n break;\n }\n }\n if (!errorRoute && _errorPageRoute) {\n errorRoute = _errorPageRoute;\n }\n if (errorRoute) {\n try {\n return await _renderPage(request, url, manifest, middlewareHeaders, {\n statusCode: 500,\n asPath: url,\n renderErrorPageOnMiss: false,\n __isInternalErrorRender: true,\n __forcedRoute: errorRoute,\n });\n } catch (errorPageErr) {\n console.error(\"[vinext] Error page render failed:\", errorPageErr);\n }\n }\n }\n return new Response(\"Internal Server Error\", { status: 500 });\n }\n });\n}\n\nexport async function handleApiRoute(request, url, ctx) {\n const match = matchRoute(url, apiRoutes);\n return __handlePagesApiRoute({\n ctx,\n match,\n request,\n url,\n reportRequestError(error, routePattern) {\n console.error(\"[vinext] API error:\", error);\n void _reportRequestError(\n error,\n { path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },\n { routerKind: \"Pages Router\", routePath: routePattern, routeType: \"route\" },\n );\n },\n });\n}\n\n${middlewareExportCode}\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAM,0BAA0B,iBAAiB,+BAA+B,OAAO,KAAK,IAAI;AAChG,MAAM,yBAAyB,iBAAiB,mCAAmC,OAAO,KAAK,IAAI;AACnG,MAAM,iBAAiB,iBAAiB,4BAA4B,OAAO,KAAK,IAAI;AACpF,MAAM,iBAAiB,iBAAiB,2BAA2B,OAAO,KAAK,IAAI;AACnF,MAAM,yBAAyB,iBAC7B,oCACA,OAAO,KAAK,IACb;AACD,MAAM,qBAAqB,iBAAiB,gCAAgC,OAAO,KAAK,IAAI;AAC5F,MAAM,uBAAuB,iBAAiB,kCAAkC,OAAO,KAAK,IAAI;AAChG,MAAM,sBAAsB,iBAAiB,iCAAiC,OAAO,KAAK,IAAI;AAC9F,MAAM,uBAAuB,iBAAiB,kCAAkC,OAAO,KAAK,IAAI;AAChG,MAAM,uBAAuB,iBAAiB,kCAAkC,OAAO,KAAK,IAAI;AAChG,MAAM,qBAAqB,iBAAiB,gCAAgC,OAAO,KAAK,IAAI;AAC5F,MAAM,gBAAgB,iBAAiB,0BAA0B,OAAO,KAAK,IAAI;AACjF,MAAM,WAAW,iBAAiB,oBAAoB,OAAO,KAAK,IAAI;AACtE,MAAM,qBAAqB,iBAAiB,+BAA+B,OAAO,KAAK,IAAI;;;;;AAM3F,eAAsB,oBACpB,UACA,YACA,aACA,gBACA,qBACiB;CACjB,MAAM,aAAa,MAAM,YAAY,UAAU,YAAY,gBAAgB,YAAY;CACvF,MAAM,YAAY,MAAM,UAAU,UAAU,YAAY,gB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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsoB5B,qBAAqB"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
//#region src/entries/runtime-entry-module.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Convert Windows-style backslash path separators to forward slashes.
|
|
4
|
-
*
|
|
5
|
-
* Generated entry modules embed absolute filesystem paths inside `import`
|
|
6
|
-
* statements. On Windows the OS-native paths use `\` which is invalid in JS
|
|
7
|
-
* module specifiers, so every entry generator normalizes paths through this
|
|
8
|
-
* helper before stringifying them into the emitted code.
|
|
9
|
-
*/
|
|
10
|
-
declare function normalizePathSeparators(p: string): string;
|
|
11
2
|
/**
|
|
12
3
|
* Resolve a sibling module path relative to a caller's `import.meta.url`,
|
|
13
4
|
* returning a forward-slash path safe for embedding in generated code.
|
|
@@ -31,5 +22,5 @@ declare function resolveEntryPath(rel: string, base: string): string;
|
|
|
31
22
|
declare function resolveRuntimeEntryModule(name: string): string;
|
|
32
23
|
declare function resolveClientRuntimeModule(name: string): string;
|
|
33
24
|
//#endregion
|
|
34
|
-
export {
|
|
25
|
+
export { resolveClientRuntimeModule, resolveEntryPath, resolveRuntimeEntryModule };
|
|
35
26
|
//# sourceMappingURL=runtime-entry-module.d.ts.map
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
+
import { normalizePathSeparators } from "../utils/path.js";
|
|
1
2
|
import fs from "node:fs";
|
|
2
3
|
import { fileURLToPath } from "node:url";
|
|
3
4
|
//#region src/entries/runtime-entry-module.ts
|
|
4
5
|
/**
|
|
5
|
-
* Convert Windows-style backslash path separators to forward slashes.
|
|
6
|
-
*
|
|
7
|
-
* Generated entry modules embed absolute filesystem paths inside `import`
|
|
8
|
-
* statements. On Windows the OS-native paths use `\` which is invalid in JS
|
|
9
|
-
* module specifiers, so every entry generator normalizes paths through this
|
|
10
|
-
* helper before stringifying them into the emitted code.
|
|
11
|
-
*/
|
|
12
|
-
function normalizePathSeparators(p) {
|
|
13
|
-
return p.replace(/\\/g, "/");
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
6
|
* Resolve a sibling module path relative to a caller's `import.meta.url`,
|
|
17
7
|
* returning a forward-slash path safe for embedding in generated code.
|
|
18
8
|
*
|
|
@@ -53,6 +43,6 @@ function resolveRuntimeModulePath(directory, name) {
|
|
|
53
43
|
return resolveEntryPath(`../${directory}/${name}.js`, import.meta.url);
|
|
54
44
|
}
|
|
55
45
|
//#endregion
|
|
56
|
-
export {
|
|
46
|
+
export { resolveClientRuntimeModule, resolveEntryPath, resolveRuntimeEntryModule };
|
|
57
47
|
|
|
58
48
|
//# sourceMappingURL=runtime-entry-module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-entry-module.js","names":[],"sources":["../../src/entries/runtime-entry-module.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\
|
|
1
|
+
{"version":3,"file":"runtime-entry-module.js","names":[],"sources":["../../src/entries/runtime-entry-module.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { normalizePathSeparators } from \"../utils/path.js\";\n\n/**\n * Resolve a sibling module path relative to a caller's `import.meta.url`,\n * returning a forward-slash path safe for embedding in generated code.\n *\n * This is the single place that owns the\n * `fileURLToPath(new URL(rel, base))` + path-separator normalization idiom so\n * callers don't duplicate it.\n *\n * @param rel - Relative path to the target module (e.g. `\"../server/foo.js\"`)\n * @param base - The caller's `import.meta.url`\n */\nexport function resolveEntryPath(rel: string, base: string): string {\n return normalizePathSeparators(fileURLToPath(new URL(rel, base)));\n}\n\n/**\n * Resolve a real runtime module for a virtual entry generator.\n *\n * During local development we want to point at source files (for example `.ts`),\n * while packed builds only contain emitted `.js` files in `dist/`. Probe the\n * common source/build extensions and fall back to the `.js` path that exists in\n * published packages.\n */\nexport function resolveRuntimeEntryModule(name: string): string {\n return resolveRuntimeModulePath(\"server\", name);\n}\n\nexport function resolveClientRuntimeModule(name: string): string {\n return resolveRuntimeModulePath(\"client\", name);\n}\n\nfunction resolveRuntimeModulePath(directory: \"client\" | \"server\", name: string): string {\n for (const ext of [\".ts\", \".js\", \".mts\", \".mjs\"]) {\n const filePath = resolveEntryPath(`../${directory}/${name}${ext}`, import.meta.url);\n if (fs.existsSync(filePath)) {\n return filePath;\n }\n }\n\n return resolveEntryPath(`../${directory}/${name}.js`, import.meta.url);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAgB,iBAAiB,KAAa,MAAsB;CAClE,OAAO,wBAAwB,cAAc,IAAI,IAAI,KAAK,KAAK,CAAC,CAAC;;;;;;;;;;AAWnE,SAAgB,0BAA0B,MAAsB;CAC9D,OAAO,yBAAyB,UAAU,KAAK;;AAGjD,SAAgB,2BAA2B,MAAsB;CAC/D,OAAO,yBAAyB,UAAU,KAAK;;AAGjD,SAAS,yBAAyB,WAAgC,MAAsB;CACtF,KAAK,MAAM,OAAO;EAAC;EAAO;EAAO;EAAQ;EAAO,EAAE;EAChD,MAAM,WAAW,iBAAiB,MAAM,UAAU,GAAG,OAAO,OAAO,OAAO,KAAK,IAAI;EACnF,IAAI,GAAG,WAAW,SAAS,EACzB,OAAO;;CAIX,OAAO,iBAAiB,MAAM,UAAU,GAAG,KAAK,MAAM,OAAO,KAAK,IAAI"}
|