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,650 +1,522 @@
1
- /**
2
- * next/headers shim
3
- *
4
- * Provides cookies() and headers() functions for App Router Server Components.
5
- * These read from a request context set by the RSC handler before rendering.
6
- *
7
- * In Next.js 15+, cookies() and headers() return Promises (async).
8
- * We support both the sync (legacy) and async patterns.
9
- */
10
- import { AsyncLocalStorage } from "node:async_hooks";
11
1
  import { buildRequestHeadersFromMiddlewareResponse } from "../server/middleware-request-headers.js";
12
2
  import { parseCookieHeader } from "./internal/parse-cookie-header.js";
13
- import { isInsideUnifiedScope, getRequestContext, runWithUnifiedStateMutation, } from "./unified-request-context.js";
14
- // NOTE:
15
- // - This shim can be loaded under multiple module specifiers in Vite's
16
- // multi-environment setup (RSC/SSR). Store the AsyncLocalStorage on
17
- // globalThis so `connection()` (next/server) and `consumeDynamicUsage()`
18
- // (next/headers) always share it.
19
- // - We use AsyncLocalStorage so concurrent requests don't stomp each other's
20
- // headers/cookies/dynamic-usage state.
3
+ import { getRequestContext, isInsideUnifiedScope, runWithUnifiedStateMutation } from "./unified-request-context.js";
4
+ import { AsyncLocalStorage } from "node:async_hooks";
5
+ //#region src/shims/headers.ts
6
+ /**
7
+ * next/headers shim
8
+ *
9
+ * Provides cookies() and headers() functions for App Router Server Components.
10
+ * These read from a request context set by the RSC handler before rendering.
11
+ *
12
+ * In Next.js 15+, cookies() and headers() return Promises (async).
13
+ * We support both the sync (legacy) and async patterns.
14
+ */
21
15
  const _ALS_KEY = Symbol.for("vinext.nextHeadersShim.als");
22
16
  const _FALLBACK_KEY = Symbol.for("vinext.nextHeadersShim.fallback");
23
17
  const _g = globalThis;
24
- const _als = (_g[_ALS_KEY] ??=
25
- new AsyncLocalStorage());
26
- const _fallbackState = (_g[_FALLBACK_KEY] ??= {
27
- headersContext: null,
28
- dynamicUsageDetected: false,
29
- pendingSetCookies: [],
30
- draftModeCookieHeader: null,
31
- phase: "render",
32
- });
18
+ const _als = _g[_ALS_KEY] ??= new AsyncLocalStorage();
19
+ const _fallbackState = _g[_FALLBACK_KEY] ??= {
20
+ headersContext: null,
21
+ dynamicUsageDetected: false,
22
+ pendingSetCookies: [],
23
+ draftModeCookieHeader: null,
24
+ phase: "render"
25
+ };
26
+ const EXPIRED_COOKIE_DATE = (/* @__PURE__ */ new Date(0)).toUTCString();
33
27
  function _getState() {
34
- if (isInsideUnifiedScope()) {
35
- return getRequestContext();
36
- }
37
- return _als.getStore() ?? _fallbackState;
28
+ if (isInsideUnifiedScope()) return getRequestContext();
29
+ return _als.getStore() ?? _fallbackState;
38
30
  }
39
31
  /**
40
- * Dynamic usage flag — set when a component calls connection(), cookies(),
41
- * headers(), or noStore() during rendering. When true, ISR caching is
42
- * bypassed and the response gets Cache-Control: no-store.
43
- */
44
- // (stored on _state)
32
+ * Dynamic usage flag — set when a component calls connection(), cookies(),
33
+ * headers(), or noStore() during rendering. When true, ISR caching is
34
+ * bypassed and the response gets Cache-Control: no-store.
35
+ */
45
36
  /**
46
- * Mark the current render as requiring dynamic (uncached) rendering.
47
- * Called by connection(), cookies(), headers(), and noStore().
48
- */
49
- export function markDynamicUsage() {
50
- _getState().dynamicUsageDetected = true;
37
+ * Mark the current render as requiring dynamic (uncached) rendering.
38
+ * Called by connection(), cookies(), headers(), and noStore().
39
+ */
40
+ function markDynamicUsage() {
41
+ _getState().dynamicUsageDetected = true;
51
42
  }
52
- // ---------------------------------------------------------------------------
53
- // Cache scope detection — checks whether we're inside "use cache" or
54
- // unstable_cache() by reading ALS instances stored on globalThis via Symbols.
55
- // This avoids circular imports between headers.ts, cache.ts, and cache-runtime.ts.
56
- // The ALS instances are registered by cache-runtime.ts and cache.ts respectively.
57
- // ---------------------------------------------------------------------------
58
43
  /** Symbol used by cache-runtime.ts to store the "use cache" ALS on globalThis */
59
44
  const _USE_CACHE_ALS_KEY = Symbol.for("vinext.cacheRuntime.contextAls");
60
45
  /** Symbol used by cache.ts to store the unstable_cache ALS on globalThis */
61
46
  const _UNSTABLE_CACHE_ALS_KEY = Symbol.for("vinext.unstableCache.als");
62
47
  const _gHeaders = globalThis;
63
48
  function _isInsideUseCache() {
64
- const als = _gHeaders[_USE_CACHE_ALS_KEY];
65
- return als?.getStore() != null;
49
+ return _gHeaders[_USE_CACHE_ALS_KEY]?.getStore() != null;
66
50
  }
67
51
  function _isInsideUnstableCache() {
68
- const als = _gHeaders[_UNSTABLE_CACHE_ALS_KEY];
69
- return als?.getStore() === true;
52
+ return _gHeaders[_UNSTABLE_CACHE_ALS_KEY]?.getStore() === true;
70
53
  }
71
54
  /**
72
- * Throw if the current execution is inside a "use cache" or unstable_cache()
73
- * scope. Called by dynamic request APIs (headers, cookies, connection) to
74
- * prevent request-specific data from being frozen into cached results.
75
- *
76
- * @param apiName - The name of the API being called (e.g. "connection()")
77
- */
78
- export function throwIfInsideCacheScope(apiName) {
79
- if (_isInsideUseCache()) {
80
- throw new Error(`\`${apiName}\` cannot be called inside "use cache". ` +
81
- `If you need this data inside a cached function, call \`${apiName}\` ` +
82
- "outside and pass the required data as an argument.");
83
- }
84
- if (_isInsideUnstableCache()) {
85
- throw new Error(`\`${apiName}\` cannot be called inside a function cached with \`unstable_cache()\`. ` +
86
- `If you need this data inside a cached function, call \`${apiName}\` ` +
87
- "outside and pass the required data as an argument.");
88
- }
55
+ * Throw if the current execution is inside a "use cache" or unstable_cache()
56
+ * scope. Called by dynamic request APIs (headers, cookies, connection) to
57
+ * prevent request-specific data from being frozen into cached results.
58
+ *
59
+ * @param apiName - The name of the API being called (e.g. "connection()")
60
+ */
61
+ function throwIfInsideCacheScope(apiName) {
62
+ if (_isInsideUseCache()) 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.`);
63
+ if (_isInsideUnstableCache()) 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.`);
89
64
  }
90
65
  /**
91
- * Check and reset the dynamic usage flag.
92
- * Called by the server after rendering to decide on caching.
93
- */
94
- export function consumeDynamicUsage() {
95
- const state = _getState();
96
- const used = state.dynamicUsageDetected;
97
- state.dynamicUsageDetected = false;
98
- return used;
66
+ * Check and reset the dynamic usage flag.
67
+ * Called by the server after rendering to decide on caching.
68
+ */
69
+ function consumeDynamicUsage() {
70
+ const state = _getState();
71
+ const used = state.dynamicUsageDetected;
72
+ state.dynamicUsageDetected = false;
73
+ return used;
99
74
  }
100
75
  function _setStatePhase(state, phase) {
101
- const previous = state.phase;
102
- state.phase = phase;
103
- return previous;
76
+ const previous = state.phase;
77
+ state.phase = phase;
78
+ return previous;
104
79
  }
105
80
  function _areCookiesMutableInCurrentPhase() {
106
- const phase = _getState().phase;
107
- return phase === "action" || phase === "route-handler";
81
+ const phase = _getState().phase;
82
+ return phase === "action" || phase === "route-handler";
108
83
  }
109
- export function setHeadersAccessPhase(phase) {
110
- return _setStatePhase(_getState(), phase);
84
+ function setHeadersAccessPhase(phase) {
85
+ return _setStatePhase(_getState(), phase);
111
86
  }
112
87
  /**
113
- * Set the headers/cookies context for the current RSC render.
114
- * Called by the framework's RSC entry before rendering each request.
115
- *
116
- * @deprecated Prefer runWithHeadersContext() which uses als.run() for
117
- * proper per-request isolation. This function mutates the ALS store
118
- * in-place and is only safe for cleanup (ctx=null) within an existing
119
- * als.run() scope.
120
- */
88
+ * Set the headers/cookies context for the current RSC render.
89
+ * Called by the framework's RSC entry before rendering each request.
90
+ *
91
+ * @deprecated Prefer runWithHeadersContext() which uses als.run() for
92
+ * proper per-request isolation. This function mutates the ALS store
93
+ * in-place and is only safe for cleanup (ctx=null) within an existing
94
+ * als.run() scope.
95
+ */
121
96
  /**
122
- * Returns the current live HeadersContext from ALS (or the fallback).
123
- * Used after applyMiddlewareRequestHeaders() to build a post-middleware
124
- * request context for afterFiles/fallback rewrite has/missing evaluation.
125
- */
126
- export function getHeadersContext() {
127
- return _getState().headersContext;
128
- }
129
- export function setHeadersContext(ctx) {
130
- const state = _getState();
131
- if (ctx !== null) {
132
- state.headersContext = ctx;
133
- state.dynamicUsageDetected = false;
134
- state.pendingSetCookies = [];
135
- state.draftModeCookieHeader = null;
136
- state.phase = "render";
137
- }
138
- else {
139
- state.headersContext = null;
140
- state.phase = "render";
141
- }
97
+ * Returns the current live HeadersContext from ALS (or the fallback).
98
+ * Used after applyMiddlewareRequestHeaders() to build a post-middleware
99
+ * request context for afterFiles/fallback rewrite has/missing evaluation.
100
+ */
101
+ function getHeadersContext() {
102
+ return _getState().headersContext;
103
+ }
104
+ function setHeadersContext(ctx) {
105
+ const state = _getState();
106
+ if (ctx !== null) {
107
+ state.headersContext = ctx;
108
+ state.dynamicUsageDetected = false;
109
+ state.pendingSetCookies = [];
110
+ state.draftModeCookieHeader = null;
111
+ state.phase = "render";
112
+ } else {
113
+ state.headersContext = null;
114
+ state.phase = "render";
115
+ }
142
116
  }
143
117
  /**
144
- * Run a function with headers context, ensuring the context propagates
145
- * through all async operations (including RSC streaming).
146
- *
147
- * Uses AsyncLocalStorage.run() to guarantee per-request isolation.
148
- * The ALS store propagates through all async continuations including
149
- * ReadableStream consumption, setTimeout callbacks, and Promise chains,
150
- * so RSC streaming works correctly — components that render when the
151
- * stream is consumed still see the correct request's context.
152
- */
153
- export function runWithHeadersContext(ctx, fn) {
154
- if (isInsideUnifiedScope()) {
155
- return runWithUnifiedStateMutation((uCtx) => {
156
- uCtx.headersContext = ctx;
157
- uCtx.dynamicUsageDetected = false;
158
- uCtx.pendingSetCookies = [];
159
- uCtx.draftModeCookieHeader = null;
160
- uCtx.phase = "render";
161
- }, fn);
162
- }
163
- const state = {
164
- headersContext: ctx,
165
- dynamicUsageDetected: false,
166
- pendingSetCookies: [],
167
- draftModeCookieHeader: null,
168
- phase: "render",
169
- };
170
- return _als.run(state, fn);
118
+ * Run a function with headers context, ensuring the context propagates
119
+ * through all async operations (including RSC streaming).
120
+ *
121
+ * Uses AsyncLocalStorage.run() to guarantee per-request isolation.
122
+ * The ALS store propagates through all async continuations including
123
+ * ReadableStream consumption, setTimeout callbacks, and Promise chains,
124
+ * so RSC streaming works correctly — components that render when the
125
+ * stream is consumed still see the correct request's context.
126
+ */
127
+ function runWithHeadersContext(ctx, fn) {
128
+ if (isInsideUnifiedScope()) return runWithUnifiedStateMutation((uCtx) => {
129
+ uCtx.headersContext = ctx;
130
+ uCtx.dynamicUsageDetected = false;
131
+ uCtx.pendingSetCookies = [];
132
+ uCtx.draftModeCookieHeader = null;
133
+ uCtx.phase = "render";
134
+ }, fn);
135
+ const state = {
136
+ headersContext: ctx,
137
+ dynamicUsageDetected: false,
138
+ pendingSetCookies: [],
139
+ draftModeCookieHeader: null,
140
+ phase: "render"
141
+ };
142
+ return _als.run(state, fn);
171
143
  }
172
144
  /**
173
- * Apply middleware-forwarded request headers to the current headers context.
174
- *
175
- * When Next.js middleware calls `NextResponse.next()` or `NextResponse.rewrite()`
176
- * with `{ request: { headers } }`, the modified headers are encoded on the
177
- * middleware response. This function decodes that protocol and applies the
178
- * resulting request header set to the live `HeadersContext`. When an override
179
- * list is present, omitted headers are deleted as part of the rebuild.
180
- */
181
- export function applyMiddlewareRequestHeaders(middlewareResponseHeaders) {
182
- const state = _getState();
183
- if (!state.headersContext)
184
- return;
185
- const ctx = state.headersContext;
186
- const previousCookieHeader = ctx.headers.get("cookie");
187
- const nextHeaders = buildRequestHeadersFromMiddlewareResponse(ctx.headers, middlewareResponseHeaders);
188
- if (!nextHeaders)
189
- return;
190
- ctx.headers = nextHeaders;
191
- const nextCookieHeader = nextHeaders.get("cookie");
192
- if (previousCookieHeader === nextCookieHeader)
193
- return;
194
- // If middleware modified the cookie header, rebuild the cookies map.
195
- ctx.cookies.clear();
196
- if (nextCookieHeader !== null) {
197
- const nextCookies = parseCookieHeader(nextCookieHeader);
198
- for (const [name, value] of nextCookies) {
199
- ctx.cookies.set(name, value);
200
- }
201
- }
145
+ * Apply middleware-forwarded request headers to the current headers context.
146
+ *
147
+ * When Next.js middleware calls `NextResponse.next()` or `NextResponse.rewrite()`
148
+ * with `{ request: { headers } }`, the modified headers are encoded on the
149
+ * middleware response. This function decodes that protocol and applies the
150
+ * resulting request header set to the live `HeadersContext`. When an override
151
+ * list is present, omitted headers are deleted as part of the rebuild.
152
+ */
153
+ function applyMiddlewareRequestHeaders(middlewareResponseHeaders) {
154
+ const state = _getState();
155
+ if (!state.headersContext) return;
156
+ const ctx = state.headersContext;
157
+ const previousCookieHeader = ctx.headers.get("cookie");
158
+ const nextHeaders = buildRequestHeadersFromMiddlewareResponse(ctx.headers, middlewareResponseHeaders);
159
+ if (!nextHeaders) return;
160
+ ctx.headers = nextHeaders;
161
+ const nextCookieHeader = nextHeaders.get("cookie");
162
+ if (previousCookieHeader === nextCookieHeader) return;
163
+ ctx.cookies.clear();
164
+ if (nextCookieHeader !== null) {
165
+ const nextCookies = parseCookieHeader(nextCookieHeader);
166
+ for (const [name, value] of nextCookies) ctx.cookies.set(name, value);
167
+ }
202
168
  }
203
169
  /** Methods on `Headers` that mutate state. Hoisted to module scope — static. */
204
- const _HEADERS_MUTATING_METHODS = new Set(["set", "delete", "append"]);
205
- class ReadonlyHeadersError extends Error {
206
- constructor() {
207
- super("Headers cannot be modified. Read more: https://nextjs.org/docs/app/api-reference/functions/headers");
208
- }
209
- static callable() {
210
- throw new ReadonlyHeadersError();
211
- }
212
- }
213
- class ReadonlyRequestCookiesError extends Error {
214
- constructor() {
215
- super("Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#options");
216
- }
217
- static callable() {
218
- throw new ReadonlyRequestCookiesError();
219
- }
220
- }
170
+ const _HEADERS_MUTATING_METHODS = new Set([
171
+ "set",
172
+ "delete",
173
+ "append"
174
+ ]);
175
+ var ReadonlyHeadersError = class ReadonlyHeadersError extends Error {
176
+ constructor() {
177
+ super("Headers cannot be modified. Read more: https://nextjs.org/docs/app/api-reference/functions/headers");
178
+ }
179
+ static callable() {
180
+ throw new ReadonlyHeadersError();
181
+ }
182
+ };
183
+ var ReadonlyRequestCookiesError = class ReadonlyRequestCookiesError extends Error {
184
+ constructor() {
185
+ super("Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#options");
186
+ }
187
+ static callable() {
188
+ throw new ReadonlyRequestCookiesError();
189
+ }
190
+ };
221
191
  function _decorateRequestApiPromise(promise, target) {
222
- return new Proxy(promise, {
223
- get(promiseTarget, prop) {
224
- if (prop in promiseTarget) {
225
- const value = Reflect.get(promiseTarget, prop, promiseTarget);
226
- return typeof value === "function" ? value.bind(promiseTarget) : value;
227
- }
228
- const value = Reflect.get(target, prop, target);
229
- return typeof value === "function" ? value.bind(target) : value;
230
- },
231
- has(promiseTarget, prop) {
232
- return prop in promiseTarget || prop in target;
233
- },
234
- ownKeys(promiseTarget) {
235
- return Array.from(new Set([...Reflect.ownKeys(promiseTarget), ...Reflect.ownKeys(target)]));
236
- },
237
- getOwnPropertyDescriptor(promiseTarget, prop) {
238
- return (Reflect.getOwnPropertyDescriptor(promiseTarget, prop) ??
239
- Reflect.getOwnPropertyDescriptor(target, prop));
240
- },
241
- });
192
+ return new Proxy(promise, {
193
+ get(promiseTarget, prop) {
194
+ if (prop in promiseTarget) {
195
+ const value = Reflect.get(promiseTarget, prop, promiseTarget);
196
+ return typeof value === "function" ? value.bind(promiseTarget) : value;
197
+ }
198
+ const value = Reflect.get(target, prop, target);
199
+ return typeof value === "function" ? value.bind(target) : value;
200
+ },
201
+ has(promiseTarget, prop) {
202
+ return prop in promiseTarget || prop in target;
203
+ },
204
+ ownKeys(promiseTarget) {
205
+ return Array.from(new Set([...Reflect.ownKeys(promiseTarget), ...Reflect.ownKeys(target)]));
206
+ },
207
+ getOwnPropertyDescriptor(promiseTarget, prop) {
208
+ return Reflect.getOwnPropertyDescriptor(promiseTarget, prop) ?? Reflect.getOwnPropertyDescriptor(target, prop);
209
+ }
210
+ });
242
211
  }
243
212
  function _decorateRejectedRequestApiPromise(error) {
244
- const normalizedError = error instanceof Error ? error : new Error(String(error));
245
- const promise = Promise.reject(normalizedError);
246
- // Mark the rejection as handled so legacy sync access does not trigger
247
- // spurious unhandled rejection noise before callers await/catch it.
248
- promise.catch(() => { });
249
- const throwingTarget = new Proxy({}, {
250
- get(_target, prop) {
251
- if (prop === "then" || prop === "catch" || prop === "finally") {
252
- return undefined;
253
- }
254
- throw normalizedError;
255
- },
256
- });
257
- return _decorateRequestApiPromise(promise, throwingTarget);
213
+ const normalizedError = error instanceof Error ? error : new Error(String(error));
214
+ const promise = Promise.reject(normalizedError);
215
+ promise.catch(() => {});
216
+ return _decorateRequestApiPromise(promise, new Proxy({}, { get(_target, prop) {
217
+ if (prop === "then" || prop === "catch" || prop === "finally") return;
218
+ throw normalizedError;
219
+ } }));
258
220
  }
259
221
  function _sealHeaders(headers) {
260
- return new Proxy(headers, {
261
- get(target, prop) {
262
- if (typeof prop === "string" && _HEADERS_MUTATING_METHODS.has(prop)) {
263
- throw new ReadonlyHeadersError();
264
- }
265
- const value = Reflect.get(target, prop, target);
266
- return typeof value === "function" ? value.bind(target) : value;
267
- },
268
- });
222
+ return new Proxy(headers, { get(target, prop) {
223
+ if (typeof prop === "string" && _HEADERS_MUTATING_METHODS.has(prop)) throw new ReadonlyHeadersError();
224
+ const value = Reflect.get(target, prop, target);
225
+ return typeof value === "function" ? value.bind(target) : value;
226
+ } });
269
227
  }
270
228
  function _wrapMutableCookies(cookies) {
271
- return new Proxy(cookies, {
272
- get(target, prop) {
273
- if (prop === "set" || prop === "delete") {
274
- return (...args) => {
275
- if (!_areCookiesMutableInCurrentPhase()) {
276
- throw new ReadonlyRequestCookiesError();
277
- }
278
- return Reflect.get(target, prop, target).apply(target, args);
279
- };
280
- }
281
- const value = Reflect.get(target, prop, target);
282
- return typeof value === "function" ? value.bind(target) : value;
283
- },
284
- });
229
+ return new Proxy(cookies, { get(target, prop) {
230
+ if (prop === "set" || prop === "delete") return (...args) => {
231
+ if (!_areCookiesMutableInCurrentPhase()) throw new ReadonlyRequestCookiesError();
232
+ return Reflect.get(target, prop, target).apply(target, args);
233
+ };
234
+ const value = Reflect.get(target, prop, target);
235
+ return typeof value === "function" ? value.bind(target) : value;
236
+ } });
285
237
  }
286
238
  function _sealCookies(cookies) {
287
- return new Proxy(cookies, {
288
- get(target, prop) {
289
- if (prop === "set" || prop === "delete") {
290
- throw new ReadonlyRequestCookiesError();
291
- }
292
- const value = Reflect.get(target, prop, target);
293
- return typeof value === "function" ? value.bind(target) : value;
294
- },
295
- });
239
+ return new Proxy(cookies, { get(target, prop) {
240
+ if (prop === "set" || prop === "delete") throw new ReadonlyRequestCookiesError();
241
+ const value = Reflect.get(target, prop, target);
242
+ return typeof value === "function" ? value.bind(target) : value;
243
+ } });
296
244
  }
297
245
  function _getMutableCookies(ctx) {
298
- if (!ctx.mutableCookies) {
299
- ctx.mutableCookies = _wrapMutableCookies(new RequestCookies(ctx.cookies));
300
- }
301
- return ctx.mutableCookies;
246
+ if (!ctx.mutableCookies) ctx.mutableCookies = _wrapMutableCookies(new RequestCookies(ctx.cookies));
247
+ return ctx.mutableCookies;
302
248
  }
303
249
  function _getReadonlyCookies(ctx) {
304
- if (!ctx.readonlyCookies) {
305
- // Keep a separate readonly wrapper so render-path reads avoid the
306
- // mutable phase-checking proxy while still reflecting the shared cookie map.
307
- ctx.readonlyCookies = _sealCookies(new RequestCookies(ctx.cookies));
308
- }
309
- return ctx.readonlyCookies;
250
+ if (!ctx.readonlyCookies) ctx.readonlyCookies = _sealCookies(new RequestCookies(ctx.cookies));
251
+ return ctx.readonlyCookies;
310
252
  }
311
253
  function _getReadonlyHeaders(ctx) {
312
- if (!ctx.readonlyHeaders) {
313
- ctx.readonlyHeaders = _sealHeaders(ctx.headers);
314
- }
315
- return ctx.readonlyHeaders;
254
+ if (!ctx.readonlyHeaders) ctx.readonlyHeaders = _sealHeaders(ctx.headers);
255
+ return ctx.readonlyHeaders;
316
256
  }
317
257
  /**
318
- * Create a HeadersContext from a standard Request object.
319
- *
320
- * Performance note: In Workerd (Cloudflare Workers), `new Headers(request.headers)`
321
- * copies the entire header map across the V8/C++ boundary, which shows up as
322
- * ~815 ms self-time in production profiles when requests carry many headers.
323
- * We defer this copy with a lazy proxy:
324
- *
325
- * - Reads (`get`, `has`, `entries`, …) are forwarded directly to the original
326
- * immutable `request.headers` — zero copy cost on the hot path.
327
- * - The first mutating call (`set`, `delete`, `append`) materialises
328
- * `new Headers(request.headers)` once, then applies the mutation to the copy.
329
- * All subsequent operations go to the copy.
330
- *
331
- * This means the ~815 ms copy only occurs when middleware actually rewrites
332
- * request headers via `NextResponse.next({ request: { headers } })`, which is
333
- * uncommon. Pure read requests (the vast majority) pay zero copy cost.
334
- *
335
- * Cookie parsing is also deferred: the `cookie` header string is not split
336
- * until the first call to `cookies()` or `draftMode()`.
337
- */
338
- export function headersContextFromRequest(request) {
339
- // ---------------------------------------------------------------------------
340
- // Lazy mutable Headers proxy
341
- // ---------------------------------------------------------------------------
342
- // `_mutable` holds the materialised copy once a write is needed.
343
- let _mutable = null;
344
- const headersProxy = new Proxy(request.headers, {
345
- get(target, prop) {
346
- // Route to the materialised copy if it exists.
347
- const src = _mutable ?? target;
348
- // Intercept mutating methods: materialise on first write.
349
- if (typeof prop === "string" && _HEADERS_MUTATING_METHODS.has(prop)) {
350
- return (...args) => {
351
- if (!_mutable) {
352
- _mutable = new Headers(target);
353
- }
354
- return _mutable[prop](...args);
355
- };
356
- }
357
- // Non-mutating method or property: bind to current source.
358
- const value = Reflect.get(src, prop, src);
359
- return typeof value === "function" ? value.bind(src) : value;
360
- },
361
- });
362
- // ---------------------------------------------------------------------------
363
- // Lazy cookie map
364
- // ---------------------------------------------------------------------------
365
- // Parsing cookies requires splitting on `;` and `=`, which is cheap but
366
- // still unnecessary overhead if `cookies()` is never called for this request.
367
- let _cookies = null;
368
- function getCookies() {
369
- if (_cookies)
370
- return _cookies;
371
- // Read from the proxy so middleware-modified cookie headers are respected.
372
- const cookieHeader = headersProxy.get("cookie") || "";
373
- _cookies = parseCookieHeader(cookieHeader);
374
- return _cookies;
375
- }
376
- // Expose cookies as a lazy getter that memoises on first access.
377
- const ctx = {
378
- headers: headersProxy,
379
- get cookies() {
380
- return getCookies();
381
- },
382
- };
383
- return ctx;
258
+ * Create a HeadersContext from a standard Request object.
259
+ *
260
+ * Performance note: In Workerd (Cloudflare Workers), `new Headers(request.headers)`
261
+ * copies the entire header map across the V8/C++ boundary, which shows up as
262
+ * ~815 ms self-time in production profiles when requests carry many headers.
263
+ * We defer this copy with a lazy proxy:
264
+ *
265
+ * - Reads (`get`, `has`, `entries`, …) are forwarded directly to the original
266
+ * immutable `request.headers` — zero copy cost on the hot path.
267
+ * - The first mutating call (`set`, `delete`, `append`) materialises
268
+ * `new Headers(request.headers)` once, then applies the mutation to the copy.
269
+ * All subsequent operations go to the copy.
270
+ *
271
+ * This means the ~815 ms copy only occurs when middleware actually rewrites
272
+ * request headers via `NextResponse.next({ request: { headers } })`, which is
273
+ * uncommon. Pure read requests (the vast majority) pay zero copy cost.
274
+ *
275
+ * Cookie parsing is also deferred: the `cookie` header string is not split
276
+ * until the first call to `cookies()` or `draftMode()`.
277
+ */
278
+ function headersContextFromRequest(request) {
279
+ let _mutable = null;
280
+ const headersProxy = new Proxy(request.headers, { get(target, prop) {
281
+ const src = _mutable ?? target;
282
+ if (typeof prop === "string" && _HEADERS_MUTATING_METHODS.has(prop)) return (...args) => {
283
+ if (!_mutable) _mutable = new Headers(target);
284
+ return _mutable[prop](...args);
285
+ };
286
+ const value = Reflect.get(src, prop, src);
287
+ return typeof value === "function" ? value.bind(src) : value;
288
+ } });
289
+ let _cookies = null;
290
+ function getCookies() {
291
+ if (_cookies) return _cookies;
292
+ _cookies = parseCookieHeader(headersProxy.get("cookie") || "");
293
+ return _cookies;
294
+ }
295
+ return {
296
+ headers: headersProxy,
297
+ get cookies() {
298
+ return getCookies();
299
+ }
300
+ };
384
301
  }
385
- // ---------------------------------------------------------------------------
386
- // Public API
387
- // ---------------------------------------------------------------------------
388
302
  /**
389
- * Read-only Headers instance from the incoming request.
390
- * Returns a Promise in Next.js 15+ style (but resolves synchronously since
391
- * the context is already available).
392
- */
393
- export function headers() {
394
- try {
395
- throwIfInsideCacheScope("headers()");
396
- }
397
- catch (error) {
398
- return _decorateRejectedRequestApiPromise(error);
399
- }
400
- const state = _getState();
401
- if (!state.headersContext) {
402
- return _decorateRejectedRequestApiPromise(new Error("headers() can only be called from a Server Component, Route Handler, " +
403
- "or Server Action. Make sure you're not calling it from a Client Component."));
404
- }
405
- if (state.headersContext.accessError) {
406
- return _decorateRejectedRequestApiPromise(state.headersContext.accessError);
407
- }
408
- markDynamicUsage();
409
- const readonlyHeaders = _getReadonlyHeaders(state.headersContext);
410
- return _decorateRequestApiPromise(Promise.resolve(readonlyHeaders), readonlyHeaders);
303
+ * Read-only Headers instance from the incoming request.
304
+ * Returns a Promise in Next.js 15+ style (but resolves synchronously since
305
+ * the context is already available).
306
+ */
307
+ function headers() {
308
+ try {
309
+ throwIfInsideCacheScope("headers()");
310
+ } catch (error) {
311
+ return _decorateRejectedRequestApiPromise(error);
312
+ }
313
+ const state = _getState();
314
+ if (!state.headersContext) return _decorateRejectedRequestApiPromise(/* @__PURE__ */ new Error("headers() can only be called from a Server Component, Route Handler, or Server Action. Make sure you're not calling it from a Client Component."));
315
+ if (state.headersContext.accessError) return _decorateRejectedRequestApiPromise(state.headersContext.accessError);
316
+ markDynamicUsage();
317
+ const readonlyHeaders = _getReadonlyHeaders(state.headersContext);
318
+ return _decorateRequestApiPromise(Promise.resolve(readonlyHeaders), readonlyHeaders);
411
319
  }
412
320
  /**
413
- * Cookie jar from the incoming request.
414
- * Returns a ReadonlyRequestCookies-like object.
415
- */
416
- export function cookies() {
417
- try {
418
- throwIfInsideCacheScope("cookies()");
419
- }
420
- catch (error) {
421
- return _decorateRejectedRequestApiPromise(error);
422
- }
423
- const state = _getState();
424
- if (!state.headersContext) {
425
- return _decorateRejectedRequestApiPromise(new Error("cookies() can only be called from a Server Component, Route Handler, or Server Action."));
426
- }
427
- if (state.headersContext.accessError) {
428
- return _decorateRejectedRequestApiPromise(state.headersContext.accessError);
429
- }
430
- markDynamicUsage();
431
- const cookieStore = _areCookiesMutableInCurrentPhase()
432
- ? _getMutableCookies(state.headersContext)
433
- : _getReadonlyCookies(state.headersContext);
434
- return _decorateRequestApiPromise(Promise.resolve(cookieStore), cookieStore);
321
+ * Cookie jar from the incoming request.
322
+ * Returns a ReadonlyRequestCookies-like object.
323
+ */
324
+ function cookies() {
325
+ try {
326
+ throwIfInsideCacheScope("cookies()");
327
+ } catch (error) {
328
+ return _decorateRejectedRequestApiPromise(error);
329
+ }
330
+ const state = _getState();
331
+ if (!state.headersContext) return _decorateRejectedRequestApiPromise(/* @__PURE__ */ new Error("cookies() can only be called from a Server Component, Route Handler, or Server Action."));
332
+ if (state.headersContext.accessError) return _decorateRejectedRequestApiPromise(state.headersContext.accessError);
333
+ markDynamicUsage();
334
+ const cookieStore = _areCookiesMutableInCurrentPhase() ? _getMutableCookies(state.headersContext) : _getReadonlyCookies(state.headersContext);
335
+ return _decorateRequestApiPromise(Promise.resolve(cookieStore), cookieStore);
435
336
  }
436
- // ---------------------------------------------------------------------------
437
- // Writable cookie accumulator for Route Handlers / Server Actions
438
- // ---------------------------------------------------------------------------
439
337
  /** Accumulated Set-Cookie headers from cookies().set() / .delete() calls */
440
- // (stored on _state)
441
338
  /**
442
- * Get and clear all pending Set-Cookie headers generated by cookies().set()/delete().
443
- * Called by the framework after rendering to attach headers to the response.
444
- */
445
- export function getAndClearPendingCookies() {
446
- const state = _getState();
447
- const cookies = state.pendingSetCookies;
448
- state.pendingSetCookies = [];
449
- return cookies;
339
+ * Get and clear all pending Set-Cookie headers generated by cookies().set()/delete().
340
+ * Called by the framework after rendering to attach headers to the response.
341
+ */
342
+ function getAndClearPendingCookies() {
343
+ const state = _getState();
344
+ const cookies = state.pendingSetCookies;
345
+ state.pendingSetCookies = [];
346
+ return cookies;
450
347
  }
451
- // Draft mode cookie name (matches Next.js convention)
452
348
  const DRAFT_MODE_COOKIE = "__prerender_bypass";
453
- // Draft mode secret — generated once at build time via Vite `define` so the
454
- // __prerender_bypass cookie is consistent across all server instances (e.g.
455
- // multiple Cloudflare Workers isolates).
456
349
  function getDraftSecret() {
457
- const secret = process.env.__VINEXT_DRAFT_SECRET;
458
- if (!secret) {
459
- throw new Error("[vinext] __VINEXT_DRAFT_SECRET is not defined. " +
460
- "This should be set by the Vite plugin at build time.");
461
- }
462
- return secret;
350
+ const secret = process.env.__VINEXT_DRAFT_SECRET;
351
+ if (!secret) throw new Error("[vinext] __VINEXT_DRAFT_SECRET is not defined. This should be set by the Vite plugin at build time.");
352
+ return secret;
463
353
  }
464
- // Store for Set-Cookie headers generated by draftMode().enable()/disable()
465
- // (stored on _state)
466
354
  /**
467
- * Get any Set-Cookie header generated by draftMode().enable()/disable().
468
- * Called by the framework after rendering to attach the header to the response.
469
- */
470
- export function getDraftModeCookieHeader() {
471
- const state = _getState();
472
- const header = state.draftModeCookieHeader;
473
- state.draftModeCookieHeader = null;
474
- return header;
355
+ * Get any Set-Cookie header generated by draftMode().enable()/disable().
356
+ * Called by the framework after rendering to attach the header to the response.
357
+ */
358
+ function getDraftModeCookieHeader() {
359
+ const state = _getState();
360
+ const header = state.draftModeCookieHeader;
361
+ state.draftModeCookieHeader = null;
362
+ return header;
475
363
  }
476
364
  /**
477
- * Draft mode — check/toggle via a `__prerender_bypass` cookie.
478
- *
479
- * - `isEnabled`: true if the bypass cookie is present in the request
480
- * - `enable()`: sets the bypass cookie (for Route Handlers)
481
- * - `disable()`: clears the bypass cookie
482
- */
483
- export async function draftMode() {
484
- throwIfInsideCacheScope("draftMode()");
485
- const state = _getState();
486
- if (state.headersContext?.accessError) {
487
- throw state.headersContext.accessError;
488
- }
489
- markDynamicUsage();
490
- const secret = getDraftSecret();
491
- const isEnabled = state.headersContext
492
- ? state.headersContext.cookies.get(DRAFT_MODE_COOKIE) === secret
493
- : false;
494
- return {
495
- isEnabled,
496
- enable() {
497
- if (state.headersContext?.accessError) {
498
- throw state.headersContext.accessError;
499
- }
500
- if (state.headersContext) {
501
- state.headersContext.cookies.set(DRAFT_MODE_COOKIE, secret);
502
- }
503
- const secure = typeof process !== "undefined" && process.env?.NODE_ENV === "production" ? "; Secure" : "";
504
- state.draftModeCookieHeader = `${DRAFT_MODE_COOKIE}=${secret}; Path=/; HttpOnly; SameSite=Lax${secure}`;
505
- },
506
- disable() {
507
- if (state.headersContext?.accessError) {
508
- throw state.headersContext.accessError;
509
- }
510
- if (state.headersContext) {
511
- state.headersContext.cookies.delete(DRAFT_MODE_COOKIE);
512
- }
513
- const secure = typeof process !== "undefined" && process.env?.NODE_ENV === "production" ? "; Secure" : "";
514
- state.draftModeCookieHeader = `${DRAFT_MODE_COOKIE}=; Path=/; HttpOnly; SameSite=Lax${secure}; Max-Age=0`;
515
- },
516
- };
365
+ * Draft mode — check/toggle via a `__prerender_bypass` cookie.
366
+ *
367
+ * - `isEnabled`: true if the bypass cookie is present in the request
368
+ * - `enable()`: sets the bypass cookie (for Route Handlers)
369
+ * - `disable()`: clears the bypass cookie
370
+ */
371
+ async function draftMode() {
372
+ throwIfInsideCacheScope("draftMode()");
373
+ const state = _getState();
374
+ if (state.headersContext?.accessError) throw state.headersContext.accessError;
375
+ markDynamicUsage();
376
+ const secret = getDraftSecret();
377
+ return {
378
+ isEnabled: state.headersContext ? state.headersContext.cookies.get(DRAFT_MODE_COOKIE) === secret : false,
379
+ enable() {
380
+ if (state.headersContext?.accessError) throw state.headersContext.accessError;
381
+ if (state.headersContext) state.headersContext.cookies.set(DRAFT_MODE_COOKIE, secret);
382
+ state.draftModeCookieHeader = `${DRAFT_MODE_COOKIE}=${secret}; Path=/; HttpOnly; SameSite=Lax${typeof process !== "undefined" && process.env?.NODE_ENV === "production" ? "; Secure" : ""}`;
383
+ },
384
+ disable() {
385
+ if (state.headersContext?.accessError) throw state.headersContext.accessError;
386
+ if (state.headersContext) state.headersContext.cookies.delete(DRAFT_MODE_COOKIE);
387
+ state.draftModeCookieHeader = `${DRAFT_MODE_COOKIE}=; Path=/; HttpOnly; SameSite=Lax${typeof process !== "undefined" && process.env?.NODE_ENV === "production" ? "; Secure" : ""}; Max-Age=0`;
388
+ }
389
+ };
517
390
  }
518
- // ---------------------------------------------------------------------------
519
- // Cookie name/value validation (RFC 6265)
520
- // ---------------------------------------------------------------------------
521
391
  /**
522
- * RFC 6265 §4.1.1: cookie-name is a token (RFC 2616 §2.2).
523
- * Allowed: any visible ASCII (0x21-0x7E) except separators: ()<>@,;:\"/[]?={}
524
- */
392
+ * RFC 6265 §4.1.1: cookie-name is a token (RFC 2616 §2.2).
393
+ * Allowed: any visible ASCII (0x21-0x7E) except separators: ()<>@,;:\"/[]?={}
394
+ */
525
395
  const VALID_COOKIE_NAME_RE = /^[\x21\x23-\x27\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7A\x7C\x7E]+$/;
526
396
  function validateCookieName(name) {
527
- if (!name || !VALID_COOKIE_NAME_RE.test(name)) {
528
- throw new Error(`Invalid cookie name: ${JSON.stringify(name)}`);
529
- }
397
+ if (!name || !VALID_COOKIE_NAME_RE.test(name)) throw new Error(`Invalid cookie name: ${JSON.stringify(name)}`);
530
398
  }
531
399
  /**
532
- * Validate cookie attribute values (path, domain) to prevent injection
533
- * via semicolons, newlines, or other control characters.
534
- */
400
+ * Validate cookie attribute values (path, domain) to prevent injection
401
+ * via semicolons, newlines, or other control characters.
402
+ */
535
403
  function validateCookieAttributeValue(value, attributeName) {
536
- for (let i = 0; i < value.length; i++) {
537
- const code = value.charCodeAt(i);
538
- if (code <= 0x1f || code === 0x7f || value[i] === ";") {
539
- throw new Error(`Invalid cookie ${attributeName} value: ${JSON.stringify(value)}`);
540
- }
541
- }
542
- }
543
- // ---------------------------------------------------------------------------
544
- // RequestCookies implementation
545
- // ---------------------------------------------------------------------------
546
- class RequestCookies {
547
- _cookies;
548
- constructor(cookies) {
549
- this._cookies = cookies;
550
- }
551
- get(name) {
552
- const value = this._cookies.get(name);
553
- if (value === undefined)
554
- return undefined;
555
- return { name, value };
556
- }
557
- getAll(nameOrOptions) {
558
- const name = typeof nameOrOptions === "string" ? nameOrOptions : nameOrOptions?.name;
559
- const result = [];
560
- for (const [cookieName, value] of this._cookies) {
561
- if (name === undefined || cookieName === name) {
562
- result.push({ name: cookieName, value });
563
- }
564
- }
565
- return result;
566
- }
567
- has(name) {
568
- return this._cookies.has(name);
569
- }
570
- /**
571
- * Set a cookie. In Route Handlers and Server Actions, this produces
572
- * a Set-Cookie header on the response.
573
- */
574
- set(nameOrOptions, value, options) {
575
- let cookieName;
576
- let cookieValue;
577
- let opts;
578
- if (typeof nameOrOptions === "string") {
579
- cookieName = nameOrOptions;
580
- cookieValue = value ?? "";
581
- opts = options;
582
- }
583
- else {
584
- cookieName = nameOrOptions.name;
585
- cookieValue = nameOrOptions.value;
586
- opts = nameOrOptions;
587
- }
588
- validateCookieName(cookieName);
589
- // Update the local cookie map
590
- this._cookies.set(cookieName, cookieValue);
591
- // Build Set-Cookie header string
592
- const parts = [`${cookieName}=${encodeURIComponent(cookieValue)}`];
593
- if (opts?.path) {
594
- validateCookieAttributeValue(opts.path, "Path");
595
- parts.push(`Path=${opts.path}`);
596
- }
597
- if (opts?.domain) {
598
- validateCookieAttributeValue(opts.domain, "Domain");
599
- parts.push(`Domain=${opts.domain}`);
600
- }
601
- if (opts?.maxAge !== undefined)
602
- parts.push(`Max-Age=${opts.maxAge}`);
603
- if (opts?.expires)
604
- parts.push(`Expires=${opts.expires.toUTCString()}`);
605
- if (opts?.httpOnly)
606
- parts.push("HttpOnly");
607
- if (opts?.secure)
608
- parts.push("Secure");
609
- if (opts?.sameSite)
610
- parts.push(`SameSite=${opts.sameSite}`);
611
- _getState().pendingSetCookies.push(parts.join("; "));
612
- return this;
613
- }
614
- /**
615
- * Delete a cookie by setting it with Max-Age=0.
616
- */
617
- delete(name) {
618
- validateCookieName(name);
619
- this._cookies.delete(name);
620
- _getState().pendingSetCookies.push(`${name}=; Path=/; Max-Age=0`);
621
- return this;
622
- }
623
- get size() {
624
- return this._cookies.size;
625
- }
626
- [Symbol.iterator]() {
627
- const entries = this._cookies.entries();
628
- const iter = {
629
- [Symbol.iterator]() {
630
- return iter;
631
- },
632
- next() {
633
- const { value, done } = entries.next();
634
- if (done)
635
- return { value: undefined, done: true };
636
- const [name, val] = value;
637
- return { value: [name, { name, value: val }], done: false };
638
- },
639
- };
640
- return iter;
641
- }
642
- toString() {
643
- const parts = [];
644
- for (const [name, value] of this._cookies) {
645
- parts.push(`${name}=${value}`);
646
- }
647
- return parts.join("; ");
648
- }
649
- }
404
+ for (let i = 0; i < value.length; i++) {
405
+ const code = value.charCodeAt(i);
406
+ if (code <= 31 || code === 127 || value[i] === ";") throw new Error(`Invalid cookie ${attributeName} value: ${JSON.stringify(value)}`);
407
+ }
408
+ }
409
+ var RequestCookies = class {
410
+ _cookies;
411
+ constructor(cookies) {
412
+ this._cookies = cookies;
413
+ }
414
+ get(name) {
415
+ const value = this._cookies.get(name);
416
+ if (value === void 0) return void 0;
417
+ return {
418
+ name,
419
+ value
420
+ };
421
+ }
422
+ getAll(nameOrOptions) {
423
+ const name = typeof nameOrOptions === "string" ? nameOrOptions : nameOrOptions?.name;
424
+ const result = [];
425
+ for (const [cookieName, value] of this._cookies) if (name === void 0 || cookieName === name) result.push({
426
+ name: cookieName,
427
+ value
428
+ });
429
+ return result;
430
+ }
431
+ has(name) {
432
+ return this._cookies.has(name);
433
+ }
434
+ /**
435
+ * Set a cookie. In Route Handlers and Server Actions, this produces
436
+ * a Set-Cookie header on the response.
437
+ */
438
+ set(nameOrOptions, value, options) {
439
+ let cookieName;
440
+ let cookieValue;
441
+ let opts;
442
+ if (typeof nameOrOptions === "string") {
443
+ cookieName = nameOrOptions;
444
+ cookieValue = value ?? "";
445
+ opts = options;
446
+ } else {
447
+ cookieName = nameOrOptions.name;
448
+ cookieValue = nameOrOptions.value;
449
+ opts = nameOrOptions;
450
+ }
451
+ validateCookieName(cookieName);
452
+ this._cookies.set(cookieName, cookieValue);
453
+ const parts = [`${cookieName}=${encodeURIComponent(cookieValue)}`];
454
+ const path = opts?.path ?? "/";
455
+ validateCookieAttributeValue(path, "Path");
456
+ parts.push(`Path=${path}`);
457
+ if (opts?.domain) {
458
+ validateCookieAttributeValue(opts.domain, "Domain");
459
+ parts.push(`Domain=${opts.domain}`);
460
+ }
461
+ if (opts?.maxAge !== void 0) parts.push(`Max-Age=${opts.maxAge}`);
462
+ if (opts?.expires) parts.push(`Expires=${opts.expires.toUTCString()}`);
463
+ if (opts?.httpOnly) parts.push("HttpOnly");
464
+ if (opts?.secure) parts.push("Secure");
465
+ if (opts?.sameSite) parts.push(`SameSite=${opts.sameSite}`);
466
+ _getState().pendingSetCookies.push(parts.join("; "));
467
+ return this;
468
+ }
469
+ /**
470
+ * Delete a cookie by emitting an expired Set-Cookie header.
471
+ */
472
+ delete(nameOrOptions) {
473
+ const name = typeof nameOrOptions === "string" ? nameOrOptions : nameOrOptions.name;
474
+ const path = typeof nameOrOptions === "string" ? "/" : nameOrOptions.path ?? "/";
475
+ const domain = typeof nameOrOptions === "string" ? void 0 : nameOrOptions.domain;
476
+ validateCookieName(name);
477
+ validateCookieAttributeValue(path, "Path");
478
+ if (domain) validateCookieAttributeValue(domain, "Domain");
479
+ this._cookies.delete(name);
480
+ const parts = [`${name}=`, `Path=${path}`];
481
+ if (domain) parts.push(`Domain=${domain}`);
482
+ parts.push(`Expires=${EXPIRED_COOKIE_DATE}`);
483
+ _getState().pendingSetCookies.push(parts.join("; "));
484
+ return this;
485
+ }
486
+ get size() {
487
+ return this._cookies.size;
488
+ }
489
+ [Symbol.iterator]() {
490
+ const entries = this._cookies.entries();
491
+ const iter = {
492
+ [Symbol.iterator]() {
493
+ return iter;
494
+ },
495
+ next() {
496
+ const { value, done } = entries.next();
497
+ if (done) return {
498
+ value: void 0,
499
+ done: true
500
+ };
501
+ const [name, val] = value;
502
+ return {
503
+ value: [name, {
504
+ name,
505
+ value: val
506
+ }],
507
+ done: false
508
+ };
509
+ }
510
+ };
511
+ return iter;
512
+ }
513
+ toString() {
514
+ const parts = [];
515
+ for (const [name, value] of this._cookies) parts.push(`${name}=${value}`);
516
+ return parts.join("; ");
517
+ }
518
+ };
519
+ //#endregion
520
+ export { applyMiddlewareRequestHeaders, consumeDynamicUsage, cookies, draftMode, getAndClearPendingCookies, getDraftModeCookieHeader, getHeadersContext, headers, headersContextFromRequest, markDynamicUsage, runWithHeadersContext, setHeadersAccessPhase, setHeadersContext, throwIfInsideCacheScope };
521
+
650
522
  //# sourceMappingURL=headers.js.map