vinext 0.0.30 → 0.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (435) hide show
  1. package/README.md +12 -6
  2. package/dist/build/prerender.d.ts +188 -0
  3. package/dist/build/prerender.js +675 -0
  4. package/dist/build/prerender.js.map +1 -0
  5. package/dist/build/report.d.ts +45 -46
  6. package/dist/build/report.js +247 -276
  7. package/dist/build/report.js.map +1 -1
  8. package/dist/build/run-prerender.d.ts +62 -0
  9. package/dist/build/run-prerender.js +183 -0
  10. package/dist/build/run-prerender.js.map +1 -0
  11. package/dist/build/server-manifest.d.ts +19 -0
  12. package/dist/build/server-manifest.js +29 -0
  13. package/dist/build/server-manifest.js.map +1 -0
  14. package/dist/build/static-export.d.ts +51 -66
  15. package/dist/build/static-export.js +51 -545
  16. package/dist/build/static-export.js.map +1 -1
  17. package/dist/check.d.ts +26 -24
  18. package/dist/check.js +591 -571
  19. package/dist/check.js.map +1 -1
  20. package/dist/cli.d.ts +1 -15
  21. package/dist/cli.js +430 -491
  22. package/dist/cli.js.map +1 -1
  23. package/dist/client/entry.d.ts +1 -2
  24. package/dist/client/entry.js +49 -62
  25. package/dist/client/entry.js.map +1 -1
  26. package/dist/client/validate-module-path.d.ts +4 -1
  27. package/dist/client/validate-module-path.js +23 -28
  28. package/dist/client/validate-module-path.js.map +1 -1
  29. package/dist/client/vinext-next-data.d.ts +15 -20
  30. package/dist/client/vinext-next-data.js +0 -1
  31. package/dist/cloudflare/index.d.ts +3 -8
  32. package/dist/cloudflare/index.js +3 -8
  33. package/dist/cloudflare/kv-cache-handler.d.ts +95 -105
  34. package/dist/cloudflare/kv-cache-handler.js +354 -380
  35. package/dist/cloudflare/kv-cache-handler.js.map +1 -1
  36. package/dist/cloudflare/tpr.d.ts +36 -34
  37. package/dist/cloudflare/tpr.js +460 -603
  38. package/dist/cloudflare/tpr.js.map +1 -1
  39. package/dist/config/config-matchers.d.ts +31 -40
  40. package/dist/config/config-matchers.js +727 -936
  41. package/dist/config/config-matchers.js.map +1 -1
  42. package/dist/config/dotenv.d.ts +18 -11
  43. package/dist/config/dotenv.js +79 -84
  44. package/dist/config/dotenv.js.map +1 -1
  45. package/dist/config/next-config.d.ts +156 -146
  46. package/dist/config/next-config.js +374 -464
  47. package/dist/config/next-config.js.map +1 -1
  48. package/dist/deploy.d.ts +87 -96
  49. package/dist/deploy.js +490 -628
  50. package/dist/deploy.js.map +1 -1
  51. package/dist/entries/app-browser-entry.d.ts +4 -1
  52. package/dist/entries/app-browser-entry.js +12 -8
  53. package/dist/entries/app-browser-entry.js.map +1 -1
  54. package/dist/entries/app-rsc-entry.d.ts +33 -20
  55. package/dist/entries/app-rsc-entry.js +442 -211
  56. package/dist/entries/app-rsc-entry.js.map +1 -1
  57. package/dist/entries/app-ssr-entry.d.ts +9 -1
  58. package/dist/entries/app-ssr-entry.js +61 -28
  59. package/dist/entries/app-ssr-entry.js.map +1 -1
  60. package/dist/entries/pages-client-entry.d.ts +6 -2
  61. package/dist/entries/pages-client-entry.js +30 -33
  62. package/dist/entries/pages-client-entry.js.map +1 -1
  63. package/dist/entries/pages-entry-helpers.d.ts +5 -1
  64. package/dist/entries/pages-entry-helpers.js +17 -14
  65. package/dist/entries/pages-entry-helpers.js.map +1 -1
  66. package/dist/entries/pages-server-entry.d.ts +6 -2
  67. package/dist/entries/pages-server-entry.js +84 -113
  68. package/dist/entries/pages-server-entry.js.map +1 -1
  69. package/dist/index.d.ts +82 -62
  70. package/dist/index.js +2172 -3133
  71. package/dist/index.js.map +1 -1
  72. package/dist/init.d.ts +40 -37
  73. package/dist/init.js +201 -258
  74. package/dist/init.js.map +1 -1
  75. package/dist/plugins/async-hooks-stub.d.ts +7 -3
  76. package/dist/plugins/async-hooks-stub.js +39 -42
  77. package/dist/plugins/async-hooks-stub.js.map +1 -1
  78. package/dist/plugins/client-reference-dedup.d.ts +7 -3
  79. package/dist/plugins/client-reference-dedup.js +63 -88
  80. package/dist/plugins/client-reference-dedup.js.map +1 -1
  81. package/dist/routing/app-router.d.ts +100 -96
  82. package/dist/routing/app-router.js +560 -670
  83. package/dist/routing/app-router.js.map +1 -1
  84. package/dist/routing/file-matcher.d.ts +18 -15
  85. package/dist/routing/file-matcher.js +65 -65
  86. package/dist/routing/file-matcher.js.map +1 -1
  87. package/dist/routing/pages-router.d.ts +23 -24
  88. package/dist/routing/pages-router.js +147 -172
  89. package/dist/routing/pages-router.js.map +1 -1
  90. package/dist/routing/route-trie.d.ts +23 -20
  91. package/dist/routing/route-trie.js +131 -151
  92. package/dist/routing/route-trie.js.map +1 -1
  93. package/dist/routing/route-validation.d.ts +5 -2
  94. package/dist/routing/route-validation.js +98 -130
  95. package/dist/routing/route-validation.js.map +1 -1
  96. package/dist/routing/utils.d.ts +10 -7
  97. package/dist/routing/utils.js +75 -111
  98. package/dist/routing/utils.js.map +1 -1
  99. package/dist/server/api-handler.d.ts +8 -13
  100. package/dist/server/api-handler.js +161 -193
  101. package/dist/server/api-handler.js.map +1 -1
  102. package/dist/server/app-router-entry.d.ts +6 -16
  103. package/dist/server/app-router-entry.js +26 -54
  104. package/dist/server/app-router-entry.js.map +1 -1
  105. package/dist/server/dev-module-runner.d.ts +11 -64
  106. package/dist/server/dev-module-runner.js +89 -101
  107. package/dist/server/dev-module-runner.js.map +1 -1
  108. package/dist/server/dev-origin-check.d.ts +12 -10
  109. package/dist/server/dev-origin-check.js +98 -108
  110. package/dist/server/dev-origin-check.js.map +1 -1
  111. package/dist/server/dev-server.d.ts +17 -14
  112. package/dist/server/dev-server.js +542 -869
  113. package/dist/server/dev-server.js.map +1 -1
  114. package/dist/server/html.d.ts +4 -1
  115. package/dist/server/html.js +25 -26
  116. package/dist/server/html.js.map +1 -1
  117. package/dist/server/image-optimization.d.ts +31 -28
  118. package/dist/server/image-optimization.js +181 -210
  119. package/dist/server/image-optimization.js.map +1 -1
  120. package/dist/server/instrumentation.d.ts +25 -22
  121. package/dist/server/instrumentation.js +110 -122
  122. package/dist/server/instrumentation.js.map +1 -1
  123. package/dist/server/isr-cache.d.ts +16 -26
  124. package/dist/server/isr-cache.js +106 -128
  125. package/dist/server/isr-cache.js.map +1 -1
  126. package/dist/server/metadata-routes.d.ts +85 -88
  127. package/dist/server/metadata-routes.js +270 -317
  128. package/dist/server/metadata-routes.js.map +1 -1
  129. package/dist/server/middleware-codegen.d.ts +7 -4
  130. package/dist/server/middleware-codegen.js +61 -61
  131. package/dist/server/middleware-codegen.js.map +1 -1
  132. package/dist/server/middleware-request-headers.d.ts +8 -6
  133. package/dist/server/middleware-request-headers.js +47 -65
  134. package/dist/server/middleware-request-headers.js.map +1 -1
  135. package/dist/server/middleware.d.ts +31 -47
  136. package/dist/server/middleware.js +273 -404
  137. package/dist/server/middleware.js.map +1 -1
  138. package/dist/server/normalize-path.d.ts +4 -1
  139. package/dist/server/normalize-path.js +33 -47
  140. package/dist/server/normalize-path.js.map +1 -1
  141. package/dist/server/pages-i18n.d.ts +38 -30
  142. package/dist/server/pages-i18n.js +112 -139
  143. package/dist/server/pages-i18n.js.map +1 -1
  144. package/dist/server/prod-server.d.ts +19 -31
  145. package/dist/server/prod-server.js +714 -945
  146. package/dist/server/prod-server.js.map +1 -1
  147. package/dist/server/request-log.d.ts +18 -12
  148. package/dist/server/request-log.js +45 -52
  149. package/dist/server/request-log.js.map +1 -1
  150. package/dist/server/request-pipeline.d.ts +9 -17
  151. package/dist/server/request-pipeline.js +133 -184
  152. package/dist/server/request-pipeline.js.map +1 -1
  153. package/dist/server/worker-utils.d.ts +4 -1
  154. package/dist/server/worker-utils.js +31 -37
  155. package/dist/server/worker-utils.js.map +1 -1
  156. package/dist/shims/amp.d.ts +5 -2
  157. package/dist/shims/amp.js +19 -15
  158. package/dist/shims/amp.js.map +1 -1
  159. package/dist/shims/app.d.ts +8 -10
  160. package/dist/shims/app.js +0 -1
  161. package/dist/shims/cache-runtime.d.ts +20 -45
  162. package/dist/shims/cache-runtime.js +271 -422
  163. package/dist/shims/cache-runtime.js.map +1 -1
  164. package/dist/shims/cache.d.ts +130 -121
  165. package/dist/shims/cache.js +339 -427
  166. package/dist/shims/cache.js.map +1 -1
  167. package/dist/shims/client-only.d.ts +1 -18
  168. package/dist/shims/client-only.js +0 -17
  169. package/dist/shims/compat-router.d.ts +4 -1
  170. package/dist/shims/compat-router.js +23 -19
  171. package/dist/shims/compat-router.js.map +1 -1
  172. package/dist/shims/config.d.ts +7 -5
  173. package/dist/shims/config.js +16 -23
  174. package/dist/shims/config.js.map +1 -1
  175. package/dist/shims/constants.d.ts +119 -118
  176. package/dist/shims/constants.js +159 -164
  177. package/dist/shims/constants.js.map +1 -1
  178. package/dist/shims/document.d.ts +20 -16
  179. package/dist/shims/document.js +41 -22
  180. package/dist/shims/document.js.map +1 -1
  181. package/dist/shims/dynamic.d.ts +13 -22
  182. package/dist/shims/dynamic.js +122 -136
  183. package/dist/shims/dynamic.js.map +1 -1
  184. package/dist/shims/error-boundary.d.ts +22 -15
  185. package/dist/shims/error-boundary.js +81 -79
  186. package/dist/shims/error-boundary.js.map +1 -1
  187. package/dist/shims/error.d.ts +11 -12
  188. package/dist/shims/error.js +35 -39
  189. package/dist/shims/error.js.map +1 -1
  190. package/dist/shims/fetch-cache.d.ts +16 -14
  191. package/dist/shims/fetch-cache.js +437 -645
  192. package/dist/shims/fetch-cache.js.map +1 -1
  193. package/dist/shims/font-google-base.d.ts +28 -26
  194. package/dist/shims/font-google-base.js +238 -325
  195. package/dist/shims/font-google-base.js.map +1 -1
  196. package/dist/shims/font-google.d.ts +3 -3
  197. package/dist/shims/font-google.generated.d.ts +1928 -1924
  198. package/dist/shims/font-google.generated.js +1928 -2133
  199. package/dist/shims/font-google.generated.js.map +1 -1
  200. package/dist/shims/font-google.js +3 -3
  201. package/dist/shims/font-local.d.ts +28 -26
  202. package/dist/shims/font-local.js +204 -260
  203. package/dist/shims/font-local.js.map +1 -1
  204. package/dist/shims/form.d.ts +13 -27
  205. package/dist/shims/form.js +128 -180
  206. package/dist/shims/form.js.map +1 -1
  207. package/dist/shims/head-state.d.ts +8 -13
  208. package/dist/shims/head-state.js +25 -42
  209. package/dist/shims/head-state.js.map +1 -1
  210. package/dist/shims/head.d.ts +16 -20
  211. package/dist/shims/head.js +172 -250
  212. package/dist/shims/head.js.map +1 -1
  213. package/dist/shims/headers.d.ts +84 -78
  214. package/dist/shims/headers.js +447 -575
  215. package/dist/shims/headers.js.map +1 -1
  216. package/dist/shims/i18n-context.d.ts +16 -20
  217. package/dist/shims/i18n-context.js +35 -48
  218. package/dist/shims/i18n-context.js.map +1 -1
  219. package/dist/shims/i18n-state.d.ts +8 -14
  220. package/dist/shims/i18n-state.js +34 -42
  221. package/dist/shims/i18n-state.js.map +1 -1
  222. package/dist/shims/image-config.d.ts +11 -8
  223. package/dist/shims/image-config.js +50 -83
  224. package/dist/shims/image-config.js.map +1 -1
  225. package/dist/shims/image.d.ts +37 -46
  226. package/dist/shims/image.js +283 -308
  227. package/dist/shims/image.js.map +1 -1
  228. package/dist/shims/internal/api-utils.d.ts +7 -4
  229. package/dist/shims/internal/api-utils.js +0 -6
  230. package/dist/shims/internal/app-router-context.d.ts +22 -17
  231. package/dist/shims/internal/app-router-context.js +17 -13
  232. package/dist/shims/internal/app-router-context.js.map +1 -1
  233. package/dist/shims/internal/cookies.d.ts +2 -9
  234. package/dist/shims/internal/cookies.js +2 -9
  235. package/dist/shims/internal/parse-cookie-header.d.ts +4 -1
  236. package/dist/shims/internal/parse-cookie-header.js +29 -29
  237. package/dist/shims/internal/parse-cookie-header.js.map +1 -1
  238. package/dist/shims/internal/router-context.d.ts +6 -1
  239. package/dist/shims/internal/router-context.js +11 -7
  240. package/dist/shims/internal/router-context.js.map +1 -1
  241. package/dist/shims/internal/utils.d.ts +40 -37
  242. package/dist/shims/internal/utils.js +24 -30
  243. package/dist/shims/internal/utils.js.map +1 -1
  244. package/dist/shims/internal/work-unit-async-storage.d.ts +6 -10
  245. package/dist/shims/internal/work-unit-async-storage.js +14 -11
  246. package/dist/shims/internal/work-unit-async-storage.js.map +1 -1
  247. package/dist/shims/layout-segment-context.d.ts +11 -14
  248. package/dist/shims/layout-segment-context.js +24 -23
  249. package/dist/shims/layout-segment-context.js.map +1 -1
  250. package/dist/shims/legacy-image.d.ts +39 -46
  251. package/dist/shims/legacy-image.js +47 -42
  252. package/dist/shims/legacy-image.js.map +1 -1
  253. package/dist/shims/link.d.ts +32 -36
  254. package/dist/shims/link.js +255 -391
  255. package/dist/shims/link.js.map +1 -1
  256. package/dist/shims/metadata.d.ts +210 -202
  257. package/dist/shims/metadata.js +545 -546
  258. package/dist/shims/metadata.js.map +1 -1
  259. package/dist/shims/navigation-state.d.ts +10 -18
  260. package/dist/shims/navigation-state.js +66 -74
  261. package/dist/shims/navigation-state.js.map +1 -1
  262. package/dist/shims/navigation.d.ts +59 -63
  263. package/dist/shims/navigation.js +505 -704
  264. package/dist/shims/navigation.js.map +1 -1
  265. package/dist/shims/og.d.ts +2 -20
  266. package/dist/shims/og.js +2 -19
  267. package/dist/shims/readonly-url-search-params.d.ts +8 -5
  268. package/dist/shims/readonly-url-search-params.js +26 -22
  269. package/dist/shims/readonly-url-search-params.js.map +1 -1
  270. package/dist/shims/request-context.d.ts +8 -5
  271. package/dist/shims/request-context.js +50 -60
  272. package/dist/shims/request-context.js.map +1 -1
  273. package/dist/shims/request-state-types.d.ts +11 -11
  274. package/dist/shims/request-state-types.js +0 -1
  275. package/dist/shims/router-state.d.ts +13 -10
  276. package/dist/shims/router-state.js +34 -43
  277. package/dist/shims/router-state.js.map +1 -1
  278. package/dist/shims/router.d.ts +81 -85
  279. package/dist/shims/router.js +506 -628
  280. package/dist/shims/router.js.map +1 -1
  281. package/dist/shims/script.d.ts +39 -48
  282. package/dist/shims/script.js +107 -160
  283. package/dist/shims/script.js.map +1 -1
  284. package/dist/shims/server-only.d.ts +1 -19
  285. package/dist/shims/server-only.js +0 -18
  286. package/dist/shims/server.d.ts +175 -164
  287. package/dist/shims/server.js +462 -478
  288. package/dist/shims/server.js.map +1 -1
  289. package/dist/shims/unified-request-context.d.ts +20 -20
  290. package/dist/shims/unified-request-context.js +81 -99
  291. package/dist/shims/unified-request-context.js.map +1 -1
  292. package/dist/shims/url-safety.d.ts +4 -1
  293. package/dist/shims/url-safety.js +15 -11
  294. package/dist/shims/url-safety.js.map +1 -1
  295. package/dist/shims/url-utils.d.ts +8 -5
  296. package/dist/shims/url-utils.js +62 -93
  297. package/dist/shims/url-utils.js.map +1 -1
  298. package/dist/shims/web-vitals.d.ts +10 -8
  299. package/dist/shims/web-vitals.js +9 -15
  300. package/dist/shims/web-vitals.js.map +1 -1
  301. package/dist/utils/base-path.d.ts +5 -2
  302. package/dist/utils/base-path.js +21 -19
  303. package/dist/utils/base-path.js.map +1 -1
  304. package/dist/utils/domain-locale.d.ts +17 -9
  305. package/dist/utils/domain-locale.js +36 -56
  306. package/dist/utils/domain-locale.js.map +1 -1
  307. package/dist/utils/hash.d.ts +4 -1
  308. package/dist/utils/hash.js +19 -17
  309. package/dist/utils/hash.js.map +1 -1
  310. package/dist/utils/manifest-paths.d.ts +6 -3
  311. package/dist/utils/manifest-paths.js +15 -16
  312. package/dist/utils/manifest-paths.js.map +1 -1
  313. package/dist/utils/project.d.ts +13 -11
  314. package/dist/utils/project.js +169 -216
  315. package/dist/utils/project.js.map +1 -1
  316. package/dist/utils/query.d.ts +8 -6
  317. package/dist/utils/query.js +57 -67
  318. package/dist/utils/query.js.map +1 -1
  319. package/package.json +10 -9
  320. package/dist/build/report.d.ts.map +0 -1
  321. package/dist/build/static-export.d.ts.map +0 -1
  322. package/dist/check.d.ts.map +0 -1
  323. package/dist/cli.d.ts.map +0 -1
  324. package/dist/client/entry.d.ts.map +0 -1
  325. package/dist/client/validate-module-path.d.ts.map +0 -1
  326. package/dist/client/vinext-next-data.d.ts.map +0 -1
  327. package/dist/client/vinext-next-data.js.map +0 -1
  328. package/dist/cloudflare/index.d.ts.map +0 -1
  329. package/dist/cloudflare/index.js.map +0 -1
  330. package/dist/cloudflare/kv-cache-handler.d.ts.map +0 -1
  331. package/dist/cloudflare/tpr.d.ts.map +0 -1
  332. package/dist/config/config-matchers.d.ts.map +0 -1
  333. package/dist/config/dotenv.d.ts.map +0 -1
  334. package/dist/config/next-config.d.ts.map +0 -1
  335. package/dist/deploy.d.ts.map +0 -1
  336. package/dist/entries/app-browser-entry.d.ts.map +0 -1
  337. package/dist/entries/app-rsc-entry.d.ts.map +0 -1
  338. package/dist/entries/app-ssr-entry.d.ts.map +0 -1
  339. package/dist/entries/pages-client-entry.d.ts.map +0 -1
  340. package/dist/entries/pages-entry-helpers.d.ts.map +0 -1
  341. package/dist/entries/pages-server-entry.d.ts.map +0 -1
  342. package/dist/index.d.ts.map +0 -1
  343. package/dist/init.d.ts.map +0 -1
  344. package/dist/plugins/async-hooks-stub.d.ts.map +0 -1
  345. package/dist/plugins/client-reference-dedup.d.ts.map +0 -1
  346. package/dist/routing/app-router.d.ts.map +0 -1
  347. package/dist/routing/file-matcher.d.ts.map +0 -1
  348. package/dist/routing/pages-router.d.ts.map +0 -1
  349. package/dist/routing/route-trie.d.ts.map +0 -1
  350. package/dist/routing/route-validation.d.ts.map +0 -1
  351. package/dist/routing/utils.d.ts.map +0 -1
  352. package/dist/server/api-handler.d.ts.map +0 -1
  353. package/dist/server/app-router-entry.d.ts.map +0 -1
  354. package/dist/server/dev-module-runner.d.ts.map +0 -1
  355. package/dist/server/dev-origin-check.d.ts.map +0 -1
  356. package/dist/server/dev-server.d.ts.map +0 -1
  357. package/dist/server/html.d.ts.map +0 -1
  358. package/dist/server/image-optimization.d.ts.map +0 -1
  359. package/dist/server/instrumentation.d.ts.map +0 -1
  360. package/dist/server/isr-cache.d.ts.map +0 -1
  361. package/dist/server/metadata-routes.d.ts.map +0 -1
  362. package/dist/server/middleware-codegen.d.ts.map +0 -1
  363. package/dist/server/middleware-request-headers.d.ts.map +0 -1
  364. package/dist/server/middleware.d.ts.map +0 -1
  365. package/dist/server/normalize-path.d.ts.map +0 -1
  366. package/dist/server/pages-i18n.d.ts.map +0 -1
  367. package/dist/server/prod-server.d.ts.map +0 -1
  368. package/dist/server/request-log.d.ts.map +0 -1
  369. package/dist/server/request-pipeline.d.ts.map +0 -1
  370. package/dist/server/worker-utils.d.ts.map +0 -1
  371. package/dist/shims/amp.d.ts.map +0 -1
  372. package/dist/shims/app.d.ts.map +0 -1
  373. package/dist/shims/app.js.map +0 -1
  374. package/dist/shims/cache-runtime.d.ts.map +0 -1
  375. package/dist/shims/cache.d.ts.map +0 -1
  376. package/dist/shims/client-only.d.ts.map +0 -1
  377. package/dist/shims/client-only.js.map +0 -1
  378. package/dist/shims/compat-router.d.ts.map +0 -1
  379. package/dist/shims/config.d.ts.map +0 -1
  380. package/dist/shims/constants.d.ts.map +0 -1
  381. package/dist/shims/document.d.ts.map +0 -1
  382. package/dist/shims/dynamic.d.ts.map +0 -1
  383. package/dist/shims/error-boundary.d.ts.map +0 -1
  384. package/dist/shims/error.d.ts.map +0 -1
  385. package/dist/shims/fetch-cache.d.ts.map +0 -1
  386. package/dist/shims/font-google-base.d.ts.map +0 -1
  387. package/dist/shims/font-google.d.ts.map +0 -1
  388. package/dist/shims/font-google.generated.d.ts.map +0 -1
  389. package/dist/shims/font-google.js.map +0 -1
  390. package/dist/shims/font-local.d.ts.map +0 -1
  391. package/dist/shims/form.d.ts.map +0 -1
  392. package/dist/shims/head-state.d.ts.map +0 -1
  393. package/dist/shims/head.d.ts.map +0 -1
  394. package/dist/shims/headers.d.ts.map +0 -1
  395. package/dist/shims/i18n-context.d.ts.map +0 -1
  396. package/dist/shims/i18n-state.d.ts.map +0 -1
  397. package/dist/shims/image-config.d.ts.map +0 -1
  398. package/dist/shims/image.d.ts.map +0 -1
  399. package/dist/shims/internal/api-utils.d.ts.map +0 -1
  400. package/dist/shims/internal/api-utils.js.map +0 -1
  401. package/dist/shims/internal/app-router-context.d.ts.map +0 -1
  402. package/dist/shims/internal/cookies.d.ts.map +0 -1
  403. package/dist/shims/internal/cookies.js.map +0 -1
  404. package/dist/shims/internal/parse-cookie-header.d.ts.map +0 -1
  405. package/dist/shims/internal/router-context.d.ts.map +0 -1
  406. package/dist/shims/internal/utils.d.ts.map +0 -1
  407. package/dist/shims/internal/work-unit-async-storage.d.ts.map +0 -1
  408. package/dist/shims/layout-segment-context.d.ts.map +0 -1
  409. package/dist/shims/legacy-image.d.ts.map +0 -1
  410. package/dist/shims/link.d.ts.map +0 -1
  411. package/dist/shims/metadata.d.ts.map +0 -1
  412. package/dist/shims/navigation-state.d.ts.map +0 -1
  413. package/dist/shims/navigation.d.ts.map +0 -1
  414. package/dist/shims/og.d.ts.map +0 -1
  415. package/dist/shims/og.js.map +0 -1
  416. package/dist/shims/readonly-url-search-params.d.ts.map +0 -1
  417. package/dist/shims/request-context.d.ts.map +0 -1
  418. package/dist/shims/request-state-types.d.ts.map +0 -1
  419. package/dist/shims/request-state-types.js.map +0 -1
  420. package/dist/shims/router-state.d.ts.map +0 -1
  421. package/dist/shims/router.d.ts.map +0 -1
  422. package/dist/shims/script.d.ts.map +0 -1
  423. package/dist/shims/server-only.d.ts.map +0 -1
  424. package/dist/shims/server-only.js.map +0 -1
  425. package/dist/shims/server.d.ts.map +0 -1
  426. package/dist/shims/unified-request-context.d.ts.map +0 -1
  427. package/dist/shims/url-safety.d.ts.map +0 -1
  428. package/dist/shims/url-utils.d.ts.map +0 -1
  429. package/dist/shims/web-vitals.d.ts.map +0 -1
  430. package/dist/utils/base-path.d.ts.map +0 -1
  431. package/dist/utils/domain-locale.d.ts.map +0 -1
  432. package/dist/utils/hash.d.ts.map +0 -1
  433. package/dist/utils/manifest-paths.d.ts.map +0 -1
  434. package/dist/utils/project.d.ts.map +0 -1
  435. package/dist/utils/query.d.ts.map +0 -1
@@ -1,497 +1,481 @@
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
+ if (input instanceof Request) {
27
+ const req = input;
28
+ super(req.url, {
29
+ method: req.method,
30
+ headers: req.headers,
31
+ body: req.body,
32
+ duplex: req.body ? "half" : void 0,
33
+ ...init
34
+ });
35
+ } else super(input, init);
36
+ this._nextUrl = new NextURL(typeof input === "string" ? new URL(input, "http://localhost") : input instanceof URL ? input : new URL(input.url, "http://localhost"));
37
+ this._cookies = new RequestCookies(this.headers);
38
+ }
39
+ get nextUrl() {
40
+ return this._nextUrl;
41
+ }
42
+ get cookies() {
43
+ return this._cookies;
44
+ }
45
+ /**
46
+ * Client IP address. Prefers Cloudflare's trusted CF-Connecting-IP header
47
+ * over the spoofable X-Forwarded-For. Returns undefined if unavailable.
48
+ */
49
+ get ip() {
50
+ return this.headers.get("cf-connecting-ip") ?? this.headers.get("x-real-ip") ?? this.headers.get("x-forwarded-for")?.split(",")[0]?.trim() ?? void 0;
51
+ }
52
+ /**
53
+ * Geolocation data. Platform-dependent (e.g., Cloudflare, Vercel).
54
+ * Returns undefined if not available.
55
+ */
56
+ get geo() {
57
+ const country = this.headers.get("cf-ipcountry") ?? this.headers.get("x-vercel-ip-country") ?? void 0;
58
+ if (!country) return void 0;
59
+ return {
60
+ country,
61
+ city: this.headers.get("cf-ipcity") ?? this.headers.get("x-vercel-ip-city") ?? void 0,
62
+ region: this.headers.get("cf-region") ?? this.headers.get("x-vercel-ip-country-region") ?? void 0,
63
+ latitude: this.headers.get("cf-iplatitude") ?? this.headers.get("x-vercel-ip-latitude") ?? void 0,
64
+ longitude: this.headers.get("cf-iplongitude") ?? this.headers.get("x-vercel-ip-longitude") ?? void 0
65
+ };
66
+ }
67
+ /**
68
+ * The build ID of the Next.js application.
69
+ * Delegates to `nextUrl.buildId` to match Next.js API surface.
70
+ * Can be used in middleware to detect deployment skew between client and server.
71
+ */
72
+ get buildId() {
73
+ return this._nextUrl.buildId;
74
+ }
75
+ };
76
+ var NextResponse = class NextResponse extends Response {
77
+ _cookies;
78
+ constructor(body, init) {
79
+ super(body, init);
80
+ this._cookies = new ResponseCookies(this.headers);
81
+ }
82
+ get cookies() {
83
+ return this._cookies;
84
+ }
85
+ /**
86
+ * Create a JSON response.
87
+ */
88
+ static json(body, init) {
89
+ const headers = new Headers(init?.headers);
90
+ if (!headers.has("content-type")) headers.set("content-type", "application/json");
91
+ return new NextResponse(JSON.stringify(body), {
92
+ ...init,
93
+ headers
94
+ });
95
+ }
96
+ /**
97
+ * Create a redirect response.
98
+ */
99
+ static redirect(url, init) {
100
+ const status = typeof init === "number" ? init : init?.status ?? 307;
101
+ const destination = typeof url === "string" ? url : url.toString();
102
+ const headers = new Headers(typeof init === "object" ? init?.headers : void 0);
103
+ headers.set("Location", destination);
104
+ return new NextResponse(null, {
105
+ status,
106
+ headers
107
+ });
108
+ }
109
+ /**
110
+ * Create a rewrite response (middleware pattern).
111
+ * Sets the x-middleware-rewrite header.
112
+ */
113
+ static rewrite(destination, init) {
114
+ const url = typeof destination === "string" ? destination : destination.toString();
115
+ const headers = new Headers(init?.headers);
116
+ headers.set("x-middleware-rewrite", url);
117
+ if (init?.request?.headers) encodeMiddlewareRequestHeaders(headers, init.request.headers);
118
+ return new NextResponse(null, {
119
+ ...init,
120
+ headers
121
+ });
122
+ }
123
+ /**
124
+ * Continue to the next handler (middleware pattern).
125
+ * Sets the x-middleware-next header.
126
+ */
127
+ static next(init) {
128
+ const headers = new Headers(init?.headers);
129
+ headers.set("x-middleware-next", "1");
130
+ if (init?.request?.headers) encodeMiddlewareRequestHeaders(headers, init.request.headers);
131
+ return new NextResponse(null, {
132
+ ...init,
133
+ headers
134
+ });
135
+ }
136
+ };
137
+ var NextURL = class NextURL {
138
+ _url;
139
+ constructor(input, base) {
140
+ this._url = new URL(input.toString(), base);
141
+ }
142
+ get href() {
143
+ return this._url.href;
144
+ }
145
+ set href(value) {
146
+ this._url.href = value;
147
+ }
148
+ get origin() {
149
+ return this._url.origin;
150
+ }
151
+ get protocol() {
152
+ return this._url.protocol;
153
+ }
154
+ set protocol(value) {
155
+ this._url.protocol = value;
156
+ }
157
+ get username() {
158
+ return this._url.username;
159
+ }
160
+ set username(value) {
161
+ this._url.username = value;
162
+ }
163
+ get password() {
164
+ return this._url.password;
165
+ }
166
+ set password(value) {
167
+ this._url.password = value;
168
+ }
169
+ get host() {
170
+ return this._url.host;
171
+ }
172
+ set host(value) {
173
+ this._url.host = value;
174
+ }
175
+ get hostname() {
176
+ return this._url.hostname;
177
+ }
178
+ set hostname(value) {
179
+ this._url.hostname = value;
180
+ }
181
+ get port() {
182
+ return this._url.port;
183
+ }
184
+ set port(value) {
185
+ this._url.port = value;
186
+ }
187
+ get pathname() {
188
+ return this._url.pathname;
189
+ }
190
+ set pathname(value) {
191
+ this._url.pathname = value;
192
+ }
193
+ get search() {
194
+ return this._url.search;
195
+ }
196
+ set search(value) {
197
+ this._url.search = value;
198
+ }
199
+ get searchParams() {
200
+ return this._url.searchParams;
201
+ }
202
+ get hash() {
203
+ return this._url.hash;
204
+ }
205
+ set hash(value) {
206
+ this._url.hash = value;
207
+ }
208
+ clone() {
209
+ return new NextURL(this._url.href);
210
+ }
211
+ toString() {
212
+ return this._url.toString();
213
+ }
214
+ /**
215
+ * The build ID of the Next.js application.
216
+ * Set from `generateBuildId` in next.config.js, or a random UUID if not configured.
217
+ * Can be used in middleware to detect deployment skew between client and server.
218
+ * Matches the Next.js API: `request.nextUrl.buildId`.
219
+ */
220
+ get buildId() {
221
+ return process.env.__VINEXT_BUILD_ID ?? void 0;
222
+ }
223
+ };
224
+ var RequestCookies = class {
225
+ _headers;
226
+ _parsed;
227
+ constructor(headers) {
228
+ this._headers = headers;
229
+ this._parsed = parseCookieHeader(headers.get("cookie") ?? "");
230
+ }
231
+ get(name) {
232
+ const value = this._parsed.get(name);
233
+ return value !== void 0 ? {
234
+ name,
235
+ value
236
+ } : void 0;
237
+ }
238
+ getAll(nameOrOptions) {
239
+ const name = typeof nameOrOptions === "string" ? nameOrOptions : nameOrOptions?.name;
240
+ return [...this._parsed.entries()].filter(([cookieName]) => name === void 0 || cookieName === name).map(([cookieName, value]) => ({
241
+ name: cookieName,
242
+ value
243
+ }));
244
+ }
245
+ has(name) {
246
+ return this._parsed.has(name);
247
+ }
248
+ set(nameOrOptions, value) {
249
+ let cookieName;
250
+ let cookieValue;
251
+ if (typeof nameOrOptions === "string") {
252
+ cookieName = nameOrOptions;
253
+ cookieValue = value ?? "";
254
+ } else {
255
+ cookieName = nameOrOptions.name;
256
+ cookieValue = nameOrOptions.value;
257
+ }
258
+ this._parsed.set(cookieName, cookieValue);
259
+ this._syncHeader();
260
+ return this;
261
+ }
262
+ delete(names) {
263
+ if (Array.isArray(names)) {
264
+ const results = names.map((name) => this._parsed.delete(name));
265
+ this._syncHeader();
266
+ return results;
267
+ }
268
+ const result = this._parsed.delete(names);
269
+ this._syncHeader();
270
+ return result;
271
+ }
272
+ clear() {
273
+ this._parsed.clear();
274
+ this._syncHeader();
275
+ return this;
276
+ }
277
+ get size() {
278
+ return this._parsed.size;
279
+ }
280
+ toString() {
281
+ return this._serialize();
282
+ }
283
+ _serialize() {
284
+ return [...this._parsed.entries()].map(([n, v]) => `${n}=${encodeURIComponent(v)}`).join("; ");
285
+ }
286
+ _syncHeader() {
287
+ if (this._parsed.size === 0) this._headers.delete("cookie");
288
+ else this._headers.set("cookie", this._serialize());
289
+ }
290
+ [Symbol.iterator]() {
291
+ return this.getAll().map((c) => [c.name, c])[Symbol.iterator]();
292
+ }
293
+ };
313
294
  /**
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
- */
295
+ * RFC 6265 §4.1.1: cookie-name is a token (RFC 2616 §2.2).
296
+ * Allowed: any visible ASCII (0x21-0x7E) except separators: ()<>@,;:\"/[]?={}
297
+ */
317
298
  const VALID_COOKIE_NAME_RE = /^[\x21\x23-\x27\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7A\x7C\x7E]+$/;
318
299
  function validateCookieName(name) {
319
- if (!name || !VALID_COOKIE_NAME_RE.test(name)) {
320
- throw new Error(`Invalid cookie name: ${JSON.stringify(name)}`);
321
- }
300
+ if (!name || !VALID_COOKIE_NAME_RE.test(name)) throw new Error(`Invalid cookie name: ${JSON.stringify(name)}`);
322
301
  }
323
302
  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
- }
303
+ for (let i = 0; i < value.length; i++) {
304
+ const code = value.charCodeAt(i);
305
+ if (code <= 31 || code === 127 || value[i] === ";") throw new Error(`Invalid cookie ${attributeName} value: ${JSON.stringify(value)}`);
306
+ }
425
307
  }
308
+ var ResponseCookies = class {
309
+ _headers;
310
+ constructor(headers) {
311
+ this._headers = headers;
312
+ }
313
+ set(name, value, options) {
314
+ validateCookieName(name);
315
+ const parts = [`${name}=${encodeURIComponent(value)}`];
316
+ if (options?.path) {
317
+ validateCookieAttributeValue(options.path, "Path");
318
+ parts.push(`Path=${options.path}`);
319
+ }
320
+ if (options?.domain) {
321
+ validateCookieAttributeValue(options.domain, "Domain");
322
+ parts.push(`Domain=${options.domain}`);
323
+ }
324
+ if (options?.maxAge !== void 0) parts.push(`Max-Age=${options.maxAge}`);
325
+ if (options?.expires) parts.push(`Expires=${options.expires.toUTCString()}`);
326
+ if (options?.httpOnly) parts.push("HttpOnly");
327
+ if (options?.secure) parts.push("Secure");
328
+ if (options?.sameSite) parts.push(`SameSite=${options.sameSite}`);
329
+ this._headers.append("Set-Cookie", parts.join("; "));
330
+ return this;
331
+ }
332
+ get(name) {
333
+ for (const header of this._headers.getSetCookie()) {
334
+ const eq = header.indexOf("=");
335
+ if (eq === -1) continue;
336
+ if (header.slice(0, eq) === name) {
337
+ const semi = header.indexOf(";", eq);
338
+ const raw = header.slice(eq + 1, semi === -1 ? void 0 : semi);
339
+ let value;
340
+ try {
341
+ value = decodeURIComponent(raw);
342
+ } catch {
343
+ value = raw;
344
+ }
345
+ return {
346
+ name,
347
+ value
348
+ };
349
+ }
350
+ }
351
+ }
352
+ has(name) {
353
+ return this.get(name) !== void 0;
354
+ }
355
+ getAll() {
356
+ const entries = [];
357
+ for (const header of this._headers.getSetCookie()) {
358
+ const eq = header.indexOf("=");
359
+ if (eq === -1) continue;
360
+ const cookieName = header.slice(0, eq);
361
+ const semi = header.indexOf(";", eq);
362
+ const raw = header.slice(eq + 1, semi === -1 ? void 0 : semi);
363
+ let value;
364
+ try {
365
+ value = decodeURIComponent(raw);
366
+ } catch {
367
+ value = raw;
368
+ }
369
+ entries.push({
370
+ name: cookieName,
371
+ value
372
+ });
373
+ }
374
+ return entries;
375
+ }
376
+ delete(name) {
377
+ this.set(name, "", {
378
+ maxAge: 0,
379
+ path: "/"
380
+ });
381
+ return this;
382
+ }
383
+ [Symbol.iterator]() {
384
+ const entries = [];
385
+ for (const header of this._headers.getSetCookie()) {
386
+ const eq = header.indexOf("=");
387
+ if (eq === -1) continue;
388
+ const cookieName = header.slice(0, eq);
389
+ const semi = header.indexOf(";", eq);
390
+ const raw = header.slice(eq + 1, semi === -1 ? void 0 : semi);
391
+ let value;
392
+ try {
393
+ value = decodeURIComponent(raw);
394
+ } catch {
395
+ value = raw;
396
+ }
397
+ entries.push([cookieName, {
398
+ name: cookieName,
399
+ value
400
+ }]);
401
+ }
402
+ return entries[Symbol.iterator]();
403
+ }
404
+ };
426
405
  /**
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
- // ---------------------------------------------------------------------------
406
+ * Minimal NextFetchEvent — extends FetchEvent where available,
407
+ * otherwise provides the waitUntil pattern standalone.
408
+ */
409
+ var NextFetchEvent = class {
410
+ sourcePage;
411
+ _waitUntilPromises = [];
412
+ constructor(params) {
413
+ this.sourcePage = params.page;
414
+ }
415
+ waitUntil(promise) {
416
+ this._waitUntilPromises.push(promise);
417
+ }
418
+ /** Drain all waitUntil promises. Returns a single promise that settles when all are done. */
419
+ drainWaitUntil() {
420
+ return Promise.allSettled(this._waitUntilPromises);
421
+ }
422
+ };
447
423
  /**
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
- };
424
+ * Parse user agent string. Minimal implementation — for full UA parsing,
425
+ * apps should use a dedicated library like `ua-parser-js`.
426
+ */
427
+ function userAgentFromString(ua) {
428
+ const input = ua ?? "";
429
+ return {
430
+ isBot: /bot|crawler|spider|crawling/i.test(input),
431
+ ua: input,
432
+ browser: {},
433
+ device: {},
434
+ engine: {},
435
+ os: {},
436
+ cpu: {}
437
+ };
462
438
  }
463
- export function userAgent({ headers }) {
464
- return userAgentFromString(headers.get("user-agent") ?? undefined);
439
+ function userAgent({ headers }) {
440
+ return userAgentFromString(headers.get("user-agent") ?? void 0);
465
441
  }
466
442
  /**
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
- });
443
+ * after() — schedule work after the response is sent.
444
+ *
445
+ * Uses the platform's `waitUntil` (via the per-request ExecutionContext) when
446
+ * available so the task survives past the response on Cloudflare Workers.
447
+ * Falls back to a fire-and-forget microtask on runtimes without an execution
448
+ * context (e.g. Node.js dev server).
449
+ *
450
+ * Throws when called inside a cached scope — request-specific
451
+ * side-effects must not leak into cached results.
452
+ */
453
+ function after(task) {
454
+ _throwIfInsideCacheScope("after()");
455
+ const guarded = (typeof task === "function" ? Promise.resolve().then(task) : task).catch((err) => {
456
+ console.error("[vinext] after() task failed:", err);
457
+ });
458
+ getRequestExecutionContext()?.waitUntil(guarded);
476
459
  }
477
460
  /**
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();
461
+ * connection() — signals that the response requires a live connection
462
+ * (not a static/cached response). Opts the page out of ISR caching
463
+ * and sets Cache-Control: no-store on the response.
464
+ */
465
+ async function connection() {
466
+ const { markDynamicUsage, throwIfInsideCacheScope } = await import("./headers.js");
467
+ throwIfInsideCacheScope("connection()");
468
+ markDynamicUsage();
486
469
  }
487
470
  /**
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
- });
471
+ * URLPattern re-export — used in middleware for route matching.
472
+ * Available natively in Node 20+, Cloudflare Workers, Deno.
473
+ * Falls back to urlpattern-polyfill if the global is not available.
474
+ */
475
+ const URLPattern = globalThis.URLPattern ?? (() => {
476
+ throw new Error("URLPattern is not available in this runtime. Install the `urlpattern-polyfill` package or upgrade to Node 20+.");
477
+ });
478
+ //#endregion
479
+ export { NextFetchEvent, NextRequest, NextResponse, NextURL, RequestCookies, ResponseCookies, URLPattern, after, connection, userAgent, userAgentFromString };
480
+
497
481
  //# sourceMappingURL=server.js.map