vinext 1.0.0-beta.4 → 1.0.0-beta.6

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 (460) hide show
  1. package/README.md +44 -3
  2. package/dist/build/client-build-config.d.ts +0 -1
  3. package/dist/build/css-url-assets.d.ts +0 -1
  4. package/dist/build/google-fonts/build-url.d.ts +5 -2
  5. package/dist/build/google-fonts/font-metadata.d.ts +7 -3
  6. package/dist/build/google-fonts/get-axes.d.ts +0 -1
  7. package/dist/build/layout-classification.d.ts +7 -4
  8. package/dist/build/next-client-runtime-manifests.d.ts +0 -1
  9. package/dist/build/next-client-runtime-manifests.js +2 -19
  10. package/dist/build/nitro-route-rules.d.ts +0 -1
  11. package/dist/build/pages-client-assets-module.d.ts +0 -1
  12. package/dist/build/precompress.d.ts +7 -2
  13. package/dist/build/precompress.js +41 -7
  14. package/dist/build/prerender-paths.d.ts +2 -2
  15. package/dist/build/prerender-paths.js +3 -4
  16. package/dist/build/prerender-phase.d.ts +15 -0
  17. package/dist/build/prerender-phase.js +37 -0
  18. package/dist/build/prerender-server-entry.d.ts +1 -1
  19. package/dist/build/prerender-server-entry.js +3 -3
  20. package/dist/build/prerender-server-pool.d.ts +4 -2
  21. package/dist/build/prerender-server-pool.js +2 -0
  22. package/dist/build/prerender.d.ts +40 -33
  23. package/dist/build/prerender.js +99 -18
  24. package/dist/build/public-dir-conflict.d.ts +14 -0
  25. package/dist/build/public-dir-conflict.js +25 -0
  26. package/dist/build/report.d.ts +2 -2
  27. package/dist/build/route-classification-injector.d.ts +0 -1
  28. package/dist/build/route-classification-manifest.d.ts +5 -3
  29. package/dist/build/run-prerender.d.ts +3 -2
  30. package/dist/build/run-prerender.js +9 -6
  31. package/dist/build/static-export.d.ts +23 -12
  32. package/dist/cache/cache-adapters-virtual.d.ts +5 -2
  33. package/dist/check.js +4 -4
  34. package/dist/cli-dev-config.d.ts +0 -1
  35. package/dist/cli.d.ts +1 -1
  36. package/dist/client/client-rewrite-matcher.d.ts +12 -0
  37. package/dist/client/client-rewrite-matcher.js +20 -0
  38. package/dist/client/client-rewrites.d.ts +31 -0
  39. package/dist/client/client-rewrites.js +41 -0
  40. package/dist/client/dev-error-overlay.d.ts +0 -1
  41. package/dist/client/empty-module.d.ts +1 -1
  42. package/dist/client/index.d.ts +2 -0
  43. package/dist/client/index.js +2 -0
  44. package/dist/client/instrumentation-client-state.d.ts +0 -1
  45. package/dist/client/navigation-runtime.d.ts +6 -1
  46. package/dist/client/navigation-runtime.js +5 -1
  47. package/dist/client/pages-router-link-navigation.d.ts +3 -21
  48. package/dist/client/react-instance-bootstrap.d.ts +1 -0
  49. package/dist/client/react-instance-bootstrap.js +7 -0
  50. package/dist/client/react-instance.d.ts +13 -0
  51. package/dist/client/react-instance.js +20 -0
  52. package/dist/client/vinext-next-data.d.ts +13 -6
  53. package/dist/client/window-next.d.ts +5 -2
  54. package/dist/config/config-matchers.d.ts +3 -5
  55. package/dist/config/config-matchers.js +7 -6
  56. package/dist/config/dotenv.d.ts +1 -5
  57. package/dist/config/next-config.d.ts +113 -54
  58. package/dist/config/next-config.js +27 -7
  59. package/dist/config/prerender.d.ts +0 -1
  60. package/dist/deps/.pnpm/image-size@2.0.2/deps/image-size/dist/index.js +808 -0
  61. package/dist/entries/app-browser-entry.d.ts +0 -1
  62. package/dist/entries/app-browser-entry.js +8 -3
  63. package/dist/entries/app-rsc-entry.d.ts +30 -16
  64. package/dist/entries/app-rsc-entry.js +48 -10
  65. package/dist/entries/app-rsc-manifest.d.ts +0 -1
  66. package/dist/entries/app-rsc-manifest.js +1 -0
  67. package/dist/entries/pages-client-entry.d.ts +0 -1
  68. package/dist/entries/pages-client-entry.js +15 -5
  69. package/dist/entries/pages-server-entry.d.ts +1 -2
  70. package/dist/entries/pages-server-entry.js +21 -5
  71. package/dist/image/image-adapters-virtual.d.ts +4 -2
  72. package/dist/index.d.ts +0 -1
  73. package/dist/index.js +328 -227
  74. package/dist/init-cloudflare.d.ts +0 -1
  75. package/dist/init-platform.d.ts +0 -1
  76. package/dist/init.d.ts +40 -20
  77. package/dist/plugins/ast-scope.d.ts +0 -1
  78. package/dist/plugins/async-hooks-stub.d.ts +0 -1
  79. package/dist/plugins/client-reference-dedup.d.ts +0 -1
  80. package/dist/plugins/css-data-url.d.ts +0 -1
  81. package/dist/plugins/css-module-imports.d.ts +0 -1
  82. package/dist/plugins/dynamic-preload-metadata.d.ts +0 -1
  83. package/dist/plugins/extensionless-dynamic-import.d.ts +0 -1
  84. package/dist/plugins/extensionless-dynamic-import.js +352 -13
  85. package/dist/plugins/fonts.d.ts +0 -1
  86. package/dist/plugins/ignore-dynamic-requests.d.ts +0 -1
  87. package/dist/plugins/ignore-dynamic-requests.js +28 -4
  88. package/dist/plugins/import-meta-url.d.ts +0 -1
  89. package/dist/plugins/instrumentation-client.d.ts +0 -1
  90. package/dist/plugins/middleware-server-only.d.ts +0 -1
  91. package/dist/plugins/og-asset-ownership.d.ts +0 -1
  92. package/dist/plugins/og-assets.d.ts +0 -1
  93. package/dist/plugins/optimize-imports.d.ts +0 -1
  94. package/dist/plugins/pages-node-externals.d.ts +23 -0
  95. package/dist/plugins/pages-node-externals.js +206 -0
  96. package/dist/plugins/remove-console.d.ts +0 -1
  97. package/dist/plugins/require-context.d.ts +0 -1
  98. package/dist/plugins/require-context.js +143 -26
  99. package/dist/plugins/rsc-client-reference-loaders.d.ts +0 -1
  100. package/dist/plugins/rsc-reference-validation-normalizer.d.ts +0 -1
  101. package/dist/plugins/sass.d.ts +30 -2
  102. package/dist/plugins/sass.js +64 -1
  103. package/dist/plugins/server-externals-manifest.d.ts +0 -1
  104. package/dist/plugins/strip-server-exports.d.ts +0 -1
  105. package/dist/plugins/styled-jsx.d.ts +0 -1
  106. package/dist/plugins/transitive-externals.d.ts +24 -0
  107. package/dist/plugins/transitive-externals.js +121 -0
  108. package/dist/plugins/typeof-window.d.ts +11 -1
  109. package/dist/plugins/typeof-window.js +141 -13
  110. package/dist/plugins/use-cache-callable.d.ts +12 -0
  111. package/dist/plugins/use-cache-callable.js +209 -0
  112. package/dist/plugins/wasm-module-import.d.ts +0 -1
  113. package/dist/routing/app-route-graph.d.ts +115 -56
  114. package/dist/routing/app-route-graph.js +2 -1
  115. package/dist/routing/app-router.d.ts +0 -1
  116. package/dist/routing/pages-router.d.ts +9 -5
  117. package/dist/routing/route-matching.d.ts +0 -1
  118. package/dist/routing/utils.d.ts +1 -23
  119. package/dist/routing/utils.js +1 -30
  120. package/dist/server/accept-encoding.d.ts +0 -1
  121. package/dist/server/api-handler.d.ts +0 -1
  122. package/dist/server/api-handler.js +1 -1
  123. package/dist/server/app-bfcache-identity.d.ts +9 -10
  124. package/dist/server/app-bfcache-identity.js +27 -128
  125. package/dist/server/app-browser-action-result.d.ts +0 -1
  126. package/dist/server/app-browser-client-reuse-manifest.d.ts +0 -1
  127. package/dist/server/app-browser-entry.d.ts +1 -1
  128. package/dist/server/app-browser-entry.js +46 -30
  129. package/dist/server/app-browser-history-controller.d.ts +8 -5
  130. package/dist/server/app-browser-hydration.d.ts +0 -1
  131. package/dist/server/app-browser-interception-context.d.ts +0 -1
  132. package/dist/server/app-browser-mpa-navigation.d.ts +0 -1
  133. package/dist/server/app-browser-navigation-controller.d.ts +2 -5
  134. package/dist/server/app-browser-popstate.d.ts +0 -1
  135. package/dist/server/app-browser-prefetch-response.d.ts +17 -1
  136. package/dist/server/app-browser-prefetch-response.js +23 -1
  137. package/dist/server/app-browser-server-action-client.d.ts +1 -1
  138. package/dist/server/app-browser-server-action-client.js +3 -2
  139. package/dist/server/app-browser-server-action-navigation.d.ts +0 -1
  140. package/dist/server/app-browser-state.d.ts +4 -3
  141. package/dist/server/app-browser-state.js +2 -4
  142. package/dist/server/app-browser-stream.d.ts +0 -1
  143. package/dist/server/app-browser-visible-commit.d.ts +1 -1
  144. package/dist/server/app-browser-visible-commit.js +6 -2
  145. package/dist/server/app-elements-wire.d.ts +16 -13
  146. package/dist/server/app-elements-wire.js +37 -10
  147. package/dist/server/app-elements.d.ts +2 -3
  148. package/dist/server/app-elements.js +2 -2
  149. package/dist/server/app-fallback-renderer.d.ts +8 -4
  150. package/dist/server/app-fallback-renderer.js +2 -1
  151. package/dist/server/app-history-state.d.ts +2 -2
  152. package/dist/server/app-history-state.js +1 -1
  153. package/dist/server/app-hook-warning-suppression.d.ts +0 -1
  154. package/dist/server/app-layout-param-observation.d.ts +0 -1
  155. package/dist/server/app-layout-param-observation.js +1 -1
  156. package/dist/server/app-middleware.d.ts +5 -1
  157. package/dist/server/app-middleware.js +96 -31
  158. package/dist/server/app-optimistic-routing.d.ts +1 -0
  159. package/dist/server/app-page-boundary-render.d.ts +8 -4
  160. package/dist/server/app-page-boundary-render.js +4 -7
  161. package/dist/server/app-page-cache-finalizer.d.ts +3 -3
  162. package/dist/server/app-page-cache-finalizer.js +45 -19
  163. package/dist/server/app-page-cache-render.d.ts +3 -2
  164. package/dist/server/app-page-cache-render.js +5 -2
  165. package/dist/server/app-page-cache.d.ts +3 -4
  166. package/dist/server/app-page-cache.js +33 -15
  167. package/dist/server/app-page-dispatch.d.ts +11 -5
  168. package/dist/server/app-page-dispatch.js +11 -6
  169. package/dist/server/app-page-element-builder.d.ts +61 -19
  170. package/dist/server/app-page-element-builder.js +113 -43
  171. package/dist/server/app-page-execution.d.ts +12 -5
  172. package/dist/server/app-page-execution.js +20 -7
  173. package/dist/server/app-page-head.d.ts +2 -2
  174. package/dist/server/app-page-http-access-fallback-metadata.d.ts +2 -2
  175. package/dist/server/app-page-params.d.ts +0 -1
  176. package/dist/server/app-page-ppr-runtime.d.ts +0 -1
  177. package/dist/server/app-page-probe.d.ts +4 -3
  178. package/dist/server/app-page-probe.js +1 -1
  179. package/dist/server/app-page-render-identity.d.ts +1 -0
  180. package/dist/server/app-page-render-observation.d.ts +0 -1
  181. package/dist/server/app-page-render.d.ts +6 -4
  182. package/dist/server/app-page-render.js +53 -25
  183. package/dist/server/app-page-request.d.ts +3 -1
  184. package/dist/server/app-page-request.js +3 -34
  185. package/dist/server/app-page-response.d.ts +13 -3
  186. package/dist/server/app-page-response.js +17 -11
  187. package/dist/server/app-page-route-wiring.d.ts +27 -5
  188. package/dist/server/app-page-route-wiring.js +110 -58
  189. package/dist/server/app-page-search-params-observation.d.ts +0 -1
  190. package/dist/server/app-page-segment-plan.d.ts +56 -0
  191. package/dist/server/app-page-segment-plan.js +177 -0
  192. package/dist/server/app-page-segment-state.d.ts +18 -2
  193. package/dist/server/app-page-segment-state.js +23 -4
  194. package/dist/server/app-page-stream.d.ts +31 -10
  195. package/dist/server/app-page-stream.js +10 -3
  196. package/dist/server/app-pages-bridge.d.ts +0 -1
  197. package/dist/server/app-pages-bridge.js +12 -1
  198. package/dist/server/app-post-middleware-context.d.ts +0 -1
  199. package/dist/server/app-ppr-fallback-shell-render.d.ts +0 -1
  200. package/dist/server/app-prerender-endpoints.d.ts +1 -1
  201. package/dist/server/app-prerender-endpoints.js +12 -0
  202. package/dist/server/app-prerender-static-params.d.ts +0 -1
  203. package/dist/server/app-render-dependency.d.ts +11 -4
  204. package/dist/server/app-render-dependency.js +59 -9
  205. package/dist/server/app-request-context.d.ts +1 -0
  206. package/dist/server/app-response-header-provenance.d.ts +13 -0
  207. package/dist/server/app-response-header-provenance.js +26 -0
  208. package/dist/server/app-route-handler-cache.d.ts +3 -2
  209. package/dist/server/app-route-handler-cache.js +7 -3
  210. package/dist/server/app-route-handler-dispatch.d.ts +0 -1
  211. package/dist/server/app-route-handler-dispatch.js +4 -2
  212. package/dist/server/app-route-handler-execution.d.ts +2 -2
  213. package/dist/server/app-route-handler-execution.js +15 -7
  214. package/dist/server/app-route-handler-policy.d.ts +1 -1
  215. package/dist/server/app-route-handler-response.d.ts +3 -2
  216. package/dist/server/app-route-handler-response.js +15 -5
  217. package/dist/server/app-route-handler-runtime.d.ts +1 -2
  218. package/dist/server/app-route-handler-runtime.js +218 -85
  219. package/dist/server/app-route-module-loader.d.ts +32 -6
  220. package/dist/server/app-route-module-loader.js +73 -3
  221. package/dist/server/app-route-request-built-ins.d.ts +16 -0
  222. package/dist/server/app-route-request-built-ins.js +41 -0
  223. package/dist/server/app-router-entry.d.ts +0 -1
  224. package/dist/server/app-router-entry.js +4 -4
  225. package/dist/server/app-rsc-cache-busting.d.ts +2 -1
  226. package/dist/server/app-rsc-cache-busting.js +24 -16
  227. package/dist/server/app-rsc-handler.d.ts +9 -2
  228. package/dist/server/app-rsc-handler.js +176 -47
  229. package/dist/server/app-rsc-redirect-flight.d.ts +0 -1
  230. package/dist/server/app-rsc-request-normalization.d.ts +19 -10
  231. package/dist/server/app-rsc-response-finalizer.d.ts +7 -2
  232. package/dist/server/app-rsc-response-finalizer.js +34 -18
  233. package/dist/server/app-rsc-route-matching.d.ts +6 -1
  234. package/dist/server/app-rsc-route-matching.js +47 -2
  235. package/dist/server/app-rsc-state-fingerprint.d.ts +14 -0
  236. package/dist/server/app-rsc-state-fingerprint.js +13 -0
  237. package/dist/server/app-segment-config.d.ts +0 -1
  238. package/dist/server/app-server-action-execution.d.ts +41 -8
  239. package/dist/server/app-server-action-execution.js +191 -113
  240. package/dist/server/app-ssr-entry.d.ts +11 -3
  241. package/dist/server/app-ssr-entry.js +19 -8
  242. package/dist/server/app-ssr-router-instance.d.ts +0 -1
  243. package/dist/server/app-ssr-stream.d.ts +13 -2
  244. package/dist/server/app-ssr-stream.js +30 -5
  245. package/dist/server/app-static-generation.d.ts +0 -1
  246. package/dist/server/app-visited-response-cache.d.ts +1 -1
  247. package/dist/server/before-interactive-head.d.ts +0 -1
  248. package/dist/server/before-interactive-head.js +2 -0
  249. package/dist/server/bfcache-identity.d.ts +45 -0
  250. package/dist/server/bfcache-identity.js +52 -0
  251. package/dist/server/cache-control.d.ts +11 -7
  252. package/dist/server/cache-control.js +23 -11
  253. package/dist/server/cache-proof.d.ts +0 -1
  254. package/dist/server/client-reuse-manifest.d.ts +0 -1
  255. package/dist/server/config-headers.d.ts +6 -2
  256. package/dist/server/config-headers.js +19 -3
  257. package/dist/server/csp.d.ts +0 -1
  258. package/dist/server/default-global-error-module.d.ts +0 -1
  259. package/dist/server/default-global-not-found-module.d.ts +0 -1
  260. package/dist/server/default-not-found-module.d.ts +0 -1
  261. package/dist/server/dev-lockfile.d.ts +21 -9
  262. package/dist/server/dev-module-runner.d.ts +0 -1
  263. package/dist/server/dev-route-files.d.ts +0 -1
  264. package/dist/server/dev-server.d.ts +4 -8
  265. package/dist/server/dev-server.js +54 -105
  266. package/dist/server/dev-stack-sourcemap.d.ts +0 -1
  267. package/dist/server/document-initial-head.d.ts +12 -2
  268. package/dist/server/document-initial-head.js +17 -2
  269. package/dist/server/file-based-metadata.d.ts +0 -1
  270. package/dist/server/headers.d.ts +21 -2
  271. package/dist/server/headers.js +23 -2
  272. package/dist/server/http-conditional.d.ts +22 -0
  273. package/dist/server/http-conditional.js +117 -0
  274. package/dist/server/http-date.d.ts +5 -0
  275. package/dist/server/http-date.js +73 -0
  276. package/dist/server/http-error-responses.d.ts +3 -2
  277. package/dist/server/http-error-responses.js +21 -4
  278. package/dist/server/http-range.d.ts +25 -0
  279. package/dist/server/http-range.js +67 -0
  280. package/dist/server/image-optimization.d.ts +14 -6
  281. package/dist/server/image-optimization.js +0 -1
  282. package/dist/server/instrumentation.d.ts +7 -4
  283. package/dist/server/isr-cache.d.ts +28 -6
  284. package/dist/server/isr-cache.js +19 -13
  285. package/dist/server/isr-decision.d.ts +6 -4
  286. package/dist/server/metadata-route-build-data.d.ts +0 -1
  287. package/dist/server/metadata-route-build-data.js +1 -1
  288. package/dist/server/metadata-route-cache-policy.d.ts +6 -0
  289. package/dist/server/metadata-route-cache-policy.js +6 -0
  290. package/dist/server/metadata-route-response.d.ts +26 -2
  291. package/dist/server/metadata-route-response.js +225 -11
  292. package/dist/server/metadata-routes.d.ts +34 -16
  293. package/dist/server/metadata-routes.js +1 -1
  294. package/dist/server/middleware-matcher-pattern.d.ts +0 -1
  295. package/dist/server/middleware-matcher.d.ts +8 -3
  296. package/dist/server/middleware-matcher.js +23 -18
  297. package/dist/server/middleware-response-headers.js +4 -2
  298. package/dist/server/middleware-runtime.d.ts +6 -1
  299. package/dist/server/middleware-runtime.js +91 -28
  300. package/dist/server/middleware.d.ts +0 -1
  301. package/dist/server/navigation-planner.d.ts +1 -1
  302. package/dist/server/next-error-digest.d.ts +0 -1
  303. package/dist/server/pages-api-route.d.ts +0 -1
  304. package/dist/server/pages-api-route.js +30 -5
  305. package/dist/server/pages-asset-tags.d.ts +2 -1
  306. package/dist/server/pages-data-route.d.ts +14 -6
  307. package/dist/server/pages-data-route.js +19 -10
  308. package/dist/server/pages-dev-hydration.js +14 -4
  309. package/dist/server/pages-dev-stylesheets.d.ts +10 -0
  310. package/dist/server/pages-dev-stylesheets.js +150 -0
  311. package/dist/server/pages-document-initial-props.d.ts +10 -6
  312. package/dist/server/pages-get-initial-props.d.ts +2 -2
  313. package/dist/server/pages-i18n.d.ts +1 -7
  314. package/dist/server/pages-node-compat.d.ts +11 -2
  315. package/dist/server/pages-node-compat.js +49 -2
  316. package/dist/server/pages-page-data.d.ts +21 -9
  317. package/dist/server/pages-page-data.js +109 -30
  318. package/dist/server/pages-page-handler.d.ts +72 -33
  319. package/dist/server/pages-page-handler.js +25 -20
  320. package/dist/server/pages-page-response.d.ts +7 -13
  321. package/dist/server/pages-page-response.js +16 -23
  322. package/dist/server/pages-readiness.d.ts +0 -1
  323. package/dist/server/pages-request-pipeline.d.ts +20 -6
  324. package/dist/server/pages-request-pipeline.js +40 -20
  325. package/dist/server/pages-revalidate.d.ts +0 -1
  326. package/dist/server/pages-revalidate.js +1 -1
  327. package/dist/server/pages-router-entry.js +13 -9
  328. package/dist/server/prerender-cache-life-header.d.ts +11 -0
  329. package/dist/server/prerender-cache-life-header.js +18 -0
  330. package/dist/server/prerender-manifest.d.ts +11 -2
  331. package/dist/server/prerender-manifest.js +4 -1
  332. package/dist/server/prod-server.d.ts +13 -7
  333. package/dist/server/prod-server.js +280 -92
  334. package/dist/server/proxy-trust.d.ts +0 -1
  335. package/dist/server/request-log.d.ts +7 -11
  336. package/dist/server/request-pipeline.d.ts +13 -4
  337. package/dist/server/request-pipeline.js +30 -20
  338. package/dist/server/revalidation-host.d.ts +0 -1
  339. package/dist/server/revalidation-host.js +1 -1
  340. package/dist/server/rsc-completion-metadata.d.ts +15 -0
  341. package/dist/server/rsc-completion-metadata.js +183 -0
  342. package/dist/server/seed-cache.d.ts +6 -2
  343. package/dist/server/seed-cache.js +35 -8
  344. package/dist/server/skip-cache-proof.d.ts +0 -1
  345. package/dist/server/static-file-cache.d.ts +23 -9
  346. package/dist/server/static-file-cache.js +47 -23
  347. package/dist/server/static-layout-client-reuse-proof.d.ts +0 -1
  348. package/dist/server/worker-revalidation-context.d.ts +0 -1
  349. package/dist/server/worker-utils.d.ts +3 -1
  350. package/dist/server/worker-utils.js +12 -3
  351. package/dist/shims/app-router-scroll.d.ts +2 -8
  352. package/dist/shims/app.d.ts +1 -5
  353. package/dist/shims/before-interactive-context.d.ts +5 -3
  354. package/dist/shims/cache-callable-runtime.d.ts +11 -0
  355. package/dist/shims/cache-callable-runtime.js +30 -0
  356. package/dist/shims/cache-handler.d.ts +6 -1
  357. package/dist/shims/cache-handler.js +4 -2
  358. package/dist/shims/cache-request-state.d.ts +15 -1
  359. package/dist/shims/cache-request-state.js +27 -1
  360. package/dist/shims/cache-runtime.d.ts +15 -6
  361. package/dist/shims/cache-runtime.js +129 -29
  362. package/dist/shims/cache.d.ts +2 -3
  363. package/dist/shims/cache.js +2 -2
  364. package/dist/shims/cdn-cache.d.ts +18 -7
  365. package/dist/shims/cdn-cache.js +4 -2
  366. package/dist/shims/client-locale.d.ts +1 -6
  367. package/dist/shims/client-only.d.ts +1 -1
  368. package/dist/shims/compat-router.d.ts +0 -1
  369. package/dist/shims/constants.d.ts +1 -1
  370. package/dist/shims/default-global-error.d.ts +1 -4
  371. package/dist/shims/default-not-found.d.ts +0 -1
  372. package/dist/shims/document.d.ts +0 -1
  373. package/dist/shims/document.js +2 -1
  374. package/dist/shims/dynamic-preload-chunks.d.ts +0 -1
  375. package/dist/shims/dynamic.d.ts +0 -1
  376. package/dist/shims/error-boundary-navigation.d.ts +0 -1
  377. package/dist/shims/error-boundary.d.ts +7 -32
  378. package/dist/shims/error.d.ts +1 -6
  379. package/dist/shims/fetch-cache.js +115 -65
  380. package/dist/shims/font-google-base.d.ts +0 -1
  381. package/dist/shims/font-local.d.ts +0 -1
  382. package/dist/shims/font-local.js +3 -3
  383. package/dist/shims/form.d.ts +5 -3
  384. package/dist/shims/head-state.d.ts +0 -1
  385. package/dist/shims/head.d.ts +17 -5
  386. package/dist/shims/head.js +70 -8
  387. package/dist/shims/headers.d.ts +2 -2
  388. package/dist/shims/headers.js +1 -1
  389. package/dist/shims/i18n-context.d.ts +0 -1
  390. package/dist/shims/i18n-state.d.ts +0 -1
  391. package/dist/shims/image.d.ts +0 -1
  392. package/dist/shims/image.js +1 -2
  393. package/dist/shims/internal/als-registry.d.ts +31 -2
  394. package/dist/shims/internal/als-registry.js +50 -2
  395. package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +17 -2
  396. package/dist/shims/internal/app-prefetch-fetch-queue.js +69 -7
  397. package/dist/shims/internal/app-route-detection.d.ts +0 -1
  398. package/dist/shims/internal/app-route-prefetch-policy.d.ts +33 -0
  399. package/dist/shims/internal/app-route-prefetch-policy.js +63 -0
  400. package/dist/shims/internal/app-router-context.d.ts +0 -1
  401. package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +1 -5
  402. package/dist/shims/internal/hybrid-client-route-owner.d.ts +0 -1
  403. package/dist/shims/internal/hybrid-client-route-owner.js +6 -8
  404. package/dist/shims/internal/interpolate-as.d.ts +3 -2
  405. package/dist/shims/internal/pages-data-target.d.ts +22 -11
  406. package/dist/shims/internal/pages-data-target.js +19 -6
  407. package/dist/shims/internal/pages-data-url.d.ts +3 -1
  408. package/dist/shims/internal/router-context.d.ts +0 -1
  409. package/dist/shims/internal/work-unit-async-storage.d.ts +4 -3
  410. package/dist/shims/internal/work-unit-async-storage.js +2 -0
  411. package/dist/shims/layout-segment-context.d.ts +2 -6
  412. package/dist/shims/legacy-image.d.ts +0 -1
  413. package/dist/shims/link.d.ts +29 -23
  414. package/dist/shims/link.js +59 -150
  415. package/dist/shims/metadata.d.ts +2 -10
  416. package/dist/shims/navigation-context-state.d.ts +4 -1
  417. package/dist/shims/navigation-state.d.ts +1 -0
  418. package/dist/shims/navigation.d.ts +65 -6
  419. package/dist/shims/navigation.js +360 -71
  420. package/dist/shims/navigation.react-server.d.ts +1 -0
  421. package/dist/shims/og.d.ts +0 -1
  422. package/dist/shims/request-context.d.ts +8 -4
  423. package/dist/shims/request-state-types.d.ts +1 -0
  424. package/dist/shims/root-params.d.ts +3 -1
  425. package/dist/shims/root-params.js +7 -1
  426. package/dist/shims/router.d.ts +44 -23
  427. package/dist/shims/router.js +184 -82
  428. package/dist/shims/script-nonce-context.d.ts +0 -1
  429. package/dist/shims/script.d.ts +25 -13
  430. package/dist/shims/server-only.d.ts +1 -1
  431. package/dist/shims/server.d.ts +1 -3
  432. package/dist/shims/server.js +7 -7
  433. package/dist/shims/slot.d.ts +22 -11
  434. package/dist/shims/slot.js +99 -19
  435. package/dist/shims/streamed-icons.d.ts +1 -3
  436. package/dist/shims/unified-request-context.d.ts +44 -4
  437. package/dist/shims/unified-request-context.js +56 -2
  438. package/dist/shims/use-merged-ref.d.ts +0 -1
  439. package/dist/shims/web-vitals.d.ts +0 -1
  440. package/dist/typegen.d.ts +1 -2
  441. package/dist/typegen.js +1 -1
  442. package/dist/utils/cache-control-metadata.d.ts +13 -1
  443. package/dist/utils/cache-control-metadata.js +17 -1
  444. package/dist/utils/client-build-manifest.d.ts +0 -1
  445. package/dist/utils/domain-locale.d.ts +1 -5
  446. package/dist/utils/encode-cache-tag.d.ts +1 -1
  447. package/dist/utils/encode-cache-tag.js +1 -1
  448. package/dist/utils/html-limited-bots.js +1 -1
  449. package/dist/utils/middleware-request-headers.d.ts +17 -5
  450. package/dist/utils/middleware-request-headers.js +32 -23
  451. package/dist/utils/precompressed-variant.d.ts +9 -0
  452. package/dist/utils/precompressed-variant.js +15 -0
  453. package/dist/utils/prerender-output-paths.d.ts +3 -1
  454. package/dist/utils/prerender-output-paths.js +6 -1
  455. package/dist/utils/project.d.ts +12 -7
  456. package/dist/utils/public-file-path.d.ts +5 -0
  457. package/dist/utils/public-file-path.js +12 -0
  458. package/dist/utils/public-routes.d.ts +1 -1
  459. package/dist/utils/public-routes.js +6 -5
  460. package/package.json +10 -6
@@ -1,5 +1,4 @@
1
1
  import { CloudflareInitOptions } from "./init-platform.js";
2
-
3
2
  //#region src/init-cloudflare.d.ts
4
3
  type CloudflareProjectInfo = {
5
4
  root: string;
@@ -1,5 +1,4 @@
1
1
  import { Readable, Writable } from "node:stream";
2
-
3
2
  //#region src/init-platform.d.ts
4
3
  type InitPlatform = "cloudflare" | "node";
5
4
  type InitDataCache = "kv" | "none";
package/dist/init.d.ts CHANGED
@@ -1,33 +1,53 @@
1
1
  import { CloudflareInitOptions, InitPlatform } from "./init-platform.js";
2
2
  import { getReactUpgradeDeps } from "./utils/react-version.js";
3
-
4
3
  //#region src/init.d.ts
5
4
  type InitOptions = {
6
- /** Project root directory */root: string; /** Dev server port (default: 3001), or false to omit the port flag. */
7
- port?: number | false; /** Skip the compatibility check step */
8
- skipCheck?: boolean; /** Force overwrite even if vite.config.ts exists */
9
- force?: boolean; /** Deployment target selected by the user */
10
- platform?: InitPlatform; /** Configure build-time pre-rendering for all discovered static routes */
11
- prerender?: boolean; /** Cloudflare cache and image choices. */
12
- cloudflare?: CloudflareInitOptions; /** Install missing dependencies with the detected package manager (default: true). */
13
- install?: boolean; /** Script naming style (default: namespaced, e.g. dev:vinext). */
14
- scriptNames?: "namespaced" | "standard"; /** @internal — override exec for testing (avoids ESM spy issues) */
5
+ /** Project root directory */
6
+ root: string;
7
+ /** Dev server port (default: 3001), or false to omit the port flag. */
8
+ port?: number | false;
9
+ /** Skip the compatibility check step */
10
+ skipCheck?: boolean;
11
+ /** Force overwrite even if vite.config.ts exists */
12
+ force?: boolean;
13
+ /** Deployment target selected by the user */
14
+ platform?: InitPlatform;
15
+ /** Configure build-time pre-rendering for all discovered static routes */
16
+ prerender?: boolean;
17
+ /** Cloudflare cache and image choices. */
18
+ cloudflare?: CloudflareInitOptions;
19
+ /** Install missing dependencies with the detected package manager (default: true). */
20
+ install?: boolean;
21
+ /** Script naming style (default: namespaced, e.g. dev:vinext). */
22
+ scriptNames?: "namespaced" | "standard";
23
+ /** @internal — override exec for testing (avoids ESM spy issues) */
15
24
  _exec?: (cmd: string, opts: {
16
25
  cwd: string;
17
26
  stdio: string;
18
- }) => string | void | Promise<string | void>; /** @internal — override pnpm ignored-builds inspection for testing */
19
- _inspectPnpmIgnoredBuilds?: (root: string) => string; /** @internal — stable compatibility date for snapshot tests */
27
+ }) => string | void | Promise<string | void>;
28
+ /** @internal — override pnpm ignored-builds inspection for testing */
29
+ _inspectPnpmIgnoredBuilds?: (root: string) => string;
30
+ /** @internal — stable compatibility date for snapshot tests */
20
31
  _today?: string;
21
32
  };
22
33
  type InitResult = {
23
- /** Whether dependencies were installed */installedDeps: string[]; /** Whether "type": "module" was added */
24
- addedTypeModule: boolean; /** CJS config files that were renamed ([old, new] pairs) */
25
- renamedConfigs: Array<[string, string]>; /** Whether scripts were added to package.json */
26
- addedScripts: string[]; /** Whether vite.config.ts was generated */
27
- generatedViteConfig: boolean; /** Whether vite.config.ts generation was skipped (already exists) */
28
- skippedViteConfig: boolean; /** Whether .gitignore was updated to include vinext-generated output */
29
- updatedGitignore: boolean; /** Deployment target configured by init */
30
- platform: InitPlatform; /** Platform-specific deployment files generated by init */
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 vinext-generated output */
47
+ updatedGitignore: boolean;
48
+ /** Deployment target configured by init */
49
+ platform: InitPlatform;
50
+ /** Platform-specific deployment files generated by init */
31
51
  generatedPlatformFiles: string[];
32
52
  };
33
53
  declare function generateViteConfig(_isAppRouter: boolean, prerender?: boolean): string;
@@ -1,5 +1,4 @@
1
1
  import { AstRecord } from "./ast-utils.js";
2
-
3
2
  //#region src/plugins/ast-scope.d.ts
4
3
  type AstScope = {
5
4
  parent: AstScope | null;
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "vite";
2
-
3
2
  //#region src/plugins/async-hooks-stub.d.ts
4
3
  /**
5
4
  * Stubs node:async_hooks in client (browser) builds.
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "vite";
2
-
3
2
  //#region src/plugins/client-reference-dedup.d.ts
4
3
  type ReadPackageJson = (path: string) => Promise<string>;
5
4
  type ClientReferenceDedupOptions = {
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "vite";
2
-
3
2
  //#region src/plugins/css-data-url.d.ts
4
3
  declare function dataUrlCssPlugin(): Plugin;
5
4
  //#endregion
@@ -1,6 +1,5 @@
1
1
  import { Plugin } from "vite";
2
2
  import MagicString from "magic-string";
3
-
4
3
  //#region src/plugins/css-module-imports.d.ts
5
4
  type ScriptLanguage = "js" | "jsx" | "ts" | "tsx";
6
5
  declare function rewriteCssModuleNamespaceImports(code: string, lang?: ScriptLanguage): {
@@ -1,6 +1,5 @@
1
1
  import { Plugin } from "vite";
2
2
  import MagicString from "magic-string";
3
-
4
3
  //#region src/plugins/dynamic-preload-metadata.d.ts
5
4
  type TransformResult = {
6
5
  code: string;
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "vite";
2
-
3
2
  //#region src/plugins/extensionless-dynamic-import.d.ts
4
3
  declare function createExtensionlessDynamicImportPlugin(): Plugin;
5
4
  //#endregion
@@ -1,5 +1,10 @@
1
+ import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
2
+ import { escapeRegExp } from "../utils/regex.js";
3
+ import { isUnknownRecord } from "../utils/record.js";
1
4
  import { DYNAMIC_IMPORT_PRESCAN, forEachAstChild, hasRange, isAstRecord, nodeArray } from "./ast-utils.js";
2
5
  import { createTransformCache } from "./transform-cache.js";
6
+ import { createRequire } from "node:module";
7
+ import fs from "node:fs";
3
8
  import { parseAst } from "vite";
4
9
  import MagicString from "magic-string";
5
10
  //#region src/plugins/extensionless-dynamic-import.ts
@@ -23,13 +28,24 @@ const TRANSFORMABLE_EXTENSIONS = /* @__PURE__ */ new Set([
23
28
  ".cts"
24
29
  ]);
25
30
  function createExtensionlessDynamicImportPlugin() {
26
- let moduleExtensions = MODULE_EXTENSIONS;
31
+ let transformConfig = {
32
+ aliases: [],
33
+ moduleExtensions: MODULE_EXTENSIONS,
34
+ exportConditions: /* @__PURE__ */ new Set([
35
+ "import",
36
+ "module",
37
+ "node",
38
+ "development",
39
+ "default"
40
+ ])
41
+ };
42
+ const environmentConfigs = /* @__PURE__ */ new WeakMap();
27
43
  const cached = createTransformCache();
28
44
  return {
29
45
  name: "vinext:extensionless-dynamic-import",
30
46
  enforce: "pre",
31
47
  configResolved(config) {
32
- moduleExtensions = getModuleExtensions(config);
48
+ transformConfig = createTransformConfig(config);
33
49
  },
34
50
  transform: {
35
51
  filter: {
@@ -40,12 +56,18 @@ function createExtensionlessDynamicImportPlugin() {
40
56
  code: DYNAMIC_IMPORT_PRESCAN
41
57
  },
42
58
  handler(code, id) {
43
- return cached(id, code, moduleExtensions, () => transformExtensionlessImports(code, id, moduleExtensions));
59
+ const environmentConfig = this.environment?.config;
60
+ let activeConfig = transformConfig;
61
+ if (environmentConfig) {
62
+ activeConfig = environmentConfigs.get(environmentConfig) ?? createTransformConfig(environmentConfig);
63
+ environmentConfigs.set(environmentConfig, activeConfig);
64
+ }
65
+ return cached(id, code, activeConfig, () => transformExtensionlessImports(code, id, activeConfig));
44
66
  }
45
67
  }
46
68
  };
47
69
  }
48
- function transformExtensionlessImports(code, id, moduleExtensions) {
70
+ function transformExtensionlessImports(code, id, config) {
49
71
  const lang = langForId(id);
50
72
  let ast;
51
73
  try {
@@ -53,12 +75,12 @@ function transformExtensionlessImports(code, id, moduleExtensions) {
53
75
  } catch {
54
76
  return null;
55
77
  }
56
- const imports = collectExtensionlessImports(ast, code, moduleExtensions);
78
+ const imports = collectExtensionlessImports(ast, code, config, id);
57
79
  if (imports.length === 0) return null;
58
80
  const output = new MagicString(code);
59
81
  for (const dynamicImport of imports) {
60
82
  const source = code.slice(dynamicImport.sourceStart, dynamicImport.sourceEnd);
61
- output.overwrite(dynamicImport.start, dynamicImport.end, buildReplacement(source, dynamicImport.globPattern, dynamicImport.moduleExtensions));
83
+ output.overwrite(dynamicImport.start, dynamicImport.end, dynamicImport.kind === "package" ? buildPackageReplacement(source, dynamicImport.resolution) : buildReplacement(source, dynamicImport.globPattern, dynamicImport.moduleExtensions));
62
84
  }
63
85
  return {
64
86
  code: output.toString(),
@@ -75,11 +97,11 @@ function langForId(id) {
75
97
  if (ext === ".tsx") return "tsx";
76
98
  return "jsx";
77
99
  }
78
- function collectExtensionlessImports(ast, code, moduleExtensions) {
100
+ function collectExtensionlessImports(ast, code, config, id) {
79
101
  const imports = [];
80
102
  function visit(value) {
81
103
  if (!isAstRecord(value)) return;
82
- const parsed = parseExtensionlessImport(value, code, moduleExtensions);
104
+ const parsed = parseExtensionlessImport(value, code, config, id);
83
105
  if (parsed) {
84
106
  imports.push(parsed);
85
107
  return;
@@ -89,7 +111,7 @@ function collectExtensionlessImports(ast, code, moduleExtensions) {
89
111
  visit(ast);
90
112
  return imports;
91
113
  }
92
- function parseExtensionlessImport(node, code, moduleExtensions) {
114
+ function parseExtensionlessImport(node, code, config, id) {
93
115
  if (node.type !== "ImportExpression" || !hasRange(node)) return null;
94
116
  if (node.options != null) return null;
95
117
  const source = node.source;
@@ -100,22 +122,308 @@ function parseExtensionlessImport(node, code, moduleExtensions) {
100
122
  const texts = quasiTexts;
101
123
  const first = texts[0];
102
124
  if (!isImportPrefix(code.slice(node.start, source.start))) return null;
103
- if (!(first.startsWith("./") || first.startsWith("../"))) return null;
104
125
  if (texts.some((text) => /[*?[\]{}()!?#]/.test(text))) return null;
126
+ if (!(first.startsWith("./") || first.startsWith("../"))) {
127
+ const resolution = resolvePackageImport(first, texts, id, config.exportConditions, config.aliases);
128
+ return resolution ? {
129
+ kind: "package",
130
+ start: node.start,
131
+ end: node.end,
132
+ sourceStart: source.start,
133
+ sourceEnd: source.end,
134
+ resolution
135
+ } : null;
136
+ }
105
137
  if (texts.slice(1).some((text) => text.includes("."))) return null;
106
138
  const directoryEnd = first.lastIndexOf("/") + 1;
107
139
  const directory = first.slice(0, directoryEnd);
108
140
  const filenamePrefix = first.slice(directoryEnd);
109
141
  if (filenamePrefix.includes(".")) return null;
110
142
  return {
143
+ kind: "relative",
111
144
  start: node.start,
112
145
  end: node.end,
113
146
  sourceStart: source.start,
114
147
  sourceEnd: source.end,
115
148
  globPattern: filenamePrefix.length > 0 ? [`${first}*`, `${first}*/**/*`] : `${directory}**/*`,
116
- moduleExtensions
149
+ moduleExtensions: config.moduleExtensions
150
+ };
151
+ }
152
+ function resolvePackageImport(first, texts, id, exportConditions, aliases) {
153
+ const packageName = parsePackageName(first);
154
+ if (packageName === null || first === packageName || !first.startsWith(`${packageName}/`)) return null;
155
+ if (aliasesMayMatch(aliases, [first, ...texts.slice(1)].join("*"))) return null;
156
+ const packageInfo = resolvePackageInfo(packageName, id);
157
+ if (packageInfo === null || !isUnknownRecord(packageInfo.packageJson.exports)) return null;
158
+ const requestPattern = `./${[first.slice(packageName.length + 1), ...texts.slice(1)].join("*")}`;
159
+ const matchedExport = findBestPackageExport(packageInfo.packageJson.exports, requestPattern);
160
+ if (matchedExport === null) return null;
161
+ const { keyMatch, exportValue } = matchedExport;
162
+ for (const target of resolveExportTargets(exportValue, exportConditions)) {
163
+ if (!target.startsWith("./")) continue;
164
+ const targetParts = decodePackageTarget(target);
165
+ if (targetParts === null) continue;
166
+ const [targetPrefix, targetSuffix] = targetParts;
167
+ const decodedCapture = decodeRequestCapturePattern(keyMatch.capture);
168
+ if (decodedCapture === null) continue;
169
+ const absoluteGlob = path.resolve(packageInfo.packageRoot, `${targetPrefix.slice(2)}${decodedCapture}${targetSuffix}`);
170
+ const absolutePrefix = path.resolve(packageInfo.packageRoot, targetPrefix.slice(2));
171
+ if (!isWithinPackage(packageInfo.packageRoot, absoluteGlob) || !isWithinPackage(packageInfo.packageRoot, absolutePrefix)) continue;
172
+ const importerDirectory = resolveImporterDirectory(id);
173
+ const globPath = toImporterPath(importerDirectory, absoluteGlob);
174
+ const resolvedPrefixPath = toImporterPath(importerDirectory, absolutePrefix);
175
+ if (globPath === null || resolvedPrefixPath === null) return null;
176
+ const resolvedPrefix = resolvedPrefixPath.replace(/\/+$/, "") + (targetPrefix.endsWith("/") ? "/" : "");
177
+ const globPattern = buildPackageGlobPatterns(resolvedPrefix, decodedCapture, targetSuffix);
178
+ if (globPattern === null) return null;
179
+ return {
180
+ globPattern,
181
+ packageName,
182
+ requestPrefix: `${packageName}/${keyMatch.prefix.slice(2)}`,
183
+ requestSuffix: keyMatch.suffix,
184
+ resolvedPrefix,
185
+ resolvedSuffix: targetSuffix
186
+ };
187
+ }
188
+ return null;
189
+ }
190
+ function findBestPackageExport(exports, requestPattern) {
191
+ let best = null;
192
+ for (const [exportKey, exportValue] of Object.entries(exports)) {
193
+ const keyMatch = matchWildcardPattern(exportKey, requestPattern);
194
+ if (keyMatch === null) continue;
195
+ if (best === null || comparePatternKeys(exportKey, best.exportKey) < 0) best = {
196
+ exportKey,
197
+ keyMatch,
198
+ exportValue
199
+ };
200
+ }
201
+ if (best === null || hasHigherPrecedenceExportIntersection(exports, requestPattern, best.exportKey)) return null;
202
+ return {
203
+ keyMatch: best.keyMatch,
204
+ exportValue: best.exportValue
205
+ };
206
+ }
207
+ function hasHigherPrecedenceExportIntersection(exports, requestPattern, selectedKey) {
208
+ for (const exportKey of Object.keys(exports)) {
209
+ if (exportKey === selectedKey || exportKey === ".") continue;
210
+ if (!exportKey.includes("*")) {
211
+ if (matchesTemplatePattern(requestPattern, exportKey)) return true;
212
+ continue;
213
+ }
214
+ if (comparePatternKeys(exportKey, selectedKey) < 0 && wildcardPatternsMayIntersect(requestPattern, exportKey)) return true;
215
+ }
216
+ return false;
217
+ }
218
+ function matchesTemplatePattern(templatePattern, value) {
219
+ const source = templatePattern.split("*").map(escapeRegExp).join(".*");
220
+ return new RegExp(`^${source}$`).test(value);
221
+ }
222
+ function wildcardPatternsMayIntersect(left, right) {
223
+ const leftBounds = wildcardPatternBounds(left);
224
+ const rightBounds = wildcardPatternBounds(right);
225
+ return (leftBounds.prefix.startsWith(rightBounds.prefix) || rightBounds.prefix.startsWith(leftBounds.prefix)) && (leftBounds.suffix.endsWith(rightBounds.suffix) || rightBounds.suffix.endsWith(leftBounds.suffix));
226
+ }
227
+ function wildcardPatternBounds(pattern) {
228
+ const firstWildcard = pattern.indexOf("*");
229
+ const lastWildcard = pattern.lastIndexOf("*");
230
+ return {
231
+ prefix: pattern.slice(0, firstWildcard),
232
+ suffix: pattern.slice(lastWildcard + 1)
117
233
  };
118
234
  }
235
+ function comparePatternKeys(left, right) {
236
+ const leftBaseLength = left.indexOf("*") + 1;
237
+ return right.indexOf("*") + 1 - leftBaseLength || right.length - left.length;
238
+ }
239
+ function parsePackageName(specifierPrefix) {
240
+ const segments = specifierPrefix.split("/");
241
+ if (specifierPrefix.startsWith("@")) return segments.length >= 2 && segments[0] && segments[1] ? `${segments[0]}/${segments[1]}` : null;
242
+ return segments[0] || null;
243
+ }
244
+ function aliasesMayMatch(aliases, requestPattern) {
245
+ const requestPrefix = requestPattern.slice(0, requestPattern.indexOf("*"));
246
+ return aliases.some((alias) => {
247
+ const { find } = alias;
248
+ if (find instanceof RegExp) return !isViteInternalAlias(alias);
249
+ if (matchesTemplatePattern(requestPattern, find)) return true;
250
+ const aliasPrefix = `${find}/`;
251
+ return requestPrefix.startsWith(aliasPrefix) || aliasPrefix.startsWith(requestPrefix);
252
+ });
253
+ }
254
+ function isViteInternalAlias(alias) {
255
+ if (!(alias.find instanceof RegExp)) return false;
256
+ const replacement = toSlash(alias.replacement);
257
+ const source = replacement.endsWith("/vite/client/env.mjs") || replacement.endsWith("/vite/dist/client/env.mjs") ? "@vite/env" : replacement.endsWith("/vite/client/client.mjs") || replacement.endsWith("/vite/dist/client/client.mjs") ? "@vite/client" : null;
258
+ if (source === null) return false;
259
+ alias.find.lastIndex = 0;
260
+ const matches = alias.find.test(source);
261
+ alias.find.lastIndex = 0;
262
+ return matches;
263
+ }
264
+ function decodePackageTarget(target) {
265
+ if (target.includes("?") || target.includes("#")) return null;
266
+ const targetParts = splitSingleWildcard(target);
267
+ if (targetParts === null) return null;
268
+ const [rawPrefix, rawSuffix] = targetParts;
269
+ if (/%[\da-f]?$/i.test(rawPrefix) || /^[\da-f]/i.test(rawSuffix)) return null;
270
+ for (const segment of target.slice(2).split("/")) {
271
+ let decodedSegment;
272
+ try {
273
+ decodedSegment = decodeURIComponent(segment);
274
+ } catch {
275
+ return null;
276
+ }
277
+ if (decodedSegment === "." || decodedSegment === ".." || decodedSegment.toLowerCase() === "node_modules" || decodedSegment.includes("/") || decodedSegment.includes("\\")) return null;
278
+ }
279
+ const wildcard = target.indexOf("*");
280
+ try {
281
+ return [decodeURIComponent(target.slice(0, wildcard)), decodeURIComponent(target.slice(wildcard + 1))];
282
+ } catch {
283
+ return null;
284
+ }
285
+ }
286
+ function decodeRequestCapturePattern(pattern) {
287
+ const parts = pattern.split("*");
288
+ for (let index = 0; index < parts.length - 1; index++) if (/%[\da-f]?$/i.test(parts[index]) || /^[\da-f]/i.test(parts[index + 1])) return null;
289
+ const decodedParts = [];
290
+ for (const part of parts) {
291
+ const decodedSegments = [];
292
+ for (const segment of part.split("/")) {
293
+ let decodedSegment;
294
+ try {
295
+ decodedSegment = decodeURIComponent(segment);
296
+ } catch {
297
+ return null;
298
+ }
299
+ if (decodedSegment.includes("/") || decodedSegment.includes("\\")) return null;
300
+ decodedSegments.push(decodedSegment);
301
+ }
302
+ decodedParts.push(decodedSegments.join("/"));
303
+ }
304
+ return decodedParts.join("*");
305
+ }
306
+ function resolvePackageInfo(packageName, id) {
307
+ const cleanId = id.split(/[?#]/, 1)[0];
308
+ const selfPackage = findNearestPackageInfo(path.dirname(cleanId), packageName);
309
+ if (selfPackage !== null) return selfPackage;
310
+ let resolver;
311
+ try {
312
+ resolver = createRequire(cleanId);
313
+ } catch {
314
+ return null;
315
+ }
316
+ try {
317
+ const entry = resolver.resolve(packageName);
318
+ const fromEntry = findPackageInfo(path.dirname(entry), packageName);
319
+ if (fromEntry !== null) return fromEntry;
320
+ } catch {}
321
+ for (const lookupPath of resolver.resolve.paths(packageName) ?? []) {
322
+ const candidate = path.join(lookupPath, packageName, "package.json");
323
+ const packageJson = readPackageJson(candidate);
324
+ if (packageJson?.name === packageName) return {
325
+ packageRoot: path.dirname(candidate),
326
+ packageJson
327
+ };
328
+ }
329
+ return null;
330
+ }
331
+ function findNearestPackageInfo(startDirectory, packageName) {
332
+ let directory = startDirectory;
333
+ while (true) {
334
+ const filename = path.join(directory, "package.json");
335
+ if (fs.existsSync(filename)) {
336
+ const packageJson = readPackageJson(filename);
337
+ return packageJson?.name === packageName ? {
338
+ packageRoot: directory,
339
+ packageJson
340
+ } : null;
341
+ }
342
+ const parent = path.dirname(directory);
343
+ if (parent === directory) return null;
344
+ directory = parent;
345
+ }
346
+ }
347
+ function findPackageInfo(startDirectory, packageName) {
348
+ let directory = startDirectory;
349
+ while (true) {
350
+ const packageJson = readPackageJson(path.join(directory, "package.json"));
351
+ if (packageJson?.name === packageName) return {
352
+ packageRoot: directory,
353
+ packageJson
354
+ };
355
+ const parent = path.dirname(directory);
356
+ if (parent === directory) return null;
357
+ directory = parent;
358
+ }
359
+ }
360
+ function readPackageJson(filename) {
361
+ try {
362
+ return JSON.parse(fs.readFileSync(filename, "utf8"));
363
+ } catch {
364
+ return null;
365
+ }
366
+ }
367
+ function resolveExportTargets(value, conditions) {
368
+ if (typeof value === "string") return [value];
369
+ if (Array.isArray(value)) return value.length === 0 ? [] : resolveExportTargets(value[0], conditions);
370
+ if (!isUnknownRecord(value)) return [];
371
+ for (const [condition, target] of Object.entries(value)) if (condition === "default" || conditions.has(condition)) return resolveExportTargets(target, conditions);
372
+ return [];
373
+ }
374
+ function matchWildcardPattern(pattern, value) {
375
+ const parts = splitSingleWildcard(pattern);
376
+ if (parts === null) return null;
377
+ const [prefix, suffix] = parts;
378
+ if (!value.startsWith(prefix) || !value.endsWith(suffix)) return null;
379
+ return {
380
+ prefix,
381
+ suffix,
382
+ capture: value.slice(prefix.length, suffix.length === 0 ? void 0 : -suffix.length)
383
+ };
384
+ }
385
+ function splitSingleWildcard(value) {
386
+ const wildcard = value.indexOf("*");
387
+ if (wildcard < 0 || wildcard !== value.lastIndexOf("*")) return null;
388
+ return [value.slice(0, wildcard), value.slice(wildcard + 1)];
389
+ }
390
+ function isWithinPackage(packageRoot, target) {
391
+ const relative = path.relative(packageRoot, target);
392
+ return relative !== ".." && !relative.startsWith("../") && !path.isAbsolute(relative);
393
+ }
394
+ function toImporterPath(importerDirectory, absolutePath) {
395
+ const relative = path.relative(importerDirectory, absolutePath);
396
+ if (path.isAbsolute(relative)) return null;
397
+ return relative.startsWith(".") ? relative : `./${relative}`;
398
+ }
399
+ const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
400
+ const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
401
+ function escapeGlobLiteral(value) {
402
+ const pattern = process.platform === "win32" ? WIN32_UNESCAPED_GLOB_SYMBOLS : POSIX_UNESCAPED_GLOB_SYMBOLS;
403
+ return value.replace(pattern, "\\$&");
404
+ }
405
+ function buildPackageGlobPatterns(resolvedPrefix, capturePattern, resolvedSuffix) {
406
+ const parts = capturePattern.split("*");
407
+ const wildcardCount = parts.length - 1;
408
+ if (wildcardCount === 0 || wildcardCount > 4) return null;
409
+ let captures = [escapeGlobLiteral(parts[0])];
410
+ for (let index = 0; index < wildcardCount; index++) {
411
+ const suffix = escapeGlobLiteral(parts[index + 1]);
412
+ captures = captures.flatMap((capture) => [`${capture}*${suffix}`, `${capture}*/**/*${suffix}`]);
413
+ }
414
+ const prefix = escapeGlobLiteral(resolvedPrefix);
415
+ const suffix = escapeGlobLiteral(resolvedSuffix);
416
+ const patterns = [...new Set(captures.map((capture) => `${prefix}${capture}${suffix}`)), `!${prefix}**/node_modules/**`];
417
+ return patterns.length === 1 ? patterns[0] : patterns;
418
+ }
419
+ function resolveImporterDirectory(id) {
420
+ const directory = path.dirname(id.split(/[?#]/, 1)[0]);
421
+ try {
422
+ return toSlash(fs.realpathSync.native(directory));
423
+ } catch {
424
+ return directory;
425
+ }
426
+ }
119
427
  function isImportPrefix(value) {
120
428
  const prefix = value.match(/^import\s*\(/)?.[0];
121
429
  if (!prefix) return false;
@@ -152,9 +460,40 @@ function templateElementText(value) {
152
460
  function getModuleExtensions(config) {
153
461
  return config.resolve.extensions.filter((extension) => extension !== ".node");
154
462
  }
463
+ function getExportConditions(config) {
464
+ const productionCondition = config.isProduction ? "production" : "development";
465
+ const conditions = /* @__PURE__ */ new Set([
466
+ "import",
467
+ "default",
468
+ productionCondition
469
+ ]);
470
+ for (const condition of config.resolve.conditions ?? []) conditions.add(condition === "development|production" ? productionCondition : condition);
471
+ return conditions;
472
+ }
473
+ function createTransformConfig(config) {
474
+ return {
475
+ aliases: config.resolve.alias ?? [],
476
+ moduleExtensions: getModuleExtensions(config),
477
+ exportConditions: getExportConditions(config)
478
+ };
479
+ }
480
+ const JAVASCRIPT_STRING_ESCAPE_MAP = {
481
+ "<": "\\u003C",
482
+ ">": "\\u003E",
483
+ "\u2028": "\\u2028",
484
+ "\u2029": "\\u2029"
485
+ };
486
+ function serializeJavaScriptValue(value) {
487
+ return JSON.stringify(value).replace(/[<>\u2028\u2029]/g, (character) => JAVASCRIPT_STRING_ESCAPE_MAP[character]);
488
+ }
155
489
  function buildReplacement(source, globPattern, moduleExtensions) {
156
- const extensions = JSON.stringify(moduleExtensions);
157
- return `((__vinextPath, __vinextModules = import.meta.glob(${JSON.stringify(globPattern)}), __vinextExtensions = ${extensions}) => { const __vinextLoader = __vinextModules[__vinextPath] ?? __vinextExtensions.map((__vinextExtension) => __vinextModules[__vinextPath + __vinextExtension]).find(Boolean) ?? __vinextExtensions.map((__vinextExtension) => __vinextModules[__vinextPath + "/index" + __vinextExtension]).find(Boolean); return __vinextLoader ? __vinextLoader() : Promise.reject(new Error("Cannot find module '" + __vinextPath + "'")); })(${source})`;
490
+ const extensions = serializeJavaScriptValue(moduleExtensions);
491
+ return `((__vinextPath, __vinextModules = import.meta.glob(${serializeJavaScriptValue(globPattern)}), __vinextExtensions = ${extensions}) => { const __vinextLoader = __vinextModules[__vinextPath] ?? __vinextExtensions.map((__vinextExtension) => __vinextModules[__vinextPath + __vinextExtension]).find(Boolean) ?? __vinextExtensions.map((__vinextExtension) => __vinextModules[__vinextPath + "/index" + __vinextExtension]).find(Boolean); return __vinextLoader ? __vinextLoader() : Promise.reject(new Error("Cannot find module '" + __vinextPath + "'")); })(${source})`;
492
+ }
493
+ function buildPackageReplacement(source, resolution) {
494
+ const captureEnd = resolution.requestSuffix ? `-${serializeJavaScriptValue(resolution.requestSuffix)}.length` : "undefined";
495
+ const packageSubpathStart = resolution.packageName.length + 1;
496
+ return `((__vinextPath, __vinextModules = import.meta.glob(${serializeJavaScriptValue(resolution.globPattern)}, { exhaustive: true })) => { const __vinextSegments = __vinextPath.slice(${packageSubpathStart}).split("/"); let __vinextDecodedSegments, __vinextCapture; try { __vinextDecodedSegments = __vinextSegments.map((__vinextSegment) => decodeURIComponent(__vinextSegment)); __vinextCapture = __vinextPath.slice(${serializeJavaScriptValue(resolution.requestPrefix)}.length, ${captureEnd}).split("/").map((__vinextSegment) => decodeURIComponent(__vinextSegment)).join("/"); } catch { return Promise.reject(new Error("Cannot find module '" + __vinextPath + "'")); } const __vinextInvalidSubpath = __vinextPath.includes("?") || __vinextPath.includes("#") || __vinextDecodedSegments.some((__vinextSegment) => __vinextSegment === "." || __vinextSegment === ".." || __vinextSegment.toLowerCase() === "node_modules" || __vinextSegment.includes("/") || __vinextSegment.includes("\\\\")); if (__vinextInvalidSubpath) return Promise.reject(new Error("Cannot find module '" + __vinextPath + "'")); const __vinextResolvedPath = (${serializeJavaScriptValue(resolution.resolvedPrefix)} + __vinextCapture + ${serializeJavaScriptValue(resolution.resolvedSuffix)}).replace(/\\/+/g, "/"); const __vinextLoader = __vinextModules[__vinextResolvedPath]; return __vinextLoader ? __vinextLoader() : Promise.reject(new Error("Cannot find module '" + __vinextPath + "'")); })(${source})`;
158
497
  }
159
498
  //#endregion
160
499
  export { createExtensionlessDynamicImportPlugin };
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "vite";
2
-
3
2
  //#region src/plugins/fonts.d.ts
4
3
  declare const VIRTUAL_GOOGLE_FONTS = "virtual:vinext-google-fonts";
5
4
  declare const RESOLVED_VIRTUAL_GOOGLE_FONTS: string;
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "vite";
2
-
3
2
  //#region src/plugins/ignore-dynamic-requests.d.ts
4
3
  declare function transformVeryDynamicRequests(code: string, id: string): {
5
4
  code: string;
@@ -43,6 +43,21 @@ function stringValue(node) {
43
43
  if ((node.type === "Literal" || node.type === "StringLiteral") && typeof node.value === "string") return node.value;
44
44
  return null;
45
45
  }
46
+ function stringFromCharCodeValue(value, scope) {
47
+ const node = unwrapExpression(value);
48
+ if (node?.type !== "CallExpression") return null;
49
+ const callee = unwrapExpression(node.callee);
50
+ const object = callee?.type === "MemberExpression" ? unwrapExpression(callee.object) : null;
51
+ const property = callee?.type === "MemberExpression" ? unwrapExpression(callee.property) : null;
52
+ if (callee?.type !== "MemberExpression" || callee.computed === true || !isIdentifierNamed(object, "String") || hasAstBinding(scope, "String") || !isIdentifierNamed(property, "fromCharCode")) return null;
53
+ let resolved = "";
54
+ for (const argument of nodeArray(node.arguments)) {
55
+ const argumentNode = unwrapExpression(argument);
56
+ if (argumentNode?.type !== "Literal" || typeof argumentNode.value !== "number" || !Number.isInteger(argumentNode.value) || argumentNode.value < 0 || argumentNode.value > 65535) return null;
57
+ resolved += String.fromCharCode(argumentNode.value);
58
+ }
59
+ return resolved;
60
+ }
46
61
  function isUnboundNumericGlobal(node, scope) {
47
62
  return node.type === "Identifier" && typeof node.name === "string" && !hasAstBinding(scope, node.name) && (isIdentifierNamed(node, "NaN") || isIdentifierNamed(node, "Infinity"));
48
63
  }
@@ -482,10 +497,19 @@ function transformVeryDynamicRequests(code, id) {
482
497
  if (node.type === "CallExpression" && hasRange(node)) {
483
498
  const callee = unwrapExpression(node.callee);
484
499
  const argumentsList = nodeArray(node.arguments);
485
- if (isIdentifierNamed(callee, "require") && !hasAstBinding(scope, "require") && argumentsList.length === 1 && astNode(argumentsList[0])?.type !== "SpreadElement" && !hasDynamicRequestIgnoreDirective(code, node, argumentsList[0]) && !requestHasStaticPart(argumentsList[0], scope)) {
486
- output.overwrite(node.start, node.end, dynamicRequireReplacement());
487
- changed = true;
488
- return;
500
+ if (isIdentifierNamed(callee, "require") && !hasAstBinding(scope, "require") && argumentsList.length === 1 && astNode(argumentsList[0])?.type !== "SpreadElement" && !hasDynamicRequestIgnoreDirective(code, node, argumentsList[0])) {
501
+ const resolvedRequest = stringFromCharCodeValue(argumentsList[0], scope);
502
+ const argument = astNode(argumentsList[0]);
503
+ if (resolvedRequest !== null && resolvedRequest.replaceAll("\\", "/") !== "/" && argument && hasRange(argument)) {
504
+ output.overwrite(argument.start, argument.end, JSON.stringify(resolvedRequest));
505
+ changed = true;
506
+ return;
507
+ }
508
+ if (!requestHasStaticPart(argumentsList[0], scope)) {
509
+ output.overwrite(node.start, node.end, dynamicRequireReplacement());
510
+ changed = true;
511
+ return;
512
+ }
489
513
  }
490
514
  }
491
515
  if (node.type === "ImportExpression" && hasRange(node) && !hasDynamicRequestIgnoreDirective(code, node, node.source) && !requestHasStaticPart(node.source, scope)) {
@@ -1,6 +1,5 @@
1
1
  import { Plugin } from "vite";
2
2
  import MagicString from "magic-string";
3
-
4
3
  //#region src/plugins/import-meta-url.d.ts
5
4
  type ImportMetaUrlEnvironment = "client" | "server";
6
5
  type RewriteResult = {