vinext 1.2.1 → 1.3.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 (509) hide show
  1. package/README.md +12 -9
  2. package/dist/_virtual/_rolldown/runtime.js +1 -1
  3. package/dist/build/action-owner-manifest.d.ts +3 -2
  4. package/dist/build/action-owner-manifest.js +18 -2
  5. package/dist/build/app-page-static-eligibility.d.ts +17 -1
  6. package/dist/build/app-page-static-eligibility.js +80 -13
  7. package/dist/build/clean-output.d.ts +2 -1
  8. package/dist/build/client-build-config.d.ts +77 -6
  9. package/dist/build/client-build-config.js +176 -12
  10. package/dist/build/client-reference-async.d.ts +48 -0
  11. package/dist/build/client-reference-async.js +123 -0
  12. package/dist/build/client-reference-chunks.d.ts +32 -0
  13. package/dist/build/client-reference-chunks.js +111 -0
  14. package/dist/build/client-reference-groups.d.ts +171 -0
  15. package/dist/build/client-reference-groups.js +572 -0
  16. package/dist/build/css-url-assets.d.ts +2 -1
  17. package/dist/build/google-fonts/fallback-metrics.d.ts +2 -1
  18. package/dist/build/google-fonts/find-font-files-in-css.d.ts +1 -0
  19. package/dist/build/google-fonts/find-font-files-in-css.js +17 -4
  20. package/dist/build/google-fonts/font-metadata.d.ts +2 -1
  21. package/dist/build/google-fonts/validate.d.ts +2 -1
  22. package/dist/build/inline-css.d.ts +2 -1
  23. package/dist/build/layout-classification.d.ts +2 -1
  24. package/dist/build/module-dependency-cache.d.ts +33 -1
  25. package/dist/build/module-dependency-cache.js +51 -1
  26. package/dist/build/next-client-runtime-manifests.d.ts +12 -2
  27. package/dist/build/next-client-runtime-manifests.js +19 -4
  28. package/dist/build/nitro-public-files.d.ts +24 -0
  29. package/dist/build/nitro-public-files.js +60 -0
  30. package/dist/build/pages-client-assets-module.js +1 -1
  31. package/dist/build/precompress.d.ts +2 -1
  32. package/dist/build/precompress.js +1 -1
  33. package/dist/build/prerender-paths.d.ts +2 -1
  34. package/dist/build/prerender-paths.js +5 -2
  35. package/dist/build/prerender-phase.d.ts +2 -1
  36. package/dist/build/prerender-server-pool.js +1 -1
  37. package/dist/build/prerender.d.ts +3 -2
  38. package/dist/build/prerender.js +5 -4
  39. package/dist/build/report.d.ts +2 -1
  40. package/dist/build/route-classification-injector.d.ts +2 -1
  41. package/dist/build/route-classification-manifest.d.ts +2 -1
  42. package/dist/build/run-prerender.d.ts +2 -1
  43. package/dist/build/server-actions-encryption-key.d.ts +24 -0
  44. package/dist/build/server-actions-encryption-key.js +101 -0
  45. package/dist/build/ssr-manifest.d.ts +3 -0
  46. package/dist/build/ssr-manifest.js +34 -2
  47. package/dist/build/standalone.d.ts +2 -1
  48. package/dist/cache/cache-adapters-virtual.d.ts +2 -1
  49. package/dist/cache.js +1 -2
  50. package/dist/check.d.ts +2 -1
  51. package/dist/check.js +4 -0
  52. package/dist/cli-args.d.ts +2 -1
  53. package/dist/cli.js +2 -0
  54. package/dist/client/client-redirect-matcher.js +2 -1
  55. package/dist/client/client-redirects.d.ts +4 -3
  56. package/dist/client/client-redirects.js +2 -1
  57. package/dist/client/client-rewrite-params.d.ts +9 -0
  58. package/dist/client/client-rewrite-params.js +20 -0
  59. package/dist/client/client-rewrites.d.ts +2 -1
  60. package/dist/client/dev-error-overlay-store.d.ts +2 -1
  61. package/dist/client/dev-error-overlay.js +2 -1
  62. package/dist/client/index.js +1 -2
  63. package/dist/client/instrumentation-client-state.js +5 -5
  64. package/dist/client/navigation-runtime.d.ts +28 -3
  65. package/dist/client/navigation-runtime.js +42 -11
  66. package/dist/client/pages-router-link-navigation.d.ts +2 -1
  67. package/dist/client/vinext-next-data.d.ts +25 -2
  68. package/dist/client/window-next.d.ts +2 -1
  69. package/dist/config/config-matchers.d.ts +27 -41
  70. package/dist/config/config-matchers.js +293 -270
  71. package/dist/config/config-source.d.ts +34 -0
  72. package/dist/config/config-source.js +141 -0
  73. package/dist/config/dotenv.d.ts +2 -1
  74. package/dist/config/header-params.d.ts +29 -0
  75. package/dist/config/header-params.js +106 -0
  76. package/dist/config/next-config.d.ts +20 -6
  77. package/dist/config/next-config.js +149 -11
  78. package/dist/config/tsconfig-paths.d.ts +2 -1
  79. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/detector.js +23 -0
  80. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/index.js +2 -0
  81. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/lookup.js +25 -0
  82. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/bmp.js +11 -0
  83. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/cur.js +15 -0
  84. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/dds.js +11 -0
  85. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/gif.js +12 -0
  86. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/heif.js +55 -0
  87. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/icns.js +76 -0
  88. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/ico.js +39 -0
  89. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/index.js +46 -0
  90. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/j2c.js +11 -0
  91. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jp2.js +21 -0
  92. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jpg.js +71 -0
  93. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jxl-stream.js +42 -0
  94. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jxl.js +46 -0
  95. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/ktx.js +19 -0
  96. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/png.js +28 -0
  97. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/pnm.js +54 -0
  98. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/psd.js +11 -0
  99. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/svg.js +79 -0
  100. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/tga.js +15 -0
  101. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/tiff.js +96 -0
  102. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/utils.js +53 -0
  103. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/webp.js +45 -0
  104. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/utils/bit-reader.js +38 -0
  105. package/dist/deps/.pnpm/ua-parser-js@1.0.35/deps/ua-parser-js/src/ua-parser.js +2 -2
  106. package/dist/entries/app-browser-entry.d.ts +34 -6
  107. package/dist/entries/app-browser-entry.js +103 -40
  108. package/dist/entries/app-rsc-entry.d.ts +4 -1
  109. package/dist/entries/app-rsc-entry.js +131 -66
  110. package/dist/entries/app-rsc-manifest.d.ts +12 -1
  111. package/dist/entries/app-rsc-manifest.js +73 -1
  112. package/dist/entries/app-ssr-entry.d.ts +4 -1
  113. package/dist/entries/app-ssr-entry.js +9 -2
  114. package/dist/entries/pages-client-entry.d.ts +1 -0
  115. package/dist/entries/pages-client-entry.js +6 -6
  116. package/dist/entries/pages-entry-helpers.js +1 -2
  117. package/dist/entries/pages-server-entry.d.ts +2 -1
  118. package/dist/entries/pages-server-entry.js +18 -15
  119. package/dist/entries/runtime-entry-module.d.ts +1 -0
  120. package/dist/entries/runtime-entry-module.js +4 -1
  121. package/dist/image/image-adapters-virtual.d.ts +2 -1
  122. package/dist/index.d.ts +11 -0
  123. package/dist/index.js +340 -116
  124. package/dist/init.js +17 -0
  125. package/dist/plugins/client-compile-hints.d.ts +30 -0
  126. package/dist/plugins/client-compile-hints.js +88 -0
  127. package/dist/plugins/client-reference-dedup.d.ts +2 -1
  128. package/dist/plugins/cloudflare-dev-module-urls.d.ts +2 -1
  129. package/dist/plugins/dynamic-preload-metadata.d.ts +3 -1
  130. package/dist/plugins/dynamic-preload-metadata.js +1 -1
  131. package/dist/plugins/environment.d.ts +2 -1
  132. package/dist/plugins/fonts.js +9 -12
  133. package/dist/plugins/ignore-dynamic-requests.d.ts +2 -1
  134. package/dist/plugins/import-meta-url.d.ts +2 -1
  135. package/dist/plugins/og-assets.d.ts +2 -1
  136. package/dist/plugins/og-assets.js +2 -3
  137. package/dist/plugins/optimize-imports.d.ts +27 -3
  138. package/dist/plugins/optimize-imports.js +106 -20
  139. package/dist/plugins/pages-node-externals.d.ts +2 -1
  140. package/dist/plugins/remove-console.d.ts +2 -1
  141. package/dist/plugins/require-condition-resolution.d.ts +2 -1
  142. package/dist/plugins/rsc-client-reference-loaders.d.ts +53 -1
  143. package/dist/plugins/rsc-client-reference-loaders.js +447 -27
  144. package/dist/plugins/rsc-client-shim-excludes.js +2 -0
  145. package/dist/plugins/sass.d.ts +2 -1
  146. package/dist/plugins/strip-server-exports.d.ts +2 -1
  147. package/dist/plugins/styled-jsx.d.ts +2 -1
  148. package/dist/plugins/transform-result.d.ts +2 -1
  149. package/dist/plugins/typeof-window.d.ts +2 -1
  150. package/dist/plugins/use-cache-callable.d.ts +5 -0
  151. package/dist/plugins/use-cache-callable.js +30 -8
  152. package/dist/plugins/worker-image-imports.d.ts +1 -0
  153. package/dist/plugins/worker-image-imports.js +2 -2
  154. package/dist/plugins/worker-use-server.d.ts +2 -1
  155. package/dist/routing/app-route-graph.d.ts +41 -1
  156. package/dist/routing/app-route-graph.js +122 -50
  157. package/dist/routing/browser-route-manifest.d.ts +44 -0
  158. package/dist/routing/browser-route-manifest.js +195 -0
  159. package/dist/routing/hashed-route-patterns.d.ts +4 -0
  160. package/dist/routing/hashed-route-patterns.js +22 -0
  161. package/dist/routing/optimistic-route-trie.d.ts +28 -0
  162. package/dist/routing/optimistic-route-trie.js +102 -0
  163. package/dist/routing/route-matching.d.ts +2 -1
  164. package/dist/routing/route-pattern.d.ts +2 -1
  165. package/dist/routing/route-validation.d.ts +6 -1
  166. package/dist/routing/route-validation.js +26 -10
  167. package/dist/server/accept-encoding.d.ts +2 -1
  168. package/dist/server/app-action-forwarding.d.ts +10 -1
  169. package/dist/server/app-action-forwarding.js +15 -1
  170. package/dist/server/app-bfcache-identity.d.ts +2 -1
  171. package/dist/server/app-browser-action-result.d.ts +2 -1
  172. package/dist/server/app-browser-client-reuse-manifest.d.ts +2 -1
  173. package/dist/server/app-browser-entry.js +175 -64
  174. package/dist/server/app-browser-error.d.ts +5 -2
  175. package/dist/server/app-browser-error.js +7 -2
  176. package/dist/server/app-browser-history-controller.d.ts +2 -1
  177. package/dist/server/app-browser-hydration.d.ts +2 -1
  178. package/dist/server/app-browser-interception-context.d.ts +4 -3
  179. package/dist/server/app-browser-mpa-navigation.d.ts +1 -0
  180. package/dist/server/app-browser-mpa-navigation.js +6 -5
  181. package/dist/server/app-browser-navigation-controller.d.ts +17 -6
  182. package/dist/server/app-browser-navigation-controller.js +103 -36
  183. package/dist/server/app-browser-popstate.d.ts +2 -1
  184. package/dist/server/app-browser-rsc-redirect.d.ts +2 -1
  185. package/dist/server/app-browser-server-action-client.d.ts +2 -1
  186. package/dist/server/app-browser-state.d.ts +2 -2
  187. package/dist/server/app-browser-state.js +1 -1
  188. package/dist/server/app-browser-stream.d.ts +2 -1
  189. package/dist/server/app-browser-visible-commit.d.ts +6 -5
  190. package/dist/server/app-client-reference-manifest.d.ts +31 -0
  191. package/dist/server/app-client-reference-manifest.js +46 -0
  192. package/dist/server/app-client-reference-preloader.d.ts +45 -2
  193. package/dist/server/app-client-reference-preloader.js +48 -10
  194. package/dist/server/app-elements-wire.d.ts +2 -1
  195. package/dist/server/app-elements.d.ts +2 -0
  196. package/dist/server/app-elements.js +3 -1
  197. package/dist/server/app-fallback-renderer.d.ts +9 -2
  198. package/dist/server/app-fallback-renderer.js +6 -2
  199. package/dist/server/app-history-state.d.ts +2 -1
  200. package/dist/server/app-inline-css-client.d.ts +2 -1
  201. package/dist/server/app-layout-param-observation.d.ts +2 -1
  202. package/dist/server/app-metadata-tracing.d.ts +2 -1
  203. package/dist/server/app-middleware.d.ts +6 -0
  204. package/dist/server/app-middleware.js +8 -10
  205. package/dist/server/app-optimistic-routing.d.ts +26 -11
  206. package/dist/server/app-optimistic-routing.js +38 -96
  207. package/dist/server/app-page-boundary-render.d.ts +20 -2
  208. package/dist/server/app-page-boundary-render.js +229 -39
  209. package/dist/server/app-page-boundary.d.ts +34 -5
  210. package/dist/server/app-page-boundary.js +40 -7
  211. package/dist/server/app-page-cache-finalizer.d.ts +2 -1
  212. package/dist/server/app-page-cache-finalizer.js +1 -1
  213. package/dist/server/app-page-cache-render.d.ts +10 -2
  214. package/dist/server/app-page-cache-render.js +15 -2
  215. package/dist/server/app-page-cache.js +2 -2
  216. package/dist/server/app-page-dispatch.d.ts +34 -1
  217. package/dist/server/app-page-dispatch.js +165 -34
  218. package/dist/server/app-page-element-builder.d.ts +17 -1
  219. package/dist/server/app-page-element-builder.js +187 -66
  220. package/dist/server/app-page-execution.d.ts +28 -1
  221. package/dist/server/app-page-execution.js +114 -5
  222. package/dist/server/app-page-head.d.ts +95 -3
  223. package/dist/server/app-page-head.js +307 -152
  224. package/dist/server/app-page-http-access-fallback-metadata.d.ts +48 -2
  225. package/dist/server/app-page-http-access-fallback-metadata.js +76 -1
  226. package/dist/server/app-page-method.d.ts +2 -1
  227. package/dist/server/app-page-probe.d.ts +2 -1
  228. package/dist/server/app-page-render-identity.d.ts +2 -1
  229. package/dist/server/app-page-render.d.ts +7 -1
  230. package/dist/server/app-page-render.js +38 -11
  231. package/dist/server/app-page-request.d.ts +14 -1
  232. package/dist/server/app-page-request.js +1 -1
  233. package/dist/server/app-page-route-wiring.d.ts +52 -2
  234. package/dist/server/app-page-route-wiring.js +197 -47
  235. package/dist/server/app-page-rsc-render-status.d.ts +3 -1
  236. package/dist/server/app-page-rsc-render-status.js +1 -0
  237. package/dist/server/app-page-search-params-observation.d.ts +8 -6
  238. package/dist/server/app-page-search-params-observation.js +16 -11
  239. package/dist/server/app-page-segment-plan.d.ts +2 -1
  240. package/dist/server/app-page-stream.d.ts +38 -1
  241. package/dist/server/app-page-stream.js +24 -4
  242. package/dist/server/app-pages-bridge.d.ts +4 -2
  243. package/dist/server/app-pages-bridge.js +11 -7
  244. package/dist/server/app-ppr-fallback-shell-render.d.ts +2 -1
  245. package/dist/server/app-ppr-fallback-shell.d.ts +2 -1
  246. package/dist/server/app-prerender-endpoints.d.ts +2 -1
  247. package/dist/server/app-prerender-static-params.d.ts +2 -1
  248. package/dist/server/app-prerender-static-params.js +3 -2
  249. package/dist/server/app-render-dependency.d.ts +11 -1
  250. package/dist/server/app-render-dependency.js +65 -6
  251. package/dist/server/app-request-stage-independent-entry.d.ts +2 -1
  252. package/dist/server/app-request-stage-independent-entry.js +2 -2
  253. package/dist/server/app-response-stage-entry.d.ts +2 -1
  254. package/dist/server/app-response-stage-entry.js +3 -3
  255. package/dist/server/app-route-handler-cache.d.ts +2 -1
  256. package/dist/server/app-route-handler-dispatch.d.ts +2 -1
  257. package/dist/server/app-route-handler-dispatch.js +4 -2
  258. package/dist/server/app-route-handler-execution.d.ts +4 -1
  259. package/dist/server/app-route-handler-execution.js +9 -2
  260. package/dist/server/app-route-handler-middleware-context.d.ts +2 -1
  261. package/dist/server/app-route-handler-middleware-context.js +3 -3
  262. package/dist/server/app-route-handler-response.d.ts +4 -2
  263. package/dist/server/app-route-handler-response.js +2 -2
  264. package/dist/server/app-route-handler-runtime.d.ts +4 -1
  265. package/dist/server/app-route-handler-runtime.js +20 -3
  266. package/dist/server/app-route-module-loader.d.ts +18 -1
  267. package/dist/server/app-route-module-loader.js +15 -6
  268. package/dist/server/app-route-tree-prefetch.d.ts +2 -1
  269. package/dist/server/app-route-tree.d.ts +20 -0
  270. package/dist/server/app-route-tree.js +18 -0
  271. package/dist/server/app-router-entry.js +2 -2
  272. package/dist/server/app-rsc-combined-handler.js +8 -1
  273. package/dist/server/app-rsc-error-handler.d.ts +2 -1
  274. package/dist/server/app-rsc-errors.d.ts +9 -1
  275. package/dist/server/app-rsc-errors.js +9 -2
  276. package/dist/server/app-rsc-handler.d.ts +6 -2
  277. package/dist/server/app-rsc-handler.js +152 -140
  278. package/dist/server/app-rsc-response-finalizer.d.ts +7 -1
  279. package/dist/server/app-rsc-response-finalizer.js +4 -1
  280. package/dist/server/app-rsc-response-stage.js +3 -1
  281. package/dist/server/app-rsc-route-matching.d.ts +39 -1
  282. package/dist/server/app-rsc-route-matching.js +25 -1
  283. package/dist/server/app-segment-config.d.ts +2 -1
  284. package/dist/server/app-segment-config.js +1 -14
  285. package/dist/server/app-server-action-execution.d.ts +25 -7
  286. package/dist/server/app-server-action-execution.js +53 -59
  287. package/dist/server/app-ssr-entry.d.ts +12 -0
  288. package/dist/server/app-ssr-entry.js +104 -48
  289. package/dist/server/app-ssr-error-meta.d.ts +2 -1
  290. package/dist/server/app-ssr-search-params-gate.d.ts +2 -1
  291. package/dist/server/app-ssr-stream.d.ts +29 -10
  292. package/dist/server/app-ssr-stream.js +311 -67
  293. package/dist/server/app-static-generation.d.ts +2 -1
  294. package/dist/server/app-streamed-client-references.d.ts +39 -0
  295. package/dist/server/app-streamed-client-references.js +156 -0
  296. package/dist/server/app-visited-response-cache.d.ts +2 -1
  297. package/dist/server/app-worker-stages.d.ts +2 -1
  298. package/dist/server/artifact-compatibility.d.ts +2 -1
  299. package/dist/server/bfcache-identity.d.ts +2 -1
  300. package/dist/server/cache-headers.d.ts +2 -1
  301. package/dist/server/cacheability-request.d.ts +2 -1
  302. package/dist/server/client-reuse-manifest.d.ts +2 -1
  303. package/dist/server/config-headers.d.ts +2 -1
  304. package/dist/server/config-headers.js +12 -3
  305. package/dist/server/csp.d.ts +2 -1
  306. package/dist/server/default-global-not-found-module.d.ts +2 -1
  307. package/dist/server/default-http-access-fallback-modules.d.ts +33 -0
  308. package/dist/server/default-http-access-fallback-modules.js +31 -0
  309. package/dist/server/defer-until-stream-consumed.d.ts +34 -0
  310. package/dist/server/defer-until-stream-consumed.js +154 -21
  311. package/dist/server/dev-lockfile.d.ts +32 -2
  312. package/dist/server/dev-lockfile.js +46 -2
  313. package/dist/server/dev-module-runner.d.ts +2 -1
  314. package/dist/server/dev-server.js +10 -3
  315. package/dist/server/fetch-handler.js +1 -2
  316. package/dist/server/file-based-metadata.d.ts +2 -1
  317. package/dist/server/framework-tracer.d.ts +2 -1
  318. package/dist/server/html.d.ts +1 -0
  319. package/dist/server/html.js +19 -1
  320. package/dist/server/http-conditional.d.ts +2 -1
  321. package/dist/server/http-error-responses.d.ts +2 -1
  322. package/dist/server/implicit-tags.d.ts +2 -1
  323. package/dist/server/isolate-shared-promise.d.ts +10 -0
  324. package/dist/server/isolate-shared-promise.js +33 -0
  325. package/dist/server/isr-cache.js +3 -2
  326. package/dist/server/metadata-route-build-data.d.ts +2 -1
  327. package/dist/server/metadata-route-build-data.js +1 -1
  328. package/dist/server/metadata-route-response.d.ts +2 -1
  329. package/dist/server/metadata-route-response.js +1 -1
  330. package/dist/server/metadata-routes.d.ts +2 -1
  331. package/dist/server/middleware-matcher-pattern.d.ts +0 -1
  332. package/dist/server/middleware-matcher-pattern.js +11 -140
  333. package/dist/server/middleware-matcher.js +5 -6
  334. package/dist/server/middleware-response-headers.d.ts +31 -0
  335. package/dist/server/middleware-response-headers.js +57 -1
  336. package/dist/server/middleware-runtime.d.ts +2 -1
  337. package/dist/server/middleware-runtime.js +26 -13
  338. package/dist/server/navigation-planner.d.ts +2 -2
  339. package/dist/server/navigation-trace.d.ts +2 -1
  340. package/dist/server/next-error-digest.d.ts +2 -1
  341. package/dist/server/nitro-public-files-plugin.d.ts +39 -0
  342. package/dist/server/nitro-public-files-plugin.js +106 -0
  343. package/dist/server/nitro-public-files.d.ts +22 -0
  344. package/dist/server/nitro-public-files.js +39 -0
  345. package/dist/server/opentelemetry-api.d.ts +2 -1
  346. package/dist/server/operation-token.d.ts +2 -1
  347. package/dist/server/pages-api-route.d.ts +2 -1
  348. package/dist/server/pages-asset-tags.d.ts +7 -1
  349. package/dist/server/pages-asset-tags.js +9 -2
  350. package/dist/server/pages-body-parser-config.d.ts +2 -1
  351. package/dist/server/pages-client-assets.d.ts +8 -1
  352. package/dist/server/pages-data-route.d.ts +2 -1
  353. package/dist/server/pages-document-asset-props.d.ts +2 -1
  354. package/dist/server/pages-document-initial-props.d.ts +2 -1
  355. package/dist/server/pages-execution-tracing.d.ts +2 -1
  356. package/dist/server/pages-execution-tracing.js +1 -1
  357. package/dist/server/pages-get-initial-props.d.ts +2 -1
  358. package/dist/server/pages-i18n.d.ts +18 -0
  359. package/dist/server/pages-i18n.js +18 -2
  360. package/dist/server/pages-node-compat.d.ts +5 -3
  361. package/dist/server/pages-node-compat.js +35 -16
  362. package/dist/server/pages-page-data.d.ts +7 -1
  363. package/dist/server/pages-page-data.js +35 -12
  364. package/dist/server/pages-page-handler.d.ts +3 -2
  365. package/dist/server/pages-page-handler.js +16 -7
  366. package/dist/server/pages-page-method.d.ts +2 -1
  367. package/dist/server/pages-page-response.d.ts +2 -1
  368. package/dist/server/pages-preview.d.ts +2 -1
  369. package/dist/server/pages-readiness.d.ts +2 -1
  370. package/dist/server/pages-request-pipeline.d.ts +8 -2
  371. package/dist/server/pages-request-pipeline.js +35 -40
  372. package/dist/server/pages-request-stage-entry.d.ts +2 -1
  373. package/dist/server/pages-request-stage-entry.js +16 -6
  374. package/dist/server/pages-response-stage-entry.d.ts +2 -1
  375. package/dist/server/pages-response-stage-entry.js +1 -1
  376. package/dist/server/pages-revalidate.js +1 -0
  377. package/dist/server/pages-route-data-kind.d.ts +2 -1
  378. package/dist/server/pages-router-entry.js +1 -1
  379. package/dist/server/prerender-cache-life-header.d.ts +2 -1
  380. package/dist/server/prerender-route-params.d.ts +2 -1
  381. package/dist/server/prod-server.d.ts +2 -2
  382. package/dist/server/prod-server.js +80 -36
  383. package/dist/server/proxy-trust.d.ts +6 -0
  384. package/dist/server/proxy-trust.js +12 -6
  385. package/dist/server/request-log.d.ts +2 -1
  386. package/dist/server/request-pipeline.d.ts +5 -0
  387. package/dist/server/request-pipeline.js +12 -1
  388. package/dist/server/request-tracing.d.ts +2 -1
  389. package/dist/server/request-tracing.js +1 -1
  390. package/dist/server/response-start-tracing.js +7 -29
  391. package/dist/server/rsc-render-stream.d.ts +4 -0
  392. package/dist/server/rsc-render-stream.js +25 -0
  393. package/dist/server/seed-cache.d.ts +2 -1
  394. package/dist/server/seed-cache.js +1 -1
  395. package/dist/server/server-reference-loader.js +10 -1
  396. package/dist/server/static-file-cache.d.ts +2 -1
  397. package/dist/server/static-file-cache.js +16 -3
  398. package/dist/server/static-layout-client-reuse-proof.d.ts +2 -1
  399. package/dist/server/worker-revalidation-context.d.ts +2 -1
  400. package/dist/server/worker-stages.d.ts +2 -1
  401. package/dist/server/worker-utils.js +1 -1
  402. package/dist/shims/app.d.ts +2 -1
  403. package/dist/shims/cache-callable-runtime.d.ts +2 -1
  404. package/dist/shims/cache-handler.d.ts +8 -3
  405. package/dist/shims/cache-handler.js +32 -11
  406. package/dist/shims/cache-request-state.d.ts +40 -3
  407. package/dist/shims/cache-request-state.js +70 -5
  408. package/dist/shims/cache-runtime.js +47 -19
  409. package/dist/shims/cache.d.ts +2 -2
  410. package/dist/shims/cache.js +17 -8
  411. package/dist/shims/caught-not-found-boundaries.d.ts +15 -0
  412. package/dist/shims/caught-not-found-boundaries.js +48 -0
  413. package/dist/shims/cdn-purge-routes.d.ts +25 -0
  414. package/dist/shims/cdn-purge-routes.js +77 -0
  415. package/dist/shims/client-locale.js +2 -1
  416. package/dist/shims/client-page-root.d.ts +2 -1
  417. package/dist/shims/config.d.ts +2 -1
  418. package/dist/shims/default-forbidden.d.ts +4 -0
  419. package/dist/shims/default-forbidden.js +18 -0
  420. package/dist/shims/default-not-found.d.ts +0 -5
  421. package/dist/shims/default-not-found.js +5 -41
  422. package/dist/shims/default-unauthorized.d.ts +4 -0
  423. package/dist/shims/default-unauthorized.js +18 -0
  424. package/dist/shims/dynamic.js +17 -4
  425. package/dist/shims/error-boundary.d.ts +39 -3
  426. package/dist/shims/error-boundary.js +31 -16
  427. package/dist/shims/font-google.js +1 -2
  428. package/dist/shims/font-utils.d.ts +3 -2
  429. package/dist/shims/font-utils.js +5 -3
  430. package/dist/shims/form.js +9 -4
  431. package/dist/shims/http-access-error-fallback.d.ts +7 -0
  432. package/dist/shims/http-access-error-fallback.js +47 -0
  433. package/dist/shims/image-props.d.ts +93 -0
  434. package/dist/shims/image-props.js +323 -0
  435. package/dist/shims/image.d.ts +4 -39
  436. package/dist/shims/image.js +4 -319
  437. package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +22 -2
  438. package/dist/shims/internal/app-prefetch-fetch-queue.js +71 -18
  439. package/dist/shims/internal/app-route-prefetch-policy.d.ts +14 -3
  440. package/dist/shims/internal/app-route-prefetch-policy.js +29 -4
  441. package/dist/shims/internal/cache-context-accessor.d.ts +2 -1
  442. package/dist/shims/internal/client-reference-loader.d.ts +7 -0
  443. package/dist/shims/internal/client-reference-loader.js +91 -0
  444. package/dist/shims/internal/cookie-serialize.d.ts +2 -1
  445. package/dist/shims/internal/cookies.js +1 -2
  446. package/dist/shims/internal/headers-state.d.ts +9 -0
  447. package/dist/shims/internal/headers-state.js +19 -2
  448. package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +6 -2
  449. package/dist/shims/internal/hybrid-client-route-owner-direct.js +31 -14
  450. package/dist/shims/internal/hybrid-client-route-owner.js +8 -8
  451. package/dist/shims/internal/interpolate-as.d.ts +2 -1
  452. package/dist/shims/internal/pages-data-target.d.ts +2 -1
  453. package/dist/shims/internal/pages-data-url.d.ts +2 -1
  454. package/dist/shims/internal/thenable-well-known-properties.d.ts +2 -1
  455. package/dist/shims/link.js +198 -53
  456. package/dist/shims/metadata.d.ts +32 -11
  457. package/dist/shims/metadata.js +88 -26
  458. package/dist/shims/navigation-errors.d.ts +2 -1
  459. package/dist/shims/navigation.d.ts +23 -3
  460. package/dist/shims/navigation.js +91 -25
  461. package/dist/shims/og.js +35 -10
  462. package/dist/shims/pages-router-runtime.d.ts +2 -1
  463. package/dist/shims/ppr-fallback-shell.d.ts +2 -1
  464. package/dist/shims/request-context.d.ts +13 -0
  465. package/dist/shims/router.js +33 -43
  466. package/dist/shims/server.d.ts +31 -4
  467. package/dist/shims/server.js +58 -10
  468. package/dist/shims/thenable-params.d.ts +6 -1
  469. package/dist/shims/thenable-params.js +11 -2
  470. package/dist/shims/unified-request-context.d.ts +5 -0
  471. package/dist/shims/unified-request-context.js +5 -3
  472. package/dist/typegen.d.ts +2 -1
  473. package/dist/utils/asset-prefix.d.ts +7 -0
  474. package/dist/utils/asset-prefix.js +10 -1
  475. package/dist/utils/client-build-manifest.d.ts +4 -1
  476. package/dist/utils/client-build-manifest.js +20 -6
  477. package/dist/utils/client-entry-manifest.d.ts +13 -0
  478. package/dist/utils/client-entry-manifest.js +20 -1
  479. package/dist/utils/client-reference-chunks.d.ts +45 -0
  480. package/dist/utils/client-reference-chunks.js +30 -0
  481. package/dist/utils/client-runtime-metadata.d.ts +10 -1
  482. package/dist/utils/client-runtime-metadata.js +53 -9
  483. package/dist/utils/compare.d.ts +9 -0
  484. package/dist/utils/compare.js +15 -1
  485. package/dist/utils/lazy-chunks.d.ts +18 -0
  486. package/dist/utils/lazy-chunks.js +27 -1
  487. package/dist/utils/manifest-paths.d.ts +14 -0
  488. package/dist/utils/manifest-paths.js +22 -1
  489. package/dist/utils/middleware-request-headers.d.ts +2 -1
  490. package/dist/utils/path-to-regexp.d.ts +21 -0
  491. package/dist/{server/middleware-path-to-regexp.js → utils/path-to-regexp.js} +14 -11
  492. package/dist/utils/plugin-react-version.d.ts +15 -0
  493. package/dist/utils/plugin-react-version.js +64 -0
  494. package/dist/utils/project.d.ts +2 -1
  495. package/dist/utils/project.js +9 -1
  496. package/dist/utils/public-routes.d.ts +2 -0
  497. package/dist/utils/public-routes.js +18 -7
  498. package/dist/utils/query.d.ts +2 -1
  499. package/dist/utils/sorted-array.d.ts +2 -1
  500. package/dist/utils/vite-cli-invocation.d.ts +2 -1
  501. package/package.json +5 -5
  502. package/dist/deps/.pnpm/image-size@2.0.2/deps/image-size/dist/index.js +0 -808
  503. package/dist/server/default-not-found-module.d.ts +0 -19
  504. package/dist/server/default-not-found-module.js +0 -18
  505. package/dist/server/middleware-path-to-regexp.d.ts +0 -13
  506. package/dist/server/rsc-stream-hints.d.ts +0 -21
  507. package/dist/server/rsc-stream-hints.js +0 -227
  508. package/dist/utils/regex-safety.d.ts +0 -17
  509. package/dist/utils/regex-safety.js +0 -789
@@ -0,0 +1,45 @@
1
+ //#region src/utils/client-reference-chunks.d.ts
2
+ /**
3
+ * The chunks an App Router client reference loads in the browser, which the
4
+ * RSC render names in the reference's Flight row (see
5
+ * server/app-client-reference-manifest.ts).
6
+ */
7
+ export type ClientReferenceChunks = {
8
+ /** Reference key -> index into `modules`. */
9
+ references: Record<string, number>;
10
+ /**
11
+ * Each chunk that registers client references (see
12
+ * shims/internal/client-reference-loader.ts), with the JS chunks to
13
+ * modulepreload (it and the chunks it imports that the browser entry
14
+ * doesn't, picked by `build.modulePreload`), and the stylesheets they need.
15
+ */
16
+ modules: {
17
+ file: string;
18
+ imports: string[];
19
+ css: string[];
20
+ }[];
21
+ };
22
+ /**
23
+ * How the browser loads a chunk a Flight row names. React passes the loader
24
+ * only the chunk id, so the id is the kind followed by the URL.
25
+ */
26
+ export declare const CLIENT_REFERENCE_CHUNK_KIND: {
27
+ /**
28
+ * The chunk that registers the reference, imported once the stylesheets
29
+ * its id lists after its URL have loaded.
30
+ */
31
+ readonly module: "m";
32
+ /** A JS chunk to modulepreload: the module chunk, or one it imports. */
33
+ readonly preload: "p";
34
+ };
35
+ /** Separates the URLs in a module chunk's id. A URL can't hold a raw newline. */
36
+ export declare const CLIENT_REFERENCE_CHUNK_URL_SEPARATOR = "\n";
37
+ /**
38
+ * React's webpack Flight binding takes a client reference's chunks as
39
+ * `[chunkId, filename, ...]` pairs. Only the id reaches the browser's chunk
40
+ * loader, so the filenames are left empty. The module chunk's id lists its
41
+ * stylesheets, so the loader can link them before the chunk evaluates, as
42
+ * Vite's preload helper does.
43
+ */
44
+ export declare function toFlightChunks(module: ClientReferenceChunks["modules"][number]): string[];
45
+ //#endregion
@@ -0,0 +1,30 @@
1
+ //#region src/utils/client-reference-chunks.ts
2
+ /**
3
+ * How the browser loads a chunk a Flight row names. React passes the loader
4
+ * only the chunk id, so the id is the kind followed by the URL.
5
+ */
6
+ const CLIENT_REFERENCE_CHUNK_KIND = {
7
+ /**
8
+ * The chunk that registers the reference, imported once the stylesheets
9
+ * its id lists after its URL have loaded.
10
+ */
11
+ module: "m",
12
+ /** A JS chunk to modulepreload: the module chunk, or one it imports. */
13
+ preload: "p"
14
+ };
15
+ /** Separates the URLs in a module chunk's id. A URL can't hold a raw newline. */
16
+ const CLIENT_REFERENCE_CHUNK_URL_SEPARATOR = "\n";
17
+ /**
18
+ * React's webpack Flight binding takes a client reference's chunks as
19
+ * `[chunkId, filename, ...]` pairs. Only the id reaches the browser's chunk
20
+ * loader, so the filenames are left empty. The module chunk's id lists its
21
+ * stylesheets, so the loader can link them before the chunk evaluates, as
22
+ * Vite's preload helper does.
23
+ */
24
+ function toFlightChunks(module) {
25
+ const chunks = [CLIENT_REFERENCE_CHUNK_KIND.module + [module.file, ...module.css].join("\n"), ""];
26
+ for (const file of module.imports) chunks.push(CLIENT_REFERENCE_CHUNK_KIND.preload + file, "");
27
+ return chunks;
28
+ }
29
+ //#endregion
30
+ export { CLIENT_REFERENCE_CHUNK_KIND, CLIENT_REFERENCE_CHUNK_URL_SEPARATOR, toFlightChunks };
@@ -1,18 +1,26 @@
1
+ import { ClientReferenceChunks } from "./client-reference-chunks.js";
1
2
  //#region src/utils/client-runtime-metadata.d.ts
2
3
  type ClientRuntimeMetadata = {
3
4
  clientEntryFile?: string;
4
5
  appBootstrapPreinitModules?: string[];
6
+ appRouteManifestModule?: string;
7
+ appClientReferenceChunks?: ClientReferenceChunks;
5
8
  cssGraph?: Record<string, {
6
9
  imports?: string[];
7
10
  css?: string[];
8
11
  }>;
9
12
  lazyChunks?: string[];
10
13
  dynamicPreloads?: Record<string, string[]>;
14
+ sharedChunks?: string[];
11
15
  };
12
16
  /**
13
17
  * Read the client build manifest and compute runtime metadata used by
14
18
  * Cloudflare worker entry injection and Node production server startup.
15
19
  *
20
+ * - `appRouteManifestModule` — the App Router RouteManifest chunk, which the
21
+ * browser entry imports as it boots, preloaded during SSR.
22
+ * - `appClientReferenceChunks` — what each App Router client reference loads
23
+ * in the browser, which the RSC render names in its Flight row.
16
24
  * - `lazyChunks` — chunks only reachable through dynamic `import()`, excluded
17
25
  * from modulepreload hints.
18
26
  * - `dynamicPreloads` — per-module JS/CSS files for rendered `next/dynamic()`
@@ -31,4 +39,5 @@ export declare function computeClientRuntimeMetadata(opts: {
31
39
  assetPrefix: string;
32
40
  includeClientEntry?: boolean | "pages-client-entry";
33
41
  }): ClientRuntimeMetadata;
34
- //#endregion
42
+ //#endregion
43
+ export {};
@@ -1,10 +1,33 @@
1
1
  import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
2
2
  import { isAbsoluteAssetPrefix, resolveAssetsDir } from "./asset-prefix.js";
3
- import { manifestFileWithAssetPrefix, manifestFileWithBase } from "./manifest-paths.js";
4
- import { findClientEntryFileFromVinextManifest, findPagesClientEntryFileFromVinextManifest, readClientEntryManifest } from "./client-entry-manifest.js";
5
- import { findClientEntryFile, findPagesClientEntryFile, readClientBuildManifest } from "./client-build-manifest.js";
6
- import { computeDynamicImportPreloads, computeLazyChunks, dynamicImportPreloadsWithBase } from "./lazy-chunks.js";
3
+ import { isSharedClientChunkName, manifestFileWithAssetPrefix, manifestFileWithBase } from "./manifest-paths.js";
4
+ import { findClientEntryFileFromVinextManifest, findPagesClientEntryFileFromVinextManifest, readClientEntryManifest, readClientReferenceSources } from "./client-entry-manifest.js";
5
+ import { findClientEntryFile, findPagesClientEntryFile, isPagesClientEntryChunk, readClientBuildManifest } from "./client-build-manifest.js";
6
+ import { addDynamicImportPreloadAliases, computeDynamicImportPreloads, computeLazyChunks, dynamicImportPreloadsWithBase } from "./lazy-chunks.js";
7
7
  //#region src/utils/client-runtime-metadata.ts
8
+ /**
9
+ * Shared Pages Router chunk files, keyed on Rolldown chunk names rather than
10
+ * emitted file names so user-configured `chunkFileNames` (e.g. hash-only
11
+ * patterns) keep their modulepreload/script tags.
12
+ */
13
+ function collectSharedChunkFiles(buildManifest, applyBase) {
14
+ const files = /* @__PURE__ */ new Set();
15
+ const visitedKeys = /* @__PURE__ */ new Set();
16
+ const addStaticImports = (key) => {
17
+ for (const importedKey of buildManifest[key]?.imports ?? []) {
18
+ if (visitedKeys.has(importedKey)) continue;
19
+ visitedKeys.add(importedKey);
20
+ const importedFile = buildManifest[importedKey]?.file;
21
+ if (importedFile?.endsWith(".js")) files.add(applyBase(importedFile));
22
+ addStaticImports(importedKey);
23
+ }
24
+ };
25
+ for (const [key, chunk] of Object.entries(buildManifest)) {
26
+ if (chunk.file.endsWith(".js") && isSharedClientChunkName(chunk.name)) files.add(applyBase(chunk.file));
27
+ if (isPagesClientEntryChunk(key, chunk)) addStaticImports(key);
28
+ }
29
+ return files.size > 0 ? [...files] : void 0;
30
+ }
8
31
  function collectCssGraph(buildManifest, applyBase) {
9
32
  const cssGraph = {};
10
33
  for (const [key, chunk] of Object.entries(buildManifest)) {
@@ -46,6 +69,10 @@ function collectAppBootstrapPreinitModules(buildManifest, appBrowserEntry, apply
46
69
  * Read the client build manifest and compute runtime metadata used by
47
70
  * Cloudflare worker entry injection and Node production server startup.
48
71
  *
72
+ * - `appRouteManifestModule` — the App Router RouteManifest chunk, which the
73
+ * browser entry imports as it boots, preloaded during SSR.
74
+ * - `appClientReferenceChunks` — what each App Router client reference loads
75
+ * in the browser, which the RSC render names in its Flight row.
49
76
  * - `lazyChunks` — chunks only reachable through dynamic `import()`, excluded
50
77
  * from modulepreload hints.
51
78
  * - `dynamicPreloads` — per-module JS/CSS files for rendered `next/dynamic()`
@@ -73,15 +100,32 @@ function computeClientRuntimeMetadata(opts) {
73
100
  const entry = opts.includeClientEntry === "pages-client-entry" ? findPagesClientEntryFileFromVinextManifest(clientEntryManifest, opts.assetBase) ?? findPagesClientEntryFile(entryOptions) : findClientEntryFileFromVinextManifest(clientEntryManifest, opts.assetBase) ?? findClientEntryFile(entryOptions);
74
101
  if (entry) metadata.clientEntryFile = entry;
75
102
  }
76
- if (!buildManifest) return metadata;
77
- if (opts.includeClientEntry) metadata.cssGraph = collectCssGraph(buildManifest, (file) => manifestFileWithBase(file, opts.assetBase));
78
- metadata.appBootstrapPreinitModules = collectAppBootstrapPreinitModules(buildManifest, clientEntryManifest?.appBrowserEntry, (file) => {
103
+ const appAssetUrl = (file) => {
79
104
  const url = manifestFileWithAssetPrefix(file, opts.assetBase, opts.assetPrefix);
80
105
  return isAbsoluteAssetPrefix(opts.assetPrefix) ? url : "/" + url;
81
- });
106
+ };
107
+ const referenceChunks = clientEntryManifest?.appClientReferenceChunks;
108
+ if (referenceChunks) metadata.appClientReferenceChunks = {
109
+ references: referenceChunks.references,
110
+ modules: referenceChunks.modules.map((module) => ({
111
+ file: appAssetUrl(module.file),
112
+ imports: module.imports.map(appAssetUrl),
113
+ css: module.css.map(appAssetUrl)
114
+ }))
115
+ };
116
+ if (!buildManifest) return metadata;
117
+ if (opts.includeClientEntry) {
118
+ metadata.cssGraph = collectCssGraph(buildManifest, (file) => manifestFileWithBase(file, opts.assetBase));
119
+ metadata.sharedChunks = collectSharedChunkFiles(buildManifest, (file) => manifestFileWithBase(file, opts.assetBase));
120
+ }
121
+ metadata.appBootstrapPreinitModules = collectAppBootstrapPreinitModules(buildManifest, clientEntryManifest?.appBrowserEntry, appAssetUrl);
122
+ if (clientEntryManifest?.appRouteManifest) metadata.appRouteManifestModule = appAssetUrl(clientEntryManifest.appRouteManifest);
82
123
  const lazyChunks = computeLazyChunks(buildManifest).map((file) => manifestFileWithBase(file, opts.assetBase));
83
124
  if (lazyChunks.length > 0) metadata.lazyChunks = lazyChunks;
84
- const dynamicPreloads = dynamicImportPreloadsWithBase(computeDynamicImportPreloads(buildManifest), (file) => manifestFileWithAssetPrefix(file, opts.assetBase, opts.assetPrefix));
125
+ const dynamicImportPreloads = computeDynamicImportPreloads(buildManifest);
126
+ const clientReferenceSources = readClientReferenceSources(opts.clientDir);
127
+ if (clientReferenceSources) addDynamicImportPreloadAliases(dynamicImportPreloads, buildManifest, clientReferenceSources);
128
+ const dynamicPreloads = dynamicImportPreloadsWithBase(dynamicImportPreloads, (file) => manifestFileWithAssetPrefix(file, opts.assetBase, opts.assetPrefix));
85
129
  if (Object.keys(dynamicPreloads).length > 0) metadata.dynamicPreloads = dynamicPreloads;
86
130
  return metadata;
87
131
  }
@@ -1,3 +1,12 @@
1
1
  //#region src/utils/compare.d.ts
2
2
  export declare const compareStrings: (left: string, right: string) => number;
3
+ /**
4
+ * Turbopack reads a folder's subfolders from a `BTreeMap<RcStr, _>`, whose
5
+ * keys compare as Rust `str`s: by UTF-8 bytes. That is Unicode code point
6
+ * order, which JavaScript's `<` (UTF-16 code units) doesn't match above the
7
+ * Basic Multilingual Plane.
8
+ * https://github.com/vercel/next.js/blob/v16.2.7/crates/next-core/src/app_structure.rs#L188-L192
9
+ * https://github.com/vercel/next.js/blob/v16.2.7/turbopack/crates/turbo-rcstr/src/lib.rs#L350-L354
10
+ */
11
+ export declare function compareFolderNames(a: string, b: string): number;
3
12
  //#endregion
@@ -4,5 +4,19 @@ const compareStrings = (left, right) => {
4
4
  if (left > right) return 1;
5
5
  return 0;
6
6
  };
7
+ /**
8
+ * Turbopack reads a folder's subfolders from a `BTreeMap<RcStr, _>`, whose
9
+ * keys compare as Rust `str`s: by UTF-8 bytes. That is Unicode code point
10
+ * order, which JavaScript's `<` (UTF-16 code units) doesn't match above the
11
+ * Basic Multilingual Plane.
12
+ * https://github.com/vercel/next.js/blob/v16.2.7/crates/next-core/src/app_structure.rs#L188-L192
13
+ * https://github.com/vercel/next.js/blob/v16.2.7/turbopack/crates/turbo-rcstr/src/lib.rs#L350-L354
14
+ */
15
+ function compareFolderNames(a, b) {
16
+ const left = Array.from(a, (char) => char.codePointAt(0) ?? 0);
17
+ const right = Array.from(b, (char) => char.codePointAt(0) ?? 0);
18
+ for (let index = 0; index < Math.min(left.length, right.length); index++) if (left[index] !== right[index]) return left[index] - right[index];
19
+ return left.length - right.length;
20
+ }
7
21
  //#endregion
8
- export { compareStrings };
22
+ export { compareFolderNames, compareStrings };
@@ -4,6 +4,10 @@
4
4
  */
5
5
  export type BuildManifestChunk = {
6
6
  file: string;
7
+ /** Source module id (or virtual id) of an entry chunk. */
8
+ src?: string;
9
+ /** Rolldown chunk name, independent of the configured output file name. */
10
+ name?: string;
7
11
  isEntry?: boolean;
8
12
  isDynamicEntry?: boolean;
9
13
  imports?: string[];
@@ -22,6 +26,11 @@ export type BuildManifestChunk = {
22
26
  * static `imports` tree (breadth-first). Any chunk file NOT reached by this
23
27
  * walk is only reachable through `dynamicImports` and is therefore "lazy".
24
28
  *
29
+ * The Pages Router client entry `import()`s every page and `_app`, but the
30
+ * HTML for a page renders that page and `_app`, so their chunks are roots of
31
+ * the walk too: Next.js emits their scripts in the initial HTML. Their own
32
+ * dynamic imports (next/dynamic, React.lazy) stay lazy.
33
+ *
25
34
  * @param buildManifest - Vite's build manifest (manifest.json), which is a
26
35
  * Record<string, ManifestChunk> where each chunk has `file`, `imports`,
27
36
  * `dynamicImports`, `isEntry`, and `isDynamicEntry` fields.
@@ -54,5 +63,14 @@ export declare function computeLazyChunks(buildManifest: Record<string, BuildMan
54
63
  * should be preloaded when that dynamic boundary is rendered.
55
64
  */
56
65
  export declare function computeDynamicImportPreloads(buildManifest: Record<string, BuildManifestChunk>): Record<string, string[]>;
66
+ /**
67
+ * Give a module the preloads of a chunk that loads it. The client build
68
+ * imports an App Router client reference through the module that registers it
69
+ * (see build/client-reference-chunks.ts), so the build manifest keys that
70
+ * module's chunk, not the reference's module a next/dynamic boundary names.
71
+ *
72
+ * @param aliases Module manifest key -> the file of the chunk that loads it.
73
+ */
74
+ export declare function addDynamicImportPreloadAliases(preloads: Record<string, string[]>, buildManifest: Record<string, BuildManifestChunk>, aliases: Record<string, string>): void;
57
75
  export declare function dynamicImportPreloadsWithBase(preloads: Record<string, string[]>, applyBase: (file: string) => string): Record<string, string[]>;
58
76
  //#endregion
@@ -1,3 +1,4 @@
1
+ import { isPagesClientEntryChunk } from "./client-build-manifest.js";
1
2
  //#region src/utils/lazy-chunks.ts
2
3
  /**
3
4
  * Compute the set of chunk filenames that are ONLY reachable through dynamic
@@ -10,6 +11,11 @@
10
11
  * static `imports` tree (breadth-first). Any chunk file NOT reached by this
11
12
  * walk is only reachable through `dynamicImports` and is therefore "lazy".
12
13
  *
14
+ * The Pages Router client entry `import()`s every page and `_app`, but the
15
+ * HTML for a page renders that page and `_app`, so their chunks are roots of
16
+ * the walk too: Next.js emits their scripts in the initial HTML. Their own
17
+ * dynamic imports (next/dynamic, React.lazy) stay lazy.
18
+ *
13
19
  * @param buildManifest - Vite's build manifest (manifest.json), which is a
14
20
  * Record<string, ManifestChunk> where each chunk has `file`, `imports`,
15
21
  * `dynamicImports`, `isEntry`, and `isDynamicEntry` fields.
@@ -32,6 +38,9 @@ function computeLazyChunks(buildManifest) {
32
38
  if (chunk.imports) {
33
39
  for (const imp of chunk.imports) if (!visited.has(imp)) queue.push(imp);
34
40
  }
41
+ if (isPagesClientEntryChunk(key, chunk)) {
42
+ for (const imp of chunk.dynamicImports ?? []) if (!visited.has(imp)) queue.push(imp);
43
+ }
35
44
  }
36
45
  const lazyChunks = [];
37
46
  const allFiles = /* @__PURE__ */ new Set();
@@ -103,10 +112,27 @@ function computeDynamicImportPreloads(buildManifest) {
103
112
  }
104
113
  return preloads;
105
114
  }
115
+ /**
116
+ * Give a module the preloads of a chunk that loads it. The client build
117
+ * imports an App Router client reference through the module that registers it
118
+ * (see build/client-reference-chunks.ts), so the build manifest keys that
119
+ * module's chunk, not the reference's module a next/dynamic boundary names.
120
+ *
121
+ * @param aliases Module manifest key -> the file of the chunk that loads it.
122
+ */
123
+ function addDynamicImportPreloadAliases(preloads, buildManifest, aliases) {
124
+ const keysByFile = /* @__PURE__ */ new Map();
125
+ for (const [key, chunk] of Object.entries(buildManifest)) keysByFile.set(chunk.file, normalizeManifestKey(key));
126
+ for (const [moduleKey, file] of Object.entries(aliases)) {
127
+ const key = keysByFile.get(file);
128
+ const files = key === void 0 ? void 0 : preloads[key];
129
+ if (files && !Object.hasOwn(preloads, moduleKey)) preloads[moduleKey] = files;
130
+ }
131
+ }
106
132
  function dynamicImportPreloadsWithBase(preloads, applyBase) {
107
133
  const withBase = {};
108
134
  for (const [key, files] of Object.entries(preloads)) withBase[key] = files.map(applyBase);
109
135
  return withBase;
110
136
  }
111
137
  //#endregion
112
- export { computeDynamicImportPreloads, computeLazyChunks, dynamicImportPreloadsWithBase };
138
+ export { addDynamicImportPreloadAliases, computeDynamicImportPreloads, computeLazyChunks, dynamicImportPreloadsWithBase };
@@ -26,4 +26,18 @@ export declare function assetServingUrlFromBaseAnchored(value: string, basePath:
26
26
  * `<base>/<base>/` prefix is collapsed; a single prefix is left untouched.
27
27
  */
28
28
  export declare function collapseDuplicateBase(file: string, base: string): string;
29
+ /**
30
+ * Whether a Rolldown chunk belongs to the shared Pages Router runtime, judged
31
+ * by its exact chunk name rather than its emitted file name so user-configured
32
+ * or hash-only `chunkFileNames` keep their modulepreload/script tags.
33
+ */
34
+ export declare function isSharedClientChunkName(name: string | undefined): boolean;
35
+ /**
36
+ * Reserved `ssr-manifest.json` key listing the shared runtime chunk files.
37
+ * Consumers that pass the on-disk manifest straight to `renderPage()` (the
38
+ * legacy two-call Pages build) have no registered build metadata, and file
39
+ * names alone can't identify these chunks. The `\0` prefix keeps it from
40
+ * matching any module id.
41
+ */
42
+ export declare const SSR_MANIFEST_SHARED_CHUNKS_KEY = "\0vinext:shared-chunks";
29
43
  //#endregion
@@ -62,5 +62,26 @@ function collapseDuplicateBase(file, base) {
62
62
  const doubledPrefix = `${normalizedBase}/${normalizedBase}/`;
63
63
  return normalizedFile.startsWith(doubledPrefix) ? normalizedFile.slice(normalizedBase.length + 1) : normalizedFile;
64
64
  }
65
+ const SHARED_CHUNK_NAMES = /* @__PURE__ */ new Set([
66
+ "framework",
67
+ "vinext",
68
+ "vinext-client-entry"
69
+ ]);
70
+ /**
71
+ * Whether a Rolldown chunk belongs to the shared Pages Router runtime, judged
72
+ * by its exact chunk name rather than its emitted file name so user-configured
73
+ * or hash-only `chunkFileNames` keep their modulepreload/script tags.
74
+ */
75
+ function isSharedClientChunkName(name) {
76
+ return name !== void 0 && SHARED_CHUNK_NAMES.has(name);
77
+ }
78
+ /**
79
+ * Reserved `ssr-manifest.json` key listing the shared runtime chunk files.
80
+ * Consumers that pass the on-disk manifest straight to `renderPage()` (the
81
+ * legacy two-call Pages build) have no registered build metadata, and file
82
+ * names alone can't identify these chunks. The `\0` prefix keeps it from
83
+ * matching any module id.
84
+ */
85
+ const SSR_MANIFEST_SHARED_CHUNKS_KEY = "\0vinext:shared-chunks";
65
86
  //#endregion
66
- export { assetServingUrlFromBaseAnchored, collapseDuplicateBase, manifestFileWithAssetPrefix, manifestFileWithBase };
87
+ export { SSR_MANIFEST_SHARED_CHUNKS_KEY, assetServingUrlFromBaseAnchored, collapseDuplicateBase, isSharedClientChunkName, manifestFileWithAssetPrefix, manifestFileWithBase };
@@ -21,4 +21,5 @@ export declare function encodeMiddlewareRequestHeaders(targetHeaders: Headers, r
21
21
  */
22
22
  export declare function buildRequestHeadersFromMiddlewareResponse(baseHeaders: Headers, middlewareHeaders: MiddlewareHeaderSource): Headers | null;
23
23
  export declare function shouldKeepMiddlewareHeader(key: string): boolean;
24
- //#endregion
24
+ //#endregion
25
+ export {};
@@ -0,0 +1,21 @@
1
+ //#region src/utils/path-to-regexp.d.ts
2
+ export type PathToken = string | PathKey;
3
+ export type PathKey = {
4
+ name: string | number;
5
+ prefix: string;
6
+ suffix: string;
7
+ pattern: string;
8
+ modifier: string;
9
+ };
10
+ export type ParsePathPatternOptions = {
11
+ /** Characters a default param cannot contain. path-to-regexp defaults to `/#?`. */
12
+ delimiter?: string;
13
+ };
14
+ export declare function parsePathPattern(value: string, options?: ParsePathPatternOptions): PathToken[];
15
+ export declare function normalizePathTokens(tokens: PathToken[]): PathToken[];
16
+ /**
17
+ * path-to-regexp's `tokensToRegexp` with `strict: true`, without the closing
18
+ * `$`. Callers append the ending their Next.js matcher uses.
19
+ */
20
+ export declare function pathTokensToRegExpSource(tokens: PathToken[]): string;
21
+ //#endregion
@@ -1,4 +1,4 @@
1
- //#region src/server/middleware-path-to-regexp.ts
1
+ //#region src/utils/path-to-regexp.ts
2
2
  function lexer(value) {
3
3
  const tokens = [];
4
4
  let index = 0;
@@ -101,11 +101,12 @@ function lexer(value) {
101
101
  });
102
102
  return tokens;
103
103
  }
104
- function parseMiddlewarePath(value) {
104
+ function parsePathPattern(value, options = {}) {
105
105
  const tokens = lexer(value);
106
106
  const result = [];
107
107
  const prefixes = "./";
108
- const delimiter = "/#?";
108
+ const delimiter = options.delimiter ?? "/#?";
109
+ const delimiterClass = `[^${escapeRegex(delimiter)}]`;
109
110
  let key = 0;
110
111
  let index = 0;
111
112
  let path = "";
@@ -135,8 +136,8 @@ function parseMiddlewarePath(value) {
135
136
  const name = typeof previous === "string" ? previous : previous.name;
136
137
  throw new TypeError(`Must have text between two parameters, missing text after "${name}"`);
137
138
  }
138
- if (!previousText || containsDelimiter(previousText)) return "[^\\/#\\?]+?";
139
- return `(?:(?!${escapeRegex(previousText)})[^\\/#\\?])+?`;
139
+ if (!previousText || containsDelimiter(previousText)) return `${delimiterClass}+?`;
140
+ return `(?:(?!${escapeRegex(previousText)})${delimiterClass})+?`;
140
141
  };
141
142
  while (index < tokens.length) {
142
143
  const character = tryConsume("CHAR");
@@ -192,7 +193,7 @@ function parseMiddlewarePath(value) {
192
193
  function escapeRegex(value) {
193
194
  return value.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
194
195
  }
195
- function normalizeMiddlewarePathTokens(tokens) {
196
+ function normalizePathTokens(tokens) {
196
197
  return tokens.map((token) => {
197
198
  if (typeof token === "object" && (token.modifier === "*" || token.modifier === "+") && token.prefix === "" && token.suffix === "") return {
198
199
  ...token,
@@ -201,8 +202,11 @@ function normalizeMiddlewarePathTokens(tokens) {
201
202
  return token;
202
203
  });
203
204
  }
204
- function middlewarePathTokensToRegExp(tokens) {
205
- const delimiterRegex = `[${escapeRegex("/#?")}]`;
205
+ /**
206
+ * path-to-regexp's `tokensToRegexp` with `strict: true`, without the closing
207
+ * `$`. Callers append the ending their Next.js matcher uses.
208
+ */
209
+ function pathTokensToRegExpSource(tokens) {
206
210
  let route = "^";
207
211
  for (const token of tokens) {
208
212
  if (typeof token === "string") {
@@ -223,8 +227,7 @@ function middlewarePathTokensToRegExp(tokens) {
223
227
  }
224
228
  } else route += `(?:${prefix}${suffix})${token.modifier}`;
225
229
  }
226
- route += `${delimiterRegex}?$`;
227
- return new RegExp(route);
230
+ return route;
228
231
  }
229
232
  //#endregion
230
- export { middlewarePathTokensToRegExp, normalizeMiddlewarePathTokens, parseMiddlewarePath };
233
+ export { normalizePathTokens, parsePathPattern, pathTokensToRegExpSource };
@@ -0,0 +1,15 @@
1
+ //#region src/utils/plugin-react-version.d.ts
2
+ /**
3
+ * Resolve @vitejs/plugin-react from the project, falling back to vinext's own
4
+ * install when the project has none or reaches an unsupported version.
5
+ * Returns null when it is not installed, and throws when every copy found is
6
+ * unsupported.
7
+ */
8
+ export declare function resolvePluginReactPath(projectRoot: string, fallbackFrom?: string): string | null;
9
+ /**
10
+ * The @vitejs/plugin-react upgrade vinext init must install before vinext.
11
+ * A declared copy below the floor conflicts with vinext's peer range: npm stops
12
+ * with ERESOLVE, and pnpm installs but vinext refuses to start.
13
+ */
14
+ export declare function getPluginReactUpgradeDeps(root: string): string[];
15
+ //#endregion
@@ -0,0 +1,64 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
2
+ import { findPackageVersion, isVersionBelow } from "./react-version.js";
3
+ import { createRequire } from "node:module";
4
+ import fs from "node:fs";
5
+ //#region src/utils/plugin-react-version.ts
6
+ const MINIMUM_PLUGIN_REACT_VERSION = [
7
+ 5,
8
+ 1,
9
+ 4
10
+ ];
11
+ function resolveFrom(from) {
12
+ try {
13
+ const resolved = createRequire(from).resolve("@vitejs/plugin-react");
14
+ return {
15
+ path: resolved,
16
+ version: findPackageVersion(resolved, "@vitejs/plugin-react")
17
+ };
18
+ } catch {
19
+ return null;
20
+ }
21
+ }
22
+ function isSupported(plugin) {
23
+ return plugin.version !== null && !isVersionBelow(plugin.version, MINIMUM_PLUGIN_REACT_VERSION);
24
+ }
25
+ /**
26
+ * Resolve @vitejs/plugin-react from the project, falling back to vinext's own
27
+ * install when the project has none or reaches an unsupported version.
28
+ * Returns null when it is not installed, and throws when every copy found is
29
+ * unsupported.
30
+ */
31
+ function resolvePluginReactPath(projectRoot, fallbackFrom = import.meta.url) {
32
+ const project = resolveFrom(path.join(projectRoot, "package.json"));
33
+ if (project && isSupported(project)) return project.path;
34
+ const fallback = resolveFrom(fallbackFrom);
35
+ if (fallback && isSupported(fallback)) {
36
+ if (project) console.warn(`[vinext] Ignoring @vitejs/plugin-react ${project.version ?? "(unknown version)"} at ${project.path}: vinext requires ${MINIMUM_PLUGIN_REACT_VERSION.join(".")} or newer. Using ${fallback.version} instead. Add @vitejs/plugin-react to your app's devDependencies to choose the version explicitly.`);
37
+ return fallback.path;
38
+ }
39
+ const found = project ?? fallback;
40
+ if (!found) return null;
41
+ throw new Error(`vinext: @vitejs/plugin-react ${MINIMUM_PLUGIN_REACT_VERSION.join(".")} or newer is required (found ${found.version ?? "an unknown version"} at ${found.path}). Add @vitejs/plugin-react@^6 to your app's devDependencies.`);
42
+ }
43
+ /**
44
+ * The @vitejs/plugin-react upgrade vinext init must install before vinext.
45
+ * A declared copy below the floor conflicts with vinext's peer range: npm stops
46
+ * with ERESOLVE, and pnpm installs but vinext refuses to start.
47
+ */
48
+ function getPluginReactUpgradeDeps(root) {
49
+ const manifest = path.join(root, "package.json");
50
+ let declared;
51
+ try {
52
+ const pkg = JSON.parse(fs.readFileSync(manifest, "utf-8"));
53
+ declared = pkg.dependencies?.["@vitejs/plugin-react"] ?? pkg.devDependencies?.["@vitejs/plugin-react"];
54
+ } catch {
55
+ return [];
56
+ }
57
+ if (typeof declared !== "string") return [];
58
+ const major = /^[~^]?(\d+)(?:\.(?:\d+|[x*])){0,2}$/.exec(declared.trim())?.[1];
59
+ if (major !== void 0 && Number(major) < MINIMUM_PLUGIN_REACT_VERSION[0]) return ["@vitejs/plugin-react@latest"];
60
+ const installed = resolveFrom(manifest);
61
+ return installed && (!isSupported(installed) || installed.version?.includes("-")) ? ["@vitejs/plugin-react@latest"] : [];
62
+ }
63
+ //#endregion
64
+ export { getPluginReactUpgradeDeps, resolvePluginReactPath };
@@ -111,4 +111,5 @@ export declare function findDir(root: string, ...candidates: string[]): string |
111
111
  * Check if the project uses App Router (has an app/ directory).
112
112
  */
113
113
  export declare function hasAppDir(root: string): boolean;
114
- //#endregion
114
+ //#endregion
115
+ export {};
@@ -333,6 +333,14 @@ function detectMDXFromConfig(root) {
333
333
  }
334
334
  return false;
335
335
  }
336
+ /**
337
+ * Next.js copies a set legacy `experimental.cacheComponents` over the
338
+ * top-level key (warnOptionHasBeenMovedOutOfExperimental).
339
+ */
340
+ function configEnablesCacheComponents(content) {
341
+ if (/\bexperimental\s*:\s*\{[^}]*\bcacheComponents\s*:\s*false\b/.test(content)) return false;
342
+ return /\bcacheComponents\s*:\s*true\b/.test(content);
343
+ }
336
344
  function detectCacheComponents(root) {
337
345
  for (const fileName of [
338
346
  "next.config.ts",
@@ -344,7 +352,7 @@ function detectCacheComponents(root) {
344
352
  const configPath = path.join(root, fileName);
345
353
  if (!fs.existsSync(configPath)) continue;
346
354
  try {
347
- if (/\bcacheComponents\s*:\s*true\b/.test(fs.readFileSync(configPath, "utf-8"))) return true;
355
+ if (configEnablesCacheComponents(fs.readFileSync(configPath, "utf-8"))) return true;
348
356
  } catch {}
349
357
  }
350
358
  return false;
@@ -1,3 +1,5 @@
1
1
  //#region src/utils/public-routes.d.ts
2
2
  export declare function scanPublicFileRoutes(root: string, configuredPublicDir?: string | false): string[];
3
+ /** List the files in the public directory as `/`-prefixed relative paths. */
4
+ export declare function scanPublicFiles(root: string, configuredPublicDir?: string | false): string[];
3
5
  //#endregion
@@ -3,10 +3,14 @@ import { publicFileRouteKey } from "./public-file-path.js";
3
3
  import fs from "node:fs";
4
4
  //#region src/utils/public-routes.ts
5
5
  function scanPublicFileRoutes(root, configuredPublicDir = "public") {
6
+ return [...new Set(scanPublicFiles(root, configuredPublicDir).map(publicFileRouteKey))].sort();
7
+ }
8
+ /** List the files in the public directory as `/`-prefixed relative paths. */
9
+ function scanPublicFiles(root, configuredPublicDir = "public") {
6
10
  if (configuredPublicDir === false || configuredPublicDir === "") return [];
7
11
  const publicDir = path.resolve(root, configuredPublicDir);
8
- const routes = [];
9
- const visitedDirs = /* @__PURE__ */ new Set();
12
+ const files = [];
13
+ const ancestorDirs = /* @__PURE__ */ new Set();
10
14
  function walk(dir) {
11
15
  let realDir;
12
16
  try {
@@ -14,8 +18,15 @@ function scanPublicFileRoutes(root, configuredPublicDir = "public") {
14
18
  } catch {
15
19
  return;
16
20
  }
17
- if (visitedDirs.has(realDir)) return;
18
- visitedDirs.add(realDir);
21
+ if (ancestorDirs.has(realDir)) return;
22
+ ancestorDirs.add(realDir);
23
+ try {
24
+ walkEntries(dir);
25
+ } finally {
26
+ ancestorDirs.delete(realDir);
27
+ }
28
+ }
29
+ function walkEntries(dir) {
19
30
  const entries = fs.readdirSync(dir, { withFileTypes: true });
20
31
  for (const entry of entries) {
21
32
  const fullPath = path.join(dir, entry.name);
@@ -37,13 +48,13 @@ function scanPublicFileRoutes(root, configuredPublicDir = "public") {
37
48
  if (!stat.isFile()) continue;
38
49
  } else if (!entry.isFile()) continue;
39
50
  const relativePath = path.relative(publicDir, fullPath);
40
- routes.push(publicFileRouteKey("/" + relativePath));
51
+ files.push("/" + relativePath);
41
52
  }
42
53
  }
43
54
  if (fs.existsSync(publicDir)) try {
44
55
  walk(publicDir);
45
56
  } catch {}
46
- return [...new Set(routes)].sort();
57
+ return files;
47
58
  }
48
59
  //#endregion
49
- export { scanPublicFileRoutes };
60
+ export { scanPublicFileRoutes, scanPublicFiles };
@@ -51,4 +51,5 @@ export declare function mergeRewriteQuery(originalUrl: string, rewriteUrl: strin
51
51
  * and fragment identifier.
52
52
  */
53
53
  export declare function appendSearchParamsToUrl(url: string, params: Iterable<[string, string]>): string;
54
- //#endregion
54
+ //#endregion
55
+ export {};