vinext 1.1.0 → 1.2.1

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 (288) hide show
  1. package/README.md +22 -10
  2. package/dist/build/client-build-config.d.ts +10 -0
  3. package/dist/build/client-build-config.js +18 -2
  4. package/dist/build/output-root-externals.d.ts +21 -0
  5. package/dist/build/output-root-externals.js +40 -0
  6. package/dist/build/pages-client-assets-module.d.ts +8 -0
  7. package/dist/build/pages-client-assets-module.js +21 -1
  8. package/dist/build/prerender-paths.js +6 -4
  9. package/dist/build/prerender.js +1 -1
  10. package/dist/build/run-prerender.js +1 -1
  11. package/dist/build/ssr-manifest.d.ts +2 -0
  12. package/dist/build/ssr-manifest.js +6 -2
  13. package/dist/check.js +12 -12
  14. package/dist/cli-dev-config.js +3 -3
  15. package/dist/cli.js +3 -2
  16. package/dist/client/client-redirect-matcher.d.ts +14 -0
  17. package/dist/client/client-redirect-matcher.js +37 -0
  18. package/dist/client/client-redirects.d.ts +27 -0
  19. package/dist/client/client-redirects.js +28 -0
  20. package/dist/client/client-rewrites.d.ts +2 -1
  21. package/dist/client/client-rewrites.js +1 -1
  22. package/dist/config/config-matchers.d.ts +26 -11
  23. package/dist/config/config-matchers.js +90 -88
  24. package/dist/config/destination-params.d.ts +47 -0
  25. package/dist/config/destination-params.js +116 -0
  26. package/dist/config/next-config.d.ts +7 -0
  27. package/dist/config/next-config.js +3 -0
  28. package/dist/entries/app-rsc-entry.d.ts +4 -0
  29. package/dist/entries/app-rsc-entry.js +20 -6
  30. package/dist/entries/pages-client-entry.js +3 -1
  31. package/dist/entries/pages-server-entry.js +13 -37
  32. package/dist/index.d.ts +3 -1
  33. package/dist/index.js +246 -136
  34. package/dist/init-cloudflare.d.ts +9 -0
  35. package/dist/init-cloudflare.js +107 -31
  36. package/dist/init-platform.d.ts +4 -0
  37. package/dist/init-platform.js +27 -2
  38. package/dist/init.d.ts +2 -1
  39. package/dist/init.js +153 -9
  40. package/dist/plugins/ast-scope.d.ts +7 -0
  41. package/dist/plugins/ast-scope.js +59 -3
  42. package/dist/plugins/ast-utils.d.ts +53 -2
  43. package/dist/plugins/ast-utils.js +90 -2
  44. package/dist/plugins/cloudflare-dev-module-urls.d.ts +41 -0
  45. package/dist/plugins/cloudflare-dev-module-urls.js +271 -0
  46. package/dist/plugins/commonjs-esm-facade.js +2 -2
  47. package/dist/plugins/css-module-imports.js +13 -20
  48. package/dist/plugins/dynamic-preload-metadata.d.ts +1 -1
  49. package/dist/plugins/dynamic-preload-metadata.js +11 -11
  50. package/dist/plugins/extensionless-dynamic-import.js +2 -3
  51. package/dist/plugins/fonts.d.ts +1 -1
  52. package/dist/plugins/fonts.js +3 -3
  53. package/dist/plugins/ignore-dynamic-requests.d.ts +1 -1
  54. package/dist/plugins/ignore-dynamic-requests.js +5 -7
  55. package/dist/plugins/import-meta-url.js +3 -4
  56. package/dist/plugins/instrumentation-client.js +3 -2
  57. package/dist/plugins/middleware-export-validation.js +2 -3
  58. package/dist/plugins/middleware-server-only.d.ts +5 -4
  59. package/dist/plugins/middleware-server-only.js +8 -5
  60. package/dist/plugins/og-harfbuzz.js +2 -3
  61. package/dist/plugins/optimize-imports.js +3 -4
  62. package/dist/plugins/pages-node-externals.js +3 -4
  63. package/dist/plugins/remove-console.js +2 -18
  64. package/dist/plugins/require-condition-resolution.js +3 -3
  65. package/dist/plugins/require-context.js +2 -3
  66. package/dist/plugins/rsc-scan-glob-imports.d.ts +19 -0
  67. package/dist/plugins/rsc-scan-glob-imports.js +50 -0
  68. package/dist/plugins/strip-server-exports.js +265 -102
  69. package/dist/plugins/styled-jsx.js +2 -3
  70. package/dist/plugins/transform-result.d.ts +9 -5
  71. package/dist/plugins/transitive-externals.js +1 -1
  72. package/dist/plugins/typeof-window.d.ts +2 -2
  73. package/dist/plugins/use-cache-callable.d.ts +21 -2
  74. package/dist/plugins/use-cache-callable.js +84 -35
  75. package/dist/plugins/worker-image-imports.js +30 -33
  76. package/dist/plugins/worker-server-only-imports.d.ts +20 -0
  77. package/dist/plugins/worker-server-only-imports.js +31 -0
  78. package/dist/plugins/worker-use-server.d.ts +25 -0
  79. package/dist/plugins/worker-use-server.js +153 -0
  80. package/dist/server/api-handler.d.ts +1 -0
  81. package/dist/server/api-handler.js +3 -2
  82. package/dist/server/app-action-forwarding.js +2 -2
  83. package/dist/server/app-browser-action-result.d.ts +1 -1
  84. package/dist/server/app-browser-action-result.js +9 -2
  85. package/dist/server/app-browser-entry.js +3 -3
  86. package/dist/server/app-browser-interception-context.js +1 -1
  87. package/dist/server/app-browser-navigation-controller.js +1 -1
  88. package/dist/server/app-browser-prefetch-response.js +2 -2
  89. package/dist/server/app-browser-server-action-client.js +1 -1
  90. package/dist/server/app-browser-state.js +1 -1
  91. package/dist/server/app-browser-supplemental-refresh.js +1 -1
  92. package/dist/server/app-middleware.d.ts +11 -0
  93. package/dist/server/app-middleware.js +17 -2
  94. package/dist/server/app-optimistic-routing.js +1 -1
  95. package/dist/server/app-page-cache.d.ts +1 -1
  96. package/dist/server/app-page-cache.js +1 -1
  97. package/dist/server/app-page-dispatch.d.ts +3 -1
  98. package/dist/server/app-page-dispatch.js +5 -4
  99. package/dist/server/app-page-ppr-runtime.js +1 -1
  100. package/dist/server/app-page-render-observation.js +1 -1
  101. package/dist/server/app-page-render.js +1 -1
  102. package/dist/server/app-page-request.js +53 -15
  103. package/dist/server/app-page-route-wiring.js +2 -2
  104. package/dist/server/app-pages-bridge.d.ts +1 -1
  105. package/dist/server/app-pages-bridge.js +3 -4
  106. package/dist/server/app-prerender-endpoints.js +9 -6
  107. package/dist/server/app-render-abort-error.d.ts +19 -0
  108. package/dist/server/app-render-abort-error.js +31 -1
  109. package/dist/server/app-request-stage-dispatch.js +6 -2
  110. package/dist/server/app-request-stage-independent-entry.js +29 -9
  111. package/dist/server/app-response-stage-entry.js +11 -3
  112. package/dist/server/app-route-handler-cache.d.ts +1 -0
  113. package/dist/server/app-route-handler-cache.js +1 -0
  114. package/dist/server/app-route-handler-dispatch.d.ts +1 -0
  115. package/dist/server/app-route-handler-dispatch.js +5 -2
  116. package/dist/server/app-route-handler-execution.d.ts +1 -0
  117. package/dist/server/app-route-handler-execution.js +1 -0
  118. package/dist/server/app-route-handler-runtime.d.ts +4 -1
  119. package/dist/server/app-route-handler-runtime.js +46 -25
  120. package/dist/server/app-router-entry.js +29 -10
  121. package/dist/server/app-rsc-cache-busting.d.ts +16 -0
  122. package/dist/server/app-rsc-cache-busting.js +30 -13
  123. package/dist/server/app-rsc-errors.js +20 -16
  124. package/dist/server/app-rsc-handler.d.ts +7 -0
  125. package/dist/server/app-rsc-handler.js +89 -39
  126. package/dist/server/app-rsc-request-normalization.js +3 -3
  127. package/dist/server/app-rsc-response-stage.js +5 -3
  128. package/dist/server/app-segment-config.d.ts +2 -1
  129. package/dist/server/app-server-action-execution.d.ts +2 -1
  130. package/dist/server/app-server-action-execution.js +62 -23
  131. package/dist/server/app-ssr-entry.js +7 -5
  132. package/dist/server/app-visited-response-cache.js +2 -2
  133. package/dist/server/app-worker-stages.d.ts +5 -0
  134. package/dist/server/app-worker-stages.js +1 -1
  135. package/dist/server/cacheability-request.js +2 -2
  136. package/dist/server/client-build-files.d.ts +16 -0
  137. package/dist/server/client-build-files.js +36 -0
  138. package/dist/server/client-reuse-manifest.js +1 -1
  139. package/dist/server/config-headers.js +1 -1
  140. package/dist/server/defer-until-stream-consumed.d.ts +2 -1
  141. package/dist/server/defer-until-stream-consumed.js +3 -1
  142. package/dist/server/dev-server.js +39 -28
  143. package/dist/server/dev-stack-sourcemap.js +18 -23
  144. package/dist/server/document-initial-head.d.ts +0 -11
  145. package/dist/server/document-initial-head.js +1 -1
  146. package/dist/server/forwarded-middleware-context.d.ts +5 -0
  147. package/dist/server/forwarded-middleware-context.js +22 -0
  148. package/dist/server/headers.d.ts +4 -1
  149. package/dist/server/headers.js +4 -1
  150. package/dist/server/http-conditional.d.ts +11 -0
  151. package/dist/server/http-conditional.js +10 -1
  152. package/dist/server/http-error-responses.d.ts +1 -1
  153. package/dist/server/image-optimization.d.ts +38 -0
  154. package/dist/server/image-optimization.js +94 -4
  155. package/dist/server/isr-cache.d.ts +10 -0
  156. package/dist/server/isr-cache.js +41 -6
  157. package/dist/server/metadata-route-response.js +11 -10
  158. package/dist/server/middleware-matcher.d.ts +2 -0
  159. package/dist/server/middleware-matcher.js +23 -2
  160. package/dist/server/middleware-path-to-regexp.js +1 -1
  161. package/dist/server/middleware-runtime.d.ts +13 -0
  162. package/dist/server/middleware-runtime.js +38 -25
  163. package/dist/server/middleware.d.ts +1 -1
  164. package/dist/server/middleware.js +3 -1
  165. package/dist/server/multi-stage.d.ts +11 -0
  166. package/dist/server/navigation-planner.js +1 -1
  167. package/dist/server/normalize-path.d.ts +0 -13
  168. package/dist/server/normalize-path.js +1 -34
  169. package/dist/server/open-redirect.d.ts +11 -4
  170. package/dist/server/open-redirect.js +11 -4
  171. package/dist/server/pages-api-route.d.ts +3 -2
  172. package/dist/server/pages-api-route.js +6 -5
  173. package/dist/server/pages-cache-tag.d.ts +12 -0
  174. package/dist/server/pages-cache-tag.js +19 -0
  175. package/dist/server/pages-client-assets.d.ts +2 -0
  176. package/dist/server/pages-data-route.d.ts +10 -0
  177. package/dist/server/pages-data-route.js +21 -3
  178. package/dist/server/pages-document-asset-props.d.ts +5 -1
  179. package/dist/server/pages-document-asset-props.js +13 -5
  180. package/dist/server/pages-document-splice.d.ts +19 -0
  181. package/dist/server/pages-document-splice.js +55 -0
  182. package/dist/server/pages-i18n.d.ts +12 -1
  183. package/dist/server/pages-i18n.js +18 -4
  184. package/dist/server/pages-node-compat.d.ts +16 -5
  185. package/dist/server/pages-node-compat.js +20 -12
  186. package/dist/server/pages-page-data.d.ts +32 -24
  187. package/dist/server/pages-page-data.js +51 -121
  188. package/dist/server/pages-page-handler.d.ts +0 -6
  189. package/dist/server/pages-page-handler.js +189 -127
  190. package/dist/server/pages-page-response.d.ts +12 -6
  191. package/dist/server/pages-page-response.js +42 -35
  192. package/dist/server/pages-request-pipeline.d.ts +10 -2
  193. package/dist/server/pages-request-pipeline.js +41 -22
  194. package/dist/server/pages-request-stage-entry.d.ts +6 -0
  195. package/dist/server/pages-request-stage-entry.js +75 -16
  196. package/dist/server/pages-response-stage-entry.js +4 -0
  197. package/dist/server/pages-revalidate.js +3 -3
  198. package/dist/server/pages-router-entry.js +5 -4
  199. package/dist/server/prerender-manifest.d.ts +3 -3
  200. package/dist/server/prerender-manifest.js +4 -3
  201. package/dist/server/prerender-work-unit-setup.js +4 -0
  202. package/dist/server/prod-server.d.ts +12 -0
  203. package/dist/server/prod-server.js +204 -74
  204. package/dist/server/proper-error.d.ts +4 -0
  205. package/dist/server/proper-error.js +31 -0
  206. package/dist/server/request-pipeline.d.ts +4 -1
  207. package/dist/server/request-pipeline.js +3 -2
  208. package/dist/server/revalidation-request.d.ts +1 -0
  209. package/dist/server/revalidation-request.js +1 -1
  210. package/dist/server/rsc-stream-hints.d.ts +1 -1
  211. package/dist/server/rsc-stream-hints.js +52 -5
  212. package/dist/server/seed-cache.d.ts +1 -0
  213. package/dist/server/seed-cache.js +5 -4
  214. package/dist/server/server-reference-loader.d.ts +4 -0
  215. package/dist/server/server-reference-loader.js +29 -0
  216. package/dist/server/socket-error-backstop.d.ts +9 -1
  217. package/dist/server/socket-error-backstop.js +46 -17
  218. package/dist/server/static-file-signal.d.ts +15 -4
  219. package/dist/server/static-file-signal.js +46 -12
  220. package/dist/server/worker-image-optimization.d.ts +34 -0
  221. package/dist/server/worker-image-optimization.js +99 -0
  222. package/dist/server/worker-stages.d.ts +1 -1
  223. package/dist/server/worker-stages.js +2 -2
  224. package/dist/server/worker-utils.d.ts +8 -3
  225. package/dist/server/worker-utils.js +12 -7
  226. package/dist/shims/app-router-scroll.js +4 -1
  227. package/dist/shims/app-router-tree-context.d.ts +5 -0
  228. package/dist/shims/app-router-tree-context.js +27 -0
  229. package/dist/shims/cache-callable-runtime.d.ts +4 -2
  230. package/dist/shims/cache-callable-runtime.js +21 -12
  231. package/dist/shims/cache-handler.js +1 -9
  232. package/dist/shims/cache-runtime.d.ts +6 -1
  233. package/dist/shims/cache-runtime.js +2 -1
  234. package/dist/shims/cache.d.ts +2 -2
  235. package/dist/shims/cache.js +40 -13
  236. package/dist/shims/cdn-cache.d.ts +8 -0
  237. package/dist/shims/cdn-cache.js +17 -1
  238. package/dist/shims/disable-smooth-scroll.d.ts +3 -0
  239. package/dist/shims/disable-smooth-scroll.js +36 -0
  240. package/dist/shims/document-placeholders.d.ts +19 -0
  241. package/dist/shims/document-placeholders.js +45 -0
  242. package/dist/shims/document.js +21 -5
  243. package/dist/shims/dynamic-preload-chunks.d.ts +1 -0
  244. package/dist/shims/dynamic-preload-chunks.js +13 -9
  245. package/dist/shims/dynamic.d.ts +1 -1
  246. package/dist/shims/dynamic.js +60 -8
  247. package/dist/shims/fetch-cache-state.d.ts +66 -0
  248. package/dist/shims/fetch-cache-state.js +92 -0
  249. package/dist/shims/fetch-cache.d.ts +3 -67
  250. package/dist/shims/fetch-cache.js +160 -125
  251. package/dist/shims/head.d.ts +10 -6
  252. package/dist/shims/head.js +16 -14
  253. package/dist/shims/headers.js +2 -2
  254. package/dist/shims/image.js +2 -1
  255. package/dist/shims/internal/hybrid-client-route-owner-direct.js +1 -1
  256. package/dist/shims/internal/hybrid-client-route-owner.js +1 -0
  257. package/dist/shims/internal/work-store-scope.d.ts +5 -0
  258. package/dist/shims/internal/work-store-scope.js +24 -0
  259. package/dist/shims/link-prefetch.js +5 -4
  260. package/dist/shims/link.js +2 -2
  261. package/dist/shims/navigation.js +34 -9
  262. package/dist/shims/request-context.d.ts +2 -0
  263. package/dist/shims/request-state-types.d.ts +2 -1
  264. package/dist/shims/router.js +21 -32
  265. package/dist/shims/server.d.ts +27 -4
  266. package/dist/shims/server.js +65 -9
  267. package/dist/shims/unified-request-context.d.ts +1 -1
  268. package/dist/shims/url-utils.d.ts +9 -0
  269. package/dist/shims/url-utils.js +15 -4
  270. package/dist/utils/client-runtime-metadata.js +1 -1
  271. package/dist/utils/domain-locale.js +1 -1
  272. package/dist/utils/hash.d.ts +7 -0
  273. package/dist/utils/hash.js +11 -1
  274. package/dist/utils/package-name.d.ts +6 -0
  275. package/dist/utils/package-name.js +12 -1
  276. package/dist/utils/plugin-rsc-version.d.ts +6 -0
  277. package/dist/utils/plugin-rsc-version.js +41 -0
  278. package/dist/utils/prerender-output-paths.js +15 -4
  279. package/dist/utils/public-file-path.d.ts +10 -2
  280. package/dist/utils/public-file-path.js +13 -9
  281. package/dist/utils/public-routes.js +2 -2
  282. package/dist/utils/react-version.d.ts +10 -0
  283. package/dist/utils/react-version.js +39 -16
  284. package/package.json +11 -7
  285. package/dist/build/nitro-route-rules.d.ts +0 -47
  286. package/dist/build/nitro-route-rules.js +0 -79
  287. package/dist/plugins/cache-flight-codec.d.ts +0 -19
  288. package/dist/plugins/cache-flight-codec.js +0 -68
@@ -25,12 +25,12 @@ import { randomUUID } from "node:crypto";
25
25
  const DEFAULT_EXPIRE_TIME = 31536e3;
26
26
  const DEFAULT_REACT_MAX_HEADERS_LENGTH = 6e3;
27
27
  const middlewareRequestHeadersPath = resolveEntryPath("../utils/middleware-request-headers.js", import.meta.url);
28
- const normalizePathModulePath = resolveEntryPath("../server/normalize-path.js", import.meta.url);
29
28
  const appRouteHandlerDispatchPath = resolveEntryPath("../server/app-route-handler-dispatch.js", import.meta.url);
30
29
  const appRouteRequestBuiltInsPath = resolveEntryPath("../server/app-route-request-built-ins.js", import.meta.url);
31
30
  const appRouteHandlerResponsePath = resolveEntryPath("../server/app-route-handler-response.js", import.meta.url);
32
31
  const appRouteHandlerMiddlewareContextPath = resolveEntryPath("../server/app-route-handler-middleware-context.js", import.meta.url);
33
32
  const appServerActionExecutionPath = resolveEntryPath("../server/app-server-action-execution.js", import.meta.url);
33
+ const serverReferenceLoaderPath = resolveEntryPath("../server/server-reference-loader.js", import.meta.url);
34
34
  const appActionForwardingPath = resolveEntryPath("../server/app-action-forwarding.js", import.meta.url);
35
35
  const appMiddlewarePath = resolveEntryPath("../server/app-middleware.js", import.meta.url);
36
36
  const metadataRouteResponsePath = resolveEntryPath("../server/metadata-route-response.js", import.meta.url);
@@ -200,6 +200,7 @@ import { dispatchAppRequestStage as __dispatchAppRequestStage } from ${JSON.stri
200
200
  import { registerConfiguredCacheAdapters as __registerConfiguredCacheAdapters } from "virtual:vinext-cdn-cache-adapter";
201
201
  import { clearAppRequestStageContext as __clearRequestContext, setAppRequestStageNavigationContext as setNavigationContext } from ${JSON.stringify(appRequestStageContextPath)};
202
202
  import { matchRoutePattern as __matchRoutePattern } from ${JSON.stringify(routePatternPath)};
203
+ import __pagesClientAssets from "virtual:vinext-pages-client-assets";
203
204
  ${middlewarePath ? `import { applyAppMiddleware as __applyAppMiddleware } from ${JSON.stringify(appMiddlewarePath)};` : ""}
204
205
  ${instrumentationPath ? `import * as _instrumentation from ${JSON.stringify(toSlash(instrumentationPath))};
205
206
  import { ensureInstrumentationRegistered as __ensureInstrumentationRegistered } from ${JSON.stringify(instrumentationRuntimePath)};
@@ -216,7 +217,6 @@ ${hasPagesDir ? `import { getDraftModeCookieHeader } from "next/headers";
216
217
  import * as __pagesRequestEntry from "virtual:vinext-pages-request-entry";
217
218
  import { renderPagesFallback as __renderPagesFallback } from ${JSON.stringify(appPagesBridgePath)};
218
219
  import { buildRequestHeadersFromMiddlewareResponse as __buildRequestHeadersFromMiddlewareResponse } from ${JSON.stringify(middlewareRequestHeadersPath)};
219
- import { decodePathParams as __decodePathParams } from ${JSON.stringify(normalizePathModulePath)};
220
220
  import { applyRouteHandlerMiddlewareContext as __applyRouteHandlerMiddlewareContext } from ${JSON.stringify(appRouteHandlerMiddlewareContextPath)};` : ""}
221
221
 
222
222
  ${hasPagesDir ? `export function __ensureHybridPagesApplication() {
@@ -238,6 +238,7 @@ export const __imageConfig = ${JSON.stringify({
238
238
  contentDispositionType: config?.imageConfig?.contentDispositionType,
239
239
  contentSecurityPolicy: config?.imageConfig?.contentSecurityPolicy
240
240
  })};
241
+ export const __clientBuildFiles = __pagesClientAssets.clientBuildFiles ?? [];
241
242
  const __routes = ${JSON.stringify(requestRoutes)};
242
243
  const __routeMatcher = __createAppRscRouteMatcher(__routes, ${JSON.stringify(buildAppDecodedPathnamePatterns(routes, config))});
243
244
  const __metadataRouteMatchers = ${JSON.stringify(metadataRouteMatchers)};
@@ -291,6 +292,7 @@ const __requestHandler = createAppRscRequestHandler({
291
292
  fallback: []
292
293
  })},
293
294
  draftModeSecret: __draftModeSecret,
295
+ devForwardedMiddlewareContextKey: ${JSON.stringify(config?.devForwardedMiddlewareContextKey ?? null)},
294
296
  dispatchMatchedPage() { throw new Error("App request stage attempted to render a page inline"); },
295
297
  dispatchMatchedRouteHandler() { throw new Error("App request stage attempted to render a route handler inline"); },
296
298
  ${instrumentationPath ? "ensureInstrumentation() { return __ensureInstrumentation(); }," : ""}
@@ -333,6 +335,7 @@ const __requestHandler = createAppRscRequestHandler({
333
335
  middlewareRequest,
334
336
  module: middlewareModule,
335
337
  request,
338
+ skipTrailingSlashRedirect: ${JSON.stringify(config?.skipTrailingSlashRedirect ?? false)},
336
339
  trailingSlash: __trailingSlash,
337
340
  validateExternalRewriteRequest,
338
341
  });
@@ -358,7 +361,6 @@ const __requestHandler = createAppRscRequestHandler({
358
361
  };
359
362
  },
360
363
  buildRequestHeaders: __buildRequestHeadersFromMiddlewareResponse,
361
- decodePathParams: __decodePathParams,
362
364
  applyRouteHandlerMiddlewareContext: __applyRouteHandlerMiddlewareContext,
363
365
  getDraftModeCookieHeader,
364
366
  }
@@ -366,6 +368,7 @@ const __requestHandler = createAppRscRequestHandler({
366
368
  },` : ""}
367
369
  rootParamNamesByPattern: {},
368
370
  setNavigationContext,
371
+ skipTrailingSlashRedirect: ${JSON.stringify(config?.skipTrailingSlashRedirect ?? false)},
369
372
  staticParamsMap: {},
370
373
  trailingSlash: __trailingSlash,
371
374
  validateDevRequestOrigin: __validateDevRequestOrigin,
@@ -520,14 +523,15 @@ import { registerConfiguredCacheAdapters as __registerConfiguredCacheAdapters }
520
523
  import __pagesClientAssets from "virtual:vinext-pages-client-assets";
521
524
  ${actionOwners === void 0 ? `import __vinextActionOwners from ${JSON.stringify(ACTION_OWNER_MANIFEST_ID)};` : ""}
522
525
  import { setPagesClientAssets as __setPagesClientAssets } from "vinext/server/pages-client-assets";
523
- import { decodePathParams as __decodePathParams } from ${JSON.stringify(normalizePathModulePath)};
524
526
  import { buildRequestHeadersFromMiddlewareResponse as __buildRequestHeadersFromMiddlewareResponse } from ${JSON.stringify(middlewareRequestHeadersPath)};
525
527
  ${hasPagesDir ? `import {
526
528
  applyRouteHandlerMiddlewareContext as __applyRouteHandlerMiddlewareContext,
527
529
  } from ${JSON.stringify(appRouteHandlerResponsePath)};` : ""}
528
530
  const __loadAppRouteHandlerDispatch = () => import(${JSON.stringify(appRouteHandlerDispatchPath)});
529
531
  ${hasServerActions ? `const __loadAppServerActionExecution = () => import(${JSON.stringify(appServerActionExecutionPath)});
530
- const __loadAppActionForwarding = () => import(${JSON.stringify(appActionForwardingPath)});` : ""}
532
+ const __loadAppActionForwarding = () => import(${JSON.stringify(appActionForwardingPath)});
533
+ import { isolateServerReferenceLoads as __isolateServerReferenceLoads } from ${JSON.stringify(serverReferenceLoaderPath)};
534
+ __isolateServerReferenceLoads();` : ""}
531
535
  ${(metadataRoutes?.length ?? 0) > 0 ? `const __loadMetadataRouteResponse = () => import(${JSON.stringify(metadataRouteResponsePath)});` : ""}
532
536
  ${(metadataRoutes?.length ?? 0) > 0 ? `const __loadFileBasedMetadata = () => import(${JSON.stringify(fileBasedMetadataPath)});
533
537
  async function __applyFileBasedMetadata(...args) {
@@ -578,6 +582,8 @@ import {
578
582
  SIBLING_PAGE_INTERCEPT_SLOT_KEY as __SIBLING_PAGE_INTERCEPT_SLOT_KEY,
579
583
  } from ${JSON.stringify(appRscRouteMatchingPath)};
580
584
  import {
585
+ appIsrFallbackShellHtmlKey as __isrFallbackShellHtmlKey,
586
+ appIsrFallbackShellKey as __isrFallbackShellKey,
581
587
  appIsrHtmlKey as __isrHtmlKey,
582
588
  appIsrRscKey as __isrRscKey,
583
589
  appIsrRouteKey as __isrRouteKey,
@@ -949,6 +955,9 @@ export async function seedMemoryCacheFromPrerender(serverDir) {
949
955
  buildAppPageHtmlKey(pathname) {
950
956
  return __isrHtmlKey(pathname);
951
957
  },
958
+ buildAppPageFallbackShellKey(pathname, suffix) {
959
+ return __isrFallbackShellKey(pathname, suffix);
960
+ },
952
961
  buildAppPageRscKey(pathname) {
953
962
  return __isrRscKey(pathname);
954
963
  },
@@ -993,6 +1002,7 @@ ${rootParamNameEntries.join("\n")}
993
1002
  };
994
1003
 
995
1004
  __setPagesClientAssets(__pagesClientAssets);
1005
+ export const __clientBuildFiles = __pagesClientAssets.clientBuildFiles ?? [];
996
1006
  function __VINEXT_ACTION_OWNERS() { return ${actionOwners === void 0 ? "__vinextActionOwners" : safeJsonStringify(actionOwners)}; }
997
1007
  ${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandler = createAppRscHandler({"}
998
1008
  assetPrefix: __assetPrefix,
@@ -1013,6 +1023,7 @@ ${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandle
1013
1023
  imageConfig: __runtimeImageConfig,
1014
1024
  isDev: process.env.NODE_ENV !== "production",
1015
1025
  draftModeSecret: __draftModeSecret,
1026
+ devForwardedMiddlewareContextKey: ${JSON.stringify(config?.devForwardedMiddlewareContextKey ?? null)},
1016
1027
  dispatchMatchedPage({
1017
1028
  bypassInterceptionContextCache,
1018
1029
  cachePathname,
@@ -1136,6 +1147,7 @@ ${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandle
1136
1147
  isRscRequest,
1137
1148
  isrDebug: __isrDebug,
1138
1149
  isrGet: __isrGet,
1150
+ isrFallbackShellHtmlKey: __isrFallbackShellHtmlKey,
1139
1151
  isrHtmlKey(pathname) {
1140
1152
  return __isrHtmlKey(pathname === cleanPathname ? cachePathname : pathname);
1141
1153
  },
@@ -1254,6 +1266,7 @@ ${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandle
1254
1266
  draftModeSecret: __draftModeSecret,
1255
1267
  i18n: __i18nConfig,
1256
1268
  trailingSlash: __trailingSlash,
1269
+ skipTrailingSlashRedirect: ${JSON.stringify(config?.skipTrailingSlashRedirect ?? false)},
1257
1270
  isrDebug: __isrDebug,
1258
1271
  isrGet: __isrGet,
1259
1272
  isrRouteKey(pathname) {
@@ -1617,6 +1630,7 @@ ${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandle
1617
1630
  middlewareRequest,
1618
1631
  module: middlewareModule,
1619
1632
  request,
1633
+ skipTrailingSlashRedirect: ${JSON.stringify(config?.skipTrailingSlashRedirect ?? false)},
1620
1634
  trailingSlash: __trailingSlash,
1621
1635
  validateExternalRewriteRequest,
1622
1636
  });
@@ -1655,7 +1669,6 @@ ${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandle
1655
1669
  };
1656
1670
  },
1657
1671
  buildRequestHeaders: __buildRequestHeadersFromMiddlewareResponse,
1658
- decodePathParams: __decodePathParams,
1659
1672
  applyRouteHandlerMiddlewareContext: __applyRouteHandlerMiddlewareContext,
1660
1673
  getDraftModeCookieHeader,
1661
1674
  }
@@ -1663,6 +1676,7 @@ ${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandle
1663
1676
  },` : ""}
1664
1677
  rootParamNamesByPattern: rootParamNamesMap,
1665
1678
  setNavigationContext,
1679
+ skipTrailingSlashRedirect: ${JSON.stringify(config?.skipTrailingSlashRedirect ?? false)},
1666
1680
  staticParamsMap: generateStaticParamsMap,
1667
1681
  trailingSlash: __trailingSlash,
1668
1682
  validateDevRequestOrigin: __validateDevRequestOrigin,
@@ -6,6 +6,7 @@ import { resolveClientRuntimeModule } from "./runtime-entry-module.js";
6
6
  import { compileMiddlewareMatcherPattern } from "../server/middleware-matcher-pattern.js";
7
7
  import { hasExportedName } from "../build/report.js";
8
8
  import { toClientRewrites } from "../client/client-rewrites.js";
9
+ import { toClientRedirects } from "../client/client-redirects.js";
9
10
  import { readFile } from "node:fs/promises";
10
11
  //#region src/entries/pages-client-entry.ts
11
12
  /**
@@ -67,6 +68,7 @@ async function generateClientEntry(pagesDir, nextConfig, fileMatcher, options =
67
68
  const pagesSsgPatterns = (await Promise.all(pageRoutes.map(async (route) => await hasGetStaticPropsExport(route.filePath) ? patternToNextFormat(route.pattern) : null))).filter((pattern) => pattern !== null);
68
69
  const pagesSspPatterns = (await Promise.all(pageRoutes.map(async (route) => await hasGetServerSidePropsExport(route.filePath) ? patternToNextFormat(route.pattern) : null))).filter((pattern) => pattern !== null);
69
70
  const instrumentationClientPath = options.instrumentationClientPath ?? null;
71
+ const clientRedirects = toClientRedirects(nextConfig.redirects);
70
72
  const clientRewrites = toClientRewrites(nextConfig.rewrites);
71
73
  const clientMiddlewareMatchers = compileClientMiddlewareMatchers(options.middlewareMatcher);
72
74
  const reactInstanceBootstrapPath = resolveClientRuntimeModule("react-instance-bootstrap");
@@ -140,7 +142,7 @@ window.__VINEXT_LINK_PREFETCH_ROUTES__ = ${JSON.stringify(appPrefetchRoutes)};
140
142
  // instead of issuing an RSC request). Set here AND in app-browser-entry.ts
141
143
  // so whichever entry runs first emits the Pages manifest.
142
144
  window.__VINEXT_PAGES_LINK_PREFETCH_ROUTES__ = ${JSON.stringify(pagesPrefetchRoutes)};
143
- window.__VINEXT_CLIENT_REDIRECTS__ = ${JSON.stringify(nextConfig.redirects)};
145
+ window.__VINEXT_CLIENT_REDIRECTS__ = ${JSON.stringify(clientRedirects)};
144
146
  window.__VINEXT_CLIENT_REWRITES__ = ${JSON.stringify(clientRewrites)};
145
147
 
146
148
  const nextDataElement = document.getElementById("__NEXT_DATA__");
@@ -57,6 +57,7 @@ async function generatePagesRequestEntry(pagesDir, nextConfig, fileMatcher, midd
57
57
  basePath: nextConfig?.basePath ?? "",
58
58
  assetPrefix: nextConfig?.assetPrefix ?? "",
59
59
  trailingSlash: nextConfig?.trailingSlash ?? false,
60
+ skipTrailingSlashRedirect: nextConfig?.skipTrailingSlashRedirect ?? false,
60
61
  skipProxyUrlNormalize: nextConfig?.skipProxyUrlNormalize ?? false,
61
62
  redirects: nextConfig?.redirects ?? [],
62
63
  rewrites: nextConfig?.rewrites ?? {
@@ -102,9 +103,11 @@ export function __ensureInstrumentation() {
102
103
  filePath: ${JSON.stringify(middlewarePath)},
103
104
  i18nConfig,
104
105
  isDataRequest: options?.isDataRequest === true,
106
+ isStaleDataRequest: options?.isStaleDataRequest === true,
105
107
  isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},
106
108
  module: middlewareModule,
107
109
  request,
110
+ skipTrailingSlashRedirect: vinextConfig.skipTrailingSlashRedirect,
108
111
  trailingSlash: vinextConfig.trailingSlash,
109
112
  });
110
113
  }` : `export async function runMiddleware() {
@@ -118,6 +121,7 @@ import { buildRouteTrie as _buildRouteTrie, trieMatch as _trieMatch } from ${JSO
118
121
  import { resolvePagesI18nRequest } from ${JSON.stringify(_pagesI18nPath)};
119
122
  import { normalizePagesDataRequest as __normalizePagesDataRequest, shouldAddTrailingSlashToPagesDataPath as __shouldAddTrailingSlashToPagesDataPath } from ${JSON.stringify(_pagesDataRoutePath)};
120
123
  import { isOnDemandRevalidateRequest as __isOnDemandRevalidateRequest } from ${JSON.stringify(_revalidationRequestPath)};
124
+ import __pagesClientAssets from "virtual:vinext-pages-client-assets";
121
125
  ${instrumentationImportCode}
122
126
 
123
127
  ${instrumentationInitCode}
@@ -131,6 +135,7 @@ export const hasMiddleware = ${JSON.stringify(Boolean(middlewarePath))};
131
135
  export const hasRequestAwareDocument = ${JSON.stringify(hasRequestAwareDocument)};
132
136
  export const vinextConfig = ${vinextConfigJson};
133
137
  export const publicFiles = new Set(${JSON.stringify(publicFiles)});
138
+ export const clientBuildFiles = new Set(__pagesClientAssets.clientBuildFiles ?? []);
134
139
 
135
140
  export function normalizeDataRequest(request) {
136
141
  return __normalizePagesDataRequest(
@@ -227,6 +232,7 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
227
232
  basePath: nextConfig?.basePath ?? "",
228
233
  assetPrefix: nextConfig?.assetPrefix ?? "",
229
234
  trailingSlash: nextConfig?.trailingSlash ?? false,
235
+ skipTrailingSlashRedirect: nextConfig?.skipTrailingSlashRedirect ?? false,
230
236
  skipProxyUrlNormalize: nextConfig?.skipProxyUrlNormalize ?? false,
231
237
  redirects: nextConfig?.redirects ?? [],
232
238
  rewrites: nextConfig?.rewrites ?? {
@@ -292,9 +298,11 @@ export async function runMiddleware(request, ctx, options) {
292
298
  filePath: ${JSON.stringify(middlewarePath)},
293
299
  i18nConfig,
294
300
  isDataRequest: options?.isDataRequest === true,
301
+ isStaleDataRequest: options?.isStaleDataRequest === true,
295
302
  isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},
296
303
  module: middlewareModule,
297
304
  request,
305
+ skipTrailingSlashRedirect: vinextConfig.skipTrailingSlashRedirect,
298
306
  trailingSlash: vinextConfig.trailingSlash,
299
307
  });
300
308
  }
@@ -311,16 +319,16 @@ import { renderToReadableStream } from "react-dom/server.edge";
311
319
  import { resetSSRHead, getSSRHeadHTML, setDocumentInitialHead } from "next/head";
312
320
  import { flushPreloads } from "next/dynamic";
313
321
  import Router, { setSSRContext, wrapWithRouterContext, getPagesNavigationIsReadyFromSerializedState } from "next/router";
314
- import { _runWithCacheState } from "vinext/shims/cache-request-state";
322
+ import "vinext/shims/cache-request-state";
315
323
  import { configureMemoryCacheHandler as __configureMemoryCacheHandler } from "vinext/shims/cache-handler";
316
324
  import { registerConfiguredCacheAdapters as __registerConfiguredCacheAdapters } from "virtual:vinext-cache-adapters";
317
325
  import __pagesClientAssets from "virtual:vinext-pages-client-assets";
318
326
  import { setPagesClientAssets as __setPagesClientAssets } from "vinext/server/pages-client-assets";
319
- import { runWithPrivateCache } from "vinext/cache-runtime";
320
- import { ensureFetchPatch, runWithFetchCache } from "vinext/fetch-cache";
327
+ import "vinext/cache-runtime";
328
+ import { ensureFetchPatch } from "vinext/fetch-cache";
321
329
  import "vinext/router-state";
322
- import { runWithServerInsertedHTMLState } from "vinext/navigation-state";
323
- import { runWithHeadState } from "vinext/head-state";
330
+ import "vinext/navigation-state";
331
+ import "vinext/head-state";
324
332
  import "vinext/i18n-state";
325
333
  import { setI18nContext } from "vinext/i18n-context";
326
334
  import { safeJsonStringify } from "vinext/html";
@@ -388,37 +396,6 @@ __configureMemoryCacheHandler({ cacheMaxMemorySize: vinextConfig.cacheMaxMemoryS
388
396
  // by _app are included in every page's <link rel="stylesheet"> set.
389
397
  const _appAssetPath = ${appAssetPathJson};
390
398
 
391
- async function _renderToStringAsync(element) {
392
- const stream = await renderToReadableStream(element);
393
- await stream.allReady;
394
- return new Response(stream).text();
395
- }
396
-
397
- async function _renderIsrPassToStringAsync(element, onHeadReady) {
398
- // The cache-fill render is a second render pass for the same request.
399
- // Reset render-scoped state so it cannot leak from the streamed response
400
- // render or affect async work that is still draining from that stream.
401
- // Keep request identity state (pathname/query/locale/executionContext)
402
- // intact: this second pass still belongs to the same request.
403
- return await runWithServerInsertedHTMLState(() =>
404
- runWithHeadState(() =>
405
- _runWithCacheState(() =>
406
- runWithPrivateCache(() =>
407
- runWithFetchCache(async () => {
408
- const html = await _renderToStringAsync(element);
409
- // next/head tags are collected as a side effect of the render
410
- // above and live in this ALS scope only, so a caller that wants
411
- // the regenerated head has to read it here — after the render,
412
- // before the scope unwinds.
413
- await onHeadReady?.();
414
- return html;
415
- }),
416
- ),
417
- ),
418
- ),
419
- );
420
- }
421
-
422
399
  ${pageImports.join("\n")}
423
400
  ${apiImports.join("\n")}
424
401
 
@@ -552,7 +529,6 @@ function __createRenderPage() {
552
529
  } catch { return []; }
553
530
  },
554
531
  renderToReadableStream,
555
- renderIsrPassToStringAsync: _renderIsrPassToStringAsync,
556
532
  safeJsonStringify,
557
533
  sanitizeDestination: sanitizeDestinationLocal,
558
534
  createPageElement(PageComponent, AppComponent, props) {
package/dist/index.d.ts CHANGED
@@ -39,7 +39,9 @@ export type VinextOptions = {
39
39
  ssrOutDir?: string;
40
40
  /**
41
41
  * Override the output directory for the client bundle.
42
- * Defaults to Vite's default (dist/client or dist).
42
+ * Defaults to "dist/client". Like rscOutDir and ssrOutDir, it is not
43
+ * supported by `vinext start` or `output: "standalone"`, which expect the
44
+ * default dist/ layout.
43
45
  */
44
46
  clientOutDir?: string;
45
47
  /**