vinext 0.0.45 → 0.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/prerender.js +10 -3
- package/dist/build/prerender.js.map +1 -1
- package/dist/build/standalone.js +4 -3
- package/dist/build/standalone.js.map +1 -1
- package/dist/check.js +30 -18
- package/dist/check.js.map +1 -1
- package/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -1
- package/dist/cloudflare/kv-cache-handler.js.map +1 -1
- package/dist/config/config-matchers.js +1 -0
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/next-config.d.ts +38 -2
- package/dist/config/next-config.js +24 -0
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.js +18 -23
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-rsc-entry.js +331 -1732
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-rsc-manifest.d.ts +24 -0
- package/dist/entries/app-rsc-manifest.js +153 -0
- package/dist/entries/app-rsc-manifest.js.map +1 -0
- package/dist/entries/pages-server-entry.js +13 -103
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/index.js +54 -34
- package/dist/index.js.map +1 -1
- package/dist/plugins/rsc-client-shim-excludes.d.ts +6 -0
- package/dist/plugins/rsc-client-shim-excludes.js +27 -0
- package/dist/plugins/rsc-client-shim-excludes.js.map +1 -0
- package/dist/routing/app-router.d.ts +14 -5
- package/dist/routing/app-router.js +75 -1
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/route-pattern.d.ts +9 -0
- package/dist/routing/route-pattern.js +90 -0
- package/dist/routing/route-pattern.js.map +1 -0
- package/dist/routing/route-trie.js +10 -11
- package/dist/routing/route-trie.js.map +1 -1
- package/dist/server/app-browser-entry.js +30 -2
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-browser-state.js.map +1 -1
- package/dist/server/app-middleware.d.ts +32 -0
- package/dist/server/app-middleware.js +147 -0
- package/dist/server/app-middleware.js.map +1 -0
- package/dist/server/app-page-boundary-render.d.ts +2 -0
- package/dist/server/app-page-boundary-render.js +50 -30
- package/dist/server/app-page-boundary-render.js.map +1 -1
- package/dist/server/app-page-boundary.d.ts +12 -1
- package/dist/server/app-page-boundary.js +27 -12
- package/dist/server/app-page-boundary.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +4 -1
- package/dist/server/app-page-cache.js +38 -2
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +120 -0
- package/dist/server/app-page-dispatch.js +332 -0
- package/dist/server/app-page-dispatch.js.map +1 -0
- package/dist/server/app-page-execution.d.ts +4 -3
- package/dist/server/app-page-execution.js +5 -8
- package/dist/server/app-page-execution.js.map +1 -1
- package/dist/server/app-page-head.d.ts +55 -0
- package/dist/server/app-page-head.js +196 -0
- package/dist/server/app-page-head.js.map +1 -0
- package/dist/server/app-page-method.d.ts +16 -0
- package/dist/server/app-page-method.js +30 -0
- package/dist/server/app-page-method.js.map +1 -0
- package/dist/server/app-page-params.d.ts +7 -0
- package/dist/server/app-page-params.js +28 -0
- package/dist/server/app-page-params.js.map +1 -0
- package/dist/server/app-page-render.d.ts +2 -1
- package/dist/server/app-page-render.js +54 -8
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-request.d.ts +4 -4
- package/dist/server/app-page-request.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +14 -3
- package/dist/server/app-page-route-wiring.js +30 -8
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-stream.d.ts +10 -0
- package/dist/server/app-page-stream.js +5 -1
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-prerender-endpoints.d.ts +19 -0
- package/dist/server/app-prerender-endpoints.js +96 -0
- package/dist/server/app-prerender-endpoints.js.map +1 -0
- package/dist/server/app-prerender-static-params.d.ts +16 -0
- package/dist/server/app-prerender-static-params.js +14 -0
- package/dist/server/app-prerender-static-params.js.map +1 -0
- package/dist/server/app-route-handler-cache.d.ts +3 -0
- package/dist/server/app-route-handler-cache.js +6 -2
- package/dist/server/app-route-handler-cache.js.map +1 -1
- package/dist/server/app-route-handler-dispatch.d.ts +42 -0
- package/dist/server/app-route-handler-dispatch.js +147 -0
- package/dist/server/app-route-handler-dispatch.js.map +1 -0
- package/dist/server/app-route-handler-execution.d.ts +6 -2
- package/dist/server/app-route-handler-execution.js +23 -2
- package/dist/server/app-route-handler-execution.js.map +1 -1
- package/dist/server/app-route-handler-response.d.ts +2 -1
- package/dist/server/app-route-handler-response.js +44 -4
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-route-handler-runtime.d.ts +4 -1
- package/dist/server/app-route-handler-runtime.js +107 -1
- package/dist/server/app-route-handler-runtime.js.map +1 -1
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/app-rsc-errors.d.ts +27 -0
- package/dist/server/app-rsc-errors.js +42 -0
- package/dist/server/app-rsc-errors.js.map +1 -0
- package/dist/server/app-rsc-route-matching.d.ts +40 -0
- package/dist/server/app-rsc-route-matching.js +66 -0
- package/dist/server/app-rsc-route-matching.js.map +1 -0
- package/dist/server/app-server-action-execution.d.ts +86 -1
- package/dist/server/app-server-action-execution.js +255 -5
- package/dist/server/app-server-action-execution.js.map +1 -1
- package/dist/server/app-ssr-entry.d.ts +7 -0
- package/dist/server/app-ssr-entry.js +30 -9
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-stream.d.ts +4 -2
- package/dist/server/app-ssr-stream.js +29 -2
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/app-static-generation.d.ts +15 -0
- package/dist/server/app-static-generation.js +20 -0
- package/dist/server/app-static-generation.js.map +1 -0
- package/dist/server/dev-route-files.d.ts +7 -0
- package/dist/server/dev-route-files.js +73 -0
- package/dist/server/dev-route-files.js.map +1 -0
- package/dist/server/dev-server.js +4 -0
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/file-based-metadata.d.ts +17 -0
- package/dist/server/file-based-metadata.js +356 -0
- package/dist/server/file-based-metadata.js.map +1 -0
- package/dist/server/implicit-tags.d.ts +6 -0
- package/dist/server/implicit-tags.js +42 -0
- package/dist/server/implicit-tags.js.map +1 -0
- package/dist/server/instrumentation.js.map +1 -1
- package/dist/server/isr-cache.d.ts +20 -2
- package/dist/server/isr-cache.js +58 -7
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/metadata-route-build-data.d.ts +25 -0
- package/dist/server/metadata-route-build-data.js +150 -0
- package/dist/server/metadata-route-build-data.js.map +1 -0
- package/dist/server/metadata-route-response.d.ts +17 -0
- package/dist/server/metadata-route-response.js +187 -0
- package/dist/server/metadata-route-response.js.map +1 -0
- package/dist/server/metadata-routes.d.ts +42 -4
- package/dist/server/metadata-routes.js +127 -11
- package/dist/server/metadata-routes.js.map +1 -1
- package/dist/server/middleware-matcher.d.ts +15 -0
- package/dist/server/middleware-matcher.js +102 -0
- package/dist/server/middleware-matcher.js.map +1 -0
- package/dist/server/middleware-request-headers.js +2 -1
- package/dist/server/middleware-request-headers.js.map +1 -1
- package/dist/server/middleware-runtime.d.ts +39 -0
- package/dist/server/middleware-runtime.js +159 -0
- package/dist/server/middleware-runtime.js.map +1 -0
- package/dist/server/middleware.d.ts +4 -36
- package/dist/server/middleware.js +18 -228
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/pages-page-data.d.ts +5 -1
- package/dist/server/pages-page-data.js +4 -0
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-response.js +2 -1
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/prerender-work-unit-setup.d.ts +7 -0
- package/dist/server/prerender-work-unit-setup.js +30 -0
- package/dist/server/prerender-work-unit-setup.js.map +1 -0
- package/dist/server/prod-server.js +10 -14
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-pipeline.d.ts +46 -5
- package/dist/server/request-pipeline.js +84 -5
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/rsc-stream-hints.d.ts +5 -0
- package/dist/server/rsc-stream-hints.js +35 -0
- package/dist/server/rsc-stream-hints.js.map +1 -0
- package/dist/server/seed-cache.js.map +1 -1
- package/dist/server/server-action-not-found.d.ts +9 -0
- package/dist/server/server-action-not-found.js +40 -0
- package/dist/server/server-action-not-found.js.map +1 -0
- package/dist/shims/cache.d.ts +25 -2
- package/dist/shims/cache.js +52 -2
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/error-boundary.d.ts +50 -5
- package/dist/shims/error-boundary.js +76 -4
- package/dist/shims/error-boundary.js.map +1 -1
- package/dist/shims/font-google-base.d.ts +5 -4
- package/dist/shims/font-google-base.js +61 -13
- package/dist/shims/font-google-base.js.map +1 -1
- package/dist/shims/headers.d.ts +14 -2
- package/dist/shims/headers.js +127 -17
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/image.js +26 -8
- package/dist/shims/image.js.map +1 -1
- package/dist/shims/internal/make-hanging-promise.d.ts +16 -0
- package/dist/shims/internal/make-hanging-promise.js +46 -0
- package/dist/shims/internal/make-hanging-promise.js.map +1 -0
- package/dist/shims/internal/work-unit-async-storage.d.ts +26 -3
- package/dist/shims/internal/work-unit-async-storage.js +6 -3
- package/dist/shims/internal/work-unit-async-storage.js.map +1 -1
- package/dist/shims/metadata.d.ts +38 -26
- package/dist/shims/metadata.js +75 -45
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation.d.ts +10 -1
- package/dist/shims/navigation.js +18 -1
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/navigation.react-server.d.ts +2 -2
- package/dist/shims/navigation.react-server.js +2 -2
- package/dist/shims/navigation.react-server.js.map +1 -1
- package/dist/shims/offline.d.ts +5 -0
- package/dist/shims/offline.js +17 -0
- package/dist/shims/offline.js.map +1 -0
- package/dist/shims/request-state-types.d.ts +2 -1
- package/dist/shims/root-params.d.ts +11 -0
- package/dist/shims/root-params.js +24 -0
- package/dist/shims/root-params.js.map +1 -0
- package/dist/shims/router.js +1 -1
- package/dist/shims/server.d.ts +3 -1
- package/dist/shims/server.js +83 -5
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/thenable-params.d.ts +5 -0
- package/dist/shims/thenable-params.js +37 -0
- package/dist/shims/thenable-params.js.map +1 -0
- package/dist/shims/unified-request-context.d.ts +2 -1
- package/dist/shims/unified-request-context.js +2 -0
- package/dist/shims/unified-request-context.js.map +1 -1
- package/package.json +6 -1
- package/dist/server/middleware-codegen.d.ts +0 -54
- package/dist/server/middleware-codegen.js +0 -414
- package/dist/server/middleware-codegen.js.map +0 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { createMetadataRouteEntriesSource } from "../server/metadata-route-build-data.js";
|
|
2
|
+
//#region src/entries/app-rsc-manifest.ts
|
|
3
|
+
function createImportAllocator() {
|
|
4
|
+
const imports = [];
|
|
5
|
+
const importMap = /* @__PURE__ */ new Map();
|
|
6
|
+
let importIdx = 0;
|
|
7
|
+
return {
|
|
8
|
+
importMap,
|
|
9
|
+
imports,
|
|
10
|
+
getImportVar(filePath) {
|
|
11
|
+
const existing = importMap.get(filePath);
|
|
12
|
+
if (existing) return existing;
|
|
13
|
+
const varName = `mod_${importIdx++}`;
|
|
14
|
+
const absPath = filePath.replace(/\\/g, "/");
|
|
15
|
+
imports.push(`import * as ${varName} from ${JSON.stringify(absPath)};`);
|
|
16
|
+
importMap.set(filePath, varName);
|
|
17
|
+
return varName;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function registerRouteModules(routes, imports) {
|
|
22
|
+
for (const route of routes) {
|
|
23
|
+
if (route.pagePath) imports.getImportVar(route.pagePath);
|
|
24
|
+
if (route.routePath) imports.getImportVar(route.routePath);
|
|
25
|
+
for (const layout of route.layouts) imports.getImportVar(layout);
|
|
26
|
+
for (const tmpl of route.templates) imports.getImportVar(tmpl);
|
|
27
|
+
if (route.loadingPath) imports.getImportVar(route.loadingPath);
|
|
28
|
+
if (route.errorPath) imports.getImportVar(route.errorPath);
|
|
29
|
+
if (route.layoutErrorPaths) {
|
|
30
|
+
for (const ep of route.layoutErrorPaths) if (ep) imports.getImportVar(ep);
|
|
31
|
+
}
|
|
32
|
+
if (route.notFoundPath) imports.getImportVar(route.notFoundPath);
|
|
33
|
+
if (route.notFoundPaths) {
|
|
34
|
+
for (const nfp of route.notFoundPaths) if (nfp) imports.getImportVar(nfp);
|
|
35
|
+
}
|
|
36
|
+
if (route.forbiddenPath) imports.getImportVar(route.forbiddenPath);
|
|
37
|
+
if (route.forbiddenPaths) {
|
|
38
|
+
for (const fp of route.forbiddenPaths) if (fp) imports.getImportVar(fp);
|
|
39
|
+
}
|
|
40
|
+
if (route.unauthorizedPath) imports.getImportVar(route.unauthorizedPath);
|
|
41
|
+
if (route.unauthorizedPaths) {
|
|
42
|
+
for (const up of route.unauthorizedPaths) if (up) imports.getImportVar(up);
|
|
43
|
+
}
|
|
44
|
+
for (const slot of route.parallelSlots) {
|
|
45
|
+
if (slot.pagePath) imports.getImportVar(slot.pagePath);
|
|
46
|
+
if (slot.defaultPath) imports.getImportVar(slot.defaultPath);
|
|
47
|
+
if (slot.layoutPath) imports.getImportVar(slot.layoutPath);
|
|
48
|
+
if (slot.loadingPath) imports.getImportVar(slot.loadingPath);
|
|
49
|
+
if (slot.errorPath) imports.getImportVar(slot.errorPath);
|
|
50
|
+
for (const ir of slot.interceptingRoutes) {
|
|
51
|
+
imports.getImportVar(ir.pagePath);
|
|
52
|
+
for (const layoutPath of ir.layoutPaths) imports.getImportVar(layoutPath);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function buildRouteEntries(routes, imports) {
|
|
58
|
+
return routes.map((route, routeIdx) => {
|
|
59
|
+
const layoutVars = route.layouts.map((l) => imports.getImportVar(l));
|
|
60
|
+
const templateVars = route.templates.map((t) => imports.getImportVar(t));
|
|
61
|
+
const notFoundVars = (route.notFoundPaths ?? []).map((nf) => nf ? imports.getImportVar(nf) : "null");
|
|
62
|
+
const forbiddenVars = (route.forbiddenPaths ?? []).map((fp) => fp ? imports.getImportVar(fp) : "null");
|
|
63
|
+
const unauthorizedVars = (route.unauthorizedPaths ?? []).map((up) => up ? imports.getImportVar(up) : "null");
|
|
64
|
+
const slotEntries = route.parallelSlots.map((slot) => {
|
|
65
|
+
const interceptEntries = slot.interceptingRoutes.map((ir) => ` {
|
|
66
|
+
convention: ${JSON.stringify(ir.convention)},
|
|
67
|
+
targetPattern: ${JSON.stringify(ir.targetPattern)},
|
|
68
|
+
interceptLayouts: [${ir.layoutPaths.map((layoutPath) => imports.getImportVar(layoutPath)).join(", ")}],
|
|
69
|
+
page: ${imports.getImportVar(ir.pagePath)},
|
|
70
|
+
params: ${JSON.stringify(ir.params)},
|
|
71
|
+
}`);
|
|
72
|
+
return ` ${JSON.stringify(slot.key)}: {
|
|
73
|
+
name: ${JSON.stringify(slot.name)},
|
|
74
|
+
page: ${slot.pagePath ? imports.getImportVar(slot.pagePath) : "null"},
|
|
75
|
+
default: ${slot.defaultPath ? imports.getImportVar(slot.defaultPath) : "null"},
|
|
76
|
+
layout: ${slot.layoutPath ? imports.getImportVar(slot.layoutPath) : "null"},
|
|
77
|
+
loading: ${slot.loadingPath ? imports.getImportVar(slot.loadingPath) : "null"},
|
|
78
|
+
error: ${slot.errorPath ? imports.getImportVar(slot.errorPath) : "null"},
|
|
79
|
+
layoutIndex: ${slot.layoutIndex},
|
|
80
|
+
routeSegments: ${JSON.stringify(slot.routeSegments)},
|
|
81
|
+
intercepts: [
|
|
82
|
+
${interceptEntries.join(",\n")}
|
|
83
|
+
],
|
|
84
|
+
}`;
|
|
85
|
+
});
|
|
86
|
+
const layoutErrorVars = (route.layoutErrorPaths || []).map((ep) => ep ? imports.getImportVar(ep) : "null");
|
|
87
|
+
return ` {
|
|
88
|
+
__buildTimeClassifications: __VINEXT_CLASS(${routeIdx}), // evaluated once at module load
|
|
89
|
+
__buildTimeReasons: __classDebug ? __VINEXT_CLASS_REASONS(${routeIdx}) : null,
|
|
90
|
+
pattern: ${JSON.stringify(route.pattern)},
|
|
91
|
+
patternParts: ${JSON.stringify(route.patternParts)},
|
|
92
|
+
isDynamic: ${route.isDynamic},
|
|
93
|
+
params: ${JSON.stringify(route.params)},
|
|
94
|
+
rootParamNames: ${JSON.stringify(route.rootParamNames ?? [])},
|
|
95
|
+
page: ${route.pagePath ? imports.getImportVar(route.pagePath) : "null"},
|
|
96
|
+
routeHandler: ${route.routePath ? imports.getImportVar(route.routePath) : "null"},
|
|
97
|
+
layouts: [${layoutVars.join(", ")}],
|
|
98
|
+
routeSegments: ${JSON.stringify(route.routeSegments)},
|
|
99
|
+
templateTreePositions: ${JSON.stringify(route.templateTreePositions)},
|
|
100
|
+
layoutTreePositions: ${JSON.stringify(route.layoutTreePositions)},
|
|
101
|
+
templates: [${templateVars.join(", ")}],
|
|
102
|
+
errors: [${layoutErrorVars.join(", ")}],
|
|
103
|
+
slots: {
|
|
104
|
+
${slotEntries.join(",\n")}
|
|
105
|
+
},
|
|
106
|
+
loading: ${route.loadingPath ? imports.getImportVar(route.loadingPath) : "null"},
|
|
107
|
+
error: ${route.errorPath ? imports.getImportVar(route.errorPath) : "null"},
|
|
108
|
+
notFound: ${route.notFoundPath ? imports.getImportVar(route.notFoundPath) : "null"},
|
|
109
|
+
notFounds: [${notFoundVars.join(", ")}],
|
|
110
|
+
forbidden: ${route.forbiddenPath ? imports.getImportVar(route.forbiddenPath) : "null"},
|
|
111
|
+
forbiddens: [${forbiddenVars.join(", ")}],
|
|
112
|
+
unauthorized: ${route.unauthorizedPath ? imports.getImportVar(route.unauthorizedPath) : "null"},
|
|
113
|
+
unauthorizeds: [${unauthorizedVars.join(", ")}],
|
|
114
|
+
}`;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
function buildGenerateStaticParamsEntries(routes, imports) {
|
|
118
|
+
const entries = [];
|
|
119
|
+
for (const route of routes) {
|
|
120
|
+
if (!route.isDynamic || !route.pagePath) continue;
|
|
121
|
+
entries.push(` ${JSON.stringify(route.pattern)}: ${imports.getImportVar(route.pagePath)}?.generateStaticParams ?? null,`);
|
|
122
|
+
}
|
|
123
|
+
return entries;
|
|
124
|
+
}
|
|
125
|
+
function buildAppRscManifestCode(options) {
|
|
126
|
+
const imports = createImportAllocator();
|
|
127
|
+
const metadataRoutes = options.metadataRoutes ?? [];
|
|
128
|
+
registerRouteModules(options.routes, imports);
|
|
129
|
+
const routeEntries = buildRouteEntries(options.routes, imports);
|
|
130
|
+
const rootRoute = options.routes.find((r) => r.pattern === "/");
|
|
131
|
+
const rootNotFoundVar = rootRoute?.notFoundPath ? imports.getImportVar(rootRoute.notFoundPath) : null;
|
|
132
|
+
const rootForbiddenVar = rootRoute?.forbiddenPath ? imports.getImportVar(rootRoute.forbiddenPath) : null;
|
|
133
|
+
const rootUnauthorizedVar = rootRoute?.unauthorizedPath ? imports.getImportVar(rootRoute.unauthorizedPath) : null;
|
|
134
|
+
const rootLayoutVars = rootRoute ? rootRoute.layouts.map((l) => imports.getImportVar(l)) : [];
|
|
135
|
+
const globalErrorVar = options.globalErrorPath ? imports.getImportVar(options.globalErrorPath) : null;
|
|
136
|
+
const dynamicMetadataRoutes = metadataRoutes.filter((r) => r.isDynamic);
|
|
137
|
+
for (const route of dynamicMetadataRoutes) imports.getImportVar(route.filePath);
|
|
138
|
+
return {
|
|
139
|
+
imports: imports.imports,
|
|
140
|
+
routeEntries,
|
|
141
|
+
metaRouteEntries: createMetadataRouteEntriesSource(metadataRoutes, imports.importMap),
|
|
142
|
+
generateStaticParamsEntries: buildGenerateStaticParamsEntries(options.routes, imports),
|
|
143
|
+
rootNotFoundVar,
|
|
144
|
+
rootForbiddenVar,
|
|
145
|
+
rootUnauthorizedVar,
|
|
146
|
+
rootLayoutVars,
|
|
147
|
+
globalErrorVar
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
export { buildAppRscManifestCode };
|
|
152
|
+
|
|
153
|
+
//# sourceMappingURL=app-rsc-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-rsc-manifest.js","names":[],"sources":["../../src/entries/app-rsc-manifest.ts"],"sourcesContent":["import type { AppRoute } from \"../routing/app-router.js\";\nimport { createMetadataRouteEntriesSource } from \"../server/metadata-route-build-data.js\";\nimport type { MetadataFileRoute } from \"../server/metadata-routes.js\";\n\ntype AppRscManifestCode = {\n imports: string[];\n routeEntries: string[];\n metaRouteEntries: string[];\n generateStaticParamsEntries: string[];\n rootNotFoundVar: string | null;\n rootForbiddenVar: string | null;\n rootUnauthorizedVar: string | null;\n rootLayoutVars: string[];\n globalErrorVar: string | null;\n};\n\ntype BuildAppRscManifestCodeOptions = {\n routes: AppRoute[];\n metadataRoutes?: MetadataFileRoute[];\n globalErrorPath?: string | null;\n};\n\ntype ImportAllocator = {\n getImportVar(filePath: string): string;\n importMap: ReadonlyMap<string, string>;\n imports: string[];\n};\n\nfunction createImportAllocator(): ImportAllocator {\n const imports: string[] = [];\n const importMap = new Map<string, string>();\n let importIdx = 0;\n\n return {\n importMap,\n imports,\n getImportVar(filePath) {\n const existing = importMap.get(filePath);\n if (existing) return existing;\n\n const varName = `mod_${importIdx++}`;\n const absPath = filePath.replace(/\\\\/g, \"/\");\n imports.push(`import * as ${varName} from ${JSON.stringify(absPath)};`);\n importMap.set(filePath, varName);\n return varName;\n },\n };\n}\n\nfunction registerRouteModules(routes: AppRoute[], imports: ImportAllocator): void {\n for (const route of routes) {\n if (route.pagePath) imports.getImportVar(route.pagePath);\n if (route.routePath) imports.getImportVar(route.routePath);\n for (const layout of route.layouts) imports.getImportVar(layout);\n for (const tmpl of route.templates) imports.getImportVar(tmpl);\n if (route.loadingPath) imports.getImportVar(route.loadingPath);\n if (route.errorPath) imports.getImportVar(route.errorPath);\n if (route.layoutErrorPaths) {\n for (const ep of route.layoutErrorPaths) {\n if (ep) imports.getImportVar(ep);\n }\n }\n if (route.notFoundPath) imports.getImportVar(route.notFoundPath);\n if (route.notFoundPaths) {\n for (const nfp of route.notFoundPaths) {\n if (nfp) imports.getImportVar(nfp);\n }\n }\n if (route.forbiddenPath) imports.getImportVar(route.forbiddenPath);\n if (route.forbiddenPaths) {\n for (const fp of route.forbiddenPaths) {\n if (fp) imports.getImportVar(fp);\n }\n }\n if (route.unauthorizedPath) imports.getImportVar(route.unauthorizedPath);\n if (route.unauthorizedPaths) {\n for (const up of route.unauthorizedPaths) {\n if (up) imports.getImportVar(up);\n }\n }\n for (const slot of route.parallelSlots) {\n if (slot.pagePath) imports.getImportVar(slot.pagePath);\n if (slot.defaultPath) imports.getImportVar(slot.defaultPath);\n if (slot.layoutPath) imports.getImportVar(slot.layoutPath);\n if (slot.loadingPath) imports.getImportVar(slot.loadingPath);\n if (slot.errorPath) imports.getImportVar(slot.errorPath);\n for (const ir of slot.interceptingRoutes) {\n imports.getImportVar(ir.pagePath);\n for (const layoutPath of ir.layoutPaths) {\n imports.getImportVar(layoutPath);\n }\n }\n }\n }\n}\n\nfunction buildRouteEntries(routes: AppRoute[], imports: ImportAllocator): string[] {\n return routes.map((route, routeIdx) => {\n const layoutVars = route.layouts.map((l) => imports.getImportVar(l));\n const templateVars = route.templates.map((t) => imports.getImportVar(t));\n const notFoundVars = (route.notFoundPaths ?? []).map((nf) =>\n nf ? imports.getImportVar(nf) : \"null\",\n );\n const forbiddenVars = (route.forbiddenPaths ?? []).map((fp) =>\n fp ? imports.getImportVar(fp) : \"null\",\n );\n const unauthorizedVars = (route.unauthorizedPaths ?? []).map((up) =>\n up ? imports.getImportVar(up) : \"null\",\n );\n const slotEntries = route.parallelSlots.map((slot) => {\n const interceptEntries = slot.interceptingRoutes.map(\n (ir) => ` {\n convention: ${JSON.stringify(ir.convention)},\n targetPattern: ${JSON.stringify(ir.targetPattern)},\n interceptLayouts: [${ir.layoutPaths.map((layoutPath) => imports.getImportVar(layoutPath)).join(\", \")}],\n page: ${imports.getImportVar(ir.pagePath)},\n params: ${JSON.stringify(ir.params)},\n }`,\n );\n return ` ${JSON.stringify(slot.key)}: {\n name: ${JSON.stringify(slot.name)},\n page: ${slot.pagePath ? imports.getImportVar(slot.pagePath) : \"null\"},\n default: ${slot.defaultPath ? imports.getImportVar(slot.defaultPath) : \"null\"},\n layout: ${slot.layoutPath ? imports.getImportVar(slot.layoutPath) : \"null\"},\n loading: ${slot.loadingPath ? imports.getImportVar(slot.loadingPath) : \"null\"},\n error: ${slot.errorPath ? imports.getImportVar(slot.errorPath) : \"null\"},\n layoutIndex: ${slot.layoutIndex},\n routeSegments: ${JSON.stringify(slot.routeSegments)},\n intercepts: [\n${interceptEntries.join(\",\\n\")}\n ],\n }`;\n });\n const layoutErrorVars = (route.layoutErrorPaths || []).map((ep) =>\n ep ? imports.getImportVar(ep) : \"null\",\n );\n return ` {\n __buildTimeClassifications: __VINEXT_CLASS(${routeIdx}), // evaluated once at module load\n __buildTimeReasons: __classDebug ? __VINEXT_CLASS_REASONS(${routeIdx}) : null,\n pattern: ${JSON.stringify(route.pattern)},\n patternParts: ${JSON.stringify(route.patternParts)},\n isDynamic: ${route.isDynamic},\n params: ${JSON.stringify(route.params)},\n rootParamNames: ${JSON.stringify(route.rootParamNames ?? [])},\n page: ${route.pagePath ? imports.getImportVar(route.pagePath) : \"null\"},\n routeHandler: ${route.routePath ? imports.getImportVar(route.routePath) : \"null\"},\n layouts: [${layoutVars.join(\", \")}],\n routeSegments: ${JSON.stringify(route.routeSegments)},\n templateTreePositions: ${JSON.stringify(route.templateTreePositions)},\n layoutTreePositions: ${JSON.stringify(route.layoutTreePositions)},\n templates: [${templateVars.join(\", \")}],\n errors: [${layoutErrorVars.join(\", \")}],\n slots: {\n${slotEntries.join(\",\\n\")}\n },\n loading: ${route.loadingPath ? imports.getImportVar(route.loadingPath) : \"null\"},\n error: ${route.errorPath ? imports.getImportVar(route.errorPath) : \"null\"},\n notFound: ${route.notFoundPath ? imports.getImportVar(route.notFoundPath) : \"null\"},\n notFounds: [${notFoundVars.join(\", \")}],\n forbidden: ${route.forbiddenPath ? imports.getImportVar(route.forbiddenPath) : \"null\"},\n forbiddens: [${forbiddenVars.join(\", \")}],\n unauthorized: ${route.unauthorizedPath ? imports.getImportVar(route.unauthorizedPath) : \"null\"},\n unauthorizeds: [${unauthorizedVars.join(\", \")}],\n }`;\n });\n}\n\nfunction buildGenerateStaticParamsEntries(routes: AppRoute[], imports: ImportAllocator): string[] {\n const entries: string[] = [];\n for (const route of routes) {\n if (!route.isDynamic || !route.pagePath) continue;\n entries.push(\n ` ${JSON.stringify(route.pattern)}: ${imports.getImportVar(route.pagePath)}?.generateStaticParams ?? null,`,\n );\n }\n return entries;\n}\n\nexport function buildAppRscManifestCode(\n options: BuildAppRscManifestCodeOptions,\n): AppRscManifestCode {\n const imports = createImportAllocator();\n const metadataRoutes = options.metadataRoutes ?? [];\n\n registerRouteModules(options.routes, imports);\n const routeEntries = buildRouteEntries(options.routes, imports);\n\n const rootRoute = options.routes.find((r) => r.pattern === \"/\");\n const rootNotFoundVar = rootRoute?.notFoundPath\n ? imports.getImportVar(rootRoute.notFoundPath)\n : null;\n const rootForbiddenVar = rootRoute?.forbiddenPath\n ? imports.getImportVar(rootRoute.forbiddenPath)\n : null;\n const rootUnauthorizedVar = rootRoute?.unauthorizedPath\n ? imports.getImportVar(rootRoute.unauthorizedPath)\n : null;\n const rootLayoutVars = rootRoute ? rootRoute.layouts.map((l) => imports.getImportVar(l)) : [];\n const globalErrorVar = options.globalErrorPath\n ? imports.getImportVar(options.globalErrorPath)\n : null;\n\n const dynamicMetadataRoutes = metadataRoutes.filter((r) => r.isDynamic);\n for (const route of dynamicMetadataRoutes) {\n imports.getImportVar(route.filePath);\n }\n\n return {\n imports: imports.imports,\n routeEntries,\n metaRouteEntries: createMetadataRouteEntriesSource(metadataRoutes, imports.importMap),\n generateStaticParamsEntries: buildGenerateStaticParamsEntries(options.routes, imports),\n rootNotFoundVar,\n rootForbiddenVar,\n rootUnauthorizedVar,\n rootLayoutVars,\n glob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C;CAEJ,MAAM,wBAAwB,eAAe,QAAQ,MAAM,EAAE,UAAU;AACvE,MAAK,MAAM,SAAS,sBAClB,SAAQ,aAAa,MAAM,SAAS;AAGtC,QAAO;EACL,SAAS,QAAQ;EACjB;EACA,kBAAkB,iCAAiC,gBAAgB,QAAQ,UAAU;EACrF,6BAA6B,iCAAiC,QAAQ,QAAQ,QAAQ;EACtF;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { apiRouter, pagesRouter } from "../routing/pages-router.js";
|
|
2
2
|
import { resolveEntryPath } from "./runtime-entry-module.js";
|
|
3
3
|
import { isProxyFile } from "../server/middleware.js";
|
|
4
|
-
import { generateMiddlewareMatcherCode, generateNormalizePathCode, generateRouteMatchNormalizationCode, generateSafeRegExpCode } from "../server/middleware-codegen.js";
|
|
5
4
|
import { findFileWithExts } from "./pages-entry-helpers.js";
|
|
6
5
|
//#region src/entries/pages-server-entry.ts
|
|
7
6
|
/**
|
|
@@ -14,6 +13,7 @@ import { findFileWithExts } from "./pages-entry-helpers.js";
|
|
|
14
13
|
* Extracted from index.ts.
|
|
15
14
|
*/
|
|
16
15
|
const _requestContextShimPath = resolveEntryPath("../shims/request-context.js", import.meta.url);
|
|
16
|
+
const _middlewareRuntimePath = resolveEntryPath("../server/middleware-runtime.js", import.meta.url);
|
|
17
17
|
const _routeTriePath = resolveEntryPath("../routing/route-trie.js", import.meta.url);
|
|
18
18
|
const _pagesI18nPath = resolveEntryPath("../server/pages-i18n.js", import.meta.url);
|
|
19
19
|
const _pagesPageResponsePath = resolveEntryPath("../server/pages-page-response.js", import.meta.url);
|
|
@@ -84,108 +84,17 @@ if (typeof _instrumentation.register === "function") {
|
|
|
84
84
|
if (typeof _instrumentation.onRequestError === "function") {
|
|
85
85
|
globalThis.__VINEXT_onRequestErrorHandler__ = _instrumentation.onRequestError;
|
|
86
86
|
}` : "";
|
|
87
|
-
const middlewareImportCode = middlewarePath ? `import * as middlewareModule from ${JSON.stringify(middlewarePath.replace(/\\/g, "/"))};
|
|
88
|
-
import { NextRequest, NextFetchEvent } from "next/server";` : "";
|
|
87
|
+
const middlewareImportCode = middlewarePath ? `import * as middlewareModule from ${JSON.stringify(middlewarePath.replace(/\\/g, "/"))};` : "";
|
|
89
88
|
const middlewareExportCode = middlewarePath ? `
|
|
90
|
-
// --- Middleware support (generated from middleware-codegen.ts) ---
|
|
91
|
-
${generateNormalizePathCode("es5")}
|
|
92
|
-
${generateRouteMatchNormalizationCode("es5")}
|
|
93
|
-
${generateSafeRegExpCode("es5")}
|
|
94
|
-
${generateMiddlewareMatcherCode("es5")}
|
|
95
|
-
|
|
96
89
|
export async function runMiddleware(request, ctx) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
: (middlewareModule.middleware ?? middlewareModule.default);
|
|
106
|
-
if (typeof middlewareFn !== "function") {
|
|
107
|
-
var fileType = isProxy ? "Proxy" : "Middleware";
|
|
108
|
-
var expectedExport = isProxy ? "proxy" : "middleware";
|
|
109
|
-
throw new Error("The " + fileType + " file must export a function named \`" + expectedExport + "\` or a \`default\` function.");
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
var config = middlewareModule.config;
|
|
113
|
-
var matcher = config && config.matcher;
|
|
114
|
-
var url = new URL(request.url);
|
|
115
|
-
|
|
116
|
-
// Normalize pathname before matching to prevent path-confusion bypasses
|
|
117
|
-
// (percent-encoding like /%61dmin, double slashes like /dashboard//settings).
|
|
118
|
-
var decodedPathname;
|
|
119
|
-
try { decodedPathname = __normalizePathnameForRouteMatchStrict(url.pathname); } catch (e) {
|
|
120
|
-
return { continue: false, response: new Response("Bad Request", { status: 400 }) };
|
|
121
|
-
}
|
|
122
|
-
var normalizedPathname = __normalizePath(decodedPathname);
|
|
123
|
-
|
|
124
|
-
if (!matchesMiddleware(normalizedPathname, matcher, request, i18nConfig)) return { continue: true };
|
|
125
|
-
|
|
126
|
-
// Construct a new Request with the decoded + normalized pathname so middleware
|
|
127
|
-
// always sees the same canonical path that the router uses.
|
|
128
|
-
var mwRequest = request;
|
|
129
|
-
if (normalizedPathname !== url.pathname) {
|
|
130
|
-
var mwUrl = new URL(url);
|
|
131
|
-
mwUrl.pathname = normalizedPathname;
|
|
132
|
-
mwRequest = new Request(mwUrl, request);
|
|
133
|
-
}
|
|
134
|
-
var __mwNextConfig = (vinextConfig.basePath || i18nConfig) ? { basePath: vinextConfig.basePath, i18n: i18nConfig || undefined } : undefined;
|
|
135
|
-
var nextRequest = mwRequest instanceof NextRequest ? mwRequest : new NextRequest(mwRequest, __mwNextConfig ? { nextConfig: __mwNextConfig } : undefined);
|
|
136
|
-
var fetchEvent = new NextFetchEvent({ page: normalizedPathname });
|
|
137
|
-
var response;
|
|
138
|
-
try { response = await middlewareFn(nextRequest, fetchEvent); }
|
|
139
|
-
catch (e) {
|
|
140
|
-
console.error("[vinext] Middleware error:", e);
|
|
141
|
-
var _mwCtxErr = _getRequestExecutionContext();
|
|
142
|
-
if (_mwCtxErr && typeof _mwCtxErr.waitUntil === "function") { _mwCtxErr.waitUntil(fetchEvent.drainWaitUntil()); } else { fetchEvent.drainWaitUntil(); }
|
|
143
|
-
return { continue: false, response: new Response("Internal Server Error", { status: 500 }) };
|
|
144
|
-
}
|
|
145
|
-
var _mwCtx = _getRequestExecutionContext();
|
|
146
|
-
if (_mwCtx && typeof _mwCtx.waitUntil === "function") { _mwCtx.waitUntil(fetchEvent.drainWaitUntil()); } else { fetchEvent.drainWaitUntil(); }
|
|
147
|
-
|
|
148
|
-
if (!response) return { continue: true };
|
|
149
|
-
|
|
150
|
-
if (response.headers.get("x-middleware-next") === "1") {
|
|
151
|
-
var rHeaders = new Headers();
|
|
152
|
-
for (var [key, value] of response.headers) {
|
|
153
|
-
// Keep x-middleware-request-* headers so the production server can
|
|
154
|
-
// apply middleware-request header overrides before stripping internals
|
|
155
|
-
// from the final client response.
|
|
156
|
-
if (
|
|
157
|
-
!key.startsWith("x-middleware-") ||
|
|
158
|
-
key === "x-middleware-override-headers" ||
|
|
159
|
-
key.startsWith("x-middleware-request-")
|
|
160
|
-
) rHeaders.append(key, value);
|
|
161
|
-
}
|
|
162
|
-
return { continue: true, responseHeaders: rHeaders };
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (response.status >= 300 && response.status < 400) {
|
|
166
|
-
var location = response.headers.get("Location") || response.headers.get("location");
|
|
167
|
-
if (location) {
|
|
168
|
-
var rdHeaders = new Headers();
|
|
169
|
-
for (var [rk, rv] of response.headers) {
|
|
170
|
-
if (!rk.startsWith("x-middleware-") && rk.toLowerCase() !== "location") rdHeaders.append(rk, rv);
|
|
171
|
-
}
|
|
172
|
-
return { continue: false, redirectUrl: location, redirectStatus: response.status, responseHeaders: rdHeaders };
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
var rewriteUrl = response.headers.get("x-middleware-rewrite");
|
|
177
|
-
if (rewriteUrl) {
|
|
178
|
-
var rwHeaders = new Headers();
|
|
179
|
-
for (var [k, v] of response.headers) {
|
|
180
|
-
if (!k.startsWith("x-middleware-") || k === "x-middleware-override-headers" || k.startsWith("x-middleware-request-")) rwHeaders.append(k, v);
|
|
181
|
-
}
|
|
182
|
-
var rewritePath;
|
|
183
|
-
try { var parsed = new URL(rewriteUrl, request.url); rewritePath = parsed.pathname + parsed.search; }
|
|
184
|
-
catch { rewritePath = rewriteUrl; }
|
|
185
|
-
return { continue: true, rewriteUrl: rewritePath, rewriteStatus: response.status !== 200 ? response.status : undefined, responseHeaders: rwHeaders };
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return { continue: false, response: response };
|
|
90
|
+
return __runGeneratedMiddleware({
|
|
91
|
+
basePath: vinextConfig.basePath,
|
|
92
|
+
ctx,
|
|
93
|
+
i18nConfig,
|
|
94
|
+
isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},
|
|
95
|
+
module: middlewareModule,
|
|
96
|
+
request,
|
|
97
|
+
});
|
|
189
98
|
}
|
|
190
99
|
` : `
|
|
191
100
|
export async function runMiddleware() { return { continue: true }; }
|
|
@@ -210,6 +119,7 @@ import { getSSRFontLinks as _getSSRFontLinks, getSSRFontStyles as _getSSRFontSty
|
|
|
210
119
|
import { getSSRFontStyles as _getSSRFontStylesLocal, getSSRFontPreloads as _getSSRFontPreloadsLocal } from "next/font/local";
|
|
211
120
|
import { sanitizeDestination as sanitizeDestinationLocal } from ${JSON.stringify(resolveEntryPath("../config/config-matchers.js", import.meta.url))};
|
|
212
121
|
import { runWithExecutionContext as _runWithExecutionContext, getRequestExecutionContext as _getRequestExecutionContext } from ${JSON.stringify(_requestContextShimPath)};
|
|
122
|
+
import { runGeneratedMiddleware as __runGeneratedMiddleware } from ${JSON.stringify(_middlewareRuntimePath)};
|
|
213
123
|
import { buildRouteTrie as _buildRouteTrie, trieMatch as _trieMatch } from ${JSON.stringify(_routeTriePath)};
|
|
214
124
|
import { reportRequestError as _reportRequestError } from "vinext/instrumentation";
|
|
215
125
|
import { resolvePagesI18nRequest } from ${JSON.stringify(_pagesI18nPath)};
|
|
@@ -244,8 +154,8 @@ function isrGet(key) {
|
|
|
244
154
|
function isrSet(key, data, revalidateSeconds, tags) {
|
|
245
155
|
return __sharedIsrSet(key, data, revalidateSeconds, tags);
|
|
246
156
|
}
|
|
247
|
-
function triggerBackgroundRegeneration(key, renderFn) {
|
|
248
|
-
return __sharedTriggerBackgroundRegeneration(key, renderFn);
|
|
157
|
+
function triggerBackgroundRegeneration(key, renderFn, errorContext) {
|
|
158
|
+
return __sharedTriggerBackgroundRegeneration(key, renderFn, errorContext);
|
|
249
159
|
}
|
|
250
160
|
function isrCacheKey(router, pathname) {
|
|
251
161
|
return __sharedIsrCacheKey(router, pathname, buildId || undefined);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pages-server-entry.js","names":[],"sources":["../../src/entries/pages-server-entry.ts"],"sourcesContent":["/**\n * Pages Router server entry generator.\n *\n * Generates the virtual SSR server entry module (`virtual:vinext-server-entry`).\n * This is the entry point for `vite build --ssr`. It handles SSR, API routes,\n * middleware, ISR, and i18n for the Pages Router.\n *\n * Extracted from index.ts.\n */\nimport { resolveEntryPath } from \"./runtime-entry-module.js\";\nimport { pagesRouter, apiRouter, type Route } from \"../routing/pages-router.js\";\nimport { createValidFileMatcher } from \"../routing/file-matcher.js\";\nimport { type ResolvedNextConfig } from \"../config/next-config.js\";\nimport { isProxyFile } from \"../server/middleware.js\";\nimport {\n generateSafeRegExpCode,\n generateMiddlewareMatcherCode,\n generateNormalizePathCode,\n generateRouteMatchNormalizationCode,\n} from \"../server/middleware-codegen.js\";\nimport { findFileWithExts } from \"./pages-entry-helpers.js\";\n\nconst _requestContextShimPath = resolveEntryPath(\"../shims/request-context.js\", import.meta.url);\nconst _routeTriePath = resolveEntryPath(\"../routing/route-trie.js\", import.meta.url);\nconst _pagesI18nPath = resolveEntryPath(\"../server/pages-i18n.js\", import.meta.url);\nconst _pagesPageResponsePath = resolveEntryPath(\n \"../server/pages-page-response.js\",\n import.meta.url,\n);\nconst _pagesPageDataPath = resolveEntryPath(\"../server/pages-page-data.js\", import.meta.url);\nconst _pagesNodeCompatPath = resolveEntryPath(\"../server/pages-node-compat.js\", import.meta.url);\nconst _pagesApiRoutePath = resolveEntryPath(\"../server/pages-api-route.js\", import.meta.url);\nconst _isrCachePath = resolveEntryPath(\"../server/isr-cache.js\", import.meta.url);\nconst _cspPath = resolveEntryPath(\"../server/csp.js\", import.meta.url);\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(\n (r: Route, i: number) =>\n ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: api_${i} }`,\n );\n\n // Check for _app 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 var _mwCtxErr = _getRequestExecutionContext();\n if (_mwCtxErr && typeof _mwCtxErr.waitUntil === \"function\") { _mwCtxErr.waitUntil(fetchEvent.drainWaitUntil()); } else { fetchEvent.drainWaitUntil(); }\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 { _runWithCacheState } from \"next/cache\";\nimport { runWithPrivateCache } from \"vinext/cache-runtime\";\nimport { ensureFetchPatch, runWithFetchCache } from \"vinext/fetch-cache\";\nimport { runWithRequestContext as _runWithUnifiedCtx, createRequestContext as _createUnifiedCtx } from \"vinext/unified-request-context\";\nimport \"vinext/router-state\";\nimport { runWithServerInsertedHTMLState } from \"vinext/navigation-state\";\nimport { runWithHeadState } from \"vinext/head-state\";\nimport \"vinext/i18n-state\";\nimport { setI18nContext } from \"vinext/i18n-context\";\nimport { createNonceAttribute as __createNonceAttribute, safeJsonStringify } from \"vinext/html\";\nimport { getSSRFontLinks as _getSSRFontLinks, getSSRFontStyles as _getSSRFontStylesGoogle, getSSRFontPreloads as _getSSRFontPreloadsGoogle } from \"next/font/google\";\nimport { getSSRFontStyles as _getSSRFontStylesLocal, getSSRFontPreloads as _getSSRFontPreloadsLocal } from \"next/font/local\";\nimport { sanitizeDestination as sanitizeDestinationLocal } from ${JSON.stringify(resolveEntryPath(\"../config/config-matchers.js\", import.meta.url))};\nimport { runWithExecutionContext as _runWithExecutionContext, getRequestExecutionContext as _getRequestExecutionContext } from ${JSON.stringify(_requestContextShimPath)};\nimport { buildRouteTrie as _buildRouteTrie, trieMatch as _trieMatch } from ${JSON.stringify(_routeTriePath)};\nimport { reportRequestError as _reportRequestError } from \"vinext/instrumentation\";\nimport { resolvePagesI18nRequest } from ${JSON.stringify(_pagesI18nPath)};\nimport { createPagesReqRes as __createPagesReqRes } from ${JSON.stringify(_pagesNodeCompatPath)};\nimport { handlePagesApiRoute as __handlePagesApiRoute } from ${JSON.stringify(_pagesApiRoutePath)};\nimport {\n isrGet as __sharedIsrGet,\n isrSet as __sharedIsrSet,\n isrCacheKey as __sharedIsrCacheKey,\n triggerBackgroundRegeneration as __sharedTriggerBackgroundRegeneration,\n} from ${JSON.stringify(_isrCachePath)};\nimport { getScriptNonceFromHeaderSources as __getScriptNonceFromHeaderSources } from ${JSON.stringify(_cspPath)};\nimport { resolvePagesPageData as __resolvePagesPageData } from ${JSON.stringify(_pagesPageDataPath)};\nimport { 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\nfunction isrGet(key) {\n return __sharedIsrGet(key);\n}\nfunction isrSet(key, data, revalidateSeconds, tags) {\n return __sharedIsrSet(key, data, revalidateSeconds, tags);\n}\nfunction triggerBackgroundRegeneration(key, renderFn) {\n return __sharedTriggerBackgroundRegeneration(key, renderFn);\n}\nfunction isrCacheKey(router, pathname) {\n return __sharedIsrCacheKey(router, pathname, buildId || undefined);\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, scriptNonce) {\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 const nonceAttr = __createNonceAttribute(scriptNonce);\n\n // Load the set of lazy chunk filenames (only reachable via dynamic imports).\n // These should NOT get <link rel=\"modulepreload\"> or <script type=\"module\">\n // tags — they are fetched on demand when the dynamic import() executes (e.g.\n // chunks behind React.lazy() or next/dynamic boundaries).\n var lazyChunks = (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_LAZY_CHUNKS__) || null;\n var lazySet = lazyChunks && lazyChunks.length > 0 ? new Set(lazyChunks) : null;\n\n // Inject the client entry script if embedded by vinext:cloudflare-build\n if (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_CLIENT_ENTRY__) {\n const entry = globalThis.__VINEXT_CLIENT_ENTRY__;\n seen.add(entry);\n tags.push('<link rel=\"modulepreload\"' + nonceAttr + ' href=\"/' + entry + '\" />');\n tags.push('<script type=\"module\"' + nonceAttr + ' src=\"/' + entry + '\" crossorigin></script>');\n }\n if (m) {\n // Always inject shared chunks (framework, vinext runtime, entry) and\n // page-specific chunks. The manifest maps module file paths to their\n // associated JS/CSS assets.\n //\n // For page-specific injection, the module IDs may be absolute paths\n // while the manifest uses relative paths. Try both the original ID\n // and a suffix match to find the correct manifest entry.\n var allFiles = [];\n\n if (moduleIds && moduleIds.length > 0) {\n // Collect assets for the requested page modules\n for (var mi = 0; mi < moduleIds.length; mi++) {\n var id = moduleIds[mi];\n var files = 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\"' + nonceAttr + ' href=\"/' + tf + '\" />');\n } else if (tf.endsWith(\".js\")) {\n // Skip lazy chunks — they are behind dynamic import() boundaries\n // (React.lazy, next/dynamic) and should only be fetched on demand.\n if (lazySet && lazySet.has(tf)) continue;\n tags.push('<link rel=\"modulepreload\"' + nonceAttr + ' href=\"/' + tf + '\" />');\n tags.push('<script type=\"module\"' + nonceAttr + ' src=\"/' + tf + '\" crossorigin></script>');\n }\n }\n }\n return tags.join(\"\\\\n \");\n}\n\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\nexport async function renderPage(request, url, manifest, ctx, middlewareHeaders) {\n if (ctx) return _runWithExecutionContext(ctx, () => _renderPage(request, url, manifest, middlewareHeaders));\n return _renderPage(request, url, manifest, middlewareHeaders);\n}\n\nasync function _renderPage(request, url, manifest, middlewareHeaders) {\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 const routePattern = patternToNextFormat(route.pattern);\n if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\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 const scriptNonce = __getScriptNonceFromHeaderSources(request.headers, middlewareHeaders);\n // Build font Link header early so it's available for ISR cached responses too.\n // Font preloads are module-level state populated at import time and persist across requests.\n var _fontLinkHeader = \"\";\n var _allFp = [];\n try {\n var _fpGoogle = typeof _getSSRFontPreloadsGoogle === \"function\" ? _getSSRFontPreloadsGoogle() : [];\n var _fpLocal = typeof _getSSRFontPreloadsLocal === \"function\" ? _getSSRFontPreloadsLocal() : [];\n _allFp = _fpGoogle.concat(_fpLocal);\n if (_allFp.length > 0) {\n _fontLinkHeader = _allFp.map(function(p) { return \"<\" + p.href + \">; rel=preload; as=font; type=\" + p.type + \"; crossorigin\"; }).join(\", \");\n }\n } catch (e) { /* font preloads not available */ }\n const query = parseQuery(routeUrl);\n const pageDataResult = await __resolvePagesPageData({\n applyRequestContexts() {\n if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query: { ...params, ...query },\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 },\n buildId,\n createGsspReqRes() {\n return __createPagesReqRes({ body: undefined, query, request, url: routeUrl });\n },\n createPageElement(currentPageProps) {\n var currentElement = AppComponent\n ? React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps })\n : React.createElement(PageComponent, currentPageProps);\n return wrapWithRouterContext(currentElement);\n },\n fontLinkHeader: _fontLinkHeader,\n i18n: {\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n },\n isrCacheKey,\n isrGet,\n isrSet,\n pageModule,\n params,\n query,\n renderIsrPassToStringAsync,\n route: {\n isDynamic: route.isDynamic,\n },\n routePattern,\n routeUrl,\n runInFreshUnifiedContext(callback) {\n var revalCtx = _createUnifiedCtx({\n executionContext: _getRequestExecutionContext(),\n });\n return _runWithUnifiedCtx(revalCtx, async () => {\n ensureFetchPatch();\n return callback();\n });\n },\n safeJsonStringify,\n sanitizeDestination: sanitizeDestinationLocal,\n scriptNonce,\n triggerBackgroundRegeneration,\n });\n if (pageDataResult.kind === \"response\") {\n return pageDataResult.response;\n }\n let pageProps = pageDataResult.pageProps;\n var gsspRes = pageDataResult.gsspRes;\n let isrRevalidateSeconds = pageDataResult.isrRevalidateSeconds;\n\n const pageModuleIds = route.filePath ? [route.filePath] : [];\n const assetTags = collectAssetTags(manifest, pageModuleIds, scriptNonce);\n\n return __renderPagesPageResponse({\n assetTags,\n buildId,\n clearSsrContext() {\n if (typeof setSSRContext === \"function\") setSSRContext(null);\n },\n createPageElement(currentPageProps) {\n var currentElement;\n if (AppComponent) {\n currentElement = React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps });\n } else {\n currentElement = React.createElement(PageComponent, currentPageProps);\n }\n return wrapWithRouterContext(currentElement);\n },\n DocumentComponent,\n flushPreloads: typeof flushPreloads === \"function\" ? flushPreloads : undefined,\n fontLinkHeader: _fontLinkHeader,\n fontPreloads: _allFp,\n getFontLinks() {\n try {\n return typeof _getSSRFontLinks === \"function\" ? _getSSRFontLinks() : [];\n } catch (e) {\n return [];\n }\n },\n getFontStyles() {\n try {\n var allFontStyles = [];\n if (typeof _getSSRFontStylesGoogle === \"function\") allFontStyles.push(..._getSSRFontStylesGoogle());\n if (typeof _getSSRFontStylesLocal === \"function\") allFontStyles.push(..._getSSRFontStylesLocal());\n return allFontStyles;\n } catch (e) {\n return [];\n }\n },\n getSSRHeadHTML: typeof getSSRHeadHTML === \"function\" ? getSSRHeadHTML : undefined,\n gsspRes,\n isrCacheKey,\n 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,\n routeUrl,\n safeJsonStringify,\n scriptNonce,\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 return __handlePagesApiRoute({\n match,\n request,\n url,\n reportRequestError(error, routePattern) {\n console.error(\"[vinext] API error:\", error);\n void _reportRequestError(\n error,\n { path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },\n { routerKind: \"Pages Router\", routePath: routePattern, routeType: \"route\" },\n );\n },\n });\n}\n\n${middlewareExportCode}\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,MAAM,0BAA0B,iBAAiB,+BAA+B,OAAO,KAAK,IAAI;AAChG,MAAM,iBAAiB,iBAAiB,4BAA4B,OAAO,KAAK,IAAI;AACpF,MAAM,iBAAiB,iBAAiB,2BAA2B,OAAO,KAAK,IAAI;AACnF,MAAM,yBAAyB,iBAC7B,oCACA,OAAO,KAAK,IACb;AACD,MAAM,qBAAqB,iBAAiB,gCAAgC,OAAO,KAAK,IAAI;AAC5F,MAAM,uBAAuB,iBAAiB,kCAAkC,OAAO,KAAK,IAAI;AAChG,MAAM,qBAAqB,iBAAiB,gCAAgC,OAAO,KAAK,IAAI;AAC5F,MAAM,gBAAgB,iBAAiB,0BAA0B,OAAO,KAAK,IAAI;AACjF,MAAM,WAAW,iBAAiB,oBAAoB,OAAO,KAAK,IAAI;;;;;AAMtE,eAAsB,oBACpB,UACA,YACA,aACA,gBACA,qBACiB;CACjB,MAAM,aAAa,MAAM,YAAY,UAAU,YAAY,gBAAgB,YAAY;CACvF,MAAM,YAAY,MAAM,UAAU,UAAU,YAAY,gBAAgB,YAAY;CAIpF,MAAM,cAAc,WAAW,KAAK,GAAU,MAAc;EAC1D,MAAM,UAAU,EAAE,SAAS,QAAQ,OAAO,IAAI;AAC9C,SAAO,oBAAoB,EAAE,QAAQ,KAAK,UAAU,QAAQ,CAAC;GAC7D;CAEF,MAAM,aAAa,UAAU,KAAK,GAAU,MAAc;EACxD,MAAM,UAAU,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uB,CAAC;EAC5G,0BAA0B;EAC1B,qBAAqB;;EAErB,wBAAwB;;;qBAGL,eAAe;;;kBAGlB,YAAY;;;8BAGA,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoC7C,YAAY,KAAK,KAAK,CAAC;EACvB,WAAW,KAAK,KAAK,CAAC;;EAEtB,cAAc;EACd,cAAc;;;EAGd,iBAAiB,KAAK,MAAM,CAAC;;;;;EAK7B,gBAAgB,KAAK,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyb5B,qBAAqB"}
|
|
1
|
+
{"version":3,"file":"pages-server-entry.js","names":[],"sources":["../../src/entries/pages-server-entry.ts"],"sourcesContent":["/**\n * Pages Router server entry generator.\n *\n * Generates the virtual SSR server entry module (`virtual:vinext-server-entry`).\n * This is the entry point for `vite build --ssr`. It handles SSR, API routes,\n * middleware, ISR, and i18n for the Pages Router.\n *\n * Extracted from index.ts.\n */\nimport { resolveEntryPath } from \"./runtime-entry-module.js\";\nimport { pagesRouter, apiRouter, type Route } from \"../routing/pages-router.js\";\nimport { createValidFileMatcher } from \"../routing/file-matcher.js\";\nimport { type ResolvedNextConfig } from \"../config/next-config.js\";\nimport { isProxyFile } from \"../server/middleware.js\";\nimport { findFileWithExts } from \"./pages-entry-helpers.js\";\n\nconst _requestContextShimPath = resolveEntryPath(\"../shims/request-context.js\", import.meta.url);\nconst _middlewareRuntimePath = resolveEntryPath(\"../server/middleware-runtime.js\", import.meta.url);\nconst _routeTriePath = resolveEntryPath(\"../routing/route-trie.js\", import.meta.url);\nconst _pagesI18nPath = resolveEntryPath(\"../server/pages-i18n.js\", import.meta.url);\nconst _pagesPageResponsePath = resolveEntryPath(\n \"../server/pages-page-response.js\",\n import.meta.url,\n);\nconst _pagesPageDataPath = resolveEntryPath(\"../server/pages-page-data.js\", import.meta.url);\nconst _pagesNodeCompatPath = resolveEntryPath(\"../server/pages-node-compat.js\", import.meta.url);\nconst _pagesApiRoutePath = resolveEntryPath(\"../server/pages-api-route.js\", import.meta.url);\nconst _isrCachePath = resolveEntryPath(\"../server/isr-cache.js\", import.meta.url);\nconst _cspPath = resolveEntryPath(\"../server/csp.js\", import.meta.url);\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(\n (r: Route, i: number) =>\n ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: api_${i} }`,\n );\n\n // Check for _app 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, \"/\"))};`\n : \"\";\n\n // The matcher config is read from the middleware module at request time.\n // The generated entry only wires the user module into the shared runtime\n // helper; matcher, execution, waitUntil, and result shaping live in normal\n // TypeScript modules so dev/prod paths cannot drift.\n const middlewareExportCode = middlewarePath\n ? `\nexport async function runMiddleware(request, ctx) {\n return __runGeneratedMiddleware({\n basePath: vinextConfig.basePath,\n ctx,\n i18nConfig,\n isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},\n module: middlewareModule,\n request,\n });\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 { _runWithCacheState } from \"next/cache\";\nimport { runWithPrivateCache } from \"vinext/cache-runtime\";\nimport { ensureFetchPatch, runWithFetchCache } from \"vinext/fetch-cache\";\nimport { runWithRequestContext as _runWithUnifiedCtx, createRequestContext as _createUnifiedCtx } from \"vinext/unified-request-context\";\nimport \"vinext/router-state\";\nimport { runWithServerInsertedHTMLState } from \"vinext/navigation-state\";\nimport { runWithHeadState } from \"vinext/head-state\";\nimport \"vinext/i18n-state\";\nimport { setI18nContext } from \"vinext/i18n-context\";\nimport { createNonceAttribute as __createNonceAttribute, safeJsonStringify } from \"vinext/html\";\nimport { getSSRFontLinks as _getSSRFontLinks, getSSRFontStyles as _getSSRFontStylesGoogle, getSSRFontPreloads as _getSSRFontPreloadsGoogle } from \"next/font/google\";\nimport { getSSRFontStyles as _getSSRFontStylesLocal, getSSRFontPreloads as _getSSRFontPreloadsLocal } from \"next/font/local\";\nimport { sanitizeDestination as sanitizeDestinationLocal } from ${JSON.stringify(resolveEntryPath(\"../config/config-matchers.js\", import.meta.url))};\nimport { runWithExecutionContext as _runWithExecutionContext, getRequestExecutionContext as _getRequestExecutionContext } from ${JSON.stringify(_requestContextShimPath)};\nimport { runGeneratedMiddleware as __runGeneratedMiddleware } from ${JSON.stringify(_middlewareRuntimePath)};\nimport { buildRouteTrie as _buildRouteTrie, trieMatch as _trieMatch } from ${JSON.stringify(_routeTriePath)};\nimport { reportRequestError as _reportRequestError } from \"vinext/instrumentation\";\nimport { resolvePagesI18nRequest } from ${JSON.stringify(_pagesI18nPath)};\nimport { createPagesReqRes as __createPagesReqRes } from ${JSON.stringify(_pagesNodeCompatPath)};\nimport { handlePagesApiRoute as __handlePagesApiRoute } from ${JSON.stringify(_pagesApiRoutePath)};\nimport {\n isrGet as __sharedIsrGet,\n isrSet as __sharedIsrSet,\n isrCacheKey as __sharedIsrCacheKey,\n triggerBackgroundRegeneration as __sharedTriggerBackgroundRegeneration,\n} from ${JSON.stringify(_isrCachePath)};\nimport { getScriptNonceFromHeaderSources as __getScriptNonceFromHeaderSources } from ${JSON.stringify(_cspPath)};\nimport { resolvePagesPageData as __resolvePagesPageData } from ${JSON.stringify(_pagesPageDataPath)};\nimport { 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\nfunction isrGet(key) {\n return __sharedIsrGet(key);\n}\nfunction isrSet(key, data, revalidateSeconds, tags) {\n return __sharedIsrSet(key, data, revalidateSeconds, tags);\n}\nfunction triggerBackgroundRegeneration(key, renderFn, errorContext) {\n return __sharedTriggerBackgroundRegeneration(key, renderFn, errorContext);\n}\nfunction isrCacheKey(router, pathname) {\n return __sharedIsrCacheKey(router, pathname, buildId || undefined);\n}\n\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, scriptNonce) {\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 const nonceAttr = __createNonceAttribute(scriptNonce);\n\n // Load the set of lazy chunk filenames (only reachable via dynamic imports).\n // These should NOT get <link rel=\"modulepreload\"> or <script type=\"module\">\n // tags — they are fetched on demand when the dynamic import() executes (e.g.\n // chunks behind React.lazy() or next/dynamic boundaries).\n var lazyChunks = (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_LAZY_CHUNKS__) || null;\n var lazySet = lazyChunks && lazyChunks.length > 0 ? new Set(lazyChunks) : null;\n\n // Inject the client entry script if embedded by vinext:cloudflare-build\n if (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_CLIENT_ENTRY__) {\n const entry = globalThis.__VINEXT_CLIENT_ENTRY__;\n seen.add(entry);\n tags.push('<link rel=\"modulepreload\"' + nonceAttr + ' href=\"/' + entry + '\" />');\n tags.push('<script type=\"module\"' + nonceAttr + ' src=\"/' + entry + '\" crossorigin></script>');\n }\n if (m) {\n // Always inject shared chunks (framework, vinext runtime, entry) and\n // page-specific chunks. The manifest maps module file paths to their\n // associated JS/CSS assets.\n //\n // For page-specific injection, the module IDs may be absolute paths\n // while the manifest uses relative paths. Try both the original ID\n // and a suffix match to find the correct manifest entry.\n var allFiles = [];\n\n if (moduleIds && moduleIds.length > 0) {\n // Collect assets for the requested page modules\n for (var mi = 0; mi < moduleIds.length; mi++) {\n var id = moduleIds[mi];\n var files = 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\"' + nonceAttr + ' href=\"/' + tf + '\" />');\n } else if (tf.endsWith(\".js\")) {\n // Skip lazy chunks — they are behind dynamic import() boundaries\n // (React.lazy, next/dynamic) and should only be fetched on demand.\n if (lazySet && lazySet.has(tf)) continue;\n tags.push('<link rel=\"modulepreload\"' + nonceAttr + ' href=\"/' + tf + '\" />');\n tags.push('<script type=\"module\"' + nonceAttr + ' src=\"/' + tf + '\" crossorigin></script>');\n }\n }\n }\n return tags.join(\"\\\\n \");\n}\n\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\nexport async function renderPage(request, url, manifest, ctx, middlewareHeaders) {\n if (ctx) return _runWithExecutionContext(ctx, () => _renderPage(request, url, manifest, middlewareHeaders));\n return _renderPage(request, url, manifest, middlewareHeaders);\n}\n\nasync function _renderPage(request, url, manifest, middlewareHeaders) {\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 const routePattern = patternToNextFormat(route.pattern);\n if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\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 const scriptNonce = __getScriptNonceFromHeaderSources(request.headers, middlewareHeaders);\n // Build font Link header early so it's available for ISR cached responses too.\n // Font preloads are module-level state populated at import time and persist across requests.\n var _fontLinkHeader = \"\";\n var _allFp = [];\n try {\n var _fpGoogle = typeof _getSSRFontPreloadsGoogle === \"function\" ? _getSSRFontPreloadsGoogle() : [];\n var _fpLocal = typeof _getSSRFontPreloadsLocal === \"function\" ? _getSSRFontPreloadsLocal() : [];\n _allFp = _fpGoogle.concat(_fpLocal);\n if (_allFp.length > 0) {\n _fontLinkHeader = _allFp.map(function(p) { return \"<\" + p.href + \">; rel=preload; as=font; type=\" + p.type + \"; crossorigin\"; }).join(\", \");\n }\n } catch (e) { /* font preloads not available */ }\n const query = parseQuery(routeUrl);\n const pageDataResult = await __resolvePagesPageData({\n applyRequestContexts() {\n if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query: { ...params, ...query },\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 },\n buildId,\n createGsspReqRes() {\n return __createPagesReqRes({ body: undefined, query, request, url: routeUrl });\n },\n createPageElement(currentPageProps) {\n var currentElement = AppComponent\n ? React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps })\n : React.createElement(PageComponent, currentPageProps);\n return wrapWithRouterContext(currentElement);\n },\n fontLinkHeader: _fontLinkHeader,\n i18n: {\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n },\n isrCacheKey,\n isrGet,\n isrSet,\n pageModule,\n params,\n query,\n renderIsrPassToStringAsync,\n route: {\n isDynamic: route.isDynamic,\n },\n routePattern,\n routeUrl,\n runInFreshUnifiedContext(callback) {\n var revalCtx = _createUnifiedCtx({\n executionContext: _getRequestExecutionContext(),\n });\n return _runWithUnifiedCtx(revalCtx, async () => {\n ensureFetchPatch();\n return callback();\n });\n },\n safeJsonStringify,\n sanitizeDestination: sanitizeDestinationLocal,\n scriptNonce,\n triggerBackgroundRegeneration,\n });\n if (pageDataResult.kind === \"response\") {\n return pageDataResult.response;\n }\n let pageProps = pageDataResult.pageProps;\n var gsspRes = pageDataResult.gsspRes;\n let isrRevalidateSeconds = pageDataResult.isrRevalidateSeconds;\n\n const pageModuleIds = route.filePath ? [route.filePath] : [];\n const assetTags = collectAssetTags(manifest, pageModuleIds, scriptNonce);\n\n return __renderPagesPageResponse({\n assetTags,\n buildId,\n clearSsrContext() {\n if (typeof setSSRContext === \"function\") setSSRContext(null);\n },\n createPageElement(currentPageProps) {\n var currentElement;\n if (AppComponent) {\n currentElement = React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps });\n } else {\n currentElement = React.createElement(PageComponent, currentPageProps);\n }\n return wrapWithRouterContext(currentElement);\n },\n DocumentComponent,\n flushPreloads: typeof flushPreloads === \"function\" ? flushPreloads : undefined,\n fontLinkHeader: _fontLinkHeader,\n fontPreloads: _allFp,\n getFontLinks() {\n try {\n return typeof _getSSRFontLinks === \"function\" ? _getSSRFontLinks() : [];\n } catch (e) {\n return [];\n }\n },\n getFontStyles() {\n try {\n var allFontStyles = [];\n if (typeof _getSSRFontStylesGoogle === \"function\") allFontStyles.push(..._getSSRFontStylesGoogle());\n if (typeof _getSSRFontStylesLocal === \"function\") allFontStyles.push(..._getSSRFontStylesLocal());\n return allFontStyles;\n } catch (e) {\n return [];\n }\n },\n getSSRHeadHTML: typeof getSSRHeadHTML === \"function\" ? getSSRHeadHTML : undefined,\n gsspRes,\n isrCacheKey,\n 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,\n routeUrl,\n safeJsonStringify,\n scriptNonce,\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 return __handlePagesApiRoute({\n match,\n request,\n url,\n reportRequestError(error, routePattern) {\n console.error(\"[vinext] API error:\", error);\n void _reportRequestError(\n error,\n { path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },\n { routerKind: \"Pages Router\", routePath: routePattern, routeType: \"route\" },\n );\n },\n });\n}\n\n${middlewareExportCode}\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAM,0BAA0B,iBAAiB,+BAA+B,OAAO,KAAK,IAAI;AAChG,MAAM,yBAAyB,iBAAiB,mCAAmC,OAAO,KAAK,IAAI;AACnG,MAAM,iBAAiB,iBAAiB,4BAA4B,OAAO,KAAK,IAAI;AACpF,MAAM,iBAAiB,iBAAiB,2BAA2B,OAAO,KAAK,IAAI;AACnF,MAAM,yBAAyB,iBAC7B,oCACA,OAAO,KAAK,IACb;AACD,MAAM,qBAAqB,iBAAiB,gCAAgC,OAAO,KAAK,IAAI;AAC5F,MAAM,uBAAuB,iBAAiB,kCAAkC,OAAO,KAAK,IAAI;AAChG,MAAM,qBAAqB,iBAAiB,gCAAgC,OAAO,KAAK,IAAI;AAC5F,MAAM,gBAAgB,iBAAiB,0BAA0B,OAAO,KAAK,IAAI;AACjF,MAAM,WAAW,iBAAiB,oBAAoB,OAAO,KAAK,IAAI;;;;;AAMtE,eAAsB,oBACpB,UACA,YACA,aACA,gBACA,qBACiB;CACjB,MAAM,aAAa,MAAM,YAAY,UAAU,YAAY,gBAAgB,YAAY;CACvF,MAAM,YAAY,MAAM,UAAU,UAAU,YAAY,gBAAgB,YAAY;CAIpF,MAAM,cAAc,WAAW,KAAK,GAAU,MAAc;EAC1D,MAAM,UAAU,EAAE,SAAS,QAAQ,OAAO,IAAI;AAC9C,SAAO,oBAAoB,EAAE,QAAQ,KAAK,UAAU,QAAQ,CAAC;GAC7D;CAEF,MAAM,aAAa,UAAU,KAAK,GAAU,MAAc;EACxD,MAAM,UAAU,EAAE,SAAS,QAAQ,OAAO,IAAI;AAC9C,SAAO,mBAAmB,EAAE,QAAQ,KAAK,UAAU,QAAQ,CAAC;GAC5D;CAGF,MAAM,mBAAmB,WAAW,KAAK,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