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