@rangojs/router 0.4.0 → 0.4.1

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 (482) hide show
  1. package/README.md +19 -1
  2. package/dist/types/browser/event-controller.d.ts +4 -0
  3. package/dist/types/browser/link-interceptor.d.ts +17 -7
  4. package/dist/types/browser/navigation-bridge.d.ts +13 -1
  5. package/dist/types/browser/notify-listeners.d.ts +2 -0
  6. package/dist/types/browser/prefetch/cache.d.ts +1 -1
  7. package/dist/types/browser/prefetch/default-strategy.d.ts +12 -3
  8. package/dist/types/browser/prefetch/invalidation.d.ts +6 -0
  9. package/dist/types/browser/prefetch/loader.d.ts +3 -1
  10. package/dist/types/browser/prefetch/observer.d.ts +3 -6
  11. package/dist/types/browser/rango-state.d.ts +4 -0
  12. package/dist/types/browser/react/Link.d.ts +4 -9
  13. package/dist/types/browser/react/context.d.ts +3 -0
  14. package/dist/types/browser/rsc-router.d.ts +7 -2
  15. package/dist/types/browser/types.d.ts +1 -0
  16. package/dist/types/cache/cache-key-utils.d.ts +11 -3
  17. package/dist/types/cache/cache-scope.d.ts +82 -3
  18. package/dist/types/cache/cf/cf-cache-store.d.ts +2 -2
  19. package/dist/types/cache/index.d.ts +3 -1
  20. package/dist/types/cache/search-params-filter.d.ts +64 -0
  21. package/dist/types/cache/shell-snapshot.d.ts +4 -4
  22. package/dist/types/cache/types.d.ts +30 -2
  23. package/dist/types/cache/vercel/vercel-cache-store.d.ts +2 -2
  24. package/dist/types/index.d.ts +1 -0
  25. package/dist/types/index.rsc.d.ts +1 -0
  26. package/dist/types/router/match-middleware/cache-lookup.d.ts +13 -0
  27. package/dist/types/router/navigation-snapshot.d.ts +29 -0
  28. package/dist/types/router/router-options.d.ts +27 -3
  29. package/dist/types/rsc/shell-build-manifest.d.ts +7 -1
  30. package/dist/types/rsc/shell-serve.d.ts +7 -1
  31. package/dist/types/rsc/types.d.ts +17 -0
  32. package/dist/types/server/request-context.d.ts +57 -4
  33. package/dist/types/testing/render-route.d.ts +10 -1
  34. package/dist/types/testing/shell-status.d.ts +6 -3
  35. package/dist/types/vite/plugin-types.d.ts +1 -1
  36. package/dist/vite/index.js +5 -5
  37. package/package.json +23 -22
  38. package/skills/caching/SKILL.md +39 -0
  39. package/skills/comparison/references/framework-comparison.md +7 -1
  40. package/skills/links/SKILL.md +24 -0
  41. package/skills/ppr/SKILL.md +53 -4
  42. package/skills/router-setup/SKILL.md +7 -2
  43. package/skills/testing/client-components.md +15 -14
  44. package/skills/vercel/SKILL.md +1 -1
  45. package/src/browser/event-controller.ts +110 -11
  46. package/src/browser/link-interceptor.ts +469 -20
  47. package/src/browser/navigation-bridge.ts +71 -2
  48. package/src/browser/navigation-store.ts +24 -1
  49. package/src/browser/notify-listeners.ts +22 -0
  50. package/src/browser/prefetch/cache.ts +4 -2
  51. package/src/browser/prefetch/default-strategy.ts +43 -3
  52. package/src/browser/prefetch/invalidation.ts +30 -0
  53. package/src/browser/prefetch/loader.ts +19 -12
  54. package/src/browser/prefetch/observer.ts +50 -22
  55. package/src/browser/rango-state.ts +21 -0
  56. package/src/browser/react/Link.tsx +97 -88
  57. package/src/browser/react/NavigationProvider.tsx +1 -0
  58. package/src/browser/react/context.ts +4 -0
  59. package/src/browser/rsc-router.tsx +22 -9
  60. package/src/browser/types.ts +1 -0
  61. package/src/cache/cache-key-utils.ts +18 -4
  62. package/src/cache/cache-runtime.ts +7 -2
  63. package/src/cache/cache-scope.ts +152 -23
  64. package/src/cache/cf/cf-cache-store.ts +51 -16
  65. package/src/cache/document-cache.ts +7 -1
  66. package/src/cache/index.ts +7 -0
  67. package/src/cache/search-params-filter.ts +118 -0
  68. package/src/cache/shell-snapshot.ts +8 -4
  69. package/src/cache/types.ts +33 -2
  70. package/src/cache/vercel/vercel-cache-store.ts +17 -3
  71. package/src/index.rsc.ts +4 -0
  72. package/src/index.ts +6 -0
  73. package/src/router/match-middleware/cache-lookup.ts +146 -33
  74. package/src/router/match-middleware/cache-store.ts +70 -0
  75. package/src/router/navigation-snapshot.ts +46 -6
  76. package/src/router/router-options.ts +31 -4
  77. package/src/rsc/handler.ts +9 -0
  78. package/src/rsc/response-cache-serve.ts +1 -1
  79. package/src/rsc/rsc-rendering.ts +252 -27
  80. package/src/rsc/shell-build-manifest.ts +8 -1
  81. package/src/rsc/shell-capture.ts +5 -0
  82. package/src/rsc/shell-serve.ts +8 -2
  83. package/src/rsc/types.ts +17 -0
  84. package/src/server/request-context.ts +62 -3
  85. package/src/testing/dispatch.ts +21 -3
  86. package/src/testing/render-route.tsx +86 -17
  87. package/src/testing/shell-status.ts +20 -3
  88. package/src/vite/plugin-types.ts +1 -1
  89. package/src/vite/plugins/vercel-output.ts +2 -2
  90. package/dist/types.backup/__internal.d.ts +0 -127
  91. package/dist/types.backup/bin/rango.d.ts +0 -1
  92. package/dist/types.backup/browser/action-coordinator.d.ts +0 -57
  93. package/dist/types.backup/browser/action-fence.d.ts +0 -33
  94. package/dist/types.backup/browser/app-shell.d.ts +0 -34
  95. package/dist/types.backup/browser/app-version.d.ts +0 -6
  96. package/dist/types.backup/browser/connection-warmup.d.ts +0 -31
  97. package/dist/types.backup/browser/cookie-name.d.ts +0 -66
  98. package/dist/types.backup/browser/event-controller.d.ts +0 -221
  99. package/dist/types.backup/browser/history-state.d.ts +0 -26
  100. package/dist/types.backup/browser/index.d.ts +0 -1
  101. package/dist/types.backup/browser/intercept-utils.d.ts +0 -30
  102. package/dist/types.backup/browser/invalidate-client-cache.d.ts +0 -17
  103. package/dist/types.backup/browser/link-interceptor.d.ts +0 -43
  104. package/dist/types.backup/browser/logging.d.ts +0 -33
  105. package/dist/types.backup/browser/merge-segment-loaders.d.ts +0 -38
  106. package/dist/types.backup/browser/navigation-bridge.d.ts +0 -27
  107. package/dist/types.backup/browser/navigation-client.d.ts +0 -17
  108. package/dist/types.backup/browser/navigation-store-handle.d.ts +0 -25
  109. package/dist/types.backup/browser/navigation-store.d.ts +0 -95
  110. package/dist/types.backup/browser/navigation-transaction.d.ts +0 -75
  111. package/dist/types.backup/browser/network-error-handler.d.ts +0 -35
  112. package/dist/types.backup/browser/partial-update.d.ts +0 -61
  113. package/dist/types.backup/browser/prefetch/cache.d.ts +0 -183
  114. package/dist/types.backup/browser/prefetch/fetch.d.ts +0 -52
  115. package/dist/types.backup/browser/prefetch/observer.d.ts +0 -27
  116. package/dist/types.backup/browser/prefetch/policy.d.ts +0 -13
  117. package/dist/types.backup/browser/prefetch/queue.d.ts +0 -48
  118. package/dist/types.backup/browser/prefetch/resource-ready.d.ts +0 -28
  119. package/dist/types.backup/browser/rango-state.d.ts +0 -52
  120. package/dist/types.backup/browser/react/Link.d.ts +0 -140
  121. package/dist/types.backup/browser/react/NavigationProvider.d.ts +0 -88
  122. package/dist/types.backup/browser/react/ScrollRestoration.d.ts +0 -78
  123. package/dist/types.backup/browser/react/context.d.ts +0 -54
  124. package/dist/types.backup/browser/react/filter-segment-order.d.ts +0 -35
  125. package/dist/types.backup/browser/react/index.d.ts +0 -1
  126. package/dist/types.backup/browser/react/location-state-shared.d.ts +0 -162
  127. package/dist/types.backup/browser/react/location-state.d.ts +0 -29
  128. package/dist/types.backup/browser/react/mount-context.d.ts +0 -23
  129. package/dist/types.backup/browser/react/nonce-context.d.ts +0 -14
  130. package/dist/types.backup/browser/react/shallow-equal.d.ts +0 -5
  131. package/dist/types.backup/browser/react/use-action.d.ts +0 -61
  132. package/dist/types.backup/browser/react/use-handle.d.ts +0 -21
  133. package/dist/types.backup/browser/react/use-href.d.ts +0 -32
  134. package/dist/types.backup/browser/react/use-link-status.d.ts +0 -36
  135. package/dist/types.backup/browser/react/use-mount.d.ts +0 -24
  136. package/dist/types.backup/browser/react/use-navigation.d.ts +0 -15
  137. package/dist/types.backup/browser/react/use-params.d.ts +0 -21
  138. package/dist/types.backup/browser/react/use-pathname.d.ts +0 -13
  139. package/dist/types.backup/browser/react/use-reverse.d.ts +0 -40
  140. package/dist/types.backup/browser/react/use-router.d.ts +0 -23
  141. package/dist/types.backup/browser/react/use-search-params.d.ts +0 -19
  142. package/dist/types.backup/browser/react/use-segments.d.ts +0 -29
  143. package/dist/types.backup/browser/response-adapter.d.ts +0 -58
  144. package/dist/types.backup/browser/rsc-router.d.ts +0 -141
  145. package/dist/types.backup/browser/scroll-restoration.d.ts +0 -103
  146. package/dist/types.backup/browser/segment-reconciler.d.ts +0 -74
  147. package/dist/types.backup/browser/segment-structure-assert.d.ts +0 -16
  148. package/dist/types.backup/browser/server-action-bridge.d.ts +0 -29
  149. package/dist/types.backup/browser/types.d.ts +0 -530
  150. package/dist/types.backup/browser/validate-redirect-origin.d.ts +0 -28
  151. package/dist/types.backup/build/collect-fallback-refs.d.ts +0 -5
  152. package/dist/types.backup/build/generate-manifest.d.ts +0 -100
  153. package/dist/types.backup/build/generate-route-types.d.ts +0 -8
  154. package/dist/types.backup/build/index.d.ts +0 -21
  155. package/dist/types.backup/build/prefix-tree-utils.d.ts +0 -56
  156. package/dist/types.backup/build/route-trie.d.ts +0 -89
  157. package/dist/types.backup/build/route-types/ast-helpers.d.ts +0 -3
  158. package/dist/types.backup/build/route-types/ast-route-extraction.d.ts +0 -13
  159. package/dist/types.backup/build/route-types/codegen.d.ts +0 -16
  160. package/dist/types.backup/build/route-types/include-resolution.d.ts +0 -74
  161. package/dist/types.backup/build/route-types/param-extraction.d.ts +0 -13
  162. package/dist/types.backup/build/route-types/per-module-writer.d.ts +0 -18
  163. package/dist/types.backup/build/route-types/router-processing.d.ts +0 -82
  164. package/dist/types.backup/build/route-types/scan-filter.d.ts +0 -17
  165. package/dist/types.backup/build/route-types/source-scan.d.ts +0 -13
  166. package/dist/types.backup/build/runtime-discovery.d.ts +0 -24
  167. package/dist/types.backup/cache/background-task.d.ts +0 -21
  168. package/dist/types.backup/cache/cache-error.d.ts +0 -71
  169. package/dist/types.backup/cache/cache-key-utils.d.ts +0 -35
  170. package/dist/types.backup/cache/cache-policy.d.ts +0 -59
  171. package/dist/types.backup/cache/cache-runtime.d.ts +0 -51
  172. package/dist/types.backup/cache/cache-scope.d.ts +0 -134
  173. package/dist/types.backup/cache/cache-tag.d.ts +0 -79
  174. package/dist/types.backup/cache/cf/cf-base64.d.ts +0 -4
  175. package/dist/types.backup/cache/cf/cf-cache-constants.d.ts +0 -105
  176. package/dist/types.backup/cache/cf/cf-cache-store.d.ts +0 -481
  177. package/dist/types.backup/cache/cf/cf-cache-types.d.ts +0 -300
  178. package/dist/types.backup/cache/cf/cf-kv-utils.d.ts +0 -22
  179. package/dist/types.backup/cache/cf/cf-tag-marker-memo.d.ts +0 -15
  180. package/dist/types.backup/cache/cf/index.d.ts +0 -3
  181. package/dist/types.backup/cache/document-cache.d.ts +0 -69
  182. package/dist/types.backup/cache/handle-capture.d.ts +0 -23
  183. package/dist/types.backup/cache/handle-snapshot.d.ts +0 -39
  184. package/dist/types.backup/cache/index.d.ts +0 -7
  185. package/dist/types.backup/cache/memory-segment-store.d.ts +0 -163
  186. package/dist/types.backup/cache/profile-registry.d.ts +0 -40
  187. package/dist/types.backup/cache/read-through-swr.d.ts +0 -60
  188. package/dist/types.backup/cache/segment-codec.d.ts +0 -78
  189. package/dist/types.backup/cache/shell-snapshot.d.ts +0 -162
  190. package/dist/types.backup/cache/tag-invalidation.d.ts +0 -74
  191. package/dist/types.backup/cache/taint.d.ts +0 -71
  192. package/dist/types.backup/cache/types.d.ts +0 -407
  193. package/dist/types.backup/cache/vercel/index.d.ts +0 -1
  194. package/dist/types.backup/cache/vercel/vercel-cache-store.d.ts +0 -267
  195. package/dist/types.backup/client.d.ts +0 -184
  196. package/dist/types.backup/client.rsc.d.ts +0 -39
  197. package/dist/types.backup/cloudflare/index.d.ts +0 -7
  198. package/dist/types.backup/cloudflare/tracing.d.ts +0 -53
  199. package/dist/types.backup/component-utils.d.ts +0 -46
  200. package/dist/types.backup/components/DefaultDocument.d.ts +0 -13
  201. package/dist/types.backup/context-var.d.ts +0 -84
  202. package/dist/types.backup/debug.d.ts +0 -57
  203. package/dist/types.backup/decode-loader-results.d.ts +0 -5
  204. package/dist/types.backup/default-error-boundary.d.ts +0 -10
  205. package/dist/types.backup/defer.d.ts +0 -89
  206. package/dist/types.backup/deps/browser.d.ts +0 -1
  207. package/dist/types.backup/deps/html-stream-client.d.ts +0 -1
  208. package/dist/types.backup/deps/html-stream-server.d.ts +0 -1
  209. package/dist/types.backup/deps/rsc.d.ts +0 -1
  210. package/dist/types.backup/deps/ssr.d.ts +0 -1
  211. package/dist/types.backup/encode-kv.d.ts +0 -35
  212. package/dist/types.backup/errors.d.ts +0 -226
  213. package/dist/types.backup/escape-script.d.ts +0 -44
  214. package/dist/types.backup/handle.d.ts +0 -93
  215. package/dist/types.backup/handles/MetaTags.d.ts +0 -17
  216. package/dist/types.backup/handles/Scripts.d.ts +0 -38
  217. package/dist/types.backup/handles/breadcrumbs.d.ts +0 -43
  218. package/dist/types.backup/handles/deferred-resolution.d.ts +0 -53
  219. package/dist/types.backup/handles/is-thenable.d.ts +0 -12
  220. package/dist/types.backup/handles/meta.d.ts +0 -43
  221. package/dist/types.backup/handles/script.d.ts +0 -139
  222. package/dist/types.backup/host/cookie-handler.d.ts +0 -8
  223. package/dist/types.backup/host/errors.d.ts +0 -40
  224. package/dist/types.backup/host/index.d.ts +0 -33
  225. package/dist/types.backup/host/pattern-matcher.d.ts +0 -30
  226. package/dist/types.backup/host/router.d.ts +0 -12
  227. package/dist/types.backup/host/testing.d.ts +0 -41
  228. package/dist/types.backup/host/types.d.ts +0 -148
  229. package/dist/types.backup/host/utils.d.ts +0 -20
  230. package/dist/types.backup/href-client.d.ts +0 -214
  231. package/dist/types.backup/index.d.ts +0 -112
  232. package/dist/types.backup/index.rsc.d.ts +0 -51
  233. package/dist/types.backup/internal-debug.d.ts +0 -1
  234. package/dist/types.backup/loader-store.d.ts +0 -193
  235. package/dist/types.backup/loader.d.ts +0 -18
  236. package/dist/types.backup/loader.rsc.d.ts +0 -18
  237. package/dist/types.backup/missing-id-error.d.ts +0 -1
  238. package/dist/types.backup/outlet-context.d.ts +0 -12
  239. package/dist/types.backup/outlet-provider.d.ts +0 -12
  240. package/dist/types.backup/prerender/build-shell-capture.d.ts +0 -104
  241. package/dist/types.backup/prerender/param-hash.d.ts +0 -6
  242. package/dist/types.backup/prerender/shell-manifest-key.d.ts +0 -18
  243. package/dist/types.backup/prerender/store.d.ts +0 -62
  244. package/dist/types.backup/prerender.d.ts +0 -292
  245. package/dist/types.backup/redirect-origin.d.ts +0 -55
  246. package/dist/types.backup/regex-escape.d.ts +0 -6
  247. package/dist/types.backup/render-error-thrower.d.ts +0 -13
  248. package/dist/types.backup/response-utils.d.ts +0 -35
  249. package/dist/types.backup/reverse.d.ts +0 -206
  250. package/dist/types.backup/root-error-boundary.d.ts +0 -32
  251. package/dist/types.backup/route-content-wrapper.d.ts +0 -40
  252. package/dist/types.backup/route-definition/dsl-helpers.d.ts +0 -130
  253. package/dist/types.backup/route-definition/helper-factories.d.ts +0 -22
  254. package/dist/types.backup/route-definition/helpers-types.d.ts +0 -392
  255. package/dist/types.backup/route-definition/index.d.ts +0 -7
  256. package/dist/types.backup/route-definition/redirect.d.ts +0 -48
  257. package/dist/types.backup/route-definition/resolve-handler-use.d.ts +0 -19
  258. package/dist/types.backup/route-definition/use-item-types.d.ts +0 -1
  259. package/dist/types.backup/route-definition.d.ts +0 -1
  260. package/dist/types.backup/route-map-builder.d.ts +0 -127
  261. package/dist/types.backup/route-name.d.ts +0 -27
  262. package/dist/types.backup/route-types.d.ts +0 -172
  263. package/dist/types.backup/router/basename.d.ts +0 -10
  264. package/dist/types.backup/router/content-negotiation.d.ts +0 -91
  265. package/dist/types.backup/router/debug-manifest.d.ts +0 -7
  266. package/dist/types.backup/router/error-handling.d.ts +0 -76
  267. package/dist/types.backup/router/find-match.d.ts +0 -19
  268. package/dist/types.backup/router/handler-context.d.ts +0 -41
  269. package/dist/types.backup/router/instrument.d.ts +0 -161
  270. package/dist/types.backup/router/intercept-resolution.d.ts +0 -79
  271. package/dist/types.backup/router/lazy-includes.d.ts +0 -26
  272. package/dist/types.backup/router/loader-resolution.d.ts +0 -63
  273. package/dist/types.backup/router/logging.d.ts +0 -41
  274. package/dist/types.backup/router/manifest.d.ts +0 -8
  275. package/dist/types.backup/router/match-api.d.ts +0 -19
  276. package/dist/types.backup/router/match-context.d.ts +0 -184
  277. package/dist/types.backup/router/match-handlers.d.ts +0 -49
  278. package/dist/types.backup/router/match-middleware/background-revalidation.d.ts +0 -113
  279. package/dist/types.backup/router/match-middleware/cache-lookup.d.ts +0 -113
  280. package/dist/types.backup/router/match-middleware/cache-store.d.ts +0 -112
  281. package/dist/types.backup/router/match-middleware/index.d.ts +0 -80
  282. package/dist/types.backup/router/match-middleware/intercept-resolution.d.ts +0 -116
  283. package/dist/types.backup/router/match-middleware/segment-resolution.d.ts +0 -94
  284. package/dist/types.backup/router/match-pipelines.d.ts +0 -103
  285. package/dist/types.backup/router/match-result.d.ts +0 -114
  286. package/dist/types.backup/router/metrics.d.ts +0 -6
  287. package/dist/types.backup/router/middleware-types.d.ts +0 -74
  288. package/dist/types.backup/router/middleware.d.ts +0 -116
  289. package/dist/types.backup/router/navigation-snapshot.d.ts +0 -22
  290. package/dist/types.backup/router/params-util.d.ts +0 -8
  291. package/dist/types.backup/router/parse-pattern.d.ts +0 -38
  292. package/dist/types.backup/router/pattern-matching.d.ts +0 -169
  293. package/dist/types.backup/router/prefetch-cache-ttl.d.ts +0 -27
  294. package/dist/types.backup/router/prefetch-limits.d.ts +0 -20
  295. package/dist/types.backup/router/prerender-match.d.ts +0 -50
  296. package/dist/types.backup/router/preview-match.d.ts +0 -22
  297. package/dist/types.backup/router/request-classification.d.ts +0 -104
  298. package/dist/types.backup/router/revalidation.d.ts +0 -57
  299. package/dist/types.backup/router/route-snapshot.d.ts +0 -112
  300. package/dist/types.backup/router/router-context.d.ts +0 -137
  301. package/dist/types.backup/router/router-interfaces.d.ts +0 -432
  302. package/dist/types.backup/router/router-options.d.ts +0 -738
  303. package/dist/types.backup/router/router-registry.d.ts +0 -15
  304. package/dist/types.backup/router/segment-resolution/fresh.d.ts +0 -55
  305. package/dist/types.backup/router/segment-resolution/helpers.d.ts +0 -93
  306. package/dist/types.backup/router/segment-resolution/loader-cache.d.ts +0 -33
  307. package/dist/types.backup/router/segment-resolution/loader-mask.d.ts +0 -44
  308. package/dist/types.backup/router/segment-resolution/loader-snapshot.d.ts +0 -90
  309. package/dist/types.backup/router/segment-resolution/mask-nested.d.ts +0 -53
  310. package/dist/types.backup/router/segment-resolution/revalidation.d.ts +0 -85
  311. package/dist/types.backup/router/segment-resolution/static-store.d.ts +0 -17
  312. package/dist/types.backup/router/segment-resolution/streamed-handler-telemetry.d.ts +0 -16
  313. package/dist/types.backup/router/segment-resolution/view-transition-default.d.ts +0 -28
  314. package/dist/types.backup/router/segment-resolution.d.ts +0 -3
  315. package/dist/types.backup/router/segment-wrappers.d.ts +0 -53
  316. package/dist/types.backup/router/state-cookie-name.d.ts +0 -1
  317. package/dist/types.backup/router/substitute-pattern-params.d.ts +0 -23
  318. package/dist/types.backup/router/telemetry-otel.d.ts +0 -113
  319. package/dist/types.backup/router/telemetry.d.ts +0 -215
  320. package/dist/types.backup/router/timeout.d.ts +0 -68
  321. package/dist/types.backup/router/tracing.d.ts +0 -125
  322. package/dist/types.backup/router/trie-matching.d.ts +0 -32
  323. package/dist/types.backup/router/types.d.ts +0 -98
  324. package/dist/types.backup/router/url-params.d.ts +0 -26
  325. package/dist/types.backup/router.d.ts +0 -7
  326. package/dist/types.backup/rsc/capture-queue.d.ts +0 -6
  327. package/dist/types.backup/rsc/full-payload.d.ts +0 -22
  328. package/dist/types.backup/rsc/handler-context.d.ts +0 -31
  329. package/dist/types.backup/rsc/handler.d.ts +0 -9
  330. package/dist/types.backup/rsc/helpers.d.ts +0 -213
  331. package/dist/types.backup/rsc/index.d.ts +0 -17
  332. package/dist/types.backup/rsc/json-route-result.d.ts +0 -20
  333. package/dist/types.backup/rsc/loader-fetch.d.ts +0 -14
  334. package/dist/types.backup/rsc/manifest-init.d.ts +0 -18
  335. package/dist/types.backup/rsc/nonce.d.ts +0 -28
  336. package/dist/types.backup/rsc/origin-guard.d.ts +0 -50
  337. package/dist/types.backup/rsc/progressive-enhancement.d.ts +0 -19
  338. package/dist/types.backup/rsc/redirect-guard.d.ts +0 -35
  339. package/dist/types.backup/rsc/response-cache-serve.d.ts +0 -46
  340. package/dist/types.backup/rsc/response-error.d.ts +0 -19
  341. package/dist/types.backup/rsc/response-route-handler.d.ts +0 -29
  342. package/dist/types.backup/rsc/rsc-rendering.d.ts +0 -23
  343. package/dist/types.backup/rsc/runtime-warnings.d.ts +0 -22
  344. package/dist/types.backup/rsc/server-action.d.ts +0 -68
  345. package/dist/types.backup/rsc/shell-build-manifest.d.ts +0 -84
  346. package/dist/types.backup/rsc/shell-capture-constants.d.ts +0 -27
  347. package/dist/types.backup/rsc/shell-capture.d.ts +0 -374
  348. package/dist/types.backup/rsc/shell-serve.d.ts +0 -136
  349. package/dist/types.backup/rsc/ssr-setup.d.ts +0 -48
  350. package/dist/types.backup/rsc/transition-gate.d.ts +0 -27
  351. package/dist/types.backup/rsc/types.d.ts +0 -290
  352. package/dist/types.backup/runtime-env.d.ts +0 -1
  353. package/dist/types.backup/search-params.d.ts +0 -125
  354. package/dist/types.backup/segment-content-promise.d.ts +0 -13
  355. package/dist/types.backup/segment-fragments.d.ts +0 -56
  356. package/dist/types.backup/segment-loader-promise.d.ts +0 -22
  357. package/dist/types.backup/segment-system.d.ts +0 -84
  358. package/dist/types.backup/serialize.d.ts +0 -164
  359. package/dist/types.backup/server/context.d.ts +0 -494
  360. package/dist/types.backup/server/cookie-parse.d.ts +0 -10
  361. package/dist/types.backup/server/cookie-store.d.ts +0 -107
  362. package/dist/types.backup/server/fetchable-loader-store.d.ts +0 -20
  363. package/dist/types.backup/server/handle-store.d.ts +0 -100
  364. package/dist/types.backup/server/loader-registry.d.ts +0 -32
  365. package/dist/types.backup/server/request-context.d.ts +0 -596
  366. package/dist/types.backup/server/root-layout.d.ts +0 -3
  367. package/dist/types.backup/server.d.ts +0 -15
  368. package/dist/types.backup/ssr/index.d.ts +0 -233
  369. package/dist/types.backup/ssr/inject-rsc-eager.d.ts +0 -3
  370. package/dist/types.backup/ssr/preinit-client-references.d.ts +0 -71
  371. package/dist/types.backup/ssr/ssr-root.d.ts +0 -69
  372. package/dist/types.backup/static-handler.d.ts +0 -57
  373. package/dist/types.backup/testing/cache-status.d.ts +0 -63
  374. package/dist/types.backup/testing/collect-handle.d.ts +0 -20
  375. package/dist/types.backup/testing/dispatch.d.ts +0 -123
  376. package/dist/types.backup/testing/dom.entry.d.ts +0 -15
  377. package/dist/types.backup/testing/e2e/fixture.d.ts +0 -37
  378. package/dist/types.backup/testing/e2e/index.d.ts +0 -30
  379. package/dist/types.backup/testing/e2e/matchers.d.ts +0 -17
  380. package/dist/types.backup/testing/e2e/page-helpers.d.ts +0 -62
  381. package/dist/types.backup/testing/e2e/parity.d.ts +0 -111
  382. package/dist/types.backup/testing/e2e/server.d.ts +0 -35
  383. package/dist/types.backup/testing/flight-matchers.d.ts +0 -55
  384. package/dist/types.backup/testing/flight-normalize.d.ts +0 -1
  385. package/dist/types.backup/testing/flight-tree.d.ts +0 -192
  386. package/dist/types.backup/testing/flight.d.ts +0 -115
  387. package/dist/types.backup/testing/flight.entry.d.ts +0 -27
  388. package/dist/types.backup/testing/generated-routes.d.ts +0 -66
  389. package/dist/types.backup/testing/index.d.ts +0 -52
  390. package/dist/types.backup/testing/internal/context.d.ts +0 -225
  391. package/dist/types.backup/testing/internal/flight-client-globals.d.ts +0 -1
  392. package/dist/types.backup/testing/internal/seed-vars.d.ts +0 -30
  393. package/dist/types.backup/testing/render-handler.d.ts +0 -160
  394. package/dist/types.backup/testing/render-route.d.ts +0 -246
  395. package/dist/types.backup/testing/run-loader.d.ts +0 -186
  396. package/dist/types.backup/testing/run-middleware.d.ts +0 -132
  397. package/dist/types.backup/testing/run-transition-when.d.ts +0 -77
  398. package/dist/types.backup/testing/vitest-stubs/cloudflare-email.d.ts +0 -6
  399. package/dist/types.backup/testing/vitest-stubs/cloudflare-workers.d.ts +0 -13
  400. package/dist/types.backup/testing/vitest-stubs/plugin-rsc.d.ts +0 -7
  401. package/dist/types.backup/testing/vitest-stubs/version.d.ts +0 -1
  402. package/dist/types.backup/testing/vitest.d.ts +0 -205
  403. package/dist/types.backup/theme/ThemeProvider.d.ts +0 -13
  404. package/dist/types.backup/theme/ThemeScript.d.ts +0 -45
  405. package/dist/types.backup/theme/constants.d.ts +0 -39
  406. package/dist/types.backup/theme/index.d.ts +0 -29
  407. package/dist/types.backup/theme/theme-context.d.ts +0 -21
  408. package/dist/types.backup/theme/theme-script.d.ts +0 -26
  409. package/dist/types.backup/theme/types.d.ts +0 -162
  410. package/dist/types.backup/theme/use-theme.d.ts +0 -8
  411. package/dist/types.backup/types/boundaries.d.ts +0 -93
  412. package/dist/types.backup/types/cache-types.d.ts +0 -191
  413. package/dist/types.backup/types/error-types.d.ts +0 -114
  414. package/dist/types.backup/types/global-namespace.d.ts +0 -90
  415. package/dist/types.backup/types/handler-context.d.ts +0 -658
  416. package/dist/types.backup/types/index.d.ts +0 -11
  417. package/dist/types.backup/types/loader-types.d.ts +0 -182
  418. package/dist/types.backup/types/request-scope.d.ts +0 -93
  419. package/dist/types.backup/types/route-config.d.ts +0 -105
  420. package/dist/types.backup/types/route-entry.d.ts +0 -95
  421. package/dist/types.backup/types/segments.d.ts +0 -234
  422. package/dist/types.backup/types.d.ts +0 -1
  423. package/dist/types.backup/urls/include-helper.d.ts +0 -17
  424. package/dist/types.backup/urls/include-provider.d.ts +0 -27
  425. package/dist/types.backup/urls/index.d.ts +0 -6
  426. package/dist/types.backup/urls/path-helper-types.d.ts +0 -197
  427. package/dist/types.backup/urls/path-helper.d.ts +0 -12
  428. package/dist/types.backup/urls/pattern-types.d.ts +0 -166
  429. package/dist/types.backup/urls/response-types.d.ts +0 -67
  430. package/dist/types.backup/urls/type-extraction.d.ts +0 -157
  431. package/dist/types.backup/urls/urls-function.d.ts +0 -24
  432. package/dist/types.backup/urls.d.ts +0 -1
  433. package/dist/types.backup/use-loader.d.ts +0 -150
  434. package/dist/types.backup/vercel/index.d.ts +0 -10
  435. package/dist/types.backup/vercel/tracing.d.ts +0 -70
  436. package/dist/types.backup/vite/debug.d.ts +0 -80
  437. package/dist/types.backup/vite/discovery/bundle-postprocess.d.ts +0 -12
  438. package/dist/types.backup/vite/discovery/dev-prerender-cache.d.ts +0 -65
  439. package/dist/types.backup/vite/discovery/discover-routers.d.ts +0 -17
  440. package/dist/types.backup/vite/discovery/discovery-errors.d.ts +0 -113
  441. package/dist/types.backup/vite/discovery/gate-state.d.ts +0 -79
  442. package/dist/types.backup/vite/discovery/prerender-collection.d.ts +0 -24
  443. package/dist/types.backup/vite/discovery/route-types-writer.d.ts +0 -32
  444. package/dist/types.backup/vite/discovery/self-gen-tracking.d.ts +0 -22
  445. package/dist/types.backup/vite/discovery/shell-prerender-phase.d.ts +0 -40
  446. package/dist/types.backup/vite/discovery/state.d.ts +0 -162
  447. package/dist/types.backup/vite/discovery/virtual-module-codegen.d.ts +0 -15
  448. package/dist/types.backup/vite/index.d.ts +0 -11
  449. package/dist/types.backup/vite/inject-client-debug.d.ts +0 -56
  450. package/dist/types.backup/vite/plugin-types.d.ts +0 -298
  451. package/dist/types.backup/vite/plugins/cjs-to-esm.d.ts +0 -6
  452. package/dist/types.backup/vite/plugins/client-ref-dedup.d.ts +0 -40
  453. package/dist/types.backup/vite/plugins/client-ref-hashing.d.ts +0 -35
  454. package/dist/types.backup/vite/plugins/cloudflare-protocol-stub.d.ts +0 -64
  455. package/dist/types.backup/vite/plugins/expose-action-id.d.ts +0 -18
  456. package/dist/types.backup/vite/plugins/expose-id-utils.d.ts +0 -37
  457. package/dist/types.backup/vite/plugins/expose-ids/export-analysis.d.ts +0 -19
  458. package/dist/types.backup/vite/plugins/expose-ids/handler-transform.d.ts +0 -10
  459. package/dist/types.backup/vite/plugins/expose-ids/loader-transform.d.ts +0 -8
  460. package/dist/types.backup/vite/plugins/expose-ids/router-transform.d.ts +0 -13
  461. package/dist/types.backup/vite/plugins/expose-ids/types.d.ts +0 -29
  462. package/dist/types.backup/vite/plugins/expose-internal-ids.d.ts +0 -6
  463. package/dist/types.backup/vite/plugins/performance-tracks.d.ts +0 -25
  464. package/dist/types.backup/vite/plugins/refresh-cmd.d.ts +0 -20
  465. package/dist/types.backup/vite/plugins/use-cache-transform.d.ts +0 -20
  466. package/dist/types.backup/vite/plugins/vercel-output.d.ts +0 -85
  467. package/dist/types.backup/vite/plugins/version-injector.d.ts +0 -21
  468. package/dist/types.backup/vite/plugins/version-plugin.d.ts +0 -19
  469. package/dist/types.backup/vite/plugins/virtual-entries.d.ts +0 -36
  470. package/dist/types.backup/vite/plugins/virtual-stub-plugin.d.ts +0 -7
  471. package/dist/types.backup/vite/rango.d.ts +0 -29
  472. package/dist/types.backup/vite/router-discovery.d.ts +0 -23
  473. package/dist/types.backup/vite/utils/ast-handler-extract.d.ts +0 -64
  474. package/dist/types.backup/vite/utils/banner.d.ts +0 -2
  475. package/dist/types.backup/vite/utils/bundle-analysis.d.ts +0 -28
  476. package/dist/types.backup/vite/utils/client-chunks.d.ts +0 -55
  477. package/dist/types.backup/vite/utils/directive-prologue.d.ts +0 -16
  478. package/dist/types.backup/vite/utils/forward-user-plugins.d.ts +0 -37
  479. package/dist/types.backup/vite/utils/manifest-utils.d.ts +0 -7
  480. package/dist/types.backup/vite/utils/package-resolution.d.ts +0 -6
  481. package/dist/types.backup/vite/utils/prerender-utils.d.ts +0 -32
  482. package/dist/types.backup/vite/utils/shared-utils.d.ts +0 -55
@@ -1,26 +0,0 @@
1
- import type { UrlPatterns } from "../urls.js";
2
- import type { AllUseItems } from "../route-types.js";
3
- import type { RouteEntry } from "../types";
4
- export interface LazyEvalDeps<TEnv = any> {
5
- routesEntries: RouteEntry<TEnv>[];
6
- mergedRouteMap: Record<string, string>;
7
- nextMountIndex: () => number;
8
- getPrecomputedByPrefix: () => Map<string, Record<string, string>> | null;
9
- routerId?: string;
10
- }
11
- export declare function findLazyIncludes<TEnv = any>(items: AllUseItems[]): Array<{
12
- prefix: string;
13
- patterns: UrlPatterns<TEnv>;
14
- context: {
15
- urlPrefix: string;
16
- namePrefix: string | undefined;
17
- parent: unknown;
18
- rootScoped?: boolean;
19
- };
20
- }>;
21
- /**
22
- * Evaluate a lazy entry's patterns and populate its routes
23
- * This runs the lazy patterns handler and updates the entry in-place
24
- * Also detects nested lazy includes and registers them as new entries
25
- */
26
- export declare function evaluateLazyEntry<TEnv = any>(entry: RouteEntry<TEnv>, deps: LazyEvalDeps<TEnv>): void | Promise<void>;
@@ -1,63 +0,0 @@
1
- /**
2
- * Router Loader Resolution
3
- *
4
- * Loader execution, memoization, and error handling utilities.
5
- */
6
- import type { ReactNode } from "react";
7
- import type { EntryData } from "../server/context";
8
- import type { HandlerContext, LoaderDataResult, ErrorBoundaryHandler, ErrorInfo } from "../types";
9
- /**
10
- * Internal callback signature for loader error notifications.
11
- * This is a simplified callback for internal use in wrapLoaderWithErrorHandling.
12
- * The caller (wrapLoaderPromise in router.ts) bridges this to the full OnErrorCallback.
13
- */
14
- export type LoaderErrorCallback = (error: unknown, context: {
15
- segmentId: string;
16
- loaderName: string;
17
- handledByBoundary: boolean;
18
- }) => void;
19
- /**
20
- * Wrap a loader promise with error handling for deferred client-side resolution.
21
- * Catches errors and converts them to LoaderDataResult objects that include
22
- * error info and pre-rendered fallback UI when an error boundary is available.
23
- *
24
- * @param onError - Optional callback invoked when loader errors occur.
25
- * This has a simplified signature for internal use - the caller (typically
26
- * wrapLoaderPromise in router.ts) is responsible for bridging to the full
27
- * OnErrorCallback with complete request context (request, url, env, etc.).
28
- */
29
- export declare function wrapLoaderWithErrorHandling<T>(promise: Promise<T>, entry: EntryData, segmentId: string, pathname: string, findNearestErrorBoundary: (entry: EntryData | null) => ReactNode | ErrorBoundaryHandler | null, createErrorInfo: (error: unknown, segmentId: string, segmentType: ErrorInfo["segmentType"]) => ErrorInfo, onError?: LoaderErrorCallback): Promise<LoaderDataResult<T>>;
30
- /**
31
- * Set up the use() method on handler context to access loaders and handles.
32
- *
33
- * For loaders: Lazily runs loaders, memoizes results per request.
34
- * For handles: Returns a push function bound to the current segment.
35
- *
36
- * Includes cycle detection: tracks dependency edges between loaders and
37
- * throws on circular dependencies to prevent deadlocks.
38
- */
39
- export declare function setupLoaderAccess<TEnv>(ctx: HandlerContext<any, TEnv>, loaderPromises: Map<string, Promise<any>>): void;
40
- /**
41
- * Set up ctx.use() for pre-rendering (build-time).
42
- * Handles push to HandleStore; loaders throw with a clear error.
43
- */
44
- export declare function setupBuildUse<TEnv>(ctx: HandlerContext<any, TEnv>): void;
45
- /**
46
- * Set up ctx.use() for proactive caching (silent mode).
47
- * Handles are silently ignored (no push to HandleStore).
48
- * Loaders work normally but with fresh memoization and cycle detection.
49
- *
50
- * This prevents duplicate handle data (breadcrumbs, meta) from being
51
- * pushed to the response stream during background proactive caching.
52
- */
53
- export declare function setupLoaderAccessSilent<TEnv>(ctx: HandlerContext<any, TEnv>, loaderPromises: Map<string, Promise<any>>): void;
54
- /**
55
- * Conditional execution based on revalidation
56
- * Evaluates revalidation logic lazily, then executes appropriate callback
57
- *
58
- * @param shouldRevalidate - Async function that determines if revalidation is needed
59
- * @param onRevalidate - Callback executed if revalidation returns true
60
- * @param onSkip - Callback executed if revalidation returns false
61
- * @returns Result from either onRevalidate or onSkip
62
- */
63
- export declare function revalidate<T>(shouldRevalidate: () => Promise<boolean>, onRevalidate: () => Promise<T>, onSkip: () => T): Promise<T>;
@@ -1,41 +0,0 @@
1
- export interface RevalidationTraceEntry {
2
- segmentId: string;
3
- segmentType: string;
4
- belongsToRoute: boolean;
5
- source: "segment-resolution" | "cache-hit" | "loader" | "parallel" | "orphan-layout" | "route-handler" | "layout-handler" | "intercept-loader";
6
- defaultShouldRevalidate: boolean;
7
- finalShouldRevalidate: boolean;
8
- reason: string;
9
- customRevalidators?: number;
10
- }
11
- export interface RevalidationTraceMeta {
12
- method: string;
13
- prevUrl: string;
14
- nextUrl: string;
15
- routeKey: string;
16
- isAction: boolean;
17
- stale?: boolean;
18
- }
19
- export interface RevalidationTrace {
20
- meta: RevalidationTraceMeta;
21
- entries: RevalidationTraceEntry[];
22
- }
23
- interface RouterLogOptions {
24
- request: Request;
25
- transaction: string;
26
- }
27
- interface LogDetails {
28
- [key: string]: unknown;
29
- }
30
- export declare function getOrCreateRequestId(request: Request): string;
31
- export declare function runWithRouterLogContext<T>(options: RouterLogOptions, fn: () => T): T;
32
- export declare function withRouterLogScope<T>(label: string, fn: () => Promise<T>): Promise<T>;
33
- export declare function withRouterLogScope<T>(label: string, fn: () => T): T;
34
- export declare function isRouterDebugEnabled(): boolean;
35
- export declare function debugLog(scope: string, message: string, details?: LogDetails): void;
36
- export declare function debugWarn(scope: string, message: string, details?: LogDetails): void;
37
- export declare function isTraceActive(): boolean;
38
- export declare function startRevalidationTrace(meta: RevalidationTraceMeta): void;
39
- export declare function pushRevalidationTraceEntry(entry: RevalidationTraceEntry): void;
40
- export declare function flushRevalidationTrace(): RevalidationTrace | null;
41
- export {};
@@ -1,8 +0,0 @@
1
- import { type EntryData, type MetricsStore } from "../server/context";
2
- import type { RouteEntry } from "../types";
3
- /**
4
- * Clear the module-level manifest cache.
5
- * Called on HMR to ensure stale handler references are discarded.
6
- */
7
- export declare function clearManifestCache(): void;
8
- export declare function loadManifest(entry: RouteEntry<any>, routeKey: string, path: string, metricsStore?: MetricsStore, isSSR?: boolean): Promise<EntryData>;
@@ -1,19 +0,0 @@
1
- import type { ErrorBoundaryHandler, ErrorInfo, MatchResult } from "../types";
2
- import type { ReactNode } from "react";
3
- import type { MatchContext } from "./match-context.js";
4
- import type { MatchApiDeps, ActionContext } from "./types.js";
5
- /**
6
- * Create match context for full requests (document/SSR).
7
- */
8
- export declare function createMatchContextForFull<TEnv>(request: Request, env: TEnv, deps: MatchApiDeps<TEnv>, findInterceptForRoute: MatchApiDeps<TEnv>["findInterceptForRoute"]): Promise<MatchContext<TEnv> | {
9
- type: "redirect";
10
- redirectUrl: string;
11
- }>;
12
- /**
13
- * Create match context for partial requests (navigation/actions).
14
- */
15
- export declare function createMatchContextForPartial<TEnv>(request: Request, env: TEnv, deps: MatchApiDeps<TEnv>, findInterceptForRoute: MatchApiDeps<TEnv>["findInterceptForRoute"], actionContext?: ActionContext): Promise<MatchContext<TEnv> | null>;
16
- /**
17
- * Match an error to the nearest error boundary and return error segments.
18
- */
19
- export declare function matchError<TEnv>(request: Request, _context: TEnv, error: unknown, deps: MatchApiDeps<TEnv>, defaultErrorBoundary: ReactNode | ErrorBoundaryHandler | undefined, segmentType?: ErrorInfo["segmentType"]): Promise<MatchResult | null>;
@@ -1,184 +0,0 @@
1
- /**
2
- * Match Context for Router Pipeline
3
- *
4
- * Encapsulates all state needed by the match pipeline middleware.
5
- * Created once at the start of match()/matchPartial() and passed through the pipeline.
6
- *
7
- * DATA FLOW ARCHITECTURE
8
- * ======================
9
- *
10
- * The router uses two complementary data structures:
11
- *
12
- * MatchContext (ctx) - Immutable request state
13
- * MatchPipelineState (state) - Mutable pipeline state
14
- *
15
- *
16
- * Request
17
- * |
18
- * v
19
- * +-------------------+
20
- * | Create Context | ctx = immutable snapshot of request
21
- * +-------------------+
22
- * |
23
- * v
24
- * +-------------------+
25
- * | Create State | state = mutable accumulator
26
- * +-------------------+
27
- * |
28
- * +---> [Pipeline Middleware]
29
- * | |
30
- * | ctx: read-only
31
- * | state: read/write
32
- * | |
33
- * +<----------+
34
- * |
35
- * v
36
- * +-------------------+
37
- * | Build Result | Merge ctx + state into MatchResult
38
- * +-------------------+
39
- *
40
- *
41
- * MATCHCONTEXT FIELDS
42
- * ===================
43
- *
44
- * Request Info:
45
- * - request, url, pathname: The incoming HTTP request
46
- *
47
- * Environment:
48
- * - env: Server environment (Cloudflare bindings, etc.)
49
- *
50
- * Client State (from RSC request headers):
51
- * - clientSegmentIds: Segments the client currently has
52
- * - clientSegmentSet: Set version for O(1) lookup
53
- * - stale: Whether client considers its cache stale
54
- *
55
- * Navigation State:
56
- * - prevUrl, prevParams, prevMatch: Previous navigation for comparison
57
- *
58
- * Current Match:
59
- * - matched: Route match result (params, route key)
60
- * - manifestEntry: Resolved manifest data
61
- * - entries: All route entries (layouts, loaders, etc.)
62
- * - routeKey, localRouteName: Route identifiers
63
- *
64
- * Handler Context:
65
- * - handlerContext: Context passed to loaders
66
- * - loaderPromises: Memoized loader promises
67
- *
68
- * Intercepts:
69
- * - interceptResult: Detected intercept (if soft navigation)
70
- * - interceptSelectorContext: Context for intercept matching
71
- *
72
- * Cache:
73
- * - cacheScope: Cache configuration and methods
74
- * - isIntercept: Whether this is an intercept request
75
- *
76
- * Flags:
77
- * - isAction: POST/mutation request
78
- * - isFullMatch: Document request vs navigation
79
- *
80
- *
81
- * MATCHPIPELINESTATE FIELDS
82
- * =========================
83
- *
84
- * State flags (set by middleware, read by others):
85
- * - cacheHit: Cache lookup succeeded
86
- * - shouldRevalidate: SWR revalidation needed
87
- *
88
- * Segment accumulation:
89
- * - segments: Resolved segments from pipeline
90
- * - matchedIds: All segment IDs in match order
91
- * - cachedSegments: Segments from cache (if hit)
92
- *
93
- * Intercept data:
94
- * - interceptSegments: Segments for modal slots
95
- * - slots: Named slot data for client
96
- *
97
- *
98
- * IMMUTABILITY CONTRACT
99
- * =====================
100
- *
101
- * MatchContext is treated as immutable after creation.
102
- * Middleware should NEVER modify ctx properties.
103
- *
104
- * MatchPipelineState is explicitly mutable.
105
- * Middleware communicate by setting state flags.
106
- *
107
- * This separation ensures:
108
- * - Request data is consistent across all middleware
109
- * - Pipeline state changes are explicit and trackable
110
- * - No hidden side effects in request handling
111
- */
112
- import type { CacheScope } from "../cache/cache-scope.js";
113
- import type { EntryData, InterceptSelectorContext, MetricsStore } from "../server/context.js";
114
- import type { HandlerContext, ResolvedSegment } from "../types.js";
115
- import type { RouteMatchResult } from "./pattern-matching.js";
116
- import type { InterceptResult } from "./router-context.js";
117
- /**
118
- * Action context passed to matchPartial
119
- */
120
- export interface ActionContext {
121
- actionId?: string;
122
- actionUrl?: URL;
123
- actionResult?: any;
124
- formData?: FormData;
125
- }
126
- /**
127
- * Match context containing all state for the match pipeline
128
- */
129
- export interface MatchContext<TEnv = any> {
130
- request: Request;
131
- url: URL;
132
- pathname: string;
133
- env: TEnv;
134
- clientSegmentIds: string[];
135
- clientSegmentSet: Set<string>;
136
- stale: boolean;
137
- prevUrl: URL;
138
- prevParams: Record<string, string>;
139
- prevMatch: RouteMatchResult | null;
140
- matched: RouteMatchResult;
141
- manifestEntry: EntryData;
142
- entries: EntryData[];
143
- routeKey: string;
144
- localRouteName: string;
145
- handlerContext: HandlerContext<any, TEnv>;
146
- loaderPromises: Map<string, Promise<any>>;
147
- routeMap: Record<string, string>;
148
- metricsStore: MetricsStore | undefined;
149
- Store: any;
150
- interceptContextMatch: RouteMatchResult | null;
151
- interceptSelectorContext: InterceptSelectorContext;
152
- isSameRouteNavigation: boolean;
153
- interceptResult: InterceptResult | null;
154
- cacheScope: CacheScope | null;
155
- isIntercept: boolean;
156
- actionContext?: ActionContext;
157
- isAction: boolean;
158
- routeMiddleware: Array<{
159
- handler: any;
160
- params: Record<string, string>;
161
- }>;
162
- isFullMatch: boolean;
163
- }
164
- /**
165
- * Mutable state that flows through the pipeline
166
- */
167
- export interface MatchPipelineState {
168
- cacheHit: boolean;
169
- cachedSegments?: ResolvedSegment[];
170
- cachedMatchedIds?: string[];
171
- shouldRevalidate?: boolean;
172
- cacheSource?: "runtime" | "prerender";
173
- segments: ResolvedSegment[];
174
- matchedIds: string[];
175
- interceptSegments: ResolvedSegment[];
176
- slots: Record<string, {
177
- active: boolean;
178
- segments: ResolvedSegment[];
179
- }>;
180
- }
181
- /**
182
- * Create initial pipeline state
183
- */
184
- export declare function createPipelineState(): MatchPipelineState;
@@ -1,49 +0,0 @@
1
- import type { ReactNode } from "react";
2
- import type { ErrorInfo, ErrorPhase, MatchResult } from "../types";
3
- import type { EntryData, InterceptEntry, InterceptSelectorContext } from "../server/context";
4
- import type { MatchApiDeps } from "./types.js";
5
- import type { RouterContext } from "./router-context.js";
6
- import { type ActionContext } from "./match-context.js";
7
- import type { ErrorBoundaryHandler } from "../types";
8
- import type { MiddlewareFn } from "./middleware.js";
9
- import { type TelemetrySink } from "./telemetry.js";
10
- export interface MatchHandlerDeps<TEnv = any> {
11
- buildRouterContext: () => RouterContext<TEnv>;
12
- callOnError: (error: unknown, phase: ErrorPhase, context: any) => void;
13
- matchApiDeps: MatchApiDeps<TEnv>;
14
- defaultErrorBoundary: ReactNode | ErrorBoundaryHandler | undefined;
15
- findMatch: (pathname: string, ms?: any) => any;
16
- findInterceptForRoute: (routeKey: string, parentEntry: EntryData | null, selectorContext: InterceptSelectorContext | null, isAction: boolean) => {
17
- intercept: InterceptEntry;
18
- entry: EntryData;
19
- } | null;
20
- telemetry?: TelemetrySink;
21
- /**
22
- * DEVELOPMENT/TEST ONLY gate for the X-Rango-Cache debug header. When true,
23
- * match/matchPartial stash a coarse route-level cache signal on the request
24
- * context for the response-finalization path to emit. Default off.
25
- */
26
- cacheSignalEnabled?: boolean;
27
- }
28
- export interface MatchHandlers<TEnv = any> {
29
- match: (request: Request, env: TEnv) => Promise<MatchResult>;
30
- matchPartial: (request: Request, context: TEnv, actionContext?: ActionContext) => Promise<MatchResult | null>;
31
- matchError: (request: Request, _context: TEnv, error: unknown, segmentType?: ErrorInfo["segmentType"]) => Promise<MatchResult | null>;
32
- previewMatch: (request: Request, _context: TEnv) => Promise<{
33
- routeMiddleware?: Array<{
34
- handler: MiddlewareFn;
35
- params: Record<string, string>;
36
- }>;
37
- responseType?: string;
38
- handler?: Function;
39
- params?: Record<string, string>;
40
- negotiated?: boolean;
41
- manifestEntry?: EntryData;
42
- } | null>;
43
- }
44
- /**
45
- * Create match handler functions bound to router closure state.
46
- * These are the main request-handling entry points for SSR, navigation,
47
- * error recovery, and preview matching.
48
- */
49
- export declare function createMatchHandlers<TEnv = any>(deps: MatchHandlerDeps<TEnv>): MatchHandlers<TEnv>;
@@ -1,113 +0,0 @@
1
- /**
2
- * Background Revalidation Middleware
3
- *
4
- * Implements SWR (stale-while-revalidate) pattern.
5
- * Triggers background refresh when cached data is stale.
6
- *
7
- * FLOW DIAGRAM
8
- * ============
9
- *
10
- * source (from cache-store)
11
- * |
12
- * v
13
- * +---------------------------+
14
- * | yield* source | Pure pass-through
15
- * | (no modifications) |
16
- * +---------------------------+
17
- * |
18
- * v
19
- * +---------------------+
20
- * | Should revalidate? |
21
- * | - shouldRevalidate |──no───> return
22
- * | - cacheHit |
23
- * | - cacheScope |
24
- * +---------------------+
25
- * | yes
26
- * v
27
- * +---------------------------+
28
- * | requestCtx.waitUntil() | Non-blocking background task
29
- * +---------------------------+
30
- * |
31
- * v (async, doesn't block response)
32
- * +---------------------------+
33
- * | Create fresh context | Fresh handleStore, handlerContext,
34
- * | (full isolation) | and loaderPromises map
35
- * +---------------------------+
36
- * |
37
- * v
38
- * +---------------------------+
39
- * | resolveAllSegments() | Fresh resolution (no revalidation)
40
- * | + resolveIntercepts() | Ensures complete components
41
- * +---------------------------+
42
- * |
43
- * v
44
- * +---------------------------+
45
- * | cacheScope.cacheRoute() | Update cache with fresh data
46
- * +---------------------------+
47
- *
48
- *
49
- * SWR PATTERN
50
- * ===========
51
- *
52
- * Stale-While-Revalidate provides fast responses with eventual consistency:
53
- *
54
- * Timeline:
55
- * ---------
56
- * T0: Request arrives
57
- * T1: Cache lookup finds stale entry
58
- * T2: Return stale data immediately (fast!)
59
- * T3: Response sent to client
60
- * T4: waitUntil() triggers background revalidation
61
- * T5: Fresh data resolved
62
- * T6: Cache updated with fresh data
63
- * T7: Next request gets fresh data from cache
64
- *
65
- * Benefits:
66
- * - Fast initial response (cached data)
67
- * - Eventually consistent (background refresh)
68
- * - No blocking on revalidation
69
- *
70
- *
71
- * WHEN IS CACHE STALE?
72
- * ====================
73
- *
74
- * The cache-lookup middleware sets state.shouldRevalidate based on:
75
- * - TTL (time-to-live) expiration
76
- * - Cache entry metadata
77
- * - Configured staleness rules
78
- *
79
- * This middleware only acts on the flag, it doesn't determine staleness.
80
- *
81
- *
82
- * ISOLATION FROM RESPONSE
83
- * =======================
84
- *
85
- * Background revalidation creates fully isolated context:
86
- * - Fresh handleStore (prevents polluting the response stream)
87
- * - Fresh handlerContext + loaderPromises (prevents reusing memoized
88
- * loader results from the foreground pass)
89
- * - handleStore is saved/restored in try/finally
90
- *
91
- * This matches the proactive caching pattern in cache-store.ts.
92
- *
93
- *
94
- * FRESH RESOLUTION (NO REVALIDATION)
95
- * ===================================
96
- *
97
- * Both full and partial requests use resolveAllSegments() (without
98
- * revalidation logic) to ensure all segments have complete components.
99
- * Using revalidation-aware resolution would produce null components
100
- * for skipped segments, which would corrupt the cache entry.
101
- */
102
- import type { ResolvedSegment } from "../../types.js";
103
- import type { MatchContext, MatchPipelineState } from "../match-context.js";
104
- import type { GeneratorMiddleware } from "./cache-lookup.js";
105
- /**
106
- * Creates background revalidation middleware
107
- *
108
- * If cache was stale (state.shouldRevalidate === true):
109
- * - Triggers background resolution via waitUntil
110
- * - Observes segments but doesn't modify them
111
- * - Updates cache with fresh segments after revalidation completes
112
- */
113
- export declare function withBackgroundRevalidation<TEnv>(ctx: MatchContext<TEnv>, state: MatchPipelineState): GeneratorMiddleware<ResolvedSegment>;
@@ -1,113 +0,0 @@
1
- /**
2
- * Cache Lookup Middleware
3
- *
4
- * First middleware in the pipeline. Checks cache before segment resolution.
5
- *
6
- * FLOW DIAGRAM
7
- * ============
8
- *
9
- * source (empty)
10
- * |
11
- * v
12
- * +---------------------+
13
- * | Is action request? |──yes──> yield* source (pass through)
14
- * +---------------------+
15
- * | no
16
- * v
17
- * +---------------------+
18
- * | Cache enabled? |──no───> yield* source (pass through)
19
- * +---------------------+
20
- * | yes
21
- * v
22
- * +---------------------+
23
- * | Lookup cache |
24
- * | (pathname, params) |
25
- * +---------------------+
26
- * |
27
- * +-----+-----+
28
- * | |
29
- * miss hit
30
- * | |
31
- * v v
32
- * yield* Set state.cacheHit = true
33
- * source Set state.shouldRevalidate
34
- * | |
35
- * | v
36
- * | +---------------------------+
37
- * | | For each cached segment: |
38
- * | | - Apply revalidation |
39
- * | | - Set component = null |
40
- * | | if client has it |
41
- * | +---------------------------+
42
- * | |
43
- * | v
44
- * | +---------------------------+
45
- * | | Resolve fresh loaders | <-- Loaders are NEVER cached
46
- * | | (always fresh data) |
47
- * | +---------------------------+
48
- * | |
49
- * | v
50
- * | yield cached segments
51
- * | yield fresh loader segments
52
- * | |
53
- * +-----------+
54
- * |
55
- * v
56
- * next middleware
57
- *
58
- *
59
- * CACHE BEHAVIOR
60
- * ==============
61
- *
62
- * Cache HIT:
63
- * - state.cacheHit = true signals downstream middleware to skip
64
- * - Cached segments have their components nullified if client already has them
65
- * - Loaders are always re-resolved for fresh data
66
- * - state.shouldRevalidate triggers background SWR if cache was stale
67
- *
68
- * Cache MISS:
69
- * - Passes through to segment-resolution middleware
70
- * - No segments yielded from this middleware
71
- *
72
- * Loaders:
73
- * - NEVER cached in the segment cache
74
- * - Always resolved fresh on every request
75
- * - Ensures data freshness even with cached UI components
76
- * - Segment cache staleness does NOT propagate to loader revalidation;
77
- * loaders use their own revalidation rules (actionId, user-defined)
78
- *
79
- *
80
- * REVALIDATION RULES
81
- * ==================
82
- *
83
- * Each cached segment is evaluated against its revalidation rules:
84
- *
85
- * 1. No rules defined -> use default (skip if client has segment)
86
- * 2. Rules return false -> skip re-render (nullify component)
87
- * 3. Rules return true -> re-render (keep component)
88
- *
89
- * Revalidation context includes:
90
- * - Previous/next URL and params
91
- * - Request object
92
- * - Action context (if POST)
93
- */
94
- import type { ResolvedSegment } from "../../types.js";
95
- import type { MatchContext, MatchPipelineState } from "../match-context.js";
96
- /**
97
- * Async generator middleware type
98
- */
99
- export type GeneratorMiddleware<T> = (source: AsyncGenerator<T>) => AsyncGenerator<T>;
100
- /**
101
- * Creates cache lookup middleware
102
- *
103
- * Checks cache for segments. If cache hit:
104
- * - Applies revalidation to determine which segments need re-rendering
105
- * - Resolves loaders fresh (loaders are NOT cached by design)
106
- * - Sets state.cacheHit = true
107
- * - Sets state.shouldRevalidate if SWR needed
108
- * - Yields cached segments + fresh loader segments
109
- *
110
- * If cache miss:
111
- * - Passes through to next middleware
112
- */
113
- export declare function withCacheLookup<TEnv>(ctx: MatchContext<TEnv>, state: MatchPipelineState): GeneratorMiddleware<ResolvedSegment>;