@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,172 +0,0 @@
1
- /**
2
- * Type definitions for route system items
3
- * These are extracted separately to avoid circular dependencies
4
- * and to prevent bundling server-only code in client bundles
5
- */
6
- /**
7
- * Brand for UrlPatterns nominal typing (see pattern-types.ts). The route-item
8
- * types below are discriminated by their `type` literal, so they carry no brand.
9
- */
10
- export declare const UrlPatternsBrand: unique symbol;
11
- export type LayoutItem = {
12
- name: string;
13
- type: "layout";
14
- uses?: AllUseItems[];
15
- };
16
- /**
17
- * Phantom inference fields attached to wrapper items (layout/cache/transition)
18
- * so the urls() type extractor can read their child routes/responses. The fields
19
- * never exist at runtime.
20
- */
21
- type WithChildren<TBase, TChildRoutes extends Record<string, any> = Record<string, string>, TChildResponses extends Record<string, unknown> = Record<string, unknown>> = TBase & {
22
- readonly __childRoutes?: TChildRoutes;
23
- readonly __childResponses?: TChildResponses;
24
- };
25
- /**
26
- * Typed layout item that carries child routes as phantom type
27
- * Used for type inference in urls() API
28
- */
29
- export type TypedLayoutItem<TChildRoutes extends Record<string, any> = Record<string, string>, TChildResponses extends Record<string, unknown> = Record<string, unknown>> = WithChildren<LayoutItem, TChildRoutes, TChildResponses>;
30
- export type RouteItem = {
31
- name: string;
32
- type: "route";
33
- uses?: AllUseItems[];
34
- };
35
- /**
36
- * Typed route item that carries route name and pattern as phantom types
37
- * Used for type inference in urls() API
38
- */
39
- export type TypedRouteItem<TName extends string = string, TPattern extends string = string, TData = unknown, TSearch = {}> = RouteItem & {
40
- readonly __name?: TName;
41
- readonly __pattern?: TPattern;
42
- readonly __data?: TData;
43
- readonly __search?: TSearch;
44
- };
45
- export type ParallelItem = {
46
- name: string;
47
- type: "parallel";
48
- uses?: ParallelUseItem[];
49
- };
50
- export type InterceptItem = {
51
- name: string;
52
- type: "intercept";
53
- uses?: InterceptUseItem[];
54
- };
55
- export type LoaderItem = {
56
- name: string;
57
- type: "loader";
58
- uses?: LoaderUseItem[];
59
- };
60
- export type MiddlewareItem = {
61
- name: string;
62
- type: "middleware";
63
- uses?: AllUseItems[];
64
- };
65
- export type RevalidateItem = {
66
- name: string;
67
- type: "revalidate";
68
- uses?: AllUseItems[];
69
- };
70
- export type LoadingItem = {
71
- name: string;
72
- type: "loading";
73
- };
74
- export type ErrorBoundaryItem = {
75
- name: string;
76
- type: "errorBoundary";
77
- uses?: AllUseItems[];
78
- };
79
- export type NotFoundBoundaryItem = {
80
- name: string;
81
- type: "notFoundBoundary";
82
- uses?: AllUseItems[];
83
- };
84
- export type CacheItem = {
85
- name: string;
86
- type: "cache";
87
- uses?: AllUseItems[];
88
- };
89
- export type TransitionItem = {
90
- name: string;
91
- type: "transition";
92
- };
93
- /**
94
- * Typed transition item that carries child routes as phantom type
95
- * Used for type inference when transition() wraps child routes
96
- */
97
- export type TypedTransitionItem<TChildRoutes extends Record<string, any> = Record<string, string>, TChildResponses extends Record<string, unknown> = Record<string, unknown>> = WithChildren<TransitionItem, TChildRoutes, TChildResponses>;
98
- /**
99
- * Typed cache item that carries child routes as phantom type
100
- * Used for type inference in urls() API
101
- */
102
- export type TypedCacheItem<TChildRoutes extends Record<string, any> = Record<string, string>, TChildResponses extends Record<string, unknown> = Record<string, unknown>> = WithChildren<CacheItem, TChildRoutes, TChildResponses>;
103
- /**
104
- * Include item for URL pattern composition (used by urls() API)
105
- */
106
- export type IncludeItem = {
107
- type: "include";
108
- name: string;
109
- prefix: string;
110
- patterns: unknown;
111
- options?: {
112
- name?: string;
113
- lazy?: boolean;
114
- };
115
- /** Whether this include should be lazily evaluated on first request */
116
- lazy?: boolean;
117
- /** Captured context for deferred lazy evaluation */
118
- _lazyContext?: {
119
- urlPrefix: string;
120
- namePrefix: string | undefined;
121
- parent: unknown;
122
- /** Counter snapshot from pattern extraction for consistent shortCode indices */
123
- counters?: Record<string, number>;
124
- /** Cache profiles for DSL-time cache("profileName") resolution */
125
- cacheProfiles?: Record<string, import("./cache/profile-registry.js").CacheProfile>;
126
- /** Root scope flag for dot-local reverse resolution */
127
- rootScoped?: boolean;
128
- /**
129
- * Positional include scope token composed from the parent scope plus this
130
- * include's sibling index (`${parentScope}I${idx}`). Applied to direct-
131
- * descendant shortCodes during lazy evaluation so routes inside the
132
- * include cannot collide with siblings declared outside it.
133
- */
134
- includeScope?: string;
135
- };
136
- };
137
- /**
138
- * Typed include item that carries nested routes as phantom type
139
- * Used for type inference in urls() API
140
- */
141
- export type TypedIncludeItem<TRoutes extends Record<string, any> = Record<string, string>, TNamePrefix extends string = string, TUrlPrefix extends string = string, TResponses extends Record<string, unknown> = Record<string, unknown>> = IncludeItem & {
142
- readonly __routes?: TRoutes;
143
- readonly __namePrefix?: TNamePrefix;
144
- readonly __urlPrefix?: TUrlPrefix;
145
- readonly __responses?: TResponses;
146
- };
147
- /**
148
- * Union types for use() callbacks
149
- */
150
- export type AllUseItems = LayoutItem | RouteItem | MiddlewareItem | RevalidateItem | ParallelItem | InterceptItem | LoaderItem | LoadingItem | ErrorBoundaryItem | NotFoundBoundaryItem | CacheItem | TransitionItem | IncludeItem;
151
- /** Items that can be used inside a layout callback */
152
- export type LayoutUseItem = AllUseItems;
153
- export type RouteUseItem = LayoutItem | ParallelItem | InterceptItem | MiddlewareItem | RevalidateItem | LoaderItem | LoadingItem | ErrorBoundaryItem | NotFoundBoundaryItem | CacheItem | TransitionItem;
154
- /** Items that can be used inside a response route (path.json(), etc.) */
155
- export type ResponseRouteUseItem = MiddlewareItem | CacheItem;
156
- export type ParallelUseItem = RevalidateItem | LoaderItem | LoadingItem | ErrorBoundaryItem | NotFoundBoundaryItem | TransitionItem;
157
- export type InterceptUseItem = MiddlewareItem | RevalidateItem | LoaderItem | LoadingItem | ErrorBoundaryItem | NotFoundBoundaryItem | LayoutItem | RouteItem | TransitionItem;
158
- export type LoaderUseItem = RevalidateItem | CacheItem;
159
- /**
160
- * Allow composition factories in use() callbacks.
161
- * Factories return T[], which placed inside a use() callback array
162
- * creates nested arrays like (T | T[])[]. These are flattened at
163
- * runtime via .flat(3).
164
- */
165
- export type UseItems<T> = (T | readonly T[])[];
166
- /**
167
- * Union of all items that handler.use() may return.
168
- * A handler doesn't know its mount site at definition time, so the type
169
- * is intentionally broad — validation happens per-mount-site at runtime.
170
- */
171
- export type HandlerUseItem = RouteUseItem | LayoutUseItem | ParallelUseItem | InterceptUseItem;
172
- export {};
@@ -1,10 +0,0 @@
1
- /**
2
- * Normalize a router basename to its canonical form: a single leading slash,
3
- * no trailing slash, and `undefined` for an empty or bare-"/" value.
4
- *
5
- * This is the single source of truth used by both createRouter() (so the RSC
6
- * handler stores a canonical basename on the request context) and the testing
7
- * primitives (so a consumer can pass the same un-normalized string their
8
- * createRouter() accepts and observe the same redirect() prefixing).
9
- */
10
- export declare function normalizeBasename(basename?: string): string | undefined;
@@ -1,91 +0,0 @@
1
- /**
2
- * Content Negotiation Utilities
3
- *
4
- * Pure functions for HTTP Accept header parsing and response type matching.
5
- * Used by previewMatch and classifyRequest for content negotiation between
6
- * RSC routes and response routes (JSON, text, image, stream, etc.).
7
- */
8
- import type { EntryData } from "../server/context.js";
9
- import type { CollectedMiddleware } from "./middleware-types.js";
10
- import type { RouteSnapshot } from "./route-snapshot.js";
11
- export declare const RESPONSE_TYPE_MIME: Record<string, string>;
12
- export declare const MIME_RESPONSE_TYPE: Record<string, string>;
13
- export type NamedRouteEntry = string | {
14
- path: string;
15
- search?: Record<string, string>;
16
- };
17
- export declare function flattenNamedRoutes(routeNames?: Record<string, NamedRouteEntry>): Record<string, string>;
18
- export interface AcceptEntry {
19
- mime: string;
20
- q: number;
21
- order: number;
22
- }
23
- /**
24
- * Parse an Accept header into a sorted array of MIME entries.
25
- * Respects q-values (default 1.0) and uses client order as tiebreaker
26
- * when q-values are equal (matching Express/Hono behavior).
27
- */
28
- export declare function parseAcceptTypes(accept: string): AcceptEntry[];
29
- export declare const RSC_RESPONSE_TYPE = "__rsc__";
30
- /** RSC wire-format MIME type; explicit-opt-in flight transport. */
31
- export declare const RSC_WIRE_MIME = "text/x-component";
32
- /**
33
- * Rank the RSC route's two representations against a parsed Accept list:
34
- * true when the flight wire format outranks the HTML document. Wildcard
35
- * entries count for the HTML side — they express "anything", and the
36
- * canonical representation of anything is the document. Co-located with
37
- * RSC_MIMES so the candidate registration and the representation choice
38
- * cannot drift.
39
- */
40
- export declare function prefersFlightRepresentation(acceptEntries: AcceptEntry[]): boolean;
41
- /**
42
- * Pick the best negotiate variant by walking the client's sorted Accept list.
43
- * For each accepted MIME type (in q-value/order priority), check if any
44
- * candidate serves that type. Wildcards match the first candidate.
45
- * Falls back to the first candidate if nothing matches.
46
- */
47
- export declare function pickNegotiateVariant<T extends {
48
- routeKey: string;
49
- responseType: string;
50
- }>(acceptEntries: AcceptEntry[], candidates: T[]): T;
51
- /**
52
- * Re-key params from the primary leaf's names to a winning variant's names.
53
- *
54
- * The trie match builds `params` positionally under the primary leaf's pa, so
55
- * `/widgets/:id` matched as the primary yields `{ id }` even when the winning
56
- * `/widgets/:file` response variant expects `{ file }`. Both share the same trie
57
- * terminal, so they bind the same number of positional named params; we zip the
58
- * variant's pa against the named values in insertion order (which is the
59
- * primary's pa order). The wildcard key (`*`) is positional-independent and left
60
- * untouched.
61
- *
62
- * Mutates `params` in place. No-op when `variantPa` is absent, when names already
63
- * match (the common case), or when the positional count diverges (defensive:
64
- * never corrupt params by zipping mismatched lengths).
65
- */
66
- export declare function rekeyParamsForVariant(params: Record<string, string>, variantPa: string[] | undefined): void;
67
- /**
68
- * Result of content negotiation for a route with negotiate variants.
69
- */
70
- export interface NegotiationResult {
71
- /** The winning response type */
72
- responseType: string;
73
- /** Handler function for the winning variant */
74
- handler: Function;
75
- /** Manifest entry for the winning variant (may differ from primary) */
76
- manifestEntry: EntryData;
77
- /** Route middleware for the winning variant */
78
- routeMiddleware: CollectedMiddleware[];
79
- /** True when negotiation selected a variant; false for a plain response route. */
80
- negotiated: boolean;
81
- }
82
- /**
83
- * Perform content negotiation for a route with negotiate variants.
84
- *
85
- * Returns a NegotiationResult when a response route wins negotiation.
86
- * Returns null when RSC wins or no negotiation is needed.
87
- *
88
- * Shared by previewMatch and classifyRequest to avoid duplicating
89
- * the candidate-building and variant-loading logic.
90
- */
91
- export declare function negotiateRoute(request: Request, pathname: string, snapshot: RouteSnapshot): Promise<NegotiationResult | null>;
@@ -1,7 +0,0 @@
1
- import { type SerializedManifest } from "../debug.js";
2
- import type { RouteEntry } from "../types";
3
- /**
4
- * Build a serialized manifest from all route entries for debug inspection.
5
- * Used by the `debugManifest()` method on the router instance.
6
- */
7
- export declare function buildDebugManifest<TEnv = any>(routesEntries: RouteEntry<TEnv>[]): Promise<SerializedManifest>;
@@ -1,76 +0,0 @@
1
- /**
2
- * Router Error Handling Utilities
3
- *
4
- * Error boundary and not-found boundary handling for Rango.
5
- * Also includes the shared invokeOnError utility for error callback invocation.
6
- */
7
- import type { ReactNode } from "react";
8
- import type { EntryData } from "../server/context";
9
- import type { ResolvedSegment, ErrorInfo, ErrorBoundaryHandler, NotFoundInfo, NotFoundBoundaryHandler, ErrorPhase, OnErrorCallback } from "../types";
10
- /**
11
- * Context required to invoke the onError callback.
12
- * This is a subset of OnErrorContext that callers must provide.
13
- */
14
- export interface InvokeOnErrorContext<TEnv = any> {
15
- request: Request;
16
- url: URL;
17
- routeKey?: string;
18
- params?: Record<string, string>;
19
- segmentId?: string;
20
- segmentType?: "layout" | "route" | "parallel" | "loader" | "middleware";
21
- loaderName?: string;
22
- middlewareId?: string;
23
- actionId?: string;
24
- env?: TEnv;
25
- isPartial?: boolean;
26
- handledByBoundary?: boolean;
27
- metadata?: Record<string, unknown>;
28
- /** Request start time from performance.now() for duration calculation */
29
- requestStartTime?: number;
30
- }
31
- /**
32
- * Invoke the onError callback with comprehensive context.
33
- * Catches any errors in the callback itself to prevent masking the original error.
34
- *
35
- * This is a shared utility used by both the router and RSC handler to ensure
36
- * consistent error callback behavior across the codebase.
37
- *
38
- * @param onError - The onError callback to invoke (may be undefined)
39
- * @param error - The error that occurred
40
- * @param phase - The phase where the error occurred
41
- * @param context - Additional context about the error
42
- * @param logPrefix - Prefix for console.error messages (e.g., "Router" or "RSC")
43
- */
44
- export declare function invokeOnError<TEnv = any>(onError: OnErrorCallback<TEnv> | undefined, error: unknown, phase: ErrorPhase, context: InvokeOnErrorContext<TEnv>, logPrefix?: string): void;
45
- /**
46
- * Find the nearest error boundary by walking up the entry chain
47
- * Also checks sibling layouts (orphan layouts) for error boundaries
48
- * Returns the first fallback found, or the default error boundary if configured
49
- */
50
- export declare function findNearestErrorBoundary(entry: EntryData | null, defaultErrorBoundary?: ReactNode | ErrorBoundaryHandler): ReactNode | ErrorBoundaryHandler | null;
51
- /**
52
- * Find the nearest notFound boundary by walking up the entry chain
53
- * Returns the first fallback found, or the default notFound boundary if configured
54
- */
55
- export declare function findNearestNotFoundBoundary(entry: EntryData | null, defaultNotFoundBoundary?: ReactNode | NotFoundBoundaryHandler): ReactNode | NotFoundBoundaryHandler | null;
56
- /**
57
- * Create ErrorInfo from an error object
58
- * Sanitizes error details in production
59
- */
60
- export declare function createErrorInfo(error: unknown, segmentId: string, segmentType: ErrorInfo["segmentType"]): ErrorInfo;
61
- /**
62
- * Create an error segment with the fallback component
63
- * Renders the fallback with error info and reset function
64
- */
65
- export declare function createErrorSegment(errorInfo: ErrorInfo, fallback: ReactNode | ErrorBoundaryHandler, entry: EntryData, params: Record<string, string>): ResolvedSegment;
66
- /**
67
- * Create NotFoundInfo from a DataNotFoundError
68
- */
69
- export declare function createNotFoundInfo(error: {
70
- message: string;
71
- }, segmentId: string, segmentType: NotFoundInfo["segmentType"], pathname?: string): NotFoundInfo;
72
- /**
73
- * Create a notFound segment with the fallback component
74
- * Renders the fallback with not found info
75
- */
76
- export declare function createNotFoundSegment(notFoundInfo: NotFoundInfo, fallback: ReactNode | NotFoundBoundaryHandler, entry: EntryData, params: Record<string, string>): ResolvedSegment;
@@ -1,19 +0,0 @@
1
- import { type RouteMatchResult } from "./pattern-matching.js";
2
- import type { MetricsStore } from "../server/context";
3
- import type { RouteEntry } from "../types";
4
- export interface FindMatchDeps<TEnv = any> {
5
- routesEntries: RouteEntry<TEnv>[];
6
- evaluateLazyEntry: (entry: RouteEntry<TEnv>) => void | Promise<void>;
7
- routerId: string;
8
- }
9
- /**
10
- * Create a findMatch function bound to router state.
11
- * Includes single-entry cache to avoid redundant matching within the same request.
12
- *
13
- * Async because a lazy include may be backed by an async provider
14
- * (`() => import("./routes")`) that must be resolved before its routes can be
15
- * matched. The hot path is unaffected: `await` only suspends on the first
16
- * request to a not-yet-loaded dynamic include; eager routes resolve in the same
17
- * microtask. Every caller already runs inside an async match pipeline.
18
- */
19
- export declare function createFindMatch<TEnv = any>(deps: FindMatchDeps<TEnv>): (pathname: string, ms?: MetricsStore) => Promise<RouteMatchResult<TEnv> | null>;
@@ -1,41 +0,0 @@
1
- /**
2
- * Router Handler Context
3
- *
4
- * Creates the handler context object passed to route handlers, middleware, and loaders.
5
- */
6
- import type { InternalHandlerContext } from "../types";
7
- /**
8
- * Strip internal _rsc* query params from a URL.
9
- * Returns a new URL with only user-facing params.
10
- */
11
- export declare function stripInternalParams(url: URL): URL;
12
- /**
13
- * Create a reverse function for URL generation from route names.
14
- * Used by both HandlerContext and MiddlewareContext.
15
- *
16
- * When currentParams is provided, those params are used as defaults for URL
17
- * generation. This enables auto-filling mount params from include() prefixes:
18
- * inner handlers can call ctx.reverse(".sibling") without explicitly passing
19
- * params that are already known from the current URL match.
20
- * Explicitly passed hrefParams take priority over currentParams.
21
- */
22
- export declare function createReverseFunction(routeMap: Record<string, string>, currentRoutePrefix?: string, currentParams?: Record<string, string>, rootScoped?: boolean): (name: string, hrefParams?: Record<string, string>, search?: Record<string, unknown>) => string;
23
- /**
24
- * Create HandlerContext with typed env/var/get/set
25
- */
26
- export declare function createHandlerContext<TEnv>(params: Record<string, string>, request: Request, searchParams: URLSearchParams, pathname: string, url: URL, bindings?: TEnv, routeMap?: Record<string, string>, routeName?: string, responseType?: string, isPassthroughRoute?: boolean): InternalHandlerContext<any, TEnv>;
27
- /**
28
- * Create a PrerenderContext for Prerender() handlers at build time.
29
- *
30
- * Returns an InternalHandlerContext where params, pathname, url, searchParams,
31
- * search, reverse, and use(handle) work. Request-time properties
32
- * (request, env, headers, cookies, get, set, res) throw with a clear error.
33
- */
34
- export declare function createPrerenderContext<TEnv>(params: Record<string, string>, pathname: string, routeMap: Record<string, string>, routeName?: string, buildVars?: Record<string, any>, isPassthroughRoute?: boolean, buildEnv?: TEnv, devMode?: boolean): InternalHandlerContext<any, TEnv>;
35
- /**
36
- * Create a StaticContext for Static() handlers at build time.
37
- *
38
- * Returns an InternalHandlerContext where only reverse and use(handle) work.
39
- * Static handlers have no URL, no params, no pathname — everything else throws.
40
- */
41
- export declare function createStaticContext<TEnv>(routeMap: Record<string, string>, routeName?: string, buildEnv?: TEnv, devMode?: boolean): InternalHandlerContext<any, TEnv>;
@@ -1,161 +0,0 @@
1
- /**
2
- * Phase + event instrumentation — the single internal API for observing router
3
- * work.
4
- *
5
- * The router exposes the same work on three surfaces, and the rule is: each
6
- * surface has exactly one owner here, so they cannot drift.
7
- *
8
- * - observePhase(): a span of work. Co-emits the `debugPerformance` perf
9
- * metric (metrics store -> [RSC Perf] timeline + Server-Timing) AND the
10
- * platform span (tracing runner -> Cloudflare custom spans / OTel). From one
11
- * wrap site, so the span set is always a subset of the perf phases and the
12
- * two can't disagree. Phases that meter their own perf metric with a finer
13
- * decomposition (request, middleware) pass `metric: false` and get the span
14
- * only — still co-located, still one owner per surface.
15
- * - observeEvent(): a discrete fact (TelemetrySink): cache decisions,
16
- * revalidation decisions, handler errors, timeouts, origin rejections.
17
- * Event-shaped, not phase-shaped — derived from the same call sites but a
18
- * separate surface from spans.
19
- *
20
- * Why phases, not events, are the parent abstraction: Cloudflare's span API is
21
- * callback-bound (enterSpan wraps the actual work), so the callback boundary is
22
- * the source of truth — async-context nesting (a loader's KV/D1/fetch spans
23
- * landing under rango.loader) cannot be faithfully reconstructed from
24
- * after-the-fact start/end events. Spans drive; events are emitted alongside.
25
- *
26
- * Phase identity lives in the PHASES registry below, so the raw `rango.*` span
27
- * names, perf-metric labels, and span attributes have a single definition each.
28
- *
29
- * When neither perf surface nor tracing is active on the request, observePhase
30
- * is a direct call — no wrapper, no timestamp, no allocation.
31
- */
32
- import { type TelemetryEvent } from "./telemetry.js";
33
- import { type TracePhase, type TraceSpan } from "./tracing.js";
34
- /**
35
- * Perf-metric boundary for a phase, or `false` for span-only. `false` means the
36
- * caller records its own perf metric with a finer decomposition than a single
37
- * wrap (request: a grand total incl. pre-context bootstrap; middleware: pre/post
38
- * own-time), so observePhase opens the span but records no metric of its own.
39
- */
40
- export type PhaseMetric = {
41
- label: string | (() => string);
42
- depth?: number;
43
- } | false;
44
- /** Describes one observable phase across the perf and span surfaces. */
45
- export interface PhaseSpec {
46
- /** Perf timeline label + Server-Timing name, or false for span-only. */
47
- metric: PhaseMetric;
48
- /** Span phase gate (per-phase toggle in the tracing config). */
49
- tracePhase: TracePhase;
50
- /** Span name (rango.*). */
51
- spanName: string;
52
- /** Span attributes set automatically when the span opens. */
53
- attributes?: Record<string, string | number | boolean>;
54
- /**
55
- * Span attributes resolved AFTER the wrapped work runs (so they can read state
56
- * that only exists once the work is underway, e.g. the matched route name).
57
- * Applied for streaming phases once fn has constructed its value. Return
58
- * undefined to add nothing.
59
- */
60
- lazyAttributes?: () => Record<string, string | number | boolean> | undefined;
61
- }
62
- /**
63
- * The router's observable phases. One definition per phase keeps the `rango.*`
64
- * span names, perf-metric labels, and identifying attributes from spreading
65
- * across call sites.
66
- */
67
- export declare const PHASES: {
68
- /** Whole request pipeline. Span only — handler:total is metered directly. */
69
- readonly request: PhaseSpec;
70
- /** One middleware (incl. its downstream onion). Span only — the perf metric
71
- * is the middleware's exclusive pre/post own-time, recorded directly.
72
- * `metricLabel` is that metric's label (e.g. "middleware:auth@*"); it doubles
73
- * as the rango.middleware_name span attribute. */
74
- readonly middleware: (metricLabel: string) => PhaseSpec;
75
- /** The server-action execution (decode args + run the action body), before
76
- * the revalidation render. The metric label carries the action id (the
77
- * _rsc_action / action $$id) so the perf timeline shows WHICH action ran, not
78
- * just "an action"; the span also gets it as rango.action_id. */
79
- readonly action: (id: string) => PhaseSpec;
80
- /**
81
- * One loader execution. `depth` is the perf-timeline indentation: 2 (default)
82
- * for render-time loaders that nest under the render phase; 1 for a standalone
83
- * fetchable `_rsc_loader` request, which has no render parent.
84
- */
85
- readonly loader: (id: string, depth?: number) => PhaseSpec;
86
- /** One segment route/layout handler execution (the component/handler that
87
- * produces a segment). Span only — the perf metric (handler:<id>) is owned by
88
- * the legacy track() at the same call site, so observePhase here adds the
89
- * rango.handler span without double-recording. `id` is the HANDLER id (the
90
- * entry.id used in the handler:<id> perf row), carried as rango.handler_id —
91
- * NOT the emitted segment's id (shortCode), which differs; the *_id naming
92
- * mirrors rango.loader_id / rango.action_id. */
93
- readonly handler: (id: string) => PhaseSpec;
94
- /** Whole render phase: match + serialize + SSR. The metric label is resolved
95
- * lazily at record time (after match has set the route name) so the perf
96
- * timeline shows WHICH route rendered: `render:total:<routeName>`, falling back
97
- * to `render:total` when there is no named route (unmatched / auto-generated). */
98
- readonly render: PhaseSpec;
99
- /** SSR HTML render from the RSC stream. Colon-delimited like the other ssr:*
100
- * setup metrics (ssr:module-load / ssr:stream-mode). */
101
- readonly ssr: PhaseSpec;
102
- };
103
- /**
104
- * Instrument one unit of work: open its span AND (unless `metric: false`) record
105
- * its perf metric, from a single wrap site. fn is invoked exactly once with the
106
- * span (a no-op span when tracing is off); its return value is returned
107
- * unchanged and thrown errors / rejected promises propagate unchanged. When fn
108
- * returns a promise both the metric duration and the span end when it settles.
109
- *
110
- * This is the ONLY phase primitive: every phase (request/middleware/action/
111
- * loader/handler/render/ssr) is construction-bound — the span and metric settle
112
- * when fn's own work completes (for the streaming phases, when the RSC/HTML
113
- * stream is constructed, NOT when the body drains). Instrumentation is strictly
114
- * best-effort: it never wraps or buffers the response and adds no work on the
115
- * streaming path, so it cannot regress response latency or streaming. A loader
116
- * that resolves while the body streams therefore keeps a rango.loader span that
117
- * may extend past its render parent — overlapping spans are valid; the loader
118
- * really did take that long.
119
- *
120
- * Reads the metrics store + tracing off the RequestContext ALS, which is active
121
- * for the WHOLE request — contrast observeEvent, which reads the RouterContext
122
- * ALS (entered later, during match).
123
- */
124
- export declare function observePhase<T>(spec: PhaseSpec, fn: (span: TraceSpan) => T): T;
125
- /**
126
- * Open a rango.handler span around one segment route/layout handler call. The
127
- * segment-resolution hot path runs this PER SEGMENT, so it gates on the SPAN
128
- * surface alone and calls the handler directly otherwise — building neither the
129
- * PhaseSpec (PHASES.handler allocates) nor the wrapper closure on the off path.
130
- * The handler:<id> perf metric is owned by the track() at the call site, so the
131
- * span is the only surface this adds (metric:false); a debugPerformance-only
132
- * request (no tracing) or a disabled handler phase (spans:{handler:false}) has
133
- * nothing to record here and short-circuits.
134
- */
135
- export declare function observeHandler<C, R>(id: string, handler: (ctx: C) => R, ctx: C): R;
136
- /**
137
- * Emit one discrete telemetry event (the event-shaped counterpart to
138
- * observePhase). Resolves the sink from the active router context and stamps the
139
- * request id when the event omits it. No-op (and total — never throws) when no
140
- * sink is configured.
141
- *
142
- * This is the canonical emitter for SYNCHRONOUS facts that fire inside the
143
- * request's ALS scope (revalidation decisions, cache-lookup decisions). A few
144
- * emitters deliberately stay on the lower-level resolveSink + safeEmit because
145
- * observeEvent's lazy, per-call getRouterContext() read does not fit them — keep
146
- * this the complete list:
147
- * - router.ts wrapLoaderPromise (loader.start/end/error) and
148
- * segment-resolution/streamed-handler-telemetry.ts (streamed handler.error)
149
- * capture the sink + request id EAGERLY and emit from a fire-and-forget
150
- * continuation that runs after the ALS scope may have unwound.
151
- * - router/match-handlers.ts resolves the sink ONCE for the hot match-pipeline
152
- * loop (request.start/end/error, cache.decision, ...).
153
- * - segment-resolution/helpers.ts emits via a caller-provided report.telemetry
154
- * sink rather than the ALS router context.
155
- * - rsc/handler.ts handleTimeoutResponse (request.timeout), the origin guard
156
- * (request.origin-rejected), and handleStore.onError (late-handle
157
- * handler.error) emit via router.telemetry directly — they run outside the
158
- * RouterContext ALS (only match()/matchPartial() enter it), so a
159
- * getRouterContext() read there throws and the event would vanish.
160
- */
161
- export declare function observeEvent(event: TelemetryEvent): void;
@@ -1,79 +0,0 @@
1
- /**
2
- * Intercept Resolution
3
- *
4
- * Extracted from createRouter closure. Contains intercept detection and resolution
5
- * functions for soft navigation (modals).
6
- */
7
- import type { EntryData, InterceptEntry, InterceptSelectorContext } from "../server/context";
8
- import type { HandlerContext, ResolvedSegment } from "../types";
9
- import type { SegmentResolutionDeps } from "./types.js";
10
- /**
11
- * Check if an intercept's when conditions are satisfied.
12
- * All when() functions must return true for the intercept to activate.
13
- * If no when() conditions are defined, the intercept always activates.
14
- *
15
- * During action revalidation, when() is NOT evaluated.
16
- */
17
- export declare function evaluateInterceptWhen(intercept: InterceptEntry, selectorContext: InterceptSelectorContext | null, isAction: boolean): boolean;
18
- /**
19
- * Find an intercept for the target route by walking up the entry chain.
20
- * Returns the first (innermost) matching intercept along with the entry that defines it.
21
- */
22
- export declare function findInterceptForRoute(targetRouteKey: string, fromEntry: EntryData | null, selectorContext?: InterceptSelectorContext | null, isAction?: boolean): {
23
- intercept: InterceptEntry;
24
- entry: EntryData;
25
- } | null;
26
- /**
27
- * Resolve an intercept entry and emit segment with the slot name.
28
- */
29
- export declare function resolveInterceptEntry<TEnv>(interceptEntry: InterceptEntry, parentEntry: EntryData, params: Record<string, string>, context: HandlerContext<any, TEnv>, belongsToRoute: boolean, deps: SegmentResolutionDeps<TEnv>, revalidationContext?: {
30
- clientSegmentIds: Set<string>;
31
- prevParams: Record<string, string>;
32
- request: Request;
33
- prevUrl: URL;
34
- nextUrl: URL;
35
- routeKey: string;
36
- actionContext?: {
37
- actionId?: string;
38
- actionUrl?: URL;
39
- actionResult?: any;
40
- formData?: FormData;
41
- };
42
- stale?: boolean;
43
- }, options?: {
44
- /**
45
- * Skip the intercept's middleware execution. Set ONLY by the post-response
46
- * background re-render paths (proactive caching, stale background
47
- * revalidation), whose sole purpose is to re-render the segment tree to
48
- * populate the cache. The foreground request already ran the intercept
49
- * middleware before the response was sent — it validated auth, set cookies,
50
- * and wrote context vars into the request context's shared `_variables`,
51
- * which the background render reuses. Re-running middleware here would fire
52
- * its side effects a SECOND time, and a middleware that short-circuits with
53
- * a Response would `throw` and silently abort the cache write. Never set on
54
- * the foreground path.
55
- */
56
- skipMiddleware?: boolean;
57
- }): Promise<ResolvedSegment[]>;
58
- /**
59
- * Resolve only the loaders for a cached intercept segment.
60
- * Used on intercept cache hit to get fresh loader data while keeping cached component/layout.
61
- */
62
- export declare function resolveInterceptLoadersOnly<TEnv>(interceptEntry: InterceptEntry, parentEntry: EntryData, params: Record<string, string>, context: HandlerContext<any, TEnv>, belongsToRoute: boolean, deps: SegmentResolutionDeps<TEnv>, revalidationContext: {
63
- clientSegmentIds: Set<string>;
64
- prevParams: Record<string, string>;
65
- request: Request;
66
- prevUrl: URL;
67
- nextUrl: URL;
68
- routeKey: string;
69
- actionContext?: {
70
- actionId?: string;
71
- actionUrl?: URL;
72
- actionResult?: any;
73
- formData?: FormData;
74
- };
75
- stale?: boolean;
76
- }): Promise<{
77
- loaderDataPromise: Promise<any[]> | any[];
78
- loaderIds: string[];
79
- } | null>;