vinext 0.0.30 → 0.0.32

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 +15 -7
  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 +581 -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 +681 -571
  19. package/dist/check.js.map +1 -1
  20. package/dist/cli.d.ts +1 -15
  21. package/dist/cli.js +432 -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 +376 -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 +444 -212
  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 +86 -114
  68. package/dist/entries/pages-server-entry.js.map +1 -1
  69. package/dist/index.d.ts +92 -60
  70. package/dist/index.js +2151 -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 +160 -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 +19 -15
  112. package/dist/server/dev-server.js +543 -871
  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 +34 -59
  121. package/dist/server/instrumentation.js +112 -125
  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 +32 -47
  136. package/dist/server/middleware.js +261 -409
  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 +715 -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 +6 -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 +439 -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 +17 -20
  211. package/dist/shims/head.js +194 -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 +7 -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 +213 -164
  287. package/dist/shims/server.js +545 -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
@@ -1,497 +1,564 @@
1
- /**
2
- * next/server shim
3
- *
4
- * Provides NextRequest, NextResponse, and related types that work with
5
- * standard Web APIs (Request/Response). This means they work on Node,
6
- * Cloudflare Workers, Deno, and any WinterCG-compatible runtime.
7
- *
8
- * This is a pragmatic subset — we implement the most commonly used APIs
9
- * rather than bug-for-bug parity with Next.js internals.
10
- */
11
1
  import { encodeMiddlewareRequestHeaders } from "../server/middleware-request-headers.js";
12
2
  import { parseCookieHeader } from "./internal/parse-cookie-header.js";
13
- // ---------------------------------------------------------------------------
14
- // NextRequest
15
- // ---------------------------------------------------------------------------
16
- export class NextRequest extends Request {
17
- _nextUrl;
18
- _cookies;
19
- constructor(input, init) {
20
- // Handle the case where input is a Request object - we need to extract URL and init
21
- // to avoid Node.js undici issues with passing Request objects directly to super()
22
- if (input instanceof Request) {
23
- const req = input;
24
- super(req.url, {
25
- method: req.method,
26
- headers: req.headers,
27
- body: req.body,
28
- // @ts-expect-error - duplex is not in RequestInit type but needed for streams
29
- duplex: req.body ? "half" : undefined,
30
- ...init,
31
- });
32
- }
33
- else {
34
- super(input, init);
35
- }
36
- const url = typeof input === "string"
37
- ? new URL(input, "http://localhost")
38
- : input instanceof URL
39
- ? input
40
- : new URL(input.url, "http://localhost");
41
- this._nextUrl = new NextURL(url);
42
- this._cookies = new RequestCookies(this.headers);
43
- }
44
- get nextUrl() {
45
- return this._nextUrl;
46
- }
47
- get cookies() {
48
- return this._cookies;
49
- }
50
- /**
51
- * Client IP address. Prefers Cloudflare's trusted CF-Connecting-IP header
52
- * over the spoofable X-Forwarded-For. Returns undefined if unavailable.
53
- */
54
- get ip() {
55
- return (this.headers.get("cf-connecting-ip") ??
56
- this.headers.get("x-real-ip") ??
57
- this.headers.get("x-forwarded-for")?.split(",")[0]?.trim() ??
58
- undefined);
59
- }
60
- /**
61
- * Geolocation data. Platform-dependent (e.g., Cloudflare, Vercel).
62
- * Returns undefined if not available.
63
- */
64
- get geo() {
65
- // Check Cloudflare-style headers, Vercel-style headers
66
- const country = this.headers.get("cf-ipcountry") ?? this.headers.get("x-vercel-ip-country") ?? undefined;
67
- if (!country)
68
- return undefined;
69
- return {
70
- country,
71
- city: this.headers.get("cf-ipcity") ?? this.headers.get("x-vercel-ip-city") ?? undefined,
72
- region: this.headers.get("cf-region") ??
73
- this.headers.get("x-vercel-ip-country-region") ??
74
- undefined,
75
- latitude: this.headers.get("cf-iplatitude") ?? this.headers.get("x-vercel-ip-latitude") ?? undefined,
76
- longitude: this.headers.get("cf-iplongitude") ??
77
- this.headers.get("x-vercel-ip-longitude") ??
78
- undefined,
79
- };
80
- }
81
- /**
82
- * The build ID of the Next.js application.
83
- * Delegates to `nextUrl.buildId` to match Next.js API surface.
84
- * Can be used in middleware to detect deployment skew between client and server.
85
- */
86
- get buildId() {
87
- return this._nextUrl.buildId;
88
- }
89
- }
90
- // ---------------------------------------------------------------------------
91
- // NextResponse
92
- // ---------------------------------------------------------------------------
93
- export class NextResponse extends Response {
94
- _cookies;
95
- constructor(body, init) {
96
- super(body, init);
97
- this._cookies = new ResponseCookies(this.headers);
98
- }
99
- get cookies() {
100
- return this._cookies;
101
- }
102
- /**
103
- * Create a JSON response.
104
- */
105
- static json(body, init) {
106
- const headers = new Headers(init?.headers);
107
- if (!headers.has("content-type")) {
108
- headers.set("content-type", "application/json");
109
- }
110
- return new NextResponse(JSON.stringify(body), {
111
- ...init,
112
- headers,
113
- });
114
- }
115
- /**
116
- * Create a redirect response.
117
- */
118
- static redirect(url, init) {
119
- const status = typeof init === "number" ? init : (init?.status ?? 307);
120
- const destination = typeof url === "string" ? url : url.toString();
121
- const headers = new Headers(typeof init === "object" ? init?.headers : undefined);
122
- headers.set("Location", destination);
123
- return new NextResponse(null, { status, headers });
124
- }
125
- /**
126
- * Create a rewrite response (middleware pattern).
127
- * Sets the x-middleware-rewrite header.
128
- */
129
- static rewrite(destination, init) {
130
- const url = typeof destination === "string" ? destination : destination.toString();
131
- const headers = new Headers(init?.headers);
132
- headers.set("x-middleware-rewrite", url);
133
- if (init?.request?.headers) {
134
- encodeMiddlewareRequestHeaders(headers, init.request.headers);
135
- }
136
- return new NextResponse(null, { ...init, headers });
137
- }
138
- /**
139
- * Continue to the next handler (middleware pattern).
140
- * Sets the x-middleware-next header.
141
- */
142
- static next(init) {
143
- const headers = new Headers(init?.headers);
144
- headers.set("x-middleware-next", "1");
145
- if (init?.request?.headers) {
146
- encodeMiddlewareRequestHeaders(headers, init.request.headers);
147
- }
148
- return new NextResponse(null, { ...init, headers });
149
- }
150
- }
151
- // ---------------------------------------------------------------------------
152
- // NextURL — lightweight URL wrapper with pathname helpers
153
- // ---------------------------------------------------------------------------
154
- export class NextURL {
155
- _url;
156
- constructor(input, base) {
157
- this._url = new URL(input.toString(), base);
158
- }
159
- get href() {
160
- return this._url.href;
161
- }
162
- set href(value) {
163
- this._url.href = value;
164
- }
165
- get origin() {
166
- return this._url.origin;
167
- }
168
- get protocol() {
169
- return this._url.protocol;
170
- }
171
- set protocol(value) {
172
- this._url.protocol = value;
173
- }
174
- get username() {
175
- return this._url.username;
176
- }
177
- set username(value) {
178
- this._url.username = value;
179
- }
180
- get password() {
181
- return this._url.password;
182
- }
183
- set password(value) {
184
- this._url.password = value;
185
- }
186
- get host() {
187
- return this._url.host;
188
- }
189
- set host(value) {
190
- this._url.host = value;
191
- }
192
- get hostname() {
193
- return this._url.hostname;
194
- }
195
- set hostname(value) {
196
- this._url.hostname = value;
197
- }
198
- get port() {
199
- return this._url.port;
200
- }
201
- set port(value) {
202
- this._url.port = value;
203
- }
204
- get pathname() {
205
- return this._url.pathname;
206
- }
207
- set pathname(value) {
208
- this._url.pathname = value;
209
- }
210
- get search() {
211
- return this._url.search;
212
- }
213
- set search(value) {
214
- this._url.search = value;
215
- }
216
- get searchParams() {
217
- return this._url.searchParams;
218
- }
219
- get hash() {
220
- return this._url.hash;
221
- }
222
- set hash(value) {
223
- this._url.hash = value;
224
- }
225
- clone() {
226
- return new NextURL(this._url.href);
227
- }
228
- toString() {
229
- return this._url.toString();
230
- }
231
- /**
232
- * The build ID of the Next.js application.
233
- * Set from `generateBuildId` in next.config.js, or a random UUID if not configured.
234
- * Can be used in middleware to detect deployment skew between client and server.
235
- * Matches the Next.js API: `request.nextUrl.buildId`.
236
- */
237
- get buildId() {
238
- return process.env.__VINEXT_BUILD_ID ?? undefined;
239
- }
240
- }
241
- export class RequestCookies {
242
- _headers;
243
- _parsed;
244
- constructor(headers) {
245
- this._headers = headers;
246
- this._parsed = parseCookieHeader(headers.get("cookie") ?? "");
247
- }
248
- get(name) {
249
- const value = this._parsed.get(name);
250
- return value !== undefined ? { name, value } : undefined;
251
- }
252
- getAll(nameOrOptions) {
253
- const name = typeof nameOrOptions === "string" ? nameOrOptions : nameOrOptions?.name;
254
- return [...this._parsed.entries()]
255
- .filter(([cookieName]) => name === undefined || cookieName === name)
256
- .map(([cookieName, value]) => ({ name: cookieName, value }));
257
- }
258
- has(name) {
259
- return this._parsed.has(name);
260
- }
261
- set(nameOrOptions, value) {
262
- let cookieName;
263
- let cookieValue;
264
- if (typeof nameOrOptions === "string") {
265
- cookieName = nameOrOptions;
266
- cookieValue = value ?? "";
267
- }
268
- else {
269
- cookieName = nameOrOptions.name;
270
- cookieValue = nameOrOptions.value;
271
- }
272
- this._parsed.set(cookieName, cookieValue);
273
- this._syncHeader();
274
- return this;
275
- }
276
- delete(names) {
277
- if (Array.isArray(names)) {
278
- const results = names.map((name) => this._parsed.delete(name));
279
- this._syncHeader();
280
- return results;
281
- }
282
- const result = this._parsed.delete(names);
283
- this._syncHeader();
284
- return result;
285
- }
286
- clear() {
287
- this._parsed.clear();
288
- this._syncHeader();
289
- return this;
290
- }
291
- get size() {
292
- return this._parsed.size;
293
- }
294
- toString() {
295
- return this._serialize();
296
- }
297
- _serialize() {
298
- return [...this._parsed.entries()].map(([n, v]) => `${n}=${encodeURIComponent(v)}`).join("; ");
299
- }
300
- _syncHeader() {
301
- if (this._parsed.size === 0) {
302
- this._headers.delete("cookie");
303
- }
304
- else {
305
- this._headers.set("cookie", this._serialize());
306
- }
307
- }
308
- [Symbol.iterator]() {
309
- const entries = this.getAll().map((c) => [c.name, c]);
310
- return entries[Symbol.iterator]();
311
- }
3
+ import { getRequestExecutionContext } from "./request-context.js";
4
+ //#region src/shims/server.ts
5
+ /**
6
+ * next/server shim
7
+ *
8
+ * Provides NextRequest, NextResponse, and related types that work with
9
+ * standard Web APIs (Request/Response). This means they work on Node,
10
+ * Cloudflare Workers, Deno, and any WinterCG-compatible runtime.
11
+ *
12
+ * This is a pragmatic subset — we implement the most commonly used APIs
13
+ * rather than bug-for-bug parity with Next.js internals.
14
+ */
15
+ const _USE_CACHE_ALS_KEY = Symbol.for("vinext.cacheRuntime.contextAls");
16
+ const _UNSTABLE_CACHE_ALS_KEY = Symbol.for("vinext.unstableCache.als");
17
+ const _g = globalThis;
18
+ function _throwIfInsideCacheScope(apiName) {
19
+ if (_g[_USE_CACHE_ALS_KEY]?.getStore() != null) throw new Error(`\`${apiName}\` cannot be called inside "use cache". If you need this data inside a cached function, call \`${apiName}\` outside and pass the required data as an argument.`);
20
+ if (_g[_UNSTABLE_CACHE_ALS_KEY]?.getStore() === true) throw new Error(`\`${apiName}\` cannot be called inside a function cached with \`unstable_cache()\`. If you need this data inside a cached function, call \`${apiName}\` outside and pass the required data as an argument.`);
312
21
  }
22
+ var NextRequest = class extends Request {
23
+ _nextUrl;
24
+ _cookies;
25
+ constructor(input, init) {
26
+ const { nextConfig: _nextConfig, ...requestInit } = init ?? {};
27
+ if (input instanceof Request) {
28
+ const req = input;
29
+ super(req.url, {
30
+ method: req.method,
31
+ headers: req.headers,
32
+ body: req.body,
33
+ duplex: req.body ? "half" : void 0,
34
+ ...requestInit
35
+ });
36
+ } else super(input, requestInit);
37
+ this._nextUrl = new NextURL(typeof input === "string" ? new URL(input, "http://localhost") : input instanceof URL ? input : new URL(input.url, "http://localhost"), void 0, _nextConfig ? {
38
+ basePath: _nextConfig.basePath,
39
+ nextConfig: { i18n: _nextConfig.i18n }
40
+ } : void 0);
41
+ this._cookies = new RequestCookies(this.headers);
42
+ }
43
+ get nextUrl() {
44
+ return this._nextUrl;
45
+ }
46
+ get cookies() {
47
+ return this._cookies;
48
+ }
49
+ /**
50
+ * Client IP address. Prefers Cloudflare's trusted CF-Connecting-IP header
51
+ * over the spoofable X-Forwarded-For. Returns undefined if unavailable.
52
+ */
53
+ get ip() {
54
+ return this.headers.get("cf-connecting-ip") ?? this.headers.get("x-real-ip") ?? this.headers.get("x-forwarded-for")?.split(",")[0]?.trim() ?? void 0;
55
+ }
56
+ /**
57
+ * Geolocation data. Platform-dependent (e.g., Cloudflare, Vercel).
58
+ * Returns undefined if not available.
59
+ */
60
+ get geo() {
61
+ const country = this.headers.get("cf-ipcountry") ?? this.headers.get("x-vercel-ip-country") ?? void 0;
62
+ if (!country) return void 0;
63
+ return {
64
+ country,
65
+ city: this.headers.get("cf-ipcity") ?? this.headers.get("x-vercel-ip-city") ?? void 0,
66
+ region: this.headers.get("cf-region") ?? this.headers.get("x-vercel-ip-country-region") ?? void 0,
67
+ latitude: this.headers.get("cf-iplatitude") ?? this.headers.get("x-vercel-ip-latitude") ?? void 0,
68
+ longitude: this.headers.get("cf-iplongitude") ?? this.headers.get("x-vercel-ip-longitude") ?? void 0
69
+ };
70
+ }
71
+ /**
72
+ * The build ID of the Next.js application.
73
+ * Delegates to `nextUrl.buildId` to match Next.js API surface.
74
+ * Can be used in middleware to detect deployment skew between client and server.
75
+ */
76
+ get buildId() {
77
+ return this._nextUrl.buildId;
78
+ }
79
+ };
80
+ var NextResponse = class NextResponse extends Response {
81
+ _cookies;
82
+ constructor(body, init) {
83
+ super(body, init);
84
+ this._cookies = new ResponseCookies(this.headers);
85
+ }
86
+ get cookies() {
87
+ return this._cookies;
88
+ }
89
+ /**
90
+ * Create a JSON response.
91
+ */
92
+ static json(body, init) {
93
+ const headers = new Headers(init?.headers);
94
+ if (!headers.has("content-type")) headers.set("content-type", "application/json");
95
+ return new NextResponse(JSON.stringify(body), {
96
+ ...init,
97
+ headers
98
+ });
99
+ }
100
+ /**
101
+ * Create a redirect response.
102
+ */
103
+ static redirect(url, init) {
104
+ const status = typeof init === "number" ? init : init?.status ?? 307;
105
+ const destination = typeof url === "string" ? url : url.toString();
106
+ const headers = new Headers(typeof init === "object" ? init?.headers : void 0);
107
+ headers.set("Location", destination);
108
+ return new NextResponse(null, {
109
+ status,
110
+ headers
111
+ });
112
+ }
113
+ /**
114
+ * Create a rewrite response (middleware pattern).
115
+ * Sets the x-middleware-rewrite header.
116
+ */
117
+ static rewrite(destination, init) {
118
+ const url = typeof destination === "string" ? destination : destination.toString();
119
+ const headers = new Headers(init?.headers);
120
+ headers.set("x-middleware-rewrite", url);
121
+ if (init?.request?.headers) encodeMiddlewareRequestHeaders(headers, init.request.headers);
122
+ return new NextResponse(null, {
123
+ ...init,
124
+ headers
125
+ });
126
+ }
127
+ /**
128
+ * Continue to the next handler (middleware pattern).
129
+ * Sets the x-middleware-next header.
130
+ */
131
+ static next(init) {
132
+ const headers = new Headers(init?.headers);
133
+ headers.set("x-middleware-next", "1");
134
+ if (init?.request?.headers) encodeMiddlewareRequestHeaders(headers, init.request.headers);
135
+ return new NextResponse(null, {
136
+ ...init,
137
+ headers
138
+ });
139
+ }
140
+ };
141
+ var NextURL = class NextURL {
142
+ /** Internal URL stores the pathname WITHOUT basePath or locale prefix. */
143
+ _url;
144
+ _basePath;
145
+ _locale;
146
+ _defaultLocale;
147
+ _locales;
148
+ constructor(input, base, config) {
149
+ this._url = new URL(input.toString(), base);
150
+ this._basePath = config?.basePath ?? "";
151
+ this._stripBasePath();
152
+ const i18n = config?.nextConfig?.i18n;
153
+ if (i18n) {
154
+ this._locales = [...i18n.locales];
155
+ this._defaultLocale = i18n.defaultLocale;
156
+ this._analyzeLocale(this._locales);
157
+ }
158
+ }
159
+ /** Strip basePath prefix from the internal pathname. */
160
+ _stripBasePath() {
161
+ if (!this._basePath) return;
162
+ const { pathname } = this._url;
163
+ if (pathname === this._basePath || pathname.startsWith(this._basePath + "/")) this._url.pathname = pathname.slice(this._basePath.length) || "/";
164
+ }
165
+ /** Extract locale from pathname, stripping it from the internal URL. */
166
+ _analyzeLocale(locales) {
167
+ const segments = this._url.pathname.split("/");
168
+ const candidate = segments[1]?.toLowerCase();
169
+ const match = locales.find((l) => l.toLowerCase() === candidate);
170
+ if (match) {
171
+ this._locale = match;
172
+ this._url.pathname = "/" + segments.slice(2).join("/");
173
+ } else this._locale = this._defaultLocale;
174
+ }
175
+ /**
176
+ * Reconstruct the full pathname with basePath + locale prefix.
177
+ * Mirrors Next.js's internal formatPathname().
178
+ */
179
+ _formatPathname() {
180
+ let prefix = this._basePath;
181
+ if (this._locale && this._locale !== this._defaultLocale) prefix += "/" + this._locale;
182
+ if (!prefix) return this._url.pathname;
183
+ const inner = this._url.pathname;
184
+ return inner === "/" ? prefix : prefix + inner;
185
+ }
186
+ get href() {
187
+ const formatted = this._formatPathname();
188
+ if (formatted === this._url.pathname) return this._url.href;
189
+ const { href, pathname, search, hash } = this._url;
190
+ const baseEnd = href.length - pathname.length - search.length - hash.length;
191
+ return href.slice(0, baseEnd) + formatted + search + hash;
192
+ }
193
+ set href(value) {
194
+ this._url.href = value;
195
+ this._stripBasePath();
196
+ if (this._locales) this._analyzeLocale(this._locales);
197
+ }
198
+ get origin() {
199
+ return this._url.origin;
200
+ }
201
+ get protocol() {
202
+ return this._url.protocol;
203
+ }
204
+ set protocol(value) {
205
+ this._url.protocol = value;
206
+ }
207
+ get username() {
208
+ return this._url.username;
209
+ }
210
+ set username(value) {
211
+ this._url.username = value;
212
+ }
213
+ get password() {
214
+ return this._url.password;
215
+ }
216
+ set password(value) {
217
+ this._url.password = value;
218
+ }
219
+ get host() {
220
+ return this._url.host;
221
+ }
222
+ set host(value) {
223
+ this._url.host = value;
224
+ }
225
+ get hostname() {
226
+ return this._url.hostname;
227
+ }
228
+ set hostname(value) {
229
+ this._url.hostname = value;
230
+ }
231
+ get port() {
232
+ return this._url.port;
233
+ }
234
+ set port(value) {
235
+ this._url.port = value;
236
+ }
237
+ /** Returns the pathname WITHOUT basePath or locale prefix. */
238
+ get pathname() {
239
+ return this._url.pathname;
240
+ }
241
+ set pathname(value) {
242
+ this._url.pathname = value;
243
+ }
244
+ get search() {
245
+ return this._url.search;
246
+ }
247
+ set search(value) {
248
+ this._url.search = value;
249
+ }
250
+ get searchParams() {
251
+ return this._url.searchParams;
252
+ }
253
+ get hash() {
254
+ return this._url.hash;
255
+ }
256
+ set hash(value) {
257
+ this._url.hash = value;
258
+ }
259
+ get basePath() {
260
+ return this._basePath;
261
+ }
262
+ set basePath(value) {
263
+ this._basePath = value === "" ? "" : value.startsWith("/") ? value : "/" + value;
264
+ }
265
+ get locale() {
266
+ return this._locale ?? "";
267
+ }
268
+ set locale(value) {
269
+ if (this._locales) {
270
+ if (!value) {
271
+ this._locale = this._defaultLocale;
272
+ return;
273
+ }
274
+ if (!this._locales.includes(value)) throw new TypeError(`The locale "${value}" is not in the configured locales: ${this._locales.join(", ")}`);
275
+ }
276
+ this._locale = this._locales ? value : this._locale;
277
+ }
278
+ get defaultLocale() {
279
+ return this._defaultLocale;
280
+ }
281
+ get locales() {
282
+ return this._locales ? [...this._locales] : void 0;
283
+ }
284
+ clone() {
285
+ const config = {
286
+ basePath: this._basePath,
287
+ nextConfig: this._locales ? { i18n: {
288
+ locales: [...this._locales],
289
+ defaultLocale: this._defaultLocale
290
+ } } : void 0
291
+ };
292
+ return new NextURL(this.href, void 0, config);
293
+ }
294
+ toString() {
295
+ return this.href;
296
+ }
297
+ /**
298
+ * The build ID of the Next.js application.
299
+ * Set from `generateBuildId` in next.config.js, or a random UUID if not configured.
300
+ * Can be used in middleware to detect deployment skew between client and server.
301
+ * Matches the Next.js API: `request.nextUrl.buildId`.
302
+ */
303
+ get buildId() {
304
+ return process.env.__VINEXT_BUILD_ID ?? void 0;
305
+ }
306
+ };
307
+ var RequestCookies = class {
308
+ _headers;
309
+ _parsed;
310
+ constructor(headers) {
311
+ this._headers = headers;
312
+ this._parsed = parseCookieHeader(headers.get("cookie") ?? "");
313
+ }
314
+ get(name) {
315
+ const value = this._parsed.get(name);
316
+ return value !== void 0 ? {
317
+ name,
318
+ value
319
+ } : void 0;
320
+ }
321
+ getAll(nameOrOptions) {
322
+ const name = typeof nameOrOptions === "string" ? nameOrOptions : nameOrOptions?.name;
323
+ return [...this._parsed.entries()].filter(([cookieName]) => name === void 0 || cookieName === name).map(([cookieName, value]) => ({
324
+ name: cookieName,
325
+ value
326
+ }));
327
+ }
328
+ has(name) {
329
+ return this._parsed.has(name);
330
+ }
331
+ set(nameOrOptions, value) {
332
+ let cookieName;
333
+ let cookieValue;
334
+ if (typeof nameOrOptions === "string") {
335
+ cookieName = nameOrOptions;
336
+ cookieValue = value ?? "";
337
+ } else {
338
+ cookieName = nameOrOptions.name;
339
+ cookieValue = nameOrOptions.value;
340
+ }
341
+ this._parsed.set(cookieName, cookieValue);
342
+ this._syncHeader();
343
+ return this;
344
+ }
345
+ delete(names) {
346
+ if (Array.isArray(names)) {
347
+ const results = names.map((name) => this._parsed.delete(name));
348
+ this._syncHeader();
349
+ return results;
350
+ }
351
+ const result = this._parsed.delete(names);
352
+ this._syncHeader();
353
+ return result;
354
+ }
355
+ clear() {
356
+ this._parsed.clear();
357
+ this._syncHeader();
358
+ return this;
359
+ }
360
+ get size() {
361
+ return this._parsed.size;
362
+ }
363
+ toString() {
364
+ return this._serialize();
365
+ }
366
+ _serialize() {
367
+ return [...this._parsed.entries()].map(([n, v]) => `${n}=${encodeURIComponent(v)}`).join("; ");
368
+ }
369
+ _syncHeader() {
370
+ if (this._parsed.size === 0) this._headers.delete("cookie");
371
+ else this._headers.set("cookie", this._serialize());
372
+ }
373
+ [Symbol.iterator]() {
374
+ return this.getAll().map((c) => [c.name, c])[Symbol.iterator]();
375
+ }
376
+ };
313
377
  /**
314
- * RFC 6265 §4.1.1: cookie-name is a token (RFC 2616 §2.2).
315
- * Allowed: any visible ASCII (0x21-0x7E) except separators: ()<>@,;:\"/[]?={}
316
- */
378
+ * RFC 6265 §4.1.1: cookie-name is a token (RFC 2616 §2.2).
379
+ * Allowed: any visible ASCII (0x21-0x7E) except separators: ()<>@,;:\"/[]?={}
380
+ */
317
381
  const VALID_COOKIE_NAME_RE = /^[\x21\x23-\x27\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7A\x7C\x7E]+$/;
318
382
  function validateCookieName(name) {
319
- if (!name || !VALID_COOKIE_NAME_RE.test(name)) {
320
- throw new Error(`Invalid cookie name: ${JSON.stringify(name)}`);
321
- }
383
+ if (!name || !VALID_COOKIE_NAME_RE.test(name)) throw new Error(`Invalid cookie name: ${JSON.stringify(name)}`);
322
384
  }
323
385
  function validateCookieAttributeValue(value, attributeName) {
324
- for (let i = 0; i < value.length; i++) {
325
- const code = value.charCodeAt(i);
326
- if (code <= 0x1f || code === 0x7f || value[i] === ";") {
327
- throw new Error(`Invalid cookie ${attributeName} value: ${JSON.stringify(value)}`);
328
- }
329
- }
330
- }
331
- export class ResponseCookies {
332
- _headers;
333
- constructor(headers) {
334
- this._headers = headers;
335
- }
336
- set(name, value, options) {
337
- validateCookieName(name);
338
- const parts = [`${name}=${encodeURIComponent(value)}`];
339
- if (options?.path) {
340
- validateCookieAttributeValue(options.path, "Path");
341
- parts.push(`Path=${options.path}`);
342
- }
343
- if (options?.domain) {
344
- validateCookieAttributeValue(options.domain, "Domain");
345
- parts.push(`Domain=${options.domain}`);
346
- }
347
- if (options?.maxAge !== undefined)
348
- parts.push(`Max-Age=${options.maxAge}`);
349
- if (options?.expires)
350
- parts.push(`Expires=${options.expires.toUTCString()}`);
351
- if (options?.httpOnly)
352
- parts.push("HttpOnly");
353
- if (options?.secure)
354
- parts.push("Secure");
355
- if (options?.sameSite)
356
- parts.push(`SameSite=${options.sameSite}`);
357
- this._headers.append("Set-Cookie", parts.join("; "));
358
- return this;
359
- }
360
- get(name) {
361
- for (const header of this._headers.getSetCookie()) {
362
- const eq = header.indexOf("=");
363
- if (eq === -1)
364
- continue;
365
- const cookieName = header.slice(0, eq);
366
- if (cookieName === name) {
367
- const semi = header.indexOf(";", eq);
368
- const raw = header.slice(eq + 1, semi === -1 ? undefined : semi);
369
- let value;
370
- try {
371
- value = decodeURIComponent(raw);
372
- }
373
- catch {
374
- value = raw;
375
- }
376
- return { name, value };
377
- }
378
- }
379
- return undefined;
380
- }
381
- getAll() {
382
- const entries = [];
383
- for (const header of this._headers.getSetCookie()) {
384
- const eq = header.indexOf("=");
385
- if (eq === -1)
386
- continue;
387
- const cookieName = header.slice(0, eq);
388
- const semi = header.indexOf(";", eq);
389
- const raw = header.slice(eq + 1, semi === -1 ? undefined : semi);
390
- let value;
391
- try {
392
- value = decodeURIComponent(raw);
393
- }
394
- catch {
395
- value = raw;
396
- }
397
- entries.push({ name: cookieName, value });
398
- }
399
- return entries;
400
- }
401
- delete(name) {
402
- this.set(name, "", { maxAge: 0, path: "/" });
403
- return this;
404
- }
405
- [Symbol.iterator]() {
406
- const entries = [];
407
- for (const header of this._headers.getSetCookie()) {
408
- const eq = header.indexOf("=");
409
- if (eq === -1)
410
- continue;
411
- const cookieName = header.slice(0, eq);
412
- const semi = header.indexOf(";", eq);
413
- const raw = header.slice(eq + 1, semi === -1 ? undefined : semi);
414
- let value;
415
- try {
416
- value = decodeURIComponent(raw);
417
- }
418
- catch {
419
- value = raw;
420
- }
421
- entries.push([cookieName, { name: cookieName, value }]);
422
- }
423
- return entries[Symbol.iterator]();
424
- }
386
+ for (let i = 0; i < value.length; i++) {
387
+ const code = value.charCodeAt(i);
388
+ if (code <= 31 || code === 127 || value[i] === ";") throw new Error(`Invalid cookie ${attributeName} value: ${JSON.stringify(value)}`);
389
+ }
425
390
  }
391
+ var ResponseCookies = class {
392
+ _headers;
393
+ constructor(headers) {
394
+ this._headers = headers;
395
+ }
396
+ set(name, value, options) {
397
+ validateCookieName(name);
398
+ const parts = [`${name}=${encodeURIComponent(value)}`];
399
+ if (options?.path) {
400
+ validateCookieAttributeValue(options.path, "Path");
401
+ parts.push(`Path=${options.path}`);
402
+ }
403
+ if (options?.domain) {
404
+ validateCookieAttributeValue(options.domain, "Domain");
405
+ parts.push(`Domain=${options.domain}`);
406
+ }
407
+ if (options?.maxAge !== void 0) parts.push(`Max-Age=${options.maxAge}`);
408
+ if (options?.expires) parts.push(`Expires=${options.expires.toUTCString()}`);
409
+ if (options?.httpOnly) parts.push("HttpOnly");
410
+ if (options?.secure) parts.push("Secure");
411
+ if (options?.sameSite) parts.push(`SameSite=${options.sameSite}`);
412
+ this._headers.append("Set-Cookie", parts.join("; "));
413
+ return this;
414
+ }
415
+ get(name) {
416
+ for (const header of this._headers.getSetCookie()) {
417
+ const eq = header.indexOf("=");
418
+ if (eq === -1) continue;
419
+ if (header.slice(0, eq) === name) {
420
+ const semi = header.indexOf(";", eq);
421
+ const raw = header.slice(eq + 1, semi === -1 ? void 0 : semi);
422
+ let value;
423
+ try {
424
+ value = decodeURIComponent(raw);
425
+ } catch {
426
+ value = raw;
427
+ }
428
+ return {
429
+ name,
430
+ value
431
+ };
432
+ }
433
+ }
434
+ }
435
+ has(name) {
436
+ return this.get(name) !== void 0;
437
+ }
438
+ getAll() {
439
+ const entries = [];
440
+ for (const header of this._headers.getSetCookie()) {
441
+ const eq = header.indexOf("=");
442
+ if (eq === -1) continue;
443
+ const cookieName = header.slice(0, eq);
444
+ const semi = header.indexOf(";", eq);
445
+ const raw = header.slice(eq + 1, semi === -1 ? void 0 : semi);
446
+ let value;
447
+ try {
448
+ value = decodeURIComponent(raw);
449
+ } catch {
450
+ value = raw;
451
+ }
452
+ entries.push({
453
+ name: cookieName,
454
+ value
455
+ });
456
+ }
457
+ return entries;
458
+ }
459
+ delete(name) {
460
+ this.set(name, "", {
461
+ maxAge: 0,
462
+ path: "/"
463
+ });
464
+ return this;
465
+ }
466
+ [Symbol.iterator]() {
467
+ const entries = [];
468
+ for (const header of this._headers.getSetCookie()) {
469
+ const eq = header.indexOf("=");
470
+ if (eq === -1) continue;
471
+ const cookieName = header.slice(0, eq);
472
+ const semi = header.indexOf(";", eq);
473
+ const raw = header.slice(eq + 1, semi === -1 ? void 0 : semi);
474
+ let value;
475
+ try {
476
+ value = decodeURIComponent(raw);
477
+ } catch {
478
+ value = raw;
479
+ }
480
+ entries.push([cookieName, {
481
+ name: cookieName,
482
+ value
483
+ }]);
484
+ }
485
+ return entries[Symbol.iterator]();
486
+ }
487
+ };
426
488
  /**
427
- * Minimal NextFetchEvent — extends FetchEvent where available,
428
- * otherwise provides the waitUntil pattern standalone.
429
- */
430
- export class NextFetchEvent {
431
- sourcePage;
432
- _waitUntilPromises = [];
433
- constructor(params) {
434
- this.sourcePage = params.page;
435
- }
436
- waitUntil(promise) {
437
- this._waitUntilPromises.push(promise);
438
- }
439
- /** Drain all waitUntil promises. Returns a single promise that settles when all are done. */
440
- drainWaitUntil() {
441
- return Promise.allSettled(this._waitUntilPromises);
442
- }
443
- }
444
- // ---------------------------------------------------------------------------
445
- // Utility exports
446
- // ---------------------------------------------------------------------------
489
+ * Minimal NextFetchEvent — extends FetchEvent where available,
490
+ * otherwise provides the waitUntil pattern standalone.
491
+ */
492
+ var NextFetchEvent = class {
493
+ sourcePage;
494
+ _waitUntilPromises = [];
495
+ constructor(params) {
496
+ this.sourcePage = params.page;
497
+ }
498
+ waitUntil(promise) {
499
+ this._waitUntilPromises.push(promise);
500
+ }
501
+ /** Drain all waitUntil promises. Returns a single promise that settles when all are done. */
502
+ drainWaitUntil() {
503
+ return Promise.allSettled(this._waitUntilPromises);
504
+ }
505
+ };
447
506
  /**
448
- * Parse user agent string. Minimal implementation — for full UA parsing,
449
- * apps should use a dedicated library like `ua-parser-js`.
450
- */
451
- export function userAgentFromString(ua) {
452
- const input = ua ?? "";
453
- return {
454
- isBot: /bot|crawler|spider|crawling/i.test(input),
455
- ua: input,
456
- browser: {},
457
- device: {},
458
- engine: {},
459
- os: {},
460
- cpu: {},
461
- };
507
+ * Parse user agent string. Minimal implementation — for full UA parsing,
508
+ * apps should use a dedicated library like `ua-parser-js`.
509
+ */
510
+ function userAgentFromString(ua) {
511
+ const input = ua ?? "";
512
+ return {
513
+ isBot: /bot|crawler|spider|crawling/i.test(input),
514
+ ua: input,
515
+ browser: {},
516
+ device: {},
517
+ engine: {},
518
+ os: {},
519
+ cpu: {}
520
+ };
462
521
  }
463
- export function userAgent({ headers }) {
464
- return userAgentFromString(headers.get("user-agent") ?? undefined);
522
+ function userAgent({ headers }) {
523
+ return userAgentFromString(headers.get("user-agent") ?? void 0);
465
524
  }
466
525
  /**
467
- * after() — schedule work after the response is sent.
468
- * In a real server, this would use the platform's waitUntil.
469
- * Here we simply run it as a microtask (best-effort).
470
- */
471
- export function after(task) {
472
- const promise = typeof task === "function" ? Promise.resolve().then(task) : task;
473
- promise.catch((err) => {
474
- console.error("[vinext] after() task failed:", err);
475
- });
526
+ * after() — schedule work after the response is sent.
527
+ *
528
+ * Uses the platform's `waitUntil` (via the per-request ExecutionContext) when
529
+ * available so the task survives past the response on Cloudflare Workers.
530
+ * Falls back to a fire-and-forget microtask on runtimes without an execution
531
+ * context (e.g. Node.js dev server).
532
+ *
533
+ * Throws when called inside a cached scope — request-specific
534
+ * side-effects must not leak into cached results.
535
+ */
536
+ function after(task) {
537
+ _throwIfInsideCacheScope("after()");
538
+ const guarded = (typeof task === "function" ? Promise.resolve().then(task) : task).catch((err) => {
539
+ console.error("[vinext] after() task failed:", err);
540
+ });
541
+ getRequestExecutionContext()?.waitUntil(guarded);
476
542
  }
477
543
  /**
478
- * connection() — signals that the response requires a live connection
479
- * (not a static/cached response). Opts the page out of ISR caching
480
- * and sets Cache-Control: no-store on the response.
481
- */
482
- export async function connection() {
483
- const { markDynamicUsage, throwIfInsideCacheScope } = await import("./headers.js");
484
- throwIfInsideCacheScope("connection()");
485
- markDynamicUsage();
544
+ * connection() — signals that the response requires a live connection
545
+ * (not a static/cached response). Opts the page out of ISR caching
546
+ * and sets Cache-Control: no-store on the response.
547
+ */
548
+ async function connection() {
549
+ const { markDynamicUsage, throwIfInsideCacheScope } = await import("./headers.js");
550
+ throwIfInsideCacheScope("connection()");
551
+ markDynamicUsage();
486
552
  }
487
553
  /**
488
- * URLPattern re-export — used in middleware for route matching.
489
- * Available natively in Node 20+, Cloudflare Workers, Deno.
490
- * Falls back to urlpattern-polyfill if the global is not available.
491
- */
492
- export const URLPattern = globalThis.URLPattern ??
493
- (() => {
494
- throw new Error("URLPattern is not available in this runtime. " +
495
- "Install the `urlpattern-polyfill` package or upgrade to Node 20+.");
496
- });
554
+ * URLPattern re-export — used in middleware for route matching.
555
+ * Available natively in Node 20+, Cloudflare Workers, Deno.
556
+ * Falls back to urlpattern-polyfill if the global is not available.
557
+ */
558
+ const URLPattern = globalThis.URLPattern ?? (() => {
559
+ throw new Error("URLPattern is not available in this runtime. Install the `urlpattern-polyfill` package or upgrade to Node 20+.");
560
+ });
561
+ //#endregion
562
+ export { NextFetchEvent, NextRequest, NextResponse, NextURL, RequestCookies, ResponseCookies, URLPattern, after, connection, userAgent, userAgentFromString };
563
+
497
564
  //# sourceMappingURL=server.js.map