@rangojs/router 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (435) hide show
  1. package/dist/types/browser/prefetch/default-strategy.d.ts +22 -0
  2. package/dist/types/browser/prefetch/runtime.d.ts +0 -1
  3. package/dist/types/browser/react/Link.d.ts +8 -11
  4. package/dist/types/browser/types.d.ts +5 -0
  5. package/dist/types/cache/types.d.ts +6 -0
  6. package/dist/types/router/prefetch-default.d.ts +28 -0
  7. package/dist/types/router/router-interfaces.d.ts +7 -0
  8. package/dist/types/router/router-options.d.ts +30 -0
  9. package/dist/types/rsc/capture-queue.d.ts +6 -0
  10. package/dist/types/rsc/shell-capture.d.ts +15 -7
  11. package/dist/types/rsc/shell-serve.d.ts +4 -3
  12. package/dist/types/rsc/types.d.ts +2 -0
  13. package/dist/types/testing/e2e/index.d.ts +2 -2
  14. package/dist/types/testing/e2e/page-helpers.d.ts +24 -0
  15. package/dist/types.backup/__internal.d.ts +127 -0
  16. package/dist/types.backup/bin/rango.d.ts +1 -0
  17. package/dist/types.backup/browser/action-coordinator.d.ts +57 -0
  18. package/dist/types.backup/browser/action-fence.d.ts +33 -0
  19. package/dist/types.backup/browser/app-shell.d.ts +34 -0
  20. package/dist/types.backup/browser/app-version.d.ts +6 -0
  21. package/dist/types.backup/browser/connection-warmup.d.ts +31 -0
  22. package/dist/types.backup/browser/cookie-name.d.ts +66 -0
  23. package/dist/types.backup/browser/event-controller.d.ts +221 -0
  24. package/dist/types.backup/browser/history-state.d.ts +26 -0
  25. package/dist/types.backup/browser/index.d.ts +1 -0
  26. package/dist/types.backup/browser/intercept-utils.d.ts +30 -0
  27. package/dist/types.backup/browser/invalidate-client-cache.d.ts +17 -0
  28. package/dist/types.backup/browser/link-interceptor.d.ts +43 -0
  29. package/dist/types.backup/browser/logging.d.ts +33 -0
  30. package/dist/types.backup/browser/merge-segment-loaders.d.ts +38 -0
  31. package/dist/types.backup/browser/navigation-bridge.d.ts +27 -0
  32. package/dist/types.backup/browser/navigation-client.d.ts +17 -0
  33. package/dist/types.backup/browser/navigation-store-handle.d.ts +25 -0
  34. package/dist/types.backup/browser/navigation-store.d.ts +95 -0
  35. package/dist/types.backup/browser/navigation-transaction.d.ts +75 -0
  36. package/dist/types.backup/browser/network-error-handler.d.ts +35 -0
  37. package/dist/types.backup/browser/partial-update.d.ts +61 -0
  38. package/dist/types.backup/browser/prefetch/cache.d.ts +183 -0
  39. package/dist/types.backup/browser/prefetch/fetch.d.ts +52 -0
  40. package/dist/types.backup/browser/prefetch/observer.d.ts +27 -0
  41. package/dist/types.backup/browser/prefetch/policy.d.ts +13 -0
  42. package/dist/types.backup/browser/prefetch/queue.d.ts +48 -0
  43. package/dist/types.backup/browser/prefetch/resource-ready.d.ts +28 -0
  44. package/dist/types.backup/browser/rango-state.d.ts +52 -0
  45. package/dist/types.backup/browser/react/Link.d.ts +140 -0
  46. package/dist/types.backup/browser/react/NavigationProvider.d.ts +88 -0
  47. package/dist/types.backup/browser/react/ScrollRestoration.d.ts +78 -0
  48. package/dist/types.backup/browser/react/context.d.ts +54 -0
  49. package/dist/types.backup/browser/react/filter-segment-order.d.ts +35 -0
  50. package/dist/types.backup/browser/react/index.d.ts +1 -0
  51. package/dist/types.backup/browser/react/location-state-shared.d.ts +162 -0
  52. package/dist/types.backup/browser/react/location-state.d.ts +29 -0
  53. package/dist/types.backup/browser/react/mount-context.d.ts +23 -0
  54. package/dist/types.backup/browser/react/nonce-context.d.ts +14 -0
  55. package/dist/types.backup/browser/react/shallow-equal.d.ts +5 -0
  56. package/dist/types.backup/browser/react/use-action.d.ts +61 -0
  57. package/dist/types.backup/browser/react/use-handle.d.ts +21 -0
  58. package/dist/types.backup/browser/react/use-href.d.ts +32 -0
  59. package/dist/types.backup/browser/react/use-link-status.d.ts +36 -0
  60. package/dist/types.backup/browser/react/use-mount.d.ts +24 -0
  61. package/dist/types.backup/browser/react/use-navigation.d.ts +15 -0
  62. package/dist/types.backup/browser/react/use-params.d.ts +21 -0
  63. package/dist/types.backup/browser/react/use-pathname.d.ts +13 -0
  64. package/dist/types.backup/browser/react/use-reverse.d.ts +40 -0
  65. package/dist/types.backup/browser/react/use-router.d.ts +23 -0
  66. package/dist/types.backup/browser/react/use-search-params.d.ts +19 -0
  67. package/dist/types.backup/browser/react/use-segments.d.ts +29 -0
  68. package/dist/types.backup/browser/response-adapter.d.ts +58 -0
  69. package/dist/types.backup/browser/rsc-router.d.ts +141 -0
  70. package/dist/types.backup/browser/scroll-restoration.d.ts +103 -0
  71. package/dist/types.backup/browser/segment-reconciler.d.ts +74 -0
  72. package/dist/types.backup/browser/segment-structure-assert.d.ts +16 -0
  73. package/dist/types.backup/browser/server-action-bridge.d.ts +29 -0
  74. package/dist/types.backup/browser/types.d.ts +530 -0
  75. package/dist/types.backup/browser/validate-redirect-origin.d.ts +28 -0
  76. package/dist/types.backup/build/collect-fallback-refs.d.ts +5 -0
  77. package/dist/types.backup/build/generate-manifest.d.ts +100 -0
  78. package/dist/types.backup/build/generate-route-types.d.ts +8 -0
  79. package/dist/types.backup/build/index.d.ts +21 -0
  80. package/dist/types.backup/build/prefix-tree-utils.d.ts +56 -0
  81. package/dist/types.backup/build/route-trie.d.ts +89 -0
  82. package/dist/types.backup/build/route-types/ast-helpers.d.ts +3 -0
  83. package/dist/types.backup/build/route-types/ast-route-extraction.d.ts +13 -0
  84. package/dist/types.backup/build/route-types/codegen.d.ts +16 -0
  85. package/dist/types.backup/build/route-types/include-resolution.d.ts +74 -0
  86. package/dist/types.backup/build/route-types/param-extraction.d.ts +13 -0
  87. package/dist/types.backup/build/route-types/per-module-writer.d.ts +18 -0
  88. package/dist/types.backup/build/route-types/router-processing.d.ts +82 -0
  89. package/dist/types.backup/build/route-types/scan-filter.d.ts +17 -0
  90. package/dist/types.backup/build/route-types/source-scan.d.ts +13 -0
  91. package/dist/types.backup/build/runtime-discovery.d.ts +24 -0
  92. package/dist/types.backup/cache/background-task.d.ts +21 -0
  93. package/dist/types.backup/cache/cache-error.d.ts +71 -0
  94. package/dist/types.backup/cache/cache-key-utils.d.ts +35 -0
  95. package/dist/types.backup/cache/cache-policy.d.ts +59 -0
  96. package/dist/types.backup/cache/cache-runtime.d.ts +51 -0
  97. package/dist/types.backup/cache/cache-scope.d.ts +134 -0
  98. package/dist/types.backup/cache/cache-tag.d.ts +79 -0
  99. package/dist/types.backup/cache/cf/cf-base64.d.ts +4 -0
  100. package/dist/types.backup/cache/cf/cf-cache-constants.d.ts +105 -0
  101. package/dist/types.backup/cache/cf/cf-cache-store.d.ts +481 -0
  102. package/dist/types.backup/cache/cf/cf-cache-types.d.ts +300 -0
  103. package/dist/types.backup/cache/cf/cf-kv-utils.d.ts +22 -0
  104. package/dist/types.backup/cache/cf/cf-tag-marker-memo.d.ts +15 -0
  105. package/dist/types.backup/cache/cf/index.d.ts +3 -0
  106. package/dist/types.backup/cache/document-cache.d.ts +69 -0
  107. package/dist/types.backup/cache/handle-capture.d.ts +23 -0
  108. package/dist/types.backup/cache/handle-snapshot.d.ts +39 -0
  109. package/dist/types.backup/cache/index.d.ts +7 -0
  110. package/dist/types.backup/cache/memory-segment-store.d.ts +163 -0
  111. package/dist/types.backup/cache/profile-registry.d.ts +40 -0
  112. package/dist/types.backup/cache/read-through-swr.d.ts +60 -0
  113. package/dist/types.backup/cache/segment-codec.d.ts +78 -0
  114. package/dist/types.backup/cache/shell-snapshot.d.ts +162 -0
  115. package/dist/types.backup/cache/tag-invalidation.d.ts +74 -0
  116. package/dist/types.backup/cache/taint.d.ts +71 -0
  117. package/dist/types.backup/cache/types.d.ts +407 -0
  118. package/dist/types.backup/cache/vercel/index.d.ts +1 -0
  119. package/dist/types.backup/cache/vercel/vercel-cache-store.d.ts +267 -0
  120. package/dist/types.backup/client.d.ts +184 -0
  121. package/dist/types.backup/client.rsc.d.ts +39 -0
  122. package/dist/types.backup/cloudflare/index.d.ts +7 -0
  123. package/dist/types.backup/cloudflare/tracing.d.ts +53 -0
  124. package/dist/types.backup/component-utils.d.ts +46 -0
  125. package/dist/types.backup/components/DefaultDocument.d.ts +13 -0
  126. package/dist/types.backup/context-var.d.ts +84 -0
  127. package/dist/types.backup/debug.d.ts +57 -0
  128. package/dist/types.backup/decode-loader-results.d.ts +5 -0
  129. package/dist/types.backup/default-error-boundary.d.ts +10 -0
  130. package/dist/types.backup/defer.d.ts +89 -0
  131. package/dist/types.backup/deps/browser.d.ts +1 -0
  132. package/dist/types.backup/deps/html-stream-client.d.ts +1 -0
  133. package/dist/types.backup/deps/html-stream-server.d.ts +1 -0
  134. package/dist/types.backup/deps/rsc.d.ts +1 -0
  135. package/dist/types.backup/deps/ssr.d.ts +1 -0
  136. package/dist/types.backup/encode-kv.d.ts +35 -0
  137. package/dist/types.backup/errors.d.ts +226 -0
  138. package/dist/types.backup/escape-script.d.ts +44 -0
  139. package/dist/types.backup/handle.d.ts +93 -0
  140. package/dist/types.backup/handles/MetaTags.d.ts +17 -0
  141. package/dist/types.backup/handles/Scripts.d.ts +38 -0
  142. package/dist/types.backup/handles/breadcrumbs.d.ts +43 -0
  143. package/dist/types.backup/handles/deferred-resolution.d.ts +53 -0
  144. package/dist/types.backup/handles/is-thenable.d.ts +12 -0
  145. package/dist/types.backup/handles/meta.d.ts +43 -0
  146. package/dist/types.backup/handles/script.d.ts +139 -0
  147. package/dist/types.backup/host/cookie-handler.d.ts +8 -0
  148. package/dist/types.backup/host/errors.d.ts +40 -0
  149. package/dist/types.backup/host/index.d.ts +33 -0
  150. package/dist/types.backup/host/pattern-matcher.d.ts +30 -0
  151. package/dist/types.backup/host/router.d.ts +12 -0
  152. package/dist/types.backup/host/testing.d.ts +41 -0
  153. package/dist/types.backup/host/types.d.ts +148 -0
  154. package/dist/types.backup/host/utils.d.ts +20 -0
  155. package/dist/types.backup/href-client.d.ts +214 -0
  156. package/dist/types.backup/index.d.ts +112 -0
  157. package/dist/types.backup/index.rsc.d.ts +51 -0
  158. package/dist/types.backup/internal-debug.d.ts +1 -0
  159. package/dist/types.backup/loader-store.d.ts +193 -0
  160. package/dist/types.backup/loader.d.ts +18 -0
  161. package/dist/types.backup/loader.rsc.d.ts +18 -0
  162. package/dist/types.backup/missing-id-error.d.ts +1 -0
  163. package/dist/types.backup/outlet-context.d.ts +12 -0
  164. package/dist/types.backup/outlet-provider.d.ts +12 -0
  165. package/dist/types.backup/prerender/build-shell-capture.d.ts +104 -0
  166. package/dist/types.backup/prerender/param-hash.d.ts +6 -0
  167. package/dist/types.backup/prerender/shell-manifest-key.d.ts +18 -0
  168. package/dist/types.backup/prerender/store.d.ts +62 -0
  169. package/dist/types.backup/prerender.d.ts +292 -0
  170. package/dist/types.backup/redirect-origin.d.ts +55 -0
  171. package/dist/types.backup/regex-escape.d.ts +6 -0
  172. package/dist/types.backup/render-error-thrower.d.ts +13 -0
  173. package/dist/types.backup/response-utils.d.ts +35 -0
  174. package/dist/types.backup/reverse.d.ts +206 -0
  175. package/dist/types.backup/root-error-boundary.d.ts +32 -0
  176. package/dist/types.backup/route-content-wrapper.d.ts +40 -0
  177. package/dist/types.backup/route-definition/dsl-helpers.d.ts +130 -0
  178. package/dist/types.backup/route-definition/helper-factories.d.ts +22 -0
  179. package/dist/types.backup/route-definition/helpers-types.d.ts +392 -0
  180. package/dist/types.backup/route-definition/index.d.ts +7 -0
  181. package/dist/types.backup/route-definition/redirect.d.ts +48 -0
  182. package/dist/types.backup/route-definition/resolve-handler-use.d.ts +19 -0
  183. package/dist/types.backup/route-definition/use-item-types.d.ts +1 -0
  184. package/dist/types.backup/route-definition.d.ts +1 -0
  185. package/dist/types.backup/route-map-builder.d.ts +127 -0
  186. package/dist/types.backup/route-name.d.ts +27 -0
  187. package/dist/types.backup/route-types.d.ts +172 -0
  188. package/dist/types.backup/router/basename.d.ts +10 -0
  189. package/dist/types.backup/router/content-negotiation.d.ts +91 -0
  190. package/dist/types.backup/router/debug-manifest.d.ts +7 -0
  191. package/dist/types.backup/router/error-handling.d.ts +76 -0
  192. package/dist/types.backup/router/find-match.d.ts +19 -0
  193. package/dist/types.backup/router/handler-context.d.ts +41 -0
  194. package/dist/types.backup/router/instrument.d.ts +161 -0
  195. package/dist/types.backup/router/intercept-resolution.d.ts +79 -0
  196. package/dist/types.backup/router/lazy-includes.d.ts +26 -0
  197. package/dist/types.backup/router/loader-resolution.d.ts +63 -0
  198. package/dist/types.backup/router/logging.d.ts +41 -0
  199. package/dist/types.backup/router/manifest.d.ts +8 -0
  200. package/dist/types.backup/router/match-api.d.ts +19 -0
  201. package/dist/types.backup/router/match-context.d.ts +184 -0
  202. package/dist/types.backup/router/match-handlers.d.ts +49 -0
  203. package/dist/types.backup/router/match-middleware/background-revalidation.d.ts +113 -0
  204. package/dist/types.backup/router/match-middleware/cache-lookup.d.ts +113 -0
  205. package/dist/types.backup/router/match-middleware/cache-store.d.ts +112 -0
  206. package/dist/types.backup/router/match-middleware/index.d.ts +80 -0
  207. package/dist/types.backup/router/match-middleware/intercept-resolution.d.ts +116 -0
  208. package/dist/types.backup/router/match-middleware/segment-resolution.d.ts +94 -0
  209. package/dist/types.backup/router/match-pipelines.d.ts +103 -0
  210. package/dist/types.backup/router/match-result.d.ts +114 -0
  211. package/dist/types.backup/router/metrics.d.ts +6 -0
  212. package/dist/types.backup/router/middleware-types.d.ts +74 -0
  213. package/dist/types.backup/router/middleware.d.ts +116 -0
  214. package/dist/types.backup/router/navigation-snapshot.d.ts +22 -0
  215. package/dist/types.backup/router/params-util.d.ts +8 -0
  216. package/dist/types.backup/router/parse-pattern.d.ts +38 -0
  217. package/dist/types.backup/router/pattern-matching.d.ts +169 -0
  218. package/dist/types.backup/router/prefetch-cache-ttl.d.ts +27 -0
  219. package/dist/types.backup/router/prefetch-limits.d.ts +20 -0
  220. package/dist/types.backup/router/prerender-match.d.ts +50 -0
  221. package/dist/types.backup/router/preview-match.d.ts +22 -0
  222. package/dist/types.backup/router/request-classification.d.ts +104 -0
  223. package/dist/types.backup/router/revalidation.d.ts +57 -0
  224. package/dist/types.backup/router/route-snapshot.d.ts +112 -0
  225. package/dist/types.backup/router/router-context.d.ts +137 -0
  226. package/dist/types.backup/router/router-interfaces.d.ts +432 -0
  227. package/dist/types.backup/router/router-options.d.ts +738 -0
  228. package/dist/types.backup/router/router-registry.d.ts +15 -0
  229. package/dist/types.backup/router/segment-resolution/fresh.d.ts +55 -0
  230. package/dist/types.backup/router/segment-resolution/helpers.d.ts +93 -0
  231. package/dist/types.backup/router/segment-resolution/loader-cache.d.ts +33 -0
  232. package/dist/types.backup/router/segment-resolution/loader-mask.d.ts +44 -0
  233. package/dist/types.backup/router/segment-resolution/loader-snapshot.d.ts +90 -0
  234. package/dist/types.backup/router/segment-resolution/mask-nested.d.ts +53 -0
  235. package/dist/types.backup/router/segment-resolution/revalidation.d.ts +85 -0
  236. package/dist/types.backup/router/segment-resolution/static-store.d.ts +17 -0
  237. package/dist/types.backup/router/segment-resolution/streamed-handler-telemetry.d.ts +16 -0
  238. package/dist/types.backup/router/segment-resolution/view-transition-default.d.ts +28 -0
  239. package/dist/types.backup/router/segment-resolution.d.ts +3 -0
  240. package/dist/types.backup/router/segment-wrappers.d.ts +53 -0
  241. package/dist/types.backup/router/state-cookie-name.d.ts +1 -0
  242. package/dist/types.backup/router/substitute-pattern-params.d.ts +23 -0
  243. package/dist/types.backup/router/telemetry-otel.d.ts +113 -0
  244. package/dist/types.backup/router/telemetry.d.ts +215 -0
  245. package/dist/types.backup/router/timeout.d.ts +68 -0
  246. package/dist/types.backup/router/tracing.d.ts +125 -0
  247. package/dist/types.backup/router/trie-matching.d.ts +32 -0
  248. package/dist/types.backup/router/types.d.ts +98 -0
  249. package/dist/types.backup/router/url-params.d.ts +26 -0
  250. package/dist/types.backup/router.d.ts +7 -0
  251. package/dist/types.backup/rsc/capture-queue.d.ts +6 -0
  252. package/dist/types.backup/rsc/full-payload.d.ts +22 -0
  253. package/dist/types.backup/rsc/handler-context.d.ts +31 -0
  254. package/dist/types.backup/rsc/handler.d.ts +9 -0
  255. package/dist/types.backup/rsc/helpers.d.ts +213 -0
  256. package/dist/types.backup/rsc/index.d.ts +17 -0
  257. package/dist/types.backup/rsc/json-route-result.d.ts +20 -0
  258. package/dist/types.backup/rsc/loader-fetch.d.ts +14 -0
  259. package/dist/types.backup/rsc/manifest-init.d.ts +18 -0
  260. package/dist/types.backup/rsc/nonce.d.ts +28 -0
  261. package/dist/types.backup/rsc/origin-guard.d.ts +50 -0
  262. package/dist/types.backup/rsc/progressive-enhancement.d.ts +19 -0
  263. package/dist/types.backup/rsc/redirect-guard.d.ts +35 -0
  264. package/dist/types.backup/rsc/response-cache-serve.d.ts +46 -0
  265. package/dist/types.backup/rsc/response-error.d.ts +19 -0
  266. package/dist/types.backup/rsc/response-route-handler.d.ts +29 -0
  267. package/dist/types.backup/rsc/rsc-rendering.d.ts +23 -0
  268. package/dist/types.backup/rsc/runtime-warnings.d.ts +22 -0
  269. package/dist/types.backup/rsc/server-action.d.ts +68 -0
  270. package/dist/types.backup/rsc/shell-build-manifest.d.ts +84 -0
  271. package/dist/types.backup/rsc/shell-capture-constants.d.ts +27 -0
  272. package/dist/types.backup/rsc/shell-capture.d.ts +374 -0
  273. package/dist/types.backup/rsc/shell-serve.d.ts +136 -0
  274. package/dist/types.backup/rsc/ssr-setup.d.ts +48 -0
  275. package/dist/types.backup/rsc/transition-gate.d.ts +27 -0
  276. package/dist/types.backup/rsc/types.d.ts +290 -0
  277. package/dist/types.backup/runtime-env.d.ts +1 -0
  278. package/dist/types.backup/search-params.d.ts +125 -0
  279. package/dist/types.backup/segment-content-promise.d.ts +13 -0
  280. package/dist/types.backup/segment-fragments.d.ts +56 -0
  281. package/dist/types.backup/segment-loader-promise.d.ts +22 -0
  282. package/dist/types.backup/segment-system.d.ts +84 -0
  283. package/dist/types.backup/serialize.d.ts +164 -0
  284. package/dist/types.backup/server/context.d.ts +494 -0
  285. package/dist/types.backup/server/cookie-parse.d.ts +10 -0
  286. package/dist/types.backup/server/cookie-store.d.ts +107 -0
  287. package/dist/types.backup/server/fetchable-loader-store.d.ts +20 -0
  288. package/dist/types.backup/server/handle-store.d.ts +100 -0
  289. package/dist/types.backup/server/loader-registry.d.ts +32 -0
  290. package/dist/types.backup/server/request-context.d.ts +596 -0
  291. package/dist/types.backup/server/root-layout.d.ts +3 -0
  292. package/dist/types.backup/server.d.ts +15 -0
  293. package/dist/types.backup/ssr/index.d.ts +233 -0
  294. package/dist/types.backup/ssr/inject-rsc-eager.d.ts +3 -0
  295. package/dist/types.backup/ssr/preinit-client-references.d.ts +71 -0
  296. package/dist/types.backup/ssr/ssr-root.d.ts +69 -0
  297. package/dist/types.backup/static-handler.d.ts +57 -0
  298. package/dist/types.backup/testing/cache-status.d.ts +63 -0
  299. package/dist/types.backup/testing/collect-handle.d.ts +20 -0
  300. package/dist/types.backup/testing/dispatch.d.ts +123 -0
  301. package/dist/types.backup/testing/dom.entry.d.ts +15 -0
  302. package/dist/types.backup/testing/e2e/fixture.d.ts +37 -0
  303. package/dist/types.backup/testing/e2e/index.d.ts +30 -0
  304. package/dist/types.backup/testing/e2e/matchers.d.ts +17 -0
  305. package/dist/types.backup/testing/e2e/page-helpers.d.ts +62 -0
  306. package/dist/types.backup/testing/e2e/parity.d.ts +111 -0
  307. package/dist/types.backup/testing/e2e/server.d.ts +35 -0
  308. package/dist/types.backup/testing/flight-matchers.d.ts +55 -0
  309. package/dist/types.backup/testing/flight-normalize.d.ts +1 -0
  310. package/dist/types.backup/testing/flight-tree.d.ts +192 -0
  311. package/dist/types.backup/testing/flight.d.ts +115 -0
  312. package/dist/types.backup/testing/flight.entry.d.ts +27 -0
  313. package/dist/types.backup/testing/generated-routes.d.ts +66 -0
  314. package/dist/types.backup/testing/index.d.ts +52 -0
  315. package/dist/types.backup/testing/internal/context.d.ts +225 -0
  316. package/dist/types.backup/testing/internal/flight-client-globals.d.ts +1 -0
  317. package/dist/types.backup/testing/internal/seed-vars.d.ts +30 -0
  318. package/dist/types.backup/testing/render-handler.d.ts +160 -0
  319. package/dist/types.backup/testing/render-route.d.ts +246 -0
  320. package/dist/types.backup/testing/run-loader.d.ts +186 -0
  321. package/dist/types.backup/testing/run-middleware.d.ts +132 -0
  322. package/dist/types.backup/testing/run-transition-when.d.ts +77 -0
  323. package/dist/types.backup/testing/vitest-stubs/cloudflare-email.d.ts +6 -0
  324. package/dist/types.backup/testing/vitest-stubs/cloudflare-workers.d.ts +13 -0
  325. package/dist/types.backup/testing/vitest-stubs/plugin-rsc.d.ts +7 -0
  326. package/dist/types.backup/testing/vitest-stubs/version.d.ts +1 -0
  327. package/dist/types.backup/testing/vitest.d.ts +205 -0
  328. package/dist/types.backup/theme/ThemeProvider.d.ts +13 -0
  329. package/dist/types.backup/theme/ThemeScript.d.ts +45 -0
  330. package/dist/types.backup/theme/constants.d.ts +39 -0
  331. package/dist/types.backup/theme/index.d.ts +29 -0
  332. package/dist/types.backup/theme/theme-context.d.ts +21 -0
  333. package/dist/types.backup/theme/theme-script.d.ts +26 -0
  334. package/dist/types.backup/theme/types.d.ts +162 -0
  335. package/dist/types.backup/theme/use-theme.d.ts +8 -0
  336. package/dist/types.backup/types/boundaries.d.ts +93 -0
  337. package/dist/types.backup/types/cache-types.d.ts +191 -0
  338. package/dist/types.backup/types/error-types.d.ts +114 -0
  339. package/dist/types.backup/types/global-namespace.d.ts +90 -0
  340. package/dist/types.backup/types/handler-context.d.ts +658 -0
  341. package/dist/types.backup/types/index.d.ts +11 -0
  342. package/dist/types.backup/types/loader-types.d.ts +182 -0
  343. package/dist/types.backup/types/request-scope.d.ts +93 -0
  344. package/dist/types.backup/types/route-config.d.ts +105 -0
  345. package/dist/types.backup/types/route-entry.d.ts +95 -0
  346. package/dist/types.backup/types/segments.d.ts +234 -0
  347. package/dist/types.backup/types.d.ts +1 -0
  348. package/dist/types.backup/urls/include-helper.d.ts +17 -0
  349. package/dist/types.backup/urls/include-provider.d.ts +27 -0
  350. package/dist/types.backup/urls/index.d.ts +6 -0
  351. package/dist/types.backup/urls/path-helper-types.d.ts +197 -0
  352. package/dist/types.backup/urls/path-helper.d.ts +12 -0
  353. package/dist/types.backup/urls/pattern-types.d.ts +166 -0
  354. package/dist/types.backup/urls/response-types.d.ts +67 -0
  355. package/dist/types.backup/urls/type-extraction.d.ts +157 -0
  356. package/dist/types.backup/urls/urls-function.d.ts +24 -0
  357. package/dist/types.backup/urls.d.ts +1 -0
  358. package/dist/types.backup/use-loader.d.ts +150 -0
  359. package/dist/types.backup/vercel/index.d.ts +10 -0
  360. package/dist/types.backup/vercel/tracing.d.ts +70 -0
  361. package/dist/types.backup/vite/debug.d.ts +80 -0
  362. package/dist/types.backup/vite/discovery/bundle-postprocess.d.ts +12 -0
  363. package/dist/types.backup/vite/discovery/dev-prerender-cache.d.ts +65 -0
  364. package/dist/types.backup/vite/discovery/discover-routers.d.ts +17 -0
  365. package/dist/types.backup/vite/discovery/discovery-errors.d.ts +113 -0
  366. package/dist/types.backup/vite/discovery/gate-state.d.ts +79 -0
  367. package/dist/types.backup/vite/discovery/prerender-collection.d.ts +24 -0
  368. package/dist/types.backup/vite/discovery/route-types-writer.d.ts +32 -0
  369. package/dist/types.backup/vite/discovery/self-gen-tracking.d.ts +22 -0
  370. package/dist/types.backup/vite/discovery/shell-prerender-phase.d.ts +40 -0
  371. package/dist/types.backup/vite/discovery/state.d.ts +162 -0
  372. package/dist/types.backup/vite/discovery/virtual-module-codegen.d.ts +15 -0
  373. package/dist/types.backup/vite/index.d.ts +11 -0
  374. package/dist/types.backup/vite/inject-client-debug.d.ts +56 -0
  375. package/dist/types.backup/vite/plugin-types.d.ts +298 -0
  376. package/dist/types.backup/vite/plugins/cjs-to-esm.d.ts +6 -0
  377. package/dist/types.backup/vite/plugins/client-ref-dedup.d.ts +40 -0
  378. package/dist/types.backup/vite/plugins/client-ref-hashing.d.ts +35 -0
  379. package/dist/types.backup/vite/plugins/cloudflare-protocol-stub.d.ts +64 -0
  380. package/dist/types.backup/vite/plugins/expose-action-id.d.ts +18 -0
  381. package/dist/types.backup/vite/plugins/expose-id-utils.d.ts +37 -0
  382. package/dist/types.backup/vite/plugins/expose-ids/export-analysis.d.ts +19 -0
  383. package/dist/types.backup/vite/plugins/expose-ids/handler-transform.d.ts +10 -0
  384. package/dist/types.backup/vite/plugins/expose-ids/loader-transform.d.ts +8 -0
  385. package/dist/types.backup/vite/plugins/expose-ids/router-transform.d.ts +13 -0
  386. package/dist/types.backup/vite/plugins/expose-ids/types.d.ts +29 -0
  387. package/dist/types.backup/vite/plugins/expose-internal-ids.d.ts +6 -0
  388. package/dist/types.backup/vite/plugins/performance-tracks.d.ts +25 -0
  389. package/dist/types.backup/vite/plugins/refresh-cmd.d.ts +20 -0
  390. package/dist/types.backup/vite/plugins/use-cache-transform.d.ts +20 -0
  391. package/dist/types.backup/vite/plugins/vercel-output.d.ts +85 -0
  392. package/dist/types.backup/vite/plugins/version-injector.d.ts +21 -0
  393. package/dist/types.backup/vite/plugins/version-plugin.d.ts +19 -0
  394. package/dist/types.backup/vite/plugins/virtual-entries.d.ts +36 -0
  395. package/dist/types.backup/vite/plugins/virtual-stub-plugin.d.ts +7 -0
  396. package/dist/types.backup/vite/rango.d.ts +29 -0
  397. package/dist/types.backup/vite/router-discovery.d.ts +23 -0
  398. package/dist/types.backup/vite/utils/ast-handler-extract.d.ts +64 -0
  399. package/dist/types.backup/vite/utils/banner.d.ts +2 -0
  400. package/dist/types.backup/vite/utils/bundle-analysis.d.ts +28 -0
  401. package/dist/types.backup/vite/utils/client-chunks.d.ts +55 -0
  402. package/dist/types.backup/vite/utils/directive-prologue.d.ts +16 -0
  403. package/dist/types.backup/vite/utils/forward-user-plugins.d.ts +37 -0
  404. package/dist/types.backup/vite/utils/manifest-utils.d.ts +7 -0
  405. package/dist/types.backup/vite/utils/package-resolution.d.ts +6 -0
  406. package/dist/types.backup/vite/utils/prerender-utils.d.ts +32 -0
  407. package/dist/types.backup/vite/utils/shared-utils.d.ts +55 -0
  408. package/dist/vite/index.js +5 -2
  409. package/package.json +1 -1
  410. package/skills/comparison/references/framework-comparison.md +2 -1
  411. package/skills/ppr/SKILL.md +28 -13
  412. package/skills/router-setup/SKILL.md +4 -0
  413. package/src/browser/prefetch/default-strategy.ts +34 -0
  414. package/src/browser/prefetch/loader.ts +6 -12
  415. package/src/browser/prefetch/runtime.ts +0 -1
  416. package/src/browser/react/Link.tsx +22 -21
  417. package/src/browser/rsc-router.tsx +8 -0
  418. package/src/browser/types.ts +5 -0
  419. package/src/cache/cf/cf-cache-store.ts +4 -0
  420. package/src/cache/types.ts +6 -0
  421. package/src/cache/vercel/vercel-cache-store.ts +6 -1
  422. package/src/router/prefetch-default.ts +59 -0
  423. package/src/router/router-interfaces.ts +8 -0
  424. package/src/router/router-options.ts +31 -0
  425. package/src/router.ts +7 -0
  426. package/src/rsc/capture-queue.ts +24 -1
  427. package/src/rsc/full-payload.ts +1 -0
  428. package/src/rsc/handler.ts +1 -0
  429. package/src/rsc/rsc-rendering.ts +120 -18
  430. package/src/rsc/shell-capture.ts +94 -50
  431. package/src/rsc/shell-serve.ts +6 -4
  432. package/src/rsc/types.ts +2 -0
  433. package/src/testing/e2e/index.ts +6 -0
  434. package/src/testing/e2e/page-helpers.ts +47 -0
  435. package/src/testing/e2e/parity.ts +13 -0
@@ -0,0 +1,113 @@
1
+ /**
2
+ * OpenTelemetry adapters for the router.
3
+ *
4
+ * Two adapters, two surfaces — matching the split in instrument.ts:
5
+ *
6
+ * - createOTelTracing(tracer): the OTel adapter for the `tracing` SLOT — the
7
+ * canonical phase-span layer. It bridges observePhase's callback boundary
8
+ * onto OTel's callback-bound `startActiveSpan`, so the router's phase spans
9
+ * (rango.request/middleware/loader/render/ssr) nest by async context and the
10
+ * loader's own OTel spans (db/fetch) land under rango.loader. This is the
11
+ * OTel equivalent of createCloudflareTracing — pass it to
12
+ * `createRouter({ tracing })`.
13
+ *
14
+ * - createOTelSink(tracer): the OTel adapter for the `telemetry` SLOT — a
15
+ * TelemetrySink for the EVENT-shaped facts (handler errors, cache decisions,
16
+ * revalidation decisions, timeouts, origin rejections). It emits one instant
17
+ * OTel span per fact. It deliberately does NOT emit request/loader phase
18
+ * spans: those are owned by the tracing slot (createOTelTracing) so the two
19
+ * layers don't produce duplicate rango.request / rango.loader spans.
20
+ *
21
+ * The core router stays OTel-agnostic — these adapters accept a standard OTel
22
+ * Tracer (structurally typed, no import needed) and bridge the gap.
23
+ *
24
+ * Usage:
25
+ * import { trace } from "@opentelemetry/api";
26
+ * import { createRouter, createOTelTracing, createOTelSink } from "@rangojs/router";
27
+ *
28
+ * const tracer = trace.getTracer("my-app");
29
+ * const router = createRouter({
30
+ * tracing: createOTelTracing(tracer), // phase spans (callback-bound)
31
+ * telemetry: createOTelSink(tracer), // discrete-fact instant spans
32
+ * });
33
+ *
34
+ * Faithful nesting requires an OTel async context manager
35
+ * (AsyncLocalStorageContextManager) configured in your OTel setup — standard for
36
+ * any startActiveSpan-based instrumentation.
37
+ */
38
+ import type { TelemetrySink } from "./telemetry.js";
39
+ import type { RouterTracingConfig, TracingToggleOptions } from "./tracing.js";
40
+ /**
41
+ * Minimal Span interface compatible with @opentelemetry/api Span.
42
+ * Only the methods used by the adapters are declared.
43
+ */
44
+ export interface OTelSpan {
45
+ setAttribute(key: string, value: string | number | boolean): OTelSpan | void;
46
+ setStatus(status: {
47
+ code: number;
48
+ message?: string;
49
+ }): OTelSpan | void;
50
+ recordException(exception: Error): void;
51
+ end(): void;
52
+ }
53
+ /**
54
+ * Minimal Tracer interface for the EVENT sink (createOTelSink): only `startSpan`
55
+ * is used (one instant span per discrete fact). Kept narrow so a custom,
56
+ * event-only tracer that does not implement `startActiveSpan` still satisfies it.
57
+ * The real `@opentelemetry/api` Tracer has both methods, so it satisfies this and
58
+ * `OTelActiveSpanTracer` below.
59
+ */
60
+ export interface OTelTracer {
61
+ startSpan(name: string, options?: {
62
+ attributes?: Record<string, string | number | boolean>;
63
+ }): OTelSpan;
64
+ }
65
+ /**
66
+ * Minimal Tracer interface for the PHASE-SPAN adapter (createOTelTracing): only
67
+ * `startActiveSpan` is used (callback-bound, so the span is active for the work
68
+ * and child spans nest). Declared separately from `OTelTracer` so each factory
69
+ * requires exactly the method it calls.
70
+ */
71
+ export interface OTelActiveSpanTracer {
72
+ startActiveSpan<T>(name: string, fn: (span: OTelSpan) => T): T;
73
+ }
74
+ /**
75
+ * Options for createOTelTracing. Alias of the shared {@link TracingToggleOptions}
76
+ * (`enabled` master switch + per-phase `spans` toggles); the name is public API.
77
+ */
78
+ export type OTelTracingOptions = TracingToggleOptions;
79
+ /**
80
+ * Create the tracing config that maps the router's phases onto OTel spans via
81
+ * `tracer.startActiveSpan`, which runs the work inside the span's active context
82
+ * (so child spans nest) and returns the work's value unchanged. The span ends
83
+ * when that value — or, for async work, the returned promise — settles, matching
84
+ * observePhase's contract. When the work throws or rejects, the exception is
85
+ * recorded and the span status is set to ERROR before it ends, so a failed phase
86
+ * stays visible in the trace (the old createOTelSink error path is preserved here
87
+ * now that phase spans live in this adapter). Pass the result to
88
+ * `createRouter({ tracing })`.
89
+ *
90
+ * @see createCloudflareTracing (`@rangojs/router/cloudflare`) for the same slot
91
+ * using Cloudflare Workers native custom spans.
92
+ */
93
+ export declare function createOTelTracing(tracer: OTelActiveSpanTracer, options?: OTelTracingOptions): RouterTracingConfig;
94
+ /**
95
+ * Create a TelemetrySink that maps the router's discrete-fact events to instant
96
+ * OTel spans. One span per fact; no duration spans.
97
+ *
98
+ * Fact mapping:
99
+ * - handler.error -> "rango.handler.error" (error)
100
+ * - cache.decision -> "rango.cache.decision"
101
+ * - revalidation.decision -> "rango.revalidation.decision"
102
+ * - request.timeout -> "rango.request.timeout" (error)
103
+ * - request.origin-rejected -> "rango.request.origin-rejected" (error)
104
+ *
105
+ * Request and loader PHASE spans are intentionally NOT emitted here — they are
106
+ * owned by the tracing slot (createOTelTracing) so the two layers cannot produce
107
+ * duplicate rango.request / rango.loader spans. request.start/end and
108
+ * loader.start/end events are no-ops for this sink.
109
+ *
110
+ * Attributes use the `rango.*` namespace for router-specific data and
111
+ * `http.method` / `http.route` for HTTP semantics.
112
+ */
113
+ export declare function createOTelSink(tracer: OTelTracer): TelemetrySink;
@@ -0,0 +1,215 @@
1
+ /**
2
+ * Router Telemetry Sink
3
+ *
4
+ * Internal event model for structured lifecycle events.
5
+ * The sink is optional and zero-cost when not configured.
6
+ *
7
+ * Emit points:
8
+ * - request.start / request.end (match-handlers.ts)
9
+ * - request.error (match-handlers.ts catch blocks)
10
+ * - request.origin-rejected (rsc/handler.ts origin guard)
11
+ * - loader.start / loader.end / loader.error (loader-resolution.ts)
12
+ * - handler.error (trackHandler catch, segment-resolution/helpers.ts)
13
+ * - cache.decision (cache-lookup middleware)
14
+ * - revalidation.decision (revalidation evaluation)
15
+ */
16
+ interface BaseEvent {
17
+ /** Monotonic timestamp from performance.now() */
18
+ timestamp: number;
19
+ /** Request ID (from header or generated) */
20
+ requestId?: string;
21
+ }
22
+ export interface RequestStartEvent extends BaseEvent {
23
+ type: "request.start";
24
+ method: string;
25
+ pathname: string;
26
+ /** "match" for full document requests, "matchPartial" for navigation */
27
+ transaction: "match" | "matchPartial";
28
+ isPartial: boolean;
29
+ }
30
+ export interface RequestEndEvent extends BaseEvent {
31
+ type: "request.end";
32
+ method: string;
33
+ pathname: string;
34
+ transaction: "match" | "matchPartial";
35
+ durationMs: number;
36
+ segmentCount: number;
37
+ cacheHit: boolean;
38
+ /**
39
+ * HTTP status when a Response ended the transaction — a thrown-Response
40
+ * short-circuit (redirect / auth gate carries the Response's status, e.g. 302),
41
+ * or dispatch()'s final response status. Absent for a normal render completion:
42
+ * the Response is built after match(), so match()/matchPartial() have no status
43
+ * to stamp there. Lets a sink split 3xx short-circuits from 2xx completions.
44
+ */
45
+ status?: number;
46
+ }
47
+ export interface RequestErrorEvent extends BaseEvent {
48
+ type: "request.error";
49
+ method: string;
50
+ pathname: string;
51
+ transaction: "match" | "matchPartial";
52
+ error: Error;
53
+ phase: string;
54
+ durationMs: number;
55
+ }
56
+ export interface LoaderStartEvent extends BaseEvent {
57
+ type: "loader.start";
58
+ segmentId: string;
59
+ loaderName: string;
60
+ pathname: string;
61
+ }
62
+ export interface LoaderEndEvent extends BaseEvent {
63
+ type: "loader.end";
64
+ segmentId: string;
65
+ loaderName: string;
66
+ pathname: string;
67
+ durationMs: number;
68
+ ok: boolean;
69
+ }
70
+ export interface LoaderErrorEvent extends BaseEvent {
71
+ type: "loader.error";
72
+ segmentId: string;
73
+ loaderName: string;
74
+ pathname: string;
75
+ error: Error;
76
+ handledByBoundary: boolean;
77
+ }
78
+ export interface HandlerErrorEvent extends BaseEvent {
79
+ type: "handler.error";
80
+ segmentId?: string;
81
+ segmentType?: string;
82
+ error: Error;
83
+ handledByBoundary: boolean;
84
+ pathname?: string;
85
+ routeKey?: string;
86
+ params?: Record<string, string>;
87
+ }
88
+ /**
89
+ * Per-segment (or coarse route-level) cache status carried on the
90
+ * cache.decision telemetry event and the X-Rango-Cache debug header.
91
+ *
92
+ * v1 is COARSE: the router's pipeline tracks cache decisions at the
93
+ * route/entry level (cacheHit/cacheSource/shouldRevalidate), not per
94
+ * individual segment. The `segments` array therefore contains a single
95
+ * route-level entry keyed by the route key. The shape is forward-compatible
96
+ * with genuine per-segment status if the pipeline later exposes it.
97
+ */
98
+ export type CacheSegmentStatus = "hit" | "miss" | "stale" | "prerendered" | "passthrough";
99
+ export interface CacheSegmentSignal {
100
+ /** Segment id (v1: the route key, since status is route-level). */
101
+ id: string;
102
+ /** Segment type (v1: "route" for the coarse route-level entry). */
103
+ type: string;
104
+ /** Resolved cache status for this segment. */
105
+ cacheStatus: CacheSegmentStatus;
106
+ /** Whether stale-while-revalidate was triggered for this segment. */
107
+ shouldRevalidate?: boolean;
108
+ }
109
+ export interface CacheDecisionEvent extends BaseEvent {
110
+ type: "cache.decision";
111
+ pathname: string;
112
+ routeKey: string;
113
+ hit: boolean;
114
+ /** Whether stale-while-revalidate was triggered */
115
+ shouldRevalidate: boolean;
116
+ source?: "runtime" | "prerender";
117
+ /**
118
+ * Optional per-segment (v1: coarse route-level) cache status. Present only
119
+ * when telemetry or the debug cache signal is enabled. Optional so existing
120
+ * sinks are unaffected.
121
+ */
122
+ segments?: CacheSegmentSignal[];
123
+ }
124
+ export interface RevalidationDecisionEvent extends BaseEvent {
125
+ type: "revalidation.decision";
126
+ segmentId: string;
127
+ pathname: string;
128
+ routeKey: string;
129
+ shouldRevalidate: boolean;
130
+ }
131
+ export interface RequestTimeoutEvent extends BaseEvent {
132
+ type: "request.timeout";
133
+ phase: import("./timeout.js").TimeoutPhase;
134
+ pathname: string;
135
+ routeKey?: string;
136
+ actionId?: string;
137
+ durationMs: number;
138
+ customHandler: boolean;
139
+ }
140
+ export interface OriginCheckRejectedEvent extends BaseEvent {
141
+ type: "request.origin-rejected";
142
+ method: string;
143
+ pathname: string;
144
+ phase: import("../rsc/origin-guard.js").OriginCheckPhase;
145
+ origin: string | null;
146
+ host: string | null;
147
+ }
148
+ export type TelemetryEvent = RequestStartEvent | RequestEndEvent | RequestErrorEvent | LoaderStartEvent | LoaderEndEvent | LoaderErrorEvent | HandlerErrorEvent | CacheDecisionEvent | RevalidationDecisionEvent | RequestTimeoutEvent | OriginCheckRejectedEvent;
149
+ /**
150
+ * Derive the coarse, route-level cache status from pipeline cache state.
151
+ *
152
+ * v1 mapping (route-level — see CacheSegmentSignal):
153
+ * - prerender hit -> "prerendered"
154
+ * - runtime hit + shouldRevalidate (SWR) -> "stale"
155
+ * - runtime hit -> "hit"
156
+ * - no hit -> "miss"
157
+ *
158
+ * Note: "passthrough" is a build-time prerender concept (a route opts out of
159
+ * being prerendered for some params). At runtime a passthrough route renders
160
+ * fresh and is indistinguishable from a normal miss in the pipeline state, so
161
+ * v1 reports it as "miss". The "passthrough" status remains in the type union
162
+ * for forward compatibility.
163
+ */
164
+ export declare function deriveCacheStatus(state: {
165
+ cacheHit: boolean;
166
+ cacheSource?: "runtime" | "prerender";
167
+ shouldRevalidate?: boolean;
168
+ }): CacheSegmentStatus;
169
+ /**
170
+ * Build the coarse route-level cache signal array (a single entry keyed by
171
+ * the route key). Used for both the cache.decision telemetry event and the
172
+ * X-Rango-Cache debug header.
173
+ */
174
+ export declare function buildCacheSignalSegments(routeKey: string, state: {
175
+ cacheHit: boolean;
176
+ cacheSource?: "runtime" | "prerender";
177
+ shouldRevalidate?: boolean;
178
+ }): CacheSegmentSignal[];
179
+ /**
180
+ * Serialize cache signal segments into the X-Rango-Cache header value:
181
+ * `<segId>=<status>, <segId2>=<status2>`.
182
+ */
183
+ export declare function formatCacheSignalHeader(segments: CacheSegmentSignal[]): string;
184
+ /**
185
+ * Telemetry sink receives structured lifecycle events from the router.
186
+ * Implement this interface to integrate with any observability backend.
187
+ *
188
+ * All methods are fire-and-forget — exceptions are caught and logged.
189
+ */
190
+ export interface TelemetrySink {
191
+ emit(event: TelemetryEvent): void;
192
+ }
193
+ /**
194
+ * Returns the configured sink, or the no-op singleton.
195
+ * Call sites use this so they don't need null checks.
196
+ */
197
+ export declare function resolveSink(sink: TelemetrySink | undefined): TelemetrySink;
198
+ /**
199
+ * Safe emit — catches any error thrown by the sink to prevent
200
+ * telemetry failures from affecting request handling.
201
+ */
202
+ export declare function safeEmit(sink: TelemetrySink, event: TelemetryEvent): void;
203
+ /**
204
+ * Get or create a request ID for telemetry correlation.
205
+ * Checks standard headers first (x-rsc-router-request-id, x-request-id,
206
+ * cf-ray), then generates an internal ID when none is present.
207
+ * Generated IDs use format "t-{base36}" to distinguish from header values.
208
+ */
209
+ export declare function getRequestId(request: Request): string;
210
+ /**
211
+ * Built-in console sink that logs events in a structured format.
212
+ * Designed as the default sink for development / debugging.
213
+ */
214
+ export declare function createConsoleSink(): TelemetrySink;
215
+ export {};
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Router Timeout
3
+ *
4
+ * Types, resolution logic, and helpers for request-level timeouts.
5
+ * Timeouts wrap action execution and render-start phases with
6
+ * a Promise.race mechanism, returning 504 on expiry.
7
+ */
8
+ export interface RouterTimeouts {
9
+ /** Timeout for server action execution (ms). */
10
+ actionMs?: number;
11
+ /** Timeout for initial render/response production (ms). */
12
+ renderStartMs?: number;
13
+ /** Timeout for idle streaming after render starts (ms). Reserved for PR 2. */
14
+ streamIdleMs?: number;
15
+ }
16
+ export type TimeoutPhase = "action" | "render-start" | "stream-idle";
17
+ export interface TimeoutContext<TEnv = any> {
18
+ phase: TimeoutPhase;
19
+ request: Request;
20
+ url: URL;
21
+ env: TEnv;
22
+ routeKey?: string;
23
+ actionId?: string;
24
+ durationMs: number;
25
+ }
26
+ export type OnTimeoutCallback<TEnv = any> = (ctx: TimeoutContext<TEnv>) => Response | Promise<Response>;
27
+ export interface ResolvedTimeouts {
28
+ actionMs: number | undefined;
29
+ renderStartMs: number | undefined;
30
+ streamIdleMs: number | undefined;
31
+ }
32
+ /**
33
+ * Merge the `timeout` shorthand with the structured `timeouts` object.
34
+ *
35
+ * - `timeout` applies to `actionMs` and `renderStartMs` (NOT `streamIdleMs`).
36
+ * - Explicit `timeouts.*` values override the shorthand.
37
+ * - Returns `undefined` for any phase that has no configured value.
38
+ */
39
+ export declare function resolveTimeouts(timeout?: number, timeouts?: RouterTimeouts): ResolvedTimeouts;
40
+ export declare class RouterTimeoutError extends Error {
41
+ name: "RouterTimeoutError";
42
+ phase: TimeoutPhase;
43
+ durationMs: number;
44
+ constructor(phase: TimeoutPhase, durationMs: number);
45
+ }
46
+ type TimeoutResult<T> = {
47
+ result: T;
48
+ timedOut: false;
49
+ } | {
50
+ timedOut: true;
51
+ durationMs: number;
52
+ };
53
+ /**
54
+ * Race an operation against a deadline.
55
+ *
56
+ * Returns a discriminated union so callers handle the timeout case
57
+ * without try/catch. Non-timeout errors from the operation re-throw.
58
+ *
59
+ * When `timeoutMs` is `undefined` or `<= 0`, the operation runs
60
+ * without any deadline (pass-through).
61
+ */
62
+ export declare function withTimeout<T>(operation: Promise<T>, timeoutMs: number | undefined, phase: TimeoutPhase): Promise<TimeoutResult<T>>;
63
+ /**
64
+ * Create the default 504 response for a timed-out request.
65
+ * Includes `X-Rango-Timeout-Phase` header for observability.
66
+ */
67
+ export declare function createDefaultTimeoutResponse(phase: TimeoutPhase): Response;
68
+ export {};
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Span tracing hook (platform-agnostic).
3
+ *
4
+ * The core router emits its existing performance phases (request, middleware, action,
5
+ * loaders, render, ssr) as spans by calling traceSpan() at a small set of
6
+ * execution boundaries. When no tracing is configured the call is a direct
7
+ * pass-through: fn is invoked with a no-op span, with no wrapper and no
8
+ * allocation, so a non-traced request behaves exactly as before.
9
+ *
10
+ * A platform integration supplies a SpanRunner that wraps fn in a real span.
11
+ * Two runners ship: the Cloudflare one (createCloudflareTracing in
12
+ * src/cloudflare/tracing.ts), which bridges onto executionContext.tracing.
13
+ * enterSpan, and the OTel one (createOTelTracing in router/telemetry-otel.ts),
14
+ * which bridges onto tracer.startActiveSpan. Both wrap the actual work — not a
15
+ * post-hoc event — so spans nest by async context and the platform's automatic
16
+ * spans (KV/D1/fetch) nest under the right phase.
17
+ *
18
+ * traceSpan() below is the low-level wrap primitive. It is INTERNAL: the only
19
+ * caller is observePhase() (instrument.ts), the single phase-instrumentation
20
+ * API, which co-emits the span AND the debugPerformance perf metric from one
21
+ * wrap site (or just the span, for metric:false phases) so the two surfaces
22
+ * can't drift. Every router phase routes through observePhase via the PHASES
23
+ * registry; do not call traceSpan directly from new code.
24
+ *
25
+ * Phase coverage (all via observePhase): rango.request (span-only; handler:total
26
+ * metered directly), rango.middleware (span-only incl. intercept middleware;
27
+ * pre/post metered directly), rango.action (action:<id>; server-action
28
+ * execution, JS + no-JS/PE), rango.loader (loader:<id>; single metering site at
29
+ * useLoader, plus the fetchable path), rango.handler (span-only, one per segment
30
+ * route/layout handler execution; the handler:<id> perf metric is owned by the
31
+ * track() at the call site), rango.render (render:total:<route>; normal AND
32
+ * action-revalidation renders), rango.ssr (ssr:render-html).
33
+ *
34
+ * Span-duration caveat (best-effort, never buffers): a span ends when its
35
+ * callback's value (or promise) settles. For the streaming phases (request,
36
+ * render, ssr) that is when the Response / HTML / RSC stream is CONSTRUCTED, not
37
+ * when the body finishes draining — instrumentation never wraps or buffers the
38
+ * response body, so it cannot regress response latency or streaming. A loader /
39
+ * Suspense child that resolves while the body streams therefore keeps a
40
+ * rango.loader span that can extend past its render parent; overlapping spans are
41
+ * valid (the loader really did take that long). Phase spans bound the work up to
42
+ * stream-handoff, which is also what the co-emitted perf metric measures.
43
+ *
44
+ * Both shipped runners (Cloudflare, OTel) keep the core agnostic: the
45
+ * platform-specific bridge lives at the edge behind the SpanRunner contract.
46
+ */
47
+ /**
48
+ * Minimal span handle passed to traced work. Structurally compatible with both
49
+ * Cloudflare's `Span` and OTel's `Span` (only setAttribute is used here).
50
+ */
51
+ export interface TraceSpan {
52
+ setAttribute(key: string, value: string | number | boolean): void;
53
+ }
54
+ /**
55
+ * Wraps a unit of work in a span. A runner MUST invoke fn exactly once, pass it
56
+ * a span, return fn's result unchanged, and propagate thrown errors / rejected
57
+ * promises unchanged. When fn returns a promise the span ends once it settles.
58
+ */
59
+ export type SpanRunner = <T>(name: string, fn: (span: TraceSpan) => T) => T;
60
+ /** The router phases that can be wrapped in a span. */
61
+ export type TracePhase = "request" | "middleware" | "action" | "loader" | "handler" | "render" | "ssr";
62
+ /** Per-phase span toggles. Omitted phases default to enabled. */
63
+ export interface TracePhaseToggles {
64
+ request?: boolean;
65
+ middleware?: boolean;
66
+ action?: boolean;
67
+ loader?: boolean;
68
+ handler?: boolean;
69
+ render?: boolean;
70
+ ssr?: boolean;
71
+ }
72
+ /**
73
+ * The option pair shared by every tracing factory (enabled master switch +
74
+ * per-phase span toggles). Extended by OTelTracingOptions,
75
+ * CloudflareTracingOptions, VercelTracingOptions, and RouterTracingConfig so
76
+ * a phase added to TracePhaseToggles propagates everywhere from one place.
77
+ */
78
+ export interface TracingToggleOptions {
79
+ /** Master switch. Defaults to true. */
80
+ enabled?: boolean;
81
+ /** Per-phase span toggles. Omitted phases default to enabled. */
82
+ spans?: TracePhaseToggles;
83
+ }
84
+ /**
85
+ * Value passed to `createRouter({ tracing })`. Produced by a platform factory
86
+ * such as `createCloudflareTracing()`.
87
+ */
88
+ export interface RouterTracingConfig extends TracingToggleOptions {
89
+ /** Platform span runner. */
90
+ runner: SpanRunner;
91
+ }
92
+ /**
93
+ * Resolved tracing state stored on the router/request context. `undefined`
94
+ * means tracing is fully disabled and every traceSpan() call is a pass-through.
95
+ */
96
+ export interface ResolvedTracing {
97
+ runner: SpanRunner;
98
+ phases: Record<TracePhase, boolean>;
99
+ }
100
+ /** Shared no-op span. setAttribute is a no-op so disabled call sites stay free. */
101
+ export declare const NOOP_TRACE_SPAN: TraceSpan;
102
+ /**
103
+ * Resolve a user-supplied tracing config into the fast internal form, or
104
+ * `undefined` when tracing is off (no config, `enabled: false`, or no runner).
105
+ */
106
+ export declare function resolveTracing(config: RouterTracingConfig | undefined): ResolvedTracing | undefined;
107
+ /**
108
+ * Wrap `fn` in a span for `phase`. When tracing is off (or the phase is
109
+ * disabled) fn runs directly with a no-op span — identical to the untraced
110
+ * path. Otherwise the platform runner wraps fn so the span covers the real
111
+ * work and nests by async context.
112
+ */
113
+ export declare function traceSpan<T>(tracing: ResolvedTracing | undefined, phase: TracePhase, name: string, fn: (span: TraceSpan) => T): T;
114
+ /**
115
+ * Run `fn` once and invoke `onSettle` exactly once when it terminates — on a
116
+ * synchronous return, a synchronous throw, an async resolution, or an async
117
+ * rejection. `onSettle` receives the error (or `undefined` on success). fn's
118
+ * value is returned and errors propagate unchanged.
119
+ *
120
+ * Centralizes the run-once-then-settle control flow shared by the two span
121
+ * surfaces: observePhase records the perf metric on settle, and the OTel runner
122
+ * ends (or error-marks) the span on settle. The Cloudflare runner delegates
123
+ * settling to enterSpan, so it does not use this.
124
+ */
125
+ export declare function runThenSettle<T>(fn: () => T, onSettle: (error: unknown) => void): T;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Runtime Trie Matching
3
+ *
4
+ * Walks the pre-built trie by path segments in O(path_length) time.
5
+ * Falls back to null when no match is found (caller uses regex fallback).
6
+ */
7
+ import type { TrieNode, NegotiateVariant } from "../build/route-trie.js";
8
+ export interface TrieMatchResult {
9
+ /** Route name */
10
+ routeKey: string;
11
+ /** Static prefix of the matched entry */
12
+ sp: string;
13
+ /** Matched route params */
14
+ params: Record<string, string>;
15
+ /** Redirect target if trailing slash requires it */
16
+ redirectTo?: string;
17
+ /** Route has pre-rendered data available */
18
+ pr?: true;
19
+ /** Passthrough: handler kept for live fallback on unknown params */
20
+ pt?: true;
21
+ /** Response type for non-RSC routes (json, text, image, any) */
22
+ responseType?: string;
23
+ /** Negotiate variants: response-type routes sharing this path */
24
+ negotiateVariants?: NegotiateVariant[];
25
+ /** RSC-first: RSC route was defined before response-type variants */
26
+ rscFirst?: true;
27
+ }
28
+ /**
29
+ * Try to match a pathname against the trie.
30
+ * Returns null if no match found (caller should fall back to regex).
31
+ */
32
+ export declare function tryTrieMatch(trie: TrieNode | null, pathname: string): TrieMatchResult | null;
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Router Internal Types
3
+ *
4
+ * Shared types for router module utilities.
5
+ */
6
+ import type { ReactNode } from "react";
7
+ import type { EntryData, InterceptEntry, InterceptSelectorContext } from "../server/context";
8
+ import type { ErrorPhase, LoaderDataResult, ResolvedSegment, ErrorBoundaryHandler, NotFoundBoundaryHandler } from "../types";
9
+ export interface SegmentRevalidationResult {
10
+ segments: ResolvedSegment[];
11
+ matchedIds: string[];
12
+ }
13
+ export type ActionContext = {
14
+ actionId?: string;
15
+ actionUrl?: URL;
16
+ actionResult?: any;
17
+ formData?: FormData;
18
+ };
19
+ export interface SegmentResolutionDeps<TEnv = any> {
20
+ wrapLoaderPromise: <T>(promise: Promise<T>, entry: EntryData, segmentId: string, pathname: string, errorContext?: {
21
+ request: Request;
22
+ url: URL;
23
+ routeKey?: string;
24
+ params?: Record<string, string>;
25
+ env?: TEnv;
26
+ isPartial?: boolean;
27
+ requestStartTime?: number;
28
+ }) => Promise<LoaderDataResult<T>>;
29
+ trackHandler: <T>(promise: Promise<T>, errorContext?: {
30
+ segmentId?: string;
31
+ segmentType?: string;
32
+ }) => Promise<T>;
33
+ findNearestErrorBoundary: (entry: EntryData | null) => ReactNode | ErrorBoundaryHandler | null;
34
+ findNearestNotFoundBoundary: (entry: EntryData | null) => ReactNode | NotFoundBoundaryHandler | null;
35
+ notFoundComponent?: ReactNode | ((props: {
36
+ pathname: string;
37
+ }) => ReactNode);
38
+ callOnError: (error: unknown, phase: ErrorPhase, context: any) => void;
39
+ /**
40
+ * Router-level default for the per-segment `transition({ viewTransition })`
41
+ * flag, from createRouter({ viewTransition }). Resolved into each segment's
42
+ * transition config during resolution (only `false` is stamped) so the render
43
+ * gate reads the boundary decision off the segment on both server and client.
44
+ * Undefined is treated as "auto" (wrap).
45
+ */
46
+ viewTransitionDefault?: "auto" | false;
47
+ }
48
+ export interface MatchApiDeps<TEnv = any> {
49
+ findMatch: (pathname: string, ms?: any) => any;
50
+ getMetricsStore: () => any;
51
+ findInterceptForRoute: (routeKey: string, parentEntry: EntryData | null, selectorContext: InterceptSelectorContext | null, isAction: boolean) => {
52
+ intercept: InterceptEntry;
53
+ entry: EntryData;
54
+ } | null;
55
+ callOnError: SegmentResolutionDeps<TEnv>["callOnError"];
56
+ findNearestErrorBoundary: SegmentResolutionDeps<TEnv>["findNearestErrorBoundary"];
57
+ getRouteMap: () => Record<string, string>;
58
+ }
59
+ export type TitleDescriptor = string | {
60
+ template: string;
61
+ default: string;
62
+ } | {
63
+ absolute: string;
64
+ };
65
+ export type UnsetDescriptor = {
66
+ unset: string;
67
+ };
68
+ export type MetaDescriptorBase = {
69
+ charSet: "utf-8";
70
+ } | {
71
+ title: TitleDescriptor;
72
+ } | {
73
+ name: string;
74
+ content: string;
75
+ } | {
76
+ property: string;
77
+ content: string;
78
+ } | {
79
+ httpEquiv: string;
80
+ content: string;
81
+ } | {
82
+ "script:ld+json": LdJsonObject;
83
+ } | {
84
+ tagName: "meta" | "link";
85
+ [name: string]: string;
86
+ } | UnsetDescriptor | {
87
+ [name: string]: unknown;
88
+ };
89
+ export type MetaDescriptor = MetaDescriptorBase | Promise<MetaDescriptorBase>;
90
+ type LdJsonObject = {
91
+ [Key in string]: LdJsonValue;
92
+ } & {
93
+ [Key in string]?: LdJsonValue | undefined;
94
+ };
95
+ type LdJsonArray = LdJsonValue[] | readonly LdJsonValue[];
96
+ type LdJsonPrimitive = string | number | boolean | null;
97
+ type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
98
+ export {};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * URL param encode/decode at the route boundary.
3
+ *
4
+ * Extraction (decode): regex/trie matchers keep param values URL-encoded;
5
+ * `safeDecodeURIComponent` turns them back into raw strings so `ctx.params`
6
+ * matches the contract apps expect (Express/React Router/Fastify/Koa) and
7
+ * round-trips through reverse stay stable. Malformed %-encoding is
8
+ * preserved as-is so a broken URL doesn't crash matching.
9
+ *
10
+ * Reversal (encode): `encodePathSegment` escapes only what RFC 3986
11
+ * requires for a path segment — `/`, `?`, `#`, space, control chars,
12
+ * non-ASCII — and leaves pchar sub-delims (`@ : $ & + , ; =` and friends)
13
+ * readable. `encodeURIComponent` over-encodes for path segments, which
14
+ * makes generated URLs harder for humans to read in the address bar
15
+ * (e.g. mailbox IDs like `ivo@example.com` would become
16
+ * `ivo%40example.com` even though `@` is path-legal).
17
+ */
18
+ export declare function safeDecodeURIComponent(raw: string): string;
19
+ export declare function encodePathSegment(value: string): string;
20
+ /**
21
+ * Encode a catch-all remainder: encode each `/`-separated segment but keep the
22
+ * separators, so `a/b c` -> `a/b%20c` (not `a%2Fb%20c`). Shared by the reverse
23
+ * helper and the build-time prerender substitution so both produce identical
24
+ * URLs. `encode` defaults to the path-safe `encodePathSegment`.
25
+ */
26
+ export declare function encodePathRemainder(value: string, encode?: (segment: string) => string): string;