vinext 0.0.35 → 0.0.36
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/config/config-matchers.js +1 -1
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/entries/pages-server-entry.js +105 -216
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/server/pages-page-data.d.ts +105 -0
- package/dist/server/pages-page-data.js +177 -0
- package/dist/server/pages-page-data.js.map +1 -0
- package/dist/server/pages-page-response.d.ts +2 -1
- package/dist/server/pages-page-response.js +1 -1
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/shims/navigation-state.js +5 -3
- package/dist/shims/navigation-state.js.map +1 -1
- package/dist/shims/navigation.d.ts +9 -7
- package/dist/shims/navigation.js +20 -5
- package/dist/shims/navigation.js.map +1 -1
- package/package.json +1 -1
|
@@ -19,6 +19,7 @@ const _requestContextShimPath = fileURLToPath(new URL("../shims/request-context.
|
|
|
19
19
|
const _routeTriePath = fileURLToPath(new URL("../routing/route-trie.js", import.meta.url)).replace(/\\/g, "/");
|
|
20
20
|
const _pagesI18nPath = fileURLToPath(new URL("../server/pages-i18n.js", import.meta.url)).replace(/\\/g, "/");
|
|
21
21
|
const _pagesPageResponsePath = fileURLToPath(new URL("../server/pages-page-response.js", import.meta.url)).replace(/\\/g, "/");
|
|
22
|
+
const _pagesPageDataPath = fileURLToPath(new URL("../server/pages-page-data.js", import.meta.url)).replace(/\\/g, "/");
|
|
22
23
|
/**
|
|
23
24
|
* Generate the virtual SSR server entry module.
|
|
24
25
|
* This is the entry point for `vite build --ssr`.
|
|
@@ -211,6 +212,7 @@ import { runWithExecutionContext as _runWithExecutionContext, getRequestExecutio
|
|
|
211
212
|
import { buildRouteTrie as _buildRouteTrie, trieMatch as _trieMatch } from ${JSON.stringify(_routeTriePath)};
|
|
212
213
|
import { reportRequestError as _reportRequestError } from "vinext/instrumentation";
|
|
213
214
|
import { resolvePagesI18nRequest } from ${JSON.stringify(_pagesI18nPath)};
|
|
215
|
+
import { resolvePagesPageData as __resolvePagesPageData } from ${JSON.stringify(_pagesPageDataPath)};
|
|
214
216
|
import { renderPagesPageResponse as __renderPagesPageResponse } from ${JSON.stringify(_pagesPageResponsePath)};
|
|
215
217
|
${instrumentationImportCode}
|
|
216
218
|
${middlewareImportCode}
|
|
@@ -668,19 +670,20 @@ async function _renderPage(request, url, manifest) {
|
|
|
668
670
|
{ status: 404, headers: { "Content-Type": "text/html" } });
|
|
669
671
|
}
|
|
670
672
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
673
|
+
const { route, params } = match;
|
|
674
|
+
const __uCtx = _createUnifiedCtx({
|
|
675
|
+
executionContext: _getRequestExecutionContext(),
|
|
676
|
+
});
|
|
677
|
+
return _runWithUnifiedCtx(__uCtx, async () => {
|
|
678
|
+
ensureFetchPatch();
|
|
679
|
+
try {
|
|
680
|
+
const routePattern = patternToNextFormat(route.pattern);
|
|
681
|
+
if (typeof setSSRContext === "function") {
|
|
682
|
+
setSSRContext({
|
|
683
|
+
pathname: routePattern,
|
|
684
|
+
query: { ...params, ...parseQuery(routeUrl) },
|
|
685
|
+
asPath: routeUrl,
|
|
686
|
+
locale: locale,
|
|
684
687
|
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
685
688
|
defaultLocale: currentDefaultLocale,
|
|
686
689
|
domainLocales: domainLocales,
|
|
@@ -699,210 +702,96 @@ async function _renderPage(request, url, manifest) {
|
|
|
699
702
|
|
|
700
703
|
const pageModule = route.module;
|
|
701
704
|
const PageComponent = pageModule.default;
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
locales: i18nConfig ? i18nConfig.locales : [],
|
|
710
|
-
defaultLocale: currentDefaultLocale || "",
|
|
711
|
-
});
|
|
712
|
-
const fallback = pathsResult && pathsResult.fallback !== undefined ? pathsResult.fallback : false;
|
|
713
|
-
|
|
714
|
-
if (fallback === false) {
|
|
715
|
-
const paths = pathsResult && pathsResult.paths ? pathsResult.paths : [];
|
|
716
|
-
const isValidPath = paths.some(function(p) {
|
|
717
|
-
return Object.entries(p.params).every(function(entry) {
|
|
718
|
-
var key = entry[0], val = entry[1];
|
|
719
|
-
var actual = params[key];
|
|
720
|
-
if (Array.isArray(val)) {
|
|
721
|
-
return Array.isArray(actual) && val.join("/") === actual.join("/");
|
|
722
|
-
}
|
|
723
|
-
return String(val) === String(actual);
|
|
724
|
-
});
|
|
725
|
-
});
|
|
726
|
-
if (!isValidPath) {
|
|
727
|
-
return new Response("<!DOCTYPE html><html><body><h1>404 - Page not found</h1></body></html>",
|
|
728
|
-
{ status: 404, headers: { "Content-Type": "text/html" } });
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
let pageProps = {};
|
|
734
|
-
var gsspRes = null;
|
|
735
|
-
if (typeof pageModule.getServerSideProps === "function") {
|
|
736
|
-
const { req, res, responsePromise } = createReqRes(request, routeUrl, parseQuery(routeUrl), undefined);
|
|
737
|
-
const ctx = {
|
|
738
|
-
params, req, res,
|
|
739
|
-
query: parseQuery(routeUrl),
|
|
740
|
-
resolvedUrl: routeUrl,
|
|
741
|
-
locale: locale,
|
|
742
|
-
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
743
|
-
defaultLocale: currentDefaultLocale,
|
|
744
|
-
};
|
|
745
|
-
const result = await pageModule.getServerSideProps(ctx);
|
|
746
|
-
// If gSSP called res.end() directly (short-circuit), return that response.
|
|
747
|
-
if (res.headersSent) {
|
|
748
|
-
return await responsePromise;
|
|
749
|
-
}
|
|
750
|
-
if (result && result.props) pageProps = result.props;
|
|
751
|
-
if (result && result.redirect) {
|
|
752
|
-
var gsspStatus = result.redirect.statusCode != null ? result.redirect.statusCode : (result.redirect.permanent ? 308 : 307);
|
|
753
|
-
return new Response(null, { status: gsspStatus, headers: { Location: sanitizeDestinationLocal(result.redirect.destination) } });
|
|
754
|
-
}
|
|
755
|
-
if (result && result.notFound) {
|
|
756
|
-
return new Response("404", { status: 404 });
|
|
757
|
-
}
|
|
758
|
-
// Preserve the res object so headers/status/cookies set by gSSP
|
|
759
|
-
// can be merged into the final HTML response.
|
|
760
|
-
gsspRes = res;
|
|
761
|
-
}
|
|
762
|
-
// Build font Link header early so it's available for ISR cached responses too.
|
|
763
|
-
// Font preloads are module-level state populated at import time and persist across requests.
|
|
764
|
-
var _fontLinkHeader = "";
|
|
765
|
-
var _allFp = [];
|
|
705
|
+
if (!PageComponent) {
|
|
706
|
+
return new Response("Page has no default export", { status: 500 });
|
|
707
|
+
}
|
|
708
|
+
// Build font Link header early so it's available for ISR cached responses too.
|
|
709
|
+
// Font preloads are module-level state populated at import time and persist across requests.
|
|
710
|
+
var _fontLinkHeader = "";
|
|
711
|
+
var _allFp = [];
|
|
766
712
|
try {
|
|
767
713
|
var _fpGoogle = typeof _getSSRFontPreloadsGoogle === "function" ? _getSSRFontPreloadsGoogle() : [];
|
|
768
714
|
var _fpLocal = typeof _getSSRFontPreloadsLocal === "function" ? _getSSRFontPreloadsLocal() : [];
|
|
769
715
|
_allFp = _fpGoogle.concat(_fpLocal);
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
// Reconstruct ISR HTML preserving the document shell from the
|
|
850
|
-
// cached entry (head, fonts, assets, custom _document markup).
|
|
851
|
-
var _cachedStr = cached.value.value.html;
|
|
852
|
-
var _btag = '<div id="__next">';
|
|
853
|
-
var _bstart = _cachedStr.indexOf(_btag);
|
|
854
|
-
var _bodyStart = _bstart >= 0 ? _bstart + _btag.length : -1;
|
|
855
|
-
// Locate __NEXT_DATA__ script to split body from suffix
|
|
856
|
-
var _ndMarker = '<script>window.__NEXT_DATA__';
|
|
857
|
-
var _ndStart = _cachedStr.indexOf(_ndMarker);
|
|
858
|
-
var _freshHtml;
|
|
859
|
-
if (_bodyStart >= 0 && _ndStart >= 0) {
|
|
860
|
-
// Region between body start and __NEXT_DATA__ contains:
|
|
861
|
-
// BODY_HTML + </div> + optional gap (custom _document content)
|
|
862
|
-
var _region = _cachedStr.slice(_bodyStart, _ndStart);
|
|
863
|
-
var _lastClose = _region.lastIndexOf('</div>');
|
|
864
|
-
var _gap = _lastClose >= 0 ? _region.slice(_lastClose + 6) : '';
|
|
865
|
-
// Tail: everything after the old __NEXT_DATA__ <\/script>
|
|
866
|
-
var _ndEnd = _cachedStr.indexOf('<\/script>', _ndStart) + 9;
|
|
867
|
-
var _tail = _cachedStr.slice(_ndEnd);
|
|
868
|
-
_freshHtml = _cachedStr.slice(0, _bodyStart) + _freshBody + '</div>' + _gap + _freshNDS + _tail;
|
|
869
|
-
} else {
|
|
870
|
-
_freshHtml = '<!DOCTYPE html>\\n<html>\\n<head>\\n</head>\\n<body>\\n <div id="__next">' + _freshBody + '</div>\\n ' + _freshNDS + '\\n</body>\\n</html>';
|
|
871
|
-
}
|
|
872
|
-
await isrSet(cacheKey, { kind: "PAGES", html: _freshHtml, pageData: _fp, headers: undefined, status: undefined }, freshResult.revalidate);
|
|
873
|
-
}
|
|
874
|
-
});
|
|
875
|
-
});
|
|
876
|
-
var _staleHeaders = {
|
|
877
|
-
"Content-Type": "text/html", "X-Vinext-Cache": "STALE",
|
|
878
|
-
"Cache-Control": "s-maxage=0, stale-while-revalidate",
|
|
879
|
-
};
|
|
880
|
-
if (_fontLinkHeader) _staleHeaders["Link"] = _fontLinkHeader;
|
|
881
|
-
return new Response(cached.value.value.html, { status: 200, headers: _staleHeaders });
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
const ctx = {
|
|
885
|
-
params,
|
|
886
|
-
locale: locale,
|
|
887
|
-
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
888
|
-
defaultLocale: currentDefaultLocale,
|
|
889
|
-
};
|
|
890
|
-
const result = await pageModule.getStaticProps(ctx);
|
|
891
|
-
if (result && result.props) pageProps = result.props;
|
|
892
|
-
if (result && result.redirect) {
|
|
893
|
-
var gspStatus = result.redirect.statusCode != null ? result.redirect.statusCode : (result.redirect.permanent ? 308 : 307);
|
|
894
|
-
return new Response(null, { status: gspStatus, headers: { Location: sanitizeDestinationLocal(result.redirect.destination) } });
|
|
895
|
-
}
|
|
896
|
-
if (result && result.notFound) {
|
|
897
|
-
return new Response("404", { status: 404 });
|
|
898
|
-
}
|
|
899
|
-
if (typeof result.revalidate === "number" && result.revalidate > 0) {
|
|
900
|
-
isrRevalidateSeconds = result.revalidate;
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
const pageModuleIds = route.filePath ? [route.filePath] : [];
|
|
905
|
-
const assetTags = collectAssetTags(manifest, pageModuleIds);
|
|
716
|
+
if (_allFp.length > 0) {
|
|
717
|
+
_fontLinkHeader = _allFp.map(function(p) { return "<" + p.href + ">; rel=preload; as=font; type=" + p.type + "; crossorigin"; }).join(", ");
|
|
718
|
+
}
|
|
719
|
+
} catch (e) { /* font preloads not available */ }
|
|
720
|
+
const query = parseQuery(routeUrl);
|
|
721
|
+
const pageDataResult = await __resolvePagesPageData({
|
|
722
|
+
applyRequestContexts() {
|
|
723
|
+
if (typeof setSSRContext === "function") {
|
|
724
|
+
setSSRContext({
|
|
725
|
+
pathname: routePattern,
|
|
726
|
+
query: { ...params, ...query },
|
|
727
|
+
asPath: routeUrl,
|
|
728
|
+
locale: locale,
|
|
729
|
+
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
730
|
+
defaultLocale: currentDefaultLocale,
|
|
731
|
+
domainLocales: domainLocales,
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
if (i18nConfig) {
|
|
735
|
+
setI18nContext({
|
|
736
|
+
locale: locale,
|
|
737
|
+
locales: i18nConfig.locales,
|
|
738
|
+
defaultLocale: currentDefaultLocale,
|
|
739
|
+
domainLocales: domainLocales,
|
|
740
|
+
hostname: new URL(request.url).hostname,
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
},
|
|
744
|
+
buildId,
|
|
745
|
+
createGsspReqRes() {
|
|
746
|
+
return createReqRes(request, routeUrl, query, undefined);
|
|
747
|
+
},
|
|
748
|
+
createPageElement(currentPageProps) {
|
|
749
|
+
var currentElement = AppComponent
|
|
750
|
+
? React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps })
|
|
751
|
+
: React.createElement(PageComponent, currentPageProps);
|
|
752
|
+
return wrapWithRouterContext(currentElement);
|
|
753
|
+
},
|
|
754
|
+
fontLinkHeader: _fontLinkHeader,
|
|
755
|
+
i18n: {
|
|
756
|
+
locale: locale,
|
|
757
|
+
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
758
|
+
defaultLocale: currentDefaultLocale,
|
|
759
|
+
domainLocales: domainLocales,
|
|
760
|
+
},
|
|
761
|
+
isrCacheKey,
|
|
762
|
+
isrGet,
|
|
763
|
+
isrSet,
|
|
764
|
+
pageModule,
|
|
765
|
+
params,
|
|
766
|
+
query,
|
|
767
|
+
renderIsrPassToStringAsync,
|
|
768
|
+
route: {
|
|
769
|
+
isDynamic: route.isDynamic,
|
|
770
|
+
},
|
|
771
|
+
routePattern,
|
|
772
|
+
routeUrl,
|
|
773
|
+
runInFreshUnifiedContext(callback) {
|
|
774
|
+
var revalCtx = _createUnifiedCtx({
|
|
775
|
+
executionContext: _getRequestExecutionContext(),
|
|
776
|
+
});
|
|
777
|
+
return _runWithUnifiedCtx(revalCtx, async () => {
|
|
778
|
+
ensureFetchPatch();
|
|
779
|
+
return callback();
|
|
780
|
+
});
|
|
781
|
+
},
|
|
782
|
+
safeJsonStringify,
|
|
783
|
+
sanitizeDestination: sanitizeDestinationLocal,
|
|
784
|
+
triggerBackgroundRegeneration,
|
|
785
|
+
});
|
|
786
|
+
if (pageDataResult.kind === "response") {
|
|
787
|
+
return pageDataResult.response;
|
|
788
|
+
}
|
|
789
|
+
let pageProps = pageDataResult.pageProps;
|
|
790
|
+
var gsspRes = pageDataResult.gsspRes;
|
|
791
|
+
let isrRevalidateSeconds = pageDataResult.isrRevalidateSeconds;
|
|
792
|
+
|
|
793
|
+
const pageModuleIds = route.filePath ? [route.filePath] : [];
|
|
794
|
+
const assetTags = collectAssetTags(manifest, pageModuleIds);
|
|
906
795
|
|
|
907
796
|
return __renderPagesPageResponse({
|
|
908
797
|
assetTags,
|
|
@@ -940,8 +829,8 @@ async function _renderPage(request, url, manifest) {
|
|
|
940
829
|
return [];
|
|
941
830
|
}
|
|
942
831
|
},
|
|
943
|
-
|
|
944
|
-
|
|
832
|
+
getSSRHeadHTML: typeof getSSRHeadHTML === "function" ? getSSRHeadHTML : undefined,
|
|
833
|
+
gsspRes,
|
|
945
834
|
isrCacheKey,
|
|
946
835
|
isrRevalidateSeconds,
|
|
947
836
|
isrSet,
|
|
@@ -961,7 +850,7 @@ async function _renderPage(request, url, manifest) {
|
|
|
961
850
|
return renderToReadableStream(element);
|
|
962
851
|
},
|
|
963
852
|
resetSSRHead: typeof resetSSRHead === "function" ? resetSSRHead : undefined,
|
|
964
|
-
|
|
853
|
+
routePattern,
|
|
965
854
|
routeUrl,
|
|
966
855
|
safeJsonStringify,
|
|
967
856
|
});
|
|
@@ -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 path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\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 {\n generateSafeRegExpCode,\n generateMiddlewareMatcherCode,\n generateNormalizePathCode,\n generateRouteMatchNormalizationCode,\n} from \"../server/middleware-codegen.js\";\nimport { findFileWithExts } from \"./pages-entry-helpers.js\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst _requestContextShimPath = fileURLToPath(\n new URL(\"../shims/request-context.js\", import.meta.url),\n).replace(/\\\\/g, \"/\");\nconst _routeTriePath = fileURLToPath(new URL(\"../routing/route-trie.js\", import.meta.url)).replace(\n /\\\\/g,\n \"/\",\n);\nconst _pagesI18nPath = fileURLToPath(new URL(\"../server/pages-i18n.js\", import.meta.url)).replace(\n /\\\\/g,\n \"/\",\n);\nconst _pagesPageResponsePath = fileURLToPath(\n new URL(\"../server/pages-page-response.js\", import.meta.url),\n).replace(/\\\\/g, \"/\");\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 = r.filePath.replace(/\\\\/g, \"/\");\n return `import * as page_${i} from ${JSON.stringify(absPath)};`;\n });\n\n const apiImports = apiRoutes.map((r: Route, i: number) => {\n const absPath = r.filePath.replace(/\\\\/g, \"/\");\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 = r.filePath.replace(/\\\\/g, \"/\");\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((r: Route, i: number) => {\n return ` { 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 and _document\n const appFilePath = findFileWithExts(pagesDir, \"_app\", fileMatcher);\n const docFilePath = findFileWithExts(pagesDir, \"_document\", fileMatcher);\n const appImportCode =\n appFilePath !== null\n ? `import { default as AppComponent } from ${JSON.stringify(appFilePath.replace(/\\\\/g, \"/\"))};`\n : `const AppComponent = null;`;\n\n const docImportCode =\n docFilePath !== null\n ? `import { default as DocumentComponent } from ${JSON.stringify(docFilePath.replace(/\\\\/g, \"/\"))};`\n : `const DocumentComponent = 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 trailingSlash: nextConfig?.trailingSlash ?? false,\n redirects: nextConfig?.redirects ?? [],\n rewrites: nextConfig?.rewrites ?? { beforeFiles: [], afterFiles: [], fallback: [] },\n headers: nextConfig?.headers ?? [],\n i18n: nextConfig?.i18n ?? null,\n images: {\n deviceSizes: nextConfig?.images?.deviceSizes,\n imageSizes: nextConfig?.images?.imageSizes,\n dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,\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(instrumentationPath.replace(/\\\\/g, \"/\"))};`\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(middlewarePath.replace(/\\\\/g, \"/\"))};\nimport { NextRequest, NextFetchEvent } from \"next/server\";`\n : \"\";\n\n // The matcher config is read from the middleware module at import time.\n // We inline the matching + execution logic so the prod server can call it.\n const middlewareExportCode = middlewarePath\n ? `\n// --- Middleware support (generated from middleware-codegen.ts) ---\n${generateNormalizePathCode(\"es5\")}\n${generateRouteMatchNormalizationCode(\"es5\")}\n${generateSafeRegExpCode(\"es5\")}\n${generateMiddlewareMatcherCode(\"es5\")}\n\nexport async function runMiddleware(request, ctx) {\n if (ctx) return _runWithExecutionContext(ctx, () => _runMiddleware(request));\n return _runMiddleware(request);\n}\n\nasync function _runMiddleware(request) {\n var isProxy = ${middlewarePath ? JSON.stringify(isProxyFile(middlewarePath)) : \"false\"};\n var middlewareFn = isProxy\n ? (middlewareModule.proxy ?? middlewareModule.default)\n : (middlewareModule.middleware ?? middlewareModule.default);\n if (typeof middlewareFn !== \"function\") {\n var fileType = isProxy ? \"Proxy\" : \"Middleware\";\n var expectedExport = isProxy ? \"proxy\" : \"middleware\";\n throw new Error(\"The \" + fileType + \" file must export a function named \\`\" + expectedExport + \"\\` or a \\`default\\` function.\");\n }\n\n var config = middlewareModule.config;\n var matcher = config && config.matcher;\n var url = new URL(request.url);\n\n // Normalize pathname before matching to prevent path-confusion bypasses\n // (percent-encoding like /%61dmin, double slashes like /dashboard//settings).\n var decodedPathname;\n try { decodedPathname = __normalizePathnameForRouteMatchStrict(url.pathname); } catch (e) {\n return { continue: false, response: new Response(\"Bad Request\", { status: 400 }) };\n }\n var normalizedPathname = __normalizePath(decodedPathname);\n\n if (!matchesMiddleware(normalizedPathname, matcher, request, i18nConfig)) return { continue: true };\n\n // Construct a new Request with the decoded + normalized pathname so middleware\n // always sees the same canonical path that the router uses.\n var mwRequest = request;\n if (normalizedPathname !== url.pathname) {\n var mwUrl = new URL(url);\n mwUrl.pathname = normalizedPathname;\n mwRequest = new Request(mwUrl, request);\n }\n var __mwNextConfig = (vinextConfig.basePath || i18nConfig) ? { basePath: vinextConfig.basePath, i18n: i18nConfig || undefined } : undefined;\n var nextRequest = mwRequest instanceof NextRequest ? mwRequest : new NextRequest(mwRequest, __mwNextConfig ? { nextConfig: __mwNextConfig } : undefined);\n var fetchEvent = new NextFetchEvent({ page: normalizedPathname });\n var response;\n try { response = await middlewareFn(nextRequest, fetchEvent); }\n catch (e) {\n console.error(\"[vinext] Middleware error:\", e);\n return { continue: false, response: new Response(\"Internal Server Error\", { status: 500 }) };\n }\n var _mwCtx = _getRequestExecutionContext();\n if (_mwCtx && typeof _mwCtx.waitUntil === \"function\") { _mwCtx.waitUntil(fetchEvent.drainWaitUntil()); } else { fetchEvent.drainWaitUntil(); }\n\n if (!response) return { continue: true };\n\n if (response.headers.get(\"x-middleware-next\") === \"1\") {\n var rHeaders = new Headers();\n for (var [key, value] of response.headers) {\n // Keep x-middleware-request-* headers so the production server can\n // apply middleware-request header overrides before stripping internals\n // from the final client response.\n if (\n !key.startsWith(\"x-middleware-\") ||\n key === \"x-middleware-override-headers\" ||\n key.startsWith(\"x-middleware-request-\")\n ) rHeaders.append(key, value);\n }\n return { continue: true, responseHeaders: rHeaders };\n }\n\n if (response.status >= 300 && response.status < 400) {\n var location = response.headers.get(\"Location\") || response.headers.get(\"location\");\n if (location) {\n var rdHeaders = new Headers();\n for (var [rk, rv] of response.headers) {\n if (!rk.startsWith(\"x-middleware-\") && rk.toLowerCase() !== \"location\") rdHeaders.append(rk, rv);\n }\n return { continue: false, redirectUrl: location, redirectStatus: response.status, responseHeaders: rdHeaders };\n }\n }\n\n var rewriteUrl = response.headers.get(\"x-middleware-rewrite\");\n if (rewriteUrl) {\n var rwHeaders = new Headers();\n for (var [k, v] of response.headers) {\n if (!k.startsWith(\"x-middleware-\") || k === \"x-middleware-override-headers\" || k.startsWith(\"x-middleware-request-\")) rwHeaders.append(k, v);\n }\n var rewritePath;\n try { var parsed = new URL(rewriteUrl, request.url); rewritePath = parsed.pathname + parsed.search; }\n catch { rewritePath = rewriteUrl; }\n return { continue: true, rewriteUrl: rewritePath, rewriteStatus: response.status !== 200 ? response.status : undefined, responseHeaders: rwHeaders };\n }\n\n return { continue: false, response: response };\n}\n`\n : `\nexport async function runMiddleware() { return { continue: true }; }\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 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 { getCacheHandler, _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 { safeJsonStringify } from \"vinext/html\";\nimport { decode as decodeQueryString } from \"node:querystring\";\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 { parseCookies, sanitizeDestination as sanitizeDestinationLocal } from ${JSON.stringify(path.resolve(__dirname, \"../config/config-matchers.js\").replace(/\\\\/g, \"/\"))};\nimport { runWithExecutionContext as _runWithExecutionContext, getRequestExecutionContext as _getRequestExecutionContext } from ${JSON.stringify(_requestContextShimPath)};\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 { 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)\nconst buildId = ${buildIdJson};\n\n// Full resolved config for production server (embedded at build time)\nexport const vinextConfig = ${vinextConfigJson};\n\nclass ApiBodyParseError extends Error {\n constructor(message, statusCode) {\n super(message);\n this.statusCode = statusCode;\n this.name = \"ApiBodyParseError\";\n }\n}\n\n// ISR cache helpers (inlined for the server entry)\nasync function isrGet(key) {\n const handler = getCacheHandler();\n const result = await handler.get(key);\n if (!result || !result.value) return null;\n return { value: result, isStale: result.cacheState === \"stale\" };\n}\nasync function isrSet(key, data, revalidateSeconds, tags) {\n const handler = getCacheHandler();\n await handler.set(key, data, { revalidate: revalidateSeconds, tags: tags || [] });\n}\nconst pendingRegenerations = new Map();\nfunction triggerBackgroundRegeneration(key, renderFn) {\n if (pendingRegenerations.has(key)) return;\n const promise = renderFn()\n .catch((err) => console.error(\"[vinext] ISR regen failed for \" + key + \":\", err))\n .finally(() => pendingRegenerations.delete(key));\n pendingRegenerations.set(key, promise);\n // Register with the Workers ExecutionContext so the isolate is kept alive\n // until the regeneration finishes, even after the Response has been sent.\n const ctx = _getRequestExecutionContext();\n if (ctx && typeof ctx.waitUntil === \"function\") ctx.waitUntil(promise);\n}\n\nfunction fnv1a64(input) {\n let h1 = 0x811c9dc5;\n for (let i = 0; i < input.length; i++) {\n h1 ^= input.charCodeAt(i);\n h1 = (h1 * 0x01000193) >>> 0;\n }\n let h2 = 0x050c5d1f;\n for (let i = 0; i < input.length; i++) {\n h2 ^= input.charCodeAt(i);\n h2 = (h2 * 0x01000193) >>> 0;\n }\n return h1.toString(36) + h2.toString(36);\n}\n// Keep prefix construction and hashing logic in sync with isrCacheKey() in server/isr-cache.ts.\n// buildId is a top-level const in the generated entry (see \"const buildId = ...\" above).\nfunction isrCacheKey(router, pathname) {\n const normalized = pathname === \"/\" ? \"/\" : pathname.replace(/\\\\/$/, \"\");\n const prefix = buildId ? router + \":\" + buildId : router;\n const key = prefix + \":\" + normalized;\n if (key.length <= 200) return key;\n return prefix + \":__hash:\" + fnv1a64(normalized);\n}\n\nfunction getMediaType(contentType) {\n var type = (contentType || \"text/plain\").split(\";\")[0];\n type = type && type.trim().toLowerCase();\n return type || \"text/plain\";\n}\n\nfunction isJsonMediaType(mediaType) {\n return mediaType === \"application/json\" || mediaType === \"application/ld+json\";\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\nexport const pageRoutes = [\n${pageRouteEntries.join(\",\\n\")}\n];\nconst _pageRouteTrie = _buildRouteTrie(pageRoutes);\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\nfunction parseQuery(url) {\n const qs = url.split(\"?\")[1];\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 patternToNextFormat(pattern) {\n return pattern\n .replace(/:([\\\\w]+)\\\\*/g, \"[[...$1]]\")\n .replace(/:([\\\\w]+)\\\\+/g, \"[...$1]\")\n .replace(/:([\\\\w]+)/g, \"[$1]\");\n}\n\nfunction collectAssetTags(manifest, moduleIds) {\n // Fall back to embedded manifest (set by vinext:cloudflare-build for Workers)\n const m = (manifest && Object.keys(manifest).length > 0)\n ? manifest\n : (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_SSR_MANIFEST__) || null;\n const tags = [];\n const seen = new Set();\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\" href=\"/' + entry + '\" />');\n tags.push('<script type=\"module\" 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 = m[id];\n if (!files) {\n // Absolute path didn't match — try matching by suffix.\n // Manifest keys are relative (e.g. \"pages/about.tsx\") while\n // moduleIds may be absolute (e.g. \"/home/.../pages/about.tsx\").\n for (var mk in m) {\n if (id.endsWith(\"/\" + mk) || id === mk) {\n files = m[mk];\n break;\n }\n }\n }\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\" 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\" href=\"/' + tf + '\" />');\n tags.push('<script type=\"module\" src=\"/' + tf + '\" crossorigin></script>');\n }\n }\n }\n return tags.join(\"\\\\n \");\n}\n\n// i18n helpers\nfunction extractLocale(url) {\n if (!i18nConfig) return { locale: undefined, url, hadPrefix: false };\n const pathname = url.split(\"?\")[0];\n const parts = pathname.split(\"/\").filter(Boolean);\n const query = url.includes(\"?\") ? url.slice(url.indexOf(\"?\")) : \"\";\n if (parts.length > 0 && i18nConfig.locales.includes(parts[0])) {\n const locale = parts[0];\n const rest = \"/\" + parts.slice(1).join(\"/\");\n return { locale, url: (rest || \"/\") + query, hadPrefix: true };\n }\n return { locale: i18nConfig.defaultLocale, url, hadPrefix: false };\n}\n\nfunction detectLocaleFromHeaders(headers) {\n if (!i18nConfig) return null;\n const acceptLang = headers.get(\"accept-language\");\n if (!acceptLang) return null;\n const langs = acceptLang.split(\",\").map(function(part) {\n const pieces = part.trim().split(\";\");\n const q = pieces[1] ? parseFloat(pieces[1].replace(\"q=\", \"\")) : 1;\n return { lang: pieces[0].trim().toLowerCase(), q: q };\n }).sort(function(a, b) { return b.q - a.q; });\n for (let k = 0; k < langs.length; k++) {\n const lang = langs[k].lang;\n for (let j = 0; j < i18nConfig.locales.length; j++) {\n if (i18nConfig.locales[j].toLowerCase() === lang) return i18nConfig.locales[j];\n }\n const prefix = lang.split(\"-\")[0];\n for (let j = 0; j < i18nConfig.locales.length; j++) {\n const loc = i18nConfig.locales[j].toLowerCase();\n if (loc === prefix || loc.startsWith(prefix + \"-\")) return i18nConfig.locales[j];\n }\n }\n return null;\n}\n\nfunction parseCookieLocaleFromHeader(cookieHeader) {\n if (!i18nConfig || !cookieHeader) return null;\n const match = cookieHeader.match(/(?:^|;\\\\s*)NEXT_LOCALE=([^;]*)/);\n if (!match) return null;\n var value;\n try { value = decodeURIComponent(match[1].trim()); } catch (e) { return null; }\n if (i18nConfig.locales.indexOf(value) !== -1) return value;\n return null;\n}\n\n// Lightweight req/res facade for getServerSideProps and API routes.\n// Next.js pages expect ctx.req/ctx.res with Node-like shapes.\nfunction createReqRes(request, url, query, body) {\n const headersObj = {};\n for (const [k, v] of request.headers) headersObj[k.toLowerCase()] = v;\n\n const req = {\n method: request.method,\n url: url,\n headers: headersObj,\n query: query,\n body: body,\n cookies: parseCookies(request.headers.get(\"cookie\")),\n };\n\n let resStatusCode = 200;\n const resHeaders = {};\n // set-cookie needs array support (multiple Set-Cookie headers are common)\n const setCookieHeaders = [];\n let resBody = null;\n let ended = false;\n let resolveResponse;\n const responsePromise = new Promise(function(r) { resolveResponse = r; });\n\n const res = {\n get statusCode() { return resStatusCode; },\n set statusCode(code) { resStatusCode = code; },\n writeHead: function(code, headers) {\n resStatusCode = code;\n if (headers) {\n for (const [k, v] of Object.entries(headers)) {\n if (k.toLowerCase() === \"set-cookie\") {\n if (Array.isArray(v)) { for (const c of v) setCookieHeaders.push(c); }\n else { setCookieHeaders.push(v); }\n } else {\n resHeaders[k] = v;\n }\n }\n }\n return res;\n },\n setHeader: function(name, value) {\n if (name.toLowerCase() === \"set-cookie\") {\n if (Array.isArray(value)) { for (const c of value) setCookieHeaders.push(c); }\n else { setCookieHeaders.push(value); }\n } else {\n resHeaders[name.toLowerCase()] = value;\n }\n return res;\n },\n getHeader: function(name) {\n if (name.toLowerCase() === \"set-cookie\") return setCookieHeaders.length > 0 ? setCookieHeaders : undefined;\n return resHeaders[name.toLowerCase()];\n },\n end: function(data) {\n if (ended) return;\n ended = true;\n if (data !== undefined && data !== null) resBody = data;\n const h = new Headers(resHeaders);\n for (const c of setCookieHeaders) h.append(\"set-cookie\", c);\n resolveResponse(new Response(resBody, { status: resStatusCode, headers: h }));\n },\n status: function(code) { resStatusCode = code; return res; },\n json: function(data) {\n resHeaders[\"content-type\"] = \"application/json\";\n res.end(JSON.stringify(data));\n },\n send: function(data) {\n if (Buffer.isBuffer(data)) {\n if (!resHeaders[\"content-type\"]) resHeaders[\"content-type\"] = \"application/octet-stream\";\n resHeaders[\"content-length\"] = String(data.length);\n res.end(data);\n } else if (typeof data === \"object\" && data !== null) {\n res.json(data);\n } else {\n if (!resHeaders[\"content-type\"]) resHeaders[\"content-type\"] = \"text/plain\";\n res.end(String(data));\n }\n },\n redirect: function(statusOrUrl, url2) {\n if (typeof statusOrUrl === \"string\") { res.writeHead(307, { Location: statusOrUrl }); }\n else { res.writeHead(statusOrUrl, { Location: url2 }); }\n res.end();\n },\n getHeaders: function() {\n var h = Object.assign({}, resHeaders);\n if (setCookieHeaders.length > 0) h[\"set-cookie\"] = setCookieHeaders;\n return h;\n },\n get headersSent() { return ended; },\n };\n\n return { req, res, responsePromise };\n}\n\n/**\n * Read request body as text with a size limit.\n * Throws if the body exceeds maxBytes. This prevents DoS via chunked\n * transfer encoding where Content-Length is absent or spoofed.\n */\nasync function readBodyWithLimit(request, maxBytes) {\n if (!request.body) return \"\";\n var reader = request.body.getReader();\n var decoder = new TextDecoder();\n var chunks = [];\n var totalSize = 0;\n for (;;) {\n var result = await reader.read();\n if (result.done) break;\n totalSize += result.value.byteLength;\n if (totalSize > maxBytes) {\n reader.cancel();\n throw new Error(\"Request body too large\");\n }\n chunks.push(decoder.decode(result.value, { stream: true }));\n }\n chunks.push(decoder.decode());\n return chunks.join(\"\");\n}\n\nexport async function renderPage(request, url, manifest, ctx) {\n if (ctx) return _runWithExecutionContext(ctx, () => _renderPage(request, url, manifest));\n return _renderPage(request, url, manifest);\n}\n\nasync function _renderPage(request, url, manifest) {\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 const match = matchRoute(routeUrl, pageRoutes);\n if (!match) {\n return new Response(\"<!DOCTYPE html><html><body><h1>404 - Page not found</h1></body></html>\",\n { status: 404, headers: { \"Content-Type\": \"text/html\" } });\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 if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: patternToNextFormat(route.pattern),\n query: { ...params, ...parseQuery(routeUrl) },\n asPath: 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 // Handle getStaticPaths for dynamic routes\n if (typeof pageModule.getStaticPaths === \"function\" && route.isDynamic) {\n const pathsResult = await pageModule.getStaticPaths({\n locales: i18nConfig ? i18nConfig.locales : [],\n defaultLocale: currentDefaultLocale || \"\",\n });\n const fallback = pathsResult && pathsResult.fallback !== undefined ? pathsResult.fallback : false;\n\n if (fallback === false) {\n const paths = pathsResult && pathsResult.paths ? pathsResult.paths : [];\n const isValidPath = paths.some(function(p) {\n return Object.entries(p.params).every(function(entry) {\n var key = entry[0], val = entry[1];\n var actual = params[key];\n if (Array.isArray(val)) {\n return Array.isArray(actual) && val.join(\"/\") === actual.join(\"/\");\n }\n return String(val) === String(actual);\n });\n });\n if (!isValidPath) {\n return new Response(\"<!DOCTYPE html><html><body><h1>404 - Page not found</h1></body></html>\",\n { status: 404, headers: { \"Content-Type\": \"text/html\" } });\n }\n }\n }\n\n let pageProps = {};\n var gsspRes = null;\n if (typeof pageModule.getServerSideProps === \"function\") {\n const { req, res, responsePromise } = createReqRes(request, routeUrl, parseQuery(routeUrl), undefined);\n const ctx = {\n params, req, res,\n query: parseQuery(routeUrl),\n resolvedUrl: routeUrl,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n };\n const result = await pageModule.getServerSideProps(ctx);\n // If gSSP called res.end() directly (short-circuit), return that response.\n if (res.headersSent) {\n return await responsePromise;\n }\n if (result && result.props) pageProps = result.props;\n if (result && result.redirect) {\n var gsspStatus = result.redirect.statusCode != null ? result.redirect.statusCode : (result.redirect.permanent ? 308 : 307);\n return new Response(null, { status: gsspStatus, headers: { Location: sanitizeDestinationLocal(result.redirect.destination) } });\n }\n if (result && result.notFound) {\n return new Response(\"404\", { status: 404 });\n }\n // Preserve the res object so headers/status/cookies set by gSSP\n // can be merged into the final HTML response.\n gsspRes = res;\n }\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\n let isrRevalidateSeconds = null;\n if (typeof pageModule.getStaticProps === \"function\") {\n const pathname = routeUrl.split(\"?\")[0];\n const cacheKey = isrCacheKey(\"pages\", pathname);\n const cached = await isrGet(cacheKey);\n\n if (cached && !cached.isStale && cached.value.value && cached.value.value.kind === \"PAGES\") {\n var _hitHeaders = {\n \"Content-Type\": \"text/html\", \"X-Vinext-Cache\": \"HIT\",\n \"Cache-Control\": \"s-maxage=\" + (cached.value.value.revalidate || 60) + \", stale-while-revalidate\",\n };\n if (_fontLinkHeader) _hitHeaders[\"Link\"] = _fontLinkHeader;\n return new Response(cached.value.value.html, { status: 200, headers: _hitHeaders });\n }\n\n if (cached && cached.isStale && cached.value.value && cached.value.value.kind === \"PAGES\") {\n triggerBackgroundRegeneration(cacheKey, async function() {\n var revalCtx = _createUnifiedCtx({\n executionContext: _getRequestExecutionContext(),\n });\n return _runWithUnifiedCtx(revalCtx, async () => {\n ensureFetchPatch();\n var freshResult = await pageModule.getStaticProps({\n params: params,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n });\n if (freshResult && freshResult.props && typeof freshResult.revalidate === \"number\" && freshResult.revalidate > 0) {\n var _fp = freshResult.props;\n if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: patternToNextFormat(route.pattern),\n query: { ...params, ...parseQuery(routeUrl) },\n asPath: 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 // Re-render the page with fresh props inside fresh render sub-scopes\n // so head/cache state cannot leak across passes.\n var _el = AppComponent\n ? React.createElement(AppComponent, { Component: PageComponent, pageProps: _fp })\n : React.createElement(PageComponent, _fp);\n _el = wrapWithRouterContext(_el);\n var _freshBody = await renderIsrPassToStringAsync(_el);\n // Rebuild __NEXT_DATA__ with fresh props\n var _regenPayload = {\n props: { pageProps: _fp }, page: patternToNextFormat(route.pattern),\n query: params, buildId: buildId, isFallback: false,\n };\n if (i18nConfig) {\n _regenPayload.locale = locale;\n _regenPayload.locales = i18nConfig.locales;\n _regenPayload.defaultLocale = currentDefaultLocale;\n _regenPayload.domainLocales = domainLocales;\n }\n var _lGlobals = i18nConfig\n ? \";window.__VINEXT_LOCALE__=\" + safeJsonStringify(locale) +\n \";window.__VINEXT_LOCALES__=\" + safeJsonStringify(i18nConfig.locales) +\n \";window.__VINEXT_DEFAULT_LOCALE__=\" + safeJsonStringify(currentDefaultLocale)\n : \"\";\n var _freshNDS = \"<script>window.__NEXT_DATA__ = \" + safeJsonStringify(_regenPayload) + _lGlobals + \"</script>\";\n // Reconstruct ISR HTML preserving the document shell from the\n // cached entry (head, fonts, assets, custom _document markup).\n var _cachedStr = cached.value.value.html;\n var _btag = '<div id=\"__next\">';\n var _bstart = _cachedStr.indexOf(_btag);\n var _bodyStart = _bstart >= 0 ? _bstart + _btag.length : -1;\n // Locate __NEXT_DATA__ script to split body from suffix\n var _ndMarker = '<script>window.__NEXT_DATA__';\n var _ndStart = _cachedStr.indexOf(_ndMarker);\n var _freshHtml;\n if (_bodyStart >= 0 && _ndStart >= 0) {\n // Region between body start and __NEXT_DATA__ contains:\n // BODY_HTML + </div> + optional gap (custom _document content)\n var _region = _cachedStr.slice(_bodyStart, _ndStart);\n var _lastClose = _region.lastIndexOf('</div>');\n var _gap = _lastClose >= 0 ? _region.slice(_lastClose + 6) : '';\n // Tail: everything after the old __NEXT_DATA__ </script>\n var _ndEnd = _cachedStr.indexOf('</script>', _ndStart) + 9;\n var _tail = _cachedStr.slice(_ndEnd);\n _freshHtml = _cachedStr.slice(0, _bodyStart) + _freshBody + '</div>' + _gap + _freshNDS + _tail;\n } else {\n _freshHtml = '<!DOCTYPE html>\\\\n<html>\\\\n<head>\\\\n</head>\\\\n<body>\\\\n <div id=\"__next\">' + _freshBody + '</div>\\\\n ' + _freshNDS + '\\\\n</body>\\\\n</html>';\n }\n await isrSet(cacheKey, { kind: \"PAGES\", html: _freshHtml, pageData: _fp, headers: undefined, status: undefined }, freshResult.revalidate);\n }\n });\n });\n var _staleHeaders = {\n \"Content-Type\": \"text/html\", \"X-Vinext-Cache\": \"STALE\",\n \"Cache-Control\": \"s-maxage=0, stale-while-revalidate\",\n };\n if (_fontLinkHeader) _staleHeaders[\"Link\"] = _fontLinkHeader;\n return new Response(cached.value.value.html, { status: 200, headers: _staleHeaders });\n }\n\n const ctx = {\n params,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n };\n const result = await pageModule.getStaticProps(ctx);\n if (result && result.props) pageProps = result.props;\n if (result && result.redirect) {\n var gspStatus = result.redirect.statusCode != null ? result.redirect.statusCode : (result.redirect.permanent ? 308 : 307);\n return new Response(null, { status: gspStatus, headers: { Location: sanitizeDestinationLocal(result.redirect.destination) } });\n }\n if (result && result.notFound) {\n return new Response(\"404\", { status: 404 });\n }\n if (typeof result.revalidate === \"number\" && result.revalidate > 0) {\n isrRevalidateSeconds = result.revalidate;\n }\n }\n\n const pageModuleIds = route.filePath ? [route.filePath] : [];\n const assetTags = collectAssetTags(manifest, pageModuleIds);\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 isrRevalidateSeconds,\n isrSet,\n i18n: {\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n },\n pageProps,\n params,\n renderDocumentToString(element) {\n return renderToStringAsync(element);\n },\n renderIsrPassToStringAsync,\n renderToReadableStream(element) {\n return renderToReadableStream(element);\n },\n resetSSRHead: typeof resetSSRHead === \"function\" ? resetSSRHead : undefined,\n routePattern: patternToNextFormat(route.pattern),\n routeUrl,\n safeJsonStringify,\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) {\n const match = matchRoute(url, apiRoutes);\n if (!match) {\n return new Response(\"404 - API route not found\", { status: 404 });\n }\n\n const { route, params } = match;\n const handler = route.module.default;\n if (typeof handler !== \"function\") {\n return new Response(\"API route does not export a default function\", { status: 500 });\n }\n\n const query = { ...params };\n const qs = url.split(\"?\")[1];\n if (qs) {\n for (const [k, v] of new URLSearchParams(qs)) {\n if (k in query) {\n // Multi-value: promote to array (Next.js returns string[] for duplicate keys)\n query[k] = Array.isArray(query[k]) ? query[k].concat(v) : [query[k], v];\n } else {\n query[k] = v;\n }\n }\n }\n\n // Parse request body (enforce 1MB limit to prevent memory exhaustion,\n // matching Next.js default bodyParser sizeLimit).\n // Check Content-Length first as a fast path, then enforce on the actual\n // stream to prevent bypasses via chunked transfer encoding.\n const contentLength = parseInt(request.headers.get(\"content-length\") || \"0\", 10);\n if (contentLength > 1 * 1024 * 1024) {\n return new Response(\"Request body too large\", { status: 413 });\n }\n try {\n let body;\n const mediaType = getMediaType(request.headers.get(\"content-type\"));\n let rawBody;\n try { rawBody = await readBodyWithLimit(request, 1 * 1024 * 1024); }\n catch { return new Response(\"Request body too large\", { status: 413 }); }\n if (!rawBody) {\n body = isJsonMediaType(mediaType)\n ? {}\n : mediaType === \"application/x-www-form-urlencoded\"\n ? decodeQueryString(rawBody)\n : undefined;\n } else if (isJsonMediaType(mediaType)) {\n try { body = JSON.parse(rawBody); }\n catch { throw new ApiBodyParseError(\"Invalid JSON\", 400); }\n } else if (mediaType === \"application/x-www-form-urlencoded\") {\n body = decodeQueryString(rawBody);\n } else {\n body = rawBody;\n }\n\n const { req, res, responsePromise } = createReqRes(request, url, query, body);\n await handler(req, res);\n // If handler didn't call res.end(), end it now.\n // The end() method is idempotent — safe to call twice.\n res.end();\n return await responsePromise;\n } catch (e) {\n if (e instanceof ApiBodyParseError) {\n return new Response(e.message, { status: e.statusCode, statusText: e.message });\n }\n console.error(\"[vinext] API 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: \"route\" },\n );\n return new Response(\"Internal Server Error\", { status: 500 });\n }\n}\n\n${middlewareExportCode}\n`;\n}\n"],"mappings":"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"}
|
|
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 path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\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 {\n generateSafeRegExpCode,\n generateMiddlewareMatcherCode,\n generateNormalizePathCode,\n generateRouteMatchNormalizationCode,\n} from \"../server/middleware-codegen.js\";\nimport { findFileWithExts } from \"./pages-entry-helpers.js\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst _requestContextShimPath = fileURLToPath(\n new URL(\"../shims/request-context.js\", import.meta.url),\n).replace(/\\\\/g, \"/\");\nconst _routeTriePath = fileURLToPath(new URL(\"../routing/route-trie.js\", import.meta.url)).replace(\n /\\\\/g,\n \"/\",\n);\nconst _pagesI18nPath = fileURLToPath(new URL(\"../server/pages-i18n.js\", import.meta.url)).replace(\n /\\\\/g,\n \"/\",\n);\nconst _pagesPageResponsePath = fileURLToPath(\n new URL(\"../server/pages-page-response.js\", import.meta.url),\n).replace(/\\\\/g, \"/\");\nconst _pagesPageDataPath = fileURLToPath(\n new URL(\"../server/pages-page-data.js\", import.meta.url),\n).replace(/\\\\/g, \"/\");\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 = r.filePath.replace(/\\\\/g, \"/\");\n return `import * as page_${i} from ${JSON.stringify(absPath)};`;\n });\n\n const apiImports = apiRoutes.map((r: Route, i: number) => {\n const absPath = r.filePath.replace(/\\\\/g, \"/\");\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 = r.filePath.replace(/\\\\/g, \"/\");\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((r: Route, i: number) => {\n return ` { 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 and _document\n const appFilePath = findFileWithExts(pagesDir, \"_app\", fileMatcher);\n const docFilePath = findFileWithExts(pagesDir, \"_document\", fileMatcher);\n const appImportCode =\n appFilePath !== null\n ? `import { default as AppComponent } from ${JSON.stringify(appFilePath.replace(/\\\\/g, \"/\"))};`\n : `const AppComponent = null;`;\n\n const docImportCode =\n docFilePath !== null\n ? `import { default as DocumentComponent } from ${JSON.stringify(docFilePath.replace(/\\\\/g, \"/\"))};`\n : `const DocumentComponent = 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 trailingSlash: nextConfig?.trailingSlash ?? false,\n redirects: nextConfig?.redirects ?? [],\n rewrites: nextConfig?.rewrites ?? { beforeFiles: [], afterFiles: [], fallback: [] },\n headers: nextConfig?.headers ?? [],\n i18n: nextConfig?.i18n ?? null,\n images: {\n deviceSizes: nextConfig?.images?.deviceSizes,\n imageSizes: nextConfig?.images?.imageSizes,\n dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,\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(instrumentationPath.replace(/\\\\/g, \"/\"))};`\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(middlewarePath.replace(/\\\\/g, \"/\"))};\nimport { NextRequest, NextFetchEvent } from \"next/server\";`\n : \"\";\n\n // The matcher config is read from the middleware module at import time.\n // We inline the matching + execution logic so the prod server can call it.\n const middlewareExportCode = middlewarePath\n ? `\n// --- Middleware support (generated from middleware-codegen.ts) ---\n${generateNormalizePathCode(\"es5\")}\n${generateRouteMatchNormalizationCode(\"es5\")}\n${generateSafeRegExpCode(\"es5\")}\n${generateMiddlewareMatcherCode(\"es5\")}\n\nexport async function runMiddleware(request, ctx) {\n if (ctx) return _runWithExecutionContext(ctx, () => _runMiddleware(request));\n return _runMiddleware(request);\n}\n\nasync function _runMiddleware(request) {\n var isProxy = ${middlewarePath ? JSON.stringify(isProxyFile(middlewarePath)) : \"false\"};\n var middlewareFn = isProxy\n ? (middlewareModule.proxy ?? middlewareModule.default)\n : (middlewareModule.middleware ?? middlewareModule.default);\n if (typeof middlewareFn !== \"function\") {\n var fileType = isProxy ? \"Proxy\" : \"Middleware\";\n var expectedExport = isProxy ? \"proxy\" : \"middleware\";\n throw new Error(\"The \" + fileType + \" file must export a function named \\`\" + expectedExport + \"\\` or a \\`default\\` function.\");\n }\n\n var config = middlewareModule.config;\n var matcher = config && config.matcher;\n var url = new URL(request.url);\n\n // Normalize pathname before matching to prevent path-confusion bypasses\n // (percent-encoding like /%61dmin, double slashes like /dashboard//settings).\n var decodedPathname;\n try { decodedPathname = __normalizePathnameForRouteMatchStrict(url.pathname); } catch (e) {\n return { continue: false, response: new Response(\"Bad Request\", { status: 400 }) };\n }\n var normalizedPathname = __normalizePath(decodedPathname);\n\n if (!matchesMiddleware(normalizedPathname, matcher, request, i18nConfig)) return { continue: true };\n\n // Construct a new Request with the decoded + normalized pathname so middleware\n // always sees the same canonical path that the router uses.\n var mwRequest = request;\n if (normalizedPathname !== url.pathname) {\n var mwUrl = new URL(url);\n mwUrl.pathname = normalizedPathname;\n mwRequest = new Request(mwUrl, request);\n }\n var __mwNextConfig = (vinextConfig.basePath || i18nConfig) ? { basePath: vinextConfig.basePath, i18n: i18nConfig || undefined } : undefined;\n var nextRequest = mwRequest instanceof NextRequest ? mwRequest : new NextRequest(mwRequest, __mwNextConfig ? { nextConfig: __mwNextConfig } : undefined);\n var fetchEvent = new NextFetchEvent({ page: normalizedPathname });\n var response;\n try { response = await middlewareFn(nextRequest, fetchEvent); }\n catch (e) {\n console.error(\"[vinext] Middleware error:\", e);\n return { continue: false, response: new Response(\"Internal Server Error\", { status: 500 }) };\n }\n var _mwCtx = _getRequestExecutionContext();\n if (_mwCtx && typeof _mwCtx.waitUntil === \"function\") { _mwCtx.waitUntil(fetchEvent.drainWaitUntil()); } else { fetchEvent.drainWaitUntil(); }\n\n if (!response) return { continue: true };\n\n if (response.headers.get(\"x-middleware-next\") === \"1\") {\n var rHeaders = new Headers();\n for (var [key, value] of response.headers) {\n // Keep x-middleware-request-* headers so the production server can\n // apply middleware-request header overrides before stripping internals\n // from the final client response.\n if (\n !key.startsWith(\"x-middleware-\") ||\n key === \"x-middleware-override-headers\" ||\n key.startsWith(\"x-middleware-request-\")\n ) rHeaders.append(key, value);\n }\n return { continue: true, responseHeaders: rHeaders };\n }\n\n if (response.status >= 300 && response.status < 400) {\n var location = response.headers.get(\"Location\") || response.headers.get(\"location\");\n if (location) {\n var rdHeaders = new Headers();\n for (var [rk, rv] of response.headers) {\n if (!rk.startsWith(\"x-middleware-\") && rk.toLowerCase() !== \"location\") rdHeaders.append(rk, rv);\n }\n return { continue: false, redirectUrl: location, redirectStatus: response.status, responseHeaders: rdHeaders };\n }\n }\n\n var rewriteUrl = response.headers.get(\"x-middleware-rewrite\");\n if (rewriteUrl) {\n var rwHeaders = new Headers();\n for (var [k, v] of response.headers) {\n if (!k.startsWith(\"x-middleware-\") || k === \"x-middleware-override-headers\" || k.startsWith(\"x-middleware-request-\")) rwHeaders.append(k, v);\n }\n var rewritePath;\n try { var parsed = new URL(rewriteUrl, request.url); rewritePath = parsed.pathname + parsed.search; }\n catch { rewritePath = rewriteUrl; }\n return { continue: true, rewriteUrl: rewritePath, rewriteStatus: response.status !== 200 ? response.status : undefined, responseHeaders: rwHeaders };\n }\n\n return { continue: false, response: response };\n}\n`\n : `\nexport async function runMiddleware() { return { continue: true }; }\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 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 { getCacheHandler, _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 { safeJsonStringify } from \"vinext/html\";\nimport { decode as decodeQueryString } from \"node:querystring\";\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 { parseCookies, sanitizeDestination as sanitizeDestinationLocal } from ${JSON.stringify(path.resolve(__dirname, \"../config/config-matchers.js\").replace(/\\\\/g, \"/\"))};\nimport { runWithExecutionContext as _runWithExecutionContext, getRequestExecutionContext as _getRequestExecutionContext } from ${JSON.stringify(_requestContextShimPath)};\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 { resolvePagesPageData as __resolvePagesPageData } from ${JSON.stringify(_pagesPageDataPath)};\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)\nconst buildId = ${buildIdJson};\n\n// Full resolved config for production server (embedded at build time)\nexport const vinextConfig = ${vinextConfigJson};\n\nclass ApiBodyParseError extends Error {\n constructor(message, statusCode) {\n super(message);\n this.statusCode = statusCode;\n this.name = \"ApiBodyParseError\";\n }\n}\n\n// ISR cache helpers (inlined for the server entry)\nasync function isrGet(key) {\n const handler = getCacheHandler();\n const result = await handler.get(key);\n if (!result || !result.value) return null;\n return { value: result, isStale: result.cacheState === \"stale\" };\n}\nasync function isrSet(key, data, revalidateSeconds, tags) {\n const handler = getCacheHandler();\n await handler.set(key, data, { revalidate: revalidateSeconds, tags: tags || [] });\n}\nconst pendingRegenerations = new Map();\nfunction triggerBackgroundRegeneration(key, renderFn) {\n if (pendingRegenerations.has(key)) return;\n const promise = renderFn()\n .catch((err) => console.error(\"[vinext] ISR regen failed for \" + key + \":\", err))\n .finally(() => pendingRegenerations.delete(key));\n pendingRegenerations.set(key, promise);\n // Register with the Workers ExecutionContext so the isolate is kept alive\n // until the regeneration finishes, even after the Response has been sent.\n const ctx = _getRequestExecutionContext();\n if (ctx && typeof ctx.waitUntil === \"function\") ctx.waitUntil(promise);\n}\n\nfunction fnv1a64(input) {\n let h1 = 0x811c9dc5;\n for (let i = 0; i < input.length; i++) {\n h1 ^= input.charCodeAt(i);\n h1 = (h1 * 0x01000193) >>> 0;\n }\n let h2 = 0x050c5d1f;\n for (let i = 0; i < input.length; i++) {\n h2 ^= input.charCodeAt(i);\n h2 = (h2 * 0x01000193) >>> 0;\n }\n return h1.toString(36) + h2.toString(36);\n}\n// Keep prefix construction and hashing logic in sync with isrCacheKey() in server/isr-cache.ts.\n// buildId is a top-level const in the generated entry (see \"const buildId = ...\" above).\nfunction isrCacheKey(router, pathname) {\n const normalized = pathname === \"/\" ? \"/\" : pathname.replace(/\\\\/$/, \"\");\n const prefix = buildId ? router + \":\" + buildId : router;\n const key = prefix + \":\" + normalized;\n if (key.length <= 200) return key;\n return prefix + \":__hash:\" + fnv1a64(normalized);\n}\n\nfunction getMediaType(contentType) {\n var type = (contentType || \"text/plain\").split(\";\")[0];\n type = type && type.trim().toLowerCase();\n return type || \"text/plain\";\n}\n\nfunction isJsonMediaType(mediaType) {\n return mediaType === \"application/json\" || mediaType === \"application/ld+json\";\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\nexport const pageRoutes = [\n${pageRouteEntries.join(\",\\n\")}\n];\nconst _pageRouteTrie = _buildRouteTrie(pageRoutes);\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\nfunction parseQuery(url) {\n const qs = url.split(\"?\")[1];\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 patternToNextFormat(pattern) {\n return pattern\n .replace(/:([\\\\w]+)\\\\*/g, \"[[...$1]]\")\n .replace(/:([\\\\w]+)\\\\+/g, \"[...$1]\")\n .replace(/:([\\\\w]+)/g, \"[$1]\");\n}\n\nfunction collectAssetTags(manifest, moduleIds) {\n // Fall back to embedded manifest (set by vinext:cloudflare-build for Workers)\n const m = (manifest && Object.keys(manifest).length > 0)\n ? manifest\n : (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_SSR_MANIFEST__) || null;\n const tags = [];\n const seen = new Set();\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\" href=\"/' + entry + '\" />');\n tags.push('<script type=\"module\" 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 = m[id];\n if (!files) {\n // Absolute path didn't match — try matching by suffix.\n // Manifest keys are relative (e.g. \"pages/about.tsx\") while\n // moduleIds may be absolute (e.g. \"/home/.../pages/about.tsx\").\n for (var mk in m) {\n if (id.endsWith(\"/\" + mk) || id === mk) {\n files = m[mk];\n break;\n }\n }\n }\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\" 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\" href=\"/' + tf + '\" />');\n tags.push('<script type=\"module\" src=\"/' + tf + '\" crossorigin></script>');\n }\n }\n }\n return tags.join(\"\\\\n \");\n}\n\n// i18n helpers\nfunction extractLocale(url) {\n if (!i18nConfig) return { locale: undefined, url, hadPrefix: false };\n const pathname = url.split(\"?\")[0];\n const parts = pathname.split(\"/\").filter(Boolean);\n const query = url.includes(\"?\") ? url.slice(url.indexOf(\"?\")) : \"\";\n if (parts.length > 0 && i18nConfig.locales.includes(parts[0])) {\n const locale = parts[0];\n const rest = \"/\" + parts.slice(1).join(\"/\");\n return { locale, url: (rest || \"/\") + query, hadPrefix: true };\n }\n return { locale: i18nConfig.defaultLocale, url, hadPrefix: false };\n}\n\nfunction detectLocaleFromHeaders(headers) {\n if (!i18nConfig) return null;\n const acceptLang = headers.get(\"accept-language\");\n if (!acceptLang) return null;\n const langs = acceptLang.split(\",\").map(function(part) {\n const pieces = part.trim().split(\";\");\n const q = pieces[1] ? parseFloat(pieces[1].replace(\"q=\", \"\")) : 1;\n return { lang: pieces[0].trim().toLowerCase(), q: q };\n }).sort(function(a, b) { return b.q - a.q; });\n for (let k = 0; k < langs.length; k++) {\n const lang = langs[k].lang;\n for (let j = 0; j < i18nConfig.locales.length; j++) {\n if (i18nConfig.locales[j].toLowerCase() === lang) return i18nConfig.locales[j];\n }\n const prefix = lang.split(\"-\")[0];\n for (let j = 0; j < i18nConfig.locales.length; j++) {\n const loc = i18nConfig.locales[j].toLowerCase();\n if (loc === prefix || loc.startsWith(prefix + \"-\")) return i18nConfig.locales[j];\n }\n }\n return null;\n}\n\nfunction parseCookieLocaleFromHeader(cookieHeader) {\n if (!i18nConfig || !cookieHeader) return null;\n const match = cookieHeader.match(/(?:^|;\\\\s*)NEXT_LOCALE=([^;]*)/);\n if (!match) return null;\n var value;\n try { value = decodeURIComponent(match[1].trim()); } catch (e) { return null; }\n if (i18nConfig.locales.indexOf(value) !== -1) return value;\n return null;\n}\n\n// Lightweight req/res facade for getServerSideProps and API routes.\n// Next.js pages expect ctx.req/ctx.res with Node-like shapes.\nfunction createReqRes(request, url, query, body) {\n const headersObj = {};\n for (const [k, v] of request.headers) headersObj[k.toLowerCase()] = v;\n\n const req = {\n method: request.method,\n url: url,\n headers: headersObj,\n query: query,\n body: body,\n cookies: parseCookies(request.headers.get(\"cookie\")),\n };\n\n let resStatusCode = 200;\n const resHeaders = {};\n // set-cookie needs array support (multiple Set-Cookie headers are common)\n const setCookieHeaders = [];\n let resBody = null;\n let ended = false;\n let resolveResponse;\n const responsePromise = new Promise(function(r) { resolveResponse = r; });\n\n const res = {\n get statusCode() { return resStatusCode; },\n set statusCode(code) { resStatusCode = code; },\n writeHead: function(code, headers) {\n resStatusCode = code;\n if (headers) {\n for (const [k, v] of Object.entries(headers)) {\n if (k.toLowerCase() === \"set-cookie\") {\n if (Array.isArray(v)) { for (const c of v) setCookieHeaders.push(c); }\n else { setCookieHeaders.push(v); }\n } else {\n resHeaders[k] = v;\n }\n }\n }\n return res;\n },\n setHeader: function(name, value) {\n if (name.toLowerCase() === \"set-cookie\") {\n if (Array.isArray(value)) { for (const c of value) setCookieHeaders.push(c); }\n else { setCookieHeaders.push(value); }\n } else {\n resHeaders[name.toLowerCase()] = value;\n }\n return res;\n },\n getHeader: function(name) {\n if (name.toLowerCase() === \"set-cookie\") return setCookieHeaders.length > 0 ? setCookieHeaders : undefined;\n return resHeaders[name.toLowerCase()];\n },\n end: function(data) {\n if (ended) return;\n ended = true;\n if (data !== undefined && data !== null) resBody = data;\n const h = new Headers(resHeaders);\n for (const c of setCookieHeaders) h.append(\"set-cookie\", c);\n resolveResponse(new Response(resBody, { status: resStatusCode, headers: h }));\n },\n status: function(code) { resStatusCode = code; return res; },\n json: function(data) {\n resHeaders[\"content-type\"] = \"application/json\";\n res.end(JSON.stringify(data));\n },\n send: function(data) {\n if (Buffer.isBuffer(data)) {\n if (!resHeaders[\"content-type\"]) resHeaders[\"content-type\"] = \"application/octet-stream\";\n resHeaders[\"content-length\"] = String(data.length);\n res.end(data);\n } else if (typeof data === \"object\" && data !== null) {\n res.json(data);\n } else {\n if (!resHeaders[\"content-type\"]) resHeaders[\"content-type\"] = \"text/plain\";\n res.end(String(data));\n }\n },\n redirect: function(statusOrUrl, url2) {\n if (typeof statusOrUrl === \"string\") { res.writeHead(307, { Location: statusOrUrl }); }\n else { res.writeHead(statusOrUrl, { Location: url2 }); }\n res.end();\n },\n getHeaders: function() {\n var h = Object.assign({}, resHeaders);\n if (setCookieHeaders.length > 0) h[\"set-cookie\"] = setCookieHeaders;\n return h;\n },\n get headersSent() { return ended; },\n };\n\n return { req, res, responsePromise };\n}\n\n/**\n * Read request body as text with a size limit.\n * Throws if the body exceeds maxBytes. This prevents DoS via chunked\n * transfer encoding where Content-Length is absent or spoofed.\n */\nasync function readBodyWithLimit(request, maxBytes) {\n if (!request.body) return \"\";\n var reader = request.body.getReader();\n var decoder = new TextDecoder();\n var chunks = [];\n var totalSize = 0;\n for (;;) {\n var result = await reader.read();\n if (result.done) break;\n totalSize += result.value.byteLength;\n if (totalSize > maxBytes) {\n reader.cancel();\n throw new Error(\"Request body too large\");\n }\n chunks.push(decoder.decode(result.value, { stream: true }));\n }\n chunks.push(decoder.decode());\n return chunks.join(\"\");\n}\n\nexport async function renderPage(request, url, manifest, ctx) {\n if (ctx) return _runWithExecutionContext(ctx, () => _renderPage(request, url, manifest));\n return _renderPage(request, url, manifest);\n}\n\nasync function _renderPage(request, url, manifest) {\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 const match = matchRoute(routeUrl, pageRoutes);\n if (!match) {\n return new Response(\"<!DOCTYPE html><html><body><h1>404 - Page not found</h1></body></html>\",\n { status: 404, headers: { \"Content-Type\": \"text/html\" } });\n }\n\n\t const { route, params } = match;\n\t const __uCtx = _createUnifiedCtx({\n\t executionContext: _getRequestExecutionContext(),\n\t });\n\t return _runWithUnifiedCtx(__uCtx, async () => {\n\t ensureFetchPatch();\n\t try {\n\t const routePattern = patternToNextFormat(route.pattern);\n\t if (typeof setSSRContext === \"function\") {\n\t setSSRContext({\n\t pathname: routePattern,\n\t query: { ...params, ...parseQuery(routeUrl) },\n\t asPath: routeUrl,\n\t 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\t if (!PageComponent) {\n\t return new Response(\"Page has no default export\", { status: 500 });\n\t }\n\t // Build font Link header early so it's available for ISR cached responses too.\n\t // Font preloads are module-level state populated at import time and persist across requests.\n\t var _fontLinkHeader = \"\";\n\t var _allFp = [];\n try {\n var _fpGoogle = typeof _getSSRFontPreloadsGoogle === \"function\" ? _getSSRFontPreloadsGoogle() : [];\n var _fpLocal = typeof _getSSRFontPreloadsLocal === \"function\" ? _getSSRFontPreloadsLocal() : [];\n _allFp = _fpGoogle.concat(_fpLocal);\n\t if (_allFp.length > 0) {\n\t _fontLinkHeader = _allFp.map(function(p) { return \"<\" + p.href + \">; rel=preload; as=font; type=\" + p.type + \"; crossorigin\"; }).join(\", \");\n\t }\n\t } catch (e) { /* font preloads not available */ }\n\t const query = parseQuery(routeUrl);\n\t const pageDataResult = await __resolvePagesPageData({\n\t applyRequestContexts() {\n\t if (typeof setSSRContext === \"function\") {\n\t setSSRContext({\n\t pathname: routePattern,\n\t query: { ...params, ...query },\n\t asPath: routeUrl,\n\t locale: locale,\n\t locales: i18nConfig ? i18nConfig.locales : undefined,\n\t defaultLocale: currentDefaultLocale,\n\t domainLocales: domainLocales,\n\t });\n\t }\n\t if (i18nConfig) {\n\t setI18nContext({\n\t locale: locale,\n\t locales: i18nConfig.locales,\n\t defaultLocale: currentDefaultLocale,\n\t domainLocales: domainLocales,\n\t hostname: new URL(request.url).hostname,\n\t });\n\t }\n\t },\n\t buildId,\n\t createGsspReqRes() {\n\t return createReqRes(request, routeUrl, query, undefined);\n\t },\n\t createPageElement(currentPageProps) {\n\t var currentElement = AppComponent\n\t ? React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps })\n\t : React.createElement(PageComponent, currentPageProps);\n\t return wrapWithRouterContext(currentElement);\n\t },\n\t fontLinkHeader: _fontLinkHeader,\n\t i18n: {\n\t locale: locale,\n\t locales: i18nConfig ? i18nConfig.locales : undefined,\n\t defaultLocale: currentDefaultLocale,\n\t domainLocales: domainLocales,\n\t },\n\t isrCacheKey,\n\t isrGet,\n\t isrSet,\n\t pageModule,\n\t params,\n\t query,\n\t renderIsrPassToStringAsync,\n\t route: {\n\t isDynamic: route.isDynamic,\n\t },\n\t routePattern,\n\t routeUrl,\n\t runInFreshUnifiedContext(callback) {\n\t var revalCtx = _createUnifiedCtx({\n\t executionContext: _getRequestExecutionContext(),\n\t });\n\t return _runWithUnifiedCtx(revalCtx, async () => {\n\t ensureFetchPatch();\n\t return callback();\n\t });\n\t },\n\t safeJsonStringify,\n\t sanitizeDestination: sanitizeDestinationLocal,\n\t triggerBackgroundRegeneration,\n\t });\n\t if (pageDataResult.kind === \"response\") {\n\t return pageDataResult.response;\n\t }\n\t let pageProps = pageDataResult.pageProps;\n\t var gsspRes = pageDataResult.gsspRes;\n\t let isrRevalidateSeconds = pageDataResult.isrRevalidateSeconds;\n\n\t const pageModuleIds = route.filePath ? [route.filePath] : [];\n\t const assetTags = collectAssetTags(manifest, pageModuleIds);\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\t getSSRHeadHTML: typeof getSSRHeadHTML === \"function\" ? getSSRHeadHTML : undefined,\n\t gsspRes,\n isrCacheKey,\n isrRevalidateSeconds,\n isrSet,\n i18n: {\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n },\n pageProps,\n params,\n renderDocumentToString(element) {\n return renderToStringAsync(element);\n },\n renderIsrPassToStringAsync,\n renderToReadableStream(element) {\n return renderToReadableStream(element);\n },\n resetSSRHead: typeof resetSSRHead === \"function\" ? resetSSRHead : undefined,\n\t routePattern,\n routeUrl,\n safeJsonStringify,\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) {\n const match = matchRoute(url, apiRoutes);\n if (!match) {\n return new Response(\"404 - API route not found\", { status: 404 });\n }\n\n const { route, params } = match;\n const handler = route.module.default;\n if (typeof handler !== \"function\") {\n return new Response(\"API route does not export a default function\", { status: 500 });\n }\n\n const query = { ...params };\n const qs = url.split(\"?\")[1];\n if (qs) {\n for (const [k, v] of new URLSearchParams(qs)) {\n if (k in query) {\n // Multi-value: promote to array (Next.js returns string[] for duplicate keys)\n query[k] = Array.isArray(query[k]) ? query[k].concat(v) : [query[k], v];\n } else {\n query[k] = v;\n }\n }\n }\n\n // Parse request body (enforce 1MB limit to prevent memory exhaustion,\n // matching Next.js default bodyParser sizeLimit).\n // Check Content-Length first as a fast path, then enforce on the actual\n // stream to prevent bypasses via chunked transfer encoding.\n const contentLength = parseInt(request.headers.get(\"content-length\") || \"0\", 10);\n if (contentLength > 1 * 1024 * 1024) {\n return new Response(\"Request body too large\", { status: 413 });\n }\n try {\n let body;\n const mediaType = getMediaType(request.headers.get(\"content-type\"));\n let rawBody;\n try { rawBody = await readBodyWithLimit(request, 1 * 1024 * 1024); }\n catch { return new Response(\"Request body too large\", { status: 413 }); }\n if (!rawBody) {\n body = isJsonMediaType(mediaType)\n ? {}\n : mediaType === \"application/x-www-form-urlencoded\"\n ? decodeQueryString(rawBody)\n : undefined;\n } else if (isJsonMediaType(mediaType)) {\n try { body = JSON.parse(rawBody); }\n catch { throw new ApiBodyParseError(\"Invalid JSON\", 400); }\n } else if (mediaType === \"application/x-www-form-urlencoded\") {\n body = decodeQueryString(rawBody);\n } else {\n body = rawBody;\n }\n\n const { req, res, responsePromise } = createReqRes(request, url, query, body);\n await handler(req, res);\n // If handler didn't call res.end(), end it now.\n // The end() method is idempotent — safe to call twice.\n res.end();\n return await responsePromise;\n } catch (e) {\n if (e instanceof ApiBodyParseError) {\n return new Response(e.message, { status: e.statusCode, statusText: e.message });\n }\n console.error(\"[vinext] API 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: \"route\" },\n );\n return new Response(\"Internal Server Error\", { status: 500 });\n }\n}\n\n${middlewareExportCode}\n`;\n}\n"],"mappings":"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"}
|