vinext 0.0.52 → 0.0.53

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.
Files changed (238) hide show
  1. package/README.md +1 -1
  2. package/dist/build/clean-output.d.ts +14 -0
  3. package/dist/build/clean-output.js +36 -0
  4. package/dist/build/clean-output.js.map +1 -0
  5. package/dist/build/prerender.d.ts +6 -2
  6. package/dist/build/prerender.js +49 -11
  7. package/dist/build/prerender.js.map +1 -1
  8. package/dist/build/run-prerender.js +10 -1
  9. package/dist/build/run-prerender.js.map +1 -1
  10. package/dist/build/static-export.d.ts +5 -0
  11. package/dist/build/static-export.js +8 -3
  12. package/dist/build/static-export.js.map +1 -1
  13. package/dist/cli.js +19 -4
  14. package/dist/cli.js.map +1 -1
  15. package/dist/client/instrumentation-client-inject.d.ts +34 -0
  16. package/dist/client/instrumentation-client-inject.js +57 -0
  17. package/dist/client/instrumentation-client-inject.js.map +1 -0
  18. package/dist/client/navigation-runtime.d.ts +14 -1
  19. package/dist/client/navigation-runtime.js +16 -1
  20. package/dist/client/navigation-runtime.js.map +1 -1
  21. package/dist/client/vinext-next-data.d.ts +2 -1
  22. package/dist/client/vinext-next-data.js.map +1 -1
  23. package/dist/client/window-next.d.ts +10 -2
  24. package/dist/client/window-next.js.map +1 -1
  25. package/dist/cloudflare/tpr.js +1 -1
  26. package/dist/cloudflare/tpr.js.map +1 -1
  27. package/dist/config/config-matchers.js +2 -1
  28. package/dist/config/config-matchers.js.map +1 -1
  29. package/dist/config/next-config.d.ts +12 -3
  30. package/dist/config/next-config.js +44 -14
  31. package/dist/config/next-config.js.map +1 -1
  32. package/dist/deploy.js +29 -7
  33. package/dist/deploy.js.map +1 -1
  34. package/dist/entries/app-rsc-entry.d.ts +4 -2
  35. package/dist/entries/app-rsc-entry.js +23 -3
  36. package/dist/entries/app-rsc-entry.js.map +1 -1
  37. package/dist/entries/pages-client-entry.js +22 -1
  38. package/dist/entries/pages-client-entry.js.map +1 -1
  39. package/dist/entries/pages-server-entry.js +211 -31
  40. package/dist/entries/pages-server-entry.js.map +1 -1
  41. package/dist/index.js +29 -6
  42. package/dist/index.js.map +1 -1
  43. package/dist/plugins/fonts.js +25 -2
  44. package/dist/plugins/fonts.js.map +1 -1
  45. package/dist/routing/route-trie.js +13 -18
  46. package/dist/routing/route-trie.js.map +1 -1
  47. package/dist/routing/utils.d.ts +11 -1
  48. package/dist/routing/utils.js +15 -1
  49. package/dist/routing/utils.js.map +1 -1
  50. package/dist/server/api-handler.js +18 -9
  51. package/dist/server/api-handler.js.map +1 -1
  52. package/dist/server/app-browser-action-result.d.ts +16 -1
  53. package/dist/server/app-browser-action-result.js +15 -1
  54. package/dist/server/app-browser-action-result.js.map +1 -1
  55. package/dist/server/app-browser-entry.js +22 -12
  56. package/dist/server/app-browser-entry.js.map +1 -1
  57. package/dist/server/app-elements.js +1 -1
  58. package/dist/server/app-fallback-renderer.d.ts +12 -3
  59. package/dist/server/app-fallback-renderer.js +10 -5
  60. package/dist/server/app-fallback-renderer.js.map +1 -1
  61. package/dist/server/app-history-state.js +6 -2
  62. package/dist/server/app-history-state.js.map +1 -1
  63. package/dist/server/app-interception-context-header.d.ts +33 -0
  64. package/dist/server/app-interception-context-header.js +44 -0
  65. package/dist/server/app-interception-context-header.js.map +1 -0
  66. package/dist/server/app-mounted-slots-header.d.ts +19 -0
  67. package/dist/server/app-mounted-slots-header.js +40 -1
  68. package/dist/server/app-mounted-slots-header.js.map +1 -1
  69. package/dist/server/app-optimistic-routing.js +26 -18
  70. package/dist/server/app-optimistic-routing.js.map +1 -1
  71. package/dist/server/app-page-boundary-render.d.ts +1 -0
  72. package/dist/server/app-page-boundary-render.js +2 -0
  73. package/dist/server/app-page-boundary-render.js.map +1 -1
  74. package/dist/server/app-page-boundary.d.ts +1 -0
  75. package/dist/server/app-page-boundary.js +2 -0
  76. package/dist/server/app-page-boundary.js.map +1 -1
  77. package/dist/server/app-page-cache.d.ts +2 -0
  78. package/dist/server/app-page-cache.js +7 -1
  79. package/dist/server/app-page-cache.js.map +1 -1
  80. package/dist/server/app-page-dispatch.d.ts +3 -0
  81. package/dist/server/app-page-dispatch.js +11 -4
  82. package/dist/server/app-page-dispatch.js.map +1 -1
  83. package/dist/server/app-page-element-builder.d.ts +2 -1
  84. package/dist/server/app-page-element-builder.js +5 -2
  85. package/dist/server/app-page-element-builder.js.map +1 -1
  86. package/dist/server/app-page-execution.d.ts +1 -0
  87. package/dist/server/app-page-execution.js +2 -0
  88. package/dist/server/app-page-execution.js.map +1 -1
  89. package/dist/server/app-page-head.d.ts +1 -0
  90. package/dist/server/app-page-head.js +8 -0
  91. package/dist/server/app-page-head.js.map +1 -1
  92. package/dist/server/app-page-render-observation.js +1 -1
  93. package/dist/server/app-page-render.d.ts +1 -0
  94. package/dist/server/app-page-render.js +5 -2
  95. package/dist/server/app-page-render.js.map +1 -1
  96. package/dist/server/app-page-response.d.ts +11 -1
  97. package/dist/server/app-page-response.js +14 -2
  98. package/dist/server/app-page-response.js.map +1 -1
  99. package/dist/server/app-page-route-wiring.d.ts +1 -0
  100. package/dist/server/app-page-route-wiring.js +19 -6
  101. package/dist/server/app-page-route-wiring.js.map +1 -1
  102. package/dist/server/app-page-stream.d.ts +1 -0
  103. package/dist/server/app-page-stream.js +2 -0
  104. package/dist/server/app-page-stream.js.map +1 -1
  105. package/dist/server/app-route-handler-dispatch.d.ts +1 -0
  106. package/dist/server/app-route-handler-dispatch.js +3 -0
  107. package/dist/server/app-route-handler-dispatch.js.map +1 -1
  108. package/dist/server/app-route-handler-execution.d.ts +1 -0
  109. package/dist/server/app-route-handler-execution.js +1 -0
  110. package/dist/server/app-route-handler-execution.js.map +1 -1
  111. package/dist/server/app-route-handler-response.js +1 -1
  112. package/dist/server/app-rsc-handler.d.ts +2 -0
  113. package/dist/server/app-rsc-handler.js +18 -9
  114. package/dist/server/app-rsc-handler.js.map +1 -1
  115. package/dist/server/app-rsc-request-normalization.js +3 -2
  116. package/dist/server/app-rsc-request-normalization.js.map +1 -1
  117. package/dist/server/app-segment-config.d.ts +4 -1
  118. package/dist/server/app-segment-config.js +6 -1
  119. package/dist/server/app-segment-config.js.map +1 -1
  120. package/dist/server/app-server-action-execution.d.ts +1 -0
  121. package/dist/server/app-server-action-execution.js +4 -0
  122. package/dist/server/app-server-action-execution.js.map +1 -1
  123. package/dist/server/app-ssr-entry.js +39 -3
  124. package/dist/server/app-ssr-entry.js.map +1 -1
  125. package/dist/server/app-ssr-stream.d.ts +24 -1
  126. package/dist/server/app-ssr-stream.js +78 -5
  127. package/dist/server/app-ssr-stream.js.map +1 -1
  128. package/dist/server/app-static-generation.d.ts +1 -0
  129. package/dist/server/app-static-generation.js +2 -1
  130. package/dist/server/app-static-generation.js.map +1 -1
  131. package/dist/server/default-not-found-module.d.ts +20 -0
  132. package/dist/server/default-not-found-module.js +20 -0
  133. package/dist/server/default-not-found-module.js.map +1 -0
  134. package/dist/server/dev-server.d.ts +1 -1
  135. package/dist/server/dev-server.js +23 -7
  136. package/dist/server/dev-server.js.map +1 -1
  137. package/dist/server/headers.d.ts +5 -1
  138. package/dist/server/headers.js +5 -1
  139. package/dist/server/headers.js.map +1 -1
  140. package/dist/server/image-optimization.d.ts +13 -4
  141. package/dist/server/image-optimization.js +15 -4
  142. package/dist/server/image-optimization.js.map +1 -1
  143. package/dist/server/middleware.js +1 -1
  144. package/dist/server/middleware.js.map +1 -1
  145. package/dist/server/pages-api-route.d.ts +18 -0
  146. package/dist/server/pages-api-route.js +3 -1
  147. package/dist/server/pages-api-route.js.map +1 -1
  148. package/dist/server/pages-body-parser-config.d.ts +60 -0
  149. package/dist/server/pages-body-parser-config.js +79 -0
  150. package/dist/server/pages-body-parser-config.js.map +1 -0
  151. package/dist/server/pages-data-route.js +1 -0
  152. package/dist/server/pages-data-route.js.map +1 -1
  153. package/dist/server/pages-default-404.d.ts +31 -0
  154. package/dist/server/pages-default-404.js +40 -0
  155. package/dist/server/pages-default-404.js.map +1 -0
  156. package/dist/server/pages-node-compat.d.ts +10 -0
  157. package/dist/server/pages-node-compat.js +12 -1
  158. package/dist/server/pages-node-compat.js.map +1 -1
  159. package/dist/server/pages-page-data.d.ts +40 -0
  160. package/dist/server/pages-page-data.js +16 -14
  161. package/dist/server/pages-page-data.js.map +1 -1
  162. package/dist/server/pages-page-response.d.ts +2 -0
  163. package/dist/server/pages-page-response.js +11 -8
  164. package/dist/server/pages-page-response.js.map +1 -1
  165. package/dist/server/prerender-route-params.d.ts +14 -0
  166. package/dist/server/prerender-route-params.js +94 -0
  167. package/dist/server/prerender-route-params.js.map +1 -0
  168. package/dist/server/prod-server.d.ts +3 -23
  169. package/dist/server/prod-server.js +40 -57
  170. package/dist/server/prod-server.js.map +1 -1
  171. package/dist/server/proxy-trust.d.ts +41 -0
  172. package/dist/server/proxy-trust.js +70 -0
  173. package/dist/server/proxy-trust.js.map +1 -0
  174. package/dist/server/request-pipeline.d.ts +3 -3
  175. package/dist/server/request-pipeline.js +5 -4
  176. package/dist/server/request-pipeline.js.map +1 -1
  177. package/dist/server/seed-cache.js +12 -6
  178. package/dist/server/seed-cache.js.map +1 -1
  179. package/dist/server/static-file-cache.js +1 -1
  180. package/dist/server/static-file-cache.js.map +1 -1
  181. package/dist/server/streaming-metadata.d.ts +5 -0
  182. package/dist/server/streaming-metadata.js +10 -0
  183. package/dist/server/streaming-metadata.js.map +1 -0
  184. package/dist/shims/app-router-scroll-state.d.ts +12 -0
  185. package/dist/shims/app-router-scroll-state.js +38 -0
  186. package/dist/shims/app-router-scroll-state.js.map +1 -0
  187. package/dist/shims/app-router-scroll.d.ts +14 -0
  188. package/dist/shims/app-router-scroll.js +100 -0
  189. package/dist/shims/app-router-scroll.js.map +1 -0
  190. package/dist/shims/before-interactive-context.d.ts +30 -0
  191. package/dist/shims/before-interactive-context.js +10 -0
  192. package/dist/shims/before-interactive-context.js.map +1 -0
  193. package/dist/shims/cache-runtime.d.ts +1 -1
  194. package/dist/shims/cache-runtime.js +14 -1
  195. package/dist/shims/cache-runtime.js.map +1 -1
  196. package/dist/shims/default-not-found.d.ts +12 -0
  197. package/dist/shims/default-not-found.js +61 -0
  198. package/dist/shims/default-not-found.js.map +1 -0
  199. package/dist/shims/font-local.d.ts +5 -0
  200. package/dist/shims/font-local.js +6 -2
  201. package/dist/shims/font-local.js.map +1 -1
  202. package/dist/shims/head.js +4 -4
  203. package/dist/shims/head.js.map +1 -1
  204. package/dist/shims/headers.d.ts +6 -2
  205. package/dist/shims/headers.js +64 -21
  206. package/dist/shims/headers.js.map +1 -1
  207. package/dist/shims/image.d.ts +1 -1
  208. package/dist/shims/image.js +4 -4
  209. package/dist/shims/image.js.map +1 -1
  210. package/dist/shims/internal/pages-data-target.d.ts +58 -0
  211. package/dist/shims/internal/pages-data-target.js +91 -0
  212. package/dist/shims/internal/pages-data-target.js.map +1 -0
  213. package/dist/shims/internal/pages-data-url.d.ts +42 -0
  214. package/dist/shims/internal/pages-data-url.js +73 -0
  215. package/dist/shims/internal/pages-data-url.js.map +1 -0
  216. package/dist/shims/link.js +59 -9
  217. package/dist/shims/link.js.map +1 -1
  218. package/dist/shims/metadata.d.ts +2 -1
  219. package/dist/shims/metadata.js +61 -2
  220. package/dist/shims/metadata.js.map +1 -1
  221. package/dist/shims/navigation.js +32 -9
  222. package/dist/shims/navigation.js.map +1 -1
  223. package/dist/shims/router.js +376 -77
  224. package/dist/shims/router.js.map +1 -1
  225. package/dist/shims/script.js +86 -12
  226. package/dist/shims/script.js.map +1 -1
  227. package/dist/shims/server.js +1 -0
  228. package/dist/shims/server.js.map +1 -1
  229. package/dist/shims/url-utils.d.ts +2 -1
  230. package/dist/shims/url-utils.js +15 -4
  231. package/dist/shims/url-utils.js.map +1 -1
  232. package/dist/utils/html-limited-bots.d.ts +5 -0
  233. package/dist/utils/html-limited-bots.js +15 -0
  234. package/dist/utils/html-limited-bots.js.map +1 -0
  235. package/dist/utils/query.d.ts +6 -0
  236. package/dist/utils/query.js +10 -1
  237. package/dist/utils/query.js.map +1 -1
  238. package/package.json +1 -1
@@ -19,6 +19,7 @@ const _pagesI18nPath = resolveEntryPath("../server/pages-i18n.js", import.meta.u
19
19
  const _pagesPageResponsePath = resolveEntryPath("../server/pages-page-response.js", import.meta.url);
20
20
  const _pagesPageDataPath = resolveEntryPath("../server/pages-page-data.js", import.meta.url);
21
21
  const _pagesDataRoutePath = resolveEntryPath("../server/pages-data-route.js", import.meta.url);
22
+ const _pagesDefault404Path = resolveEntryPath("../server/pages-default-404.js", import.meta.url);
22
23
  const _pagesNodeCompatPath = resolveEntryPath("../server/pages-node-compat.js", import.meta.url);
23
24
  const _pagesApiRoutePath = resolveEntryPath("../server/pages-api-route.js", import.meta.url);
24
25
  const _isrCachePath = resolveEntryPath("../server/isr-cache.js", import.meta.url);
@@ -46,9 +47,12 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
46
47
  const apiRouteEntries = apiRoutes.map((r, i) => ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: api_${i} }`);
47
48
  const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
48
49
  const docFilePath = findFileWithExts(pagesDir, "_document", fileMatcher);
50
+ const errorFilePath = findFileWithExts(pagesDir, "_error", fileMatcher);
49
51
  const appAssetPathJson = appFilePath !== null ? JSON.stringify(normalizePathSeparators(appFilePath)) : "null";
50
52
  const appImportCode = appFilePath !== null ? `import { default as AppComponent } from ${JSON.stringify(normalizePathSeparators(appFilePath))};` : `const AppComponent = null;`;
51
53
  const docImportCode = docFilePath !== null ? `import { default as DocumentComponent } from ${JSON.stringify(normalizePathSeparators(docFilePath))};` : `const DocumentComponent = null;`;
54
+ const errorAssetPathJson = errorFilePath !== null ? JSON.stringify(normalizePathSeparators(errorFilePath)) : "null";
55
+ const errorImportCode = errorFilePath !== null ? `import * as ErrorPageModule from ${JSON.stringify(normalizePathSeparators(errorFilePath))};` : `const ErrorPageModule = null;`;
52
56
  const i18nConfigJson = nextConfig?.i18n ? JSON.stringify({
53
57
  locales: nextConfig.i18n.locales,
54
58
  defaultLocale: nextConfig.i18n.defaultLocale,
@@ -93,19 +97,44 @@ if (typeof _instrumentation.onRequestError === "function") {
93
97
  const middlewareImportCode = middlewarePath ? `import * as middlewareModule from ${JSON.stringify(normalizePathSeparators(middlewarePath))};` : "";
94
98
  const middlewareExportCode = middlewarePath ? `
95
99
  export async function runMiddleware(request, ctx, options) {
96
- return __runGeneratedMiddleware({
100
+ // Auto-detect /_next/data/<buildId>/<page>.json requests so user-written
101
+ // worker entries don't need to know about the data endpoint protocol.
102
+ // Mismatched buildId → JSON 404 short-circuit. Matched → middleware sees
103
+ // the normalized page path via the request URL, and the worker sees the
104
+ // normalized URL via result.rewriteUrl (if middleware didn't already
105
+ // rewrite to something else).
106
+ const __dataNorm = __normalizePagesDataRequest(request);
107
+ if (__dataNorm.notFoundResponse) {
108
+ return { continue: false, response: __dataNorm.notFoundResponse };
109
+ }
110
+ const __result = await __runGeneratedMiddleware({
97
111
  basePath: vinextConfig.basePath,
98
112
  ctx,
99
113
  i18nConfig,
100
- isDataRequest: options?.isDataRequest === true,
114
+ isDataRequest: options?.isDataRequest === true || __dataNorm.isDataReq,
101
115
  isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},
102
116
  module: middlewareModule,
103
- request,
117
+ request: __dataNorm.request,
104
118
  trailingSlash: vinextConfig.trailingSlash,
105
119
  });
120
+ if (__dataNorm.isDataReq && __result.continue && !__result.rewriteUrl && !__result.redirectUrl) {
121
+ return { ...__result, rewriteUrl: __dataNorm.normalizedPathname + __dataNorm.search };
122
+ }
123
+ return __result;
106
124
  }
107
125
  ` : `
108
- export async function runMiddleware() { return { continue: true }; }
126
+ export async function runMiddleware(request) {
127
+ // Even without user middleware, the data-endpoint URL must be normalized so
128
+ // the worker pipeline sees the page path. Mismatched buildId → JSON 404.
129
+ const __dataNorm = __normalizePagesDataRequest(request);
130
+ if (__dataNorm.notFoundResponse) {
131
+ return { continue: false, response: __dataNorm.notFoundResponse };
132
+ }
133
+ if (__dataNorm.isDataReq) {
134
+ return { continue: true, rewriteUrl: __dataNorm.normalizedPathname + __dataNorm.search };
135
+ }
136
+ return { continue: true };
137
+ }
109
138
  `;
110
139
  return `
111
140
  import ${JSON.stringify(_serverGlobalsPath)};
@@ -142,7 +171,8 @@ import {
142
171
  } from ${JSON.stringify(_isrCachePath)};
143
172
  import { getScriptNonceFromHeaderSources as __getScriptNonceFromHeaderSources } from ${JSON.stringify(_cspPath)};
144
173
  import { resolvePagesPageData as __resolvePagesPageData } from ${JSON.stringify(_pagesPageDataPath)};
145
- import { buildNextDataJsonResponse as __buildNextDataJsonResponse, buildNextDataNotFoundResponse as __buildNextDataNotFoundResponse } from ${JSON.stringify(_pagesDataRoutePath)};
174
+ import { buildNextDataJsonResponse as __buildNextDataJsonResponse, buildNextDataNotFoundResponse as __buildNextDataNotFoundResponse, isNextDataPathname as __isNextDataPathname, parseNextDataPathname as __parseNextDataPathname } from ${JSON.stringify(_pagesDataRoutePath)};
175
+ import { buildDefaultPagesNotFoundResponse as __buildDefaultPagesNotFoundResponse } from ${JSON.stringify(_pagesDefault404Path)};
146
176
  import { renderPagesPageResponse as __renderPagesPageResponse } from ${JSON.stringify(_pagesPageResponsePath)};
147
177
  ${instrumentationImportCode}
148
178
  ${middlewareImportCode}
@@ -156,6 +186,7 @@ const i18nConfig = ${i18nConfigJson};
156
186
  // match _next/data requests against the embedded buildId without needing
157
187
  // to load next.config.js at runtime.
158
188
  export const buildId = ${buildIdJson};
189
+ const __hasMiddleware = ${JSON.stringify(Boolean(middlewarePath))};
159
190
 
160
191
  // Full resolved config for production server (embedded at build time)
161
192
  export const vinextConfig = ${vinextConfigJson};
@@ -178,6 +209,40 @@ function isrCacheKey(router, pathname) {
178
209
  return __sharedIsrCacheKey(router, pathname, buildId || undefined);
179
210
  }
180
211
 
212
+ /**
213
+ * Detect and normalize /_next/data/<buildId>/<page>.json requests in one
214
+ * place so user-written worker entries don't need to know about the data
215
+ * endpoint protocol. Returns the normalized request (with the page path as
216
+ * its URL), an isDataReq flag, and notFoundResponse when the buildId in
217
+ * the URL does not match this server's buildId — callers should return that
218
+ * response immediately so a stale client falls back to a hard navigation.
219
+ */
220
+ function __normalizePagesDataRequest(request) {
221
+ const reqUrl = new URL(request.url);
222
+ if (!__isNextDataPathname(reqUrl.pathname)) {
223
+ return { isDataReq: false, request, normalizedPathname: null, search: "", notFoundResponse: null };
224
+ }
225
+ const dataMatch = buildId ? __parseNextDataPathname(reqUrl.pathname, buildId) : null;
226
+ if (!dataMatch) {
227
+ return {
228
+ isDataReq: false,
229
+ request,
230
+ normalizedPathname: null,
231
+ search: "",
232
+ notFoundResponse: __buildNextDataNotFoundResponse(),
233
+ };
234
+ }
235
+ const normalizedUrl = new URL(reqUrl);
236
+ normalizedUrl.pathname = dataMatch.pagePathname;
237
+ return {
238
+ isDataReq: true,
239
+ request: new Request(normalizedUrl, request),
240
+ normalizedPathname: dataMatch.pagePathname,
241
+ search: reqUrl.search,
242
+ notFoundResponse: null,
243
+ };
244
+ }
245
+
181
246
  async function renderToStringAsync(element) {
182
247
  const stream = await renderToReadableStream(element);
183
248
  await stream.allReady;
@@ -204,11 +269,22 @@ ${apiImports.join("\n")}
204
269
 
205
270
  ${appImportCode}
206
271
  ${docImportCode}
272
+ ${errorImportCode}
207
273
 
208
274
  export const pageRoutes = [
209
275
  ${pageRouteEntries.join(",\n")}
210
276
  ];
211
277
  const _pageRouteTrie = _buildRouteTrie(pageRoutes);
278
+ const _errorPageRoute = ErrorPageModule
279
+ ? {
280
+ pattern: "/_error",
281
+ patternParts: ["_error"],
282
+ isDynamic: false,
283
+ params: [],
284
+ module: ErrorPageModule,
285
+ filePath: ${errorAssetPathJson},
286
+ }
287
+ : null;
212
288
 
213
289
  const apiRoutes = [
214
290
  ${apiRouteEntries.join(",\n")}
@@ -240,7 +316,14 @@ export function matchPageRoute(url, request) {
240
316
  }
241
317
 
242
318
  function parseQuery(url) {
243
- const qs = url.split("?")[1];
319
+ // Per RFC 3986 only the first "?" separates path from query, so additional
320
+ // "?" chars belong to the query string (e.g. /linker?href=/about?hello=world
321
+ // has query "href=/about?hello=world"). split("?")[1] would drop everything
322
+ // after the second "?" and strip embedded query strings from values.
323
+ const queryIndex = url.indexOf("?");
324
+ if (queryIndex === -1) return {};
325
+ const hashIndex = url.indexOf("#", queryIndex + 1);
326
+ const qs = hashIndex === -1 ? url.slice(queryIndex + 1) : url.slice(queryIndex + 1, hashIndex);
244
327
  if (!qs) return {};
245
328
  const p = new URLSearchParams(qs);
246
329
  const q = {};
@@ -268,11 +351,29 @@ function patternToNextFormat(pattern) {
268
351
  .replace(/:([^\\/]+?)(?=\\/|$)/g, "[$1]");
269
352
  }
270
353
 
271
- function collectAssetTags(manifest, moduleIds, scriptNonce) {
354
+ function resolveSsrManifest(manifest) {
272
355
  // Fall back to embedded manifest (set by vinext:cloudflare-build for Workers)
273
- const m = (manifest && Object.keys(manifest).length > 0)
356
+ return (manifest && Object.keys(manifest).length > 0)
274
357
  ? manifest
275
358
  : (typeof globalThis !== "undefined" && globalThis.__VINEXT_SSR_MANIFEST__) || null;
359
+ }
360
+
361
+ function getManifestFilesForModule(manifest, moduleId) {
362
+ if (!manifest || !moduleId) return null;
363
+
364
+ var files = manifest[moduleId];
365
+ if (files) return files;
366
+
367
+ for (var key in manifest) {
368
+ if (moduleId.endsWith("/" + key) || moduleId === key) {
369
+ return manifest[key];
370
+ }
371
+ }
372
+ return null;
373
+ }
374
+
375
+ function collectAssetTags(manifest, moduleIds, scriptNonce) {
376
+ const m = resolveSsrManifest(manifest);
276
377
  const tags = [];
277
378
  const seen = new Set();
278
379
  const nonceAttr = __createNonceAttribute(scriptNonce);
@@ -305,18 +406,7 @@ function collectAssetTags(manifest, moduleIds, scriptNonce) {
305
406
  // Collect assets for the requested page modules
306
407
  for (var mi = 0; mi < moduleIds.length; mi++) {
307
408
  var id = moduleIds[mi];
308
- var files = m[id];
309
- if (!files) {
310
- // Absolute path didn't match — try matching by suffix.
311
- // Manifest keys are relative (e.g. "pages/about.tsx") while
312
- // moduleIds may be absolute (e.g. "/home/.../pages/about.tsx").
313
- for (var mk in m) {
314
- if (id.endsWith("/" + mk) || id === mk) {
315
- files = m[mk];
316
- break;
317
- }
318
- }
319
- }
409
+ var files = getManifestFilesForModule(m, id);
320
410
  if (files) {
321
411
  for (var fi = 0; fi < files.length; fi++) allFiles.push(files[fi]);
322
412
  }
@@ -377,13 +467,43 @@ function collectAssetTags(manifest, moduleIds, scriptNonce) {
377
467
  return tags.join("\\n ");
378
468
  }
379
469
 
470
+ function resolveClientModuleUrl(manifest, moduleId) {
471
+ const files = getManifestFilesForModule(resolveSsrManifest(manifest), moduleId);
472
+ if (!files) return undefined;
473
+ for (var i = 0; i < files.length; i++) {
474
+ var file = files[i];
475
+ if (!file || !file.endsWith(".js")) continue;
476
+ if (file.charAt(0) !== "/") file = "/" + file;
477
+ return file;
478
+ }
479
+ return undefined;
480
+ }
481
+
380
482
  export async function renderPage(request, url, manifest, ctx, middlewareHeaders, options) {
381
483
  if (ctx) return _runWithExecutionContext(ctx, () => _renderPage(request, url, manifest, middlewareHeaders, options));
382
484
  return _renderPage(request, url, manifest, middlewareHeaders, options);
383
485
  }
384
486
 
385
487
  async function _renderPage(request, url, manifest, middlewareHeaders, options) {
386
- const isDataReq = !!(options && options.isDataReq);
488
+ let isDataReq = !!(options && options.isDataReq);
489
+ // Auto-detect /_next/data/... requests by inspecting the incoming request
490
+ // URL. The worker pipeline does not need to know about the data endpoint
491
+ // protocol — when it forwards an unrewritten data URL as the url arg, we
492
+ // normalize it to the page path here.
493
+ if (!isDataReq) {
494
+ const __dataNorm = __normalizePagesDataRequest(request);
495
+ if (__dataNorm.notFoundResponse) return __dataNorm.notFoundResponse;
496
+ if (__dataNorm.isDataReq) {
497
+ isDataReq = true;
498
+ if (url && url.startsWith("/_next/data/")) {
499
+ const __qs = url.includes("?") ? url.slice(url.indexOf("?")) : "";
500
+ url = __dataNorm.normalizedPathname + __qs;
501
+ }
502
+ }
503
+ }
504
+ const statusCode = options && typeof options.statusCode === "number" ? options.statusCode : undefined;
505
+ const asPath = options && typeof options.asPath === "string" ? options.asPath : undefined;
506
+ const renderErrorPageOnMiss = !(options && options.renderErrorPageOnMiss === false);
387
507
  const localeInfo = i18nConfig
388
508
  ? resolvePagesI18nRequest(
389
509
  url,
@@ -405,13 +525,29 @@ async function _renderPage(request, url, manifest, middlewareHeaders, options) {
405
525
  return new Response(null, { status: 307, headers: { Location: localeInfo.redirectUrl } });
406
526
  }
407
527
 
408
- const match = matchRoute(routeUrl, pageRoutes);
528
+ let match = matchRoute(routeUrl, pageRoutes);
529
+ let renderStatusCodeOverride = statusCode;
530
+ let renderAsPath = asPath;
409
531
  if (!match) {
410
532
  if (isDataReq) {
411
533
  return __buildNextDataNotFoundResponse();
412
534
  }
413
- return new Response("<!DOCTYPE html><html><body><h1>404 - Page not found</h1></body></html>",
414
- { status: 404, headers: { "Content-Type": "text/html" } });
535
+ if (!renderErrorPageOnMiss) {
536
+ return __buildDefaultPagesNotFoundResponse();
537
+ }
538
+ const notFoundMatch = matchRoute("/404", pageRoutes);
539
+ // matchRoute may match a catch-all (e.g. [...slug]); only use the explicit pages/404 route.
540
+ if (notFoundMatch && notFoundMatch.route.pattern === "/404") {
541
+ match = notFoundMatch;
542
+ renderStatusCodeOverride = 404;
543
+ renderAsPath = routeUrl;
544
+ } else if (_errorPageRoute) {
545
+ match = { route: _errorPageRoute, params: {} };
546
+ renderStatusCodeOverride = 404;
547
+ renderAsPath = routeUrl;
548
+ } else {
549
+ return __buildDefaultPagesNotFoundResponse();
550
+ }
415
551
  }
416
552
 
417
553
  const { route, params } = match;
@@ -422,12 +558,13 @@ async function _renderPage(request, url, manifest, middlewareHeaders, options) {
422
558
  ensureFetchPatch();
423
559
  try {
424
560
  const routePattern = patternToNextFormat(route.pattern);
561
+ const renderStatusCode = renderStatusCodeOverride ?? (routePattern === "/404" ? 404 : undefined);
425
562
  const query = mergeRouteParamsIntoQuery(parseQuery(routeUrl), params);
426
563
  if (typeof setSSRContext === "function") {
427
564
  setSSRContext({
428
565
  pathname: routePattern,
429
566
  query,
430
- asPath: routeUrl,
567
+ asPath: renderAsPath || routeUrl,
431
568
  locale: locale,
432
569
  locales: i18nConfig ? i18nConfig.locales : undefined,
433
570
  defaultLocale: currentDefaultLocale,
@@ -450,6 +587,8 @@ async function _renderPage(request, url, manifest, middlewareHeaders, options) {
450
587
  if (!PageComponent) {
451
588
  return new Response("Page has no default export", { status: 500 });
452
589
  }
590
+ const pageModuleUrl = resolveClientModuleUrl(manifest, route.filePath);
591
+ const appModuleUrl = resolveClientModuleUrl(manifest, _appAssetPath);
453
592
  const scriptNonce = __getScriptNonceFromHeaderSources(request.headers, middlewareHeaders);
454
593
  // Build font Link header early so it's available for ISR cached responses too.
455
594
  // Font preloads are module-level state populated at import time and persist across requests.
@@ -470,7 +609,7 @@ async function _renderPage(request, url, manifest, middlewareHeaders, options) {
470
609
  setSSRContext({
471
610
  pathname: routePattern,
472
611
  query,
473
- asPath: routeUrl,
612
+ asPath: renderAsPath || routeUrl,
474
613
  locale: locale,
475
614
  locales: i18nConfig ? i18nConfig.locales : undefined,
476
615
  defaultLocale: currentDefaultLocale,
@@ -508,6 +647,13 @@ async function _renderPage(request, url, manifest, middlewareHeaders, options) {
508
647
  isrGet,
509
648
  isrSet,
510
649
  expireSeconds: vinextConfig.expireTime,
650
+ // The vinext build phase boots the prod server with VINEXT_PRERENDER=1
651
+ // and fetches every statically-generated page through it. That hit is
652
+ // the "build" prerender for revalidateReason; runtime hits are not.
653
+ // Mirrors Next.js's \`renderOpts.isBuildTimePrerendering\`. See
654
+ // \`.nextjs-ref/packages/next/src/server/render.tsx\` and
655
+ // \`packages/vinext/src/build/prerender.ts\`.
656
+ isBuildTimePrerendering: typeof process !== "undefined" && process.env && process.env.VINEXT_PRERENDER === "1",
511
657
  pageModule,
512
658
  params,
513
659
  query,
@@ -529,12 +675,21 @@ async function _renderPage(request, url, manifest, middlewareHeaders, options) {
529
675
  safeJsonStringify,
530
676
  sanitizeDestination: sanitizeDestinationLocal,
531
677
  scriptNonce,
678
+ statusCode: renderStatusCode,
532
679
  triggerBackgroundRegeneration,
680
+ vinext: {
681
+ pageModuleUrl,
682
+ appModuleUrl,
683
+ hasMiddleware: __hasMiddleware,
684
+ },
533
685
  });
534
686
  if (pageDataResult.kind === "response") {
535
687
  return pageDataResult.response;
536
688
  }
537
689
  let pageProps = pageDataResult.pageProps;
690
+ if (routePattern === "/_error" && typeof renderStatusCode === "number") {
691
+ pageProps = { ...pageProps, statusCode: renderStatusCode };
692
+ }
538
693
  var gsspRes = pageDataResult.gsspRes;
539
694
  let isrRevalidateSeconds = pageDataResult.isrRevalidateSeconds;
540
695
  const isFallbackRender = pageDataResult.isFallback === true;
@@ -547,7 +702,7 @@ async function _renderPage(request, url, manifest, middlewareHeaders, options) {
547
702
  setSSRContext({
548
703
  pathname: routePattern,
549
704
  query,
550
- asPath: routeUrl,
705
+ asPath: renderAsPath || routeUrl,
551
706
  locale: locale,
552
707
  locales: i18nConfig ? i18nConfig.locales : undefined,
553
708
  defaultLocale: currentDefaultLocale,
@@ -564,14 +719,33 @@ async function _renderPage(request, url, manifest, middlewareHeaders, options) {
564
719
  // cookies set on the gsspRes by getServerSideProps are forwarded so
565
720
  // middleware/auth flows work the same as the HTML page.
566
721
  if (isDataReq) {
567
- const init = {};
568
- if (gsspRes && gsspRes.headers) {
569
- init.headers = {};
570
- for (const [k, v] of Object.entries(gsspRes.headers)) {
722
+ const init = { headers: {} };
723
+ if (gsspRes && typeof gsspRes.getHeaders === "function") {
724
+ const gsspHeaders = gsspRes.getHeaders();
725
+ for (const k of Object.keys(gsspHeaders)) {
726
+ const v = gsspHeaders[k];
571
727
  if (v === undefined || v === null) continue;
572
728
  init.headers[k] = Array.isArray(v) ? v.join(", ") : String(v);
573
729
  }
574
730
  }
731
+ if (gsspRes) {
732
+ // Default Cache-Control for gSSP-driven _next/data responses,
733
+ // matching Next.js's pages-handler.ts (revalidate: 0 →
734
+ // getCacheControlHeader). Skip when gSSP already set one via
735
+ // res.setHeader (case-insensitive). Mirrors the HTML branch in
736
+ // pages-page-response.ts and the dev-server branch. Fixes #1461.
737
+ var hasUserCacheControl = false;
738
+ for (const headerKey of Object.keys(init.headers)) {
739
+ if (headerKey.toLowerCase() === "cache-control") {
740
+ hasUserCacheControl = true;
741
+ break;
742
+ }
743
+ }
744
+ if (!hasUserCacheControl) {
745
+ init.headers["Cache-Control"] =
746
+ "private, no-cache, no-store, max-age=0, must-revalidate";
747
+ }
748
+ }
575
749
  return __buildNextDataJsonResponse(pageProps, safeJsonStringify, init);
576
750
  }
577
751
 
@@ -649,6 +823,12 @@ async function _renderPage(request, url, manifest, middlewareHeaders, options) {
649
823
  routeUrl,
650
824
  safeJsonStringify,
651
825
  scriptNonce,
826
+ statusCode: renderStatusCode,
827
+ vinext: {
828
+ pageModuleUrl,
829
+ appModuleUrl,
830
+ hasMiddleware: __hasMiddleware,
831
+ },
652
832
  });
653
833
  } catch (e) {
654
834
  console.error("[vinext] SSR error:", e);
@@ -1 +1 @@
1
- {"version":3,"file":"pages-server-entry.js","names":[],"sources":["../../src/entries/pages-server-entry.ts"],"sourcesContent":["/**\n * Pages Router server entry generator.\n *\n * Generates the virtual SSR server entry module (`virtual:vinext-server-entry`).\n * This is the entry point for `vite build --ssr`. It handles SSR, API routes,\n * middleware, ISR, and i18n for the Pages Router.\n *\n * Extracted from index.ts.\n */\nimport { resolveEntryPath, normalizePathSeparators } from \"./runtime-entry-module.js\";\nimport { pagesRouter, apiRouter, type Route } from \"../routing/pages-router.js\";\nimport { createValidFileMatcher } from \"../routing/file-matcher.js\";\nimport { type ResolvedNextConfig } from \"../config/next-config.js\";\nimport { isProxyFile } from \"../server/middleware.js\";\nimport { findFileWithExts } from \"./pages-entry-helpers.js\";\n\nconst _requestContextShimPath = resolveEntryPath(\"../shims/request-context.js\", import.meta.url);\nconst _middlewareRuntimePath = resolveEntryPath(\"../server/middleware-runtime.js\", import.meta.url);\nconst _routeTriePath = resolveEntryPath(\"../routing/route-trie.js\", import.meta.url);\nconst _pagesI18nPath = resolveEntryPath(\"../server/pages-i18n.js\", import.meta.url);\nconst _pagesPageResponsePath = resolveEntryPath(\n \"../server/pages-page-response.js\",\n import.meta.url,\n);\nconst _pagesPageDataPath = resolveEntryPath(\"../server/pages-page-data.js\", import.meta.url);\nconst _pagesDataRoutePath = resolveEntryPath(\"../server/pages-data-route.js\", import.meta.url);\nconst _pagesNodeCompatPath = resolveEntryPath(\"../server/pages-node-compat.js\", import.meta.url);\nconst _pagesApiRoutePath = resolveEntryPath(\"../server/pages-api-route.js\", import.meta.url);\nconst _isrCachePath = resolveEntryPath(\"../server/isr-cache.js\", import.meta.url);\nconst _cspPath = resolveEntryPath(\"../server/csp.js\", import.meta.url);\nconst _serverGlobalsPath = resolveEntryPath(\"../server/server-globals.js\", import.meta.url);\n\n/**\n * Generate the virtual SSR server entry module.\n * This is the entry point for `vite build --ssr`.\n */\nexport async function generateServerEntry(\n pagesDir: string,\n nextConfig: ResolvedNextConfig,\n fileMatcher: ReturnType<typeof createValidFileMatcher>,\n middlewarePath: string | null,\n instrumentationPath: string | null,\n): Promise<string> {\n const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);\n const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);\n\n // Generate import statements using absolute paths since virtual\n // modules don't have a real file location for relative resolution.\n const pageImports = pageRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return `import * as page_${i} from ${JSON.stringify(absPath)};`;\n });\n\n const apiImports = apiRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return `import * as api_${i} from ${JSON.stringify(absPath)};`;\n });\n\n // Build the route table — include filePath for SSR manifest lookup\n const pageRouteEntries = pageRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: page_${i}, filePath: ${JSON.stringify(absPath)} }`;\n });\n\n const apiRouteEntries = apiRoutes.map(\n (r: Route, i: number) =>\n ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: api_${i} }`,\n );\n\n // Check for _app and _document\n const appFilePath = findFileWithExts(pagesDir, \"_app\", fileMatcher);\n const docFilePath = findFileWithExts(pagesDir, \"_document\", fileMatcher);\n // Embed the resolved _app path (or null) so the runtime can look it up\n // in the SSR manifest and include any CSS/JS chunks `_app` brings in\n // (e.g. global stylesheets imported by `_app.tsx`) alongside the page's\n // own assets. Without this, `_app`-imported CSS is emitted by Vite but\n // never `<link>`ed from the rendered HTML — see LHF-5 cluster.\n const appAssetPathJson =\n appFilePath !== null ? JSON.stringify(normalizePathSeparators(appFilePath)) : \"null\";\n const appImportCode =\n appFilePath !== null\n ? `import { default as AppComponent } from ${JSON.stringify(normalizePathSeparators(appFilePath))};`\n : `const AppComponent = null;`;\n\n const docImportCode =\n docFilePath !== null\n ? `import { default as DocumentComponent } from ${JSON.stringify(normalizePathSeparators(docFilePath))};`\n : `const DocumentComponent = null;`;\n\n // Serialize i18n config for embedding in the server entry\n const i18nConfigJson = nextConfig?.i18n\n ? JSON.stringify({\n locales: nextConfig.i18n.locales,\n defaultLocale: nextConfig.i18n.defaultLocale,\n localeDetection: nextConfig.i18n.localeDetection,\n domains: nextConfig.i18n.domains,\n })\n : \"null\";\n\n // Embed the resolved build ID at build time\n const buildIdJson = JSON.stringify(nextConfig?.buildId ?? null);\n\n // Serialize the full resolved config for the production server.\n // This embeds redirects, rewrites, headers, basePath, trailingSlash\n // so prod-server.ts can apply them without loading next.config.js at runtime.\n const vinextConfigJson = JSON.stringify({\n basePath: nextConfig?.basePath ?? \"\",\n assetPrefix: nextConfig?.assetPrefix ?? \"\",\n trailingSlash: nextConfig?.trailingSlash ?? false,\n redirects: nextConfig?.redirects ?? [],\n rewrites: nextConfig?.rewrites ?? { beforeFiles: [], afterFiles: [], fallback: [] },\n headers: nextConfig?.headers ?? [],\n expireTime: nextConfig?.expireTime,\n i18n: nextConfig?.i18n ?? null,\n images: {\n deviceSizes: nextConfig?.images?.deviceSizes,\n imageSizes: nextConfig?.images?.imageSizes,\n dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,\n dangerouslyAllowLocalIP: nextConfig?.images?.dangerouslyAllowLocalIP,\n contentDispositionType: nextConfig?.images?.contentDispositionType,\n contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy,\n },\n });\n\n // Generate instrumentation code if instrumentation.ts exists.\n // For production (Cloudflare Workers), instrumentation.ts is bundled into the\n // Worker and register() is called as a top-level await at module evaluation time —\n // before any request is handled. This mirrors App Router behavior (generateRscEntry)\n // and matches Next.js semantics: register() runs once on startup in the process\n // that handles requests.\n //\n // The onRequestError handler is stored on globalThis so it is visible across\n // all code within the Worker (same global scope).\n const instrumentationImportCode = instrumentationPath\n ? `import * as _instrumentation from ${JSON.stringify(normalizePathSeparators(instrumentationPath))};`\n : \"\";\n\n const instrumentationInitCode = instrumentationPath\n ? `// Run instrumentation register() once at module evaluation time — before any\n// requests are handled. Matches Next.js semantics: register() is called once\n// on startup in the process that handles requests.\nif (typeof _instrumentation.register === \"function\") {\n await _instrumentation.register();\n}\n// Store the onRequestError handler on globalThis so it is visible to all\n// code within the Worker (same global scope).\nif (typeof _instrumentation.onRequestError === \"function\") {\n globalThis.__VINEXT_onRequestErrorHandler__ = _instrumentation.onRequestError;\n}`\n : \"\";\n\n // Generate middleware code if middleware.ts exists\n const middlewareImportCode = middlewarePath\n ? `import * as middlewareModule from ${JSON.stringify(normalizePathSeparators(middlewarePath))};`\n : \"\";\n\n // The matcher config is read from the middleware module at request time.\n // The generated entry only wires the user module into the shared runtime\n // helper; matcher, execution, waitUntil, and result shaping live in normal\n // TypeScript modules so dev/prod paths cannot drift.\n const middlewareExportCode = middlewarePath\n ? `\nexport async function runMiddleware(request, ctx, options) {\n return __runGeneratedMiddleware({\n basePath: vinextConfig.basePath,\n ctx,\n i18nConfig,\n isDataRequest: options?.isDataRequest === true,\n isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},\n module: middlewareModule,\n request,\n trailingSlash: vinextConfig.trailingSlash,\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 ${JSON.stringify(_serverGlobalsPath)};\nimport React from \"react\";\nimport { renderToReadableStream } from \"react-dom/server.edge\";\nimport { resetSSRHead, getSSRHeadHTML } from \"next/head\";\nimport { flushPreloads } from \"next/dynamic\";\nimport { setSSRContext, wrapWithRouterContext } from \"next/router\";\nimport { _runWithCacheState } from \"next/cache\";\nimport { runWithPrivateCache } from \"vinext/cache-runtime\";\nimport { ensureFetchPatch, runWithFetchCache } from \"vinext/fetch-cache\";\nimport { runWithRequestContext as _runWithUnifiedCtx, createRequestContext as _createUnifiedCtx } from \"vinext/unified-request-context\";\nimport \"vinext/router-state\";\nimport { runWithServerInsertedHTMLState } from \"vinext/navigation-state\";\nimport { runWithHeadState } from \"vinext/head-state\";\nimport \"vinext/i18n-state\";\nimport { setI18nContext } from \"vinext/i18n-context\";\nimport { createNonceAttribute as __createNonceAttribute, safeJsonStringify } from \"vinext/html\";\nimport { getSSRFontLinks as _getSSRFontLinks, getSSRFontStyles as _getSSRFontStylesGoogle, getSSRFontPreloads as _getSSRFontPreloadsGoogle } from \"next/font/google\";\nimport { getSSRFontStyles as _getSSRFontStylesLocal, getSSRFontPreloads as _getSSRFontPreloadsLocal } from \"next/font/local\";\nimport { sanitizeDestination as sanitizeDestinationLocal } from ${JSON.stringify(resolveEntryPath(\"../config/config-matchers.js\", import.meta.url))};\nimport { runWithExecutionContext as _runWithExecutionContext, getRequestExecutionContext as _getRequestExecutionContext } from ${JSON.stringify(_requestContextShimPath)};\nimport { runGeneratedMiddleware as __runGeneratedMiddleware } from ${JSON.stringify(_middlewareRuntimePath)};\nimport { buildRouteTrie as _buildRouteTrie, trieMatch as _trieMatch } from ${JSON.stringify(_routeTriePath)};\nimport { reportRequestError as _reportRequestError } from \"vinext/instrumentation\";\nimport { resolvePagesI18nRequest } from ${JSON.stringify(_pagesI18nPath)};\nimport { createPagesReqRes as __createPagesReqRes } from ${JSON.stringify(_pagesNodeCompatPath)};\nimport { handlePagesApiRoute as __handlePagesApiRoute } from ${JSON.stringify(_pagesApiRoutePath)};\nimport {\n isrGet as __sharedIsrGet,\n isrSet as __sharedIsrSet,\n isrCacheKey as __sharedIsrCacheKey,\n triggerBackgroundRegeneration as __sharedTriggerBackgroundRegeneration,\n} from ${JSON.stringify(_isrCachePath)};\nimport { getScriptNonceFromHeaderSources as __getScriptNonceFromHeaderSources } from ${JSON.stringify(_cspPath)};\nimport { resolvePagesPageData as __resolvePagesPageData } from ${JSON.stringify(_pagesPageDataPath)};\nimport { buildNextDataJsonResponse as __buildNextDataJsonResponse, buildNextDataNotFoundResponse as __buildNextDataNotFoundResponse } from ${JSON.stringify(_pagesDataRoutePath)};\nimport { renderPagesPageResponse as __renderPagesPageResponse } from ${JSON.stringify(_pagesPageResponsePath)};\n${instrumentationImportCode}\n${middlewareImportCode}\n\n${instrumentationInitCode}\n\n// i18n config (embedded at build time)\nconst i18nConfig = ${i18nConfigJson};\n\n// Build ID (embedded at build time). Exported so the production server can\n// match _next/data requests against the embedded buildId without needing\n// to load next.config.js at runtime.\nexport const buildId = ${buildIdJson};\n\n// Full resolved config for production server (embedded at build time)\nexport const vinextConfig = ${vinextConfigJson};\n\n// Path to the user's pages/_app file (or null). Used to look up the\n// _app's CSS/JS chunks in the SSR manifest so any global styles imported\n// by _app are included in every page's <link rel=\"stylesheet\"> set.\nconst _appAssetPath = ${appAssetPathJson};\n\nfunction isrGet(key) {\n return __sharedIsrGet(key);\n}\nfunction isrSet(key, data, revalidateSeconds, tags, expireSeconds) {\n return __sharedIsrSet(key, data, revalidateSeconds, tags, expireSeconds);\n}\nfunction triggerBackgroundRegeneration(key, renderFn, errorContext) {\n return __sharedTriggerBackgroundRegeneration(key, renderFn, errorContext);\n}\nfunction isrCacheKey(router, pathname) {\n return __sharedIsrCacheKey(router, pathname, buildId || undefined);\n}\n\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\nexport function matchPageRoute(url, request) {\n const routeUrl = i18nConfig && request\n ? resolvePagesI18nRequest(\n url,\n i18nConfig,\n request.headers,\n new URL(request.url).hostname,\n vinextConfig.basePath,\n vinextConfig.trailingSlash,\n ).url\n : url;\n return matchRoute(routeUrl, pageRoutes);\n}\n\nfunction parseQuery(url) {\n 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 mergeRouteParamsIntoQuery(query, params) {\n return Object.assign(query, params);\n}\n\nfunction patternToNextFormat(pattern) {\n // Match any non-/ param name. Non-greedy with lookahead prevents\n // the +/* suffix being consumed into the param name when the name\n // itself contains + or * internally (e.g. :c++lang → [c++lang]).\n return pattern\n .replace(/:([^\\\\/]+?)\\\\+(?=\\\\/|$)/g, \"[...$1]\")\n .replace(/:([^\\\\/]+?)\\\\*(?=\\\\/|$)/g, \"[[...$1]]\")\n .replace(/:([^\\\\/]+?)(?=\\\\/|$)/g, \"[$1]\");\n}\n\nfunction 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\nexport async function renderPage(request, url, manifest, ctx, middlewareHeaders, options) {\n if (ctx) return _runWithExecutionContext(ctx, () => _renderPage(request, url, manifest, middlewareHeaders, options));\n return _renderPage(request, url, manifest, middlewareHeaders, options);\n}\n\nasync function _renderPage(request, url, manifest, middlewareHeaders, options) {\n const isDataReq = !!(options && options.isDataReq);\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 if (isDataReq) {\n return __buildNextDataNotFoundResponse();\n }\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 const query = mergeRouteParamsIntoQuery(parseQuery(routeUrl), params);\n if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query,\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 pageDataResult = await __resolvePagesPageData({\n isDataReq,\n applyRequestContexts() {\n if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n 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 expireSeconds: vinextConfig.expireTime,\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 const isFallbackRender = pageDataResult.isFallback === true;\n\n // Republish the SSR context with isFallback flipped on so the page's\n // \\`useRouter().isFallback\\` returns true during render, matching Next.js's\n // \\`render.tsx\\` fallback shell. Without this, the page would still see\n // \\`isFallback: false\\` and run the non-fallback branch.\n if (isFallbackRender && typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query,\n asPath: routeUrl,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n isFallback: true,\n });\n }\n\n // ── _next/data JSON envelope short-circuit ───────────────────────\n // For client-side navigations Next.js fetches /_next/data/<buildId>/<page>.json\n // and expects { pageProps } as JSON instead of the full HTML page. Skip\n // rendering the React tree and emit the JSON envelope directly via the\n // typed helper so the envelope shape stays in one place. Headers and\n // cookies set on the gsspRes by getServerSideProps are forwarded so\n // middleware/auth flows work the same as the HTML page.\n if (isDataReq) {\n const init = {};\n if (gsspRes && gsspRes.headers) {\n init.headers = {};\n for (const [k, v] of Object.entries(gsspRes.headers)) {\n if (v === undefined || v === null) continue;\n init.headers[k] = Array.isArray(v) ? v.join(\", \") : String(v);\n }\n }\n return __buildNextDataJsonResponse(pageProps, safeJsonStringify, init);\n }\n\n // Include both the matched page module and the global _app module\n // (if present). _app is wrapped around every page in Pages Router,\n // and any CSS/JS it imports must be linked from the rendered HTML\n // so the browser actually loads it. Without _app in this list, a\n // global stylesheet imported via import \"./globals.scss\" in\n // _app.tsx never reaches the page, producing the LHF-5 symptom\n // where styled elements render with the browser default colour.\n const pageModuleIds = [];\n if (route.filePath) pageModuleIds.push(route.filePath);\n if (_appAssetPath) pageModuleIds.push(_appAssetPath);\n const assetTags = collectAssetTags(manifest, pageModuleIds, scriptNonce);\n\n return __renderPagesPageResponse({\n assetTags,\n buildId,\n clearSsrContext() {\n if (typeof setSSRContext === \"function\") setSSRContext(null);\n },\n createPageElement(currentPageProps) {\n var currentElement;\n if (AppComponent) {\n currentElement = React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps });\n } else {\n currentElement = React.createElement(PageComponent, currentPageProps);\n }\n return wrapWithRouterContext(currentElement);\n },\n DocumentComponent,\n flushPreloads: typeof flushPreloads === \"function\" ? flushPreloads : undefined,\n fontLinkHeader: _fontLinkHeader,\n fontPreloads: _allFp,\n getFontLinks() {\n try {\n return typeof _getSSRFontLinks === \"function\" ? _getSSRFontLinks() : [];\n } catch (e) {\n return [];\n }\n },\n getFontStyles() {\n try {\n var allFontStyles = [];\n if (typeof _getSSRFontStylesGoogle === \"function\") allFontStyles.push(..._getSSRFontStylesGoogle());\n if (typeof _getSSRFontStylesLocal === \"function\") allFontStyles.push(..._getSSRFontStylesLocal());\n return allFontStyles;\n } catch (e) {\n return [];\n }\n },\n getSSRHeadHTML: typeof getSSRHeadHTML === \"function\" ? getSSRHeadHTML : undefined,\n gsspRes,\n isrCacheKey,\n expireSeconds: vinextConfig.expireTime,\n isrRevalidateSeconds,\n isrSet,\n i18n: {\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n },\n isFallback: isFallbackRender,\n pageProps,\n params,\n renderDocumentToString(element) {\n return renderToStringAsync(element);\n },\n renderToReadableStream(element) {\n return renderToReadableStream(element);\n },\n resetSSRHead: typeof resetSSRHead === \"function\" ? resetSSRHead : undefined,\n routePattern,\n routeUrl,\n safeJsonStringify,\n scriptNonce,\n });\n } catch (e) {\n console.error(\"[vinext] SSR error:\", e);\n _reportRequestError(\n e instanceof Error ? e : new Error(String(e)),\n { path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },\n { routerKind: \"Pages Router\", routePath: route.pattern, routeType: \"render\" },\n ).catch(() => { /* ignore reporting errors */ });\n return new Response(\"Internal Server Error\", { status: 500 });\n }\n });\n}\n\nexport async function handleApiRoute(request, url, ctx) {\n const match = matchRoute(url, apiRoutes);\n return __handlePagesApiRoute({\n ctx,\n match,\n request,\n url,\n reportRequestError(error, routePattern) {\n console.error(\"[vinext] API error:\", error);\n void _reportRequestError(\n error,\n { path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },\n { routerKind: \"Pages Router\", routePath: routePattern, routeType: \"route\" },\n );\n },\n });\n}\n\n${middlewareExportCode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AAW,KAAK,KAAK,CAAC;;EAEtB,cAAc;EACd,cAAc;;;EAGd,iBAAiB,KAAK,MAAM,CAAC;;;;;EAK7B,gBAAgB,KAAK,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqd5B,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, normalizePathSeparators } from \"./runtime-entry-module.js\";\nimport { pagesRouter, apiRouter, type Route } from \"../routing/pages-router.js\";\nimport { createValidFileMatcher } from \"../routing/file-matcher.js\";\nimport { type ResolvedNextConfig } from \"../config/next-config.js\";\nimport { isProxyFile } from \"../server/middleware.js\";\nimport { findFileWithExts } from \"./pages-entry-helpers.js\";\n\nconst _requestContextShimPath = resolveEntryPath(\"../shims/request-context.js\", import.meta.url);\nconst _middlewareRuntimePath = resolveEntryPath(\"../server/middleware-runtime.js\", import.meta.url);\nconst _routeTriePath = resolveEntryPath(\"../routing/route-trie.js\", import.meta.url);\nconst _pagesI18nPath = resolveEntryPath(\"../server/pages-i18n.js\", import.meta.url);\nconst _pagesPageResponsePath = resolveEntryPath(\n \"../server/pages-page-response.js\",\n import.meta.url,\n);\nconst _pagesPageDataPath = resolveEntryPath(\"../server/pages-page-data.js\", import.meta.url);\nconst _pagesDataRoutePath = resolveEntryPath(\"../server/pages-data-route.js\", import.meta.url);\nconst _pagesDefault404Path = resolveEntryPath(\"../server/pages-default-404.js\", import.meta.url);\nconst _pagesNodeCompatPath = resolveEntryPath(\"../server/pages-node-compat.js\", import.meta.url);\nconst _pagesApiRoutePath = resolveEntryPath(\"../server/pages-api-route.js\", import.meta.url);\nconst _isrCachePath = resolveEntryPath(\"../server/isr-cache.js\", import.meta.url);\nconst _cspPath = resolveEntryPath(\"../server/csp.js\", import.meta.url);\nconst _serverGlobalsPath = resolveEntryPath(\"../server/server-globals.js\", import.meta.url);\n\n/**\n * Generate the virtual SSR server entry module.\n * This is the entry point for `vite build --ssr`.\n */\nexport async function generateServerEntry(\n pagesDir: string,\n nextConfig: ResolvedNextConfig,\n fileMatcher: ReturnType<typeof createValidFileMatcher>,\n middlewarePath: string | null,\n instrumentationPath: string | null,\n): Promise<string> {\n const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);\n const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);\n\n // Generate import statements using absolute paths since virtual\n // modules don't have a real file location for relative resolution.\n const pageImports = pageRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return `import * as page_${i} from ${JSON.stringify(absPath)};`;\n });\n\n const apiImports = apiRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return `import * as api_${i} from ${JSON.stringify(absPath)};`;\n });\n\n // Build the route table — include filePath for SSR manifest lookup\n const pageRouteEntries = pageRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: page_${i}, filePath: ${JSON.stringify(absPath)} }`;\n });\n\n const apiRouteEntries = apiRoutes.map(\n (r: Route, i: number) =>\n ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: api_${i} }`,\n );\n\n // Check for _app, _document, and _error.\n const appFilePath = findFileWithExts(pagesDir, \"_app\", fileMatcher);\n const docFilePath = findFileWithExts(pagesDir, \"_document\", fileMatcher);\n const errorFilePath = findFileWithExts(pagesDir, \"_error\", fileMatcher);\n // Embed the resolved _app path (or null) so the runtime can look it up\n // in the SSR manifest and include any CSS/JS chunks `_app` brings in\n // (e.g. global stylesheets imported by `_app.tsx`) alongside the page's\n // own assets. Without this, `_app`-imported CSS is emitted by Vite but\n // never `<link>`ed from the rendered HTML — see LHF-5 cluster.\n const appAssetPathJson =\n appFilePath !== null ? JSON.stringify(normalizePathSeparators(appFilePath)) : \"null\";\n const appImportCode =\n appFilePath !== null\n ? `import { default as AppComponent } from ${JSON.stringify(normalizePathSeparators(appFilePath))};`\n : `const AppComponent = null;`;\n\n const docImportCode =\n docFilePath !== null\n ? `import { default as DocumentComponent } from ${JSON.stringify(normalizePathSeparators(docFilePath))};`\n : `const DocumentComponent = null;`;\n\n const errorAssetPathJson =\n errorFilePath !== null ? JSON.stringify(normalizePathSeparators(errorFilePath)) : \"null\";\n const errorImportCode =\n errorFilePath !== null\n ? `import * as ErrorPageModule from ${JSON.stringify(normalizePathSeparators(errorFilePath))};`\n : `const ErrorPageModule = null;`;\n\n // Serialize i18n config for embedding in the server entry\n const i18nConfigJson = nextConfig?.i18n\n ? JSON.stringify({\n locales: nextConfig.i18n.locales,\n defaultLocale: nextConfig.i18n.defaultLocale,\n localeDetection: nextConfig.i18n.localeDetection,\n domains: nextConfig.i18n.domains,\n })\n : \"null\";\n\n // Embed the resolved build ID at build time\n const buildIdJson = JSON.stringify(nextConfig?.buildId ?? null);\n\n // Serialize the full resolved config for the production server.\n // This embeds redirects, rewrites, headers, basePath, trailingSlash\n // so prod-server.ts can apply them without loading next.config.js at runtime.\n const vinextConfigJson = JSON.stringify({\n basePath: nextConfig?.basePath ?? \"\",\n assetPrefix: nextConfig?.assetPrefix ?? \"\",\n trailingSlash: nextConfig?.trailingSlash ?? false,\n redirects: nextConfig?.redirects ?? [],\n rewrites: nextConfig?.rewrites ?? { beforeFiles: [], afterFiles: [], fallback: [] },\n headers: nextConfig?.headers ?? [],\n expireTime: nextConfig?.expireTime,\n i18n: nextConfig?.i18n ?? null,\n images: {\n deviceSizes: nextConfig?.images?.deviceSizes,\n imageSizes: nextConfig?.images?.imageSizes,\n dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,\n dangerouslyAllowLocalIP: nextConfig?.images?.dangerouslyAllowLocalIP,\n contentDispositionType: nextConfig?.images?.contentDispositionType,\n contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy,\n },\n });\n\n // Generate instrumentation code if instrumentation.ts exists.\n // For production (Cloudflare Workers), instrumentation.ts is bundled into the\n // Worker and register() is called as a top-level await at module evaluation time —\n // before any request is handled. This mirrors App Router behavior (generateRscEntry)\n // and matches Next.js semantics: register() runs once on startup in the process\n // that handles requests.\n //\n // The onRequestError handler is stored on globalThis so it is visible across\n // all code within the Worker (same global scope).\n const instrumentationImportCode = instrumentationPath\n ? `import * as _instrumentation from ${JSON.stringify(normalizePathSeparators(instrumentationPath))};`\n : \"\";\n\n const instrumentationInitCode = instrumentationPath\n ? `// Run instrumentation register() once at module evaluation time — before any\n// requests are handled. Matches Next.js semantics: register() is called once\n// on startup in the process that handles requests.\nif (typeof _instrumentation.register === \"function\") {\n await _instrumentation.register();\n}\n// Store the onRequestError handler on globalThis so it is visible to all\n// code within the Worker (same global scope).\nif (typeof _instrumentation.onRequestError === \"function\") {\n globalThis.__VINEXT_onRequestErrorHandler__ = _instrumentation.onRequestError;\n}`\n : \"\";\n\n // Generate middleware code if middleware.ts exists\n const middlewareImportCode = middlewarePath\n ? `import * as middlewareModule from ${JSON.stringify(normalizePathSeparators(middlewarePath))};`\n : \"\";\n\n // The matcher config is read from the middleware module at request time.\n // The generated entry only wires the user module into the shared runtime\n // helper; matcher, execution, waitUntil, and result shaping live in normal\n // TypeScript modules so dev/prod paths cannot drift.\n const middlewareExportCode = middlewarePath\n ? `\nexport async function runMiddleware(request, ctx, options) {\n // Auto-detect /_next/data/<buildId>/<page>.json requests so user-written\n // worker entries don't need to know about the data endpoint protocol.\n // Mismatched buildId → JSON 404 short-circuit. Matched → middleware sees\n // the normalized page path via the request URL, and the worker sees the\n // normalized URL via result.rewriteUrl (if middleware didn't already\n // rewrite to something else).\n const __dataNorm = __normalizePagesDataRequest(request);\n if (__dataNorm.notFoundResponse) {\n return { continue: false, response: __dataNorm.notFoundResponse };\n }\n const __result = await __runGeneratedMiddleware({\n basePath: vinextConfig.basePath,\n ctx,\n i18nConfig,\n isDataRequest: options?.isDataRequest === true || __dataNorm.isDataReq,\n isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},\n module: middlewareModule,\n request: __dataNorm.request,\n trailingSlash: vinextConfig.trailingSlash,\n });\n if (__dataNorm.isDataReq && __result.continue && !__result.rewriteUrl && !__result.redirectUrl) {\n return { ...__result, rewriteUrl: __dataNorm.normalizedPathname + __dataNorm.search };\n }\n return __result;\n}\n`\n : `\nexport async function runMiddleware(request) {\n // Even without user middleware, the data-endpoint URL must be normalized so\n // the worker pipeline sees the page path. Mismatched buildId → JSON 404.\n const __dataNorm = __normalizePagesDataRequest(request);\n if (__dataNorm.notFoundResponse) {\n return { continue: false, response: __dataNorm.notFoundResponse };\n }\n if (__dataNorm.isDataReq) {\n return { continue: true, rewriteUrl: __dataNorm.normalizedPathname + __dataNorm.search };\n }\n return { continue: true };\n}\n`;\n\n // The server entry is a self-contained module that uses Web-standard APIs\n // (Request/Response, renderToReadableStream) so it runs on Cloudflare Workers.\n return `\nimport ${JSON.stringify(_serverGlobalsPath)};\nimport React from \"react\";\nimport { renderToReadableStream } from \"react-dom/server.edge\";\nimport { resetSSRHead, getSSRHeadHTML } from \"next/head\";\nimport { flushPreloads } from \"next/dynamic\";\nimport { setSSRContext, wrapWithRouterContext } from \"next/router\";\nimport { _runWithCacheState } from \"next/cache\";\nimport { runWithPrivateCache } from \"vinext/cache-runtime\";\nimport { ensureFetchPatch, runWithFetchCache } from \"vinext/fetch-cache\";\nimport { runWithRequestContext as _runWithUnifiedCtx, createRequestContext as _createUnifiedCtx } from \"vinext/unified-request-context\";\nimport \"vinext/router-state\";\nimport { runWithServerInsertedHTMLState } from \"vinext/navigation-state\";\nimport { runWithHeadState } from \"vinext/head-state\";\nimport \"vinext/i18n-state\";\nimport { setI18nContext } from \"vinext/i18n-context\";\nimport { createNonceAttribute as __createNonceAttribute, safeJsonStringify } from \"vinext/html\";\nimport { getSSRFontLinks as _getSSRFontLinks, getSSRFontStyles as _getSSRFontStylesGoogle, getSSRFontPreloads as _getSSRFontPreloadsGoogle } from \"next/font/google\";\nimport { getSSRFontStyles as _getSSRFontStylesLocal, getSSRFontPreloads as _getSSRFontPreloadsLocal } from \"next/font/local\";\nimport { sanitizeDestination as sanitizeDestinationLocal } from ${JSON.stringify(resolveEntryPath(\"../config/config-matchers.js\", import.meta.url))};\nimport { runWithExecutionContext as _runWithExecutionContext, getRequestExecutionContext as _getRequestExecutionContext } from ${JSON.stringify(_requestContextShimPath)};\nimport { runGeneratedMiddleware as __runGeneratedMiddleware } from ${JSON.stringify(_middlewareRuntimePath)};\nimport { buildRouteTrie as _buildRouteTrie, trieMatch as _trieMatch } from ${JSON.stringify(_routeTriePath)};\nimport { reportRequestError as _reportRequestError } from \"vinext/instrumentation\";\nimport { resolvePagesI18nRequest } from ${JSON.stringify(_pagesI18nPath)};\nimport { createPagesReqRes as __createPagesReqRes } from ${JSON.stringify(_pagesNodeCompatPath)};\nimport { handlePagesApiRoute as __handlePagesApiRoute } from ${JSON.stringify(_pagesApiRoutePath)};\nimport {\n isrGet as __sharedIsrGet,\n isrSet as __sharedIsrSet,\n isrCacheKey as __sharedIsrCacheKey,\n triggerBackgroundRegeneration as __sharedTriggerBackgroundRegeneration,\n} from ${JSON.stringify(_isrCachePath)};\nimport { getScriptNonceFromHeaderSources as __getScriptNonceFromHeaderSources } from ${JSON.stringify(_cspPath)};\nimport { resolvePagesPageData as __resolvePagesPageData } from ${JSON.stringify(_pagesPageDataPath)};\nimport { buildNextDataJsonResponse as __buildNextDataJsonResponse, buildNextDataNotFoundResponse as __buildNextDataNotFoundResponse, isNextDataPathname as __isNextDataPathname, parseNextDataPathname as __parseNextDataPathname } from ${JSON.stringify(_pagesDataRoutePath)};\nimport { buildDefaultPagesNotFoundResponse as __buildDefaultPagesNotFoundResponse } from ${JSON.stringify(_pagesDefault404Path)};\nimport { renderPagesPageResponse as __renderPagesPageResponse } from ${JSON.stringify(_pagesPageResponsePath)};\n${instrumentationImportCode}\n${middlewareImportCode}\n\n${instrumentationInitCode}\n\n// i18n config (embedded at build time)\nconst i18nConfig = ${i18nConfigJson};\n\n// Build ID (embedded at build time). Exported so the production server can\n// match _next/data requests against the embedded buildId without needing\n// to load next.config.js at runtime.\nexport const buildId = ${buildIdJson};\nconst __hasMiddleware = ${JSON.stringify(Boolean(middlewarePath))};\n\n// Full resolved config for production server (embedded at build time)\nexport const vinextConfig = ${vinextConfigJson};\n\n// Path to the user's pages/_app file (or null). Used to look up the\n// _app's CSS/JS chunks in the SSR manifest so any global styles imported\n// by _app are included in every page's <link rel=\"stylesheet\"> set.\nconst _appAssetPath = ${appAssetPathJson};\n\nfunction isrGet(key) {\n return __sharedIsrGet(key);\n}\nfunction isrSet(key, data, revalidateSeconds, tags, expireSeconds) {\n return __sharedIsrSet(key, data, revalidateSeconds, tags, expireSeconds);\n}\nfunction triggerBackgroundRegeneration(key, renderFn, errorContext) {\n return __sharedTriggerBackgroundRegeneration(key, renderFn, errorContext);\n}\nfunction isrCacheKey(router, pathname) {\n return __sharedIsrCacheKey(router, pathname, buildId || undefined);\n}\n\n/**\n * Detect and normalize /_next/data/<buildId>/<page>.json requests in one\n * place so user-written worker entries don't need to know about the data\n * endpoint protocol. Returns the normalized request (with the page path as\n * its URL), an isDataReq flag, and notFoundResponse when the buildId in\n * the URL does not match this server's buildId — callers should return that\n * response immediately so a stale client falls back to a hard navigation.\n */\nfunction __normalizePagesDataRequest(request) {\n const reqUrl = new URL(request.url);\n if (!__isNextDataPathname(reqUrl.pathname)) {\n return { isDataReq: false, request, normalizedPathname: null, search: \"\", notFoundResponse: null };\n }\n const dataMatch = buildId ? __parseNextDataPathname(reqUrl.pathname, buildId) : null;\n if (!dataMatch) {\n return {\n isDataReq: false,\n request,\n normalizedPathname: null,\n search: \"\",\n notFoundResponse: __buildNextDataNotFoundResponse(),\n };\n }\n const normalizedUrl = new URL(reqUrl);\n normalizedUrl.pathname = dataMatch.pagePathname;\n return {\n isDataReq: true,\n request: new Request(normalizedUrl, request),\n normalizedPathname: dataMatch.pagePathname,\n search: reqUrl.search,\n notFoundResponse: null,\n };\n}\n\nasync function renderToStringAsync(element) {\n const stream = await renderToReadableStream(element);\n await stream.allReady;\n return new Response(stream).text();\n}\n\nasync function renderIsrPassToStringAsync(element) {\n // The cache-fill render is a second render pass for the same request.\n // Reset render-scoped state so it cannot leak from the streamed response\n // render or affect async work that is still draining from that stream.\n // Keep request identity state (pathname/query/locale/executionContext)\n // intact: this second pass still belongs to the same request.\n return await runWithServerInsertedHTMLState(() =>\n runWithHeadState(() =>\n _runWithCacheState(() =>\n runWithPrivateCache(() => runWithFetchCache(async () => renderToStringAsync(element))),\n ),\n ),\n );\n}\n\n${pageImports.join(\"\\n\")}\n${apiImports.join(\"\\n\")}\n\n${appImportCode}\n${docImportCode}\n${errorImportCode}\n\nexport const pageRoutes = [\n${pageRouteEntries.join(\",\\n\")}\n];\nconst _pageRouteTrie = _buildRouteTrie(pageRoutes);\nconst _errorPageRoute = ErrorPageModule\n ? {\n pattern: \"/_error\",\n patternParts: [\"_error\"],\n isDynamic: false,\n params: [],\n module: ErrorPageModule,\n filePath: ${errorAssetPathJson},\n }\n : null;\n\nconst apiRoutes = [\n${apiRouteEntries.join(\",\\n\")}\n];\nconst _apiRouteTrie = _buildRouteTrie(apiRoutes);\n\nfunction matchRoute(url, routes) {\n const pathname = url.split(\"?\")[0];\n let normalizedUrl = pathname === \"/\" ? \"/\" : pathname.replace(/\\\\/$/, \"\");\n // NOTE: Do NOT decodeURIComponent here. The pathname is already decoded at\n // the entry point. Decoding again would create a double-decode vector.\n const urlParts = normalizedUrl.split(\"/\").filter(Boolean);\n const trie = routes === pageRoutes ? _pageRouteTrie : _apiRouteTrie;\n return _trieMatch(trie, urlParts);\n}\n\nexport function matchPageRoute(url, request) {\n const routeUrl = i18nConfig && request\n ? resolvePagesI18nRequest(\n url,\n i18nConfig,\n request.headers,\n new URL(request.url).hostname,\n vinextConfig.basePath,\n vinextConfig.trailingSlash,\n ).url\n : url;\n return matchRoute(routeUrl, pageRoutes);\n}\n\nfunction parseQuery(url) {\n // Per RFC 3986 only the first \"?\" separates path from query, so additional\n // \"?\" chars belong to the query string (e.g. /linker?href=/about?hello=world\n // has query \"href=/about?hello=world\"). split(\"?\")[1] would drop everything\n // after the second \"?\" and strip embedded query strings from values.\n const queryIndex = url.indexOf(\"?\");\n if (queryIndex === -1) return {};\n const hashIndex = url.indexOf(\"#\", queryIndex + 1);\n const qs = hashIndex === -1 ? url.slice(queryIndex + 1) : url.slice(queryIndex + 1, hashIndex);\n if (!qs) return {};\n const p = new URLSearchParams(qs);\n const q = {};\n for (const [k, v] of p) {\n if (k in q) {\n q[k] = Array.isArray(q[k]) ? q[k].concat(v) : [q[k], v];\n } else {\n q[k] = v;\n }\n }\n return q;\n}\n\nfunction mergeRouteParamsIntoQuery(query, params) {\n return Object.assign(query, params);\n}\n\nfunction patternToNextFormat(pattern) {\n // Match any non-/ param name. Non-greedy with lookahead prevents\n // the +/* suffix being consumed into the param name when the name\n // itself contains + or * internally (e.g. :c++lang → [c++lang]).\n return pattern\n .replace(/:([^\\\\/]+?)\\\\+(?=\\\\/|$)/g, \"[...$1]\")\n .replace(/:([^\\\\/]+?)\\\\*(?=\\\\/|$)/g, \"[[...$1]]\")\n .replace(/:([^\\\\/]+?)(?=\\\\/|$)/g, \"[$1]\");\n}\n\nfunction resolveSsrManifest(manifest) {\n // Fall back to embedded manifest (set by vinext:cloudflare-build for Workers)\n return (manifest && Object.keys(manifest).length > 0)\n ? manifest\n : (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_SSR_MANIFEST__) || null;\n}\n\nfunction getManifestFilesForModule(manifest, moduleId) {\n if (!manifest || !moduleId) return null;\n\n var files = manifest[moduleId];\n if (files) return files;\n\n for (var key in manifest) {\n if (moduleId.endsWith(\"/\" + key) || moduleId === key) {\n return manifest[key];\n }\n }\n return null;\n}\n\nfunction collectAssetTags(manifest, moduleIds, scriptNonce) {\n const m = resolveSsrManifest(manifest);\n const tags = [];\n const seen = new Set();\n const nonceAttr = __createNonceAttribute(scriptNonce);\n\n // Load the set of lazy chunk filenames (only reachable via dynamic imports).\n // These should NOT get <link rel=\"modulepreload\"> or <script type=\"module\">\n // tags — they are fetched on demand when the dynamic import() executes (e.g.\n // chunks behind React.lazy() or next/dynamic boundaries).\n var lazyChunks = (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_LAZY_CHUNKS__) || null;\n var lazySet = lazyChunks && lazyChunks.length > 0 ? new Set(lazyChunks) : null;\n\n // Inject the client entry script if embedded by vinext:cloudflare-build\n if (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_CLIENT_ENTRY__) {\n const entry = globalThis.__VINEXT_CLIENT_ENTRY__;\n seen.add(entry);\n tags.push('<link rel=\"modulepreload\"' + nonceAttr + ' href=\"/' + entry + '\" />');\n tags.push('<script type=\"module\"' + nonceAttr + ' src=\"/' + entry + '\" crossorigin></script>');\n }\n if (m) {\n // Always inject shared chunks (framework, vinext runtime, entry) and\n // page-specific chunks. The manifest maps module file paths to their\n // associated JS/CSS assets.\n //\n // For page-specific injection, the module IDs may be absolute paths\n // while the manifest uses relative paths. Try both the original ID\n // and a suffix match to find the correct manifest entry.\n var allFiles = [];\n\n if (moduleIds && moduleIds.length > 0) {\n // Collect assets for the requested page modules\n for (var mi = 0; mi < moduleIds.length; mi++) {\n var id = moduleIds[mi];\n var files = getManifestFilesForModule(m, id);\n if (files) {\n for (var fi = 0; fi < files.length; fi++) allFiles.push(files[fi]);\n }\n }\n\n // Also inject shared chunks that every page needs: framework,\n // vinext runtime, and the entry bootstrap. These are identified\n // by scanning all manifest values for chunk filenames containing\n // known prefixes.\n for (var key in m) {\n var vals = m[key];\n if (!vals) continue;\n for (var vi = 0; vi < vals.length; vi++) {\n var file = vals[vi];\n var basename = file.split(\"/\").pop() || \"\";\n if (\n basename.startsWith(\"framework-\") ||\n basename.startsWith(\"vinext-\") ||\n basename.includes(\"vinext-client-entry\") ||\n basename.includes(\"vinext-app-browser-entry\")\n ) {\n allFiles.push(file);\n }\n }\n }\n } else {\n // No specific modules — include all assets from manifest\n for (var akey in m) {\n var avals = m[akey];\n if (avals) {\n for (var ai = 0; ai < avals.length; ai++) allFiles.push(avals[ai]);\n }\n }\n }\n\n for (var ti = 0; ti < allFiles.length; ti++) {\n var tf = allFiles[ti];\n // Normalize: Vite's SSR manifest values include a leading '/'\n // (from base path), but we prepend '/' ourselves when building\n // href/src attributes. Strip any existing leading slash to avoid\n // producing protocol-relative URLs like \"//assets/chunk.js\".\n // This also ensures consistent keys for the seen-set dedup and\n // lazySet.has() checks (which use values without leading slash).\n if (tf.charAt(0) === '/') tf = tf.slice(1);\n if (seen.has(tf)) continue;\n seen.add(tf);\n if (tf.endsWith(\".css\")) {\n tags.push('<link rel=\"stylesheet\"' + nonceAttr + ' href=\"/' + tf + '\" />');\n } else if (tf.endsWith(\".js\")) {\n // Skip lazy chunks — they are behind dynamic import() boundaries\n // (React.lazy, next/dynamic) and should only be fetched on demand.\n if (lazySet && lazySet.has(tf)) continue;\n tags.push('<link rel=\"modulepreload\"' + nonceAttr + ' href=\"/' + tf + '\" />');\n tags.push('<script type=\"module\"' + nonceAttr + ' src=\"/' + tf + '\" crossorigin></script>');\n }\n }\n }\n return tags.join(\"\\\\n \");\n}\n\nfunction resolveClientModuleUrl(manifest, moduleId) {\n const files = getManifestFilesForModule(resolveSsrManifest(manifest), moduleId);\n if (!files) return undefined;\n for (var i = 0; i < files.length; i++) {\n var file = files[i];\n if (!file || !file.endsWith(\".js\")) continue;\n if (file.charAt(0) !== \"/\") file = \"/\" + file;\n return file;\n }\n return undefined;\n}\n\nexport async function renderPage(request, url, manifest, ctx, middlewareHeaders, options) {\n if (ctx) return _runWithExecutionContext(ctx, () => _renderPage(request, url, manifest, middlewareHeaders, options));\n return _renderPage(request, url, manifest, middlewareHeaders, options);\n}\n\nasync function _renderPage(request, url, manifest, middlewareHeaders, options) {\n let isDataReq = !!(options && options.isDataReq);\n // Auto-detect /_next/data/... requests by inspecting the incoming request\n // URL. The worker pipeline does not need to know about the data endpoint\n // protocol — when it forwards an unrewritten data URL as the url arg, we\n // normalize it to the page path here.\n if (!isDataReq) {\n const __dataNorm = __normalizePagesDataRequest(request);\n if (__dataNorm.notFoundResponse) return __dataNorm.notFoundResponse;\n if (__dataNorm.isDataReq) {\n isDataReq = true;\n if (url && url.startsWith(\"/_next/data/\")) {\n const __qs = url.includes(\"?\") ? url.slice(url.indexOf(\"?\")) : \"\";\n url = __dataNorm.normalizedPathname + __qs;\n }\n }\n }\n const statusCode = options && typeof options.statusCode === \"number\" ? options.statusCode : undefined;\n const asPath = options && typeof options.asPath === \"string\" ? options.asPath : undefined;\n const renderErrorPageOnMiss = !(options && options.renderErrorPageOnMiss === false);\n const localeInfo = i18nConfig\n ? resolvePagesI18nRequest(\n url,\n i18nConfig,\n request.headers,\n new URL(request.url).hostname,\n vinextConfig.basePath,\n vinextConfig.trailingSlash,\n )\n : { locale: undefined, url, hadPrefix: false, domainLocale: undefined, redirectUrl: undefined };\n const locale = localeInfo.locale;\n const routeUrl = localeInfo.url;\n const currentDefaultLocale = i18nConfig\n ? (localeInfo.domainLocale ? localeInfo.domainLocale.defaultLocale : i18nConfig.defaultLocale)\n : undefined;\n const domainLocales = i18nConfig ? i18nConfig.domains : undefined;\n\n if (localeInfo.redirectUrl) {\n return new Response(null, { status: 307, headers: { Location: localeInfo.redirectUrl } });\n }\n\n let match = matchRoute(routeUrl, pageRoutes);\n let renderStatusCodeOverride = statusCode;\n let renderAsPath = asPath;\n if (!match) {\n if (isDataReq) {\n return __buildNextDataNotFoundResponse();\n }\n if (!renderErrorPageOnMiss) {\n return __buildDefaultPagesNotFoundResponse();\n }\n const notFoundMatch = matchRoute(\"/404\", pageRoutes);\n // matchRoute may match a catch-all (e.g. [...slug]); only use the explicit pages/404 route.\n if (notFoundMatch && notFoundMatch.route.pattern === \"/404\") {\n match = notFoundMatch;\n renderStatusCodeOverride = 404;\n renderAsPath = routeUrl;\n } else if (_errorPageRoute) {\n match = { route: _errorPageRoute, params: {} };\n renderStatusCodeOverride = 404;\n renderAsPath = routeUrl;\n } else {\n return __buildDefaultPagesNotFoundResponse();\n }\n }\n\n const { route, params } = match;\n const __uCtx = _createUnifiedCtx({\n executionContext: _getRequestExecutionContext(),\n });\n return _runWithUnifiedCtx(__uCtx, async () => {\n ensureFetchPatch();\n try {\n const routePattern = patternToNextFormat(route.pattern);\n const renderStatusCode = renderStatusCodeOverride ?? (routePattern === \"/404\" ? 404 : undefined);\n const query = mergeRouteParamsIntoQuery(parseQuery(routeUrl), params);\n if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query,\n asPath: renderAsPath || routeUrl,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n });\n }\n\n if (i18nConfig) {\n setI18nContext({\n locale: locale,\n locales: i18nConfig.locales,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n hostname: new URL(request.url).hostname,\n });\n }\n\n const pageModule = route.module;\n const PageComponent = pageModule.default;\n if (!PageComponent) {\n return new Response(\"Page has no default export\", { status: 500 });\n }\n const pageModuleUrl = resolveClientModuleUrl(manifest, route.filePath);\n const appModuleUrl = resolveClientModuleUrl(manifest, _appAssetPath);\n const scriptNonce = __getScriptNonceFromHeaderSources(request.headers, middlewareHeaders);\n // Build font Link header early so it's available for ISR cached responses too.\n // Font preloads are module-level state populated at import time and persist across requests.\n var _fontLinkHeader = \"\";\n var _allFp = [];\n try {\n var _fpGoogle = typeof _getSSRFontPreloadsGoogle === \"function\" ? _getSSRFontPreloadsGoogle() : [];\n var _fpLocal = typeof _getSSRFontPreloadsLocal === \"function\" ? _getSSRFontPreloadsLocal() : [];\n _allFp = _fpGoogle.concat(_fpLocal);\n if (_allFp.length > 0) {\n _fontLinkHeader = _allFp.map(function(p) { return \"<\" + p.href + \">; rel=preload; as=font; type=\" + p.type + \"; crossorigin\"; }).join(\", \");\n }\n } catch (e) { /* font preloads not available */ }\n const pageDataResult = await __resolvePagesPageData({\n isDataReq,\n applyRequestContexts() {\n if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query,\n asPath: renderAsPath || routeUrl,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n });\n }\n if (i18nConfig) {\n setI18nContext({\n locale: locale,\n locales: i18nConfig.locales,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n hostname: new URL(request.url).hostname,\n });\n }\n },\n buildId,\n createGsspReqRes() {\n return __createPagesReqRes({ body: undefined, query, request, url: routeUrl });\n },\n createPageElement(currentPageProps) {\n var currentElement = AppComponent\n ? React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps })\n : React.createElement(PageComponent, currentPageProps);\n return wrapWithRouterContext(currentElement);\n },\n fontLinkHeader: _fontLinkHeader,\n i18n: {\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n },\n isrCacheKey,\n isrGet,\n isrSet,\n expireSeconds: vinextConfig.expireTime,\n // The vinext build phase boots the prod server with VINEXT_PRERENDER=1\n // and fetches every statically-generated page through it. That hit is\n // the \"build\" prerender for revalidateReason; runtime hits are not.\n // Mirrors Next.js's \\`renderOpts.isBuildTimePrerendering\\`. See\n // \\`.nextjs-ref/packages/next/src/server/render.tsx\\` and\n // \\`packages/vinext/src/build/prerender.ts\\`.\n isBuildTimePrerendering: typeof process !== \"undefined\" && process.env && process.env.VINEXT_PRERENDER === \"1\",\n pageModule,\n params,\n query,\n renderIsrPassToStringAsync,\n route: {\n isDynamic: route.isDynamic,\n },\n routePattern,\n routeUrl,\n runInFreshUnifiedContext(callback) {\n var revalCtx = _createUnifiedCtx({\n executionContext: _getRequestExecutionContext(),\n });\n return _runWithUnifiedCtx(revalCtx, async () => {\n ensureFetchPatch();\n return callback();\n });\n },\n safeJsonStringify,\n sanitizeDestination: sanitizeDestinationLocal,\n scriptNonce,\n statusCode: renderStatusCode,\n triggerBackgroundRegeneration,\n vinext: {\n pageModuleUrl,\n appModuleUrl,\n hasMiddleware: __hasMiddleware,\n },\n });\n if (pageDataResult.kind === \"response\") {\n return pageDataResult.response;\n }\n let pageProps = pageDataResult.pageProps;\n if (routePattern === \"/_error\" && typeof renderStatusCode === \"number\") {\n pageProps = { ...pageProps, statusCode: renderStatusCode };\n }\n var gsspRes = pageDataResult.gsspRes;\n let isrRevalidateSeconds = pageDataResult.isrRevalidateSeconds;\n const isFallbackRender = pageDataResult.isFallback === true;\n\n // Republish the SSR context with isFallback flipped on so the page's\n // \\`useRouter().isFallback\\` returns true during render, matching Next.js's\n // \\`render.tsx\\` fallback shell. Without this, the page would still see\n // \\`isFallback: false\\` and run the non-fallback branch.\n if (isFallbackRender && typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query,\n asPath: renderAsPath || routeUrl,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n isFallback: true,\n });\n }\n\n // ── _next/data JSON envelope short-circuit ───────────────────────\n // For client-side navigations Next.js fetches /_next/data/<buildId>/<page>.json\n // and expects { pageProps } as JSON instead of the full HTML page. Skip\n // rendering the React tree and emit the JSON envelope directly via the\n // typed helper so the envelope shape stays in one place. Headers and\n // cookies set on the gsspRes by getServerSideProps are forwarded so\n // middleware/auth flows work the same as the HTML page.\n if (isDataReq) {\n const init = { headers: {} };\n if (gsspRes && typeof gsspRes.getHeaders === \"function\") {\n const gsspHeaders = gsspRes.getHeaders();\n for (const k of Object.keys(gsspHeaders)) {\n const v = gsspHeaders[k];\n if (v === undefined || v === null) continue;\n init.headers[k] = Array.isArray(v) ? v.join(\", \") : String(v);\n }\n }\n if (gsspRes) {\n // Default Cache-Control for gSSP-driven _next/data responses,\n // matching Next.js's pages-handler.ts (revalidate: 0 →\n // getCacheControlHeader). Skip when gSSP already set one via\n // res.setHeader (case-insensitive). Mirrors the HTML branch in\n // pages-page-response.ts and the dev-server branch. Fixes #1461.\n var hasUserCacheControl = false;\n for (const headerKey of Object.keys(init.headers)) {\n if (headerKey.toLowerCase() === \"cache-control\") {\n hasUserCacheControl = true;\n break;\n }\n }\n if (!hasUserCacheControl) {\n init.headers[\"Cache-Control\"] =\n \"private, no-cache, no-store, max-age=0, must-revalidate\";\n }\n }\n return __buildNextDataJsonResponse(pageProps, safeJsonStringify, init);\n }\n\n // Include both the matched page module and the global _app module\n // (if present). _app is wrapped around every page in Pages Router,\n // and any CSS/JS it imports must be linked from the rendered HTML\n // so the browser actually loads it. Without _app in this list, a\n // global stylesheet imported via import \"./globals.scss\" in\n // _app.tsx never reaches the page, producing the LHF-5 symptom\n // where styled elements render with the browser default colour.\n const pageModuleIds = [];\n if (route.filePath) pageModuleIds.push(route.filePath);\n if (_appAssetPath) pageModuleIds.push(_appAssetPath);\n const assetTags = collectAssetTags(manifest, pageModuleIds, scriptNonce);\n\n return __renderPagesPageResponse({\n assetTags,\n buildId,\n clearSsrContext() {\n if (typeof setSSRContext === \"function\") setSSRContext(null);\n },\n createPageElement(currentPageProps) {\n var currentElement;\n if (AppComponent) {\n currentElement = React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps });\n } else {\n currentElement = React.createElement(PageComponent, currentPageProps);\n }\n return wrapWithRouterContext(currentElement);\n },\n DocumentComponent,\n flushPreloads: typeof flushPreloads === \"function\" ? flushPreloads : undefined,\n fontLinkHeader: _fontLinkHeader,\n fontPreloads: _allFp,\n getFontLinks() {\n try {\n return typeof _getSSRFontLinks === \"function\" ? _getSSRFontLinks() : [];\n } catch (e) {\n return [];\n }\n },\n getFontStyles() {\n try {\n var allFontStyles = [];\n if (typeof _getSSRFontStylesGoogle === \"function\") allFontStyles.push(..._getSSRFontStylesGoogle());\n if (typeof _getSSRFontStylesLocal === \"function\") allFontStyles.push(..._getSSRFontStylesLocal());\n return allFontStyles;\n } catch (e) {\n return [];\n }\n },\n getSSRHeadHTML: typeof getSSRHeadHTML === \"function\" ? getSSRHeadHTML : undefined,\n gsspRes,\n isrCacheKey,\n expireSeconds: vinextConfig.expireTime,\n isrRevalidateSeconds,\n isrSet,\n i18n: {\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n },\n isFallback: isFallbackRender,\n pageProps,\n params,\n renderDocumentToString(element) {\n return renderToStringAsync(element);\n },\n renderToReadableStream(element) {\n return renderToReadableStream(element);\n },\n resetSSRHead: typeof resetSSRHead === \"function\" ? resetSSRHead : undefined,\n routePattern,\n routeUrl,\n safeJsonStringify,\n scriptNonce,\n statusCode: renderStatusCode,\n vinext: {\n pageModuleUrl,\n appModuleUrl,\n hasMiddleware: __hasMiddleware,\n },\n });\n } catch (e) {\n console.error(\"[vinext] SSR error:\", e);\n _reportRequestError(\n e instanceof Error ? e : new Error(String(e)),\n { path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },\n { routerKind: \"Pages Router\", routePath: route.pattern, routeType: \"render\" },\n ).catch(() => { /* ignore reporting errors */ });\n return new Response(\"Internal Server Error\", { status: 500 });\n }\n });\n}\n\nexport async function handleApiRoute(request, url, ctx) {\n const match = matchRoute(url, apiRoutes);\n return __handlePagesApiRoute({\n ctx,\n match,\n request,\n url,\n reportRequestError(error, routePattern) {\n console.error(\"[vinext] API error:\", error);\n void _reportRequestError(\n error,\n { path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },\n { routerKind: \"Pages Router\", routePath: routePattern, routeType: \"route\" },\n );\n },\n });\n}\n\n${middlewareExportCode}\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAM,0BAA0B,iBAAiB,+BAA+B,OAAO,KAAK,IAAI;AAChG,MAAM,yBAAyB,iBAAiB,mCAAmC,OAAO,KAAK,IAAI;AACnG,MAAM,iBAAiB,iBAAiB,4BAA4B,OAAO,KAAK,IAAI;AACpF,MAAM,iBAAiB,iBAAiB,2BAA2B,OAAO,KAAK,IAAI;AACnF,MAAM,yBAAyB,iBAC7B,oCACA,OAAO,KAAK,IACb;AACD,MAAM,qBAAqB,iBAAiB,gCAAgC,OAAO,KAAK,IAAI;AAC5F,MAAM,sBAAsB,iBAAiB,iCAAiC,OAAO,KAAK,IAAI;AAC9F,MAAM,uBAAuB,iBAAiB,kCAAkC,OAAO,KAAK,IAAI;AAChG,MAAM,uBAAuB,iBAAiB,kCAAkC,OAAO,KAAK,IAAI;AAChG,MAAM,qBAAqB,iBAAiB,gCAAgC,OAAO,KAAK,IAAI;AAC5F,MAAM,gBAAgB,iBAAiB,0BAA0B,OAAO,KAAK,IAAI;AACjF,MAAM,WAAW,iBAAiB,oBAAoB,OAA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