@qzsy/vinext 0.1.7

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 (803) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +773 -0
  3. package/dist/build/assets-ignore.d.ts +32 -0
  4. package/dist/build/assets-ignore.js +48 -0
  5. package/dist/build/clean-output.d.ts +13 -0
  6. package/dist/build/clean-output.js +34 -0
  7. package/dist/build/client-build-config.d.ts +171 -0
  8. package/dist/build/client-build-config.js +270 -0
  9. package/dist/build/css-url-assets.d.ts +29 -0
  10. package/dist/build/css-url-assets.js +213 -0
  11. package/dist/build/google-fonts/build-url.d.ts +9 -0
  12. package/dist/build/google-fonts/build-url.js +28 -0
  13. package/dist/build/google-fonts/fallback-metrics-data.js +14029 -0
  14. package/dist/build/google-fonts/fallback-metrics.d.ts +12 -0
  15. package/dist/build/google-fonts/fallback-metrics.js +44 -0
  16. package/dist/build/google-fonts/find-font-files-in-css.d.ts +16 -0
  17. package/dist/build/google-fonts/find-font-files-in-css.js +28 -0
  18. package/dist/build/google-fonts/font-data.js +24983 -0
  19. package/dist/build/google-fonts/font-metadata.d.ts +16 -0
  20. package/dist/build/google-fonts/font-metadata.js +5 -0
  21. package/dist/build/google-fonts/get-axes.d.ts +6 -0
  22. package/dist/build/google-fonts/get-axes.js +37 -0
  23. package/dist/build/google-fonts/sort-variants.d.ts +4 -0
  24. package/dist/build/google-fonts/sort-variants.js +12 -0
  25. package/dist/build/google-fonts/validate.d.ts +27 -0
  26. package/dist/build/google-fonts/validate.js +54 -0
  27. package/dist/build/inline-css.d.ts +6 -0
  28. package/dist/build/inline-css.js +48 -0
  29. package/dist/build/layout-classification-types.d.ts +61 -0
  30. package/dist/build/layout-classification-types.js +1 -0
  31. package/dist/build/layout-classification.d.ts +59 -0
  32. package/dist/build/layout-classification.js +98 -0
  33. package/dist/build/next-client-runtime-manifests.d.ts +14 -0
  34. package/dist/build/next-client-runtime-manifests.js +39 -0
  35. package/dist/build/nitro-route-rules.d.ts +49 -0
  36. package/dist/build/nitro-route-rules.js +79 -0
  37. package/dist/build/precompress.d.ts +27 -0
  38. package/dist/build/precompress.js +110 -0
  39. package/dist/build/prerender.d.ts +209 -0
  40. package/dist/build/prerender.js +932 -0
  41. package/dist/build/report.d.ts +132 -0
  42. package/dist/build/report.js +504 -0
  43. package/dist/build/route-classification-injector.d.ts +34 -0
  44. package/dist/build/route-classification-injector.js +59 -0
  45. package/dist/build/route-classification-manifest.d.ts +52 -0
  46. package/dist/build/route-classification-manifest.js +143 -0
  47. package/dist/build/run-prerender.d.ts +61 -0
  48. package/dist/build/run-prerender.js +224 -0
  49. package/dist/build/server-manifest.d.ts +18 -0
  50. package/dist/build/server-manifest.js +22 -0
  51. package/dist/build/ssr-manifest.d.ts +18 -0
  52. package/dist/build/ssr-manifest.js +69 -0
  53. package/dist/build/standalone.d.ts +31 -0
  54. package/dist/build/standalone.js +203 -0
  55. package/dist/build/static-export.d.ts +55 -0
  56. package/dist/build/static-export.js +60 -0
  57. package/dist/cache/cache-adapters-virtual.d.ts +50 -0
  58. package/dist/cache/cache-adapters-virtual.js +45 -0
  59. package/dist/cache.d.ts +2 -0
  60. package/dist/cache.js +2 -0
  61. package/dist/check.d.ts +87 -0
  62. package/dist/check.js +1037 -0
  63. package/dist/cli-args.d.ts +33 -0
  64. package/dist/cli-args.js +124 -0
  65. package/dist/cli.d.ts +1 -0
  66. package/dist/cli.js +744 -0
  67. package/dist/client/app-nav-failure-handler.d.ts +8 -0
  68. package/dist/client/app-nav-failure-handler.js +44 -0
  69. package/dist/client/empty-module.d.ts +1 -0
  70. package/dist/client/empty-module.js +1 -0
  71. package/dist/client/instrumentation-client-inject.d.ts +33 -0
  72. package/dist/client/instrumentation-client-inject.js +55 -0
  73. package/dist/client/instrumentation-client-state.d.ts +9 -0
  74. package/dist/client/instrumentation-client-state.js +17 -0
  75. package/dist/client/instrumentation-client.d.ts +7 -0
  76. package/dist/client/instrumentation-client.js +6 -0
  77. package/dist/client/navigation-runtime.d.ts +70 -0
  78. package/dist/client/navigation-runtime.js +169 -0
  79. package/dist/client/pages-router-link-navigation.d.ts +61 -0
  80. package/dist/client/pages-router-link-navigation.js +42 -0
  81. package/dist/client/validate-module-path.d.ts +17 -0
  82. package/dist/client/validate-module-path.js +24 -0
  83. package/dist/client/vinext-next-data.d.ts +44 -0
  84. package/dist/client/vinext-next-data.js +50 -0
  85. package/dist/client/window-next.d.ts +168 -0
  86. package/dist/client/window-next.js +57 -0
  87. package/dist/cloudflare/index.d.ts +3 -0
  88. package/dist/cloudflare/index.js +3 -0
  89. package/dist/cloudflare/src/cache/cdn-adapter.runtime.js +102 -0
  90. package/dist/cloudflare/src/cache/kv-data-adapter.runtime.d.ts +126 -0
  91. package/dist/cloudflare/src/cache/kv-data-adapter.runtime.js +435 -0
  92. package/dist/cloudflare/src/utils/cache-control-metadata.js +20 -0
  93. package/dist/cloudflare/tpr.d.ts +82 -0
  94. package/dist/cloudflare/tpr.js +558 -0
  95. package/dist/config/config-matchers.d.ts +257 -0
  96. package/dist/config/config-matchers.js +1046 -0
  97. package/dist/config/dotenv.d.ts +56 -0
  98. package/dist/config/dotenv.js +88 -0
  99. package/dist/config/next-config.d.ts +540 -0
  100. package/dist/config/next-config.js +1050 -0
  101. package/dist/config/tsconfig-paths.d.ts +21 -0
  102. package/dist/config/tsconfig-paths.js +157 -0
  103. package/dist/deploy.d.ts +190 -0
  104. package/dist/deploy.js +1033 -0
  105. package/dist/entries/app-browser-entry.d.ts +29 -0
  106. package/dist/entries/app-browser-entry.js +83 -0
  107. package/dist/entries/app-rsc-entry.d.ts +81 -0
  108. package/dist/entries/app-rsc-entry.js +943 -0
  109. package/dist/entries/app-rsc-manifest.d.ts +53 -0
  110. package/dist/entries/app-rsc-manifest.js +294 -0
  111. package/dist/entries/app-ssr-entry.d.ts +15 -0
  112. package/dist/entries/app-ssr-entry.js +24 -0
  113. package/dist/entries/pages-client-entry.d.ts +11 -0
  114. package/dist/entries/pages-client-entry.js +204 -0
  115. package/dist/entries/pages-entry-helpers.d.ts +2 -0
  116. package/dist/entries/pages-entry-helpers.js +2 -0
  117. package/dist/entries/pages-server-entry.d.ts +11 -0
  118. package/dist/entries/pages-server-entry.js +398 -0
  119. package/dist/entries/runtime-entry-module.d.ts +25 -0
  120. package/dist/entries/runtime-entry-module.js +46 -0
  121. package/dist/index.d.ts +115 -0
  122. package/dist/index.js +2661 -0
  123. package/dist/init.d.ts +69 -0
  124. package/dist/init.js +253 -0
  125. package/dist/plugins/ast-utils.d.ts +20 -0
  126. package/dist/plugins/ast-utils.js +78 -0
  127. package/dist/plugins/async-hooks-stub.d.ts +18 -0
  128. package/dist/plugins/async-hooks-stub.js +40 -0
  129. package/dist/plugins/client-reference-dedup.d.ts +35 -0
  130. package/dist/plugins/client-reference-dedup.js +189 -0
  131. package/dist/plugins/css-data-url.d.ts +6 -0
  132. package/dist/plugins/css-data-url.js +83 -0
  133. package/dist/plugins/dynamic-preload-metadata.d.ts +13 -0
  134. package/dist/plugins/dynamic-preload-metadata.js +413 -0
  135. package/dist/plugins/extensionless-dynamic-import.d.ts +6 -0
  136. package/dist/plugins/extensionless-dynamic-import.js +155 -0
  137. package/dist/plugins/fonts.d.ts +95 -0
  138. package/dist/plugins/fonts.js +711 -0
  139. package/dist/plugins/import-meta-url.d.ts +16 -0
  140. package/dist/plugins/import-meta-url.js +353 -0
  141. package/dist/plugins/instrumentation-client.d.ts +6 -0
  142. package/dist/plugins/instrumentation-client.js +27 -0
  143. package/dist/plugins/middleware-export-validation.d.ts +5 -0
  144. package/dist/plugins/middleware-export-validation.js +36 -0
  145. package/dist/plugins/middleware-server-only.d.ts +53 -0
  146. package/dist/plugins/middleware-server-only.js +90 -0
  147. package/dist/plugins/og-asset-ownership.d.ts +27 -0
  148. package/dist/plugins/og-asset-ownership.js +285 -0
  149. package/dist/plugins/og-assets.d.ts +50 -0
  150. package/dist/plugins/og-assets.js +229 -0
  151. package/dist/plugins/optimize-imports.d.ts +42 -0
  152. package/dist/plugins/optimize-imports.js +587 -0
  153. package/dist/plugins/postcss.d.ts +26 -0
  154. package/dist/plugins/postcss.js +96 -0
  155. package/dist/plugins/remove-console.d.ts +21 -0
  156. package/dist/plugins/remove-console.js +177 -0
  157. package/dist/plugins/require-context.d.ts +6 -0
  158. package/dist/plugins/require-context.js +185 -0
  159. package/dist/plugins/rsc-client-reference-loaders.d.ts +6 -0
  160. package/dist/plugins/rsc-client-reference-loaders.js +46 -0
  161. package/dist/plugins/rsc-client-shim-excludes.d.ts +6 -0
  162. package/dist/plugins/rsc-client-shim-excludes.js +35 -0
  163. package/dist/plugins/sass.d.ts +62 -0
  164. package/dist/plugins/sass.js +268 -0
  165. package/dist/plugins/server-externals-manifest.d.ts +26 -0
  166. package/dist/plugins/server-externals-manifest.js +81 -0
  167. package/dist/plugins/strip-server-exports.d.ts +21 -0
  168. package/dist/plugins/strip-server-exports.js +519 -0
  169. package/dist/plugins/typeof-window.d.ts +14 -0
  170. package/dist/plugins/typeof-window.js +150 -0
  171. package/dist/plugins/wasm-module-import.d.ts +15 -0
  172. package/dist/plugins/wasm-module-import.js +50 -0
  173. package/dist/routing/app-route-graph.d.ts +336 -0
  174. package/dist/routing/app-route-graph.js +1518 -0
  175. package/dist/routing/app-router.d.ts +30 -0
  176. package/dist/routing/app-router.js +59 -0
  177. package/dist/routing/file-matcher.d.ts +60 -0
  178. package/dist/routing/file-matcher.js +147 -0
  179. package/dist/routing/pages-router.d.ts +48 -0
  180. package/dist/routing/pages-router.js +163 -0
  181. package/dist/routing/route-matching.d.ts +27 -0
  182. package/dist/routing/route-matching.js +42 -0
  183. package/dist/routing/route-pattern.d.ts +64 -0
  184. package/dist/routing/route-pattern.js +165 -0
  185. package/dist/routing/route-trie.d.ts +67 -0
  186. package/dist/routing/route-trie.js +143 -0
  187. package/dist/routing/route-validation.d.ts +10 -0
  188. package/dist/routing/route-validation.js +101 -0
  189. package/dist/routing/utils.d.ts +117 -0
  190. package/dist/routing/utils.js +242 -0
  191. package/dist/server/accept-encoding.d.ts +29 -0
  192. package/dist/server/accept-encoding.js +95 -0
  193. package/dist/server/api-handler.d.ts +17 -0
  194. package/dist/server/api-handler.js +276 -0
  195. package/dist/server/app-action-request.d.ts +4 -0
  196. package/dist/server/app-action-request.js +9 -0
  197. package/dist/server/app-bfcache-id.d.ts +5 -0
  198. package/dist/server/app-bfcache-id.js +5 -0
  199. package/dist/server/app-bfcache-identity.d.ts +36 -0
  200. package/dist/server/app-bfcache-identity.js +156 -0
  201. package/dist/server/app-browser-action-result.d.ts +64 -0
  202. package/dist/server/app-browser-action-result.js +111 -0
  203. package/dist/server/app-browser-client-reuse-manifest.d.ts +12 -0
  204. package/dist/server/app-browser-client-reuse-manifest.js +101 -0
  205. package/dist/server/app-browser-entry.d.ts +1 -0
  206. package/dist/server/app-browser-entry.js +1087 -0
  207. package/dist/server/app-browser-error.d.ts +13 -0
  208. package/dist/server/app-browser-error.js +52 -0
  209. package/dist/server/app-browser-history-controller.d.ts +104 -0
  210. package/dist/server/app-browser-history-controller.js +210 -0
  211. package/dist/server/app-browser-hydration.d.ts +32 -0
  212. package/dist/server/app-browser-hydration.js +29 -0
  213. package/dist/server/app-browser-interception-context.d.ts +24 -0
  214. package/dist/server/app-browser-interception-context.js +43 -0
  215. package/dist/server/app-browser-mpa-navigation.d.ts +16 -0
  216. package/dist/server/app-browser-mpa-navigation.js +42 -0
  217. package/dist/server/app-browser-navigation-controller.d.ts +109 -0
  218. package/dist/server/app-browser-navigation-controller.js +465 -0
  219. package/dist/server/app-browser-popstate.d.ts +26 -0
  220. package/dist/server/app-browser-popstate.js +44 -0
  221. package/dist/server/app-browser-rsc-redirect.d.ts +38 -0
  222. package/dist/server/app-browser-rsc-redirect.js +64 -0
  223. package/dist/server/app-browser-server-action-client.d.ts +32 -0
  224. package/dist/server/app-browser-server-action-client.js +128 -0
  225. package/dist/server/app-browser-server-action-navigation.d.ts +6 -0
  226. package/dist/server/app-browser-server-action-navigation.js +9 -0
  227. package/dist/server/app-browser-state.d.ts +140 -0
  228. package/dist/server/app-browser-state.js +315 -0
  229. package/dist/server/app-browser-stream.d.ts +28 -0
  230. package/dist/server/app-browser-stream.js +122 -0
  231. package/dist/server/app-browser-visible-commit.d.ts +78 -0
  232. package/dist/server/app-browser-visible-commit.js +241 -0
  233. package/dist/server/app-client-reference-preloader.d.ts +14 -0
  234. package/dist/server/app-client-reference-preloader.js +44 -0
  235. package/dist/server/app-elements-wire.d.ts +192 -0
  236. package/dist/server/app-elements-wire.js +443 -0
  237. package/dist/server/app-elements.d.ts +9 -0
  238. package/dist/server/app-elements.js +18 -0
  239. package/dist/server/app-fallback-renderer.d.ts +89 -0
  240. package/dist/server/app-fallback-renderer.js +136 -0
  241. package/dist/server/app-history-state.d.ts +85 -0
  242. package/dist/server/app-history-state.js +223 -0
  243. package/dist/server/app-hook-warning-suppression.d.ts +6 -0
  244. package/dist/server/app-hook-warning-suppression.js +10 -0
  245. package/dist/server/app-inline-css-client.d.ts +6 -0
  246. package/dist/server/app-inline-css-client.js +35 -0
  247. package/dist/server/app-interception-context-header.d.ts +32 -0
  248. package/dist/server/app-interception-context-header.js +42 -0
  249. package/dist/server/app-layout-param-observation.d.ts +43 -0
  250. package/dist/server/app-layout-param-observation.js +168 -0
  251. package/dist/server/app-middleware.d.ts +46 -0
  252. package/dist/server/app-middleware.js +168 -0
  253. package/dist/server/app-mounted-slots-header.d.ts +35 -0
  254. package/dist/server/app-mounted-slots-header.js +58 -0
  255. package/dist/server/app-optimistic-routing.d.ts +53 -0
  256. package/dist/server/app-optimistic-routing.js +227 -0
  257. package/dist/server/app-page-boundary-render.d.ts +85 -0
  258. package/dist/server/app-page-boundary-render.js +305 -0
  259. package/dist/server/app-page-boundary.d.ts +102 -0
  260. package/dist/server/app-page-boundary.js +120 -0
  261. package/dist/server/app-page-cache-finalizer.d.ts +62 -0
  262. package/dist/server/app-page-cache-finalizer.js +122 -0
  263. package/dist/server/app-page-cache-render.d.ts +53 -0
  264. package/dist/server/app-page-cache-render.js +91 -0
  265. package/dist/server/app-page-cache.d.ts +83 -0
  266. package/dist/server/app-page-cache.js +272 -0
  267. package/dist/server/app-page-dispatch.d.ts +223 -0
  268. package/dist/server/app-page-dispatch.js +610 -0
  269. package/dist/server/app-page-element-builder.d.ts +96 -0
  270. package/dist/server/app-page-element-builder.js +205 -0
  271. package/dist/server/app-page-execution.d.ts +138 -0
  272. package/dist/server/app-page-execution.js +328 -0
  273. package/dist/server/app-page-head.d.ts +65 -0
  274. package/dist/server/app-page-head.js +228 -0
  275. package/dist/server/app-page-method.d.ts +15 -0
  276. package/dist/server/app-page-method.js +25 -0
  277. package/dist/server/app-page-params.d.ts +8 -0
  278. package/dist/server/app-page-params.js +39 -0
  279. package/dist/server/app-page-ppr-runtime.d.ts +7 -0
  280. package/dist/server/app-page-ppr-runtime.js +70 -0
  281. package/dist/server/app-page-probe.d.ts +134 -0
  282. package/dist/server/app-page-probe.js +276 -0
  283. package/dist/server/app-page-render-identity.d.ts +21 -0
  284. package/dist/server/app-page-render-identity.js +40 -0
  285. package/dist/server/app-page-render-observation.d.ts +36 -0
  286. package/dist/server/app-page-render-observation.js +82 -0
  287. package/dist/server/app-page-render.d.ts +111 -0
  288. package/dist/server/app-page-render.js +602 -0
  289. package/dist/server/app-page-request.d.ts +137 -0
  290. package/dist/server/app-page-request.js +216 -0
  291. package/dist/server/app-page-response.d.ts +68 -0
  292. package/dist/server/app-page-response.js +120 -0
  293. package/dist/server/app-page-route-wiring.d.ts +151 -0
  294. package/dist/server/app-page-route-wiring.js +452 -0
  295. package/dist/server/app-page-search-params-observation.d.ts +10 -0
  296. package/dist/server/app-page-search-params-observation.js +20 -0
  297. package/dist/server/app-page-segment-state.d.ts +9 -0
  298. package/dist/server/app-page-segment-state.js +80 -0
  299. package/dist/server/app-page-stream.d.ts +151 -0
  300. package/dist/server/app-page-stream.js +143 -0
  301. package/dist/server/app-pages-bridge.d.ts +63 -0
  302. package/dist/server/app-pages-bridge.js +63 -0
  303. package/dist/server/app-post-middleware-context.d.ts +15 -0
  304. package/dist/server/app-post-middleware-context.js +26 -0
  305. package/dist/server/app-ppr-fallback-shell-render.d.ts +18 -0
  306. package/dist/server/app-ppr-fallback-shell-render.js +26 -0
  307. package/dist/server/app-ppr-fallback-shell.d.ts +33 -0
  308. package/dist/server/app-ppr-fallback-shell.js +89 -0
  309. package/dist/server/app-prerender-endpoints.d.ts +18 -0
  310. package/dist/server/app-prerender-endpoints.js +94 -0
  311. package/dist/server/app-prerender-static-params.d.ts +30 -0
  312. package/dist/server/app-prerender-static-params.js +81 -0
  313. package/dist/server/app-render-dependency.d.ts +14 -0
  314. package/dist/server/app-render-dependency.js +41 -0
  315. package/dist/server/app-request-context.d.ts +20 -0
  316. package/dist/server/app-request-context.js +29 -0
  317. package/dist/server/app-route-handler-cache.d.ts +46 -0
  318. package/dist/server/app-route-handler-cache.js +78 -0
  319. package/dist/server/app-route-handler-dispatch.d.ts +49 -0
  320. package/dist/server/app-route-handler-dispatch.js +163 -0
  321. package/dist/server/app-route-handler-execution.d.ts +86 -0
  322. package/dist/server/app-route-handler-execution.js +128 -0
  323. package/dist/server/app-route-handler-policy.d.ts +55 -0
  324. package/dist/server/app-route-handler-policy.js +58 -0
  325. package/dist/server/app-route-handler-response.d.ts +28 -0
  326. package/dist/server/app-route-handler-response.js +145 -0
  327. package/dist/server/app-route-handler-runtime.d.ts +39 -0
  328. package/dist/server/app-route-handler-runtime.js +250 -0
  329. package/dist/server/app-route-module-loader.d.ts +91 -0
  330. package/dist/server/app-route-module-loader.js +83 -0
  331. package/dist/server/app-router-entry.d.ts +13 -0
  332. package/dist/server/app-router-entry.js +49 -0
  333. package/dist/server/app-rsc-cache-busting.d.ts +64 -0
  334. package/dist/server/app-rsc-cache-busting.js +206 -0
  335. package/dist/server/app-rsc-embedded-chunks.d.ts +8 -0
  336. package/dist/server/app-rsc-embedded-chunks.js +32 -0
  337. package/dist/server/app-rsc-error-handler.d.ts +20 -0
  338. package/dist/server/app-rsc-error-handler.js +28 -0
  339. package/dist/server/app-rsc-errors.d.ts +40 -0
  340. package/dist/server/app-rsc-errors.js +60 -0
  341. package/dist/server/app-rsc-handler.d.ts +201 -0
  342. package/dist/server/app-rsc-handler.js +538 -0
  343. package/dist/server/app-rsc-render-mode.d.ts +11 -0
  344. package/dist/server/app-rsc-render-mode.js +25 -0
  345. package/dist/server/app-rsc-request-normalization.d.ts +48 -0
  346. package/dist/server/app-rsc-request-normalization.js +75 -0
  347. package/dist/server/app-rsc-response-finalizer.d.ts +37 -0
  348. package/dist/server/app-rsc-response-finalizer.js +54 -0
  349. package/dist/server/app-rsc-route-matching.d.ts +93 -0
  350. package/dist/server/app-rsc-route-matching.js +134 -0
  351. package/dist/server/app-segment-config.d.ts +46 -0
  352. package/dist/server/app-segment-config.js +113 -0
  353. package/dist/server/app-server-action-execution.d.ts +219 -0
  354. package/dist/server/app-server-action-execution.js +767 -0
  355. package/dist/server/app-ssr-entry.d.ts +52 -0
  356. package/dist/server/app-ssr-entry.js +295 -0
  357. package/dist/server/app-ssr-error-meta.d.ts +13 -0
  358. package/dist/server/app-ssr-error-meta.js +48 -0
  359. package/dist/server/app-ssr-router-instance.d.ts +6 -0
  360. package/dist/server/app-ssr-router-instance.js +24 -0
  361. package/dist/server/app-ssr-stream.d.ts +60 -0
  362. package/dist/server/app-ssr-stream.js +408 -0
  363. package/dist/server/app-static-generation.d.ts +15 -0
  364. package/dist/server/app-static-generation.js +19 -0
  365. package/dist/server/app-visited-response-cache.d.ts +23 -0
  366. package/dist/server/app-visited-response-cache.js +19 -0
  367. package/dist/server/artifact-compatibility.d.ts +54 -0
  368. package/dist/server/artifact-compatibility.js +91 -0
  369. package/dist/server/before-interactive-head.d.ts +17 -0
  370. package/dist/server/before-interactive-head.js +35 -0
  371. package/dist/server/cache-control.d.ts +37 -0
  372. package/dist/server/cache-control.js +56 -0
  373. package/dist/server/cache-headers.d.ts +6 -0
  374. package/dist/server/cache-headers.js +17 -0
  375. package/dist/server/cache-proof.d.ts +364 -0
  376. package/dist/server/cache-proof.js +794 -0
  377. package/dist/server/client-reuse-manifest.d.ts +104 -0
  378. package/dist/server/client-reuse-manifest.js +209 -0
  379. package/dist/server/client-trace-metadata.d.ts +30 -0
  380. package/dist/server/client-trace-metadata.js +81 -0
  381. package/dist/server/cookie-utils.d.ts +12 -0
  382. package/dist/server/cookie-utils.js +18 -0
  383. package/dist/server/csp.d.ts +10 -0
  384. package/dist/server/csp.js +41 -0
  385. package/dist/server/default-global-error-module.d.ts +19 -0
  386. package/dist/server/default-global-error-module.js +18 -0
  387. package/dist/server/default-not-found-module.d.ts +19 -0
  388. package/dist/server/default-not-found-module.js +18 -0
  389. package/dist/server/defer-until-stream-consumed.d.ts +7 -0
  390. package/dist/server/defer-until-stream-consumed.js +34 -0
  391. package/dist/server/dev-error-overlay-store.d.ts +39 -0
  392. package/dist/server/dev-error-overlay-store.js +86 -0
  393. package/dist/server/dev-error-overlay.d.ts +51 -0
  394. package/dist/server/dev-error-overlay.js +1341 -0
  395. package/dist/server/dev-initial-server-error.d.ts +9 -0
  396. package/dist/server/dev-initial-server-error.js +26 -0
  397. package/dist/server/dev-lockfile.d.ts +109 -0
  398. package/dist/server/dev-lockfile.js +179 -0
  399. package/dist/server/dev-module-runner.d.ts +30 -0
  400. package/dist/server/dev-module-runner.js +91 -0
  401. package/dist/server/dev-origin-check.d.ts +62 -0
  402. package/dist/server/dev-origin-check.js +156 -0
  403. package/dist/server/dev-route-files.d.ts +6 -0
  404. package/dist/server/dev-route-files.js +71 -0
  405. package/dist/server/dev-server.d.ts +58 -0
  406. package/dist/server/dev-server.js +1114 -0
  407. package/dist/server/dev-stack-sourcemap-endpoint.d.ts +4 -0
  408. package/dist/server/dev-stack-sourcemap-endpoint.js +4 -0
  409. package/dist/server/dev-stack-sourcemap.d.ts +43 -0
  410. package/dist/server/dev-stack-sourcemap.js +443 -0
  411. package/dist/server/document-initial-head.d.ts +6 -0
  412. package/dist/server/document-initial-head.js +33 -0
  413. package/dist/server/edge-api-runtime.d.ts +4 -0
  414. package/dist/server/edge-api-runtime.js +6 -0
  415. package/dist/server/file-based-metadata.d.ts +29 -0
  416. package/dist/server/file-based-metadata.js +401 -0
  417. package/dist/server/headers.d.ts +114 -0
  418. package/dist/server/headers.js +136 -0
  419. package/dist/server/html.d.ts +28 -0
  420. package/dist/server/html.js +41 -0
  421. package/dist/server/http-error-responses.d.ts +91 -0
  422. package/dist/server/http-error-responses.js +105 -0
  423. package/dist/server/hybrid-route-priority.d.ts +22 -0
  424. package/dist/server/hybrid-route-priority.js +33 -0
  425. package/dist/server/image-optimization.d.ts +130 -0
  426. package/dist/server/image-optimization.js +247 -0
  427. package/dist/server/implicit-tags.d.ts +6 -0
  428. package/dist/server/implicit-tags.js +44 -0
  429. package/dist/server/instrumentation-runtime.d.ts +49 -0
  430. package/dist/server/instrumentation-runtime.js +35 -0
  431. package/dist/server/instrumentation.d.ts +85 -0
  432. package/dist/server/instrumentation.js +130 -0
  433. package/dist/server/isr-cache.d.ts +127 -0
  434. package/dist/server/isr-cache.js +282 -0
  435. package/dist/server/isr-decision.d.ts +79 -0
  436. package/dist/server/isr-decision.js +70 -0
  437. package/dist/server/metadata-route-build-data.d.ts +24 -0
  438. package/dist/server/metadata-route-build-data.js +148 -0
  439. package/dist/server/metadata-route-response.d.ts +16 -0
  440. package/dist/server/metadata-route-response.js +205 -0
  441. package/dist/server/metadata-routes.d.ts +139 -0
  442. package/dist/server/metadata-routes.js +433 -0
  443. package/dist/server/middleware-matcher.d.ts +14 -0
  444. package/dist/server/middleware-matcher.js +111 -0
  445. package/dist/server/middleware-request-headers.d.ts +11 -0
  446. package/dist/server/middleware-request-headers.js +65 -0
  447. package/dist/server/middleware-response-headers.d.ts +12 -0
  448. package/dist/server/middleware-response-headers.js +42 -0
  449. package/dist/server/middleware-runtime.d.ts +67 -0
  450. package/dist/server/middleware-runtime.js +240 -0
  451. package/dist/server/middleware.d.ts +62 -0
  452. package/dist/server/middleware.js +114 -0
  453. package/dist/server/navigation-planner.d.ts +308 -0
  454. package/dist/server/navigation-planner.js +831 -0
  455. package/dist/server/navigation-trace.d.ts +68 -0
  456. package/dist/server/navigation-trace.js +71 -0
  457. package/dist/server/next-error-digest.d.ts +44 -0
  458. package/dist/server/next-error-digest.js +40 -0
  459. package/dist/server/normalize-path.d.ts +38 -0
  460. package/dist/server/normalize-path.js +70 -0
  461. package/dist/server/open-redirect.d.ts +12 -0
  462. package/dist/server/open-redirect.js +21 -0
  463. package/dist/server/operation-token.d.ts +40 -0
  464. package/dist/server/operation-token.js +85 -0
  465. package/dist/server/otel-tracer-extension.d.ts +45 -0
  466. package/dist/server/otel-tracer-extension.js +89 -0
  467. package/dist/server/pages-api-route.d.ts +83 -0
  468. package/dist/server/pages-api-route.js +75 -0
  469. package/dist/server/pages-asset-tags.d.ts +78 -0
  470. package/dist/server/pages-asset-tags.js +126 -0
  471. package/dist/server/pages-body-parser-config.d.ts +59 -0
  472. package/dist/server/pages-body-parser-config.js +77 -0
  473. package/dist/server/pages-data-route.d.ts +121 -0
  474. package/dist/server/pages-data-route.js +157 -0
  475. package/dist/server/pages-default-404.d.ts +30 -0
  476. package/dist/server/pages-default-404.js +38 -0
  477. package/dist/server/pages-dev-module-url.d.ts +4 -0
  478. package/dist/server/pages-dev-module-url.js +15 -0
  479. package/dist/server/pages-document-initial-props.d.ts +77 -0
  480. package/dist/server/pages-document-initial-props.js +109 -0
  481. package/dist/server/pages-get-initial-props.d.ts +67 -0
  482. package/dist/server/pages-get-initial-props.js +92 -0
  483. package/dist/server/pages-i18n.d.ts +106 -0
  484. package/dist/server/pages-i18n.js +183 -0
  485. package/dist/server/pages-media-type.d.ts +15 -0
  486. package/dist/server/pages-media-type.js +24 -0
  487. package/dist/server/pages-node-compat.d.ts +55 -0
  488. package/dist/server/pages-node-compat.js +235 -0
  489. package/dist/server/pages-page-data.d.ts +223 -0
  490. package/dist/server/pages-page-data.js +484 -0
  491. package/dist/server/pages-page-handler.d.ts +100 -0
  492. package/dist/server/pages-page-handler.js +403 -0
  493. package/dist/server/pages-page-method.d.ts +47 -0
  494. package/dist/server/pages-page-method.js +17 -0
  495. package/dist/server/pages-page-response.d.ts +138 -0
  496. package/dist/server/pages-page-response.js +285 -0
  497. package/dist/server/pages-readiness.d.ts +36 -0
  498. package/dist/server/pages-readiness.js +21 -0
  499. package/dist/server/pages-request-pipeline.d.ts +116 -0
  500. package/dist/server/pages-request-pipeline.js +311 -0
  501. package/dist/server/pages-revalidate.d.ts +15 -0
  502. package/dist/server/pages-revalidate.js +19 -0
  503. package/dist/server/pages-serializable-props.d.ts +24 -0
  504. package/dist/server/pages-serializable-props.js +67 -0
  505. package/dist/server/pregenerated-concrete-paths.d.ts +16 -0
  506. package/dist/server/pregenerated-concrete-paths.js +61 -0
  507. package/dist/server/prerender-manifest.d.ts +33 -0
  508. package/dist/server/prerender-manifest.js +54 -0
  509. package/dist/server/prerender-route-params.d.ts +23 -0
  510. package/dist/server/prerender-route-params.js +113 -0
  511. package/dist/server/prerender-work-unit-setup.d.ts +6 -0
  512. package/dist/server/prerender-work-unit-setup.js +28 -0
  513. package/dist/server/prod-server.d.ts +148 -0
  514. package/dist/server/prod-server.js +1136 -0
  515. package/dist/server/proxy-trust.d.ts +40 -0
  516. package/dist/server/proxy-trust.js +68 -0
  517. package/dist/server/request-log.d.ts +39 -0
  518. package/dist/server/request-log.js +56 -0
  519. package/dist/server/request-pipeline.d.ts +187 -0
  520. package/dist/server/request-pipeline.js +447 -0
  521. package/dist/server/rsc-stream-hints.d.ts +10 -0
  522. package/dist/server/rsc-stream-hints.js +41 -0
  523. package/dist/server/seed-cache.d.ts +29 -0
  524. package/dist/server/seed-cache.js +125 -0
  525. package/dist/server/server-action-not-found.d.ts +21 -0
  526. package/dist/server/server-action-not-found.js +62 -0
  527. package/dist/server/server-globals.d.ts +4 -0
  528. package/dist/server/server-globals.js +35 -0
  529. package/dist/server/skip-cache-proof.d.ts +61 -0
  530. package/dist/server/skip-cache-proof.js +168 -0
  531. package/dist/server/socket-error-backstop.d.ts +34 -0
  532. package/dist/server/socket-error-backstop.js +200 -0
  533. package/dist/server/static-file-cache.d.ts +56 -0
  534. package/dist/server/static-file-cache.js +231 -0
  535. package/dist/server/static-layout-client-reuse-proof.d.ts +15 -0
  536. package/dist/server/static-layout-client-reuse-proof.js +33 -0
  537. package/dist/server/streaming-metadata.d.ts +4 -0
  538. package/dist/server/streaming-metadata.js +8 -0
  539. package/dist/server/worker-utils.d.ts +7 -0
  540. package/dist/server/worker-utils.js +99 -0
  541. package/dist/shims/amp.d.ts +19 -0
  542. package/dist/shims/amp.js +23 -0
  543. package/dist/shims/app-router-scroll-state.d.ts +15 -0
  544. package/dist/shims/app-router-scroll-state.js +61 -0
  545. package/dist/shims/app-router-scroll.d.ts +29 -0
  546. package/dist/shims/app-router-scroll.js +141 -0
  547. package/dist/shims/app.d.ts +42 -0
  548. package/dist/shims/app.js +48 -0
  549. package/dist/shims/before-interactive-context.d.ts +40 -0
  550. package/dist/shims/before-interactive-context.js +8 -0
  551. package/dist/shims/cache-for-request.d.ts +57 -0
  552. package/dist/shims/cache-for-request.js +72 -0
  553. package/dist/shims/cache-handler.d.ts +106 -0
  554. package/dist/shims/cache-handler.js +176 -0
  555. package/dist/shims/cache-request-state.d.ts +47 -0
  556. package/dist/shims/cache-request-state.js +126 -0
  557. package/dist/shims/cache-runtime.d.ts +83 -0
  558. package/dist/shims/cache-runtime.js +452 -0
  559. package/dist/shims/cache.d.ts +145 -0
  560. package/dist/shims/cache.js +401 -0
  561. package/dist/shims/cdn-cache.d.ts +125 -0
  562. package/dist/shims/cdn-cache.js +100 -0
  563. package/dist/shims/client-hook-error.d.ts +13 -0
  564. package/dist/shims/client-hook-error.js +17 -0
  565. package/dist/shims/client-locale.d.ts +14 -0
  566. package/dist/shims/client-locale.js +11 -0
  567. package/dist/shims/client-only.d.ts +1 -0
  568. package/dist/shims/client-only.js +1 -0
  569. package/dist/shims/compat-router.d.ts +16 -0
  570. package/dist/shims/compat-router.js +25 -0
  571. package/dist/shims/config.d.ts +28 -0
  572. package/dist/shims/config.js +21 -0
  573. package/dist/shims/constants.d.ts +130 -0
  574. package/dist/shims/constants.js +167 -0
  575. package/dist/shims/default-global-error.d.ts +31 -0
  576. package/dist/shims/default-global-error.js +179 -0
  577. package/dist/shims/default-not-found.d.ts +11 -0
  578. package/dist/shims/default-not-found.js +59 -0
  579. package/dist/shims/document.d.ts +92 -0
  580. package/dist/shims/document.js +76 -0
  581. package/dist/shims/dynamic-preload-chunks.d.ts +8 -0
  582. package/dist/shims/dynamic-preload-chunks.js +79 -0
  583. package/dist/shims/dynamic.d.ts +35 -0
  584. package/dist/shims/dynamic.js +204 -0
  585. package/dist/shims/error-boundary-navigation.d.ts +7 -0
  586. package/dist/shims/error-boundary-navigation.js +44 -0
  587. package/dist/shims/error-boundary.d.ts +155 -0
  588. package/dist/shims/error-boundary.js +342 -0
  589. package/dist/shims/error.d.ts +31 -0
  590. package/dist/shims/error.js +123 -0
  591. package/dist/shims/error.react-server.d.ts +9 -0
  592. package/dist/shims/error.react-server.js +6 -0
  593. package/dist/shims/fetch-cache.d.ts +136 -0
  594. package/dist/shims/fetch-cache.js +766 -0
  595. package/dist/shims/font-google-base.d.ts +83 -0
  596. package/dist/shims/font-google-base.js +290 -0
  597. package/dist/shims/font-google.d.ts +2 -0
  598. package/dist/shims/font-google.js +2 -0
  599. package/dist/shims/font-local.d.ts +50 -0
  600. package/dist/shims/font-local.js +195 -0
  601. package/dist/shims/font-utils.d.ts +56 -0
  602. package/dist/shims/font-utils.js +107 -0
  603. package/dist/shims/form.d.ts +19 -0
  604. package/dist/shims/form.js +236 -0
  605. package/dist/shims/hash-scroll.d.ts +10 -0
  606. package/dist/shims/hash-scroll.js +47 -0
  607. package/dist/shims/head-state.d.ts +16 -0
  608. package/dist/shims/head-state.js +43 -0
  609. package/dist/shims/head.d.ts +73 -0
  610. package/dist/shims/head.js +340 -0
  611. package/dist/shims/headers.d.ts +253 -0
  612. package/dist/shims/headers.js +754 -0
  613. package/dist/shims/i18n-context.d.ts +22 -0
  614. package/dist/shims/i18n-context.js +42 -0
  615. package/dist/shims/i18n-state.d.ts +14 -0
  616. package/dist/shims/i18n-state.js +38 -0
  617. package/dist/shims/image-config.d.ts +45 -0
  618. package/dist/shims/image-config.js +85 -0
  619. package/dist/shims/image.d.ts +55 -0
  620. package/dist/shims/image.js +582 -0
  621. package/dist/shims/internal/als-registry.d.ts +14 -0
  622. package/dist/shims/internal/als-registry.js +80 -0
  623. package/dist/shims/internal/api-utils.d.ts +14 -0
  624. package/dist/shims/internal/api-utils.js +1 -0
  625. package/dist/shims/internal/app-page-props-cache-key.d.ts +5 -0
  626. package/dist/shims/internal/app-page-props-cache-key.js +16 -0
  627. package/dist/shims/internal/app-route-detection.d.ts +39 -0
  628. package/dist/shims/internal/app-route-detection.js +62 -0
  629. package/dist/shims/internal/app-router-context.d.ts +31 -0
  630. package/dist/shims/internal/app-router-context.js +28 -0
  631. package/dist/shims/internal/cookie-serialize.d.ts +45 -0
  632. package/dist/shims/internal/cookie-serialize.js +49 -0
  633. package/dist/shims/internal/cookies.d.ts +2 -0
  634. package/dist/shims/internal/cookies.js +2 -0
  635. package/dist/shims/internal/hybrid-client-route-owner.d.ts +31 -0
  636. package/dist/shims/internal/hybrid-client-route-owner.js +143 -0
  637. package/dist/shims/internal/interpolate-as.d.ts +25 -0
  638. package/dist/shims/internal/interpolate-as.js +196 -0
  639. package/dist/shims/internal/link-status-registry.d.ts +43 -0
  640. package/dist/shims/internal/link-status-registry.js +42 -0
  641. package/dist/shims/internal/make-hanging-promise.d.ts +15 -0
  642. package/dist/shims/internal/make-hanging-promise.js +44 -0
  643. package/dist/shims/internal/navigation-untracked.d.ts +35 -0
  644. package/dist/shims/internal/navigation-untracked.js +56 -0
  645. package/dist/shims/internal/pages-data-fetch-dedup.d.ts +54 -0
  646. package/dist/shims/internal/pages-data-fetch-dedup.js +121 -0
  647. package/dist/shims/internal/pages-data-target.d.ts +62 -0
  648. package/dist/shims/internal/pages-data-target.js +98 -0
  649. package/dist/shims/internal/pages-data-url.d.ts +41 -0
  650. package/dist/shims/internal/pages-data-url.js +71 -0
  651. package/dist/shims/internal/pages-router-accessor.d.ts +19 -0
  652. package/dist/shims/internal/pages-router-accessor.js +13 -0
  653. package/dist/shims/internal/route-pattern-for-warning.d.ts +27 -0
  654. package/dist/shims/internal/route-pattern-for-warning.js +40 -0
  655. package/dist/shims/internal/router-context.d.ts +7 -0
  656. package/dist/shims/internal/router-context.js +13 -0
  657. package/dist/shims/internal/utils.d.ts +52 -0
  658. package/dist/shims/internal/utils.js +27 -0
  659. package/dist/shims/internal/work-unit-async-storage.d.ts +30 -0
  660. package/dist/shims/internal/work-unit-async-storage.js +17 -0
  661. package/dist/shims/layout-segment-context.d.ts +24 -0
  662. package/dist/shims/layout-segment-context.js +39 -0
  663. package/dist/shims/legacy-image.d.ts +41 -0
  664. package/dist/shims/legacy-image.js +49 -0
  665. package/dist/shims/link-prefetch.d.ts +41 -0
  666. package/dist/shims/link-prefetch.js +43 -0
  667. package/dist/shims/link.d.ts +102 -0
  668. package/dist/shims/link.js +687 -0
  669. package/dist/shims/metadata.d.ts +285 -0
  670. package/dist/shims/metadata.js +820 -0
  671. package/dist/shims/navigation-context-state.d.ts +40 -0
  672. package/dist/shims/navigation-context-state.js +116 -0
  673. package/dist/shims/navigation-errors.d.ts +55 -0
  674. package/dist/shims/navigation-errors.js +110 -0
  675. package/dist/shims/navigation-server.d.ts +3 -0
  676. package/dist/shims/navigation-server.js +3 -0
  677. package/dist/shims/navigation-state.d.ts +25 -0
  678. package/dist/shims/navigation-state.js +66 -0
  679. package/dist/shims/navigation.d.ts +286 -0
  680. package/dist/shims/navigation.js +1206 -0
  681. package/dist/shims/navigation.react-server.d.ts +14 -0
  682. package/dist/shims/navigation.react-server.js +32 -0
  683. package/dist/shims/offline.d.ts +4 -0
  684. package/dist/shims/offline.js +15 -0
  685. package/dist/shims/og.d.ts +17 -0
  686. package/dist/shims/og.js +48 -0
  687. package/dist/shims/pages-router-runtime.d.ts +12 -0
  688. package/dist/shims/pages-router-runtime.js +24 -0
  689. package/dist/shims/ppr-fallback-shell.d.ts +33 -0
  690. package/dist/shims/ppr-fallback-shell.js +170 -0
  691. package/dist/shims/readonly-url-search-params.d.ts +13 -0
  692. package/dist/shims/readonly-url-search-params.js +26 -0
  693. package/dist/shims/request-context.d.ts +58 -0
  694. package/dist/shims/request-context.js +45 -0
  695. package/dist/shims/request-state-types.d.ts +12 -0
  696. package/dist/shims/request-state-types.js +1 -0
  697. package/dist/shims/root-params.d.ts +12 -0
  698. package/dist/shims/root-params.js +30 -0
  699. package/dist/shims/router-state.d.ts +32 -0
  700. package/dist/shims/router-state.js +39 -0
  701. package/dist/shims/router.d.ts +192 -0
  702. package/dist/shims/router.js +1786 -0
  703. package/dist/shims/script-nonce-context.d.ts +11 -0
  704. package/dist/shims/script-nonce-context.js +23 -0
  705. package/dist/shims/script.d.ts +43 -0
  706. package/dist/shims/script.js +370 -0
  707. package/dist/shims/server-only.d.ts +1 -0
  708. package/dist/shims/server-only.js +1 -0
  709. package/dist/shims/server.d.ts +323 -0
  710. package/dist/shims/server.js +729 -0
  711. package/dist/shims/slot.d.ts +45 -0
  712. package/dist/shims/slot.js +230 -0
  713. package/dist/shims/thenable-params.d.ts +11 -0
  714. package/dist/shims/thenable-params.js +176 -0
  715. package/dist/shims/unified-request-context.d.ts +68 -0
  716. package/dist/shims/unified-request-context.js +86 -0
  717. package/dist/shims/unrecognized-action-error.d.ts +34 -0
  718. package/dist/shims/unrecognized-action-error.js +39 -0
  719. package/dist/shims/url-safety.d.ts +34 -0
  720. package/dist/shims/url-safety.js +70 -0
  721. package/dist/shims/url-utils.d.ts +51 -0
  722. package/dist/shims/url-utils.js +156 -0
  723. package/dist/shims/use-merged-ref.d.ts +6 -0
  724. package/dist/shims/use-merged-ref.js +38 -0
  725. package/dist/shims/web-vitals.d.ts +8 -0
  726. package/dist/shims/web-vitals.js +22 -0
  727. package/dist/typegen.d.ts +9 -0
  728. package/dist/typegen.js +228 -0
  729. package/dist/utils/asset-prefix.d.ts +96 -0
  730. package/dist/utils/asset-prefix.js +122 -0
  731. package/dist/utils/base-path.d.ts +31 -0
  732. package/dist/utils/base-path.js +45 -0
  733. package/dist/utils/built-asset-url.d.ts +4 -0
  734. package/dist/utils/built-asset-url.js +11 -0
  735. package/dist/utils/cache-control-metadata.d.ts +4 -0
  736. package/dist/utils/cache-control-metadata.js +12 -0
  737. package/dist/utils/client-build-manifest.d.ts +21 -0
  738. package/dist/utils/client-build-manifest.js +87 -0
  739. package/dist/utils/client-entry-manifest.d.ts +11 -0
  740. package/dist/utils/client-entry-manifest.js +29 -0
  741. package/dist/utils/client-runtime-metadata.d.ts +45 -0
  742. package/dist/utils/client-runtime-metadata.js +63 -0
  743. package/dist/utils/commonjs-loader.d.ts +16 -0
  744. package/dist/utils/commonjs-loader.js +100 -0
  745. package/dist/utils/compare.d.ts +4 -0
  746. package/dist/utils/compare.js +8 -0
  747. package/dist/utils/deployment-id.d.ts +8 -0
  748. package/dist/utils/deployment-id.js +22 -0
  749. package/dist/utils/dev-error-recovery-event.d.ts +4 -0
  750. package/dist/utils/dev-error-recovery-event.js +4 -0
  751. package/dist/utils/domain-locale.d.ts +26 -0
  752. package/dist/utils/domain-locale.js +50 -0
  753. package/dist/utils/encode-cache-tag.d.ts +30 -0
  754. package/dist/utils/encode-cache-tag.js +36 -0
  755. package/dist/utils/error-cause.d.ts +4 -0
  756. package/dist/utils/error-cause.js +95 -0
  757. package/dist/utils/has-trailing-comma.d.ts +24 -0
  758. package/dist/utils/has-trailing-comma.js +62 -0
  759. package/dist/utils/hash.d.ts +24 -0
  760. package/dist/utils/hash.js +55 -0
  761. package/dist/utils/html-limited-bots.d.ts +21 -0
  762. package/dist/utils/html-limited-bots.js +35 -0
  763. package/dist/utils/lazy-chunks.d.ts +59 -0
  764. package/dist/utils/lazy-chunks.js +112 -0
  765. package/dist/utils/manifest-paths.d.ts +30 -0
  766. package/dist/utils/manifest-paths.js +66 -0
  767. package/dist/utils/mdx-scan.d.ts +9 -0
  768. package/dist/utils/mdx-scan.js +34 -0
  769. package/dist/utils/navigation-signal.d.ts +4 -0
  770. package/dist/utils/navigation-signal.js +12 -0
  771. package/dist/utils/number.d.ts +4 -0
  772. package/dist/utils/number.js +6 -0
  773. package/dist/utils/parse-cookie.d.ts +13 -0
  774. package/dist/utils/parse-cookie.js +52 -0
  775. package/dist/utils/path.d.ts +22 -0
  776. package/dist/utils/path.js +30 -0
  777. package/dist/utils/prerender-output-paths.d.ts +14 -0
  778. package/dist/utils/prerender-output-paths.js +22 -0
  779. package/dist/utils/project.d.ts +76 -0
  780. package/dist/utils/project.js +213 -0
  781. package/dist/utils/promise.d.ts +4 -0
  782. package/dist/utils/promise.js +6 -0
  783. package/dist/utils/public-routes.d.ts +4 -0
  784. package/dist/utils/public-routes.js +48 -0
  785. package/dist/utils/query.d.ts +49 -0
  786. package/dist/utils/query.js +122 -0
  787. package/dist/utils/record.d.ts +4 -0
  788. package/dist/utils/record.js +6 -0
  789. package/dist/utils/regex.d.ts +4 -0
  790. package/dist/utils/regex.js +6 -0
  791. package/dist/utils/safe-json-file.d.ts +17 -0
  792. package/dist/utils/safe-json-file.js +23 -0
  793. package/dist/utils/sorted-array.d.ts +8 -0
  794. package/dist/utils/sorted-array.js +20 -0
  795. package/dist/utils/text-stream.d.ts +28 -0
  796. package/dist/utils/text-stream.js +64 -0
  797. package/dist/utils/vinext-root.d.ts +23 -0
  798. package/dist/utils/vinext-root.js +29 -0
  799. package/dist/utils/virtual-module.d.ts +5 -0
  800. package/dist/utils/virtual-module.js +0 -0
  801. package/dist/utils/vite-version.d.ts +21 -0
  802. package/dist/utils/vite-version.js +42 -0
  803. package/package.json +145 -0
package/dist/deploy.js ADDED
@@ -0,0 +1,1033 @@
1
+ import { detectPackageManager as detectPackageManager$1, ensureESModule as ensureESModule$1, findDir, findInNodeModules, hasAppDir, renameCJSConfigs as renameCJSConfigs$1 } from "./utils/project.js";
2
+ import { parsePositiveIntegerArg } from "./cli-args.js";
3
+ import { escapeRegExp } from "./utils/regex.js";
4
+ import { loadNextConfig, resolveNextConfig } from "./config/next-config.js";
5
+ import { getReactUpgradeDeps } from "./init.js";
6
+ import { runTPR } from "./cloudflare/tpr.js";
7
+ import { buildPregeneratedConcretePathTable, readPrerenderManifest } from "./server/prerender-manifest.js";
8
+ import { runPrerender } from "./build/run-prerender.js";
9
+ import { loadDotenv } from "./config/dotenv.js";
10
+ import { createRequire } from "node:module";
11
+ import fs from "node:fs";
12
+ import path from "node:path";
13
+ import { pathToFileURL } from "node:url";
14
+ import { parseArgs } from "node:util";
15
+ import { execFileSync } from "node:child_process";
16
+ //#region src/deploy.ts
17
+ /**
18
+ * vinext deploy — one-command Cloudflare Workers deployment.
19
+ *
20
+ * Takes any Next.js app and deploys it to Cloudflare Workers:
21
+ *
22
+ * 1. Detects App Router vs Pages Router
23
+ * 2. Auto-generates missing config files (wrangler.jsonc, worker/index.ts, vite.config.ts)
24
+ * 3. Ensures dependencies are installed (@cloudflare/vite-plugin, wrangler, @vitejs/plugin-react, App Router deps)
25
+ * 4. Runs the Vite build
26
+ * 5. Deploys to Cloudflare Workers via wrangler
27
+ *
28
+ * Design: Everything is auto-generated into a `.vinext/` directory (not the
29
+ * project root) to avoid cluttering the user's project. If the user already
30
+ * has these files, we use theirs.
31
+ */
32
+ /** Deploy command flag definitions for util.parseArgs. */
33
+ const deployArgOptions = {
34
+ help: {
35
+ type: "boolean",
36
+ short: "h",
37
+ default: false
38
+ },
39
+ preview: {
40
+ type: "boolean",
41
+ default: false
42
+ },
43
+ env: { type: "string" },
44
+ name: { type: "string" },
45
+ "skip-build": {
46
+ type: "boolean",
47
+ default: false
48
+ },
49
+ "dry-run": {
50
+ type: "boolean",
51
+ default: false
52
+ },
53
+ "prerender-all": {
54
+ type: "boolean",
55
+ default: false
56
+ },
57
+ "prerender-concurrency": { type: "string" },
58
+ "experimental-tpr": {
59
+ type: "boolean",
60
+ default: false
61
+ },
62
+ "tpr-coverage": { type: "string" },
63
+ "tpr-limit": { type: "string" },
64
+ "tpr-window": { type: "string" }
65
+ };
66
+ function parseDeployArgs(args) {
67
+ const { values } = parseArgs({
68
+ args,
69
+ options: deployArgOptions,
70
+ strict: true
71
+ });
72
+ function parseIntArg(name, raw) {
73
+ if (!raw) return void 0;
74
+ const n = parseInt(raw, 10);
75
+ if (isNaN(n)) {
76
+ console.error(` --${name} must be a number (got: ${raw})`);
77
+ process.exit(1);
78
+ }
79
+ return n;
80
+ }
81
+ return {
82
+ help: values.help,
83
+ preview: values.preview,
84
+ env: values.env?.trim() || void 0,
85
+ name: values.name?.trim() || void 0,
86
+ skipBuild: values["skip-build"],
87
+ dryRun: values["dry-run"],
88
+ prerenderAll: values["prerender-all"],
89
+ prerenderConcurrency: values["prerender-concurrency"] === void 0 ? void 0 : parsePositiveIntegerArg(values["prerender-concurrency"], "--prerender-concurrency"),
90
+ experimentalTPR: values["experimental-tpr"],
91
+ tprCoverage: parseIntArg("tpr-coverage", values["tpr-coverage"]),
92
+ tprLimit: parseIntArg("tpr-limit", values["tpr-limit"]),
93
+ tprWindow: parseIntArg("tpr-window", values["tpr-window"])
94
+ };
95
+ }
96
+ /** Check whether a wrangler config file exists in the given directory. */
97
+ function hasWranglerConfig(root) {
98
+ return fs.existsSync(path.join(root, "wrangler.jsonc")) || fs.existsSync(path.join(root, "wrangler.json")) || fs.existsSync(path.join(root, "wrangler.toml"));
99
+ }
100
+ /**
101
+ * Build the error message thrown when cloudflare() is missing from the Vite config.
102
+ * Shared between the build-time guard (index.ts configResolved) and the
103
+ * deploy-time guard (deploy.ts deploy()).
104
+ */
105
+ function formatMissingCloudflarePluginError(options) {
106
+ const cfArg = options.isAppRouter ? "{\n viteEnvironment: { name: \"rsc\", childEnvironments: [\"ssr\"] },\n }" : "";
107
+ const configRef = options.configFile ? options.configFile : "your Vite config";
108
+ return `[vinext] Missing @cloudflare/vite-plugin in ${configRef}.\n\n Cloudflare Workers builds require the cloudflare() plugin.\n Add it to ${configRef}:\n\n import { cloudflare } from "@cloudflare/vite-plugin";\n\n export default defineConfig({\n plugins: [\n vinext(),\n cloudflare(${cfArg}),\n ],\n });\n\n Or delete ${configRef} and re-run \`vinext deploy\` to auto-generate it.`;
109
+ }
110
+ function detectProject(root) {
111
+ const hasApp = hasAppDir(root);
112
+ const hasPages = findDir(root, "pages", path.join("src", "pages")) !== null;
113
+ const isAppRouter = hasApp;
114
+ const isPagesRouter = !hasApp && hasPages;
115
+ const hasViteConfig = fs.existsSync(path.join(root, "vite.config.ts")) || fs.existsSync(path.join(root, "vite.config.js")) || fs.existsSync(path.join(root, "vite.config.mjs"));
116
+ const wranglerConfigExists = hasWranglerConfig(root);
117
+ const hasWorkerEntry = fs.existsSync(path.join(root, "worker", "index.ts")) || fs.existsSync(path.join(root, "worker", "index.js"));
118
+ const hasCloudflarePlugin = findInNodeModules(root, "@cloudflare/vite-plugin") !== null;
119
+ const hasRscPlugin = findInNodeModules(root, "@vitejs/plugin-rsc") !== null;
120
+ const hasWrangler = findInNodeModules(root, ".bin/wrangler") !== null;
121
+ const pkgPath = path.join(root, "package.json");
122
+ let pkg = null;
123
+ if (fs.existsSync(pkgPath)) try {
124
+ pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
125
+ } catch {}
126
+ let projectName = path.basename(root);
127
+ if (pkg?.name && typeof pkg.name === "string") projectName = pkg.name.replace(/^@[^/]+\//, "").toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
128
+ const hasTypeModule = pkg?.type === "module";
129
+ let hasISR = false;
130
+ let hasMDX = detectMDXFromConfig(root);
131
+ if (isAppRouter) {
132
+ const appDir = resolveProjectDir(root, "app");
133
+ if (appDir) {
134
+ const found = scanTreeForDetection(appDir, {
135
+ isr: true,
136
+ mdx: !hasMDX
137
+ });
138
+ hasISR = found.isr;
139
+ hasMDX = hasMDX || found.mdx;
140
+ }
141
+ }
142
+ if (hasPages && !hasMDX) {
143
+ const pagesDir = resolveProjectDir(root, "pages");
144
+ if (pagesDir) hasMDX = scanTreeForDetection(pagesDir, {
145
+ isr: false,
146
+ mdx: true
147
+ }).mdx;
148
+ }
149
+ const allDeps = {
150
+ ...pkg?.dependencies,
151
+ ...pkg?.devDependencies
152
+ };
153
+ const hasCodeHike = "codehike" in allDeps;
154
+ const nativeModulesToStub = detectNativeModules(allDeps);
155
+ return {
156
+ root,
157
+ isAppRouter,
158
+ isPagesRouter,
159
+ hasViteConfig,
160
+ hasWranglerConfig: wranglerConfigExists,
161
+ hasWorkerEntry,
162
+ hasCloudflarePlugin,
163
+ hasRscPlugin,
164
+ hasWrangler,
165
+ projectName,
166
+ hasISR,
167
+ hasTypeModule,
168
+ hasMDX,
169
+ hasCodeHike,
170
+ nativeModulesToStub
171
+ };
172
+ }
173
+ /** Matches `export const revalidate = …` (ISR opt-in) in App Router source. */
174
+ const ISR_REVALIDATE_PATTERN = /export\s+const\s+revalidate\s*=/;
175
+ /** Source extensions whose contents are scanned for the ISR pattern. */
176
+ const ISR_SCANNABLE_EXTENSION = /\.(ts|tsx|js|jsx)$/;
177
+ /**
178
+ * Resolve a project subdirectory (`app`/`pages`), preferring the root-level
179
+ * location and falling back to the `src/` variant. Returns null when neither
180
+ * exists.
181
+ */
182
+ function resolveProjectDir(root, name) {
183
+ const rootDir = path.join(root, name);
184
+ if (fs.existsSync(rootDir)) return rootDir;
185
+ const srcDir = path.join(root, "src", name);
186
+ if (fs.existsSync(srcDir)) return srcDir;
187
+ return null;
188
+ }
189
+ /**
190
+ * Recursively walk `dir` once, evaluating the requested detection predicates
191
+ * per entry. Each flag short-circuits independently: an `.mdx` file sets `mdx`;
192
+ * a scannable source file containing `export const revalidate` sets `isr`. The
193
+ * walk stops as soon as every requested flag is satisfied, so callers that only
194
+ * want one signal don't pay for the other.
195
+ *
196
+ * Replaces the previous pair of single-purpose recursive walkers
197
+ * (`scanDirForPattern` + `scanDirForExtension`) that traversed the same tree
198
+ * twice. Detection semantics are unchanged: same dirs skipped (dotfiles,
199
+ * node_modules), same extension and content tests.
200
+ */
201
+ function scanTreeForDetection(dir, want) {
202
+ const found = {
203
+ isr: false,
204
+ mdx: false
205
+ };
206
+ const walk = (current) => {
207
+ let entries;
208
+ try {
209
+ entries = fs.readdirSync(current, { withFileTypes: true });
210
+ } catch {
211
+ return;
212
+ }
213
+ for (const entry of entries) {
214
+ if ((!want.isr || found.isr) && (!want.mdx || found.mdx)) return;
215
+ const fullPath = path.join(current, entry.name);
216
+ if (entry.isDirectory()) {
217
+ if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
218
+ walk(fullPath);
219
+ } else if (entry.isFile()) {
220
+ if (want.mdx && !found.mdx && entry.name.endsWith(".mdx")) found.mdx = true;
221
+ if (want.isr && !found.isr && ISR_SCANNABLE_EXTENSION.test(entry.name)) try {
222
+ if (ISR_REVALIDATE_PATTERN.test(fs.readFileSync(fullPath, "utf-8"))) found.isr = true;
223
+ } catch {}
224
+ }
225
+ }
226
+ };
227
+ walk(dir);
228
+ return found;
229
+ }
230
+ /**
231
+ * Detect MDX usage declared in next.config (`pageExtensions` including "mdx" or
232
+ * an `@next/mdx` import). Filesystem `.mdx` detection is handled separately by
233
+ * the shared app/pages tree walk in `detectProject`.
234
+ */
235
+ function detectMDXFromConfig(root) {
236
+ for (const f of [
237
+ "next.config.ts",
238
+ "next.config.mts",
239
+ "next.config.mjs",
240
+ "next.config.js",
241
+ "next.config.cjs"
242
+ ]) {
243
+ const p = path.join(root, f);
244
+ if (fs.existsSync(p)) try {
245
+ const content = fs.readFileSync(p, "utf-8");
246
+ if (/pageExtensions.*mdx/i.test(content) || /@next\/mdx/.test(content)) return true;
247
+ } catch {}
248
+ }
249
+ return false;
250
+ }
251
+ /** Known native Node modules that can't run in Workers */
252
+ const NATIVE_MODULES_TO_STUB = [
253
+ "@resvg/resvg-js",
254
+ "satori",
255
+ "lightningcss",
256
+ "@napi-rs/canvas",
257
+ "sharp"
258
+ ];
259
+ /**
260
+ * Detect native Node modules in the project's merged dependency map that need
261
+ * stubbing for Workers. Accepts the already-built `allDeps` (dependencies +
262
+ * devDependencies) so package.json is not re-read or re-parsed.
263
+ */
264
+ function detectNativeModules(allDeps) {
265
+ return NATIVE_MODULES_TO_STUB.filter((mod) => mod in allDeps);
266
+ }
267
+ /** @see {@link _ensureESModule} */
268
+ const ensureESModule = ensureESModule$1;
269
+ /** @see {@link _renameCJSConfigs} */
270
+ const renameCJSConfigs = renameCJSConfigs$1;
271
+ /** Generate wrangler.jsonc content */
272
+ function generateWranglerConfig(info) {
273
+ const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
274
+ const config = {
275
+ $schema: "node_modules/wrangler/config-schema.json",
276
+ name: info.projectName,
277
+ compatibility_date: today,
278
+ compatibility_flags: ["nodejs_compat"],
279
+ main: "./worker/index.ts",
280
+ assets: {
281
+ directory: "dist/client",
282
+ not_found_handling: "none",
283
+ binding: "ASSETS"
284
+ },
285
+ images: { binding: "IMAGES" }
286
+ };
287
+ if (info.hasISR) config.kv_namespaces = [{
288
+ binding: "VINEXT_KV_CACHE",
289
+ id: "<your-kv-namespace-id>"
290
+ }];
291
+ return JSON.stringify(config, null, 2) + "\n";
292
+ }
293
+ /** Generate worker/index.ts for App Router */
294
+ function generateAppRouterWorkerEntry() {
295
+ return `/**
296
+ * Cloudflare Worker entry point — auto-generated by vinext deploy.
297
+ * Edit freely or delete to regenerate on next deploy.
298
+ *
299
+ * Cache backends (data + page ISR) are configured declaratively in
300
+ * vite.config via the vinext({ cache }) option.
301
+ *
302
+ * For apps without image optimization, you can use vinext/server/app-router-entry
303
+ * directly in wrangler.jsonc: "main": "vinext/server/app-router-entry"
304
+ */
305
+ import { handleImageOptimization, DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, isImageOptimizationPath } from "vinext/server/image-optimization";
306
+ import type { ImageConfig } from "vinext/server/image-optimization";
307
+ import handler from "vinext/server/app-router-entry";
308
+
309
+ const imageConfig: ImageConfig = {
310
+ deviceSizes: JSON.parse(
311
+ process.env.__VINEXT_IMAGE_DEVICE_SIZES ?? JSON.stringify(DEFAULT_DEVICE_SIZES),
312
+ ),
313
+ imageSizes: JSON.parse(
314
+ process.env.__VINEXT_IMAGE_SIZES ?? JSON.stringify(DEFAULT_IMAGE_SIZES),
315
+ ),
316
+ qualities: JSON.parse(process.env.__VINEXT_IMAGE_QUALITIES ?? "null") ?? undefined,
317
+ dangerouslyAllowSVG: process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_SVG === "true",
318
+ };
319
+
320
+ interface Env {
321
+ ASSETS: Fetcher;
322
+ IMAGES: {
323
+ input(stream: ReadableStream): {
324
+ transform(options: Record<string, unknown>): {
325
+ output(options: { format: string; quality: number }): Promise<{ response(): Response }>;
326
+ };
327
+ };
328
+ };
329
+ }
330
+
331
+ interface ExecutionContext {
332
+ waitUntil(promise: Promise<unknown>): void;
333
+ passThroughOnException(): void;
334
+ }
335
+
336
+ // Image security config. SVG sources with .svg extension auto-skip the
337
+ // optimization endpoint on the client side (served directly, no proxy).
338
+ // To route SVGs through the optimizer (with security headers), set
339
+ // dangerouslyAllowSVG: true in next.config.js and uncomment below:
340
+ // const imageConfig: ImageConfig = { dangerouslyAllowSVG: true };
341
+
342
+ export default {
343
+ async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
344
+ const url = new URL(request.url);
345
+
346
+ // Image optimization via Cloudflare Images binding.
347
+ // The parseImageParams validation inside handleImageOptimization
348
+ // normalizes backslashes and validates the origin hasn't changed.
349
+ if (isImageOptimizationPath(url.pathname)) {
350
+ const allowedWidths = [
351
+ ...(imageConfig.deviceSizes ?? DEFAULT_DEVICE_SIZES),
352
+ ...(imageConfig.imageSizes ?? DEFAULT_IMAGE_SIZES),
353
+ ];
354
+ return handleImageOptimization(request, {
355
+ fetchAsset: (path) => env.ASSETS.fetch(new Request(new URL(path, request.url))),
356
+ transformImage: async (body, { width, format, quality }) => {
357
+ const result = await env.IMAGES.input(body).transform(width > 0 ? { width } : {}).output({ format, quality });
358
+ return result.response();
359
+ },
360
+ }, allowedWidths, imageConfig);
361
+ }
362
+
363
+ // Delegate everything else to vinext, forwarding ctx so that
364
+ // ctx.waitUntil() is available to background cache writes and
365
+ // other deferred work via getRequestExecutionContext().
366
+ return handler.fetch(request, env, ctx);
367
+ },
368
+ };
369
+ `;
370
+ }
371
+ /** Generate worker/index.ts for Pages Router */
372
+ function generatePagesRouterWorkerEntry() {
373
+ return `/**
374
+ * Cloudflare Worker entry point -- auto-generated by vinext deploy.
375
+ * Edit freely or delete to regenerate on next deploy.
376
+ */
377
+ import { fetchWorkerFilesystemRoute, runPagesRequest, wrapMiddlewareWithBasePath } from "vinext/server/pages-request-pipeline";
378
+ import type { PagesPipelineDeps } from "vinext/server/pages-request-pipeline";
379
+ import { handleImageOptimization, DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, isImageOptimizationPath } from "vinext/server/image-optimization";
380
+ import type { ImageConfig } from "vinext/server/image-optimization";
381
+ import { cloneRequestWithHeaders, cloneRequestWithUrl, filterInternalHeaders, isOpenRedirectShaped } from "vinext/server/request-pipeline";
382
+ import { notFoundStaticAssetResponse } from "vinext/server/http-error-responses";
383
+ import { assetPrefixPathname, isNextStaticPath } from "vinext/utils/asset-prefix";
384
+ import { hasBasePath, stripBasePath } from "vinext/utils/base-path";
385
+
386
+ // @ts-expect-error -- virtual module resolved by vinext at build time
387
+ import { renderPage, handleApiRoute, runMiddleware, normalizeDataRequest, vinextConfig, matchPageRoute } from "virtual:vinext-server-entry";
388
+ // @ts-expect-error -- virtual module resolved by vinext at build time
389
+ import { registerConfiguredCacheAdapters } from "virtual:vinext-cache-adapters";
390
+
391
+ interface Env {
392
+ ASSETS: Fetcher;
393
+ IMAGES: {
394
+ input(stream: ReadableStream): {
395
+ transform(options: Record<string, unknown>): {
396
+ output(options: { format: string; quality: number }): Promise<{ response(): Response }>;
397
+ };
398
+ };
399
+ };
400
+ }
401
+
402
+ interface ExecutionContext {
403
+ waitUntil(promise: Promise<unknown>): void;
404
+ passThroughOnException(): void;
405
+ }
406
+
407
+ // Extract config values (embedded at build time in the server entry)
408
+ const basePath: string = vinextConfig?.basePath ?? "";
409
+ const assetPathPrefix: string = assetPrefixPathname(vinextConfig?.assetPrefix ?? "");
410
+ const trailingSlash: boolean = vinextConfig?.trailingSlash ?? false;
411
+ const i18nConfig = vinextConfig?.i18n ?? null;
412
+ const configRedirects = vinextConfig?.redirects ?? [];
413
+ const configRewrites = vinextConfig?.rewrites ?? { beforeFiles: [], afterFiles: [], fallback: [] };
414
+ const configHeaders = vinextConfig?.headers ?? [];
415
+ const imageConfig: ImageConfig | undefined = vinextConfig?.images ? {
416
+ qualities: vinextConfig.images.qualities,
417
+ dangerouslyAllowSVG: vinextConfig.images.dangerouslyAllowSVG,
418
+ dangerouslyAllowLocalIP: vinextConfig.images.dangerouslyAllowLocalIP,
419
+ contentDispositionType: vinextConfig.images.contentDispositionType,
420
+ contentSecurityPolicy: vinextConfig.images.contentSecurityPolicy,
421
+ } : undefined;
422
+
423
+ export default {
424
+ async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
425
+ // Pass the Worker \`env\` so binding-backed adapters (e.g. KV) resolve.
426
+ registerConfiguredCacheAdapters(env);
427
+ try {
428
+ const url = new URL(request.url);
429
+ let pathname = url.pathname;
430
+
431
+ // Block protocol-relative URL open redirects in all shapes:
432
+ // literal //evil.com, /\\\\evil.com
433
+ // encoded /%5Cevil.com, /%2F/evil.com
434
+ // Browsers normalize backslash to forward slash, and they percent-decode
435
+ // Location headers, so an encoded backslash in a downstream 308 redirect
436
+ // would also navigate to the attacker's origin.
437
+ if (isOpenRedirectShaped(pathname)) {
438
+ return new Response("This page could not be found", { status: 404 });
439
+ }
440
+
441
+ // Invalid \`_next/static/*\` paths short-circuit with a plain-text 404
442
+ // instead of falling through to renderPage (which would render the full
443
+ // HTML 404 page with bootstrap scripts + CSS). Valid assets are served
444
+ // by Cloudflare's ASSETS binding BEFORE the worker runs; only misses
445
+ // reach this code. Matches Next.js (#1337):
446
+ // packages/next/src/server/lib/router-server.ts
447
+ if (isNextStaticPath(pathname, basePath, assetPathPrefix)) {
448
+ return notFoundStaticAssetResponse();
449
+ }
450
+
451
+ // Strip internal headers from inbound requests so they cannot be
452
+ // forged to influence routing or impersonate internal state.
453
+ // Request.headers is immutable in Workers, so build a clean copy.
454
+ {
455
+ const filteredHeaders = filterInternalHeaders(request.headers);
456
+ request = cloneRequestWithHeaders(request, filteredHeaders);
457
+ }
458
+
459
+ // ── 1. Strip basePath ─────────────────────────────────────────
460
+ // Track basePath presence on the original request so the matcher
461
+ // gating below can distinguish requests inside basePath (default
462
+ // rules apply) from requests outside it (only opt-out rules apply).
463
+ const hadBasePath = !basePath || hasBasePath(pathname, basePath);
464
+ {
465
+ const stripped = stripBasePath(pathname, basePath);
466
+ if (stripped !== pathname) {
467
+ const strippedUrl = new URL(request.url);
468
+ strippedUrl.pathname = stripped;
469
+ request = cloneRequestWithUrl(request, strippedUrl.toString());
470
+ pathname = stripped;
471
+ }
472
+ }
473
+
474
+ const dataNorm = normalizeDataRequest(request);
475
+ if (dataNorm.notFoundResponse) return dataNorm.notFoundResponse;
476
+ const isDataReq = dataNorm.isDataReq;
477
+ if (isDataReq) {
478
+ request = dataNorm.request;
479
+ pathname = dataNorm.normalizedPathname;
480
+ }
481
+
482
+ // ── Image optimization via Cloudflare Images binding ──────────
483
+ // Checked after basePath stripping so /<basePath>/_next/image works.
484
+ if (isImageOptimizationPath(pathname)) {
485
+ const allowedWidths = [
486
+ ...(vinextConfig?.images?.deviceSizes ?? DEFAULT_DEVICE_SIZES),
487
+ ...(vinextConfig?.images?.imageSizes ?? DEFAULT_IMAGE_SIZES),
488
+ ];
489
+ return handleImageOptimization(request, {
490
+ fetchAsset: (path) => env.ASSETS.fetch(new Request(new URL(path, request.url))),
491
+ transformImage: async (body, { width, format, quality }) => {
492
+ const result = await env.IMAGES.input(body).transform(width > 0 ? { width } : {}).output({ format, quality });
493
+ return result.response();
494
+ },
495
+ }, allowedWidths, imageConfig);
496
+ }
497
+
498
+ // Delegate the canonical 9-step Next.js pipeline to the shared owner.
499
+ // The worker adapter is responsible for: open-redirect guard, _next/static
500
+ // 404 short-circuit, header filtering, basePath stripping, and image
501
+ // optimization. runPagesRequest receives a clean, basePath-stripped request.
502
+ const deps: PagesPipelineDeps = {
503
+ basePath,
504
+ trailingSlash,
505
+ i18nConfig,
506
+ configRedirects,
507
+ configRewrites,
508
+ configHeaders,
509
+ hadBasePath,
510
+ isDataReq,
511
+ isDataRequest: isDataReq,
512
+ ctx,
513
+ matchPageRoute: typeof matchPageRoute === "function" ? matchPageRoute : null,
514
+ // Pass the original (pre-basePath-stripping) URL to middleware so that
515
+ // request.nextUrl.basePath reflects whether the URL actually had the
516
+ // basePath prefix. Matches Next.js behavior and the prod-server.ts
517
+ // equivalent (shared via wrapMiddlewareWithBasePath).
518
+ runMiddleware:
519
+ typeof runMiddleware === "function"
520
+ ? wrapMiddlewareWithBasePath(runMiddleware, basePath, hadBasePath)
521
+ : null,
522
+ renderPage: typeof renderPage === "function"
523
+ ? (req, resolvedUrl, options, stagedHeaders) =>
524
+ renderPage(req, resolvedUrl, null, ctx, stagedHeaders, options)
525
+ : null,
526
+ handleApi: typeof handleApiRoute === "function"
527
+ ? (req, apiUrl) => handleApiRoute(req, apiUrl, ctx)
528
+ : null,
529
+ serveFilesystemRoute: async (requestPathname, _stagedHeaders, phase) => {
530
+ return fetchWorkerFilesystemRoute(
531
+ request,
532
+ requestPathname,
533
+ phase,
534
+ (assetRequest) => env.ASSETS.fetch(assetRequest),
535
+ );
536
+ },
537
+ };
538
+
539
+ const result = await runPagesRequest(request, deps);
540
+ if (result.type === "response") {
541
+ return result.response;
542
+ }
543
+ // Should not reach here for prod/worker (all callbacks supplied).
544
+ return new Response("This page could not be found", { status: 404 });
545
+
546
+ } catch (error) {
547
+ console.error("[vinext] Worker error:", error);
548
+ return new Response("Internal Server Error", { status: 500 });
549
+ }
550
+ },
551
+ };
552
+
553
+ `;
554
+ }
555
+ /** Generate vite.config.ts for App Router */
556
+ function generateAppRouterViteConfig(info) {
557
+ const imports = [
558
+ `import { defineConfig } from "vite";`,
559
+ `import vinext from "vinext";`,
560
+ `import { cloudflare } from "@cloudflare/vite-plugin";`
561
+ ];
562
+ if (info?.nativeModulesToStub && info.nativeModulesToStub.length > 0) imports.push(`import path from "node:path";`);
563
+ const plugins = [];
564
+ if (info?.hasMDX) plugins.push(` // vinext auto-injects @mdx-js/rollup with plugins from next.config`);
565
+ plugins.push(` vinext(),`);
566
+ plugins.push(` cloudflare({
567
+ viteEnvironment: {
568
+ name: "rsc",
569
+ childEnvironments: ["ssr"],
570
+ },
571
+ }),`);
572
+ let resolveBlock = "";
573
+ const aliases = [];
574
+ if (info?.nativeModulesToStub && info.nativeModulesToStub.length > 0) for (const mod of info.nativeModulesToStub) aliases.push(` "${mod}": path.resolve(__dirname, "empty-stub.js"),`);
575
+ if (aliases.length > 0) resolveBlock = `\n resolve: {\n alias: {\n${aliases.join("\n")}\n },\n },`;
576
+ return `${imports.join("\n")}
577
+
578
+ export default defineConfig({
579
+ plugins: [
580
+ ${plugins.join("\n")}
581
+ ],${resolveBlock}
582
+ });
583
+ `;
584
+ }
585
+ /** Generate vite.config.ts for Pages Router */
586
+ function generatePagesRouterViteConfig(info) {
587
+ const imports = [
588
+ `import { defineConfig } from "vite";`,
589
+ `import vinext from "vinext";`,
590
+ `import { cloudflare } from "@cloudflare/vite-plugin";`
591
+ ];
592
+ if (info?.nativeModulesToStub && info.nativeModulesToStub.length > 0) imports.push(`import path from "node:path";`);
593
+ let resolveBlock = "";
594
+ const aliases = [];
595
+ if (info?.nativeModulesToStub && info.nativeModulesToStub.length > 0) for (const mod of info.nativeModulesToStub) aliases.push(` "${mod}": path.resolve(__dirname, "empty-stub.js"),`);
596
+ if (aliases.length > 0) resolveBlock = `\n resolve: {\n alias: {\n${aliases.join("\n")}\n },\n },`;
597
+ return `${imports.join("\n")}
598
+
599
+ export default defineConfig({
600
+ plugins: [
601
+ vinext(),
602
+ cloudflare(),
603
+ ],${resolveBlock}
604
+ });
605
+ `;
606
+ }
607
+ /**
608
+ * Check if a package is resolvable from a given root directory using
609
+ * Node's module resolution (createRequire). Handles hoisting, pnpm
610
+ * symlinks, monorepos, and Yarn PnP correctly.
611
+ */
612
+ function isPackageResolvable(root, packageName) {
613
+ try {
614
+ createRequire(path.join(root, "package.json")).resolve(packageName);
615
+ return true;
616
+ } catch {
617
+ return false;
618
+ }
619
+ }
620
+ function getMissingDeps(info, _isResolvable = isPackageResolvable) {
621
+ const missing = [];
622
+ if (!info.hasCloudflarePlugin) missing.push({
623
+ name: "@cloudflare/vite-plugin",
624
+ version: "latest"
625
+ });
626
+ if (!info.hasWrangler) missing.push({
627
+ name: "wrangler",
628
+ version: "latest"
629
+ });
630
+ if (!_isResolvable(info.root, "@vitejs/plugin-react")) missing.push({
631
+ name: "@vitejs/plugin-react",
632
+ version: "latest"
633
+ });
634
+ if (info.isAppRouter && !info.hasRscPlugin) missing.push({
635
+ name: "@vitejs/plugin-rsc",
636
+ version: "latest"
637
+ });
638
+ if (info.isAppRouter) {
639
+ if (!_isResolvable(info.root, "react-server-dom-webpack")) missing.push({
640
+ name: "react-server-dom-webpack",
641
+ version: "latest"
642
+ });
643
+ }
644
+ if (info.hasMDX) {
645
+ if (!_isResolvable(info.root, "@mdx-js/rollup")) missing.push({
646
+ name: "@mdx-js/rollup",
647
+ version: "latest"
648
+ });
649
+ }
650
+ return missing;
651
+ }
652
+ function installDeps(root, deps) {
653
+ if (deps.length === 0) return;
654
+ const depSpecs = deps.map((d) => `${d.name}@${d.version}`);
655
+ const [pm, ...pmArgs] = detectPackageManager(root).split(" ");
656
+ console.log(` Installing: ${deps.map((d) => d.name).join(", ")}`);
657
+ execFileSync(pm, [...pmArgs, ...depSpecs], {
658
+ cwd: root,
659
+ stdio: "inherit",
660
+ shell: process.platform === "win32"
661
+ });
662
+ }
663
+ const detectPackageManager = detectPackageManager$1;
664
+ /**
665
+ * Check whether an existing vite.config file already imports and uses the
666
+ * Cloudflare Vite plugin. This is a heuristic text scan — it doesn't execute
667
+ * the config — so it may produce false negatives for unusual configurations.
668
+ *
669
+ * Returns true if `@cloudflare/vite-plugin` appears to be configured, false
670
+ * if it is missing (meaning the build will fail with "could not resolve
671
+ * virtual:vinext-rsc-entry").
672
+ */
673
+ function viteConfigHasCloudflarePlugin(root) {
674
+ const candidates = [
675
+ path.join(root, "vite.config.ts"),
676
+ path.join(root, "vite.config.js"),
677
+ path.join(root, "vite.config.mjs")
678
+ ];
679
+ for (const candidate of candidates) if (fs.existsSync(candidate)) try {
680
+ return fs.readFileSync(candidate, "utf-8").includes("@cloudflare/vite-plugin");
681
+ } catch {
682
+ return true;
683
+ }
684
+ return false;
685
+ }
686
+ /**
687
+ * Extract the object-literal text of the `cache:` key (the `{ ... }` passed as
688
+ * `vinext({ cache })`) from a Vite config source, via brace matching. Returns
689
+ * null if there is no `cache:` object literal.
690
+ */
691
+ function extractCacheBlock(content) {
692
+ const m = /\bcache\s*:\s*\{/.exec(content);
693
+ if (!m) return null;
694
+ const open = m.index + m[0].length - 1;
695
+ let depth = 0;
696
+ for (let i = open; i < content.length; i++) {
697
+ const ch = content[i];
698
+ if (ch === "{") depth++;
699
+ else if (ch === "}" && --depth === 0) return content.slice(open, i + 1);
700
+ }
701
+ return null;
702
+ }
703
+ /**
704
+ * Whether a `cdn` / `data` field inside the cache object is assigned a real
705
+ * value (not absent, `undefined`, or `null`). Reads the value up to the next
706
+ * comma / closing brace / newline, which is enough to tell an assignment like
707
+ * `data: kvDataAdapter()` from `data: undefined`.
708
+ */
709
+ function cacheFieldAssigned(cacheBlock, field) {
710
+ const m = new RegExp(`\\b${field}\\s*:\\s*([^,}\\n]+)`).exec(cacheBlock);
711
+ if (!m) return false;
712
+ const value = m[1].trim();
713
+ return value.length > 0 && value !== "undefined" && value !== "null";
714
+ }
715
+ /**
716
+ * Detect whether the Vite config assigns a CDN or data cache adapter — i.e. the
717
+ * `cdn` or `data` field of the `vinext({ cache })` option is given a value.
718
+ * This is a source-level check on those exact object fields, not a fuzzy scan
719
+ * for adapter names. Mirrors {@link viteConfigHasCloudflarePlugin}'s leniency:
720
+ * an unreadable or absent config is treated as configured so a deploy is never
721
+ * blocked on a false negative.
722
+ */
723
+ function viteConfigHasCacheAdapter(root) {
724
+ const candidates = [
725
+ path.join(root, "vite.config.ts"),
726
+ path.join(root, "vite.config.js"),
727
+ path.join(root, "vite.config.mjs")
728
+ ];
729
+ for (const candidate of candidates) {
730
+ if (!fs.existsSync(candidate)) continue;
731
+ let content;
732
+ try {
733
+ content = fs.readFileSync(candidate, "utf-8");
734
+ } catch {
735
+ return true;
736
+ }
737
+ const block = extractCacheBlock(content);
738
+ if (!block) return false;
739
+ return cacheFieldAssigned(block, "cdn") || cacheFieldAssigned(block, "data");
740
+ }
741
+ return true;
742
+ }
743
+ /**
744
+ * Detect whether an existing user-authored Worker entry wires up a cache
745
+ * backend imperatively via one of the `setCacheHandler` / `setDataCacheHandler`
746
+ * / `setCdnCacheAdapter` setters. These setters are deprecated in favour of the
747
+ * declarative `vinext({ cache })` option, but older apps that scaffolded a KV
748
+ * cache handler into their Worker entry must keep working — so a deploy should
749
+ * not be blocked when the Worker entry already configures a backend.
750
+ *
751
+ * This is a heuristic text scan (it doesn't execute the entry), mirroring
752
+ * {@link viteConfigHasCacheAdapter}'s leniency: an unreadable Worker entry is
753
+ * treated as configured so a deploy is never blocked on a false negative. A
754
+ * missing Worker entry returns false (nothing to inspect — defer to other
755
+ * checks).
756
+ */
757
+ function workerEntryHasCacheHandler(root) {
758
+ const candidates = [path.join(root, "worker", "index.ts"), path.join(root, "worker", "index.js")];
759
+ for (const candidate of candidates) {
760
+ if (!fs.existsSync(candidate)) continue;
761
+ let content;
762
+ try {
763
+ content = fs.readFileSync(candidate, "utf-8");
764
+ } catch {
765
+ return true;
766
+ }
767
+ return /\b(?:setCacheHandler|setDataCacheHandler|setCdnCacheAdapter)\s*\(/.test(content);
768
+ }
769
+ return false;
770
+ }
771
+ /**
772
+ * Build the error thrown when an ISR/cached app is deployed without a cache
773
+ * adapter configured in the Vite config. Production deployments need a
774
+ * persistent cache backend; vinext no longer scaffolds one into the Worker
775
+ * entry, so it must be declared via `vinext({ cache })`.
776
+ */
777
+ function formatMissingCacheAdapterError(options) {
778
+ const configRef = options.configFile ? options.configFile : "your Vite config";
779
+ return `[vinext] This app uses ISR / caching but no cache adapter is configured in ${configRef}.\n\n Production deployments need a persistent cache backend. Declare one on the\n vinext() plugin in ${configRef}:\n\n import { kvDataAdapter } from "@vinext/cloudflare/cache/kv-data-adapter";\n\n export default defineConfig({\n plugins: [\n vinext({\n cache: {\n data: kvDataAdapter(), // KV-backed data cache (binding: VINEXT_KV_CACHE)\n },\n }),\n cloudflare(),\n ],\n });\n\n The VINEXT_KV_CACHE namespace binding is added to wrangler.jsonc for you.\n Create the namespace with:\n\n npx wrangler kv namespace create VINEXT_KV_CACHE`;
780
+ }
781
+ function getFilesToGenerate(info) {
782
+ const files = [];
783
+ if (!info.hasWranglerConfig) files.push({
784
+ path: path.join(info.root, "wrangler.jsonc"),
785
+ content: generateWranglerConfig(info),
786
+ description: "wrangler.jsonc"
787
+ });
788
+ if (!info.hasWorkerEntry) {
789
+ const workerContent = info.isAppRouter ? generateAppRouterWorkerEntry() : generatePagesRouterWorkerEntry();
790
+ files.push({
791
+ path: path.join(info.root, "worker", "index.ts"),
792
+ content: workerContent,
793
+ description: "worker/index.ts"
794
+ });
795
+ }
796
+ if (!info.hasViteConfig) {
797
+ const viteContent = info.isAppRouter ? generateAppRouterViteConfig(info) : generatePagesRouterViteConfig(info);
798
+ files.push({
799
+ path: path.join(info.root, "vite.config.ts"),
800
+ content: viteContent,
801
+ description: "vite.config.ts"
802
+ });
803
+ }
804
+ return files;
805
+ }
806
+ function writeGeneratedFiles(files) {
807
+ for (const file of files) {
808
+ const dir = path.dirname(file.path);
809
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
810
+ fs.writeFileSync(file.path, file.content, "utf-8");
811
+ console.log(` Created ${file.description}`);
812
+ }
813
+ }
814
+ /**
815
+ * Run a function with `process.env.CLOUDFLARE_ENV` set to the given value,
816
+ * restoring the previous state (whether set or absent) after the function
817
+ * resolves or throws.
818
+ *
819
+ * The `@cloudflare/vite-plugin` reads `CLOUDFLARE_ENV` from `process.env` to
820
+ * drive the multi-environment merge applied to the emitted `wrangler.json`.
821
+ * Without this propagation the `--env <name>` CLI flag is silently ignored at
822
+ * build time and the top-level config is emitted regardless. See issue #1210.
823
+ *
824
+ * Passing `undefined` is a no-op; the callback runs with `process.env` untouched.
825
+ */
826
+ async function withCloudflareEnv(env, fn) {
827
+ if (env === void 0 || env === "") return fn();
828
+ const hadPrev = "CLOUDFLARE_ENV" in process.env;
829
+ const prev = process.env.CLOUDFLARE_ENV;
830
+ process.env.CLOUDFLARE_ENV = env;
831
+ try {
832
+ return await fn();
833
+ } finally {
834
+ if (hadPrev) process.env.CLOUDFLARE_ENV = prev;
835
+ else delete process.env.CLOUDFLARE_ENV;
836
+ }
837
+ }
838
+ async function runBuild(info, env) {
839
+ console.log("\n Building for Cloudflare Workers...\n");
840
+ let vitePath;
841
+ try {
842
+ vitePath = createRequire(path.join(info.root, "package.json")).resolve("vite");
843
+ } catch {
844
+ vitePath = "vite";
845
+ }
846
+ const { createBuilder } = await (vitePath === "vite" ? import(vitePath) : import(pathToFileURL(vitePath).href));
847
+ await withCloudflareEnv(env, async () => {
848
+ await (await createBuilder({ root: info.root })).buildApp();
849
+ });
850
+ }
851
+ function validateWranglerEnvName(env) {
852
+ if (env.includes("\0")) throw new Error("Wrangler environment names cannot contain null bytes.");
853
+ return env;
854
+ }
855
+ function buildWranglerDeployArgs(options) {
856
+ const args = ["deploy"];
857
+ const env = options.env || (options.preview ? "preview" : void 0);
858
+ if (env) args.push("--env", validateWranglerEnvName(env));
859
+ return {
860
+ args,
861
+ env
862
+ };
863
+ }
864
+ /**
865
+ * Resolve Wrangler's JavaScript CLI entrypoint in node_modules.
866
+ *
867
+ * Invoking the JavaScript file through `process.execPath` avoids the `.cmd`
868
+ * shim and command shell that package managers create on Windows.
869
+ */
870
+ function resolveWranglerBin(root, resolvePackageJson = (projectRoot) => {
871
+ try {
872
+ return createRequire(path.join(projectRoot, "package.json")).resolve("wrangler/package.json");
873
+ } catch {
874
+ return findInNodeModules(projectRoot, "wrangler/package.json");
875
+ }
876
+ }) {
877
+ const packageJsonPath = resolvePackageJson(root);
878
+ if (packageJsonPath) {
879
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
880
+ const bin = typeof packageJson.bin === "string" ? packageJson.bin : packageJson.bin?.wrangler;
881
+ if (bin) return path.resolve(path.dirname(packageJsonPath), bin);
882
+ }
883
+ return path.join(root, "node_modules", "wrangler", "bin", "wrangler.js");
884
+ }
885
+ function buildNodeCliInvocation(scriptPath, args, nodeExecutable = process.execPath) {
886
+ return {
887
+ file: nodeExecutable,
888
+ args: [scriptPath, ...args]
889
+ };
890
+ }
891
+ function buildWranglerInvocation(root, options, nodeExecutable = process.execPath) {
892
+ const wranglerBin = resolveWranglerBin(root);
893
+ const { args, env } = buildWranglerDeployArgs(options);
894
+ return {
895
+ ...buildNodeCliInvocation(wranglerBin, args, nodeExecutable),
896
+ env
897
+ };
898
+ }
899
+ function runWranglerDeploy(root, options, execute = execFileSync) {
900
+ const execOpts = {
901
+ cwd: root,
902
+ stdio: "pipe",
903
+ encoding: "utf-8",
904
+ shell: false
905
+ };
906
+ const { file, args, env } = buildWranglerInvocation(root, options);
907
+ if (env) console.log(`\n Deploying to env: ${env}...`);
908
+ else console.log("\n Deploying to production...");
909
+ const output = execute(file, args, execOpts);
910
+ const urlMatch = output.match(/https:\/\/[^\s]+\.workers\.dev[^\s]*/);
911
+ const deployedUrl = urlMatch ? urlMatch[0] : null;
912
+ if (output.trim()) for (const line of output.trim().split("\n")) console.log(` ${line}`);
913
+ return deployedUrl ?? "(URL not detected in wrangler output)";
914
+ }
915
+ const VINEXT_PREGEN_START = "/* __VINEXT_PREGENERATED_CONCRETE_PATHS_START__ */";
916
+ const VINEXT_PREGEN_END = "/* __VINEXT_PREGENERATED_CONCRETE_PATHS_END__ */";
917
+ const VINEXT_PREGEN_RE = new RegExp(`${escapeRegExp(VINEXT_PREGEN_START)}[\\s\\S]*?${escapeRegExp(VINEXT_PREGEN_END)}\\n?`, "g");
918
+ /**
919
+ * Read the prerender manifest and inject pregenerated concrete paths into the
920
+ * App Router Worker bundle so the PPR fallback-shell guard is populated at
921
+ * module init time without calling `seedMemoryCacheFromPrerender`.
922
+ *
923
+ * The paths are injected as `globalThis.__VINEXT_PREGENERATED_CONCRETE_PATHS`
924
+ * wrapped in replaceable marker comments, and consumed by
925
+ * `initPregeneratedPathsFromGlobals` in the generated RSC entry.
926
+ *
927
+ * Idempotent: repeated calls strip the previous injection before writing the
928
+ * new one. If the manifest is missing, corrupt, or empty, any prior injection
929
+ * is stripped and nothing new is written — failing closed to empty.
930
+ */
931
+ function injectPregeneratedConcretePaths(root) {
932
+ const workerEntry = path.resolve(root, "dist", "server", "index.js");
933
+ if (!fs.existsSync(workerEntry)) return;
934
+ let code = fs.readFileSync(workerEntry, "utf-8");
935
+ code = code.replace(VINEXT_PREGEN_RE, "");
936
+ const table = buildPregeneratedConcretePathTable(readPrerenderManifest(path.join(root, "dist", "server", "vinext-prerender.json")) ?? {});
937
+ if (table.length > 0) code = `${VINEXT_PREGEN_START}\nglobalThis.__VINEXT_PREGENERATED_CONCRETE_PATHS = ${JSON.stringify(table)};\n${VINEXT_PREGEN_END}\n` + code;
938
+ fs.writeFileSync(workerEntry, code);
939
+ }
940
+ async function deploy(options) {
941
+ const deployEnv = validateWranglerEnvName(options.env || (options.preview ? "preview" : "production"));
942
+ const root = path.resolve(options.root);
943
+ loadDotenv({
944
+ root,
945
+ mode: "production"
946
+ });
947
+ console.log("\n vinext deploy\n");
948
+ const info = detectProject(root);
949
+ if (!info.isAppRouter && !info.isPagesRouter) {
950
+ console.error(" Error: No app/ or pages/ directory found.");
951
+ console.error(" vinext deploy requires a Next.js project with an app/ or pages/ directory");
952
+ console.error(" (also checks src/app/ and src/pages/).\n");
953
+ process.exit(1);
954
+ }
955
+ if (options.name) info.projectName = options.name;
956
+ console.log(` Project: ${info.projectName}`);
957
+ console.log(` Router: ${info.isAppRouter ? "App Router" : "Pages Router"}`);
958
+ console.log(` ISR: ${info.hasISR ? "detected" : "none"}`);
959
+ if (info.isAppRouter) {
960
+ const reactUpgrade = getReactUpgradeDeps(root);
961
+ if (reactUpgrade.length > 0) {
962
+ const [pm, ...pmArgs] = detectPackageManager(root).replace(/ -D$/, "").split(" ");
963
+ console.log(` Upgrading ${reactUpgrade.map((d) => d.replace(/@latest$/, "")).join(", ")}...`);
964
+ execFileSync(pm, [...pmArgs, ...reactUpgrade], {
965
+ cwd: root,
966
+ stdio: "inherit",
967
+ shell: process.platform === "win32"
968
+ });
969
+ }
970
+ }
971
+ const missingDeps = getMissingDeps(info);
972
+ if (missingDeps.length > 0) {
973
+ console.log();
974
+ installDeps(root, missingDeps);
975
+ const nameOverride = options.name ? info.projectName : void 0;
976
+ Object.assign(info, detectProject(root));
977
+ if (nameOverride) info.projectName = nameOverride;
978
+ }
979
+ if (!info.hasTypeModule) {
980
+ const renamedConfigs = renameCJSConfigs(root);
981
+ for (const [oldName, newName] of renamedConfigs) console.log(` Renamed ${oldName} → ${newName} (CJS → .cjs)`);
982
+ if (ensureESModule(root)) {
983
+ console.log(` Added "type": "module" to package.json`);
984
+ info.hasTypeModule = true;
985
+ }
986
+ }
987
+ const filesToGenerate = getFilesToGenerate(info);
988
+ if (filesToGenerate.length > 0) {
989
+ console.log();
990
+ writeGeneratedFiles(filesToGenerate);
991
+ }
992
+ if (info.hasViteConfig && !viteConfigHasCloudflarePlugin(root)) throw new Error(formatMissingCloudflarePluginError({ isAppRouter: info.isAppRouter }));
993
+ if (info.hasISR && !viteConfigHasCacheAdapter(root) && !workerEntryHasCacheHandler(root)) throw new Error(formatMissingCacheAdapterError({}));
994
+ if (options.dryRun) {
995
+ console.log("\n Dry run complete. Files generated but no build or deploy performed.\n");
996
+ return;
997
+ }
998
+ if (!options.skipBuild) await runBuild(info, deployEnv === "production" && !options.env ? void 0 : deployEnv);
999
+ else console.log("\n Skipping build (--skip-build)");
1000
+ {
1001
+ const nextConfig = await resolveNextConfig(await loadNextConfig(info.root), info.root);
1002
+ const isStaticExport = nextConfig.output === "export";
1003
+ if (options.prerenderAll || isStaticExport) {
1004
+ const label = isStaticExport && !options.prerenderAll ? "Pre-rendering all routes (output: 'export')..." : "Pre-rendering all routes...";
1005
+ console.log(`\n ${label}`);
1006
+ if (nextConfig.enablePrerenderSourceMaps) {
1007
+ process.setSourceMapsEnabled(true);
1008
+ Error.stackTraceLimit = Math.max(Error.stackTraceLimit, 50);
1009
+ }
1010
+ await runPrerender({
1011
+ root: info.root,
1012
+ concurrency: options.prerenderConcurrency
1013
+ });
1014
+ }
1015
+ injectPregeneratedConcretePaths(root);
1016
+ }
1017
+ if (options.experimentalTPR) {
1018
+ console.log();
1019
+ const tprResult = await runTPR({
1020
+ root,
1021
+ coverage: Math.max(1, Math.min(100, options.tprCoverage ?? 90)),
1022
+ limit: Math.max(1, options.tprLimit ?? 1e3),
1023
+ window: Math.max(1, options.tprWindow ?? 24)
1024
+ });
1025
+ if (tprResult.skipped) console.log(` TPR: Skipped (${tprResult.skipped})`);
1026
+ }
1027
+ const url = runWranglerDeploy(root, { env: deployEnv === "production" && !options.env ? void 0 : deployEnv });
1028
+ console.log("\n ─────────────────────────────────────────");
1029
+ console.log(` Deployed to: ${url}`);
1030
+ console.log(" ─────────────────────────────────────────\n");
1031
+ }
1032
+ //#endregion
1033
+ export { buildNodeCliInvocation, buildWranglerDeployArgs, buildWranglerInvocation, deploy, detectProject, ensureESModule, formatMissingCacheAdapterError, formatMissingCloudflarePluginError, generateAppRouterViteConfig, generateAppRouterWorkerEntry, generatePagesRouterViteConfig, generatePagesRouterWorkerEntry, generateWranglerConfig, getFilesToGenerate, getMissingDeps, hasWranglerConfig, injectPregeneratedConcretePaths, isPackageResolvable, parseDeployArgs, renameCJSConfigs, resolveWranglerBin, runWranglerDeploy, validateWranglerEnvName, viteConfigHasCacheAdapter, viteConfigHasCloudflarePlugin, withCloudflareEnv, workerEntryHasCacheHandler };