vinext 0.0.30 → 0.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (435) hide show
  1. package/README.md +12 -6
  2. package/dist/build/prerender.d.ts +188 -0
  3. package/dist/build/prerender.js +675 -0
  4. package/dist/build/prerender.js.map +1 -0
  5. package/dist/build/report.d.ts +45 -46
  6. package/dist/build/report.js +247 -276
  7. package/dist/build/report.js.map +1 -1
  8. package/dist/build/run-prerender.d.ts +62 -0
  9. package/dist/build/run-prerender.js +183 -0
  10. package/dist/build/run-prerender.js.map +1 -0
  11. package/dist/build/server-manifest.d.ts +19 -0
  12. package/dist/build/server-manifest.js +29 -0
  13. package/dist/build/server-manifest.js.map +1 -0
  14. package/dist/build/static-export.d.ts +51 -66
  15. package/dist/build/static-export.js +51 -545
  16. package/dist/build/static-export.js.map +1 -1
  17. package/dist/check.d.ts +26 -24
  18. package/dist/check.js +591 -571
  19. package/dist/check.js.map +1 -1
  20. package/dist/cli.d.ts +1 -15
  21. package/dist/cli.js +430 -491
  22. package/dist/cli.js.map +1 -1
  23. package/dist/client/entry.d.ts +1 -2
  24. package/dist/client/entry.js +49 -62
  25. package/dist/client/entry.js.map +1 -1
  26. package/dist/client/validate-module-path.d.ts +4 -1
  27. package/dist/client/validate-module-path.js +23 -28
  28. package/dist/client/validate-module-path.js.map +1 -1
  29. package/dist/client/vinext-next-data.d.ts +15 -20
  30. package/dist/client/vinext-next-data.js +0 -1
  31. package/dist/cloudflare/index.d.ts +3 -8
  32. package/dist/cloudflare/index.js +3 -8
  33. package/dist/cloudflare/kv-cache-handler.d.ts +95 -105
  34. package/dist/cloudflare/kv-cache-handler.js +354 -380
  35. package/dist/cloudflare/kv-cache-handler.js.map +1 -1
  36. package/dist/cloudflare/tpr.d.ts +36 -34
  37. package/dist/cloudflare/tpr.js +460 -603
  38. package/dist/cloudflare/tpr.js.map +1 -1
  39. package/dist/config/config-matchers.d.ts +31 -40
  40. package/dist/config/config-matchers.js +727 -936
  41. package/dist/config/config-matchers.js.map +1 -1
  42. package/dist/config/dotenv.d.ts +18 -11
  43. package/dist/config/dotenv.js +79 -84
  44. package/dist/config/dotenv.js.map +1 -1
  45. package/dist/config/next-config.d.ts +156 -146
  46. package/dist/config/next-config.js +374 -464
  47. package/dist/config/next-config.js.map +1 -1
  48. package/dist/deploy.d.ts +87 -96
  49. package/dist/deploy.js +490 -628
  50. package/dist/deploy.js.map +1 -1
  51. package/dist/entries/app-browser-entry.d.ts +4 -1
  52. package/dist/entries/app-browser-entry.js +12 -8
  53. package/dist/entries/app-browser-entry.js.map +1 -1
  54. package/dist/entries/app-rsc-entry.d.ts +33 -20
  55. package/dist/entries/app-rsc-entry.js +442 -211
  56. package/dist/entries/app-rsc-entry.js.map +1 -1
  57. package/dist/entries/app-ssr-entry.d.ts +9 -1
  58. package/dist/entries/app-ssr-entry.js +61 -28
  59. package/dist/entries/app-ssr-entry.js.map +1 -1
  60. package/dist/entries/pages-client-entry.d.ts +6 -2
  61. package/dist/entries/pages-client-entry.js +30 -33
  62. package/dist/entries/pages-client-entry.js.map +1 -1
  63. package/dist/entries/pages-entry-helpers.d.ts +5 -1
  64. package/dist/entries/pages-entry-helpers.js +17 -14
  65. package/dist/entries/pages-entry-helpers.js.map +1 -1
  66. package/dist/entries/pages-server-entry.d.ts +6 -2
  67. package/dist/entries/pages-server-entry.js +84 -113
  68. package/dist/entries/pages-server-entry.js.map +1 -1
  69. package/dist/index.d.ts +82 -62
  70. package/dist/index.js +2172 -3133
  71. package/dist/index.js.map +1 -1
  72. package/dist/init.d.ts +40 -37
  73. package/dist/init.js +201 -258
  74. package/dist/init.js.map +1 -1
  75. package/dist/plugins/async-hooks-stub.d.ts +7 -3
  76. package/dist/plugins/async-hooks-stub.js +39 -42
  77. package/dist/plugins/async-hooks-stub.js.map +1 -1
  78. package/dist/plugins/client-reference-dedup.d.ts +7 -3
  79. package/dist/plugins/client-reference-dedup.js +63 -88
  80. package/dist/plugins/client-reference-dedup.js.map +1 -1
  81. package/dist/routing/app-router.d.ts +100 -96
  82. package/dist/routing/app-router.js +560 -670
  83. package/dist/routing/app-router.js.map +1 -1
  84. package/dist/routing/file-matcher.d.ts +18 -15
  85. package/dist/routing/file-matcher.js +65 -65
  86. package/dist/routing/file-matcher.js.map +1 -1
  87. package/dist/routing/pages-router.d.ts +23 -24
  88. package/dist/routing/pages-router.js +147 -172
  89. package/dist/routing/pages-router.js.map +1 -1
  90. package/dist/routing/route-trie.d.ts +23 -20
  91. package/dist/routing/route-trie.js +131 -151
  92. package/dist/routing/route-trie.js.map +1 -1
  93. package/dist/routing/route-validation.d.ts +5 -2
  94. package/dist/routing/route-validation.js +98 -130
  95. package/dist/routing/route-validation.js.map +1 -1
  96. package/dist/routing/utils.d.ts +10 -7
  97. package/dist/routing/utils.js +75 -111
  98. package/dist/routing/utils.js.map +1 -1
  99. package/dist/server/api-handler.d.ts +8 -13
  100. package/dist/server/api-handler.js +161 -193
  101. package/dist/server/api-handler.js.map +1 -1
  102. package/dist/server/app-router-entry.d.ts +6 -16
  103. package/dist/server/app-router-entry.js +26 -54
  104. package/dist/server/app-router-entry.js.map +1 -1
  105. package/dist/server/dev-module-runner.d.ts +11 -64
  106. package/dist/server/dev-module-runner.js +89 -101
  107. package/dist/server/dev-module-runner.js.map +1 -1
  108. package/dist/server/dev-origin-check.d.ts +12 -10
  109. package/dist/server/dev-origin-check.js +98 -108
  110. package/dist/server/dev-origin-check.js.map +1 -1
  111. package/dist/server/dev-server.d.ts +17 -14
  112. package/dist/server/dev-server.js +542 -869
  113. package/dist/server/dev-server.js.map +1 -1
  114. package/dist/server/html.d.ts +4 -1
  115. package/dist/server/html.js +25 -26
  116. package/dist/server/html.js.map +1 -1
  117. package/dist/server/image-optimization.d.ts +31 -28
  118. package/dist/server/image-optimization.js +181 -210
  119. package/dist/server/image-optimization.js.map +1 -1
  120. package/dist/server/instrumentation.d.ts +25 -22
  121. package/dist/server/instrumentation.js +110 -122
  122. package/dist/server/instrumentation.js.map +1 -1
  123. package/dist/server/isr-cache.d.ts +16 -26
  124. package/dist/server/isr-cache.js +106 -128
  125. package/dist/server/isr-cache.js.map +1 -1
  126. package/dist/server/metadata-routes.d.ts +85 -88
  127. package/dist/server/metadata-routes.js +270 -317
  128. package/dist/server/metadata-routes.js.map +1 -1
  129. package/dist/server/middleware-codegen.d.ts +7 -4
  130. package/dist/server/middleware-codegen.js +61 -61
  131. package/dist/server/middleware-codegen.js.map +1 -1
  132. package/dist/server/middleware-request-headers.d.ts +8 -6
  133. package/dist/server/middleware-request-headers.js +47 -65
  134. package/dist/server/middleware-request-headers.js.map +1 -1
  135. package/dist/server/middleware.d.ts +31 -47
  136. package/dist/server/middleware.js +273 -404
  137. package/dist/server/middleware.js.map +1 -1
  138. package/dist/server/normalize-path.d.ts +4 -1
  139. package/dist/server/normalize-path.js +33 -47
  140. package/dist/server/normalize-path.js.map +1 -1
  141. package/dist/server/pages-i18n.d.ts +38 -30
  142. package/dist/server/pages-i18n.js +112 -139
  143. package/dist/server/pages-i18n.js.map +1 -1
  144. package/dist/server/prod-server.d.ts +19 -31
  145. package/dist/server/prod-server.js +714 -945
  146. package/dist/server/prod-server.js.map +1 -1
  147. package/dist/server/request-log.d.ts +18 -12
  148. package/dist/server/request-log.js +45 -52
  149. package/dist/server/request-log.js.map +1 -1
  150. package/dist/server/request-pipeline.d.ts +9 -17
  151. package/dist/server/request-pipeline.js +133 -184
  152. package/dist/server/request-pipeline.js.map +1 -1
  153. package/dist/server/worker-utils.d.ts +4 -1
  154. package/dist/server/worker-utils.js +31 -37
  155. package/dist/server/worker-utils.js.map +1 -1
  156. package/dist/shims/amp.d.ts +5 -2
  157. package/dist/shims/amp.js +19 -15
  158. package/dist/shims/amp.js.map +1 -1
  159. package/dist/shims/app.d.ts +8 -10
  160. package/dist/shims/app.js +0 -1
  161. package/dist/shims/cache-runtime.d.ts +20 -45
  162. package/dist/shims/cache-runtime.js +271 -422
  163. package/dist/shims/cache-runtime.js.map +1 -1
  164. package/dist/shims/cache.d.ts +130 -121
  165. package/dist/shims/cache.js +339 -427
  166. package/dist/shims/cache.js.map +1 -1
  167. package/dist/shims/client-only.d.ts +1 -18
  168. package/dist/shims/client-only.js +0 -17
  169. package/dist/shims/compat-router.d.ts +4 -1
  170. package/dist/shims/compat-router.js +23 -19
  171. package/dist/shims/compat-router.js.map +1 -1
  172. package/dist/shims/config.d.ts +7 -5
  173. package/dist/shims/config.js +16 -23
  174. package/dist/shims/config.js.map +1 -1
  175. package/dist/shims/constants.d.ts +119 -118
  176. package/dist/shims/constants.js +159 -164
  177. package/dist/shims/constants.js.map +1 -1
  178. package/dist/shims/document.d.ts +20 -16
  179. package/dist/shims/document.js +41 -22
  180. package/dist/shims/document.js.map +1 -1
  181. package/dist/shims/dynamic.d.ts +13 -22
  182. package/dist/shims/dynamic.js +122 -136
  183. package/dist/shims/dynamic.js.map +1 -1
  184. package/dist/shims/error-boundary.d.ts +22 -15
  185. package/dist/shims/error-boundary.js +81 -79
  186. package/dist/shims/error-boundary.js.map +1 -1
  187. package/dist/shims/error.d.ts +11 -12
  188. package/dist/shims/error.js +35 -39
  189. package/dist/shims/error.js.map +1 -1
  190. package/dist/shims/fetch-cache.d.ts +16 -14
  191. package/dist/shims/fetch-cache.js +437 -645
  192. package/dist/shims/fetch-cache.js.map +1 -1
  193. package/dist/shims/font-google-base.d.ts +28 -26
  194. package/dist/shims/font-google-base.js +238 -325
  195. package/dist/shims/font-google-base.js.map +1 -1
  196. package/dist/shims/font-google.d.ts +3 -3
  197. package/dist/shims/font-google.generated.d.ts +1928 -1924
  198. package/dist/shims/font-google.generated.js +1928 -2133
  199. package/dist/shims/font-google.generated.js.map +1 -1
  200. package/dist/shims/font-google.js +3 -3
  201. package/dist/shims/font-local.d.ts +28 -26
  202. package/dist/shims/font-local.js +204 -260
  203. package/dist/shims/font-local.js.map +1 -1
  204. package/dist/shims/form.d.ts +13 -27
  205. package/dist/shims/form.js +128 -180
  206. package/dist/shims/form.js.map +1 -1
  207. package/dist/shims/head-state.d.ts +8 -13
  208. package/dist/shims/head-state.js +25 -42
  209. package/dist/shims/head-state.js.map +1 -1
  210. package/dist/shims/head.d.ts +16 -20
  211. package/dist/shims/head.js +172 -250
  212. package/dist/shims/head.js.map +1 -1
  213. package/dist/shims/headers.d.ts +84 -78
  214. package/dist/shims/headers.js +447 -575
  215. package/dist/shims/headers.js.map +1 -1
  216. package/dist/shims/i18n-context.d.ts +16 -20
  217. package/dist/shims/i18n-context.js +35 -48
  218. package/dist/shims/i18n-context.js.map +1 -1
  219. package/dist/shims/i18n-state.d.ts +8 -14
  220. package/dist/shims/i18n-state.js +34 -42
  221. package/dist/shims/i18n-state.js.map +1 -1
  222. package/dist/shims/image-config.d.ts +11 -8
  223. package/dist/shims/image-config.js +50 -83
  224. package/dist/shims/image-config.js.map +1 -1
  225. package/dist/shims/image.d.ts +37 -46
  226. package/dist/shims/image.js +283 -308
  227. package/dist/shims/image.js.map +1 -1
  228. package/dist/shims/internal/api-utils.d.ts +7 -4
  229. package/dist/shims/internal/api-utils.js +0 -6
  230. package/dist/shims/internal/app-router-context.d.ts +22 -17
  231. package/dist/shims/internal/app-router-context.js +17 -13
  232. package/dist/shims/internal/app-router-context.js.map +1 -1
  233. package/dist/shims/internal/cookies.d.ts +2 -9
  234. package/dist/shims/internal/cookies.js +2 -9
  235. package/dist/shims/internal/parse-cookie-header.d.ts +4 -1
  236. package/dist/shims/internal/parse-cookie-header.js +29 -29
  237. package/dist/shims/internal/parse-cookie-header.js.map +1 -1
  238. package/dist/shims/internal/router-context.d.ts +6 -1
  239. package/dist/shims/internal/router-context.js +11 -7
  240. package/dist/shims/internal/router-context.js.map +1 -1
  241. package/dist/shims/internal/utils.d.ts +40 -37
  242. package/dist/shims/internal/utils.js +24 -30
  243. package/dist/shims/internal/utils.js.map +1 -1
  244. package/dist/shims/internal/work-unit-async-storage.d.ts +6 -10
  245. package/dist/shims/internal/work-unit-async-storage.js +14 -11
  246. package/dist/shims/internal/work-unit-async-storage.js.map +1 -1
  247. package/dist/shims/layout-segment-context.d.ts +11 -14
  248. package/dist/shims/layout-segment-context.js +24 -23
  249. package/dist/shims/layout-segment-context.js.map +1 -1
  250. package/dist/shims/legacy-image.d.ts +39 -46
  251. package/dist/shims/legacy-image.js +47 -42
  252. package/dist/shims/legacy-image.js.map +1 -1
  253. package/dist/shims/link.d.ts +32 -36
  254. package/dist/shims/link.js +255 -391
  255. package/dist/shims/link.js.map +1 -1
  256. package/dist/shims/metadata.d.ts +210 -202
  257. package/dist/shims/metadata.js +545 -546
  258. package/dist/shims/metadata.js.map +1 -1
  259. package/dist/shims/navigation-state.d.ts +10 -18
  260. package/dist/shims/navigation-state.js +66 -74
  261. package/dist/shims/navigation-state.js.map +1 -1
  262. package/dist/shims/navigation.d.ts +59 -63
  263. package/dist/shims/navigation.js +505 -704
  264. package/dist/shims/navigation.js.map +1 -1
  265. package/dist/shims/og.d.ts +2 -20
  266. package/dist/shims/og.js +2 -19
  267. package/dist/shims/readonly-url-search-params.d.ts +8 -5
  268. package/dist/shims/readonly-url-search-params.js +26 -22
  269. package/dist/shims/readonly-url-search-params.js.map +1 -1
  270. package/dist/shims/request-context.d.ts +8 -5
  271. package/dist/shims/request-context.js +50 -60
  272. package/dist/shims/request-context.js.map +1 -1
  273. package/dist/shims/request-state-types.d.ts +11 -11
  274. package/dist/shims/request-state-types.js +0 -1
  275. package/dist/shims/router-state.d.ts +13 -10
  276. package/dist/shims/router-state.js +34 -43
  277. package/dist/shims/router-state.js.map +1 -1
  278. package/dist/shims/router.d.ts +81 -85
  279. package/dist/shims/router.js +506 -628
  280. package/dist/shims/router.js.map +1 -1
  281. package/dist/shims/script.d.ts +39 -48
  282. package/dist/shims/script.js +107 -160
  283. package/dist/shims/script.js.map +1 -1
  284. package/dist/shims/server-only.d.ts +1 -19
  285. package/dist/shims/server-only.js +0 -18
  286. package/dist/shims/server.d.ts +175 -164
  287. package/dist/shims/server.js +462 -478
  288. package/dist/shims/server.js.map +1 -1
  289. package/dist/shims/unified-request-context.d.ts +20 -20
  290. package/dist/shims/unified-request-context.js +81 -99
  291. package/dist/shims/unified-request-context.js.map +1 -1
  292. package/dist/shims/url-safety.d.ts +4 -1
  293. package/dist/shims/url-safety.js +15 -11
  294. package/dist/shims/url-safety.js.map +1 -1
  295. package/dist/shims/url-utils.d.ts +8 -5
  296. package/dist/shims/url-utils.js +62 -93
  297. package/dist/shims/url-utils.js.map +1 -1
  298. package/dist/shims/web-vitals.d.ts +10 -8
  299. package/dist/shims/web-vitals.js +9 -15
  300. package/dist/shims/web-vitals.js.map +1 -1
  301. package/dist/utils/base-path.d.ts +5 -2
  302. package/dist/utils/base-path.js +21 -19
  303. package/dist/utils/base-path.js.map +1 -1
  304. package/dist/utils/domain-locale.d.ts +17 -9
  305. package/dist/utils/domain-locale.js +36 -56
  306. package/dist/utils/domain-locale.js.map +1 -1
  307. package/dist/utils/hash.d.ts +4 -1
  308. package/dist/utils/hash.js +19 -17
  309. package/dist/utils/hash.js.map +1 -1
  310. package/dist/utils/manifest-paths.d.ts +6 -3
  311. package/dist/utils/manifest-paths.js +15 -16
  312. package/dist/utils/manifest-paths.js.map +1 -1
  313. package/dist/utils/project.d.ts +13 -11
  314. package/dist/utils/project.js +169 -216
  315. package/dist/utils/project.js.map +1 -1
  316. package/dist/utils/query.d.ts +8 -6
  317. package/dist/utils/query.js +57 -67
  318. package/dist/utils/query.js.map +1 -1
  319. package/package.json +10 -9
  320. package/dist/build/report.d.ts.map +0 -1
  321. package/dist/build/static-export.d.ts.map +0 -1
  322. package/dist/check.d.ts.map +0 -1
  323. package/dist/cli.d.ts.map +0 -1
  324. package/dist/client/entry.d.ts.map +0 -1
  325. package/dist/client/validate-module-path.d.ts.map +0 -1
  326. package/dist/client/vinext-next-data.d.ts.map +0 -1
  327. package/dist/client/vinext-next-data.js.map +0 -1
  328. package/dist/cloudflare/index.d.ts.map +0 -1
  329. package/dist/cloudflare/index.js.map +0 -1
  330. package/dist/cloudflare/kv-cache-handler.d.ts.map +0 -1
  331. package/dist/cloudflare/tpr.d.ts.map +0 -1
  332. package/dist/config/config-matchers.d.ts.map +0 -1
  333. package/dist/config/dotenv.d.ts.map +0 -1
  334. package/dist/config/next-config.d.ts.map +0 -1
  335. package/dist/deploy.d.ts.map +0 -1
  336. package/dist/entries/app-browser-entry.d.ts.map +0 -1
  337. package/dist/entries/app-rsc-entry.d.ts.map +0 -1
  338. package/dist/entries/app-ssr-entry.d.ts.map +0 -1
  339. package/dist/entries/pages-client-entry.d.ts.map +0 -1
  340. package/dist/entries/pages-entry-helpers.d.ts.map +0 -1
  341. package/dist/entries/pages-server-entry.d.ts.map +0 -1
  342. package/dist/index.d.ts.map +0 -1
  343. package/dist/init.d.ts.map +0 -1
  344. package/dist/plugins/async-hooks-stub.d.ts.map +0 -1
  345. package/dist/plugins/client-reference-dedup.d.ts.map +0 -1
  346. package/dist/routing/app-router.d.ts.map +0 -1
  347. package/dist/routing/file-matcher.d.ts.map +0 -1
  348. package/dist/routing/pages-router.d.ts.map +0 -1
  349. package/dist/routing/route-trie.d.ts.map +0 -1
  350. package/dist/routing/route-validation.d.ts.map +0 -1
  351. package/dist/routing/utils.d.ts.map +0 -1
  352. package/dist/server/api-handler.d.ts.map +0 -1
  353. package/dist/server/app-router-entry.d.ts.map +0 -1
  354. package/dist/server/dev-module-runner.d.ts.map +0 -1
  355. package/dist/server/dev-origin-check.d.ts.map +0 -1
  356. package/dist/server/dev-server.d.ts.map +0 -1
  357. package/dist/server/html.d.ts.map +0 -1
  358. package/dist/server/image-optimization.d.ts.map +0 -1
  359. package/dist/server/instrumentation.d.ts.map +0 -1
  360. package/dist/server/isr-cache.d.ts.map +0 -1
  361. package/dist/server/metadata-routes.d.ts.map +0 -1
  362. package/dist/server/middleware-codegen.d.ts.map +0 -1
  363. package/dist/server/middleware-request-headers.d.ts.map +0 -1
  364. package/dist/server/middleware.d.ts.map +0 -1
  365. package/dist/server/normalize-path.d.ts.map +0 -1
  366. package/dist/server/pages-i18n.d.ts.map +0 -1
  367. package/dist/server/prod-server.d.ts.map +0 -1
  368. package/dist/server/request-log.d.ts.map +0 -1
  369. package/dist/server/request-pipeline.d.ts.map +0 -1
  370. package/dist/server/worker-utils.d.ts.map +0 -1
  371. package/dist/shims/amp.d.ts.map +0 -1
  372. package/dist/shims/app.d.ts.map +0 -1
  373. package/dist/shims/app.js.map +0 -1
  374. package/dist/shims/cache-runtime.d.ts.map +0 -1
  375. package/dist/shims/cache.d.ts.map +0 -1
  376. package/dist/shims/client-only.d.ts.map +0 -1
  377. package/dist/shims/client-only.js.map +0 -1
  378. package/dist/shims/compat-router.d.ts.map +0 -1
  379. package/dist/shims/config.d.ts.map +0 -1
  380. package/dist/shims/constants.d.ts.map +0 -1
  381. package/dist/shims/document.d.ts.map +0 -1
  382. package/dist/shims/dynamic.d.ts.map +0 -1
  383. package/dist/shims/error-boundary.d.ts.map +0 -1
  384. package/dist/shims/error.d.ts.map +0 -1
  385. package/dist/shims/fetch-cache.d.ts.map +0 -1
  386. package/dist/shims/font-google-base.d.ts.map +0 -1
  387. package/dist/shims/font-google.d.ts.map +0 -1
  388. package/dist/shims/font-google.generated.d.ts.map +0 -1
  389. package/dist/shims/font-google.js.map +0 -1
  390. package/dist/shims/font-local.d.ts.map +0 -1
  391. package/dist/shims/form.d.ts.map +0 -1
  392. package/dist/shims/head-state.d.ts.map +0 -1
  393. package/dist/shims/head.d.ts.map +0 -1
  394. package/dist/shims/headers.d.ts.map +0 -1
  395. package/dist/shims/i18n-context.d.ts.map +0 -1
  396. package/dist/shims/i18n-state.d.ts.map +0 -1
  397. package/dist/shims/image-config.d.ts.map +0 -1
  398. package/dist/shims/image.d.ts.map +0 -1
  399. package/dist/shims/internal/api-utils.d.ts.map +0 -1
  400. package/dist/shims/internal/api-utils.js.map +0 -1
  401. package/dist/shims/internal/app-router-context.d.ts.map +0 -1
  402. package/dist/shims/internal/cookies.d.ts.map +0 -1
  403. package/dist/shims/internal/cookies.js.map +0 -1
  404. package/dist/shims/internal/parse-cookie-header.d.ts.map +0 -1
  405. package/dist/shims/internal/router-context.d.ts.map +0 -1
  406. package/dist/shims/internal/utils.d.ts.map +0 -1
  407. package/dist/shims/internal/work-unit-async-storage.d.ts.map +0 -1
  408. package/dist/shims/layout-segment-context.d.ts.map +0 -1
  409. package/dist/shims/legacy-image.d.ts.map +0 -1
  410. package/dist/shims/link.d.ts.map +0 -1
  411. package/dist/shims/metadata.d.ts.map +0 -1
  412. package/dist/shims/navigation-state.d.ts.map +0 -1
  413. package/dist/shims/navigation.d.ts.map +0 -1
  414. package/dist/shims/og.d.ts.map +0 -1
  415. package/dist/shims/og.js.map +0 -1
  416. package/dist/shims/readonly-url-search-params.d.ts.map +0 -1
  417. package/dist/shims/request-context.d.ts.map +0 -1
  418. package/dist/shims/request-state-types.d.ts.map +0 -1
  419. package/dist/shims/request-state-types.js.map +0 -1
  420. package/dist/shims/router-state.d.ts.map +0 -1
  421. package/dist/shims/router.d.ts.map +0 -1
  422. package/dist/shims/script.d.ts.map +0 -1
  423. package/dist/shims/server-only.d.ts.map +0 -1
  424. package/dist/shims/server-only.js.map +0 -1
  425. package/dist/shims/server.d.ts.map +0 -1
  426. package/dist/shims/unified-request-context.d.ts.map +0 -1
  427. package/dist/shims/url-safety.d.ts.map +0 -1
  428. package/dist/shims/url-utils.d.ts.map +0 -1
  429. package/dist/shims/web-vitals.d.ts.map +0 -1
  430. package/dist/utils/base-path.d.ts.map +0 -1
  431. package/dist/utils/domain-locale.d.ts.map +0 -1
  432. package/dist/utils/hash.d.ts.map +0 -1
  433. package/dist/utils/manifest-paths.d.ts.map +0 -1
  434. package/dist/utils/project.d.ts.map +0 -1
  435. package/dist/utils/query.d.ts.map +0 -1
@@ -1,479 +1,391 @@
1
- /**
2
- * next/cache shim
3
- *
4
- * Provides the Next.js caching API surface: revalidateTag, revalidatePath,
5
- * unstable_cache. Backed by a pluggable CacheHandler that defaults to
6
- * in-memory but can be swapped for Cloudflare KV, Redis, DynamoDB, etc.
7
- *
8
- * The CacheHandler interface matches Next.js 16's CacheHandler class, so
9
- * existing community adapters (@neshca/cache-handler, @opennextjs/aws, etc.)
10
- * can be used directly.
11
- *
12
- * Configuration (in vite.config.ts or next.config.js):
13
- * vinext({ cacheHandler: './my-cache-handler.ts' })
14
- *
15
- * Or set at runtime:
16
- * import { setCacheHandler } from 'next/cache';
17
- * setCacheHandler(new MyCacheHandler());
18
- */
19
- import { markDynamicUsage as _markDynamic } from "./headers.js";
20
- import { AsyncLocalStorage } from "node:async_hooks";
1
+ import { getRequestContext, isInsideUnifiedScope, runWithUnifiedStateMutation } from "./unified-request-context.js";
2
+ import { getRequestExecutionContext, runWithExecutionContext } from "./request-context.js";
3
+ import { markDynamicUsage } from "./headers.js";
21
4
  import { fnv1a64 } from "../utils/hash.js";
22
- import { isInsideUnifiedScope, getRequestContext, runWithUnifiedStateMutation, } from "./unified-request-context.js";
5
+ import { AsyncLocalStorage } from "node:async_hooks";
6
+ //#region src/shims/cache.ts
7
+ /**
8
+ * next/cache shim
9
+ *
10
+ * Provides the Next.js caching API surface: revalidateTag, revalidatePath,
11
+ * unstable_cache. Backed by a pluggable CacheHandler that defaults to
12
+ * in-memory but can be swapped for Cloudflare KV, Redis, DynamoDB, etc.
13
+ *
14
+ * The CacheHandler interface matches Next.js 16's CacheHandler class, so
15
+ * existing community adapters (@neshca/cache-handler, @opennextjs/aws, etc.)
16
+ * can be used directly.
17
+ *
18
+ * Configuration (in vite.config.ts or next.config.js):
19
+ * vinext({ cacheHandler: './my-cache-handler.ts' })
20
+ *
21
+ * Or set at runtime:
22
+ * import { setCacheHandler } from 'next/cache';
23
+ * setCacheHandler(new MyCacheHandler());
24
+ */
23
25
  /** @internal Set by cache-runtime.ts on import to avoid circular dependency */
24
26
  let _getCacheContextFn = null;
25
27
  /**
26
- * Register the cache context accessor. Called by cache-runtime.ts on load.
27
- * @internal
28
- */
29
- export function _registerCacheContextAccessor(fn) {
30
- _getCacheContextFn = fn;
31
- }
32
- export class MemoryCacheHandler {
33
- store = new Map();
34
- tagRevalidatedAt = new Map();
35
- async get(key, _ctx) {
36
- const entry = this.store.get(key);
37
- if (!entry)
38
- return null;
39
- // Check tag-based invalidation first — if tag was invalidated, treat as hard miss
40
- for (const tag of entry.tags) {
41
- const revalidatedAt = this.tagRevalidatedAt.get(tag);
42
- if (revalidatedAt && revalidatedAt >= entry.lastModified) {
43
- this.store.delete(key);
44
- return null;
45
- }
46
- }
47
- // Check time-based expiry — return stale entry with cacheState="stale"
48
- // instead of deleting, so ISR can serve stale-while-revalidate
49
- if (entry.revalidateAt !== null && Date.now() > entry.revalidateAt) {
50
- return {
51
- lastModified: entry.lastModified,
52
- value: entry.value,
53
- cacheState: "stale",
54
- };
55
- }
56
- return {
57
- lastModified: entry.lastModified,
58
- value: entry.value,
59
- };
60
- }
61
- async set(key, data, ctx) {
62
- const tags = [];
63
- if (data && "tags" in data && Array.isArray(data.tags)) {
64
- tags.push(...data.tags);
65
- }
66
- if (ctx && "tags" in ctx && Array.isArray(ctx.tags)) {
67
- tags.push(...ctx.tags);
68
- }
69
- // Resolve effective revalidate — data overrides ctx.
70
- // revalidate: 0 means "don't cache", so skip storage entirely.
71
- let effectiveRevalidate;
72
- if (ctx) {
73
- const revalidate = ctx.cacheControl?.revalidate ?? ctx.revalidate;
74
- if (typeof revalidate === "number") {
75
- effectiveRevalidate = revalidate;
76
- }
77
- }
78
- if (data && "revalidate" in data && typeof data.revalidate === "number") {
79
- effectiveRevalidate = data.revalidate;
80
- }
81
- if (effectiveRevalidate === 0)
82
- return;
83
- const revalidateAt = typeof effectiveRevalidate === "number" && effectiveRevalidate > 0
84
- ? Date.now() + effectiveRevalidate * 1000
85
- : null;
86
- this.store.set(key, {
87
- value: data,
88
- tags,
89
- lastModified: Date.now(),
90
- revalidateAt,
91
- });
92
- }
93
- async revalidateTag(tags, _durations) {
94
- const tagList = Array.isArray(tags) ? tags : [tags];
95
- const now = Date.now();
96
- for (const tag of tagList) {
97
- this.tagRevalidatedAt.set(tag, now);
98
- }
99
- }
100
- resetRequestCache() {
101
- // No-op for the simple memory cache. In a production adapter,
102
- // this would clear per-request caches (e.g., dedup fetch calls).
103
- }
28
+ * Register the cache context accessor. Called by cache-runtime.ts on load.
29
+ * @internal
30
+ */
31
+ function _registerCacheContextAccessor(fn) {
32
+ _getCacheContextFn = fn;
104
33
  }
105
- export { runWithExecutionContext, getRequestExecutionContext } from "./request-context.js";
106
- // ---------------------------------------------------------------------------
107
- // Active cache handler — the singleton used by next/cache API functions.
108
- // Defaults to MemoryCacheHandler, can be swapped at runtime.
109
- //
110
- // Stored on globalThis via Symbol.for so that setCacheHandler() called in the
111
- // Cloudflare Worker environment (worker/index.ts) is visible to getCacheHandler()
112
- // called in the RSC environment (generated RSC entry). Without this, the two
113
- // environments load separate module instances and operate on different
114
- // `activeHandler` variables setCacheHandler sets KVCacheHandler in one copy,
115
- // but getCacheHandler returns MemoryCacheHandler from the other copy.
116
- // ---------------------------------------------------------------------------
34
+ var NoOpCacheHandler = class {
35
+ async get(_key, _ctx) {
36
+ return null;
37
+ }
38
+ async set(_key, _data, _ctx) {}
39
+ async revalidateTag(_tags, _durations) {}
40
+ };
41
+ var MemoryCacheHandler = class {
42
+ store = /* @__PURE__ */ new Map();
43
+ tagRevalidatedAt = /* @__PURE__ */ new Map();
44
+ async get(key, _ctx) {
45
+ const entry = this.store.get(key);
46
+ if (!entry) return null;
47
+ for (const tag of entry.tags) {
48
+ const revalidatedAt = this.tagRevalidatedAt.get(tag);
49
+ if (revalidatedAt && revalidatedAt >= entry.lastModified) {
50
+ this.store.delete(key);
51
+ return null;
52
+ }
53
+ }
54
+ if (entry.revalidateAt !== null && Date.now() > entry.revalidateAt) return {
55
+ lastModified: entry.lastModified,
56
+ value: entry.value,
57
+ cacheState: "stale"
58
+ };
59
+ return {
60
+ lastModified: entry.lastModified,
61
+ value: entry.value
62
+ };
63
+ }
64
+ async set(key, data, ctx) {
65
+ const typedCtx = ctx;
66
+ const tagSet = /* @__PURE__ */ new Set();
67
+ if (data && "tags" in data && Array.isArray(data.tags)) for (const t of data.tags) tagSet.add(t);
68
+ if (typedCtx && Array.isArray(typedCtx.tags)) for (const t of typedCtx.tags) tagSet.add(t);
69
+ const tags = [...tagSet];
70
+ let effectiveRevalidate;
71
+ if (typedCtx) {
72
+ const revalidate = typedCtx.cacheControl?.revalidate ?? typedCtx.revalidate;
73
+ if (typeof revalidate === "number") effectiveRevalidate = revalidate;
74
+ }
75
+ if (data && "revalidate" in data && typeof data.revalidate === "number") effectiveRevalidate = data.revalidate;
76
+ if (effectiveRevalidate === 0) return;
77
+ const revalidateAt = typeof effectiveRevalidate === "number" && effectiveRevalidate > 0 ? Date.now() + effectiveRevalidate * 1e3 : null;
78
+ this.store.set(key, {
79
+ value: data,
80
+ tags,
81
+ lastModified: Date.now(),
82
+ revalidateAt
83
+ });
84
+ }
85
+ async revalidateTag(tags, _durations) {
86
+ const tagList = Array.isArray(tags) ? tags : [tags];
87
+ const now = Date.now();
88
+ for (const tag of tagList) this.tagRevalidatedAt.set(tag, now);
89
+ }
90
+ resetRequestCache() {}
91
+ };
117
92
  const _HANDLER_KEY = Symbol.for("vinext.cacheHandler");
118
93
  const _gHandler = globalThis;
119
94
  function _getActiveHandler() {
120
- return _gHandler[_HANDLER_KEY] ?? (_gHandler[_HANDLER_KEY] = new MemoryCacheHandler());
95
+ return _gHandler[_HANDLER_KEY] ?? (_gHandler[_HANDLER_KEY] = new MemoryCacheHandler());
121
96
  }
122
97
  /**
123
- * Set a custom CacheHandler. Call this during server startup to
124
- * plug in Cloudflare KV, Redis, DynamoDB, or any other backend.
125
- *
126
- * The handler must implement the CacheHandler interface (same shape
127
- * as Next.js 16's CacheHandler class).
128
- */
129
- export function setCacheHandler(handler) {
130
- _gHandler[_HANDLER_KEY] = handler;
98
+ * Set a custom CacheHandler. Call this during server startup to
99
+ * plug in Cloudflare KV, Redis, DynamoDB, or any other backend.
100
+ *
101
+ * The handler must implement the CacheHandler interface (same shape
102
+ * as Next.js 16's CacheHandler class).
103
+ */
104
+ function setCacheHandler(handler) {
105
+ _gHandler[_HANDLER_KEY] = handler;
131
106
  }
132
107
  /**
133
- * Get the active CacheHandler (for internal use or testing).
134
- */
135
- export function getCacheHandler() {
136
- return _getActiveHandler();
108
+ * Get the active CacheHandler (for internal use or testing).
109
+ */
110
+ function getCacheHandler() {
111
+ return _getActiveHandler();
137
112
  }
138
- // ---------------------------------------------------------------------------
139
- // Public API — what app code imports from 'next/cache'
140
- // ---------------------------------------------------------------------------
141
113
  /**
142
- * Revalidate cached data associated with a specific cache tag.
143
- *
144
- * Works with both `fetch(..., { next: { tags: ['myTag'] } })` and
145
- * `unstable_cache(fn, keys, { tags: ['myTag'] })`.
146
- */
147
- /**
148
- * Revalidate cached data associated with a specific cache tag.
149
- *
150
- * Next.js 16 updated signature: requires a cacheLife profile as second argument
151
- * for stale-while-revalidate (SWR) behavior. The single-argument form is
152
- * deprecated but still supported for backward compatibility.
153
- *
154
- * @param tag - Cache tag to revalidate
155
- * @param profile - cacheLife profile name (e.g. 'max', 'hours') or inline { expire: number }
156
- */
157
- export async function revalidateTag(tag, profile) {
158
- // Resolve the profile to durations for the handler
159
- let durations;
160
- if (typeof profile === "string") {
161
- const resolved = cacheLifeProfiles[profile];
162
- if (resolved) {
163
- durations = { expire: resolved.expire };
164
- }
165
- }
166
- else if (profile && typeof profile === "object") {
167
- durations = profile;
168
- }
169
- await _getActiveHandler().revalidateTag(tag, durations);
114
+ * Revalidate cached data associated with a specific cache tag.
115
+ *
116
+ * Works with both `fetch(..., { next: { tags: ['myTag'] } })` and
117
+ * `unstable_cache(fn, keys, { tags: ['myTag'] })`.
118
+ *
119
+ * Next.js 16 updated signature: accepts a cacheLife profile as second argument
120
+ * for stale-while-revalidate (SWR) behavior. The single-argument form is
121
+ * deprecated but still supported for backward compatibility.
122
+ *
123
+ * @param tag - Cache tag to revalidate
124
+ * @param profile - cacheLife profile name (e.g. 'max', 'hours') or inline { expire: number }
125
+ */
126
+ async function revalidateTag(tag, profile) {
127
+ let durations;
128
+ if (typeof profile === "string") {
129
+ const resolved = cacheLifeProfiles[profile];
130
+ if (resolved) durations = { expire: resolved.expire };
131
+ } else if (profile && typeof profile === "object") durations = profile;
132
+ await _getActiveHandler().revalidateTag(tag, durations);
170
133
  }
171
134
  /**
172
- * Revalidate cached data associated with a specific path.
173
- *
174
- * Under the hood, Next.js converts paths to internal tags.
175
- * We use a `_N_T_/path` prefix convention for path-based tags.
176
- */
177
- export async function revalidatePath(path, _type) {
178
- // Next.js internally converts paths to tags with a prefix
179
- const pathTag = `_N_T_${path}`;
180
- await _getActiveHandler().revalidateTag([path, pathTag]);
135
+ * Revalidate cached data associated with a specific path.
136
+ *
137
+ * Invalidation works through implicit tags generated at render time by
138
+ * `__pageCacheTags` (in app-rsc-entry.ts), matching Next.js's getDerivedTags:
139
+ *
140
+ * - `type: "layout"` → invalidates `_N_T_<path>/layout`, cascading to all
141
+ * descendant pages (they carry ancestor layout tags from render time).
142
+ * - `type: "page"` → invalidates `_N_T_<path>/page`, targeting only the
143
+ * exact route's page component.
144
+ * - No type → invalidates `_N_T_<path>` (broader, exact path).
145
+ *
146
+ * The `type` parameter is App Router only — Pages Router does not generate
147
+ * layout/page hierarchy tags, so only no-type invalidation applies there.
148
+ */
149
+ async function revalidatePath(path, type) {
150
+ const stem = path.endsWith("/") ? path.slice(0, -1) : path;
151
+ const tag = type ? `_N_T_${stem}/${type}` : `_N_T_${stem || "/"}`;
152
+ await _getActiveHandler().revalidateTag(tag);
181
153
  }
182
154
  /**
183
- * Expire and immediately refresh cached data for a tag (Next.js 16).
184
- *
185
- * Server Actions-only API that provides read-your-writes semantics:
186
- * the cache entry is expired and fresh data is read within the same request,
187
- * so the user immediately sees their changes.
188
- *
189
- * Use this for interactive features (forms, user settings) where users
190
- * expect to see their updates instantly.
191
- *
192
- * @param tag - Cache tag to expire and refresh
193
- */
194
- export async function updateTag(tag) {
195
- // Expire the tag immediately (same as revalidateTag without SWR)
196
- await _getActiveHandler().revalidateTag(tag);
197
- }
155
+ * No-op shim for API compatibility.
156
+ *
157
+ * In Next.js, calling `refresh()` inside a Server Action triggers a
158
+ * client-side router refresh so the user immediately sees updated data.
159
+ * vinext does not yet implement the Server Actions refresh protocol,
160
+ * so this function has no effect.
161
+ */
162
+ function refresh() {}
198
163
  /**
199
- * Refresh uncached data on the page (Next.js 16).
200
- *
201
- * Server Actions-only API that signals the client to re-fetch dynamic
202
- * (uncached) data without touching the cache. Complementary to the
203
- * client-side router.refresh().
204
- *
205
- * Use this when you need to refresh data like notification counts,
206
- * live metrics, or status indicators after performing a server action.
207
- */
208
- export function refresh() {
209
- // In our implementation, this is a signal that the client should
210
- // refresh dynamic data. The actual refresh happens on the client side
211
- // via the RSC protocol — the server action response triggers a
212
- // client-side navigation refresh.
213
- // For now, this is a no-op on the server; the Server Action response
214
- // mechanism already handles re-rendering the affected RSC tree.
164
+ * Expire a cache tag immediately (Next.js 16).
165
+ *
166
+ * Server Actions-only API that expires a tag so the next request
167
+ * fetches fresh data. Unlike `revalidateTag`, which uses stale-while-revalidate,
168
+ * `updateTag` invalidates synchronously within the same request context.
169
+ */
170
+ async function updateTag(tag) {
171
+ await _getActiveHandler().revalidateTag(tag);
215
172
  }
216
173
  /**
217
- * Opt out of static rendering and indicate a particular component should not be cached.
218
- *
219
- * In Next.js, calling noStore() inside a Server Component ensures the component
220
- * is dynamically rendered. In our implementation, this is a no-op since we don't
221
- * have the same static/dynamic rendering split — all server rendering is on-demand.
222
- * It's provided for API compatibility so apps importing it don't break.
223
- */
224
- export function unstable_noStore() {
225
- // Signal dynamic usage so ISR-configured routes bypass the cache
226
- _markDynamic();
174
+ * Opt out of static rendering and indicate a particular component should not be cached.
175
+ *
176
+ * In Next.js, calling noStore() inside a Server Component ensures the component
177
+ * is dynamically rendered. In our implementation, this is a no-op since we don't
178
+ * have the same static/dynamic rendering split — all server rendering is on-demand.
179
+ * It's provided for API compatibility so apps importing it don't break.
180
+ */
181
+ function unstable_noStore() {
182
+ markDynamicUsage();
227
183
  }
228
- // Also export as `noStore` (Next.js 15+ naming)
229
- export { unstable_noStore as noStore };
230
184
  const _ALS_KEY = Symbol.for("vinext.cache.als");
231
185
  const _FALLBACK_KEY = Symbol.for("vinext.cache.fallback");
232
186
  const _g = globalThis;
233
- const _cacheAls = (_g[_ALS_KEY] ??=
234
- new AsyncLocalStorage());
235
- const _cacheFallbackState = (_g[_FALLBACK_KEY] ??= {
236
- requestScopedCacheLife: null,
237
- });
187
+ const _cacheAls = _g[_ALS_KEY] ??= new AsyncLocalStorage();
188
+ const _cacheFallbackState = _g[_FALLBACK_KEY] ??= { requestScopedCacheLife: null };
238
189
  function _getCacheState() {
239
- if (isInsideUnifiedScope()) {
240
- return getRequestContext();
241
- }
242
- return _cacheAls.getStore() ?? _cacheFallbackState;
190
+ if (isInsideUnifiedScope()) return getRequestContext();
191
+ return _cacheAls.getStore() ?? _cacheFallbackState;
243
192
  }
244
193
  /**
245
- * Run a function within a cache state ALS scope.
246
- * Ensures per-request isolation for request-scoped cacheLife config
247
- * on concurrent runtimes.
248
- * @internal
249
- */
250
- export function _runWithCacheState(fn) {
251
- if (isInsideUnifiedScope()) {
252
- return runWithUnifiedStateMutation((uCtx) => {
253
- uCtx.requestScopedCacheLife = null;
254
- }, fn);
255
- }
256
- const state = {
257
- requestScopedCacheLife: null,
258
- };
259
- return _cacheAls.run(state, fn);
194
+ * Run a function within a cache state ALS scope.
195
+ * Ensures per-request isolation for request-scoped cacheLife config
196
+ * on concurrent runtimes.
197
+ * @internal
198
+ */
199
+ function _runWithCacheState(fn) {
200
+ if (isInsideUnifiedScope()) return runWithUnifiedStateMutation((uCtx) => {
201
+ uCtx.requestScopedCacheLife = null;
202
+ }, fn);
203
+ return _cacheAls.run({ requestScopedCacheLife: null }, fn);
260
204
  }
261
205
  /**
262
- * Initialize cache ALS for a new request. Call at request entry.
263
- * Only needed when not using _runWithCacheState() (legacy path).
264
- * @internal
265
- */
266
- export function _initRequestScopedCacheState() {
267
- _getCacheState().requestScopedCacheLife = null;
206
+ * Initialize cache ALS for a new request. Call at request entry.
207
+ * Only needed when not using _runWithCacheState() (legacy path).
208
+ * @internal
209
+ */
210
+ function _initRequestScopedCacheState() {
211
+ _getCacheState().requestScopedCacheLife = null;
268
212
  }
269
213
  /**
270
- * Set a request-scoped cache life config. Called by cacheLife() when outside
271
- * a "use cache" function context.
272
- * @internal
273
- */
274
- export function _setRequestScopedCacheLife(config) {
275
- const state = _getCacheState();
276
- if (state.requestScopedCacheLife === null) {
277
- state.requestScopedCacheLife = { ...config };
278
- }
279
- else {
280
- // Minimum-wins rule
281
- if (config.stale !== undefined) {
282
- state.requestScopedCacheLife.stale =
283
- state.requestScopedCacheLife.stale !== undefined
284
- ? Math.min(state.requestScopedCacheLife.stale, config.stale)
285
- : config.stale;
286
- }
287
- if (config.revalidate !== undefined) {
288
- state.requestScopedCacheLife.revalidate =
289
- state.requestScopedCacheLife.revalidate !== undefined
290
- ? Math.min(state.requestScopedCacheLife.revalidate, config.revalidate)
291
- : config.revalidate;
292
- }
293
- if (config.expire !== undefined) {
294
- state.requestScopedCacheLife.expire =
295
- state.requestScopedCacheLife.expire !== undefined
296
- ? Math.min(state.requestScopedCacheLife.expire, config.expire)
297
- : config.expire;
298
- }
299
- }
214
+ * Set a request-scoped cache life config. Called by cacheLife() when outside
215
+ * a "use cache" function context.
216
+ * @internal
217
+ */
218
+ function _setRequestScopedCacheLife(config) {
219
+ const state = _getCacheState();
220
+ if (state.requestScopedCacheLife === null) state.requestScopedCacheLife = { ...config };
221
+ else {
222
+ if (config.stale !== void 0) state.requestScopedCacheLife.stale = state.requestScopedCacheLife.stale !== void 0 ? Math.min(state.requestScopedCacheLife.stale, config.stale) : config.stale;
223
+ if (config.revalidate !== void 0) state.requestScopedCacheLife.revalidate = state.requestScopedCacheLife.revalidate !== void 0 ? Math.min(state.requestScopedCacheLife.revalidate, config.revalidate) : config.revalidate;
224
+ if (config.expire !== void 0) state.requestScopedCacheLife.expire = state.requestScopedCacheLife.expire !== void 0 ? Math.min(state.requestScopedCacheLife.expire, config.expire) : config.expire;
225
+ }
300
226
  }
301
227
  /**
302
- * Consume and reset the request-scoped cache life. Returns null if none was set.
303
- * @internal
304
- */
305
- export function _consumeRequestScopedCacheLife() {
306
- const state = _getCacheState();
307
- const config = state.requestScopedCacheLife;
308
- state.requestScopedCacheLife = null;
309
- return config;
228
+ * Consume and reset the request-scoped cache life. Returns null if none was set.
229
+ * @internal
230
+ */
231
+ function _consumeRequestScopedCacheLife() {
232
+ const state = _getCacheState();
233
+ const config = state.requestScopedCacheLife;
234
+ state.requestScopedCacheLife = null;
235
+ return config;
310
236
  }
311
237
  /**
312
- * Built-in cache life profiles matching Next.js 16.
313
- */
314
- export const cacheLifeProfiles = {
315
- default: { revalidate: 900, expire: 4294967294 },
316
- seconds: { stale: 30, revalidate: 1, expire: 60 },
317
- minutes: { stale: 300, revalidate: 60, expire: 3600 },
318
- hours: { stale: 300, revalidate: 3600, expire: 86400 },
319
- days: { stale: 300, revalidate: 86400, expire: 604800 },
320
- weeks: { stale: 300, revalidate: 604800, expire: 2592000 },
321
- max: { stale: 300, revalidate: 2592000, expire: 31536000 },
238
+ * Built-in cache life profiles matching Next.js 16.
239
+ */
240
+ const cacheLifeProfiles = {
241
+ default: {
242
+ revalidate: 900,
243
+ expire: 4294967294
244
+ },
245
+ seconds: {
246
+ stale: 30,
247
+ revalidate: 1,
248
+ expire: 60
249
+ },
250
+ minutes: {
251
+ stale: 300,
252
+ revalidate: 60,
253
+ expire: 3600
254
+ },
255
+ hours: {
256
+ stale: 300,
257
+ revalidate: 3600,
258
+ expire: 86400
259
+ },
260
+ days: {
261
+ stale: 300,
262
+ revalidate: 86400,
263
+ expire: 604800
264
+ },
265
+ weeks: {
266
+ stale: 300,
267
+ revalidate: 604800,
268
+ expire: 2592e3
269
+ },
270
+ max: {
271
+ stale: 300,
272
+ revalidate: 2592e3,
273
+ expire: 31536e3
274
+ }
322
275
  };
323
276
  /**
324
- * Set the cache lifetime for a "use cache" function.
325
- *
326
- * Accepts either a built-in profile name (e.g., "hours", "days") or a custom
327
- * configuration object. In Next.js, this only works inside "use cache" functions.
328
- *
329
- * When called inside a "use cache" function, this sets the cache TTL.
330
- * The "minimum-wins" rule applies: if called multiple times, the shortest
331
- * duration for each field wins.
332
- *
333
- * When called outside a "use cache" context, this is a validated no-op.
334
- */
335
- export function cacheLife(profile) {
336
- let resolvedConfig;
337
- if (typeof profile === "string") {
338
- // Validate the profile name exists
339
- if (!cacheLifeProfiles[profile]) {
340
- console.warn(`[vinext] cacheLife: unknown profile "${profile}". ` +
341
- `Available profiles: ${Object.keys(cacheLifeProfiles).join(", ")}`);
342
- return;
343
- }
344
- resolvedConfig = { ...cacheLifeProfiles[profile] };
345
- }
346
- else if (typeof profile === "object" && profile !== null) {
347
- // Validate the config shape
348
- if (profile.expire !== undefined &&
349
- profile.revalidate !== undefined &&
350
- profile.expire < profile.revalidate) {
351
- console.warn("[vinext] cacheLife: expire must be >= revalidate");
352
- }
353
- resolvedConfig = { ...profile };
354
- }
355
- else {
356
- return;
357
- }
358
- // If we're inside a "use cache" context, push the config
359
- try {
360
- const ctx = _getCacheContextFn?.();
361
- if (ctx) {
362
- ctx.lifeConfigs.push(resolvedConfig);
363
- return;
364
- }
365
- }
366
- catch {
367
- // Fall through to request-scoped
368
- }
369
- // Outside a "use cache" context (e.g., page component with file-level "use cache"):
370
- // store as request-scoped so the server can read it after rendering.
371
- _setRequestScopedCacheLife(resolvedConfig);
277
+ * Set the cache lifetime for a "use cache" function.
278
+ *
279
+ * Accepts either a built-in profile name (e.g., "hours", "days") or a custom
280
+ * configuration object. In Next.js, this only works inside "use cache" functions.
281
+ *
282
+ * When called inside a "use cache" function, this sets the cache TTL.
283
+ * The "minimum-wins" rule applies: if called multiple times, the shortest
284
+ * duration for each field wins.
285
+ *
286
+ * When called outside a "use cache" context, this is a validated no-op.
287
+ */
288
+ function cacheLife(profile) {
289
+ let resolvedConfig;
290
+ if (typeof profile === "string") {
291
+ if (!cacheLifeProfiles[profile]) {
292
+ console.warn(`[vinext] cacheLife: unknown profile "${profile}". Available profiles: ${Object.keys(cacheLifeProfiles).join(", ")}`);
293
+ return;
294
+ }
295
+ resolvedConfig = { ...cacheLifeProfiles[profile] };
296
+ } else if (typeof profile === "object" && profile !== null) {
297
+ if (profile.expire !== void 0 && profile.revalidate !== void 0 && profile.expire < profile.revalidate) console.warn("[vinext] cacheLife: expire must be >= revalidate");
298
+ resolvedConfig = { ...profile };
299
+ } else return;
300
+ try {
301
+ const ctx = _getCacheContextFn?.();
302
+ if (ctx) {
303
+ ctx.lifeConfigs.push(resolvedConfig);
304
+ return;
305
+ }
306
+ } catch {}
307
+ _setRequestScopedCacheLife(resolvedConfig);
372
308
  }
373
309
  /**
374
- * Tag a "use cache" function's cached result for on-demand revalidation.
375
- *
376
- * Tags set here can be invalidated via revalidateTag(). In Next.js, this only
377
- * works inside "use cache" functions.
378
- *
379
- * When called inside a "use cache" function, tags are attached to the cached
380
- * entry. They can later be invalidated via revalidateTag().
381
- *
382
- * When called outside a "use cache" context, this is a no-op.
383
- */
384
- export function cacheTag(...tags) {
385
- try {
386
- const ctx = _getCacheContextFn?.();
387
- if (ctx) {
388
- ctx.tags.push(...tags);
389
- }
390
- }
391
- catch {
392
- // Not in a cache context — no-op
393
- }
310
+ * Tag a "use cache" function's cached result for on-demand revalidation.
311
+ *
312
+ * Tags set here can be invalidated via revalidateTag(). In Next.js, this only
313
+ * works inside "use cache" functions.
314
+ *
315
+ * When called inside a "use cache" function, tags are attached to the cached
316
+ * entry. They can later be invalidated via revalidateTag().
317
+ *
318
+ * When called outside a "use cache" context, this is a no-op.
319
+ */
320
+ function cacheTag(...tags) {
321
+ try {
322
+ const ctx = _getCacheContextFn?.();
323
+ if (ctx) ctx.tags.push(...tags);
324
+ } catch {}
394
325
  }
395
- // ---------------------------------------------------------------------------
396
- // unstable_cache — the older caching API
397
- // ---------------------------------------------------------------------------
398
326
  /**
399
- * AsyncLocalStorage to track whether we're inside an unstable_cache() callback.
400
- * Stored on globalThis via Symbol so headers.ts can detect the scope without
401
- * a direct import (avoiding circular dependencies).
402
- */
327
+ * AsyncLocalStorage to track whether we're inside an unstable_cache() callback.
328
+ * Stored on globalThis via Symbol so headers.ts can detect the scope without
329
+ * a direct import (avoiding circular dependencies).
330
+ */
403
331
  const _UNSTABLE_CACHE_ALS_KEY = Symbol.for("vinext.unstableCache.als");
404
- const _unstableCacheAls = (_g[_UNSTABLE_CACHE_ALS_KEY] ??=
405
- new AsyncLocalStorage());
406
- const UNSTABLE_CACHE_UNDEFINED_SENTINEL = "__vinext_unstable_cache_undefined__";
332
+ const _unstableCacheAls = _g[_UNSTABLE_CACHE_ALS_KEY] ??= new AsyncLocalStorage();
407
333
  function serializeUnstableCacheResult(value) {
408
- return value === undefined ? UNSTABLE_CACHE_UNDEFINED_SENTINEL : JSON.stringify(value);
334
+ const wrapper = value === void 0 ? { undef: true } : { v: value };
335
+ return JSON.stringify(wrapper);
409
336
  }
410
337
  function deserializeUnstableCacheResult(body) {
411
- if (body === UNSTABLE_CACHE_UNDEFINED_SENTINEL) {
412
- return undefined;
413
- }
414
- return JSON.parse(body);
338
+ const wrapper = JSON.parse(body);
339
+ return "undef" in wrapper ? void 0 : wrapper.v;
415
340
  }
416
341
  /**
417
- * Check if the current execution context is inside an unstable_cache() callback.
418
- * Used by headers(), cookies(), and connection() to throw errors when
419
- * dynamic request APIs are called inside a cache scope.
420
- */
421
- export function isInsideUnstableCacheScope() {
422
- return _unstableCacheAls.getStore() === true;
342
+ * Check if the current execution context is inside an unstable_cache() callback.
343
+ * Used by headers(), cookies(), and connection() to throw errors when
344
+ * dynamic request APIs are called inside a cache scope.
345
+ */
346
+ function isInsideUnstableCacheScope() {
347
+ return _unstableCacheAls.getStore() === true;
423
348
  }
424
349
  /**
425
- * Wrap an async function with caching.
426
- *
427
- * Returns a new function that caches results. The cache key is derived
428
- * from keyParts + serialized arguments.
429
- */
430
- export function unstable_cache(fn, keyParts, options) {
431
- const baseKey = keyParts ? keyParts.join(":") : fnv1a64(fn.toString());
432
- const tags = options?.tags ?? [];
433
- const revalidateSeconds = options?.revalidate;
434
- const cachedFn = async (...args) => {
435
- const argsKey = JSON.stringify(args);
436
- const cacheKey = `unstable_cache:${baseKey}:${argsKey}`;
437
- // Try to get from cache. Check cacheState so time-expired entries
438
- // trigger a re-fetch instead of being served indefinitely.
439
- const existing = await _getActiveHandler().get(cacheKey, {
440
- kind: "FETCH",
441
- tags,
442
- });
443
- if (existing?.value && existing.value.kind === "FETCH" && existing.cacheState !== "stale") {
444
- try {
445
- return deserializeUnstableCacheResult(existing.value.data.body);
446
- }
447
- catch {
448
- // Corrupted entry, fall through to re-fetch
449
- }
450
- }
451
- // Cache miss — call the function inside the unstable_cache ALS scope
452
- // so that headers()/cookies()/connection() can detect they're in a
453
- // cache scope and throw an appropriate error.
454
- const result = await _unstableCacheAls.run(true, () => fn(...args));
455
- // Store in cache using the FETCH kind
456
- const cacheValue = {
457
- kind: "FETCH",
458
- data: {
459
- headers: {},
460
- body: serializeUnstableCacheResult(result),
461
- url: cacheKey,
462
- },
463
- tags,
464
- // revalidate: false means "cache indefinitely" (no time-based expiry).
465
- // A positive number means time-based revalidation in seconds.
466
- // When unset (undefined), default to false (indefinite) matching
467
- // Next.js behavior for unstable_cache without explicit revalidate.
468
- revalidate: typeof revalidateSeconds === "number" ? revalidateSeconds : false,
469
- };
470
- await _getActiveHandler().set(cacheKey, cacheValue, {
471
- fetchCache: true,
472
- tags,
473
- revalidate: revalidateSeconds,
474
- });
475
- return result;
476
- };
477
- return cachedFn;
350
+ * Wrap an async function with caching.
351
+ *
352
+ * Returns a new function that caches results. The cache key is derived
353
+ * from keyParts + serialized arguments.
354
+ */
355
+ function unstable_cache(fn, keyParts, options) {
356
+ const baseKey = keyParts ? keyParts.join(":") : fnv1a64(fn.toString());
357
+ const tags = options?.tags ?? [];
358
+ const revalidateSeconds = options?.revalidate;
359
+ const cachedFn = async (...args) => {
360
+ const cacheKey = `unstable_cache:${baseKey}:${JSON.stringify(args)}`;
361
+ const existing = await _getActiveHandler().get(cacheKey, {
362
+ kind: "FETCH",
363
+ tags
364
+ });
365
+ if (existing?.value && existing.value.kind === "FETCH" && existing.cacheState !== "stale") try {
366
+ return deserializeUnstableCacheResult(existing.value.data.body);
367
+ } catch {}
368
+ const result = await _unstableCacheAls.run(true, () => fn(...args));
369
+ const cacheValue = {
370
+ kind: "FETCH",
371
+ data: {
372
+ headers: {},
373
+ body: serializeUnstableCacheResult(result),
374
+ url: cacheKey
375
+ },
376
+ tags,
377
+ revalidate: typeof revalidateSeconds === "number" ? revalidateSeconds : false
378
+ };
379
+ await _getActiveHandler().set(cacheKey, cacheValue, {
380
+ fetchCache: true,
381
+ tags,
382
+ revalidate: revalidateSeconds
383
+ });
384
+ return result;
385
+ };
386
+ return cachedFn;
478
387
  }
388
+ //#endregion
389
+ export { MemoryCacheHandler, NoOpCacheHandler, _consumeRequestScopedCacheLife, _initRequestScopedCacheState, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLife, cacheLifeProfiles, cacheTag, getCacheHandler, getRequestExecutionContext, isInsideUnstableCacheScope, unstable_noStore as noStore, unstable_noStore, refresh, revalidatePath, revalidateTag, runWithExecutionContext, setCacheHandler, unstable_cache, updateTag };
390
+
479
391
  //# sourceMappingURL=cache.js.map