@rangojs/router 0.0.0-experimental.dfa55db4 → 0.0.0-experimental.e16b7c00

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 (1041) hide show
  1. package/README.md +120 -25
  2. package/dist/bin/rango.js +147 -57
  3. package/dist/vite/index.js +2108 -829
  4. package/dist/vite/plugins/cloudflare-protocol-loader-hook.mjs +76 -0
  5. package/package.json +13 -8
  6. package/skills/breadcrumbs/SKILL.md +3 -1
  7. package/skills/bundle-analysis/SKILL.md +159 -0
  8. package/skills/cache-guide/SKILL.md +222 -30
  9. package/skills/caching/SKILL.md +188 -8
  10. package/skills/composability/SKILL.md +27 -2
  11. package/skills/document-cache/SKILL.md +78 -55
  12. package/skills/handler-use/SKILL.md +364 -0
  13. package/skills/hooks/SKILL.md +229 -20
  14. package/skills/host-router/SKILL.md +45 -20
  15. package/skills/i18n/SKILL.md +276 -0
  16. package/skills/intercept/SKILL.md +46 -4
  17. package/skills/layout/SKILL.md +28 -7
  18. package/skills/links/SKILL.md +247 -17
  19. package/skills/loader/SKILL.md +219 -9
  20. package/skills/middleware/SKILL.md +47 -12
  21. package/skills/migrate-nextjs/SKILL.md +582 -0
  22. package/skills/migrate-react-router/SKILL.md +769 -0
  23. package/skills/mime-routes/SKILL.md +27 -0
  24. package/skills/observability/SKILL.md +137 -0
  25. package/skills/parallel/SKILL.md +71 -6
  26. package/skills/prerender/SKILL.md +14 -33
  27. package/skills/rango/SKILL.md +236 -22
  28. package/skills/react-compiler/SKILL.md +168 -0
  29. package/skills/response-routes/SKILL.md +66 -9
  30. package/skills/route/SKILL.md +57 -4
  31. package/skills/router-setup/SKILL.md +3 -3
  32. package/skills/server-actions/SKILL.md +751 -0
  33. package/skills/streams-and-websockets/SKILL.md +283 -0
  34. package/skills/typesafety/SKILL.md +319 -27
  35. package/skills/use-cache/SKILL.md +36 -5
  36. package/skills/view-transitions/SKILL.md +294 -0
  37. package/src/__augment-tests__/augment.ts +81 -0
  38. package/src/__augment-tests__/augmented.check.ts +117 -0
  39. package/src/browser/action-coordinator.ts +53 -36
  40. package/src/browser/app-shell.ts +52 -0
  41. package/src/browser/event-controller.ts +86 -70
  42. package/src/browser/history-state.ts +21 -0
  43. package/src/browser/index.ts +3 -3
  44. package/src/browser/navigation-bridge.ts +86 -11
  45. package/src/browser/navigation-client.ts +76 -28
  46. package/src/browser/navigation-store.ts +32 -9
  47. package/src/browser/navigation-transaction.ts +10 -28
  48. package/src/browser/partial-update.ts +64 -26
  49. package/src/browser/prefetch/cache.ts +129 -21
  50. package/src/browser/prefetch/fetch.ts +148 -16
  51. package/src/browser/prefetch/queue.ts +36 -5
  52. package/src/browser/rango-state.ts +53 -13
  53. package/src/browser/react/Link.tsx +30 -2
  54. package/src/browser/react/NavigationProvider.tsx +72 -31
  55. package/src/browser/react/filter-segment-order.ts +51 -7
  56. package/src/browser/react/index.ts +3 -0
  57. package/src/browser/react/location-state-shared.ts +175 -4
  58. package/src/browser/react/location-state.ts +39 -13
  59. package/src/browser/react/use-handle.ts +17 -9
  60. package/src/browser/react/use-navigation.ts +22 -2
  61. package/src/browser/react/use-params.ts +20 -8
  62. package/src/browser/react/use-reverse.ts +106 -0
  63. package/src/browser/react/use-router.ts +22 -2
  64. package/src/browser/react/use-segments.ts +11 -8
  65. package/src/browser/response-adapter.ts +25 -0
  66. package/src/browser/rsc-router.tsx +64 -22
  67. package/src/browser/scroll-restoration.ts +22 -14
  68. package/src/browser/segment-reconciler.ts +36 -14
  69. package/src/browser/segment-structure-assert.ts +2 -2
  70. package/src/browser/server-action-bridge.ts +23 -30
  71. package/src/browser/types.ts +21 -0
  72. package/src/build/collect-fallback-refs.ts +107 -0
  73. package/src/build/generate-manifest.ts +60 -35
  74. package/src/build/generate-route-types.ts +2 -0
  75. package/src/build/index.ts +2 -0
  76. package/src/build/route-trie.ts +52 -25
  77. package/src/build/route-types/codegen.ts +4 -4
  78. package/src/build/route-types/include-resolution.ts +1 -1
  79. package/src/build/route-types/per-module-writer.ts +7 -4
  80. package/src/build/route-types/router-processing.ts +55 -14
  81. package/src/build/route-types/scan-filter.ts +1 -1
  82. package/src/build/route-types/source-scan.ts +118 -0
  83. package/src/build/runtime-discovery.ts +9 -20
  84. package/src/cache/cache-error.ts +104 -0
  85. package/src/cache/cache-policy.ts +95 -1
  86. package/src/cache/cache-runtime.ts +79 -13
  87. package/src/cache/cache-scope.ts +77 -46
  88. package/src/cache/cache-tag.ts +135 -0
  89. package/src/cache/cf/cf-cache-store.ts +1067 -176
  90. package/src/cache/cf/index.ts +4 -1
  91. package/src/cache/document-cache.ts +59 -7
  92. package/src/cache/index.ts +6 -0
  93. package/src/cache/memory-segment-store.ts +158 -14
  94. package/src/cache/tag-invalidation.ts +206 -0
  95. package/src/cache/types.ts +27 -0
  96. package/src/client.rsc.tsx +3 -0
  97. package/src/client.tsx +92 -182
  98. package/src/context-var.ts +5 -5
  99. package/src/decode-loader-results.ts +36 -0
  100. package/src/errors.ts +30 -1
  101. package/src/handle.ts +4 -6
  102. package/src/host/index.ts +2 -2
  103. package/src/host/router.ts +129 -57
  104. package/src/host/types.ts +31 -2
  105. package/src/host/utils.ts +1 -1
  106. package/src/href-client.ts +140 -20
  107. package/src/index.rsc.ts +16 -4
  108. package/src/index.ts +65 -15
  109. package/src/loader-store.ts +500 -0
  110. package/src/loader.rsc.ts +2 -5
  111. package/src/loader.ts +3 -10
  112. package/src/missing-id-error.ts +68 -0
  113. package/src/outlet-context.ts +1 -1
  114. package/src/prerender.ts +4 -4
  115. package/src/response-utils.ts +37 -0
  116. package/src/reverse.ts +65 -36
  117. package/src/route-content-wrapper.tsx +6 -28
  118. package/src/route-definition/dsl-helpers.ts +384 -257
  119. package/src/route-definition/helper-factories.ts +29 -139
  120. package/src/route-definition/helpers-types.ts +100 -28
  121. package/src/route-definition/resolve-handler-use.ts +6 -0
  122. package/src/route-definition/use-item-types.ts +32 -0
  123. package/src/route-types.ts +26 -41
  124. package/src/router/content-negotiation.ts +15 -2
  125. package/src/router/error-handling.ts +1 -1
  126. package/src/router/handler-context.ts +21 -38
  127. package/src/router/intercept-resolution.ts +4 -18
  128. package/src/router/lazy-includes.ts +8 -8
  129. package/src/router/loader-resolution.ts +19 -2
  130. package/src/router/manifest.ts +22 -13
  131. package/src/router/match-api.ts +4 -3
  132. package/src/router/match-handlers.ts +1 -0
  133. package/src/router/match-middleware/cache-lookup.ts +46 -92
  134. package/src/router/match-middleware/cache-store.ts +3 -2
  135. package/src/router/match-result.ts +103 -4
  136. package/src/router/metrics.ts +1 -1
  137. package/src/router/middleware-types.ts +15 -26
  138. package/src/router/middleware.ts +99 -84
  139. package/src/router/pattern-matching.ts +101 -17
  140. package/src/router/prerender-match.ts +3 -1
  141. package/src/router/preview-match.ts +3 -1
  142. package/src/router/request-classification.ts +4 -28
  143. package/src/router/revalidation.ts +58 -2
  144. package/src/router/router-interfaces.ts +45 -28
  145. package/src/router/router-options.ts +25 -1
  146. package/src/router/router-registry.ts +2 -5
  147. package/src/router/segment-resolution/fresh.ts +32 -6
  148. package/src/router/segment-resolution/loader-cache.ts +8 -17
  149. package/src/router/segment-resolution/revalidation.ts +154 -107
  150. package/src/router/segment-resolution/view-transition-default.ts +36 -0
  151. package/src/router/substitute-pattern-params.ts +56 -0
  152. package/src/router/trie-matching.ts +18 -13
  153. package/src/router/types.ts +8 -0
  154. package/src/router/url-params.ts +49 -0
  155. package/src/router.ts +23 -18
  156. package/src/rsc/handler-context.ts +2 -2
  157. package/src/rsc/handler.ts +46 -74
  158. package/src/rsc/helpers.ts +72 -43
  159. package/src/rsc/index.ts +1 -1
  160. package/src/rsc/origin-guard.ts +28 -10
  161. package/src/rsc/progressive-enhancement.ts +4 -0
  162. package/src/rsc/response-route-handler.ts +54 -54
  163. package/src/rsc/rsc-rendering.ts +35 -51
  164. package/src/rsc/runtime-warnings.ts +9 -10
  165. package/src/rsc/server-action.ts +17 -37
  166. package/src/rsc/ssr-setup.ts +16 -0
  167. package/src/rsc/types.ts +8 -2
  168. package/src/search-params.ts +4 -4
  169. package/src/segment-content-promise.ts +67 -0
  170. package/src/segment-loader-promise.ts +122 -0
  171. package/src/segment-system.tsx +132 -116
  172. package/src/serialize.ts +243 -0
  173. package/src/server/context.ts +143 -53
  174. package/src/server/cookie-store.ts +28 -4
  175. package/src/server/request-context.ts +46 -44
  176. package/src/ssr/index.tsx +5 -1
  177. package/src/static-handler.ts +1 -1
  178. package/src/types/cache-types.ts +13 -4
  179. package/src/types/error-types.ts +5 -1
  180. package/src/types/global-namespace.ts +39 -26
  181. package/src/types/handler-context.ts +68 -50
  182. package/src/types/index.ts +1 -0
  183. package/src/types/loader-types.ts +5 -6
  184. package/src/types/request-scope.ts +126 -0
  185. package/src/types/route-entry.ts +11 -0
  186. package/src/types/segments.ts +36 -2
  187. package/src/urls/include-helper.ts +34 -67
  188. package/src/urls/index.ts +0 -3
  189. package/src/urls/path-helper-types.ts +41 -7
  190. package/src/urls/path-helper.ts +17 -52
  191. package/src/urls/pattern-types.ts +36 -19
  192. package/src/urls/response-types.ts +22 -29
  193. package/src/urls/type-extraction.ts +26 -116
  194. package/src/urls/urls-function.ts +1 -5
  195. package/src/use-loader.tsx +416 -42
  196. package/src/vite/debug.ts +185 -0
  197. package/src/vite/discovery/bundle-postprocess.ts +6 -6
  198. package/src/vite/discovery/discover-routers.ts +101 -51
  199. package/src/vite/discovery/discovery-errors.ts +194 -0
  200. package/src/vite/discovery/gate-state.ts +171 -0
  201. package/src/vite/discovery/prerender-collection.ts +67 -26
  202. package/src/vite/discovery/route-types-writer.ts +40 -84
  203. package/src/vite/discovery/self-gen-tracking.ts +27 -1
  204. package/src/vite/discovery/state.ts +33 -0
  205. package/src/vite/discovery/virtual-module-codegen.ts +13 -23
  206. package/src/vite/index.ts +2 -0
  207. package/src/vite/plugin-types.ts +67 -0
  208. package/src/vite/plugins/cjs-to-esm.ts +8 -7
  209. package/src/vite/plugins/client-ref-dedup.ts +16 -0
  210. package/src/vite/plugins/client-ref-hashing.ts +28 -5
  211. package/src/vite/plugins/cloudflare-protocol-loader-hook.d.mts +23 -0
  212. package/src/vite/plugins/cloudflare-protocol-loader-hook.mjs +76 -0
  213. package/src/vite/plugins/cloudflare-protocol-stub.ts +214 -0
  214. package/src/vite/plugins/expose-action-id.ts +54 -30
  215. package/src/vite/plugins/expose-id-utils.ts +24 -8
  216. package/src/vite/plugins/expose-ids/export-analysis.ts +100 -20
  217. package/src/vite/plugins/expose-ids/handler-transform.ts +8 -61
  218. package/src/vite/plugins/expose-ids/loader-transform.ts +3 -5
  219. package/src/vite/plugins/expose-ids/router-transform.ts +20 -3
  220. package/src/vite/plugins/expose-internal-ids.ts +503 -468
  221. package/src/vite/plugins/performance-tracks.ts +29 -25
  222. package/src/vite/plugins/use-cache-transform.ts +65 -50
  223. package/src/vite/plugins/version-injector.ts +39 -23
  224. package/src/vite/plugins/version-plugin.ts +59 -2
  225. package/src/vite/plugins/virtual-entries.ts +2 -2
  226. package/src/vite/rango.ts +116 -29
  227. package/src/vite/router-discovery.ts +750 -100
  228. package/src/vite/utils/ast-handler-extract.ts +15 -15
  229. package/src/vite/utils/banner.ts +1 -1
  230. package/src/vite/utils/bundle-analysis.ts +4 -2
  231. package/src/vite/utils/client-chunks.ts +190 -0
  232. package/src/vite/utils/forward-user-plugins.ts +193 -0
  233. package/src/vite/utils/manifest-utils.ts +21 -5
  234. package/src/vite/utils/package-resolution.ts +41 -1
  235. package/src/vite/utils/prerender-utils.ts +21 -6
  236. package/src/vite/utils/shared-utils.ts +107 -26
  237. package/dist/__internal.d.ts +0 -83
  238. package/dist/__internal.d.ts.map +0 -1
  239. package/dist/__internal.js +0 -19
  240. package/dist/__internal.js.map +0 -1
  241. package/dist/__mocks__/version.d.ts +0 -7
  242. package/dist/__mocks__/version.d.ts.map +0 -1
  243. package/dist/__mocks__/version.js +0 -7
  244. package/dist/__mocks__/version.js.map +0 -1
  245. package/dist/__tests__/client-href.test.d.ts +0 -2
  246. package/dist/__tests__/client-href.test.d.ts.map +0 -1
  247. package/dist/__tests__/client-href.test.js +0 -74
  248. package/dist/__tests__/client-href.test.js.map +0 -1
  249. package/dist/__tests__/component-utils.test.d.ts +0 -2
  250. package/dist/__tests__/component-utils.test.d.ts.map +0 -1
  251. package/dist/__tests__/component-utils.test.js +0 -51
  252. package/dist/__tests__/component-utils.test.js.map +0 -1
  253. package/dist/__tests__/event-controller.test.d.ts +0 -2
  254. package/dist/__tests__/event-controller.test.d.ts.map +0 -1
  255. package/dist/__tests__/event-controller.test.js +0 -538
  256. package/dist/__tests__/event-controller.test.js.map +0 -1
  257. package/dist/__tests__/helpers/route-tree.d.ts +0 -118
  258. package/dist/__tests__/helpers/route-tree.d.ts.map +0 -1
  259. package/dist/__tests__/helpers/route-tree.js +0 -374
  260. package/dist/__tests__/helpers/route-tree.js.map +0 -1
  261. package/dist/__tests__/match-result.test.d.ts +0 -2
  262. package/dist/__tests__/match-result.test.d.ts.map +0 -1
  263. package/dist/__tests__/match-result.test.js +0 -154
  264. package/dist/__tests__/match-result.test.js.map +0 -1
  265. package/dist/__tests__/navigation-store.test.d.ts +0 -2
  266. package/dist/__tests__/navigation-store.test.d.ts.map +0 -1
  267. package/dist/__tests__/navigation-store.test.js +0 -440
  268. package/dist/__tests__/navigation-store.test.js.map +0 -1
  269. package/dist/__tests__/partial-update.test.d.ts +0 -2
  270. package/dist/__tests__/partial-update.test.d.ts.map +0 -1
  271. package/dist/__tests__/partial-update.test.js +0 -1009
  272. package/dist/__tests__/partial-update.test.js.map +0 -1
  273. package/dist/__tests__/reverse-types.test.d.ts +0 -8
  274. package/dist/__tests__/reverse-types.test.d.ts.map +0 -1
  275. package/dist/__tests__/reverse-types.test.js +0 -656
  276. package/dist/__tests__/reverse-types.test.js.map +0 -1
  277. package/dist/__tests__/route-definition.test.d.ts +0 -2
  278. package/dist/__tests__/route-definition.test.d.ts.map +0 -1
  279. package/dist/__tests__/route-definition.test.js +0 -55
  280. package/dist/__tests__/route-definition.test.js.map +0 -1
  281. package/dist/__tests__/router-helpers.test.d.ts +0 -2
  282. package/dist/__tests__/router-helpers.test.d.ts.map +0 -1
  283. package/dist/__tests__/router-helpers.test.js +0 -377
  284. package/dist/__tests__/router-helpers.test.js.map +0 -1
  285. package/dist/__tests__/router-integration-2.test.d.ts +0 -2
  286. package/dist/__tests__/router-integration-2.test.d.ts.map +0 -1
  287. package/dist/__tests__/router-integration-2.test.js +0 -426
  288. package/dist/__tests__/router-integration-2.test.js.map +0 -1
  289. package/dist/__tests__/router-integration.test.d.ts +0 -2
  290. package/dist/__tests__/router-integration.test.d.ts.map +0 -1
  291. package/dist/__tests__/router-integration.test.js +0 -1051
  292. package/dist/__tests__/router-integration.test.js.map +0 -1
  293. package/dist/__tests__/search-params.test.d.ts +0 -5
  294. package/dist/__tests__/search-params.test.d.ts.map +0 -1
  295. package/dist/__tests__/search-params.test.js +0 -306
  296. package/dist/__tests__/search-params.test.js.map +0 -1
  297. package/dist/__tests__/segment-system.test.d.ts +0 -2
  298. package/dist/__tests__/segment-system.test.d.ts.map +0 -1
  299. package/dist/__tests__/segment-system.test.js +0 -627
  300. package/dist/__tests__/segment-system.test.js.map +0 -1
  301. package/dist/__tests__/static-handler-types.test.d.ts +0 -8
  302. package/dist/__tests__/static-handler-types.test.d.ts.map +0 -1
  303. package/dist/__tests__/static-handler-types.test.js +0 -63
  304. package/dist/__tests__/static-handler-types.test.js.map +0 -1
  305. package/dist/__tests__/urls.test.d.ts +0 -2
  306. package/dist/__tests__/urls.test.d.ts.map +0 -1
  307. package/dist/__tests__/urls.test.js +0 -421
  308. package/dist/__tests__/urls.test.js.map +0 -1
  309. package/dist/__tests__/use-mount.test.d.ts +0 -2
  310. package/dist/__tests__/use-mount.test.d.ts.map +0 -1
  311. package/dist/__tests__/use-mount.test.js +0 -35
  312. package/dist/__tests__/use-mount.test.js.map +0 -1
  313. package/dist/bin/rango.d.ts +0 -2
  314. package/dist/bin/rango.d.ts.map +0 -1
  315. package/dist/bin/rango.js.map +0 -1
  316. package/dist/browser/event-controller.d.ts +0 -191
  317. package/dist/browser/event-controller.d.ts.map +0 -1
  318. package/dist/browser/event-controller.js +0 -559
  319. package/dist/browser/event-controller.js.map +0 -1
  320. package/dist/browser/index.d.ts +0 -2
  321. package/dist/browser/index.d.ts.map +0 -1
  322. package/dist/browser/index.js +0 -14
  323. package/dist/browser/index.js.map +0 -1
  324. package/dist/browser/link-interceptor.d.ts +0 -38
  325. package/dist/browser/link-interceptor.d.ts.map +0 -1
  326. package/dist/browser/link-interceptor.js +0 -99
  327. package/dist/browser/link-interceptor.js.map +0 -1
  328. package/dist/browser/logging.d.ts +0 -10
  329. package/dist/browser/logging.d.ts.map +0 -1
  330. package/dist/browser/logging.js +0 -29
  331. package/dist/browser/logging.js.map +0 -1
  332. package/dist/browser/lru-cache.d.ts +0 -17
  333. package/dist/browser/lru-cache.d.ts.map +0 -1
  334. package/dist/browser/lru-cache.js +0 -50
  335. package/dist/browser/lru-cache.js.map +0 -1
  336. package/dist/browser/merge-segment-loaders.d.ts +0 -39
  337. package/dist/browser/merge-segment-loaders.d.ts.map +0 -1
  338. package/dist/browser/merge-segment-loaders.js +0 -102
  339. package/dist/browser/merge-segment-loaders.js.map +0 -1
  340. package/dist/browser/navigation-bridge.d.ts +0 -102
  341. package/dist/browser/navigation-bridge.d.ts.map +0 -1
  342. package/dist/browser/navigation-bridge.js +0 -708
  343. package/dist/browser/navigation-bridge.js.map +0 -1
  344. package/dist/browser/navigation-client.d.ts +0 -25
  345. package/dist/browser/navigation-client.d.ts.map +0 -1
  346. package/dist/browser/navigation-client.js +0 -157
  347. package/dist/browser/navigation-client.js.map +0 -1
  348. package/dist/browser/navigation-store.d.ts +0 -101
  349. package/dist/browser/navigation-store.d.ts.map +0 -1
  350. package/dist/browser/navigation-store.js +0 -625
  351. package/dist/browser/navigation-store.js.map +0 -1
  352. package/dist/browser/partial-update.d.ts +0 -75
  353. package/dist/browser/partial-update.d.ts.map +0 -1
  354. package/dist/browser/partial-update.js +0 -426
  355. package/dist/browser/partial-update.js.map +0 -1
  356. package/dist/browser/react/Link.d.ts +0 -86
  357. package/dist/browser/react/Link.d.ts.map +0 -1
  358. package/dist/browser/react/Link.js +0 -128
  359. package/dist/browser/react/Link.js.map +0 -1
  360. package/dist/browser/react/NavigationProvider.d.ts +0 -63
  361. package/dist/browser/react/NavigationProvider.d.ts.map +0 -1
  362. package/dist/browser/react/NavigationProvider.js +0 -216
  363. package/dist/browser/react/NavigationProvider.js.map +0 -1
  364. package/dist/browser/react/ScrollRestoration.d.ts +0 -75
  365. package/dist/browser/react/ScrollRestoration.d.ts.map +0 -1
  366. package/dist/browser/react/ScrollRestoration.js +0 -57
  367. package/dist/browser/react/ScrollRestoration.js.map +0 -1
  368. package/dist/browser/react/context.d.ts +0 -46
  369. package/dist/browser/react/context.d.ts.map +0 -1
  370. package/dist/browser/react/context.js +0 -10
  371. package/dist/browser/react/context.js.map +0 -1
  372. package/dist/browser/react/index.d.ts +0 -11
  373. package/dist/browser/react/index.d.ts.map +0 -1
  374. package/dist/browser/react/index.js +0 -22
  375. package/dist/browser/react/index.js.map +0 -1
  376. package/dist/browser/react/location-state-shared.d.ts +0 -63
  377. package/dist/browser/react/location-state-shared.d.ts.map +0 -1
  378. package/dist/browser/react/location-state-shared.js +0 -81
  379. package/dist/browser/react/location-state-shared.js.map +0 -1
  380. package/dist/browser/react/location-state.d.ts +0 -23
  381. package/dist/browser/react/location-state.d.ts.map +0 -1
  382. package/dist/browser/react/location-state.js +0 -29
  383. package/dist/browser/react/location-state.js.map +0 -1
  384. package/dist/browser/react/mount-context.d.ts +0 -24
  385. package/dist/browser/react/mount-context.d.ts.map +0 -1
  386. package/dist/browser/react/mount-context.js +0 -24
  387. package/dist/browser/react/mount-context.js.map +0 -1
  388. package/dist/browser/react/use-action.d.ts +0 -64
  389. package/dist/browser/react/use-action.d.ts.map +0 -1
  390. package/dist/browser/react/use-action.js +0 -134
  391. package/dist/browser/react/use-action.js.map +0 -1
  392. package/dist/browser/react/use-client-cache.d.ts +0 -41
  393. package/dist/browser/react/use-client-cache.d.ts.map +0 -1
  394. package/dist/browser/react/use-client-cache.js +0 -39
  395. package/dist/browser/react/use-client-cache.js.map +0 -1
  396. package/dist/browser/react/use-handle.d.ts +0 -31
  397. package/dist/browser/react/use-handle.d.ts.map +0 -1
  398. package/dist/browser/react/use-handle.js +0 -144
  399. package/dist/browser/react/use-handle.js.map +0 -1
  400. package/dist/browser/react/use-href.d.ts +0 -33
  401. package/dist/browser/react/use-href.d.ts.map +0 -1
  402. package/dist/browser/react/use-href.js +0 -39
  403. package/dist/browser/react/use-href.js.map +0 -1
  404. package/dist/browser/react/use-link-status.d.ts +0 -37
  405. package/dist/browser/react/use-link-status.d.ts.map +0 -1
  406. package/dist/browser/react/use-link-status.js +0 -99
  407. package/dist/browser/react/use-link-status.js.map +0 -1
  408. package/dist/browser/react/use-mount.d.ts +0 -25
  409. package/dist/browser/react/use-mount.d.ts.map +0 -1
  410. package/dist/browser/react/use-mount.js +0 -30
  411. package/dist/browser/react/use-mount.js.map +0 -1
  412. package/dist/browser/react/use-navigation.d.ts +0 -27
  413. package/dist/browser/react/use-navigation.d.ts.map +0 -1
  414. package/dist/browser/react/use-navigation.js +0 -87
  415. package/dist/browser/react/use-navigation.js.map +0 -1
  416. package/dist/browser/react/use-segments.d.ts +0 -38
  417. package/dist/browser/react/use-segments.d.ts.map +0 -1
  418. package/dist/browser/react/use-segments.js +0 -130
  419. package/dist/browser/react/use-segments.js.map +0 -1
  420. package/dist/browser/request-controller.d.ts +0 -26
  421. package/dist/browser/request-controller.d.ts.map +0 -1
  422. package/dist/browser/request-controller.js +0 -147
  423. package/dist/browser/request-controller.js.map +0 -1
  424. package/dist/browser/rsc-router.d.ts +0 -129
  425. package/dist/browser/rsc-router.d.ts.map +0 -1
  426. package/dist/browser/rsc-router.js +0 -195
  427. package/dist/browser/rsc-router.js.map +0 -1
  428. package/dist/browser/scroll-restoration.d.ts +0 -93
  429. package/dist/browser/scroll-restoration.d.ts.map +0 -1
  430. package/dist/browser/scroll-restoration.js +0 -321
  431. package/dist/browser/scroll-restoration.js.map +0 -1
  432. package/dist/browser/segment-structure-assert.d.ts +0 -17
  433. package/dist/browser/segment-structure-assert.d.ts.map +0 -1
  434. package/dist/browser/segment-structure-assert.js +0 -59
  435. package/dist/browser/segment-structure-assert.js.map +0 -1
  436. package/dist/browser/server-action-bridge.d.ts +0 -26
  437. package/dist/browser/server-action-bridge.d.ts.map +0 -1
  438. package/dist/browser/server-action-bridge.js +0 -668
  439. package/dist/browser/server-action-bridge.js.map +0 -1
  440. package/dist/browser/shallow.d.ts +0 -12
  441. package/dist/browser/shallow.d.ts.map +0 -1
  442. package/dist/browser/shallow.js +0 -34
  443. package/dist/browser/shallow.js.map +0 -1
  444. package/dist/browser/types.d.ts +0 -369
  445. package/dist/browser/types.d.ts.map +0 -1
  446. package/dist/browser/types.js +0 -2
  447. package/dist/browser/types.js.map +0 -1
  448. package/dist/build/__tests__/generate-cli.test.d.ts +0 -2
  449. package/dist/build/__tests__/generate-cli.test.d.ts.map +0 -1
  450. package/dist/build/__tests__/generate-cli.test.js +0 -237
  451. package/dist/build/__tests__/generate-cli.test.js.map +0 -1
  452. package/dist/build/__tests__/generate-manifest.test.d.ts +0 -2
  453. package/dist/build/__tests__/generate-manifest.test.d.ts.map +0 -1
  454. package/dist/build/__tests__/generate-manifest.test.js +0 -119
  455. package/dist/build/__tests__/generate-manifest.test.js.map +0 -1
  456. package/dist/build/__tests__/generate-route-types.test.d.ts +0 -2
  457. package/dist/build/__tests__/generate-route-types.test.d.ts.map +0 -1
  458. package/dist/build/__tests__/generate-route-types.test.js +0 -620
  459. package/dist/build/__tests__/generate-route-types.test.js.map +0 -1
  460. package/dist/build/__tests__/per-router-manifest.test.d.ts +0 -2
  461. package/dist/build/__tests__/per-router-manifest.test.d.ts.map +0 -1
  462. package/dist/build/__tests__/per-router-manifest.test.js +0 -308
  463. package/dist/build/__tests__/per-router-manifest.test.js.map +0 -1
  464. package/dist/build/generate-manifest.d.ts +0 -81
  465. package/dist/build/generate-manifest.d.ts.map +0 -1
  466. package/dist/build/generate-manifest.js +0 -276
  467. package/dist/build/generate-manifest.js.map +0 -1
  468. package/dist/build/generate-route-types.d.ts +0 -115
  469. package/dist/build/generate-route-types.d.ts.map +0 -1
  470. package/dist/build/generate-route-types.js +0 -740
  471. package/dist/build/generate-route-types.js.map +0 -1
  472. package/dist/build/index.d.ts +0 -21
  473. package/dist/build/index.d.ts.map +0 -1
  474. package/dist/build/index.js +0 -21
  475. package/dist/build/index.js.map +0 -1
  476. package/dist/build/route-trie.d.ts +0 -71
  477. package/dist/build/route-trie.d.ts.map +0 -1
  478. package/dist/build/route-trie.js +0 -175
  479. package/dist/build/route-trie.js.map +0 -1
  480. package/dist/cache/__tests__/cache-scope.test.d.ts +0 -2
  481. package/dist/cache/__tests__/cache-scope.test.d.ts.map +0 -1
  482. package/dist/cache/__tests__/cache-scope.test.js +0 -208
  483. package/dist/cache/__tests__/cache-scope.test.js.map +0 -1
  484. package/dist/cache/__tests__/document-cache.test.d.ts +0 -2
  485. package/dist/cache/__tests__/document-cache.test.d.ts.map +0 -1
  486. package/dist/cache/__tests__/document-cache.test.js +0 -345
  487. package/dist/cache/__tests__/document-cache.test.js.map +0 -1
  488. package/dist/cache/__tests__/memory-segment-store.test.d.ts +0 -2
  489. package/dist/cache/__tests__/memory-segment-store.test.d.ts.map +0 -1
  490. package/dist/cache/__tests__/memory-segment-store.test.js +0 -425
  491. package/dist/cache/__tests__/memory-segment-store.test.js.map +0 -1
  492. package/dist/cache/__tests__/memory-store.test.d.ts +0 -2
  493. package/dist/cache/__tests__/memory-store.test.d.ts.map +0 -1
  494. package/dist/cache/__tests__/memory-store.test.js +0 -367
  495. package/dist/cache/__tests__/memory-store.test.js.map +0 -1
  496. package/dist/cache/cache-scope.d.ts +0 -102
  497. package/dist/cache/cache-scope.d.ts.map +0 -1
  498. package/dist/cache/cache-scope.js +0 -440
  499. package/dist/cache/cache-scope.js.map +0 -1
  500. package/dist/cache/cf/__tests__/cf-cache-store.test.d.ts +0 -2
  501. package/dist/cache/cf/__tests__/cf-cache-store.test.d.ts.map +0 -1
  502. package/dist/cache/cf/__tests__/cf-cache-store.test.js +0 -330
  503. package/dist/cache/cf/__tests__/cf-cache-store.test.js.map +0 -1
  504. package/dist/cache/cf/cf-cache-store.d.ts +0 -165
  505. package/dist/cache/cf/cf-cache-store.d.ts.map +0 -1
  506. package/dist/cache/cf/cf-cache-store.js +0 -242
  507. package/dist/cache/cf/cf-cache-store.js.map +0 -1
  508. package/dist/cache/cf/index.d.ts +0 -14
  509. package/dist/cache/cf/index.d.ts.map +0 -1
  510. package/dist/cache/cf/index.js +0 -17
  511. package/dist/cache/cf/index.js.map +0 -1
  512. package/dist/cache/document-cache.d.ts +0 -64
  513. package/dist/cache/document-cache.d.ts.map +0 -1
  514. package/dist/cache/document-cache.js +0 -228
  515. package/dist/cache/document-cache.js.map +0 -1
  516. package/dist/cache/index.d.ts +0 -19
  517. package/dist/cache/index.d.ts.map +0 -1
  518. package/dist/cache/index.js +0 -21
  519. package/dist/cache/index.js.map +0 -1
  520. package/dist/cache/memory-segment-store.d.ts +0 -110
  521. package/dist/cache/memory-segment-store.d.ts.map +0 -1
  522. package/dist/cache/memory-segment-store.js +0 -117
  523. package/dist/cache/memory-segment-store.js.map +0 -1
  524. package/dist/cache/memory-store.d.ts +0 -41
  525. package/dist/cache/memory-store.d.ts.map +0 -1
  526. package/dist/cache/memory-store.js +0 -191
  527. package/dist/cache/memory-store.js.map +0 -1
  528. package/dist/cache/types.d.ts +0 -317
  529. package/dist/cache/types.d.ts.map +0 -1
  530. package/dist/cache/types.js +0 -12
  531. package/dist/cache/types.js.map +0 -1
  532. package/dist/client.d.ts +0 -248
  533. package/dist/client.d.ts.map +0 -1
  534. package/dist/client.js +0 -367
  535. package/dist/client.js.map +0 -1
  536. package/dist/client.rsc.d.ts +0 -26
  537. package/dist/client.rsc.d.ts.map +0 -1
  538. package/dist/client.rsc.js +0 -46
  539. package/dist/client.rsc.js.map +0 -1
  540. package/dist/component-utils.d.ts +0 -36
  541. package/dist/component-utils.d.ts.map +0 -1
  542. package/dist/component-utils.js +0 -61
  543. package/dist/component-utils.js.map +0 -1
  544. package/dist/components/DefaultDocument.d.ts +0 -13
  545. package/dist/components/DefaultDocument.d.ts.map +0 -1
  546. package/dist/components/DefaultDocument.js +0 -15
  547. package/dist/components/DefaultDocument.js.map +0 -1
  548. package/dist/debug.d.ts +0 -58
  549. package/dist/debug.d.ts.map +0 -1
  550. package/dist/debug.js +0 -157
  551. package/dist/debug.js.map +0 -1
  552. package/dist/default-error-boundary.d.ts +0 -11
  553. package/dist/default-error-boundary.d.ts.map +0 -1
  554. package/dist/default-error-boundary.js +0 -45
  555. package/dist/default-error-boundary.js.map +0 -1
  556. package/dist/deps/browser.d.ts +0 -2
  557. package/dist/deps/browser.d.ts.map +0 -1
  558. package/dist/deps/browser.js +0 -3
  559. package/dist/deps/browser.js.map +0 -1
  560. package/dist/deps/html-stream-client.d.ts +0 -2
  561. package/dist/deps/html-stream-client.d.ts.map +0 -1
  562. package/dist/deps/html-stream-client.js +0 -3
  563. package/dist/deps/html-stream-client.js.map +0 -1
  564. package/dist/deps/html-stream-server.d.ts +0 -2
  565. package/dist/deps/html-stream-server.d.ts.map +0 -1
  566. package/dist/deps/html-stream-server.js +0 -3
  567. package/dist/deps/html-stream-server.js.map +0 -1
  568. package/dist/deps/rsc.d.ts +0 -2
  569. package/dist/deps/rsc.d.ts.map +0 -1
  570. package/dist/deps/rsc.js +0 -4
  571. package/dist/deps/rsc.js.map +0 -1
  572. package/dist/deps/ssr.d.ts +0 -2
  573. package/dist/deps/ssr.d.ts.map +0 -1
  574. package/dist/deps/ssr.js +0 -3
  575. package/dist/deps/ssr.js.map +0 -1
  576. package/dist/errors.d.ts +0 -174
  577. package/dist/errors.d.ts.map +0 -1
  578. package/dist/errors.js +0 -241
  579. package/dist/errors.js.map +0 -1
  580. package/dist/handle.d.ts +0 -78
  581. package/dist/handle.d.ts.map +0 -1
  582. package/dist/handle.js +0 -82
  583. package/dist/handle.js.map +0 -1
  584. package/dist/handles/MetaTags.d.ts +0 -14
  585. package/dist/handles/MetaTags.d.ts.map +0 -1
  586. package/dist/handles/MetaTags.js +0 -136
  587. package/dist/handles/MetaTags.js.map +0 -1
  588. package/dist/handles/index.d.ts +0 -6
  589. package/dist/handles/index.d.ts.map +0 -1
  590. package/dist/handles/index.js +0 -6
  591. package/dist/handles/index.js.map +0 -1
  592. package/dist/handles/meta.d.ts +0 -39
  593. package/dist/handles/meta.d.ts.map +0 -1
  594. package/dist/handles/meta.js +0 -202
  595. package/dist/handles/meta.js.map +0 -1
  596. package/dist/host/__tests__/errors.test.d.ts +0 -2
  597. package/dist/host/__tests__/errors.test.d.ts.map +0 -1
  598. package/dist/host/__tests__/errors.test.js +0 -76
  599. package/dist/host/__tests__/errors.test.js.map +0 -1
  600. package/dist/host/__tests__/pattern-comprehensive.test.d.ts +0 -2
  601. package/dist/host/__tests__/pattern-comprehensive.test.d.ts.map +0 -1
  602. package/dist/host/__tests__/pattern-comprehensive.test.js +0 -732
  603. package/dist/host/__tests__/pattern-comprehensive.test.js.map +0 -1
  604. package/dist/host/__tests__/pattern-matcher.test.d.ts +0 -2
  605. package/dist/host/__tests__/pattern-matcher.test.d.ts.map +0 -1
  606. package/dist/host/__tests__/pattern-matcher.test.js +0 -251
  607. package/dist/host/__tests__/pattern-matcher.test.js.map +0 -1
  608. package/dist/host/__tests__/router.test.d.ts +0 -2
  609. package/dist/host/__tests__/router.test.d.ts.map +0 -1
  610. package/dist/host/__tests__/router.test.js +0 -241
  611. package/dist/host/__tests__/router.test.js.map +0 -1
  612. package/dist/host/__tests__/testing.test.d.ts +0 -2
  613. package/dist/host/__tests__/testing.test.d.ts.map +0 -1
  614. package/dist/host/__tests__/testing.test.js +0 -64
  615. package/dist/host/__tests__/testing.test.js.map +0 -1
  616. package/dist/host/__tests__/utils.test.d.ts +0 -2
  617. package/dist/host/__tests__/utils.test.d.ts.map +0 -1
  618. package/dist/host/__tests__/utils.test.js +0 -29
  619. package/dist/host/__tests__/utils.test.js.map +0 -1
  620. package/dist/host/cookie-handler.d.ts +0 -34
  621. package/dist/host/cookie-handler.d.ts.map +0 -1
  622. package/dist/host/cookie-handler.js +0 -124
  623. package/dist/host/cookie-handler.js.map +0 -1
  624. package/dist/host/errors.d.ts +0 -56
  625. package/dist/host/errors.d.ts.map +0 -1
  626. package/dist/host/errors.js +0 -79
  627. package/dist/host/errors.js.map +0 -1
  628. package/dist/host/index.d.ts +0 -29
  629. package/dist/host/index.d.ts.map +0 -1
  630. package/dist/host/index.js +0 -32
  631. package/dist/host/index.js.map +0 -1
  632. package/dist/host/pattern-matcher.d.ts +0 -36
  633. package/dist/host/pattern-matcher.d.ts.map +0 -1
  634. package/dist/host/pattern-matcher.js +0 -172
  635. package/dist/host/pattern-matcher.js.map +0 -1
  636. package/dist/host/router.d.ts +0 -26
  637. package/dist/host/router.d.ts.map +0 -1
  638. package/dist/host/router.js +0 -218
  639. package/dist/host/router.js.map +0 -1
  640. package/dist/host/testing.d.ts +0 -36
  641. package/dist/host/testing.d.ts.map +0 -1
  642. package/dist/host/testing.js +0 -55
  643. package/dist/host/testing.js.map +0 -1
  644. package/dist/host/types.d.ts +0 -115
  645. package/dist/host/types.d.ts.map +0 -1
  646. package/dist/host/types.js +0 -7
  647. package/dist/host/types.js.map +0 -1
  648. package/dist/host/utils.d.ts +0 -21
  649. package/dist/host/utils.d.ts.map +0 -1
  650. package/dist/host/utils.js +0 -23
  651. package/dist/host/utils.js.map +0 -1
  652. package/dist/href-client.d.ts +0 -131
  653. package/dist/href-client.d.ts.map +0 -1
  654. package/dist/href-client.js +0 -64
  655. package/dist/href-client.js.map +0 -1
  656. package/dist/href-context.d.ts +0 -29
  657. package/dist/href-context.d.ts.map +0 -1
  658. package/dist/href-context.js +0 -21
  659. package/dist/href-context.js.map +0 -1
  660. package/dist/index.d.ts +0 -73
  661. package/dist/index.d.ts.map +0 -1
  662. package/dist/index.js +0 -91
  663. package/dist/index.js.map +0 -1
  664. package/dist/index.rsc.d.ts +0 -32
  665. package/dist/index.rsc.d.ts.map +0 -1
  666. package/dist/index.rsc.js +0 -40
  667. package/dist/index.rsc.js.map +0 -1
  668. package/dist/internal-debug.d.ts +0 -2
  669. package/dist/internal-debug.d.ts.map +0 -1
  670. package/dist/internal-debug.js +0 -5
  671. package/dist/internal-debug.js.map +0 -1
  672. package/dist/loader.d.ts +0 -14
  673. package/dist/loader.d.ts.map +0 -1
  674. package/dist/loader.js +0 -20
  675. package/dist/loader.js.map +0 -1
  676. package/dist/loader.rsc.d.ts +0 -19
  677. package/dist/loader.rsc.d.ts.map +0 -1
  678. package/dist/loader.rsc.js +0 -99
  679. package/dist/loader.rsc.js.map +0 -1
  680. package/dist/network-error-thrower.d.ts +0 -17
  681. package/dist/network-error-thrower.d.ts.map +0 -1
  682. package/dist/network-error-thrower.js +0 -14
  683. package/dist/network-error-thrower.js.map +0 -1
  684. package/dist/outlet-context.d.ts +0 -13
  685. package/dist/outlet-context.d.ts.map +0 -1
  686. package/dist/outlet-context.js +0 -3
  687. package/dist/outlet-context.js.map +0 -1
  688. package/dist/prerender/__tests__/param-hash.test.d.ts +0 -2
  689. package/dist/prerender/__tests__/param-hash.test.d.ts.map +0 -1
  690. package/dist/prerender/__tests__/param-hash.test.js +0 -148
  691. package/dist/prerender/__tests__/param-hash.test.js.map +0 -1
  692. package/dist/prerender/param-hash.d.ts +0 -16
  693. package/dist/prerender/param-hash.d.ts.map +0 -1
  694. package/dist/prerender/param-hash.js +0 -36
  695. package/dist/prerender/param-hash.js.map +0 -1
  696. package/dist/prerender/store.d.ts +0 -38
  697. package/dist/prerender/store.d.ts.map +0 -1
  698. package/dist/prerender/store.js +0 -61
  699. package/dist/prerender/store.js.map +0 -1
  700. package/dist/prerender.d.ts +0 -66
  701. package/dist/prerender.d.ts.map +0 -1
  702. package/dist/prerender.js +0 -57
  703. package/dist/prerender.js.map +0 -1
  704. package/dist/reverse.d.ts +0 -196
  705. package/dist/reverse.d.ts.map +0 -1
  706. package/dist/reverse.js +0 -78
  707. package/dist/reverse.js.map +0 -1
  708. package/dist/root-error-boundary.d.ts +0 -33
  709. package/dist/root-error-boundary.d.ts.map +0 -1
  710. package/dist/root-error-boundary.js +0 -165
  711. package/dist/root-error-boundary.js.map +0 -1
  712. package/dist/route-content-wrapper.d.ts +0 -46
  713. package/dist/route-content-wrapper.d.ts.map +0 -1
  714. package/dist/route-content-wrapper.js +0 -77
  715. package/dist/route-content-wrapper.js.map +0 -1
  716. package/dist/route-definition.d.ts +0 -421
  717. package/dist/route-definition.d.ts.map +0 -1
  718. package/dist/route-definition.js +0 -868
  719. package/dist/route-definition.js.map +0 -1
  720. package/dist/route-map-builder.d.ts +0 -155
  721. package/dist/route-map-builder.d.ts.map +0 -1
  722. package/dist/route-map-builder.js +0 -237
  723. package/dist/route-map-builder.js.map +0 -1
  724. package/dist/route-types.d.ts +0 -165
  725. package/dist/route-types.d.ts.map +0 -1
  726. package/dist/route-types.js +0 -7
  727. package/dist/route-types.js.map +0 -1
  728. package/dist/router/__tests__/handler-context.test.d.ts +0 -2
  729. package/dist/router/__tests__/handler-context.test.d.ts.map +0 -1
  730. package/dist/router/__tests__/handler-context.test.js +0 -65
  731. package/dist/router/__tests__/handler-context.test.js.map +0 -1
  732. package/dist/router/__tests__/loader-cycle-detection.test.d.ts +0 -2
  733. package/dist/router/__tests__/loader-cycle-detection.test.d.ts.map +0 -1
  734. package/dist/router/__tests__/loader-cycle-detection.test.js +0 -221
  735. package/dist/router/__tests__/loader-cycle-detection.test.js.map +0 -1
  736. package/dist/router/__tests__/match-context.test.d.ts +0 -2
  737. package/dist/router/__tests__/match-context.test.d.ts.map +0 -1
  738. package/dist/router/__tests__/match-context.test.js +0 -92
  739. package/dist/router/__tests__/match-context.test.js.map +0 -1
  740. package/dist/router/__tests__/match-pipelines.test.d.ts +0 -2
  741. package/dist/router/__tests__/match-pipelines.test.d.ts.map +0 -1
  742. package/dist/router/__tests__/match-pipelines.test.js +0 -417
  743. package/dist/router/__tests__/match-pipelines.test.js.map +0 -1
  744. package/dist/router/__tests__/match-result.test.d.ts +0 -2
  745. package/dist/router/__tests__/match-result.test.d.ts.map +0 -1
  746. package/dist/router/__tests__/match-result.test.js +0 -457
  747. package/dist/router/__tests__/match-result.test.js.map +0 -1
  748. package/dist/router/__tests__/on-error.test.d.ts +0 -2
  749. package/dist/router/__tests__/on-error.test.d.ts.map +0 -1
  750. package/dist/router/__tests__/on-error.test.js +0 -678
  751. package/dist/router/__tests__/on-error.test.js.map +0 -1
  752. package/dist/router/__tests__/pattern-matching.test.d.ts +0 -2
  753. package/dist/router/__tests__/pattern-matching.test.d.ts.map +0 -1
  754. package/dist/router/__tests__/pattern-matching.test.js +0 -629
  755. package/dist/router/__tests__/pattern-matching.test.js.map +0 -1
  756. package/dist/router/__tests__/segment-resolution-parallel-loading.test.d.ts +0 -2
  757. package/dist/router/__tests__/segment-resolution-parallel-loading.test.d.ts.map +0 -1
  758. package/dist/router/__tests__/segment-resolution-parallel-loading.test.js +0 -155
  759. package/dist/router/__tests__/segment-resolution-parallel-loading.test.js.map +0 -1
  760. package/dist/router/error-handling.d.ts +0 -77
  761. package/dist/router/error-handling.d.ts.map +0 -1
  762. package/dist/router/error-handling.js +0 -202
  763. package/dist/router/error-handling.js.map +0 -1
  764. package/dist/router/handler-context.d.ts +0 -20
  765. package/dist/router/handler-context.d.ts.map +0 -1
  766. package/dist/router/handler-context.js +0 -198
  767. package/dist/router/handler-context.js.map +0 -1
  768. package/dist/router/intercept-resolution.d.ts +0 -66
  769. package/dist/router/intercept-resolution.d.ts.map +0 -1
  770. package/dist/router/intercept-resolution.js +0 -246
  771. package/dist/router/intercept-resolution.js.map +0 -1
  772. package/dist/router/loader-resolution.d.ts +0 -64
  773. package/dist/router/loader-resolution.d.ts.map +0 -1
  774. package/dist/router/loader-resolution.js +0 -284
  775. package/dist/router/loader-resolution.js.map +0 -1
  776. package/dist/router/logging.d.ts +0 -15
  777. package/dist/router/logging.d.ts.map +0 -1
  778. package/dist/router/logging.js +0 -99
  779. package/dist/router/logging.js.map +0 -1
  780. package/dist/router/manifest.d.ts +0 -22
  781. package/dist/router/manifest.d.ts.map +0 -1
  782. package/dist/router/manifest.js +0 -181
  783. package/dist/router/manifest.js.map +0 -1
  784. package/dist/router/match-api.d.ts +0 -35
  785. package/dist/router/match-api.d.ts.map +0 -1
  786. package/dist/router/match-api.js +0 -406
  787. package/dist/router/match-api.js.map +0 -1
  788. package/dist/router/match-context.d.ts +0 -206
  789. package/dist/router/match-context.d.ts.map +0 -1
  790. package/dist/router/match-context.js +0 -17
  791. package/dist/router/match-context.js.map +0 -1
  792. package/dist/router/match-middleware/background-revalidation.d.ts +0 -127
  793. package/dist/router/match-middleware/background-revalidation.d.ts.map +0 -1
  794. package/dist/router/match-middleware/background-revalidation.js +0 -75
  795. package/dist/router/match-middleware/background-revalidation.js.map +0 -1
  796. package/dist/router/match-middleware/cache-lookup.d.ts +0 -112
  797. package/dist/router/match-middleware/cache-lookup.d.ts.map +0 -1
  798. package/dist/router/match-middleware/cache-lookup.js +0 -257
  799. package/dist/router/match-middleware/cache-lookup.js.map +0 -1
  800. package/dist/router/match-middleware/cache-store.d.ts +0 -113
  801. package/dist/router/match-middleware/cache-store.d.ts.map +0 -1
  802. package/dist/router/match-middleware/cache-store.js +0 -108
  803. package/dist/router/match-middleware/cache-store.js.map +0 -1
  804. package/dist/router/match-middleware/index.d.ts +0 -81
  805. package/dist/router/match-middleware/index.d.ts.map +0 -1
  806. package/dist/router/match-middleware/index.js +0 -80
  807. package/dist/router/match-middleware/index.js.map +0 -1
  808. package/dist/router/match-middleware/intercept-resolution.d.ts +0 -117
  809. package/dist/router/match-middleware/intercept-resolution.d.ts.map +0 -1
  810. package/dist/router/match-middleware/intercept-resolution.js +0 -134
  811. package/dist/router/match-middleware/intercept-resolution.js.map +0 -1
  812. package/dist/router/match-middleware/segment-resolution.d.ts +0 -99
  813. package/dist/router/match-middleware/segment-resolution.d.ts.map +0 -1
  814. package/dist/router/match-middleware/segment-resolution.js +0 -53
  815. package/dist/router/match-middleware/segment-resolution.js.map +0 -1
  816. package/dist/router/match-pipelines.d.ts +0 -147
  817. package/dist/router/match-pipelines.d.ts.map +0 -1
  818. package/dist/router/match-pipelines.js +0 -82
  819. package/dist/router/match-pipelines.js.map +0 -1
  820. package/dist/router/match-result.d.ts +0 -126
  821. package/dist/router/match-result.d.ts.map +0 -1
  822. package/dist/router/match-result.js +0 -93
  823. package/dist/router/match-result.js.map +0 -1
  824. package/dist/router/metrics.d.ts +0 -20
  825. package/dist/router/metrics.d.ts.map +0 -1
  826. package/dist/router/metrics.js +0 -47
  827. package/dist/router/metrics.js.map +0 -1
  828. package/dist/router/middleware.d.ts +0 -249
  829. package/dist/router/middleware.d.ts.map +0 -1
  830. package/dist/router/middleware.js +0 -434
  831. package/dist/router/middleware.js.map +0 -1
  832. package/dist/router/middleware.test.d.ts +0 -2
  833. package/dist/router/middleware.test.d.ts.map +0 -1
  834. package/dist/router/middleware.test.js +0 -816
  835. package/dist/router/middleware.test.js.map +0 -1
  836. package/dist/router/pattern-matching.d.ts +0 -149
  837. package/dist/router/pattern-matching.d.ts.map +0 -1
  838. package/dist/router/pattern-matching.js +0 -349
  839. package/dist/router/pattern-matching.js.map +0 -1
  840. package/dist/router/revalidation.d.ts +0 -44
  841. package/dist/router/revalidation.d.ts.map +0 -1
  842. package/dist/router/revalidation.js +0 -147
  843. package/dist/router/revalidation.js.map +0 -1
  844. package/dist/router/router-context.d.ts +0 -135
  845. package/dist/router/router-context.d.ts.map +0 -1
  846. package/dist/router/router-context.js +0 -36
  847. package/dist/router/router-context.js.map +0 -1
  848. package/dist/router/segment-resolution.d.ts +0 -127
  849. package/dist/router/segment-resolution.d.ts.map +0 -1
  850. package/dist/router/segment-resolution.js +0 -919
  851. package/dist/router/segment-resolution.js.map +0 -1
  852. package/dist/router/trie-matching.d.ts +0 -40
  853. package/dist/router/trie-matching.d.ts.map +0 -1
  854. package/dist/router/trie-matching.js +0 -127
  855. package/dist/router/trie-matching.js.map +0 -1
  856. package/dist/router/types.d.ts +0 -136
  857. package/dist/router/types.d.ts.map +0 -1
  858. package/dist/router/types.js +0 -7
  859. package/dist/router/types.js.map +0 -1
  860. package/dist/router.d.ts +0 -753
  861. package/dist/router.d.ts.map +0 -1
  862. package/dist/router.gen.d.ts +0 -6
  863. package/dist/router.gen.d.ts.map +0 -1
  864. package/dist/router.gen.js +0 -6
  865. package/dist/router.gen.js.map +0 -1
  866. package/dist/router.js +0 -1304
  867. package/dist/router.js.map +0 -1
  868. package/dist/rsc/__tests__/helpers.test.d.ts +0 -2
  869. package/dist/rsc/__tests__/helpers.test.d.ts.map +0 -1
  870. package/dist/rsc/__tests__/helpers.test.js +0 -140
  871. package/dist/rsc/__tests__/helpers.test.js.map +0 -1
  872. package/dist/rsc/handler.d.ts +0 -45
  873. package/dist/rsc/handler.d.ts.map +0 -1
  874. package/dist/rsc/handler.js +0 -1172
  875. package/dist/rsc/handler.js.map +0 -1
  876. package/dist/rsc/helpers.d.ts +0 -16
  877. package/dist/rsc/helpers.d.ts.map +0 -1
  878. package/dist/rsc/helpers.js +0 -55
  879. package/dist/rsc/helpers.js.map +0 -1
  880. package/dist/rsc/index.d.ts +0 -22
  881. package/dist/rsc/index.d.ts.map +0 -1
  882. package/dist/rsc/index.js +0 -23
  883. package/dist/rsc/index.js.map +0 -1
  884. package/dist/rsc/nonce.d.ts +0 -9
  885. package/dist/rsc/nonce.d.ts.map +0 -1
  886. package/dist/rsc/nonce.js +0 -18
  887. package/dist/rsc/nonce.js.map +0 -1
  888. package/dist/rsc/types.d.ts +0 -206
  889. package/dist/rsc/types.d.ts.map +0 -1
  890. package/dist/rsc/types.js +0 -8
  891. package/dist/rsc/types.js.map +0 -1
  892. package/dist/search-params.d.ts +0 -103
  893. package/dist/search-params.d.ts.map +0 -1
  894. package/dist/search-params.js +0 -74
  895. package/dist/search-params.js.map +0 -1
  896. package/dist/segment-system.d.ts +0 -75
  897. package/dist/segment-system.d.ts.map +0 -1
  898. package/dist/segment-system.js +0 -336
  899. package/dist/segment-system.js.map +0 -1
  900. package/dist/server/context.d.ts +0 -245
  901. package/dist/server/context.d.ts.map +0 -1
  902. package/dist/server/context.js +0 -197
  903. package/dist/server/context.js.map +0 -1
  904. package/dist/server/fetchable-loader-store.d.ts +0 -18
  905. package/dist/server/fetchable-loader-store.d.ts.map +0 -1
  906. package/dist/server/fetchable-loader-store.js +0 -18
  907. package/dist/server/fetchable-loader-store.js.map +0 -1
  908. package/dist/server/handle-store.d.ts +0 -85
  909. package/dist/server/handle-store.d.ts.map +0 -1
  910. package/dist/server/handle-store.js +0 -142
  911. package/dist/server/handle-store.js.map +0 -1
  912. package/dist/server/loader-registry.d.ts +0 -55
  913. package/dist/server/loader-registry.d.ts.map +0 -1
  914. package/dist/server/loader-registry.js +0 -132
  915. package/dist/server/loader-registry.js.map +0 -1
  916. package/dist/server/request-context.d.ts +0 -226
  917. package/dist/server/request-context.d.ts.map +0 -1
  918. package/dist/server/request-context.js +0 -290
  919. package/dist/server/request-context.js.map +0 -1
  920. package/dist/server/root-layout.d.ts +0 -4
  921. package/dist/server/root-layout.d.ts.map +0 -1
  922. package/dist/server/root-layout.js +0 -5
  923. package/dist/server/root-layout.js.map +0 -1
  924. package/dist/server.d.ts +0 -15
  925. package/dist/server.d.ts.map +0 -1
  926. package/dist/server.js +0 -20
  927. package/dist/server.js.map +0 -1
  928. package/dist/ssr/__tests__/ssr-handler.test.d.ts +0 -2
  929. package/dist/ssr/__tests__/ssr-handler.test.d.ts.map +0 -1
  930. package/dist/ssr/__tests__/ssr-handler.test.js +0 -132
  931. package/dist/ssr/__tests__/ssr-handler.test.js.map +0 -1
  932. package/dist/ssr/index.d.ts +0 -98
  933. package/dist/ssr/index.d.ts.map +0 -1
  934. package/dist/ssr/index.js +0 -158
  935. package/dist/ssr/index.js.map +0 -1
  936. package/dist/static-handler.d.ts +0 -50
  937. package/dist/static-handler.d.ts.map +0 -1
  938. package/dist/static-handler.gen.d.ts +0 -5
  939. package/dist/static-handler.gen.d.ts.map +0 -1
  940. package/dist/static-handler.gen.js +0 -5
  941. package/dist/static-handler.gen.js.map +0 -1
  942. package/dist/static-handler.js +0 -29
  943. package/dist/static-handler.js.map +0 -1
  944. package/dist/theme/ThemeProvider.d.ts +0 -20
  945. package/dist/theme/ThemeProvider.d.ts.map +0 -1
  946. package/dist/theme/ThemeProvider.js +0 -240
  947. package/dist/theme/ThemeProvider.js.map +0 -1
  948. package/dist/theme/ThemeScript.d.ts +0 -48
  949. package/dist/theme/ThemeScript.d.ts.map +0 -1
  950. package/dist/theme/ThemeScript.js +0 -13
  951. package/dist/theme/ThemeScript.js.map +0 -1
  952. package/dist/theme/__tests__/theme.test.d.ts +0 -2
  953. package/dist/theme/__tests__/theme.test.d.ts.map +0 -1
  954. package/dist/theme/__tests__/theme.test.js +0 -103
  955. package/dist/theme/__tests__/theme.test.js.map +0 -1
  956. package/dist/theme/constants.d.ts +0 -29
  957. package/dist/theme/constants.d.ts.map +0 -1
  958. package/dist/theme/constants.js +0 -48
  959. package/dist/theme/constants.js.map +0 -1
  960. package/dist/theme/index.d.ts +0 -31
  961. package/dist/theme/index.d.ts.map +0 -1
  962. package/dist/theme/index.js +0 -36
  963. package/dist/theme/index.js.map +0 -1
  964. package/dist/theme/theme-context.d.ts +0 -40
  965. package/dist/theme/theme-context.d.ts.map +0 -1
  966. package/dist/theme/theme-context.js +0 -60
  967. package/dist/theme/theme-context.js.map +0 -1
  968. package/dist/theme/theme-script.d.ts +0 -27
  969. package/dist/theme/theme-script.d.ts.map +0 -1
  970. package/dist/theme/theme-script.js +0 -147
  971. package/dist/theme/theme-script.js.map +0 -1
  972. package/dist/theme/types.d.ts +0 -163
  973. package/dist/theme/types.d.ts.map +0 -1
  974. package/dist/theme/types.js +0 -11
  975. package/dist/theme/types.js.map +0 -1
  976. package/dist/theme/use-theme.d.ts +0 -12
  977. package/dist/theme/use-theme.d.ts.map +0 -1
  978. package/dist/theme/use-theme.js +0 -40
  979. package/dist/theme/use-theme.js.map +0 -1
  980. package/dist/types.d.ts +0 -1479
  981. package/dist/types.d.ts.map +0 -1
  982. package/dist/types.js +0 -10
  983. package/dist/types.js.map +0 -1
  984. package/dist/urls.d.ts +0 -441
  985. package/dist/urls.d.ts.map +0 -1
  986. package/dist/urls.gen.d.ts +0 -8
  987. package/dist/urls.gen.d.ts.map +0 -1
  988. package/dist/urls.gen.js +0 -8
  989. package/dist/urls.gen.js.map +0 -1
  990. package/dist/urls.js +0 -443
  991. package/dist/urls.js.map +0 -1
  992. package/dist/use-loader.d.ts +0 -127
  993. package/dist/use-loader.d.ts.map +0 -1
  994. package/dist/use-loader.js +0 -237
  995. package/dist/use-loader.js.map +0 -1
  996. package/dist/vite/__tests__/ast-handler-extract.test.d.ts +0 -2
  997. package/dist/vite/__tests__/ast-handler-extract.test.d.ts.map +0 -1
  998. package/dist/vite/__tests__/ast-handler-extract.test.js +0 -294
  999. package/dist/vite/__tests__/ast-handler-extract.test.js.map +0 -1
  1000. package/dist/vite/__tests__/expose-id-utils.test.d.ts +0 -2
  1001. package/dist/vite/__tests__/expose-id-utils.test.d.ts.map +0 -1
  1002. package/dist/vite/__tests__/expose-id-utils.test.js +0 -224
  1003. package/dist/vite/__tests__/expose-id-utils.test.js.map +0 -1
  1004. package/dist/vite/__tests__/expose-internal-ids.test.d.ts +0 -2
  1005. package/dist/vite/__tests__/expose-internal-ids.test.d.ts.map +0 -1
  1006. package/dist/vite/__tests__/expose-internal-ids.test.js +0 -647
  1007. package/dist/vite/__tests__/expose-internal-ids.test.js.map +0 -1
  1008. package/dist/vite/__tests__/expose-router-id.test.d.ts +0 -2
  1009. package/dist/vite/__tests__/expose-router-id.test.d.ts.map +0 -1
  1010. package/dist/vite/__tests__/expose-router-id.test.js +0 -39
  1011. package/dist/vite/__tests__/expose-router-id.test.js.map +0 -1
  1012. package/dist/vite/ast-handler-extract.d.ts +0 -49
  1013. package/dist/vite/ast-handler-extract.d.ts.map +0 -1
  1014. package/dist/vite/ast-handler-extract.js +0 -249
  1015. package/dist/vite/ast-handler-extract.js.map +0 -1
  1016. package/dist/vite/expose-action-id.d.ts +0 -19
  1017. package/dist/vite/expose-action-id.d.ts.map +0 -1
  1018. package/dist/vite/expose-action-id.js +0 -250
  1019. package/dist/vite/expose-action-id.js.map +0 -1
  1020. package/dist/vite/expose-id-utils.d.ts +0 -69
  1021. package/dist/vite/expose-id-utils.d.ts.map +0 -1
  1022. package/dist/vite/expose-id-utils.js +0 -289
  1023. package/dist/vite/expose-id-utils.js.map +0 -1
  1024. package/dist/vite/expose-internal-ids.d.ts +0 -22
  1025. package/dist/vite/expose-internal-ids.d.ts.map +0 -1
  1026. package/dist/vite/expose-internal-ids.js +0 -886
  1027. package/dist/vite/expose-internal-ids.js.map +0 -1
  1028. package/dist/vite/index.d.ts +0 -149
  1029. package/dist/vite/index.d.ts.map +0 -1
  1030. package/dist/vite/index.js.bak +0 -5448
  1031. package/dist/vite/index.js.map +0 -1
  1032. package/dist/vite/index.named-routes.gen.ts +0 -103
  1033. package/dist/vite/package-resolution.d.ts +0 -43
  1034. package/dist/vite/package-resolution.d.ts.map +0 -1
  1035. package/dist/vite/package-resolution.js +0 -112
  1036. package/dist/vite/package-resolution.js.map +0 -1
  1037. package/dist/vite/virtual-entries.d.ts +0 -25
  1038. package/dist/vite/virtual-entries.d.ts.map +0 -1
  1039. package/dist/vite/virtual-entries.js +0 -110
  1040. package/dist/vite/virtual-entries.js.map +0 -1
  1041. package/src/browser/action-response-classifier.ts +0 -99
@@ -16,7 +16,10 @@ export {
16
16
  type KVNamespace,
17
17
  } from "./cf-cache-store.js";
18
18
 
19
- // Header constants for debugging and inspection
19
+ // Header constants for debugging and inspection. The tag headers
20
+ // (x-edge-cache-tags / x-edge-cache-tagged-at) are intentionally NOT re-exported:
21
+ // they are an internal encoding detail of the store's tag-invalidation check, not
22
+ // a consumer-inspectable contract.
20
23
  export {
21
24
  CACHE_STALE_AT_HEADER,
22
25
  CACHE_STATUS_HEADER,
@@ -12,10 +12,14 @@
12
12
  */
13
13
 
14
14
  import type { MiddlewareFn, MiddlewareContext } from "../router/middleware.js";
15
- import { getRequestContext } from "../server/request-context.js";
15
+ import {
16
+ getRequestContext,
17
+ type RequestContext,
18
+ } from "../server/request-context.js";
16
19
  import { mayNeedSSR } from "../rsc/ssr-setup.js";
17
20
  import { sortedSearchString } from "./cache-key-utils.js";
18
21
  import { runBackground } from "./background-task.js";
22
+ import { reportCacheError } from "./cache-error.js";
19
23
 
20
24
  // ============================================================================
21
25
  // Constants
@@ -24,6 +28,32 @@ import { runBackground } from "./background-task.js";
24
28
  /** Header indicating cache status for debugging */
25
29
  const CACHE_STATUS_HEADER = "x-document-cache-status";
26
30
 
31
+ /**
32
+ * Snapshot the request-scoped tag union for a document cache write. The full-page
33
+ * entry is tagged with every cache tag its content resolved (runtime cacheTag(),
34
+ * "use cache" profile tags, and loader cache tags) so updateTag()/revalidateTag()
35
+ * can invalidate it. Returns undefined when no tags were used, keeping untagged
36
+ * document entries header-free.
37
+ *
38
+ * This is a plain synchronous snapshot. The CALLER must drain the rendered body
39
+ * first (see the cache-write closures): runtime cacheTag()/"use cache" and loader
40
+ * tags are recorded synchronously as each value resolves during render, including
41
+ * Suspense-streamed ones that resolve AFTER the handler-settlement barrier - so
42
+ * the correct barrier is the stream draining (render complete), not _handleStore.
43
+ *
44
+ * Caveat: segment cache({ tags }) DSL tags are recorded inside the deferred
45
+ * cacheRoute waitUntil, which can still run after this snapshot; a document that
46
+ * combines whole-page document caching with segment-DSL tags may miss those (the
47
+ * segment cache entry itself is still correctly tagged and invalidated). Runtime
48
+ * cacheTag()/"use cache" and loader tags are always captured once the body drains.
49
+ */
50
+ function collectRequestTags(
51
+ requestCtx: RequestContext | undefined,
52
+ ): string[] | undefined {
53
+ const tags = requestCtx?._requestTags;
54
+ return tags && tags.size > 0 ? [...tags] : undefined;
55
+ }
56
+
27
57
  /**
28
58
  * Simple hash function for segment IDs.
29
59
  * Creates a short, deterministic hash to differentiate cache keys
@@ -303,17 +333,26 @@ export function createDocumentCacheMiddleware<TEnv = any>(
303
333
  const fresh = await next();
304
334
  const directives = shouldCacheResponse(fresh);
305
335
 
306
- if (directives) {
336
+ if (directives && fresh.body) {
337
+ // Background revalidation: nothing streams to a client, so drain
338
+ // the fresh render fully before snapshotting tags (same
339
+ // render-complete barrier as the miss path).
340
+ const body = await new Response(fresh.body).arrayBuffer();
307
341
  await store.putResponse!(
308
342
  cacheKey,
309
- fresh,
343
+ new Response(body, fresh),
310
344
  directives.sMaxAge!,
311
345
  directives.staleWhileRevalidate,
346
+ collectRequestTags(requestCtx),
312
347
  );
313
348
  log(`[DocumentCache] REVALIDATED ${typeLabel}: ${url.pathname}`);
314
349
  }
315
350
  } catch (error) {
316
- console.error(`[DocumentCache] Revalidation failed:`, error);
351
+ reportCacheError(
352
+ error,
353
+ "cache-write",
354
+ "[DocumentCache] revalidation",
355
+ );
317
356
  }
318
357
  });
319
358
 
@@ -346,14 +385,27 @@ export function createDocumentCacheMiddleware<TEnv = any>(
346
385
  // Clone response for caching (non-blocking)
347
386
  runBackground(requestCtx, async () => {
348
387
  try {
388
+ // Drain the cache copy fully BEFORE snapshotting tags. Tags from
389
+ // Suspense-streamed "use cache"/cacheTag and loaders are recorded as
390
+ // each value resolves during the RSC/HTML render, which completes
391
+ // only when the stream ends - the handler-settlement barrier is too
392
+ // early. Buffering the body (the client streams the other tee branch,
393
+ // unaffected) is the render-complete barrier that keeps the cached
394
+ // body and its tag set consistent.
395
+ const body = await new Response(cacheStream).arrayBuffer();
349
396
  await store.putResponse!(
350
397
  cacheKey,
351
- new Response(cacheStream, originalResponse),
398
+ new Response(body, originalResponse),
352
399
  directives.sMaxAge!,
353
400
  directives.staleWhileRevalidate,
401
+ collectRequestTags(requestCtx),
354
402
  );
355
403
  } catch (error) {
356
- console.error(`[DocumentCache] Cache write failed:`, error);
404
+ reportCacheError(
405
+ error,
406
+ "cache-write",
407
+ "[DocumentCache] cache write",
408
+ );
357
409
  }
358
410
  });
359
411
 
@@ -366,7 +418,7 @@ export function createDocumentCacheMiddleware<TEnv = any>(
366
418
  // No cache headers - pass through
367
419
  return originalResponse;
368
420
  } catch (error) {
369
- console.error(`[DocumentCache] Error:`, error);
421
+ reportCacheError(error, "cache-read", "[DocumentCache] middleware");
370
422
  if (handlerCalled) {
371
423
  // Post-handler failure (e.g. body.tee()): do not call next() again
372
424
  // as that would re-run handler side effects.
@@ -42,3 +42,9 @@ export {
42
42
  createDocumentCacheMiddleware,
43
43
  type DocumentCacheOptions,
44
44
  } from "./document-cache.js";
45
+
46
+ // Cache error reporting. CacheErrorCategory is the discriminator surfaced to a
47
+ // router's onError callback as `metadata.category` for the `cache` phase, so
48
+ // consumers can branch on the failure kind (e.g. distinguish a transient
49
+ // cache-read outage from cache-corrupt self-heal).
50
+ export type { CacheErrorCategory } from "./cache-error.js";
@@ -21,10 +21,13 @@ import {
21
21
  computeExpiration,
22
22
  DEFAULT_FUNCTION_TTL,
23
23
  } from "./cache-policy.js";
24
+ import { reportCacheError } from "./cache-error.js";
24
25
 
25
26
  const CACHE_REGISTRY_KEY = "__rsc_router_segment_cache_registry__";
26
27
  const RESPONSE_CACHE_REGISTRY_KEY = "__rsc_router_response_cache_registry__";
27
28
  const ITEM_CACHE_REGISTRY_KEY = "__rsc_router_item_cache_registry__";
29
+ const TAG_INDEX_REGISTRY_KEY = "__rsc_router_tag_index_registry__";
30
+ const KEY_TAGS_REGISTRY_KEY = "__rsc_router_key_tags_registry__";
28
31
 
29
32
  /**
30
33
  * Get or create a named Map from a globalThis-backed registry.
@@ -59,6 +62,7 @@ interface CachedItemEntry {
59
62
  handles?: Record<string, SegmentHandleData>;
60
63
  expiresAt: number;
61
64
  staleAt: number;
65
+ tags?: string[];
62
66
  }
63
67
 
64
68
  /**
@@ -73,6 +77,11 @@ export interface MemorySegmentCacheStoreOptions<TEnv = unknown> {
73
77
  * When omitted, the store uses a plain instance-level Map with no
74
78
  * globalThis sharing, which is the safest default for isolation.
75
79
  *
80
+ * Caveat: two instances constructed with the SAME name share all backing maps
81
+ * (data + tag index), but each keeps its OWN `defaults` and `keyGenerator` from
82
+ * its options - those are not shared. Use one instance per name, or keep the
83
+ * options identical, to avoid surprising divergence.
84
+ *
76
85
  * @example
77
86
  * ```typescript
78
87
  * // Two named stores are isolated from each other
@@ -121,6 +130,11 @@ export interface MemorySegmentCacheStoreOptions<TEnv = unknown> {
121
130
  * For production with multiple instances, use a distributed store
122
131
  * like Cloudflare KV or Redis.
123
132
  *
133
+ * Tag-index cleanup is lazy, mirroring the data maps: a tagged entry that
134
+ * expires but is never re-read or invalidated leaves its forward+reverse index
135
+ * entries resident until the key is reused or invalidated. This is bounded by
136
+ * the distinct-tag count and acceptable for a dev/single-instance store.
137
+ *
124
138
  * @example
125
139
  * ```typescript
126
140
  * // Basic usage
@@ -143,6 +157,10 @@ export class MemorySegmentCacheStore<
143
157
  private cache: Map<string, CachedEntryData>;
144
158
  private responseCache: Map<string, CachedResponseEntry>;
145
159
  private itemCache: Map<string, CachedItemEntry>;
160
+ /** tag -> set of prefixed cache keys (seg:key, res:key, item:key) */
161
+ private tagIndex: Map<string, Set<string>>;
162
+ /** prefixed cache key -> set of tags (reverse index for O(tags) unregister) */
163
+ private keyTags: Map<string, Set<string>>;
146
164
  readonly defaults?: CacheDefaults;
147
165
  readonly keyGenerator?: (
148
166
  ctx: RequestContext<TEnv>,
@@ -165,11 +183,21 @@ export class MemorySegmentCacheStore<
165
183
  ITEM_CACHE_REGISTRY_KEY,
166
184
  options.name,
167
185
  );
186
+ this.tagIndex = getNamedMap<Set<string>>(
187
+ TAG_INDEX_REGISTRY_KEY,
188
+ options.name,
189
+ );
190
+ this.keyTags = getNamedMap<Set<string>>(
191
+ KEY_TAGS_REGISTRY_KEY,
192
+ options.name,
193
+ );
168
194
  } else {
169
195
  // Unnamed stores get a plain instance-level Map (no globalThis sharing).
170
196
  this.cache = new Map<string, CachedEntryData>();
171
197
  this.responseCache = new Map<string, CachedResponseEntry>();
172
198
  this.itemCache = new Map<string, CachedItemEntry>();
199
+ this.tagIndex = new Map<string, Set<string>>();
200
+ this.keyTags = new Map<string, Set<string>>();
173
201
  }
174
202
  this.defaults = options?.defaults;
175
203
  this.keyGenerator = options?.keyGenerator;
@@ -184,6 +212,7 @@ export class MemorySegmentCacheStore<
184
212
 
185
213
  // Check expiration
186
214
  if (Date.now() > cached.expiresAt) {
215
+ this.unregisterTags(`seg:${key}`);
187
216
  this.cache.delete(key);
188
217
  return null;
189
218
  }
@@ -204,10 +233,18 @@ export class MemorySegmentCacheStore<
204
233
  ...data,
205
234
  expiresAt: Date.now() + ttl * 1000,
206
235
  };
236
+ const prefixedKey = `seg:${key}`;
237
+ // Always drop stale tag mappings before writing so an overwrite with
238
+ // different (or no) tags cannot leave the previous tags pointing here.
239
+ this.unregisterTags(prefixedKey);
207
240
  this.cache.set(key, entry);
241
+ if (data.tags && data.tags.length > 0) {
242
+ this.registerTags(data.tags, prefixedKey);
243
+ }
208
244
  }
209
245
 
210
246
  async delete(key: string): Promise<boolean> {
247
+ this.unregisterTags(`seg:${key}`);
211
248
  return this.cache.delete(key);
212
249
  }
213
250
 
@@ -215,6 +252,8 @@ export class MemorySegmentCacheStore<
215
252
  this.cache.clear();
216
253
  this.responseCache.clear();
217
254
  this.itemCache.clear();
255
+ this.tagIndex.clear();
256
+ this.keyTags.clear();
218
257
  }
219
258
 
220
259
  async getResponse(
@@ -224,6 +263,7 @@ export class MemorySegmentCacheStore<
224
263
  if (!cached) return null;
225
264
 
226
265
  if (Date.now() > cached.expiresAt) {
266
+ this.unregisterTags(`res:${key}`);
227
267
  this.responseCache.delete(key);
228
268
  return null;
229
269
  }
@@ -244,23 +284,40 @@ export class MemorySegmentCacheStore<
244
284
  response: Response,
245
285
  ttl: number,
246
286
  swr?: number,
287
+ tags?: string[],
247
288
  ): Promise<void> {
248
- const body = await response.clone().arrayBuffer();
249
- const headers: [string, string][] = [];
250
- response.headers.forEach((value, name) => {
251
- headers.push([name, value]);
252
- });
289
+ try {
290
+ // arrayBuffer() can reject (e.g. an already-consumed body). A write
291
+ // failure must degrade to a no-op (entry simply not cached), never throw
292
+ // up and fail the request.
293
+ const body = await response.clone().arrayBuffer();
294
+ const headers: [string, string][] = [];
295
+ response.headers.forEach((value, name) => {
296
+ headers.push([name, value]);
297
+ });
253
298
 
254
- const swrWindow = resolveSwrWindow(swr, this.defaults);
255
- const { staleAt, expiresAt } = computeExpiration(ttl, swrWindow);
299
+ const swrWindow = resolveSwrWindow(swr, this.defaults);
300
+ const { staleAt, expiresAt } = computeExpiration(ttl, swrWindow);
256
301
 
257
- this.responseCache.set(key, {
258
- body,
259
- status: response.status,
260
- headers,
261
- expiresAt,
262
- staleAt,
263
- });
302
+ const prefixedKey = `res:${key}`;
303
+ this.unregisterTags(prefixedKey);
304
+ this.responseCache.set(key, {
305
+ body,
306
+ status: response.status,
307
+ headers,
308
+ expiresAt,
309
+ staleAt,
310
+ });
311
+ if (tags && tags.length > 0) {
312
+ this.registerTags(tags, prefixedKey);
313
+ }
314
+ } catch (error) {
315
+ reportCacheError(
316
+ error,
317
+ "cache-write",
318
+ "[MemorySegmentCacheStore] putResponse",
319
+ );
320
+ }
264
321
  }
265
322
 
266
323
  async getItem(key: string): Promise<CacheItemResult | null> {
@@ -269,6 +326,7 @@ export class MemorySegmentCacheStore<
269
326
 
270
327
  const now = Date.now();
271
328
  if (now > cached.expiresAt) {
329
+ this.unregisterTags(`item:${key}`);
272
330
  this.itemCache.delete(key);
273
331
  return null;
274
332
  }
@@ -278,6 +336,7 @@ export class MemorySegmentCacheStore<
278
336
  value: cached.value,
279
337
  handles: cached.handles,
280
338
  shouldRevalidate: isStale,
339
+ tags: cached.tags,
281
340
  };
282
341
  }
283
342
 
@@ -289,12 +348,95 @@ export class MemorySegmentCacheStore<
289
348
  const ttl = resolveTtl(options?.ttl, this.defaults, DEFAULT_FUNCTION_TTL);
290
349
  const swrWindow = resolveSwrWindow(options?.swr, this.defaults);
291
350
  const { staleAt, expiresAt } = computeExpiration(ttl, swrWindow);
351
+ const prefixedKey = `item:${key}`;
352
+ this.unregisterTags(prefixedKey);
292
353
  this.itemCache.set(key, {
293
354
  value,
294
355
  handles: options?.handles,
295
356
  expiresAt,
296
357
  staleAt,
358
+ tags: options?.tags,
297
359
  });
360
+ if (options?.tags && options.tags.length > 0) {
361
+ this.registerTags(options.tags, prefixedKey);
362
+ }
363
+ }
364
+
365
+ /**
366
+ * Invalidate every cache entry (segment, response, item) tagged with any of
367
+ * `tags`. Entries are dropped immediately; the next read is a miss and
368
+ * re-renders fresh. This is the store-level primitive both updateTag() and
369
+ * revalidateTag() delegate to. (In-process, so there is nothing to batch
370
+ * beyond looping the tags.)
371
+ */
372
+ async invalidateTags(tags: string[]): Promise<void> {
373
+ for (const tag of tags) {
374
+ const keys = this.tagIndex.get(tag);
375
+ if (!keys || keys.size === 0) continue;
376
+
377
+ // Snapshot the keys before mutating the index inside the loop.
378
+ const prefixedKeys = [...keys];
379
+
380
+ for (const prefixedKey of prefixedKeys) {
381
+ const colonIdx = prefixedKey.indexOf(":");
382
+ const prefix = prefixedKey.slice(0, colonIdx);
383
+ const rawKey = prefixedKey.slice(colonIdx + 1);
384
+
385
+ if (prefix === "seg") {
386
+ this.cache.delete(rawKey);
387
+ } else if (prefix === "res") {
388
+ this.responseCache.delete(rawKey);
389
+ } else if (prefix === "item") {
390
+ this.itemCache.delete(rawKey);
391
+ }
392
+
393
+ // Drop this key from every tag set it belonged to, not just `tag`.
394
+ this.unregisterTags(prefixedKey);
395
+ }
396
+ }
397
+ }
398
+
399
+ /**
400
+ * Register `tags` for a prefixed cache key in both the forward
401
+ * (tag -> keys) and reverse (key -> tags) indexes.
402
+ * Callers must call unregisterTags() first to clear stale mappings.
403
+ * @internal
404
+ */
405
+ private registerTags(tags: string[], prefixedKey: string): void {
406
+ let tagSet = this.keyTags.get(prefixedKey);
407
+ if (!tagSet) {
408
+ tagSet = new Set();
409
+ this.keyTags.set(prefixedKey, tagSet);
410
+ }
411
+ for (const tag of tags) {
412
+ tagSet.add(tag);
413
+ let keys = this.tagIndex.get(tag);
414
+ if (!keys) {
415
+ keys = new Set();
416
+ this.tagIndex.set(tag, keys);
417
+ }
418
+ keys.add(prefixedKey);
419
+ }
420
+ }
421
+
422
+ /**
423
+ * Remove a prefixed cache key from every tag set it belongs to.
424
+ * Uses the reverse index so this is O(tags-per-key), not O(total-tags).
425
+ * @internal
426
+ */
427
+ private unregisterTags(prefixedKey: string): void {
428
+ const tagSet = this.keyTags.get(prefixedKey);
429
+ if (!tagSet) return;
430
+ for (const tag of tagSet) {
431
+ const keys = this.tagIndex.get(tag);
432
+ if (keys) {
433
+ keys.delete(prefixedKey);
434
+ if (keys.size === 0) {
435
+ this.tagIndex.delete(tag);
436
+ }
437
+ }
438
+ }
439
+ this.keyTags.delete(prefixedKey);
298
440
  }
299
441
 
300
442
  /**
@@ -324,5 +466,7 @@ export class MemorySegmentCacheStore<
324
466
  delete (globalThis as any)[CACHE_REGISTRY_KEY];
325
467
  delete (globalThis as any)[RESPONSE_CACHE_REGISTRY_KEY];
326
468
  delete (globalThis as any)[ITEM_CACHE_REGISTRY_KEY];
469
+ delete (globalThis as any)[TAG_INDEX_REGISTRY_KEY];
470
+ delete (globalThis as any)[KEY_TAGS_REGISTRY_KEY];
327
471
  }
328
472
  }
@@ -0,0 +1,206 @@
1
+ /**
2
+ * Cache Tag Invalidation API
3
+ *
4
+ * Two on-demand invalidation verbs, mirroring the distinction popularized by
5
+ * Next.js so consumers can pick the right consistency model:
6
+ *
7
+ * - updateTag(...tags): read-your-own-writes. Awaitable - resolves only after
8
+ * in-process invalidation across every configured store completes. Use in a
9
+ * Server Action and `await` it before the action re-renders, so the action's
10
+ * own response reflects the mutation.
11
+ *
12
+ * - revalidateTag(...tags): fire-and-forget via waitUntil - the response is not
13
+ * blocked. Use in Route Handlers / webhooks. NOTE: both verbs hard-purge; the
14
+ * only difference is awaitability. revalidateTag does NOT serve stale content -
15
+ * the next read after the invalidation lands is a hard miss that re-renders.
16
+ * (The name mirrors Next.js, where it is SWR; here it is background-purge.)
17
+ *
18
+ * Both fan out across the app-level store (ctx._cacheStore) and every explicit
19
+ * per-scope store from cache({ store }) registered for this handler
20
+ * (ctx._explicitTaggedStores), calling the store-level invalidateTags()
21
+ * primitive for each tag. A single configured store (the common case) owns its
22
+ * own tag index and distributed invalidation - there is no separate
23
+ * tag-invalidation store.
24
+ */
25
+
26
+ import { _getRequestContext } from "../server/request-context.js";
27
+ import { reportingAsync } from "./cache-error.js";
28
+ import { normalizeTags } from "./cache-tag.js";
29
+ import type { SegmentCacheStore } from "./types.js";
30
+
31
+ /**
32
+ * Collect every store that may hold entries tagged for this request's handler:
33
+ * the app-level store plus all explicit per-scope stores (deduplicated). Splits
34
+ * them into tag-capable (implement invalidateTags()) and not, so callers can
35
+ * warn about configured stores whose tagged entries will NOT be invalidated.
36
+ */
37
+ function collectStores(): {
38
+ capable: SegmentCacheStore[];
39
+ incapable: number;
40
+ } {
41
+ const ctx = _getRequestContext();
42
+ const stores = new Set<SegmentCacheStore>();
43
+ if (ctx?._cacheStore) stores.add(ctx._cacheStore);
44
+ if (ctx?._explicitTaggedStores) {
45
+ for (const store of ctx._explicitTaggedStores) stores.add(store);
46
+ }
47
+ const capable: SegmentCacheStore[] = [];
48
+ let incapable = 0;
49
+ for (const store of stores) {
50
+ if (typeof store.invalidateTags === "function") capable.push(store);
51
+ else incapable++;
52
+ }
53
+ return { capable, incapable };
54
+ }
55
+
56
+ /**
57
+ * Production-visible warning. A misconfigured store silently dropping
58
+ * invalidations is a data-correctness footgun, so this surfaces in every
59
+ * environment (not dev-only).
60
+ */
61
+ function warnNoTagStore(fn: string, tags: string[]): void {
62
+ console.warn(
63
+ `[${fn}] No tag-capable cache store is configured; tags ` +
64
+ `[${tags.join(", ")}] were not invalidated. The configured store must ` +
65
+ `implement invalidateTags() (the built-in MemorySegmentCacheStore and ` +
66
+ `CFCacheStore do).`,
67
+ );
68
+ }
69
+
70
+ /**
71
+ * Production-visible warning for mixed-store configs: at least one configured
72
+ * store does not support tag invalidation, so its tagged entries (if any) are
73
+ * left stale even though other stores were invalidated.
74
+ */
75
+ function warnPartialTagStore(fn: string, incapable: number): void {
76
+ console.warn(
77
+ `[${fn}] ${incapable} configured cache store(s) do not implement ` +
78
+ `invalidateTags(); their tagged entries were NOT invalidated. Use a ` +
79
+ `tag-capable store (e.g. MemorySegmentCacheStore / CFCacheStore) for any ` +
80
+ `cache({ store }) boundary whose entries you invalidate by tag.`,
81
+ );
82
+ }
83
+
84
+ async function invalidateAcross(
85
+ stores: SegmentCacheStore[],
86
+ tags: string[],
87
+ ): Promise<void> {
88
+ // One invalidateTags(tags) call per store: the store receives the whole tag
89
+ // batch so it can do a single CDN purge request rather than one per tag.
90
+ //
91
+ // allSettled, not all: a store's invalidateTags() can reject (e.g. CFCacheStore
92
+ // surfaces a failed durable KV marker write). With Promise.all, the first
93
+ // rejection would short-circuit and the other stores' outcomes would go
94
+ // unobserved. Attempt every store, then surface a combined error so an awaited
95
+ // updateTag() still rejects (read-your-own-writes honesty) without masking the
96
+ // stores that did succeed.
97
+ const results = await Promise.allSettled(
98
+ stores.map((store) => store.invalidateTags!(tags)),
99
+ );
100
+ const errors = results
101
+ .filter((r): r is PromiseRejectedResult => r.status === "rejected")
102
+ .map((r) => r.reason);
103
+ if (errors.length > 0) {
104
+ const err = new Error(
105
+ `[tag invalidation] ${errors.length}/${stores.length} store(s) failed to ` +
106
+ `invalidate tags [${tags.join(", ")}]; their entries may still serve ` +
107
+ `stale data. Retry the invalidation.`,
108
+ );
109
+ (err as Error & { cause?: unknown }).cause = errors[0];
110
+ throw err;
111
+ }
112
+ }
113
+
114
+ /**
115
+ * Immediately expire every cache entry tagged with any of `tags`, resolving
116
+ * once in-process invalidation across all configured stores completes.
117
+ *
118
+ * Read-your-own-writes: because the returned promise resolves before you return
119
+ * from a Server Action, awaiting it guarantees the action's own re-render (and
120
+ * any subsequent read) sees fresh data.
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * async function updateProduct(formData: FormData) {
125
+ * "use server";
126
+ * await db.updateProduct(formData);
127
+ * await updateTag("products"); // next render is fresh
128
+ * }
129
+ * ```
130
+ */
131
+ export async function updateTag(...tags: string[]): Promise<void> {
132
+ const valid = normalizeTags(tags);
133
+ if (valid.length === 0) return;
134
+
135
+ const { capable, incapable } = collectStores();
136
+ if (capable.length === 0) {
137
+ warnNoTagStore("updateTag", valid);
138
+ return;
139
+ }
140
+ if (incapable > 0) warnPartialTagStore("updateTag", incapable);
141
+
142
+ await invalidateAcross(capable, valid);
143
+ }
144
+
145
+ /**
146
+ * Invalidate every cache entry tagged with any of `tags` in the background,
147
+ * without blocking the current response (fire-and-forget via waitUntil).
148
+ *
149
+ * This is NOT stale-while-revalidate: like updateTag() it hard-purges, so the
150
+ * next read after the invalidation lands is a miss that re-renders fresh. The
151
+ * only difference from updateTag() is awaitability - revalidateTag() defers the
152
+ * purge off the response path and is not awaited.
153
+ *
154
+ * Use in Route Handlers / webhooks. For read-your-own-writes inside a Server
155
+ * Action, use updateTag() instead so the action's own response is fresh.
156
+ *
157
+ * Fire-and-forget: because this returns void and runs in the background, a
158
+ * failed durable marker write (e.g. a transient KV outage) is NOT surfaced to
159
+ * the caller. It IS reported - logged loudly and routed through the router's
160
+ * `onError` callback (phase `cache`, `metadata.category === "cache-invalidate"`)
161
+ * via reportingAsync - so the failure is observable in telemetry even though it
162
+ * cannot be awaited. If you need the invalidation to be CONFIRMED (and to retry
163
+ * on failure), use `await updateTag()` instead, which rejects when a store's
164
+ * durable write fails.
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * // route handler invoked by an external webhook
169
+ * export async function POST() {
170
+ * "use server";
171
+ * revalidateTag("products");
172
+ * return new Response("ok");
173
+ * }
174
+ * ```
175
+ */
176
+ export function revalidateTag(...tags: string[]): void {
177
+ const valid = normalizeTags(tags);
178
+ if (valid.length === 0) return;
179
+
180
+ const { capable, incapable } = collectStores();
181
+ if (capable.length === 0) {
182
+ warnNoTagStore("revalidateTag", valid);
183
+ return;
184
+ }
185
+ if (incapable > 0) warnPartialTagStore("revalidateTag", incapable);
186
+
187
+ const ctx = _getRequestContext();
188
+ // reportingAsync never rejects: it catches a failed durable write and routes
189
+ // it through reportCacheError (loud log + onError). This is the only place a
190
+ // revalidateTag failure can be observed, since it is not awaitable. Pass ctx
191
+ // explicitly - the run executes in a detached waitUntil where the ALS context
192
+ // is gone, so onError fires only if we hand it the captured context.
193
+ const run = () =>
194
+ reportingAsync(
195
+ () => invalidateAcross(capable, valid),
196
+ "cache-invalidate",
197
+ "[revalidateTag] background invalidation",
198
+ ctx,
199
+ );
200
+ if (ctx?.waitUntil) {
201
+ ctx.waitUntil(run);
202
+ } else {
203
+ // No request context (e.g. called outside ALS): best-effort background run.
204
+ void run();
205
+ }
206
+ }