vinext 0.0.45 → 0.0.47

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 (311) hide show
  1. package/README.md +7 -5
  2. package/dist/build/prerender.d.ts +2 -1
  3. package/dist/build/prerender.js +80 -17
  4. package/dist/build/prerender.js.map +1 -1
  5. package/dist/build/report.d.ts +1 -1
  6. package/dist/build/route-classification-injector.d.ts +35 -0
  7. package/dist/build/route-classification-injector.js +61 -0
  8. package/dist/build/route-classification-injector.js.map +1 -0
  9. package/dist/build/route-classification-manifest.d.ts +1 -1
  10. package/dist/build/standalone.js +4 -3
  11. package/dist/build/standalone.js.map +1 -1
  12. package/dist/build/static-export.d.ts +1 -1
  13. package/dist/check.js +30 -18
  14. package/dist/check.js.map +1 -1
  15. package/dist/cli-args.d.ts +31 -0
  16. package/dist/cli-args.js +104 -0
  17. package/dist/cli-args.js.map +1 -0
  18. package/dist/cli.js +6 -19
  19. package/dist/cli.js.map +1 -1
  20. package/dist/cloudflare/kv-cache-handler.js +29 -9
  21. package/dist/cloudflare/kv-cache-handler.js.map +1 -1
  22. package/dist/config/config-matchers.js +1 -0
  23. package/dist/config/config-matchers.js.map +1 -1
  24. package/dist/config/next-config.d.ts +42 -4
  25. package/dist/config/next-config.js +27 -0
  26. package/dist/config/next-config.js.map +1 -1
  27. package/dist/deploy.js +18 -23
  28. package/dist/deploy.js.map +1 -1
  29. package/dist/entries/app-rsc-entry.d.ts +4 -3
  30. package/dist/entries/app-rsc-entry.js +435 -2317
  31. package/dist/entries/app-rsc-entry.js.map +1 -1
  32. package/dist/entries/app-rsc-manifest.d.ts +24 -0
  33. package/dist/entries/app-rsc-manifest.js +155 -0
  34. package/dist/entries/app-rsc-manifest.js.map +1 -0
  35. package/dist/entries/pages-server-entry.js +18 -105
  36. package/dist/entries/pages-server-entry.js.map +1 -1
  37. package/dist/index.js +82 -85
  38. package/dist/index.js.map +1 -1
  39. package/dist/plugins/fonts.js +54 -32
  40. package/dist/plugins/fonts.js.map +1 -1
  41. package/dist/plugins/rsc-client-shim-excludes.d.ts +6 -0
  42. package/dist/plugins/rsc-client-shim-excludes.js +28 -0
  43. package/dist/plugins/rsc-client-shim-excludes.js.map +1 -0
  44. package/dist/routing/app-route-graph.d.ts +109 -0
  45. package/dist/routing/app-route-graph.js +819 -0
  46. package/dist/routing/app-route-graph.js.map +1 -0
  47. package/dist/routing/app-router.d.ts +2 -79
  48. package/dist/routing/app-router.js +7 -621
  49. package/dist/routing/app-router.js.map +1 -1
  50. package/dist/routing/route-pattern.d.ts +9 -0
  51. package/dist/routing/route-pattern.js +90 -0
  52. package/dist/routing/route-pattern.js.map +1 -0
  53. package/dist/routing/route-trie.js +10 -11
  54. package/dist/routing/route-trie.js.map +1 -1
  55. package/dist/server/app-browser-entry.js +94 -232
  56. package/dist/server/app-browser-entry.js.map +1 -1
  57. package/dist/server/app-browser-error.d.ts +3 -4
  58. package/dist/server/app-browser-error.js +8 -4
  59. package/dist/server/app-browser-error.js.map +1 -1
  60. package/dist/server/app-browser-navigation-controller.d.ts +73 -0
  61. package/dist/server/app-browser-navigation-controller.js +282 -0
  62. package/dist/server/app-browser-navigation-controller.js.map +1 -0
  63. package/dist/server/app-browser-state.d.ts +1 -1
  64. package/dist/server/app-browser-state.js.map +1 -1
  65. package/dist/server/app-elements.js +1 -5
  66. package/dist/server/app-elements.js.map +1 -1
  67. package/dist/server/app-fallback-renderer.d.ts +57 -0
  68. package/dist/server/app-fallback-renderer.js +79 -0
  69. package/dist/server/app-fallback-renderer.js.map +1 -0
  70. package/dist/server/app-hook-warning-suppression.d.ts +7 -0
  71. package/dist/server/app-hook-warning-suppression.js +12 -0
  72. package/dist/server/app-hook-warning-suppression.js.map +1 -0
  73. package/dist/server/app-middleware.d.ts +32 -0
  74. package/dist/server/app-middleware.js +147 -0
  75. package/dist/server/app-middleware.js.map +1 -0
  76. package/dist/server/app-mounted-slots-header.d.ts +17 -0
  77. package/dist/server/app-mounted-slots-header.js +21 -0
  78. package/dist/server/app-mounted-slots-header.js.map +1 -0
  79. package/dist/server/app-page-boundary-render.d.ts +4 -2
  80. package/dist/server/app-page-boundary-render.js +50 -30
  81. package/dist/server/app-page-boundary-render.js.map +1 -1
  82. package/dist/server/app-page-boundary.d.ts +12 -1
  83. package/dist/server/app-page-boundary.js +27 -12
  84. package/dist/server/app-page-boundary.js.map +1 -1
  85. package/dist/server/app-page-cache.d.ts +22 -5
  86. package/dist/server/app-page-cache.js +90 -11
  87. package/dist/server/app-page-cache.js.map +1 -1
  88. package/dist/server/app-page-dispatch.d.ts +123 -0
  89. package/dist/server/app-page-dispatch.js +348 -0
  90. package/dist/server/app-page-dispatch.js.map +1 -0
  91. package/dist/server/app-page-element-builder.d.ts +61 -0
  92. package/dist/server/app-page-element-builder.js +139 -0
  93. package/dist/server/app-page-element-builder.js.map +1 -0
  94. package/dist/server/app-page-execution.d.ts +4 -3
  95. package/dist/server/app-page-execution.js +5 -8
  96. package/dist/server/app-page-execution.js.map +1 -1
  97. package/dist/server/app-page-head.d.ts +55 -0
  98. package/dist/server/app-page-head.js +196 -0
  99. package/dist/server/app-page-head.js.map +1 -0
  100. package/dist/server/app-page-method.d.ts +16 -0
  101. package/dist/server/app-page-method.js +30 -0
  102. package/dist/server/app-page-method.js.map +1 -0
  103. package/dist/server/app-page-params.d.ts +8 -0
  104. package/dist/server/app-page-params.js +28 -0
  105. package/dist/server/app-page-params.js.map +1 -0
  106. package/dist/server/app-page-render.d.ts +7 -2
  107. package/dist/server/app-page-render.js +131 -32
  108. package/dist/server/app-page-render.js.map +1 -1
  109. package/dist/server/app-page-request.d.ts +23 -8
  110. package/dist/server/app-page-request.js +51 -6
  111. package/dist/server/app-page-request.js.map +1 -1
  112. package/dist/server/app-page-response.d.ts +1 -0
  113. package/dist/server/app-page-response.js +3 -7
  114. package/dist/server/app-page-response.js.map +1 -1
  115. package/dist/server/app-page-route-wiring.d.ts +29 -5
  116. package/dist/server/app-page-route-wiring.js +30 -8
  117. package/dist/server/app-page-route-wiring.js.map +1 -1
  118. package/dist/server/app-page-stream.d.ts +10 -0
  119. package/dist/server/app-page-stream.js +5 -1
  120. package/dist/server/app-page-stream.js.map +1 -1
  121. package/dist/server/app-post-middleware-context.d.ts +16 -0
  122. package/dist/server/app-post-middleware-context.js +28 -0
  123. package/dist/server/app-post-middleware-context.js.map +1 -0
  124. package/dist/server/app-prerender-endpoints.d.ts +19 -0
  125. package/dist/server/app-prerender-endpoints.js +96 -0
  126. package/dist/server/app-prerender-endpoints.js.map +1 -0
  127. package/dist/server/app-prerender-static-params.d.ts +16 -0
  128. package/dist/server/app-prerender-static-params.js +14 -0
  129. package/dist/server/app-prerender-static-params.js.map +1 -0
  130. package/dist/server/app-request-context.d.ts +22 -0
  131. package/dist/server/app-request-context.js +30 -0
  132. package/dist/server/app-request-context.js.map +1 -0
  133. package/dist/server/app-route-handler-cache.d.ts +4 -0
  134. package/dist/server/app-route-handler-cache.js +11 -3
  135. package/dist/server/app-route-handler-cache.js.map +1 -1
  136. package/dist/server/app-route-handler-dispatch.d.ts +43 -0
  137. package/dist/server/app-route-handler-dispatch.js +149 -0
  138. package/dist/server/app-route-handler-dispatch.js.map +1 -0
  139. package/dist/server/app-route-handler-execution.d.ts +8 -3
  140. package/dist/server/app-route-handler-execution.js +25 -4
  141. package/dist/server/app-route-handler-execution.js.map +1 -1
  142. package/dist/server/app-route-handler-response.d.ts +6 -3
  143. package/dist/server/app-route-handler-response.js +52 -11
  144. package/dist/server/app-route-handler-response.js.map +1 -1
  145. package/dist/server/app-route-handler-runtime.d.ts +4 -1
  146. package/dist/server/app-route-handler-runtime.js +107 -1
  147. package/dist/server/app-route-handler-runtime.js.map +1 -1
  148. package/dist/server/app-router-entry.js.map +1 -1
  149. package/dist/server/app-rsc-error-handler.d.ts +21 -0
  150. package/dist/server/app-rsc-error-handler.js +30 -0
  151. package/dist/server/app-rsc-error-handler.js.map +1 -0
  152. package/dist/server/app-rsc-errors.d.ts +27 -0
  153. package/dist/server/app-rsc-errors.js +42 -0
  154. package/dist/server/app-rsc-errors.js.map +1 -0
  155. package/dist/server/app-rsc-handler.d.ts +117 -0
  156. package/dist/server/app-rsc-handler.js +260 -0
  157. package/dist/server/app-rsc-handler.js.map +1 -0
  158. package/dist/server/app-rsc-request-normalization.d.ts +40 -0
  159. package/dist/server/app-rsc-request-normalization.js +63 -0
  160. package/dist/server/app-rsc-request-normalization.js.map +1 -0
  161. package/dist/server/app-rsc-response-finalizer.d.ts +30 -0
  162. package/dist/server/app-rsc-response-finalizer.js +38 -0
  163. package/dist/server/app-rsc-response-finalizer.js.map +1 -0
  164. package/dist/server/app-rsc-route-matching.d.ts +40 -0
  165. package/dist/server/app-rsc-route-matching.js +66 -0
  166. package/dist/server/app-rsc-route-matching.js.map +1 -0
  167. package/dist/server/app-segment-config.d.ts +33 -0
  168. package/dist/server/app-segment-config.js +86 -0
  169. package/dist/server/app-segment-config.js.map +1 -0
  170. package/dist/server/app-server-action-execution.d.ts +88 -1
  171. package/dist/server/app-server-action-execution.js +257 -5
  172. package/dist/server/app-server-action-execution.js.map +1 -1
  173. package/dist/server/app-ssr-entry.d.ts +7 -0
  174. package/dist/server/app-ssr-entry.js +30 -9
  175. package/dist/server/app-ssr-entry.js.map +1 -1
  176. package/dist/server/app-ssr-stream.d.ts +4 -2
  177. package/dist/server/app-ssr-stream.js +29 -2
  178. package/dist/server/app-ssr-stream.js.map +1 -1
  179. package/dist/server/app-static-generation.d.ts +15 -0
  180. package/dist/server/app-static-generation.js +20 -0
  181. package/dist/server/app-static-generation.js.map +1 -0
  182. package/dist/server/cache-control.d.ts +24 -0
  183. package/dist/server/cache-control.js +33 -0
  184. package/dist/server/cache-control.js.map +1 -0
  185. package/dist/server/dev-error-overlay-store.d.ts +23 -0
  186. package/dist/server/dev-error-overlay-store.js +67 -0
  187. package/dist/server/dev-error-overlay-store.js.map +1 -0
  188. package/dist/server/dev-error-overlay.d.ts +15 -0
  189. package/dist/server/dev-error-overlay.js +548 -0
  190. package/dist/server/dev-error-overlay.js.map +1 -0
  191. package/dist/server/dev-route-files.d.ts +7 -0
  192. package/dist/server/dev-route-files.js +73 -0
  193. package/dist/server/dev-route-files.js.map +1 -0
  194. package/dist/server/dev-server.js +4 -0
  195. package/dist/server/dev-server.js.map +1 -1
  196. package/dist/server/file-based-metadata.d.ts +17 -0
  197. package/dist/server/file-based-metadata.js +356 -0
  198. package/dist/server/file-based-metadata.js.map +1 -0
  199. package/dist/server/implicit-tags.d.ts +6 -0
  200. package/dist/server/implicit-tags.js +42 -0
  201. package/dist/server/implicit-tags.js.map +1 -0
  202. package/dist/server/instrumentation-runtime.d.ts +44 -0
  203. package/dist/server/instrumentation-runtime.js +29 -0
  204. package/dist/server/instrumentation-runtime.js.map +1 -0
  205. package/dist/server/instrumentation.js.map +1 -1
  206. package/dist/server/isr-cache.d.ts +16 -3
  207. package/dist/server/isr-cache.js +56 -8
  208. package/dist/server/isr-cache.js.map +1 -1
  209. package/dist/server/metadata-route-build-data.d.ts +25 -0
  210. package/dist/server/metadata-route-build-data.js +150 -0
  211. package/dist/server/metadata-route-build-data.js.map +1 -0
  212. package/dist/server/metadata-route-response.d.ts +17 -0
  213. package/dist/server/metadata-route-response.js +187 -0
  214. package/dist/server/metadata-route-response.js.map +1 -0
  215. package/dist/server/metadata-routes.d.ts +42 -4
  216. package/dist/server/metadata-routes.js +127 -11
  217. package/dist/server/metadata-routes.js.map +1 -1
  218. package/dist/server/middleware-matcher.d.ts +15 -0
  219. package/dist/server/middleware-matcher.js +102 -0
  220. package/dist/server/middleware-matcher.js.map +1 -0
  221. package/dist/server/middleware-request-headers.js +2 -1
  222. package/dist/server/middleware-request-headers.js.map +1 -1
  223. package/dist/server/middleware-runtime.d.ts +39 -0
  224. package/dist/server/middleware-runtime.js +159 -0
  225. package/dist/server/middleware-runtime.js.map +1 -0
  226. package/dist/server/middleware.d.ts +4 -36
  227. package/dist/server/middleware.js +18 -228
  228. package/dist/server/middleware.js.map +1 -1
  229. package/dist/server/pages-page-data.d.ts +7 -2
  230. package/dist/server/pages-page-data.js +10 -5
  231. package/dist/server/pages-page-data.js.map +1 -1
  232. package/dist/server/pages-page-response.d.ts +2 -1
  233. package/dist/server/pages-page-response.js +5 -3
  234. package/dist/server/pages-page-response.js.map +1 -1
  235. package/dist/server/prerender-work-unit-setup.d.ts +7 -0
  236. package/dist/server/prerender-work-unit-setup.js +30 -0
  237. package/dist/server/prerender-work-unit-setup.js.map +1 -0
  238. package/dist/server/prod-server.js +10 -14
  239. package/dist/server/prod-server.js.map +1 -1
  240. package/dist/server/request-pipeline.d.ts +46 -5
  241. package/dist/server/request-pipeline.js +84 -5
  242. package/dist/server/request-pipeline.js.map +1 -1
  243. package/dist/server/rsc-stream-hints.d.ts +7 -0
  244. package/dist/server/rsc-stream-hints.js +38 -0
  245. package/dist/server/rsc-stream-hints.js.map +1 -0
  246. package/dist/server/seed-cache.js +19 -8
  247. package/dist/server/seed-cache.js.map +1 -1
  248. package/dist/server/server-action-not-found.d.ts +9 -0
  249. package/dist/server/server-action-not-found.js +40 -0
  250. package/dist/server/server-action-not-found.js.map +1 -0
  251. package/dist/shims/cache-runtime.js +28 -11
  252. package/dist/shims/cache-runtime.js.map +1 -1
  253. package/dist/shims/cache.d.ts +39 -4
  254. package/dist/shims/cache.js +93 -16
  255. package/dist/shims/cache.js.map +1 -1
  256. package/dist/shims/error-boundary.d.ts +66 -5
  257. package/dist/shims/error-boundary.js +106 -4
  258. package/dist/shims/error-boundary.js.map +1 -1
  259. package/dist/shims/fetch-cache.d.ts +4 -1
  260. package/dist/shims/fetch-cache.js +55 -13
  261. package/dist/shims/fetch-cache.js.map +1 -1
  262. package/dist/shims/font-google-base.d.ts +5 -4
  263. package/dist/shims/font-google-base.js +61 -13
  264. package/dist/shims/font-google-base.js.map +1 -1
  265. package/dist/shims/headers.d.ts +14 -2
  266. package/dist/shims/headers.js +127 -17
  267. package/dist/shims/headers.js.map +1 -1
  268. package/dist/shims/image.js +116 -10
  269. package/dist/shims/image.js.map +1 -1
  270. package/dist/shims/internal/make-hanging-promise.d.ts +16 -0
  271. package/dist/shims/internal/make-hanging-promise.js +46 -0
  272. package/dist/shims/internal/make-hanging-promise.js.map +1 -0
  273. package/dist/shims/internal/work-unit-async-storage.d.ts +26 -3
  274. package/dist/shims/internal/work-unit-async-storage.js +6 -3
  275. package/dist/shims/internal/work-unit-async-storage.js.map +1 -1
  276. package/dist/shims/metadata.d.ts +38 -26
  277. package/dist/shims/metadata.js +75 -45
  278. package/dist/shims/metadata.js.map +1 -1
  279. package/dist/shims/navigation.d.ts +10 -1
  280. package/dist/shims/navigation.js +18 -1
  281. package/dist/shims/navigation.js.map +1 -1
  282. package/dist/shims/navigation.react-server.d.ts +2 -2
  283. package/dist/shims/navigation.react-server.js +2 -2
  284. package/dist/shims/navigation.react-server.js.map +1 -1
  285. package/dist/shims/offline.d.ts +5 -0
  286. package/dist/shims/offline.js +17 -0
  287. package/dist/shims/offline.js.map +1 -0
  288. package/dist/shims/request-state-types.d.ts +3 -2
  289. package/dist/shims/root-params.d.ts +11 -0
  290. package/dist/shims/root-params.js +24 -0
  291. package/dist/shims/root-params.js.map +1 -0
  292. package/dist/shims/router.js +1 -1
  293. package/dist/shims/server.d.ts +3 -1
  294. package/dist/shims/server.js +83 -5
  295. package/dist/shims/server.js.map +1 -1
  296. package/dist/shims/thenable-params.d.ts +5 -0
  297. package/dist/shims/thenable-params.js +37 -0
  298. package/dist/shims/thenable-params.js.map +1 -0
  299. package/dist/shims/unified-request-context.d.ts +3 -2
  300. package/dist/shims/unified-request-context.js +3 -0
  301. package/dist/shims/unified-request-context.js.map +1 -1
  302. package/dist/shims/use-merged-ref.d.ts +7 -0
  303. package/dist/shims/use-merged-ref.js +40 -0
  304. package/dist/shims/use-merged-ref.js.map +1 -0
  305. package/dist/utils/cache-control-metadata.d.ts +6 -0
  306. package/dist/utils/cache-control-metadata.js +16 -0
  307. package/dist/utils/cache-control-metadata.js.map +1 -0
  308. package/package.json +6 -1
  309. package/dist/server/middleware-codegen.d.ts +0 -54
  310. package/dist/server/middleware-codegen.js +0 -414
  311. package/dist/server/middleware-codegen.js.map +0 -1
package/dist/index.js CHANGED
@@ -3,36 +3,38 @@ import { normalizePathnameForRouteMatchStrict } from "./routing/utils.js";
3
3
  import { createValidFileMatcher } from "./routing/file-matcher.js";
4
4
  import { apiRouter, invalidateRouteCache, matchRoute, pagesRouter } from "./routing/pages-router.js";
5
5
  import { buildRequestHeadersFromMiddlewareResponse } from "./server/middleware-request-headers.js";
6
- import { isExternalUrl, matchHeaders, matchRedirect, matchRewrite, proxyExternalRequest, requestContextFromRequest, sanitizeDestination } from "./config/config-matchers.js";
7
6
  import { normalizePath as normalizePath$1 } from "./server/normalize-path.js";
7
+ import { isExternalUrl, matchHeaders, matchRedirect, matchRewrite, proxyExternalRequest, requestContextFromRequest, sanitizeDestination } from "./config/config-matchers.js";
8
+ import { hasBasePath } from "./utils/base-path.js";
9
+ import { isOpenRedirectShaped } from "./server/request-pipeline.js";
8
10
  import { findMiddlewareFile, runMiddleware } from "./server/middleware.js";
9
11
  import { generateServerEntry } from "./entries/pages-server-entry.js";
10
12
  import { generateClientEntry } from "./entries/pages-client-entry.js";
11
13
  import { appRouter, invalidateAppRouteCache } from "./routing/app-router.js";
12
14
  import { findInstrumentationClientFile, findInstrumentationFile, runInstrumentation } from "./server/instrumentation.js";
13
- import { hasBasePath } from "./utils/base-path.js";
14
15
  import { logRequest, now } from "./server/request-log.js";
15
16
  import { createSSRHandler } from "./server/dev-server.js";
16
17
  import { handleApiRoute } from "./server/api-handler.js";
17
18
  import { installSocketErrorBackstop } from "./server/socket-error-backstop.js";
19
+ import { scanMetadataFiles } from "./server/metadata-routes.js";
20
+ import { shouldInvalidateAppRouteFile } from "./server/dev-route-files.js";
18
21
  import { createDirectRunner } from "./server/dev-module-runner.js";
19
22
  import { validateDevRequest } from "./server/dev-origin-check.js";
20
23
  import { generateRscEntry } from "./entries/app-rsc-entry.js";
21
24
  import { generateSsrEntry } from "./entries/app-ssr-entry.js";
22
25
  import { generateBrowserEntry } from "./entries/app-browser-entry.js";
23
- import { buildGenerateBundleReplacement, buildReasonsReplacement, collectRouteClassificationManifest } from "./build/route-classification-manifest.js";
24
- import { classifyLayoutByModuleGraph, isStaticModuleGraphResult, moduleGraphReason } from "./build/layout-classification.js";
26
+ import { collectRouteClassificationManifest } from "./build/route-classification-manifest.js";
27
+ import { planRouteClassificationInjection } from "./build/route-classification-injector.js";
25
28
  import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "./shims/constants.js";
26
29
  import { findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
27
- import { isOpenRedirectShaped } from "./server/request-pipeline.js";
28
30
  import { precompressAssets } from "./build/precompress.js";
29
- import { scanMetadataFiles } from "./server/metadata-routes.js";
30
31
  import { manifestFileWithBase, manifestFilesWithBase } from "./utils/manifest-paths.js";
31
32
  import { asyncHooksStubPlugin } from "./plugins/async-hooks-stub.js";
32
33
  import { clientReferenceDedupPlugin } from "./plugins/client-reference-dedup.js";
33
34
  import { createInstrumentationClientTransformPlugin } from "./plugins/instrumentation-client.js";
34
35
  import { createOptimizeImportsPlugin } from "./plugins/optimize-imports.js";
35
36
  import { createOgInlineFetchAssetsPlugin, ogAssetsPlugin } from "./plugins/og-assets.js";
37
+ import { VINEXT_OPTIMIZE_DEPS_EXCLUDE, mergeOptimizeDepsExclude } from "./plugins/rsc-client-shim-excludes.js";
36
38
  import { createServerExternalsManifestPlugin } from "./plugins/server-externals-manifest.js";
37
39
  import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral } from "./plugins/fonts.js";
38
40
  import { computeLazyChunks } from "./utils/lazy-chunks.js";
@@ -205,12 +207,23 @@ const VIRTUAL_APP_SSR_ENTRY = "virtual:vinext-app-ssr-entry";
205
207
  const RESOLVED_APP_SSR_ENTRY = "\0" + VIRTUAL_APP_SSR_ENTRY;
206
208
  const VIRTUAL_APP_BROWSER_ENTRY = "virtual:vinext-app-browser-entry";
207
209
  const RESOLVED_APP_BROWSER_ENTRY = "\0" + VIRTUAL_APP_BROWSER_ENTRY;
210
+ const RESOLVED_ROOT_PARAMS = "\0virtual:vinext-root-params";
208
211
  /** Image file extensions handled by the vinext:image-imports plugin.
209
212
  * Shared between the Rolldown hook filter and the transform handler regex. */
210
213
  const IMAGE_EXTS = "png|jpe?g|gif|webp|avif|svg|ico|bmp|tiff?";
211
214
  /** Absolute path to vinext's shims directory, used by clientManualChunks. */
212
215
  const _shimsDir = path.resolve(__dirname, "shims") + "/";
213
216
  const _fontGoogleShimPath = resolveShimModulePath(_shimsDir, "font-google");
217
+ function isValidExportIdentifier(name) {
218
+ return /^[$A-Z_a-z][$\w]*$/.test(name);
219
+ }
220
+ function generateRootParamsModule(rootParamNames) {
221
+ const names = Array.from(new Set(rootParamNames)).filter(isValidExportIdentifier).sort();
222
+ if (names.length === 0) return "export {};\n";
223
+ const rootParamsShimPath = resolveShimModulePath(_shimsDir, "root-params");
224
+ const exports = names.map((name) => `export function ${name}() { return getRootParam(${JSON.stringify(name)}); }`).join("\n");
225
+ return `import { getRootParam } from ${JSON.stringify(rootParamsShimPath)};\n${exports}\n`;
226
+ }
214
227
  /**
215
228
  * Shims with a `.react-server.ts` variant for the RSC environment.
216
229
  * Maps import specifier → base shim name. In the RSC env, resolveId
@@ -451,6 +464,7 @@ function vinext(options = {}) {
451
464
  "next/og": path.join(shimsDir, "og"),
452
465
  "next/web-vitals": path.join(shimsDir, "web-vitals"),
453
466
  "next/amp": path.join(shimsDir, "amp"),
467
+ "next/offline": path.join(shimsDir, "offline"),
454
468
  "next/error": path.join(shimsDir, "error"),
455
469
  "next/constants": path.join(shimsDir, "constants"),
456
470
  "next/dist/shared/lib/app-router-context.shared-runtime": path.join(shimsDir, "internal", "app-router-context"),
@@ -464,6 +478,7 @@ function vinext(options = {}) {
464
478
  "next/dist/client/components/work-unit-async-storage.external": path.join(shimsDir, "internal", "work-unit-async-storage"),
465
479
  "next/dist/client/components/request-async-storage.external": path.join(shimsDir, "internal", "work-unit-async-storage"),
466
480
  "next/dist/client/components/request-async-storage": path.join(shimsDir, "internal", "work-unit-async-storage"),
481
+ "next/dist/server/request/root-params": path.join(shimsDir, "root-params"),
467
482
  "next/dist/server/config-shared": path.join(shimsDir, "internal", "utils"),
468
483
  "server-only": path.join(shimsDir, "server-only"),
469
484
  "client-only": path.join(shimsDir, "client-only"),
@@ -557,12 +572,7 @@ function vinext(options = {}) {
557
572
  }
558
573
  };
559
574
  viteConfig.optimizeDeps = {
560
- exclude: [...new Set([
561
- ...incomingExclude,
562
- "vinext",
563
- "@vercel/og",
564
- "@tailwindcss/oxide"
565
- ])],
575
+ exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["@tailwindcss/oxide"]),
566
576
  ...incomingInclude.length > 0 ? { include: incomingInclude } : {},
567
577
  rolldownOptions: { plugins: [depOptimizeAliasPlugin] }
568
578
  };
@@ -583,11 +593,7 @@ function vinext(options = {}) {
583
593
  ...userSsrExternal === true ? {} : { noExternal: true }
584
594
  } },
585
595
  optimizeDeps: {
586
- exclude: [...new Set([
587
- ...incomingExclude,
588
- "vinext",
589
- "@vercel/og"
590
- ])],
596
+ exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE),
591
597
  entries: optimizeEntries
592
598
  },
593
599
  build: {
@@ -601,11 +607,7 @@ function vinext(options = {}) {
601
607
  ...userSsrExternal === true ? {} : { noExternal: true }
602
608
  } },
603
609
  optimizeDeps: {
604
- exclude: [...new Set([
605
- ...incomingExclude,
606
- "vinext",
607
- "@vercel/og"
608
- ])],
610
+ exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE),
609
611
  entries: optimizeEntries
610
612
  },
611
613
  build: {
@@ -616,12 +618,7 @@ function vinext(options = {}) {
616
618
  client: {
617
619
  consumer: "client",
618
620
  optimizeDeps: {
619
- exclude: [...new Set([
620
- ...incomingExclude,
621
- "vinext",
622
- "@vercel/og",
623
- ...nextServerExternal
624
- ])],
621
+ exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, nextServerExternal),
625
622
  entries: optimizeEntries,
626
623
  include: [...new Set([
627
624
  ...incomingInclude,
@@ -722,6 +719,7 @@ function vinext(options = {}) {
722
719
  if (cleanId === VIRTUAL_RSC_ENTRY) return RESOLVED_RSC_ENTRY;
723
720
  if (cleanId === VIRTUAL_APP_SSR_ENTRY) return RESOLVED_APP_SSR_ENTRY;
724
721
  if (cleanId === VIRTUAL_APP_BROWSER_ENTRY) return RESOLVED_APP_BROWSER_ENTRY;
722
+ if (cleanId === "next/root-params" || cleanId === "next/root-params.js") return RESOLVED_ROOT_PARAMS;
725
723
  if (cleanId.startsWith("virtual:vinext-google-fonts?")) return RESOLVED_VIRTUAL_GOOGLE_FONTS + cleanId.slice(VIRTUAL_GOOGLE_FONTS.length);
726
724
  if (cleanId.endsWith("/" + VIRTUAL_RSC_ENTRY) || cleanId.endsWith("\\" + VIRTUAL_RSC_ENTRY)) return RESOLVED_RSC_ENTRY;
727
725
  if (cleanId.endsWith("/" + VIRTUAL_APP_SSR_ENTRY) || cleanId.endsWith("\\" + VIRTUAL_APP_SSR_ENTRY)) return RESOLVED_APP_SSR_ENTRY;
@@ -749,11 +747,13 @@ function vinext(options = {}) {
749
747
  allowedOrigins: nextConfig?.serverActionsAllowedOrigins,
750
748
  allowedDevOrigins: nextConfig?.allowedDevOrigins,
751
749
  bodySizeLimit: nextConfig?.serverActionsBodySizeLimit,
750
+ expireTime: nextConfig?.expireTime,
752
751
  i18n: nextConfig?.i18n,
753
752
  hasPagesDir,
754
753
  publicFiles: scanPublicFileRoutes(root)
755
754
  }, instrumentationPath);
756
755
  }
756
+ if (id === RESOLVED_ROOT_PARAMS) return generateRootParamsModule((hasAppDir ? await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : []).flatMap((route) => route.rootParamNames ?? []));
757
757
  if (id === RESOLVED_APP_SSR_ENTRY && hasAppDir) return generateSsrEntry(hasPagesDir);
758
758
  if (id === RESOLVED_APP_BROWSER_ENTRY && hasAppDir) return generateBrowserEntry();
759
759
  if (id.startsWith("\0virtual:vinext-google-fonts?")) return generateGoogleFontsVirtualModule(id, _fontGoogleShimPath);
@@ -762,60 +762,36 @@ function vinext(options = {}) {
762
762
  if (this.environment?.name !== "rsc") return;
763
763
  if (!rscClassificationManifest) return;
764
764
  const enableClassificationDebug = Boolean(process.env.VINEXT_DEBUG_CLASSIFICATION);
765
- const stubRe = /function __VINEXT_CLASS\(routeIdx\)\s*\{\s*return null;?\s*\}/;
766
- const reasonsStubRe = /function __VINEXT_CLASS_REASONS\(routeIdx\)\s*\{\s*return null;?\s*\}/;
767
- const chunksMentioningStub = [];
768
- const chunksWithStubBody = [];
765
+ const chunks = [];
766
+ const chunksByFileName = /* @__PURE__ */ new Map();
769
767
  for (const chunk of Object.values(bundle)) {
770
768
  if (chunk.type !== "chunk") continue;
771
- if (!chunk.code.includes("__VINEXT_CLASS")) continue;
772
- chunksMentioningStub.push({
773
- chunk,
774
- fileName: chunk.fileName
775
- });
776
- if (stubRe.test(chunk.code)) chunksWithStubBody.push({
777
- chunk,
769
+ chunks.push({
770
+ code: chunk.code,
778
771
  fileName: chunk.fileName
779
772
  });
773
+ chunksByFileName.set(chunk.fileName, chunk);
780
774
  }
781
- if (chunksMentioningStub.length === 0) return;
782
- if (chunksWithStubBody.length === 0) throw new Error(`vinext: build-time classification — __VINEXT_CLASS is referenced in ${chunksMentioningStub.map((c) => c.fileName).join(", ")} but no chunk contains the stub body. The generator and generateBundle have drifted.`);
783
- if (chunksWithStubBody.length > 1) throw new Error(`vinext: build-time classification — expected __VINEXT_CLASS stub in exactly one RSC chunk, found ${chunksWithStubBody.length}`);
784
- if (enableClassificationDebug && !reasonsStubRe.test(chunksWithStubBody[0].chunk.code)) throw new Error("vinext: build-time classification — __VINEXT_CLASS_REASONS stub is missing alongside __VINEXT_CLASS. The generator and generateBundle have drifted.");
785
- const moduleInfo = { getModuleInfo: (moduleId) => {
786
- const info = this.getModuleInfo(moduleId);
787
- if (!info) return null;
788
- return {
789
- importedIds: info.importedIds ?? [],
790
- dynamicImportedIds: info.dynamicallyImportedIds ?? []
791
- };
792
- } };
793
- const layer2PerRoute = /* @__PURE__ */ new Map();
794
- const graphCache = /* @__PURE__ */ new Map();
795
- for (let routeIdx = 0; routeIdx < rscClassificationManifest.routes.length; routeIdx++) {
796
- const route = rscClassificationManifest.routes[routeIdx];
797
- const perRoute = /* @__PURE__ */ new Map();
798
- for (let layoutIdx = 0; layoutIdx < route.layoutPaths.length; layoutIdx++) {
799
- if (route.layer1.has(layoutIdx)) continue;
800
- const layoutModuleId = canonicalize(route.layoutPaths[layoutIdx]);
801
- if (!moduleInfo.getModuleInfo(layoutModuleId)) continue;
802
- let graphResult = graphCache.get(layoutModuleId);
803
- if (graphResult === void 0) {
804
- graphResult = classifyLayoutByModuleGraph(layoutModuleId, dynamicShimPaths, moduleInfo);
805
- graphCache.set(layoutModuleId, graphResult);
806
- }
807
- if (isStaticModuleGraphResult(graphResult)) perRoute.set(layoutIdx, moduleGraphReason(graphResult));
808
- }
809
- if (perRoute.size > 0) layer2PerRoute.set(routeIdx, perRoute);
810
- }
811
- const patchedBody = `function __VINEXT_CLASS(routeIdx) { return (${buildGenerateBundleReplacement(rscClassificationManifest, layer2PerRoute)})(routeIdx); }`;
812
- const target = chunksWithStubBody[0].chunk;
813
- target.code = target.code.replace(stubRe, patchedBody);
814
- if (enableClassificationDebug) {
815
- const patchedReasonsBody = `function __VINEXT_CLASS_REASONS(routeIdx) { return (${buildReasonsReplacement(rscClassificationManifest, layer2PerRoute)})(routeIdx); }`;
816
- target.code = target.code.replace(reasonsStubRe, patchedReasonsBody);
817
- }
818
- target.map = null;
775
+ const patchPlan = planRouteClassificationInjection({
776
+ canonicalizeLayoutPath: canonicalize,
777
+ chunks,
778
+ dynamicShimPaths,
779
+ enableDebugReasons: enableClassificationDebug,
780
+ manifest: rscClassificationManifest,
781
+ moduleInfo: { getModuleInfo: (moduleId) => {
782
+ const info = this.getModuleInfo(moduleId);
783
+ if (!info) return null;
784
+ return {
785
+ importedIds: info.importedIds ?? [],
786
+ dynamicImportedIds: info.dynamicallyImportedIds ?? []
787
+ };
788
+ } }
789
+ });
790
+ if (patchPlan.kind === "skip") return;
791
+ const target = chunksByFileName.get(patchPlan.fileName);
792
+ if (!target) throw new Error(`vinext: build-time classification — patch target ${patchPlan.fileName} disappeared from the RSC bundle`);
793
+ target.code = patchPlan.code;
794
+ target.map = patchPlan.map;
819
795
  rscClassificationManifest = null;
820
796
  }
821
797
  },
@@ -904,22 +880,27 @@ function vinext(options = {}) {
904
880
  rscEnv.hot.send({ type: "full-reload" });
905
881
  }
906
882
  }
883
+ function invalidateRootParamsModule() {
884
+ for (const env of Object.values(server.environments)) {
885
+ const mod = env.moduleGraph.getModuleById(RESOLVED_ROOT_PARAMS);
886
+ if (mod) env.moduleGraph.invalidateModule(mod);
887
+ }
888
+ }
889
+ function invalidateAppRoutingModules() {
890
+ invalidateAppRouteCache();
891
+ invalidateRscEntryModule();
892
+ invalidateRootParamsModule();
893
+ }
907
894
  server.httpServer?.on("connection", (socket) => {
908
895
  socket.on("error", () => {});
909
896
  });
910
897
  server.watcher.on("add", (filePath) => {
911
898
  if (hasPagesDir && filePath.startsWith(pagesDir) && pageExtensions.test(filePath)) invalidateRouteCache(pagesDir);
912
- if (hasAppDir && filePath.startsWith(appDir) && pageExtensions.test(filePath)) {
913
- invalidateAppRouteCache();
914
- invalidateRscEntryModule();
915
- }
899
+ if (hasAppDir && shouldInvalidateAppRouteFile(appDir, filePath, fileMatcher)) invalidateAppRoutingModules();
916
900
  });
917
901
  server.watcher.on("unlink", (filePath) => {
918
902
  if (hasPagesDir && filePath.startsWith(pagesDir) && pageExtensions.test(filePath)) invalidateRouteCache(pagesDir);
919
- if (hasAppDir && filePath.startsWith(appDir) && pageExtensions.test(filePath)) {
920
- invalidateAppRouteCache();
921
- invalidateRscEntryModule();
922
- }
903
+ if (hasAppDir && shouldInvalidateAppRouteFile(appDir, filePath, fileMatcher)) invalidateAppRoutingModules();
923
904
  });
924
905
  server.middlewares.use((req, res, next) => {
925
906
  const blockReason = validateDevRequest({
@@ -1086,6 +1067,10 @@ function vinext(options = {}) {
1086
1067
  const applyDeferredMwHeaders = () => {
1087
1068
  if (deferredMwResponseHeaders) for (const [key, value] of deferredMwResponseHeaders) res.appendHeader(key, value);
1088
1069
  };
1070
+ const applyMwRequestHeadersForExternalProxy = () => {
1071
+ if (middlewareRequestHeaders) applyRequestHeadersToNodeRequest(middlewareRequestHeaders);
1072
+ else delete req.headers["x-vinext-mw-ctx"];
1073
+ };
1089
1074
  if (middlewarePath) {
1090
1075
  const rawProto = process.env.VINEXT_TRUST_PROXY === "1" || (process.env.VINEXT_TRUSTED_HOSTS ?? "").split(",").some((h) => h.trim()) ? String(req.headers["x-forwarded-proto"] || "").split(",")[0].trim() : "";
1091
1076
  const origin = `${rawProto === "https" || rawProto === "http" ? rawProto : "http"}://${req.headers.host || "localhost"}`;
@@ -1151,6 +1136,7 @@ function vinext(options = {}) {
1151
1136
  if (nextConfig?.rewrites.beforeFiles.length) resolvedUrl = applyRewrites(pathname, nextConfig.rewrites.beforeFiles, reqCtx) ?? url;
1152
1137
  if (isExternalUrl(resolvedUrl)) {
1153
1138
  applyDeferredMwHeaders();
1139
+ applyMwRequestHeadersForExternalProxy();
1154
1140
  await proxyExternalRewriteNode(req, res, resolvedUrl);
1155
1141
  return;
1156
1142
  }
@@ -1174,6 +1160,7 @@ function vinext(options = {}) {
1174
1160
  }
1175
1161
  if (isExternalUrl(resolvedUrl)) {
1176
1162
  applyDeferredMwHeaders();
1163
+ applyMwRequestHeadersForExternalProxy();
1177
1164
  await proxyExternalRewriteNode(req, res, resolvedUrl);
1178
1165
  return;
1179
1166
  }
@@ -1190,6 +1177,7 @@ function vinext(options = {}) {
1190
1177
  if (fallbackRewrite) {
1191
1178
  if (isExternalUrl(fallbackRewrite)) {
1192
1179
  applyDeferredMwHeaders();
1180
+ applyMwRequestHeadersForExternalProxy();
1193
1181
  await proxyExternalRewriteNode(req, res, fallbackRewrite);
1194
1182
  return;
1195
1183
  }
@@ -1442,6 +1430,15 @@ function vinext(options = {}) {
1442
1430
  }
1443
1431
  };
1444
1432
  })(),
1433
+ {
1434
+ name: "vinext:hash-salt",
1435
+ apply: "build",
1436
+ augmentChunkHash() {
1437
+ if (this.environment?.name !== "client") return;
1438
+ const salt = nextConfig?.hashSalt;
1439
+ if (salt) return salt;
1440
+ }
1441
+ },
1445
1442
  (() => {
1446
1443
  const prerenderSecret = randomBytes(32).toString("hex");
1447
1444
  return {