vinext 0.0.30 → 0.0.31

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 (435) hide show
  1. package/README.md +12 -6
  2. package/dist/build/prerender.d.ts +188 -0
  3. package/dist/build/prerender.js +675 -0
  4. package/dist/build/prerender.js.map +1 -0
  5. package/dist/build/report.d.ts +45 -46
  6. package/dist/build/report.js +247 -276
  7. package/dist/build/report.js.map +1 -1
  8. package/dist/build/run-prerender.d.ts +62 -0
  9. package/dist/build/run-prerender.js +183 -0
  10. package/dist/build/run-prerender.js.map +1 -0
  11. package/dist/build/server-manifest.d.ts +19 -0
  12. package/dist/build/server-manifest.js +29 -0
  13. package/dist/build/server-manifest.js.map +1 -0
  14. package/dist/build/static-export.d.ts +51 -66
  15. package/dist/build/static-export.js +51 -545
  16. package/dist/build/static-export.js.map +1 -1
  17. package/dist/check.d.ts +26 -24
  18. package/dist/check.js +591 -571
  19. package/dist/check.js.map +1 -1
  20. package/dist/cli.d.ts +1 -15
  21. package/dist/cli.js +430 -491
  22. package/dist/cli.js.map +1 -1
  23. package/dist/client/entry.d.ts +1 -2
  24. package/dist/client/entry.js +49 -62
  25. package/dist/client/entry.js.map +1 -1
  26. package/dist/client/validate-module-path.d.ts +4 -1
  27. package/dist/client/validate-module-path.js +23 -28
  28. package/dist/client/validate-module-path.js.map +1 -1
  29. package/dist/client/vinext-next-data.d.ts +15 -20
  30. package/dist/client/vinext-next-data.js +0 -1
  31. package/dist/cloudflare/index.d.ts +3 -8
  32. package/dist/cloudflare/index.js +3 -8
  33. package/dist/cloudflare/kv-cache-handler.d.ts +95 -105
  34. package/dist/cloudflare/kv-cache-handler.js +354 -380
  35. package/dist/cloudflare/kv-cache-handler.js.map +1 -1
  36. package/dist/cloudflare/tpr.d.ts +36 -34
  37. package/dist/cloudflare/tpr.js +460 -603
  38. package/dist/cloudflare/tpr.js.map +1 -1
  39. package/dist/config/config-matchers.d.ts +31 -40
  40. package/dist/config/config-matchers.js +727 -936
  41. package/dist/config/config-matchers.js.map +1 -1
  42. package/dist/config/dotenv.d.ts +18 -11
  43. package/dist/config/dotenv.js +79 -84
  44. package/dist/config/dotenv.js.map +1 -1
  45. package/dist/config/next-config.d.ts +156 -146
  46. package/dist/config/next-config.js +374 -464
  47. package/dist/config/next-config.js.map +1 -1
  48. package/dist/deploy.d.ts +87 -96
  49. package/dist/deploy.js +490 -628
  50. package/dist/deploy.js.map +1 -1
  51. package/dist/entries/app-browser-entry.d.ts +4 -1
  52. package/dist/entries/app-browser-entry.js +12 -8
  53. package/dist/entries/app-browser-entry.js.map +1 -1
  54. package/dist/entries/app-rsc-entry.d.ts +33 -20
  55. package/dist/entries/app-rsc-entry.js +442 -211
  56. package/dist/entries/app-rsc-entry.js.map +1 -1
  57. package/dist/entries/app-ssr-entry.d.ts +9 -1
  58. package/dist/entries/app-ssr-entry.js +61 -28
  59. package/dist/entries/app-ssr-entry.js.map +1 -1
  60. package/dist/entries/pages-client-entry.d.ts +6 -2
  61. package/dist/entries/pages-client-entry.js +30 -33
  62. package/dist/entries/pages-client-entry.js.map +1 -1
  63. package/dist/entries/pages-entry-helpers.d.ts +5 -1
  64. package/dist/entries/pages-entry-helpers.js +17 -14
  65. package/dist/entries/pages-entry-helpers.js.map +1 -1
  66. package/dist/entries/pages-server-entry.d.ts +6 -2
  67. package/dist/entries/pages-server-entry.js +84 -113
  68. package/dist/entries/pages-server-entry.js.map +1 -1
  69. package/dist/index.d.ts +82 -62
  70. package/dist/index.js +2172 -3133
  71. package/dist/index.js.map +1 -1
  72. package/dist/init.d.ts +40 -37
  73. package/dist/init.js +201 -258
  74. package/dist/init.js.map +1 -1
  75. package/dist/plugins/async-hooks-stub.d.ts +7 -3
  76. package/dist/plugins/async-hooks-stub.js +39 -42
  77. package/dist/plugins/async-hooks-stub.js.map +1 -1
  78. package/dist/plugins/client-reference-dedup.d.ts +7 -3
  79. package/dist/plugins/client-reference-dedup.js +63 -88
  80. package/dist/plugins/client-reference-dedup.js.map +1 -1
  81. package/dist/routing/app-router.d.ts +100 -96
  82. package/dist/routing/app-router.js +560 -670
  83. package/dist/routing/app-router.js.map +1 -1
  84. package/dist/routing/file-matcher.d.ts +18 -15
  85. package/dist/routing/file-matcher.js +65 -65
  86. package/dist/routing/file-matcher.js.map +1 -1
  87. package/dist/routing/pages-router.d.ts +23 -24
  88. package/dist/routing/pages-router.js +147 -172
  89. package/dist/routing/pages-router.js.map +1 -1
  90. package/dist/routing/route-trie.d.ts +23 -20
  91. package/dist/routing/route-trie.js +131 -151
  92. package/dist/routing/route-trie.js.map +1 -1
  93. package/dist/routing/route-validation.d.ts +5 -2
  94. package/dist/routing/route-validation.js +98 -130
  95. package/dist/routing/route-validation.js.map +1 -1
  96. package/dist/routing/utils.d.ts +10 -7
  97. package/dist/routing/utils.js +75 -111
  98. package/dist/routing/utils.js.map +1 -1
  99. package/dist/server/api-handler.d.ts +8 -13
  100. package/dist/server/api-handler.js +161 -193
  101. package/dist/server/api-handler.js.map +1 -1
  102. package/dist/server/app-router-entry.d.ts +6 -16
  103. package/dist/server/app-router-entry.js +26 -54
  104. package/dist/server/app-router-entry.js.map +1 -1
  105. package/dist/server/dev-module-runner.d.ts +11 -64
  106. package/dist/server/dev-module-runner.js +89 -101
  107. package/dist/server/dev-module-runner.js.map +1 -1
  108. package/dist/server/dev-origin-check.d.ts +12 -10
  109. package/dist/server/dev-origin-check.js +98 -108
  110. package/dist/server/dev-origin-check.js.map +1 -1
  111. package/dist/server/dev-server.d.ts +17 -14
  112. package/dist/server/dev-server.js +542 -869
  113. package/dist/server/dev-server.js.map +1 -1
  114. package/dist/server/html.d.ts +4 -1
  115. package/dist/server/html.js +25 -26
  116. package/dist/server/html.js.map +1 -1
  117. package/dist/server/image-optimization.d.ts +31 -28
  118. package/dist/server/image-optimization.js +181 -210
  119. package/dist/server/image-optimization.js.map +1 -1
  120. package/dist/server/instrumentation.d.ts +25 -22
  121. package/dist/server/instrumentation.js +110 -122
  122. package/dist/server/instrumentation.js.map +1 -1
  123. package/dist/server/isr-cache.d.ts +16 -26
  124. package/dist/server/isr-cache.js +106 -128
  125. package/dist/server/isr-cache.js.map +1 -1
  126. package/dist/server/metadata-routes.d.ts +85 -88
  127. package/dist/server/metadata-routes.js +270 -317
  128. package/dist/server/metadata-routes.js.map +1 -1
  129. package/dist/server/middleware-codegen.d.ts +7 -4
  130. package/dist/server/middleware-codegen.js +61 -61
  131. package/dist/server/middleware-codegen.js.map +1 -1
  132. package/dist/server/middleware-request-headers.d.ts +8 -6
  133. package/dist/server/middleware-request-headers.js +47 -65
  134. package/dist/server/middleware-request-headers.js.map +1 -1
  135. package/dist/server/middleware.d.ts +31 -47
  136. package/dist/server/middleware.js +273 -404
  137. package/dist/server/middleware.js.map +1 -1
  138. package/dist/server/normalize-path.d.ts +4 -1
  139. package/dist/server/normalize-path.js +33 -47
  140. package/dist/server/normalize-path.js.map +1 -1
  141. package/dist/server/pages-i18n.d.ts +38 -30
  142. package/dist/server/pages-i18n.js +112 -139
  143. package/dist/server/pages-i18n.js.map +1 -1
  144. package/dist/server/prod-server.d.ts +19 -31
  145. package/dist/server/prod-server.js +714 -945
  146. package/dist/server/prod-server.js.map +1 -1
  147. package/dist/server/request-log.d.ts +18 -12
  148. package/dist/server/request-log.js +45 -52
  149. package/dist/server/request-log.js.map +1 -1
  150. package/dist/server/request-pipeline.d.ts +9 -17
  151. package/dist/server/request-pipeline.js +133 -184
  152. package/dist/server/request-pipeline.js.map +1 -1
  153. package/dist/server/worker-utils.d.ts +4 -1
  154. package/dist/server/worker-utils.js +31 -37
  155. package/dist/server/worker-utils.js.map +1 -1
  156. package/dist/shims/amp.d.ts +5 -2
  157. package/dist/shims/amp.js +19 -15
  158. package/dist/shims/amp.js.map +1 -1
  159. package/dist/shims/app.d.ts +8 -10
  160. package/dist/shims/app.js +0 -1
  161. package/dist/shims/cache-runtime.d.ts +20 -45
  162. package/dist/shims/cache-runtime.js +271 -422
  163. package/dist/shims/cache-runtime.js.map +1 -1
  164. package/dist/shims/cache.d.ts +130 -121
  165. package/dist/shims/cache.js +339 -427
  166. package/dist/shims/cache.js.map +1 -1
  167. package/dist/shims/client-only.d.ts +1 -18
  168. package/dist/shims/client-only.js +0 -17
  169. package/dist/shims/compat-router.d.ts +4 -1
  170. package/dist/shims/compat-router.js +23 -19
  171. package/dist/shims/compat-router.js.map +1 -1
  172. package/dist/shims/config.d.ts +7 -5
  173. package/dist/shims/config.js +16 -23
  174. package/dist/shims/config.js.map +1 -1
  175. package/dist/shims/constants.d.ts +119 -118
  176. package/dist/shims/constants.js +159 -164
  177. package/dist/shims/constants.js.map +1 -1
  178. package/dist/shims/document.d.ts +20 -16
  179. package/dist/shims/document.js +41 -22
  180. package/dist/shims/document.js.map +1 -1
  181. package/dist/shims/dynamic.d.ts +13 -22
  182. package/dist/shims/dynamic.js +122 -136
  183. package/dist/shims/dynamic.js.map +1 -1
  184. package/dist/shims/error-boundary.d.ts +22 -15
  185. package/dist/shims/error-boundary.js +81 -79
  186. package/dist/shims/error-boundary.js.map +1 -1
  187. package/dist/shims/error.d.ts +11 -12
  188. package/dist/shims/error.js +35 -39
  189. package/dist/shims/error.js.map +1 -1
  190. package/dist/shims/fetch-cache.d.ts +16 -14
  191. package/dist/shims/fetch-cache.js +437 -645
  192. package/dist/shims/fetch-cache.js.map +1 -1
  193. package/dist/shims/font-google-base.d.ts +28 -26
  194. package/dist/shims/font-google-base.js +238 -325
  195. package/dist/shims/font-google-base.js.map +1 -1
  196. package/dist/shims/font-google.d.ts +3 -3
  197. package/dist/shims/font-google.generated.d.ts +1928 -1924
  198. package/dist/shims/font-google.generated.js +1928 -2133
  199. package/dist/shims/font-google.generated.js.map +1 -1
  200. package/dist/shims/font-google.js +3 -3
  201. package/dist/shims/font-local.d.ts +28 -26
  202. package/dist/shims/font-local.js +204 -260
  203. package/dist/shims/font-local.js.map +1 -1
  204. package/dist/shims/form.d.ts +13 -27
  205. package/dist/shims/form.js +128 -180
  206. package/dist/shims/form.js.map +1 -1
  207. package/dist/shims/head-state.d.ts +8 -13
  208. package/dist/shims/head-state.js +25 -42
  209. package/dist/shims/head-state.js.map +1 -1
  210. package/dist/shims/head.d.ts +16 -20
  211. package/dist/shims/head.js +172 -250
  212. package/dist/shims/head.js.map +1 -1
  213. package/dist/shims/headers.d.ts +84 -78
  214. package/dist/shims/headers.js +447 -575
  215. package/dist/shims/headers.js.map +1 -1
  216. package/dist/shims/i18n-context.d.ts +16 -20
  217. package/dist/shims/i18n-context.js +35 -48
  218. package/dist/shims/i18n-context.js.map +1 -1
  219. package/dist/shims/i18n-state.d.ts +8 -14
  220. package/dist/shims/i18n-state.js +34 -42
  221. package/dist/shims/i18n-state.js.map +1 -1
  222. package/dist/shims/image-config.d.ts +11 -8
  223. package/dist/shims/image-config.js +50 -83
  224. package/dist/shims/image-config.js.map +1 -1
  225. package/dist/shims/image.d.ts +37 -46
  226. package/dist/shims/image.js +283 -308
  227. package/dist/shims/image.js.map +1 -1
  228. package/dist/shims/internal/api-utils.d.ts +7 -4
  229. package/dist/shims/internal/api-utils.js +0 -6
  230. package/dist/shims/internal/app-router-context.d.ts +22 -17
  231. package/dist/shims/internal/app-router-context.js +17 -13
  232. package/dist/shims/internal/app-router-context.js.map +1 -1
  233. package/dist/shims/internal/cookies.d.ts +2 -9
  234. package/dist/shims/internal/cookies.js +2 -9
  235. package/dist/shims/internal/parse-cookie-header.d.ts +4 -1
  236. package/dist/shims/internal/parse-cookie-header.js +29 -29
  237. package/dist/shims/internal/parse-cookie-header.js.map +1 -1
  238. package/dist/shims/internal/router-context.d.ts +6 -1
  239. package/dist/shims/internal/router-context.js +11 -7
  240. package/dist/shims/internal/router-context.js.map +1 -1
  241. package/dist/shims/internal/utils.d.ts +40 -37
  242. package/dist/shims/internal/utils.js +24 -30
  243. package/dist/shims/internal/utils.js.map +1 -1
  244. package/dist/shims/internal/work-unit-async-storage.d.ts +6 -10
  245. package/dist/shims/internal/work-unit-async-storage.js +14 -11
  246. package/dist/shims/internal/work-unit-async-storage.js.map +1 -1
  247. package/dist/shims/layout-segment-context.d.ts +11 -14
  248. package/dist/shims/layout-segment-context.js +24 -23
  249. package/dist/shims/layout-segment-context.js.map +1 -1
  250. package/dist/shims/legacy-image.d.ts +39 -46
  251. package/dist/shims/legacy-image.js +47 -42
  252. package/dist/shims/legacy-image.js.map +1 -1
  253. package/dist/shims/link.d.ts +32 -36
  254. package/dist/shims/link.js +255 -391
  255. package/dist/shims/link.js.map +1 -1
  256. package/dist/shims/metadata.d.ts +210 -202
  257. package/dist/shims/metadata.js +545 -546
  258. package/dist/shims/metadata.js.map +1 -1
  259. package/dist/shims/navigation-state.d.ts +10 -18
  260. package/dist/shims/navigation-state.js +66 -74
  261. package/dist/shims/navigation-state.js.map +1 -1
  262. package/dist/shims/navigation.d.ts +59 -63
  263. package/dist/shims/navigation.js +505 -704
  264. package/dist/shims/navigation.js.map +1 -1
  265. package/dist/shims/og.d.ts +2 -20
  266. package/dist/shims/og.js +2 -19
  267. package/dist/shims/readonly-url-search-params.d.ts +8 -5
  268. package/dist/shims/readonly-url-search-params.js +26 -22
  269. package/dist/shims/readonly-url-search-params.js.map +1 -1
  270. package/dist/shims/request-context.d.ts +8 -5
  271. package/dist/shims/request-context.js +50 -60
  272. package/dist/shims/request-context.js.map +1 -1
  273. package/dist/shims/request-state-types.d.ts +11 -11
  274. package/dist/shims/request-state-types.js +0 -1
  275. package/dist/shims/router-state.d.ts +13 -10
  276. package/dist/shims/router-state.js +34 -43
  277. package/dist/shims/router-state.js.map +1 -1
  278. package/dist/shims/router.d.ts +81 -85
  279. package/dist/shims/router.js +506 -628
  280. package/dist/shims/router.js.map +1 -1
  281. package/dist/shims/script.d.ts +39 -48
  282. package/dist/shims/script.js +107 -160
  283. package/dist/shims/script.js.map +1 -1
  284. package/dist/shims/server-only.d.ts +1 -19
  285. package/dist/shims/server-only.js +0 -18
  286. package/dist/shims/server.d.ts +175 -164
  287. package/dist/shims/server.js +462 -478
  288. package/dist/shims/server.js.map +1 -1
  289. package/dist/shims/unified-request-context.d.ts +20 -20
  290. package/dist/shims/unified-request-context.js +81 -99
  291. package/dist/shims/unified-request-context.js.map +1 -1
  292. package/dist/shims/url-safety.d.ts +4 -1
  293. package/dist/shims/url-safety.js +15 -11
  294. package/dist/shims/url-safety.js.map +1 -1
  295. package/dist/shims/url-utils.d.ts +8 -5
  296. package/dist/shims/url-utils.js +62 -93
  297. package/dist/shims/url-utils.js.map +1 -1
  298. package/dist/shims/web-vitals.d.ts +10 -8
  299. package/dist/shims/web-vitals.js +9 -15
  300. package/dist/shims/web-vitals.js.map +1 -1
  301. package/dist/utils/base-path.d.ts +5 -2
  302. package/dist/utils/base-path.js +21 -19
  303. package/dist/utils/base-path.js.map +1 -1
  304. package/dist/utils/domain-locale.d.ts +17 -9
  305. package/dist/utils/domain-locale.js +36 -56
  306. package/dist/utils/domain-locale.js.map +1 -1
  307. package/dist/utils/hash.d.ts +4 -1
  308. package/dist/utils/hash.js +19 -17
  309. package/dist/utils/hash.js.map +1 -1
  310. package/dist/utils/manifest-paths.d.ts +6 -3
  311. package/dist/utils/manifest-paths.js +15 -16
  312. package/dist/utils/manifest-paths.js.map +1 -1
  313. package/dist/utils/project.d.ts +13 -11
  314. package/dist/utils/project.js +169 -216
  315. package/dist/utils/project.js.map +1 -1
  316. package/dist/utils/query.d.ts +8 -6
  317. package/dist/utils/query.js +57 -67
  318. package/dist/utils/query.js.map +1 -1
  319. package/package.json +10 -9
  320. package/dist/build/report.d.ts.map +0 -1
  321. package/dist/build/static-export.d.ts.map +0 -1
  322. package/dist/check.d.ts.map +0 -1
  323. package/dist/cli.d.ts.map +0 -1
  324. package/dist/client/entry.d.ts.map +0 -1
  325. package/dist/client/validate-module-path.d.ts.map +0 -1
  326. package/dist/client/vinext-next-data.d.ts.map +0 -1
  327. package/dist/client/vinext-next-data.js.map +0 -1
  328. package/dist/cloudflare/index.d.ts.map +0 -1
  329. package/dist/cloudflare/index.js.map +0 -1
  330. package/dist/cloudflare/kv-cache-handler.d.ts.map +0 -1
  331. package/dist/cloudflare/tpr.d.ts.map +0 -1
  332. package/dist/config/config-matchers.d.ts.map +0 -1
  333. package/dist/config/dotenv.d.ts.map +0 -1
  334. package/dist/config/next-config.d.ts.map +0 -1
  335. package/dist/deploy.d.ts.map +0 -1
  336. package/dist/entries/app-browser-entry.d.ts.map +0 -1
  337. package/dist/entries/app-rsc-entry.d.ts.map +0 -1
  338. package/dist/entries/app-ssr-entry.d.ts.map +0 -1
  339. package/dist/entries/pages-client-entry.d.ts.map +0 -1
  340. package/dist/entries/pages-entry-helpers.d.ts.map +0 -1
  341. package/dist/entries/pages-server-entry.d.ts.map +0 -1
  342. package/dist/index.d.ts.map +0 -1
  343. package/dist/init.d.ts.map +0 -1
  344. package/dist/plugins/async-hooks-stub.d.ts.map +0 -1
  345. package/dist/plugins/client-reference-dedup.d.ts.map +0 -1
  346. package/dist/routing/app-router.d.ts.map +0 -1
  347. package/dist/routing/file-matcher.d.ts.map +0 -1
  348. package/dist/routing/pages-router.d.ts.map +0 -1
  349. package/dist/routing/route-trie.d.ts.map +0 -1
  350. package/dist/routing/route-validation.d.ts.map +0 -1
  351. package/dist/routing/utils.d.ts.map +0 -1
  352. package/dist/server/api-handler.d.ts.map +0 -1
  353. package/dist/server/app-router-entry.d.ts.map +0 -1
  354. package/dist/server/dev-module-runner.d.ts.map +0 -1
  355. package/dist/server/dev-origin-check.d.ts.map +0 -1
  356. package/dist/server/dev-server.d.ts.map +0 -1
  357. package/dist/server/html.d.ts.map +0 -1
  358. package/dist/server/image-optimization.d.ts.map +0 -1
  359. package/dist/server/instrumentation.d.ts.map +0 -1
  360. package/dist/server/isr-cache.d.ts.map +0 -1
  361. package/dist/server/metadata-routes.d.ts.map +0 -1
  362. package/dist/server/middleware-codegen.d.ts.map +0 -1
  363. package/dist/server/middleware-request-headers.d.ts.map +0 -1
  364. package/dist/server/middleware.d.ts.map +0 -1
  365. package/dist/server/normalize-path.d.ts.map +0 -1
  366. package/dist/server/pages-i18n.d.ts.map +0 -1
  367. package/dist/server/prod-server.d.ts.map +0 -1
  368. package/dist/server/request-log.d.ts.map +0 -1
  369. package/dist/server/request-pipeline.d.ts.map +0 -1
  370. package/dist/server/worker-utils.d.ts.map +0 -1
  371. package/dist/shims/amp.d.ts.map +0 -1
  372. package/dist/shims/app.d.ts.map +0 -1
  373. package/dist/shims/app.js.map +0 -1
  374. package/dist/shims/cache-runtime.d.ts.map +0 -1
  375. package/dist/shims/cache.d.ts.map +0 -1
  376. package/dist/shims/client-only.d.ts.map +0 -1
  377. package/dist/shims/client-only.js.map +0 -1
  378. package/dist/shims/compat-router.d.ts.map +0 -1
  379. package/dist/shims/config.d.ts.map +0 -1
  380. package/dist/shims/constants.d.ts.map +0 -1
  381. package/dist/shims/document.d.ts.map +0 -1
  382. package/dist/shims/dynamic.d.ts.map +0 -1
  383. package/dist/shims/error-boundary.d.ts.map +0 -1
  384. package/dist/shims/error.d.ts.map +0 -1
  385. package/dist/shims/fetch-cache.d.ts.map +0 -1
  386. package/dist/shims/font-google-base.d.ts.map +0 -1
  387. package/dist/shims/font-google.d.ts.map +0 -1
  388. package/dist/shims/font-google.generated.d.ts.map +0 -1
  389. package/dist/shims/font-google.js.map +0 -1
  390. package/dist/shims/font-local.d.ts.map +0 -1
  391. package/dist/shims/form.d.ts.map +0 -1
  392. package/dist/shims/head-state.d.ts.map +0 -1
  393. package/dist/shims/head.d.ts.map +0 -1
  394. package/dist/shims/headers.d.ts.map +0 -1
  395. package/dist/shims/i18n-context.d.ts.map +0 -1
  396. package/dist/shims/i18n-state.d.ts.map +0 -1
  397. package/dist/shims/image-config.d.ts.map +0 -1
  398. package/dist/shims/image.d.ts.map +0 -1
  399. package/dist/shims/internal/api-utils.d.ts.map +0 -1
  400. package/dist/shims/internal/api-utils.js.map +0 -1
  401. package/dist/shims/internal/app-router-context.d.ts.map +0 -1
  402. package/dist/shims/internal/cookies.d.ts.map +0 -1
  403. package/dist/shims/internal/cookies.js.map +0 -1
  404. package/dist/shims/internal/parse-cookie-header.d.ts.map +0 -1
  405. package/dist/shims/internal/router-context.d.ts.map +0 -1
  406. package/dist/shims/internal/utils.d.ts.map +0 -1
  407. package/dist/shims/internal/work-unit-async-storage.d.ts.map +0 -1
  408. package/dist/shims/layout-segment-context.d.ts.map +0 -1
  409. package/dist/shims/legacy-image.d.ts.map +0 -1
  410. package/dist/shims/link.d.ts.map +0 -1
  411. package/dist/shims/metadata.d.ts.map +0 -1
  412. package/dist/shims/navigation-state.d.ts.map +0 -1
  413. package/dist/shims/navigation.d.ts.map +0 -1
  414. package/dist/shims/og.d.ts.map +0 -1
  415. package/dist/shims/og.js.map +0 -1
  416. package/dist/shims/readonly-url-search-params.d.ts.map +0 -1
  417. package/dist/shims/request-context.d.ts.map +0 -1
  418. package/dist/shims/request-state-types.d.ts.map +0 -1
  419. package/dist/shims/request-state-types.js.map +0 -1
  420. package/dist/shims/router-state.d.ts.map +0 -1
  421. package/dist/shims/router.d.ts.map +0 -1
  422. package/dist/shims/script.d.ts.map +0 -1
  423. package/dist/shims/server-only.d.ts.map +0 -1
  424. package/dist/shims/server-only.js.map +0 -1
  425. package/dist/shims/server.d.ts.map +0 -1
  426. package/dist/shims/unified-request-context.d.ts.map +0 -1
  427. package/dist/shims/url-safety.d.ts.map +0 -1
  428. package/dist/shims/url-utils.d.ts.map +0 -1
  429. package/dist/shims/web-vitals.d.ts.map +0 -1
  430. package/dist/utils/base-path.d.ts.map +0 -1
  431. package/dist/utils/domain-locale.d.ts.map +0 -1
  432. package/dist/utils/hash.d.ts.map +0 -1
  433. package/dist/utils/manifest-paths.d.ts.map +0 -1
  434. package/dist/utils/project.d.ts.map +0 -1
  435. package/dist/utils/query.d.ts.map +0 -1
package/dist/init.d.ts CHANGED
@@ -1,10 +1,11 @@
1
+ //#region src/init.d.ts
1
2
  /**
2
3
  * vinext init — one-command project migration for Next.js apps.
3
4
  *
4
5
  * Automates the steps needed to run a Next.js app under vinext:
5
6
  *
6
7
  * 1. Run `vinext check` to show compatibility report
7
- * 2. Install dependencies (vite, @vitejs/plugin-rsc for App Router)
8
+ * 2. Install dependencies (vite, @vitejs/plugin-react, and App Router deps)
8
9
  * 3. Add "type": "module" to package.json
9
10
  * 4. Rename CJS config files to .cjs
10
11
  * 5. Add vinext scripts to package.json
@@ -15,45 +16,45 @@
15
16
  * Non-destructive: does NOT modify next.config, tsconfig, or source files.
16
17
  * The project should work with both Next.js and vinext simultaneously.
17
18
  */
18
- export interface InitOptions {
19
- /** Project root directory */
20
- root: string;
21
- /** Dev server port (default: 3001) */
22
- port?: number;
23
- /** Skip the compatibility check step */
24
- skipCheck?: boolean;
25
- /** Force overwrite even if vite.config.ts exists */
26
- force?: boolean;
27
- /** @internal — override exec for testing (avoids ESM spy issues) */
28
- _exec?: (cmd: string, opts: {
29
- cwd: string;
30
- stdio: string;
31
- }) => void;
19
+ interface InitOptions {
20
+ /** Project root directory */
21
+ root: string;
22
+ /** Dev server port (default: 3001) */
23
+ port?: number;
24
+ /** Skip the compatibility check step */
25
+ skipCheck?: boolean;
26
+ /** Force overwrite even if vite.config.ts exists */
27
+ force?: boolean;
28
+ /** @internal — override exec for testing (avoids ESM spy issues) */
29
+ _exec?: (cmd: string, opts: {
30
+ cwd: string;
31
+ stdio: string;
32
+ }) => void;
32
33
  }
33
- export interface InitResult {
34
- /** Whether dependencies were installed */
35
- installedDeps: string[];
36
- /** Whether "type": "module" was added */
37
- addedTypeModule: boolean;
38
- /** CJS config files that were renamed ([old, new] pairs) */
39
- renamedConfigs: Array<[string, string]>;
40
- /** Whether scripts were added to package.json */
41
- addedScripts: string[];
42
- /** Whether vite.config.ts was generated */
43
- generatedViteConfig: boolean;
44
- /** Whether vite.config.ts generation was skipped (already exists) */
45
- skippedViteConfig: boolean;
46
- /** Whether .gitignore was updated to include /dist/ */
47
- updatedGitignore: boolean;
34
+ interface InitResult {
35
+ /** Whether dependencies were installed */
36
+ installedDeps: string[];
37
+ /** Whether "type": "module" was added */
38
+ addedTypeModule: boolean;
39
+ /** CJS config files that were renamed ([old, new] pairs) */
40
+ renamedConfigs: Array<[string, string]>;
41
+ /** Whether scripts were added to package.json */
42
+ addedScripts: string[];
43
+ /** Whether vite.config.ts was generated */
44
+ generatedViteConfig: boolean;
45
+ /** Whether vite.config.ts generation was skipped (already exists) */
46
+ skippedViteConfig: boolean;
47
+ /** Whether .gitignore was updated to include /dist/ */
48
+ updatedGitignore: boolean;
48
49
  }
49
- export declare function generateViteConfig(_isAppRouter: boolean): string;
50
+ declare function generateViteConfig(_isAppRouter: boolean): string;
50
51
  /**
51
52
  * Add vinext scripts to package.json without overwriting existing scripts.
52
53
  * Returns the list of script names that were added.
53
54
  */
54
- export declare function addScripts(root: string, port: number): string[];
55
- export declare function getInitDeps(isAppRouter: boolean): string[];
56
- export declare function isDepInstalled(root: string, dep: string): boolean;
55
+ declare function addScripts(root: string, port: number): string[];
56
+ declare function getInitDeps(isAppRouter: boolean): string[];
57
+ declare function isDepInstalled(root: string, dep: string): boolean;
57
58
  /**
58
59
  * Check if react/react-dom need upgrading for react-server-dom-webpack compatibility.
59
60
  *
@@ -68,11 +69,13 @@ export declare function isDepInstalled(root: string, dep: string): boolean;
68
69
  *
69
70
  * Returns ["react@latest", "react-dom@latest"] if upgrade is needed, [] otherwise.
70
71
  */
71
- export declare function getReactUpgradeDeps(root: string): string[];
72
+ declare function getReactUpgradeDeps(root: string): string[];
72
73
  /**
73
74
  * Ensure /dist/ is listed in .gitignore. Creates the file if it doesn't exist.
74
75
  * Returns true if the file was modified (or created), false if /dist/ was already present.
75
76
  */
76
- export declare function updateGitignore(root: string): boolean;
77
- export declare function init(options: InitOptions): Promise<InitResult>;
77
+ declare function updateGitignore(root: string): boolean;
78
+ declare function init(options: InitOptions): Promise<InitResult>;
79
+ //#endregion
80
+ export { InitOptions, InitResult, addScripts, generateViteConfig, getInitDeps, getReactUpgradeDeps, init, isDepInstalled, updateGitignore };
78
81
  //# sourceMappingURL=init.d.ts.map
package/dist/init.js CHANGED
@@ -1,29 +1,29 @@
1
- /**
2
- * vinext init one-command project migration for Next.js apps.
3
- *
4
- * Automates the steps needed to run a Next.js app under vinext:
5
- *
6
- * 1. Run `vinext check` to show compatibility report
7
- * 2. Install dependencies (vite, @vitejs/plugin-rsc for App Router)
8
- * 3. Add "type": "module" to package.json
9
- * 4. Rename CJS config files to .cjs
10
- * 5. Add vinext scripts to package.json
11
- * 6. Generate vite.config.ts
12
- * 7. Update .gitignore to include /dist/
13
- * 8. Print summary
14
- *
15
- * Non-destructive: does NOT modify next.config, tsconfig, or source files.
16
- * The project should work with both Next.js and vinext simultaneously.
17
- */
1
+ import { detectPackageManager, detectPackageManagerName, ensureESModule, hasAppDir, hasViteConfig, renameCJSConfigs } from "./utils/project.js";
2
+ import { formatReport, runCheck } from "./check.js";
3
+ import { createRequire } from "node:module";
18
4
  import fs from "node:fs";
19
5
  import path from "node:path";
20
- import { createRequire } from "node:module";
21
6
  import { execFileSync } from "node:child_process";
22
- import { runCheck, formatReport } from "./check.js";
23
- import { ensureESModule, renameCJSConfigs, detectPackageManager, detectPackageManagerName, hasViteConfig, hasAppDir, } from "./utils/project.js";
24
- // ─── Vite Config Generation (minimal, non-Cloudflare) ────────────────────────
25
- export function generateViteConfig(_isAppRouter) {
26
- return `import vinext from "vinext";
7
+ //#region src/init.ts
8
+ /**
9
+ * vinext init one-command project migration for Next.js apps.
10
+ *
11
+ * Automates the steps needed to run a Next.js app under vinext:
12
+ *
13
+ * 1. Run `vinext check` to show compatibility report
14
+ * 2. Install dependencies (vite, @vitejs/plugin-react, and App Router deps)
15
+ * 3. Add "type": "module" to package.json
16
+ * 4. Rename CJS config files to .cjs
17
+ * 5. Add vinext scripts to package.json
18
+ * 6. Generate vite.config.ts
19
+ * 7. Update .gitignore to include /dist/
20
+ * 8. Print summary
21
+ *
22
+ * Non-destructive: does NOT modify next.config, tsconfig, or source files.
23
+ * The project should work with both Next.js and vinext simultaneously.
24
+ */
25
+ function generateViteConfig(_isAppRouter) {
26
+ return `import vinext from "vinext";
27
27
  import { defineConfig } from "vite";
28
28
 
29
29
  export default defineConfig({
@@ -31,257 +31,200 @@ export default defineConfig({
31
31
  });
32
32
  `;
33
33
  }
34
- // ─── Script Addition ─────────────────────────────────────────────────────────
35
34
  /**
36
- * Add vinext scripts to package.json without overwriting existing scripts.
37
- * Returns the list of script names that were added.
38
- */
39
- export function addScripts(root, port) {
40
- const pkgPath = path.join(root, "package.json");
41
- if (!fs.existsSync(pkgPath))
42
- return [];
43
- try {
44
- const raw = fs.readFileSync(pkgPath, "utf-8");
45
- const pkg = JSON.parse(raw);
46
- if (!pkg.scripts) {
47
- pkg.scripts = {};
48
- }
49
- const added = [];
50
- if (!pkg.scripts["dev:vinext"]) {
51
- pkg.scripts["dev:vinext"] = `vite dev --port ${port}`;
52
- added.push("dev:vinext");
53
- }
54
- if (!pkg.scripts["build:vinext"]) {
55
- pkg.scripts["build:vinext"] = "vite build";
56
- added.push("build:vinext");
57
- }
58
- if (added.length > 0) {
59
- fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
60
- }
61
- return added;
62
- }
63
- catch {
64
- return [];
65
- }
35
+ * Add vinext scripts to package.json without overwriting existing scripts.
36
+ * Returns the list of script names that were added.
37
+ */
38
+ function addScripts(root, port) {
39
+ const pkgPath = path.join(root, "package.json");
40
+ if (!fs.existsSync(pkgPath)) return [];
41
+ try {
42
+ const raw = fs.readFileSync(pkgPath, "utf-8");
43
+ const pkg = JSON.parse(raw);
44
+ if (!pkg.scripts) pkg.scripts = {};
45
+ const added = [];
46
+ if (!pkg.scripts["dev:vinext"]) {
47
+ pkg.scripts["dev:vinext"] = `vite dev --port ${port}`;
48
+ added.push("dev:vinext");
49
+ }
50
+ if (!pkg.scripts["build:vinext"]) {
51
+ pkg.scripts["build:vinext"] = "vite build";
52
+ added.push("build:vinext");
53
+ }
54
+ if (added.length > 0) fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
55
+ return added;
56
+ } catch {
57
+ return [];
58
+ }
66
59
  }
67
- // ─── Dependency Installation ─────────────────────────────────────────────────
68
- export function getInitDeps(isAppRouter) {
69
- const deps = ["vinext", "vite"];
70
- if (isAppRouter) {
71
- deps.push("@vitejs/plugin-rsc");
72
- deps.push("react-server-dom-webpack");
73
- }
74
- return deps;
60
+ function getInitDeps(isAppRouter) {
61
+ const deps = [
62
+ "vinext",
63
+ "vite",
64
+ "@vitejs/plugin-react"
65
+ ];
66
+ if (isAppRouter) {
67
+ deps.push("@vitejs/plugin-rsc");
68
+ deps.push("react-server-dom-webpack");
69
+ }
70
+ return deps;
75
71
  }
76
- export function isDepInstalled(root, dep) {
77
- const pkgPath = path.join(root, "package.json");
78
- if (!fs.existsSync(pkgPath))
79
- return false;
80
- try {
81
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
82
- const allDeps = {
83
- ...pkg.dependencies,
84
- ...pkg.devDependencies,
85
- ...pkg.peerDependencies,
86
- };
87
- return dep in allDeps;
88
- }
89
- catch {
90
- return false;
91
- }
72
+ function isDepInstalled(root, dep) {
73
+ const pkgPath = path.join(root, "package.json");
74
+ if (!fs.existsSync(pkgPath)) return false;
75
+ try {
76
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
77
+ return dep in {
78
+ ...pkg.dependencies,
79
+ ...pkg.devDependencies,
80
+ ...pkg.peerDependencies
81
+ };
82
+ } catch {
83
+ return false;
84
+ }
92
85
  }
93
86
  /**
94
- * Check if react/react-dom need upgrading for react-server-dom-webpack compatibility.
95
- *
96
- * react-server-dom-webpack versions are pinned to match their React version
97
- * (e.g. rsdw@19.2.4 requires react@^19.2.4). When a project has an older
98
- * React (e.g. create-next-app ships react@19.2.3), we need to upgrade
99
- * react/react-dom BEFORE installing rsdw to avoid peer-dep conflicts.
100
- *
101
- * Uses createRequire to resolve react's package.json through Node's module
102
- * resolution, which works correctly across all package managers (npm, pnpm,
103
- * yarn, Yarn PnP) and monorepo layouts with hoisting/symlinking.
104
- *
105
- * Returns ["react@latest", "react-dom@latest"] if upgrade is needed, [] otherwise.
106
- */
107
- export function getReactUpgradeDeps(root) {
108
- try {
109
- const req = createRequire(path.join(root, "package.json"));
110
- // Resolve react's entry, then walk up to its package.json.
111
- // We can't use require.resolve("react/package.json") because not all
112
- // packages export ./package.json in their exports map.
113
- const resolved = req.resolve("react");
114
- const version = findPackageVersion(resolved, "react");
115
- if (!version)
116
- return [];
117
- // react-server-dom-webpack@latest currently requires react@^19.2.4
118
- const parts = version.split(".");
119
- const major = parseInt(parts[0], 10);
120
- const minor = parseInt(parts[1], 10);
121
- const patch = parseInt(parts[2], 10);
122
- if (major < 19 || (major === 19 && minor < 2) || (major === 19 && minor === 2 && patch < 4)) {
123
- return ["react@latest", "react-dom@latest"];
124
- }
125
- return [];
126
- }
127
- catch {
128
- return [];
129
- }
87
+ * Check if react/react-dom need upgrading for react-server-dom-webpack compatibility.
88
+ *
89
+ * react-server-dom-webpack versions are pinned to match their React version
90
+ * (e.g. rsdw@19.2.4 requires react@^19.2.4). When a project has an older
91
+ * React (e.g. create-next-app ships react@19.2.3), we need to upgrade
92
+ * react/react-dom BEFORE installing rsdw to avoid peer-dep conflicts.
93
+ *
94
+ * Uses createRequire to resolve react's package.json through Node's module
95
+ * resolution, which works correctly across all package managers (npm, pnpm,
96
+ * yarn, Yarn PnP) and monorepo layouts with hoisting/symlinking.
97
+ *
98
+ * Returns ["react@latest", "react-dom@latest"] if upgrade is needed, [] otherwise.
99
+ */
100
+ function getReactUpgradeDeps(root) {
101
+ try {
102
+ const version = findPackageVersion(createRequire(path.join(root, "package.json")).resolve("react"), "react");
103
+ if (!version) return [];
104
+ const parts = version.split(".");
105
+ const major = parseInt(parts[0], 10);
106
+ const minor = parseInt(parts[1], 10);
107
+ const patch = parseInt(parts[2], 10);
108
+ if (major < 19 || major === 19 && minor < 2 || major === 19 && minor === 2 && patch < 4) return ["react@latest", "react-dom@latest"];
109
+ return [];
110
+ } catch {
111
+ return [];
112
+ }
130
113
  }
131
114
  /**
132
- * Walk up from a resolved module entry to find its package.json and return
133
- * the version field. Uses the same approach as PR #18's findReactServerPackages.
134
- */
115
+ * Walk up from a resolved module entry to find its package.json and return
116
+ * the version field. Uses the same approach as PR #18's findReactServerPackages.
117
+ */
135
118
  function findPackageVersion(resolvedEntry, packageName) {
136
- let dir = path.dirname(resolvedEntry);
137
- while (dir !== path.dirname(dir)) {
138
- const candidate = path.join(dir, "package.json");
139
- try {
140
- const pkg = JSON.parse(fs.readFileSync(candidate, "utf-8"));
141
- if (pkg.name === packageName) {
142
- return pkg.version ?? null;
143
- }
144
- }
145
- catch {
146
- // no package.json at this level, keep walking up
147
- }
148
- dir = path.dirname(dir);
149
- }
150
- return null;
119
+ let dir = path.dirname(resolvedEntry);
120
+ while (dir !== path.dirname(dir)) {
121
+ const candidate = path.join(dir, "package.json");
122
+ try {
123
+ const pkg = JSON.parse(fs.readFileSync(candidate, "utf-8"));
124
+ if (pkg.name === packageName) return pkg.version ?? null;
125
+ } catch {}
126
+ dir = path.dirname(dir);
127
+ }
128
+ return null;
151
129
  }
152
130
  function installDeps(root, deps, exec, { dev = true } = {}) {
153
- if (deps.length === 0)
154
- return;
155
- const baseCmd = detectPackageManager(root);
156
- // Strip " -D" for non-dev installs (keeps deps in "dependencies", not "devDependencies")
157
- const installCmd = dev ? baseCmd : baseCmd.replace(/ -D$/, "");
158
- const depsStr = deps.join(" ");
159
- exec(`${installCmd} ${depsStr}`, {
160
- cwd: root,
161
- stdio: "inherit",
162
- });
131
+ if (deps.length === 0) return;
132
+ const baseCmd = detectPackageManager(root);
133
+ exec(`${dev ? baseCmd : baseCmd.replace(/ -D$/, "")} ${deps.join(" ")}`, {
134
+ cwd: root,
135
+ stdio: "inherit"
136
+ });
163
137
  }
164
- // ─── .gitignore Update ───────────────────────────────────────────────────────
165
138
  /**
166
- * Ensure /dist/ is listed in .gitignore. Creates the file if it doesn't exist.
167
- * Returns true if the file was modified (or created), false if /dist/ was already present.
168
- */
169
- export function updateGitignore(root) {
170
- const gitignorePath = path.join(root, ".gitignore");
171
- const exactEntry = "/dist/";
172
- let content = "";
173
- if (fs.existsSync(gitignorePath)) {
174
- content = fs.readFileSync(gitignorePath, "utf-8");
175
- // Check if dist is already covered — match /dist/, dist/, or dist (all common variants)
176
- const lines = content.split("\n").map((l) => l.trim());
177
- if (lines.includes(exactEntry) || lines.includes("dist/") || lines.includes("dist")) {
178
- return false;
179
- }
180
- }
181
- // Append /dist/ with a trailing newline, ensuring we don't merge with an existing last line
182
- const separator = content.length > 0 && !content.endsWith("\n") ? "\n" : "";
183
- fs.writeFileSync(gitignorePath, content + separator + exactEntry + "\n", "utf-8");
184
- return true;
139
+ * Ensure /dist/ is listed in .gitignore. Creates the file if it doesn't exist.
140
+ * Returns true if the file was modified (or created), false if /dist/ was already present.
141
+ */
142
+ function updateGitignore(root) {
143
+ const gitignorePath = path.join(root, ".gitignore");
144
+ const exactEntry = "/dist/";
145
+ let content = "";
146
+ if (fs.existsSync(gitignorePath)) {
147
+ content = fs.readFileSync(gitignorePath, "utf-8");
148
+ const lines = content.split("\n").map((l) => l.trim());
149
+ if (lines.includes(exactEntry) || lines.includes("dist/") || lines.includes("dist")) return false;
150
+ }
151
+ const separator = content.length > 0 && !content.endsWith("\n") ? "\n" : "";
152
+ fs.writeFileSync(gitignorePath, content + separator + exactEntry + "\n", "utf-8");
153
+ return true;
185
154
  }
186
- // ─── Main Entry ──────────────────────────────────────────────────────────────
187
- export async function init(options) {
188
- const root = path.resolve(options.root);
189
- const port = options.port ?? 3001;
190
- const exec = options._exec ??
191
- ((cmd, opts) => {
192
- const [program, ...args] = cmd.split(" ");
193
- execFileSync(program, args, { ...opts, shell: true });
194
- });
195
- // ── Pre-flight checks ──────────────────────────────────────────────────
196
- // Ensure package.json exists
197
- const pkgPath = path.join(root, "package.json");
198
- if (!fs.existsSync(pkgPath)) {
199
- console.error(" Error: No package.json found in the current directory.");
200
- console.error(" Run this command from the root of a Next.js project.\n");
201
- process.exit(1);
202
- }
203
- // Check if vite.config already exists — skip generation later, but continue
204
- const viteConfigExists = hasViteConfig(root);
205
- const isApp = hasAppDir(root);
206
- const pmName = detectPackageManagerName(root);
207
- // ── Step 1: Compatibility check ────────────────────────────────────────
208
- if (!options.skipCheck) {
209
- console.log(" Running compatibility check...\n");
210
- const checkResult = runCheck(root);
211
- console.log(formatReport(checkResult, { calledFromInit: true }));
212
- console.log(); // blank line before migration steps
213
- }
214
- // ── Step 2: Install dependencies ───────────────────────────────────────
215
- const neededDeps = getInitDeps(isApp);
216
- const missingDeps = neededDeps.filter((dep) => !isDepInstalled(root, dep));
217
- // For App Router: react-server-dom-webpack requires react/react-dom versions
218
- // to match exactly (e.g. rsdw@19.2.4 needs react@^19.2.4). If the installed
219
- // React is too old (common with create-next-app), upgrade it first as a
220
- // regular dependency to avoid ERESOLVE peer-dep conflicts.
221
- if (isApp && missingDeps.includes("react-server-dom-webpack")) {
222
- const reactUpgrade = getReactUpgradeDeps(root);
223
- if (reactUpgrade.length > 0) {
224
- console.log(` Upgrading ${reactUpgrade.map((d) => d.replace(/@latest$/, "")).join(", ")}...`);
225
- installDeps(root, reactUpgrade, exec, { dev: false });
226
- }
227
- }
228
- if (missingDeps.length > 0) {
229
- console.log(` Installing ${missingDeps.join(", ")}...`);
230
- installDeps(root, missingDeps, exec);
231
- console.log();
232
- }
233
- // ── Step 3: Add "type": "module" ───────────────────────────────────────
234
- // Rename CJS configs first (before adding "type": "module") to avoid breakage
235
- const renamedConfigs = renameCJSConfigs(root);
236
- const addedTypeModule = ensureESModule(root);
237
- // ── Step 4: Add scripts ────────────────────────────────────────────────
238
- const addedScripts = addScripts(root, port);
239
- // ── Step 5: Generate vite.config.ts ────────────────────────────────────
240
- let generatedViteConfig = false;
241
- const skippedViteConfig = viteConfigExists && !options.force;
242
- if (!skippedViteConfig) {
243
- const configContent = generateViteConfig(isApp);
244
- fs.writeFileSync(path.join(root, "vite.config.ts"), configContent, "utf-8");
245
- generatedViteConfig = true;
246
- }
247
- // ── Step 6: Update .gitignore ───────────────────────────────────────
248
- const updatedGitignore = updateGitignore(root);
249
- // ── Step 7: Print summary ──────────────────────────────────────────────
250
- console.log(" vinext init complete!\n");
251
- if (missingDeps.length > 0) {
252
- console.log(` \u2713 Added ${missingDeps.join(", ")} to devDependencies`);
253
- }
254
- if (addedTypeModule) {
255
- console.log(` \u2713 Added "type": "module" to package.json`);
256
- }
257
- for (const [oldName, newName] of renamedConfigs) {
258
- console.log(` \u2713 Renamed ${oldName} \u2192 ${newName}`);
259
- }
260
- for (const script of addedScripts) {
261
- console.log(` \u2713 Added ${script} script`);
262
- }
263
- if (generatedViteConfig) {
264
- console.log(` \u2713 Generated vite.config.ts`);
265
- }
266
- if (skippedViteConfig) {
267
- console.log(` - Skipped vite.config.ts (already exists, use --force to overwrite)`);
268
- }
269
- if (updatedGitignore) {
270
- console.log(` \u2713 Added /dist/ to .gitignore`);
271
- }
272
- console.log(`
155
+ async function init(options) {
156
+ const root = path.resolve(options.root);
157
+ const port = options.port ?? 3001;
158
+ const exec = options._exec ?? ((cmd, opts) => {
159
+ const [program, ...args] = cmd.split(" ");
160
+ execFileSync(program, args, {
161
+ ...opts,
162
+ shell: true
163
+ });
164
+ });
165
+ const pkgPath = path.join(root, "package.json");
166
+ if (!fs.existsSync(pkgPath)) {
167
+ console.error(" Error: No package.json found in the current directory.");
168
+ console.error(" Run this command from the root of a Next.js project.\n");
169
+ process.exit(1);
170
+ }
171
+ const viteConfigExists = hasViteConfig(root);
172
+ const isApp = hasAppDir(root);
173
+ const pmName = detectPackageManagerName(root);
174
+ if (!options.skipCheck) {
175
+ console.log(" Running compatibility check...\n");
176
+ const checkResult = runCheck(root);
177
+ console.log(formatReport(checkResult, { calledFromInit: true }));
178
+ console.log();
179
+ }
180
+ const missingDeps = getInitDeps(isApp).filter((dep) => !isDepInstalled(root, dep));
181
+ if (isApp && missingDeps.includes("react-server-dom-webpack")) {
182
+ const reactUpgrade = getReactUpgradeDeps(root);
183
+ if (reactUpgrade.length > 0) {
184
+ console.log(` Upgrading ${reactUpgrade.map((d) => d.replace(/@latest$/, "")).join(", ")}...`);
185
+ installDeps(root, reactUpgrade, exec, { dev: false });
186
+ }
187
+ }
188
+ if (missingDeps.length > 0) {
189
+ console.log(` Installing ${missingDeps.join(", ")}...`);
190
+ installDeps(root, missingDeps, exec);
191
+ console.log();
192
+ }
193
+ const renamedConfigs = renameCJSConfigs(root);
194
+ const addedTypeModule = ensureESModule(root);
195
+ const addedScripts = addScripts(root, port);
196
+ let generatedViteConfig = false;
197
+ const skippedViteConfig = viteConfigExists && !options.force;
198
+ if (!skippedViteConfig) {
199
+ const configContent = generateViteConfig(isApp);
200
+ fs.writeFileSync(path.join(root, "vite.config.ts"), configContent, "utf-8");
201
+ generatedViteConfig = true;
202
+ }
203
+ const updatedGitignore = updateGitignore(root);
204
+ console.log(" vinext init complete!\n");
205
+ if (missingDeps.length > 0) console.log(` \u2713 Added ${missingDeps.join(", ")} to devDependencies`);
206
+ if (addedTypeModule) console.log(` \u2713 Added "type": "module" to package.json`);
207
+ for (const [oldName, newName] of renamedConfigs) console.log(` \u2713 Renamed ${oldName} \u2192 ${newName}`);
208
+ for (const script of addedScripts) console.log(` \u2713 Added ${script} script`);
209
+ if (generatedViteConfig) console.log(` \u2713 Generated vite.config.ts`);
210
+ if (skippedViteConfig) console.log(` - Skipped vite.config.ts (already exists, use --force to overwrite)`);
211
+ if (updatedGitignore) console.log(` \u2713 Added /dist/ to .gitignore`);
212
+ console.log(`
273
213
  Next steps:
274
214
  ${pmName} run dev:vinext Start the vinext dev server
275
215
  ${pmName} run dev Start Next.js (still works as before)
276
216
  `);
277
- return {
278
- installedDeps: missingDeps,
279
- addedTypeModule,
280
- renamedConfigs,
281
- addedScripts,
282
- generatedViteConfig,
283
- skippedViteConfig,
284
- updatedGitignore,
285
- };
217
+ return {
218
+ installedDeps: missingDeps,
219
+ addedTypeModule,
220
+ renamedConfigs,
221
+ addedScripts,
222
+ generatedViteConfig,
223
+ skippedViteConfig,
224
+ updatedGitignore
225
+ };
286
226
  }
227
+ //#endregion
228
+ export { addScripts, generateViteConfig, getInitDeps, getReactUpgradeDeps, init, isDepInstalled, updateGitignore };
229
+
287
230
  //# sourceMappingURL=init.js.map