@rangojs/router 0.4.3 → 0.5.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 (420) hide show
  1. package/dist/types/browser/prefetch/cache.d.ts +31 -2
  2. package/dist/types/cache/cf/cf-cache-store.d.ts +2 -0
  3. package/dist/types/cache/types.d.ts +39 -6
  4. package/dist/types/route-definition/helpers-types.d.ts +5 -4
  5. package/dist/types/rsc/capture-queue.d.ts +19 -3
  6. package/dist/types/rsc/shell-build-manifest.d.ts +2 -2
  7. package/dist/types/rsc/shell-capture.d.ts +22 -2
  8. package/dist/types/rsc/shell-serve.d.ts +18 -12
  9. package/dist/types/static-handler.d.ts +15 -1
  10. package/dist/types/urls/path-helper-types.d.ts +6 -7
  11. package/dist/types.backup/__internal.d.ts +127 -0
  12. package/dist/types.backup/bin/rango.d.ts +1 -0
  13. package/dist/types.backup/browser/action-coordinator.d.ts +57 -0
  14. package/dist/types.backup/browser/action-fence.d.ts +33 -0
  15. package/dist/types.backup/browser/app-shell.d.ts +34 -0
  16. package/dist/types.backup/browser/app-version.d.ts +6 -0
  17. package/dist/types.backup/browser/connection-warmup.d.ts +31 -0
  18. package/dist/types.backup/browser/cookie-name.d.ts +66 -0
  19. package/dist/types.backup/browser/event-controller.d.ts +221 -0
  20. package/dist/types.backup/browser/history-state.d.ts +26 -0
  21. package/dist/types.backup/browser/index.d.ts +1 -0
  22. package/dist/types.backup/browser/intercept-utils.d.ts +30 -0
  23. package/dist/types.backup/browser/invalidate-client-cache.d.ts +17 -0
  24. package/dist/types.backup/browser/link-interceptor.d.ts +43 -0
  25. package/dist/types.backup/browser/logging.d.ts +33 -0
  26. package/dist/types.backup/browser/merge-segment-loaders.d.ts +38 -0
  27. package/dist/types.backup/browser/navigation-bridge.d.ts +27 -0
  28. package/dist/types.backup/browser/navigation-client.d.ts +17 -0
  29. package/dist/types.backup/browser/navigation-store-handle.d.ts +25 -0
  30. package/dist/types.backup/browser/navigation-store.d.ts +95 -0
  31. package/dist/types.backup/browser/navigation-transaction.d.ts +75 -0
  32. package/dist/types.backup/browser/network-error-handler.d.ts +35 -0
  33. package/dist/types.backup/browser/partial-update.d.ts +61 -0
  34. package/dist/types.backup/browser/prefetch/cache.d.ts +183 -0
  35. package/dist/types.backup/browser/prefetch/fetch.d.ts +52 -0
  36. package/dist/types.backup/browser/prefetch/observer.d.ts +27 -0
  37. package/dist/types.backup/browser/prefetch/policy.d.ts +13 -0
  38. package/dist/types.backup/browser/prefetch/queue.d.ts +48 -0
  39. package/dist/types.backup/browser/prefetch/resource-ready.d.ts +28 -0
  40. package/dist/types.backup/browser/rango-state.d.ts +52 -0
  41. package/dist/types.backup/browser/react/Link.d.ts +140 -0
  42. package/dist/types.backup/browser/react/NavigationProvider.d.ts +88 -0
  43. package/dist/types.backup/browser/react/ScrollRestoration.d.ts +78 -0
  44. package/dist/types.backup/browser/react/context.d.ts +54 -0
  45. package/dist/types.backup/browser/react/filter-segment-order.d.ts +35 -0
  46. package/dist/types.backup/browser/react/index.d.ts +1 -0
  47. package/dist/types.backup/browser/react/location-state-shared.d.ts +162 -0
  48. package/dist/types.backup/browser/react/location-state.d.ts +29 -0
  49. package/dist/types.backup/browser/react/mount-context.d.ts +23 -0
  50. package/dist/types.backup/browser/react/nonce-context.d.ts +14 -0
  51. package/dist/types.backup/browser/react/shallow-equal.d.ts +5 -0
  52. package/dist/types.backup/browser/react/use-action.d.ts +61 -0
  53. package/dist/types.backup/browser/react/use-handle.d.ts +21 -0
  54. package/dist/types.backup/browser/react/use-href.d.ts +32 -0
  55. package/dist/types.backup/browser/react/use-link-status.d.ts +36 -0
  56. package/dist/types.backup/browser/react/use-mount.d.ts +24 -0
  57. package/dist/types.backup/browser/react/use-navigation.d.ts +15 -0
  58. package/dist/types.backup/browser/react/use-params.d.ts +21 -0
  59. package/dist/types.backup/browser/react/use-pathname.d.ts +13 -0
  60. package/dist/types.backup/browser/react/use-reverse.d.ts +40 -0
  61. package/dist/types.backup/browser/react/use-router.d.ts +23 -0
  62. package/dist/types.backup/browser/react/use-search-params.d.ts +19 -0
  63. package/dist/types.backup/browser/react/use-segments.d.ts +29 -0
  64. package/dist/types.backup/browser/response-adapter.d.ts +58 -0
  65. package/dist/types.backup/browser/rsc-router.d.ts +141 -0
  66. package/dist/types.backup/browser/scroll-restoration.d.ts +103 -0
  67. package/dist/types.backup/browser/segment-reconciler.d.ts +74 -0
  68. package/dist/types.backup/browser/segment-structure-assert.d.ts +16 -0
  69. package/dist/types.backup/browser/server-action-bridge.d.ts +29 -0
  70. package/dist/types.backup/browser/types.d.ts +530 -0
  71. package/dist/types.backup/browser/validate-redirect-origin.d.ts +28 -0
  72. package/dist/types.backup/build/collect-fallback-refs.d.ts +5 -0
  73. package/dist/types.backup/build/generate-manifest.d.ts +100 -0
  74. package/dist/types.backup/build/generate-route-types.d.ts +8 -0
  75. package/dist/types.backup/build/index.d.ts +21 -0
  76. package/dist/types.backup/build/prefix-tree-utils.d.ts +56 -0
  77. package/dist/types.backup/build/route-trie.d.ts +89 -0
  78. package/dist/types.backup/build/route-types/ast-helpers.d.ts +3 -0
  79. package/dist/types.backup/build/route-types/ast-route-extraction.d.ts +13 -0
  80. package/dist/types.backup/build/route-types/codegen.d.ts +16 -0
  81. package/dist/types.backup/build/route-types/include-resolution.d.ts +74 -0
  82. package/dist/types.backup/build/route-types/param-extraction.d.ts +13 -0
  83. package/dist/types.backup/build/route-types/per-module-writer.d.ts +18 -0
  84. package/dist/types.backup/build/route-types/router-processing.d.ts +82 -0
  85. package/dist/types.backup/build/route-types/scan-filter.d.ts +17 -0
  86. package/dist/types.backup/build/route-types/source-scan.d.ts +13 -0
  87. package/dist/types.backup/build/runtime-discovery.d.ts +24 -0
  88. package/dist/types.backup/cache/background-task.d.ts +21 -0
  89. package/dist/types.backup/cache/cache-error.d.ts +71 -0
  90. package/dist/types.backup/cache/cache-key-utils.d.ts +35 -0
  91. package/dist/types.backup/cache/cache-policy.d.ts +59 -0
  92. package/dist/types.backup/cache/cache-runtime.d.ts +51 -0
  93. package/dist/types.backup/cache/cache-scope.d.ts +134 -0
  94. package/dist/types.backup/cache/cache-tag.d.ts +79 -0
  95. package/dist/types.backup/cache/cf/cf-base64.d.ts +4 -0
  96. package/dist/types.backup/cache/cf/cf-cache-constants.d.ts +105 -0
  97. package/dist/types.backup/cache/cf/cf-cache-store.d.ts +481 -0
  98. package/dist/types.backup/cache/cf/cf-cache-types.d.ts +300 -0
  99. package/dist/types.backup/cache/cf/cf-kv-utils.d.ts +22 -0
  100. package/dist/types.backup/cache/cf/cf-tag-marker-memo.d.ts +15 -0
  101. package/dist/types.backup/cache/cf/index.d.ts +3 -0
  102. package/dist/types.backup/cache/document-cache.d.ts +69 -0
  103. package/dist/types.backup/cache/handle-capture.d.ts +23 -0
  104. package/dist/types.backup/cache/handle-snapshot.d.ts +39 -0
  105. package/dist/types.backup/cache/index.d.ts +7 -0
  106. package/dist/types.backup/cache/memory-segment-store.d.ts +163 -0
  107. package/dist/types.backup/cache/profile-registry.d.ts +40 -0
  108. package/dist/types.backup/cache/read-through-swr.d.ts +60 -0
  109. package/dist/types.backup/cache/segment-codec.d.ts +78 -0
  110. package/dist/types.backup/cache/shell-snapshot.d.ts +162 -0
  111. package/dist/types.backup/cache/tag-invalidation.d.ts +74 -0
  112. package/dist/types.backup/cache/taint.d.ts +71 -0
  113. package/dist/types.backup/cache/types.d.ts +407 -0
  114. package/dist/types.backup/cache/vercel/index.d.ts +1 -0
  115. package/dist/types.backup/cache/vercel/vercel-cache-store.d.ts +267 -0
  116. package/dist/types.backup/client.d.ts +184 -0
  117. package/dist/types.backup/client.rsc.d.ts +39 -0
  118. package/dist/types.backup/cloudflare/index.d.ts +7 -0
  119. package/dist/types.backup/cloudflare/tracing.d.ts +53 -0
  120. package/dist/types.backup/component-utils.d.ts +46 -0
  121. package/dist/types.backup/components/DefaultDocument.d.ts +13 -0
  122. package/dist/types.backup/context-var.d.ts +84 -0
  123. package/dist/types.backup/debug.d.ts +57 -0
  124. package/dist/types.backup/decode-loader-results.d.ts +5 -0
  125. package/dist/types.backup/default-error-boundary.d.ts +10 -0
  126. package/dist/types.backup/defer.d.ts +89 -0
  127. package/dist/types.backup/deps/browser.d.ts +1 -0
  128. package/dist/types.backup/deps/html-stream-client.d.ts +1 -0
  129. package/dist/types.backup/deps/html-stream-server.d.ts +1 -0
  130. package/dist/types.backup/deps/rsc.d.ts +1 -0
  131. package/dist/types.backup/deps/ssr.d.ts +1 -0
  132. package/dist/types.backup/encode-kv.d.ts +35 -0
  133. package/dist/types.backup/errors.d.ts +226 -0
  134. package/dist/types.backup/escape-script.d.ts +44 -0
  135. package/dist/types.backup/handle.d.ts +93 -0
  136. package/dist/types.backup/handles/MetaTags.d.ts +17 -0
  137. package/dist/types.backup/handles/Scripts.d.ts +38 -0
  138. package/dist/types.backup/handles/breadcrumbs.d.ts +43 -0
  139. package/dist/types.backup/handles/deferred-resolution.d.ts +53 -0
  140. package/dist/types.backup/handles/is-thenable.d.ts +12 -0
  141. package/dist/types.backup/handles/meta.d.ts +43 -0
  142. package/dist/types.backup/handles/script.d.ts +139 -0
  143. package/dist/types.backup/host/cookie-handler.d.ts +8 -0
  144. package/dist/types.backup/host/errors.d.ts +40 -0
  145. package/dist/types.backup/host/index.d.ts +33 -0
  146. package/dist/types.backup/host/pattern-matcher.d.ts +30 -0
  147. package/dist/types.backup/host/router.d.ts +12 -0
  148. package/dist/types.backup/host/testing.d.ts +41 -0
  149. package/dist/types.backup/host/types.d.ts +148 -0
  150. package/dist/types.backup/host/utils.d.ts +20 -0
  151. package/dist/types.backup/href-client.d.ts +214 -0
  152. package/dist/types.backup/index.d.ts +112 -0
  153. package/dist/types.backup/index.rsc.d.ts +51 -0
  154. package/dist/types.backup/internal-debug.d.ts +1 -0
  155. package/dist/types.backup/loader-store.d.ts +193 -0
  156. package/dist/types.backup/loader.d.ts +18 -0
  157. package/dist/types.backup/loader.rsc.d.ts +18 -0
  158. package/dist/types.backup/missing-id-error.d.ts +1 -0
  159. package/dist/types.backup/outlet-context.d.ts +12 -0
  160. package/dist/types.backup/outlet-provider.d.ts +12 -0
  161. package/dist/types.backup/prerender/build-shell-capture.d.ts +104 -0
  162. package/dist/types.backup/prerender/param-hash.d.ts +6 -0
  163. package/dist/types.backup/prerender/shell-manifest-key.d.ts +18 -0
  164. package/dist/types.backup/prerender/store.d.ts +62 -0
  165. package/dist/types.backup/prerender.d.ts +292 -0
  166. package/dist/types.backup/redirect-origin.d.ts +55 -0
  167. package/dist/types.backup/regex-escape.d.ts +6 -0
  168. package/dist/types.backup/render-error-thrower.d.ts +13 -0
  169. package/dist/types.backup/response-utils.d.ts +35 -0
  170. package/dist/types.backup/reverse.d.ts +206 -0
  171. package/dist/types.backup/root-error-boundary.d.ts +32 -0
  172. package/dist/types.backup/route-content-wrapper.d.ts +40 -0
  173. package/dist/types.backup/route-definition/dsl-helpers.d.ts +130 -0
  174. package/dist/types.backup/route-definition/helper-factories.d.ts +22 -0
  175. package/dist/types.backup/route-definition/helpers-types.d.ts +392 -0
  176. package/dist/types.backup/route-definition/index.d.ts +7 -0
  177. package/dist/types.backup/route-definition/redirect.d.ts +48 -0
  178. package/dist/types.backup/route-definition/resolve-handler-use.d.ts +19 -0
  179. package/dist/types.backup/route-definition/use-item-types.d.ts +1 -0
  180. package/dist/types.backup/route-definition.d.ts +1 -0
  181. package/dist/types.backup/route-map-builder.d.ts +127 -0
  182. package/dist/types.backup/route-name.d.ts +27 -0
  183. package/dist/types.backup/route-types.d.ts +172 -0
  184. package/dist/types.backup/router/basename.d.ts +10 -0
  185. package/dist/types.backup/router/content-negotiation.d.ts +91 -0
  186. package/dist/types.backup/router/debug-manifest.d.ts +7 -0
  187. package/dist/types.backup/router/error-handling.d.ts +76 -0
  188. package/dist/types.backup/router/find-match.d.ts +19 -0
  189. package/dist/types.backup/router/handler-context.d.ts +41 -0
  190. package/dist/types.backup/router/instrument.d.ts +161 -0
  191. package/dist/types.backup/router/intercept-resolution.d.ts +79 -0
  192. package/dist/types.backup/router/lazy-includes.d.ts +26 -0
  193. package/dist/types.backup/router/loader-resolution.d.ts +63 -0
  194. package/dist/types.backup/router/logging.d.ts +41 -0
  195. package/dist/types.backup/router/manifest.d.ts +8 -0
  196. package/dist/types.backup/router/match-api.d.ts +19 -0
  197. package/dist/types.backup/router/match-context.d.ts +184 -0
  198. package/dist/types.backup/router/match-handlers.d.ts +49 -0
  199. package/dist/types.backup/router/match-middleware/background-revalidation.d.ts +113 -0
  200. package/dist/types.backup/router/match-middleware/cache-lookup.d.ts +113 -0
  201. package/dist/types.backup/router/match-middleware/cache-store.d.ts +112 -0
  202. package/dist/types.backup/router/match-middleware/index.d.ts +80 -0
  203. package/dist/types.backup/router/match-middleware/intercept-resolution.d.ts +116 -0
  204. package/dist/types.backup/router/match-middleware/segment-resolution.d.ts +94 -0
  205. package/dist/types.backup/router/match-pipelines.d.ts +103 -0
  206. package/dist/types.backup/router/match-result.d.ts +114 -0
  207. package/dist/types.backup/router/metrics.d.ts +6 -0
  208. package/dist/types.backup/router/middleware-types.d.ts +74 -0
  209. package/dist/types.backup/router/middleware.d.ts +116 -0
  210. package/dist/types.backup/router/navigation-snapshot.d.ts +22 -0
  211. package/dist/types.backup/router/params-util.d.ts +8 -0
  212. package/dist/types.backup/router/parse-pattern.d.ts +38 -0
  213. package/dist/types.backup/router/pattern-matching.d.ts +169 -0
  214. package/dist/types.backup/router/prefetch-cache-ttl.d.ts +27 -0
  215. package/dist/types.backup/router/prefetch-limits.d.ts +20 -0
  216. package/dist/types.backup/router/prerender-match.d.ts +50 -0
  217. package/dist/types.backup/router/preview-match.d.ts +22 -0
  218. package/dist/types.backup/router/request-classification.d.ts +104 -0
  219. package/dist/types.backup/router/revalidation.d.ts +57 -0
  220. package/dist/types.backup/router/route-snapshot.d.ts +112 -0
  221. package/dist/types.backup/router/router-context.d.ts +137 -0
  222. package/dist/types.backup/router/router-interfaces.d.ts +432 -0
  223. package/dist/types.backup/router/router-options.d.ts +738 -0
  224. package/dist/types.backup/router/router-registry.d.ts +15 -0
  225. package/dist/types.backup/router/segment-resolution/fresh.d.ts +55 -0
  226. package/dist/types.backup/router/segment-resolution/helpers.d.ts +93 -0
  227. package/dist/types.backup/router/segment-resolution/loader-cache.d.ts +33 -0
  228. package/dist/types.backup/router/segment-resolution/loader-mask.d.ts +44 -0
  229. package/dist/types.backup/router/segment-resolution/loader-snapshot.d.ts +90 -0
  230. package/dist/types.backup/router/segment-resolution/mask-nested.d.ts +53 -0
  231. package/dist/types.backup/router/segment-resolution/revalidation.d.ts +85 -0
  232. package/dist/types.backup/router/segment-resolution/static-store.d.ts +17 -0
  233. package/dist/types.backup/router/segment-resolution/streamed-handler-telemetry.d.ts +16 -0
  234. package/dist/types.backup/router/segment-resolution/view-transition-default.d.ts +28 -0
  235. package/dist/types.backup/router/segment-resolution.d.ts +3 -0
  236. package/dist/types.backup/router/segment-wrappers.d.ts +53 -0
  237. package/dist/types.backup/router/state-cookie-name.d.ts +1 -0
  238. package/dist/types.backup/router/substitute-pattern-params.d.ts +23 -0
  239. package/dist/types.backup/router/telemetry-otel.d.ts +113 -0
  240. package/dist/types.backup/router/telemetry.d.ts +215 -0
  241. package/dist/types.backup/router/timeout.d.ts +68 -0
  242. package/dist/types.backup/router/tracing.d.ts +125 -0
  243. package/dist/types.backup/router/trie-matching.d.ts +32 -0
  244. package/dist/types.backup/router/types.d.ts +98 -0
  245. package/dist/types.backup/router/url-params.d.ts +26 -0
  246. package/dist/types.backup/router.d.ts +7 -0
  247. package/dist/types.backup/rsc/capture-queue.d.ts +6 -0
  248. package/dist/types.backup/rsc/full-payload.d.ts +22 -0
  249. package/dist/types.backup/rsc/handler-context.d.ts +31 -0
  250. package/dist/types.backup/rsc/handler.d.ts +9 -0
  251. package/dist/types.backup/rsc/helpers.d.ts +213 -0
  252. package/dist/types.backup/rsc/index.d.ts +17 -0
  253. package/dist/types.backup/rsc/json-route-result.d.ts +20 -0
  254. package/dist/types.backup/rsc/loader-fetch.d.ts +14 -0
  255. package/dist/types.backup/rsc/manifest-init.d.ts +18 -0
  256. package/dist/types.backup/rsc/nonce.d.ts +28 -0
  257. package/dist/types.backup/rsc/origin-guard.d.ts +50 -0
  258. package/dist/types.backup/rsc/progressive-enhancement.d.ts +19 -0
  259. package/dist/types.backup/rsc/redirect-guard.d.ts +35 -0
  260. package/dist/types.backup/rsc/response-cache-serve.d.ts +46 -0
  261. package/dist/types.backup/rsc/response-error.d.ts +19 -0
  262. package/dist/types.backup/rsc/response-route-handler.d.ts +29 -0
  263. package/dist/types.backup/rsc/rsc-rendering.d.ts +23 -0
  264. package/dist/types.backup/rsc/runtime-warnings.d.ts +22 -0
  265. package/dist/types.backup/rsc/server-action.d.ts +68 -0
  266. package/dist/types.backup/rsc/shell-build-manifest.d.ts +84 -0
  267. package/dist/types.backup/rsc/shell-capture-constants.d.ts +27 -0
  268. package/dist/types.backup/rsc/shell-capture.d.ts +374 -0
  269. package/dist/types.backup/rsc/shell-serve.d.ts +136 -0
  270. package/dist/types.backup/rsc/ssr-setup.d.ts +48 -0
  271. package/dist/types.backup/rsc/transition-gate.d.ts +27 -0
  272. package/dist/types.backup/rsc/types.d.ts +290 -0
  273. package/dist/types.backup/runtime-env.d.ts +1 -0
  274. package/dist/types.backup/search-params.d.ts +125 -0
  275. package/dist/types.backup/segment-content-promise.d.ts +13 -0
  276. package/dist/types.backup/segment-fragments.d.ts +56 -0
  277. package/dist/types.backup/segment-loader-promise.d.ts +22 -0
  278. package/dist/types.backup/segment-system.d.ts +84 -0
  279. package/dist/types.backup/serialize.d.ts +164 -0
  280. package/dist/types.backup/server/context.d.ts +494 -0
  281. package/dist/types.backup/server/cookie-parse.d.ts +10 -0
  282. package/dist/types.backup/server/cookie-store.d.ts +107 -0
  283. package/dist/types.backup/server/fetchable-loader-store.d.ts +20 -0
  284. package/dist/types.backup/server/handle-store.d.ts +100 -0
  285. package/dist/types.backup/server/loader-registry.d.ts +32 -0
  286. package/dist/types.backup/server/request-context.d.ts +596 -0
  287. package/dist/types.backup/server/root-layout.d.ts +3 -0
  288. package/dist/types.backup/server.d.ts +15 -0
  289. package/dist/types.backup/ssr/index.d.ts +233 -0
  290. package/dist/types.backup/ssr/inject-rsc-eager.d.ts +3 -0
  291. package/dist/types.backup/ssr/preinit-client-references.d.ts +71 -0
  292. package/dist/types.backup/ssr/ssr-root.d.ts +69 -0
  293. package/dist/types.backup/static-handler.d.ts +57 -0
  294. package/dist/types.backup/testing/cache-status.d.ts +63 -0
  295. package/dist/types.backup/testing/collect-handle.d.ts +20 -0
  296. package/dist/types.backup/testing/dispatch.d.ts +123 -0
  297. package/dist/types.backup/testing/dom.entry.d.ts +15 -0
  298. package/dist/types.backup/testing/e2e/fixture.d.ts +37 -0
  299. package/dist/types.backup/testing/e2e/index.d.ts +30 -0
  300. package/dist/types.backup/testing/e2e/matchers.d.ts +17 -0
  301. package/dist/types.backup/testing/e2e/page-helpers.d.ts +62 -0
  302. package/dist/types.backup/testing/e2e/parity.d.ts +111 -0
  303. package/dist/types.backup/testing/e2e/server.d.ts +35 -0
  304. package/dist/types.backup/testing/flight-matchers.d.ts +55 -0
  305. package/dist/types.backup/testing/flight-normalize.d.ts +1 -0
  306. package/dist/types.backup/testing/flight-tree.d.ts +192 -0
  307. package/dist/types.backup/testing/flight.d.ts +115 -0
  308. package/dist/types.backup/testing/flight.entry.d.ts +27 -0
  309. package/dist/types.backup/testing/generated-routes.d.ts +66 -0
  310. package/dist/types.backup/testing/index.d.ts +52 -0
  311. package/dist/types.backup/testing/internal/context.d.ts +225 -0
  312. package/dist/types.backup/testing/internal/flight-client-globals.d.ts +1 -0
  313. package/dist/types.backup/testing/internal/seed-vars.d.ts +30 -0
  314. package/dist/types.backup/testing/render-handler.d.ts +160 -0
  315. package/dist/types.backup/testing/render-route.d.ts +246 -0
  316. package/dist/types.backup/testing/run-loader.d.ts +186 -0
  317. package/dist/types.backup/testing/run-middleware.d.ts +132 -0
  318. package/dist/types.backup/testing/run-transition-when.d.ts +77 -0
  319. package/dist/types.backup/testing/vitest-stubs/cloudflare-email.d.ts +6 -0
  320. package/dist/types.backup/testing/vitest-stubs/cloudflare-workers.d.ts +13 -0
  321. package/dist/types.backup/testing/vitest-stubs/plugin-rsc.d.ts +7 -0
  322. package/dist/types.backup/testing/vitest-stubs/version.d.ts +1 -0
  323. package/dist/types.backup/testing/vitest.d.ts +205 -0
  324. package/dist/types.backup/theme/ThemeProvider.d.ts +13 -0
  325. package/dist/types.backup/theme/ThemeScript.d.ts +45 -0
  326. package/dist/types.backup/theme/constants.d.ts +39 -0
  327. package/dist/types.backup/theme/index.d.ts +29 -0
  328. package/dist/types.backup/theme/theme-context.d.ts +21 -0
  329. package/dist/types.backup/theme/theme-script.d.ts +26 -0
  330. package/dist/types.backup/theme/types.d.ts +162 -0
  331. package/dist/types.backup/theme/use-theme.d.ts +8 -0
  332. package/dist/types.backup/types/boundaries.d.ts +93 -0
  333. package/dist/types.backup/types/cache-types.d.ts +191 -0
  334. package/dist/types.backup/types/error-types.d.ts +114 -0
  335. package/dist/types.backup/types/global-namespace.d.ts +90 -0
  336. package/dist/types.backup/types/handler-context.d.ts +658 -0
  337. package/dist/types.backup/types/index.d.ts +11 -0
  338. package/dist/types.backup/types/loader-types.d.ts +182 -0
  339. package/dist/types.backup/types/request-scope.d.ts +93 -0
  340. package/dist/types.backup/types/route-config.d.ts +105 -0
  341. package/dist/types.backup/types/route-entry.d.ts +95 -0
  342. package/dist/types.backup/types/segments.d.ts +234 -0
  343. package/dist/types.backup/types.d.ts +1 -0
  344. package/dist/types.backup/urls/include-helper.d.ts +17 -0
  345. package/dist/types.backup/urls/include-provider.d.ts +27 -0
  346. package/dist/types.backup/urls/index.d.ts +6 -0
  347. package/dist/types.backup/urls/path-helper-types.d.ts +197 -0
  348. package/dist/types.backup/urls/path-helper.d.ts +12 -0
  349. package/dist/types.backup/urls/pattern-types.d.ts +166 -0
  350. package/dist/types.backup/urls/response-types.d.ts +67 -0
  351. package/dist/types.backup/urls/type-extraction.d.ts +157 -0
  352. package/dist/types.backup/urls/urls-function.d.ts +24 -0
  353. package/dist/types.backup/urls.d.ts +1 -0
  354. package/dist/types.backup/use-loader.d.ts +150 -0
  355. package/dist/types.backup/vercel/index.d.ts +10 -0
  356. package/dist/types.backup/vercel/tracing.d.ts +70 -0
  357. package/dist/types.backup/vite/debug.d.ts +80 -0
  358. package/dist/types.backup/vite/discovery/bundle-postprocess.d.ts +12 -0
  359. package/dist/types.backup/vite/discovery/dev-prerender-cache.d.ts +65 -0
  360. package/dist/types.backup/vite/discovery/discover-routers.d.ts +17 -0
  361. package/dist/types.backup/vite/discovery/discovery-errors.d.ts +113 -0
  362. package/dist/types.backup/vite/discovery/gate-state.d.ts +79 -0
  363. package/dist/types.backup/vite/discovery/prerender-collection.d.ts +24 -0
  364. package/dist/types.backup/vite/discovery/route-types-writer.d.ts +32 -0
  365. package/dist/types.backup/vite/discovery/self-gen-tracking.d.ts +22 -0
  366. package/dist/types.backup/vite/discovery/shell-prerender-phase.d.ts +40 -0
  367. package/dist/types.backup/vite/discovery/state.d.ts +162 -0
  368. package/dist/types.backup/vite/discovery/virtual-module-codegen.d.ts +15 -0
  369. package/dist/types.backup/vite/index.d.ts +11 -0
  370. package/dist/types.backup/vite/inject-client-debug.d.ts +56 -0
  371. package/dist/types.backup/vite/plugin-types.d.ts +298 -0
  372. package/dist/types.backup/vite/plugins/cjs-to-esm.d.ts +6 -0
  373. package/dist/types.backup/vite/plugins/client-ref-dedup.d.ts +40 -0
  374. package/dist/types.backup/vite/plugins/client-ref-hashing.d.ts +35 -0
  375. package/dist/types.backup/vite/plugins/cloudflare-protocol-stub.d.ts +64 -0
  376. package/dist/types.backup/vite/plugins/expose-action-id.d.ts +18 -0
  377. package/dist/types.backup/vite/plugins/expose-id-utils.d.ts +37 -0
  378. package/dist/types.backup/vite/plugins/expose-ids/export-analysis.d.ts +19 -0
  379. package/dist/types.backup/vite/plugins/expose-ids/handler-transform.d.ts +10 -0
  380. package/dist/types.backup/vite/plugins/expose-ids/loader-transform.d.ts +8 -0
  381. package/dist/types.backup/vite/plugins/expose-ids/router-transform.d.ts +13 -0
  382. package/dist/types.backup/vite/plugins/expose-ids/types.d.ts +29 -0
  383. package/dist/types.backup/vite/plugins/expose-internal-ids.d.ts +6 -0
  384. package/dist/types.backup/vite/plugins/performance-tracks.d.ts +25 -0
  385. package/dist/types.backup/vite/plugins/refresh-cmd.d.ts +20 -0
  386. package/dist/types.backup/vite/plugins/use-cache-transform.d.ts +20 -0
  387. package/dist/types.backup/vite/plugins/vercel-output.d.ts +85 -0
  388. package/dist/types.backup/vite/plugins/version-injector.d.ts +21 -0
  389. package/dist/types.backup/vite/plugins/version-plugin.d.ts +19 -0
  390. package/dist/types.backup/vite/plugins/virtual-entries.d.ts +36 -0
  391. package/dist/types.backup/vite/plugins/virtual-stub-plugin.d.ts +7 -0
  392. package/dist/types.backup/vite/rango.d.ts +29 -0
  393. package/dist/types.backup/vite/router-discovery.d.ts +23 -0
  394. package/dist/types.backup/vite/utils/ast-handler-extract.d.ts +64 -0
  395. package/dist/types.backup/vite/utils/banner.d.ts +2 -0
  396. package/dist/types.backup/vite/utils/bundle-analysis.d.ts +28 -0
  397. package/dist/types.backup/vite/utils/client-chunks.d.ts +55 -0
  398. package/dist/types.backup/vite/utils/directive-prologue.d.ts +16 -0
  399. package/dist/types.backup/vite/utils/forward-user-plugins.d.ts +37 -0
  400. package/dist/types.backup/vite/utils/manifest-utils.d.ts +7 -0
  401. package/dist/types.backup/vite/utils/package-resolution.d.ts +6 -0
  402. package/dist/types.backup/vite/utils/prerender-utils.d.ts +32 -0
  403. package/dist/types.backup/vite/utils/shared-utils.d.ts +55 -0
  404. package/dist/vite/index.js +1 -1
  405. package/package.json +1 -1
  406. package/skills/parallel/SKILL.md +1 -1
  407. package/skills/ppr/SKILL.md +44 -3
  408. package/src/browser/prefetch/cache.ts +53 -9
  409. package/src/browser/prefetch/fetch.ts +83 -2
  410. package/src/cache/cf/cf-cache-store.ts +27 -8
  411. package/src/cache/types.ts +41 -6
  412. package/src/cache/vercel/vercel-cache-store.ts +24 -10
  413. package/src/route-definition/helpers-types.ts +5 -3
  414. package/src/rsc/capture-queue.ts +120 -47
  415. package/src/rsc/rsc-rendering.ts +11 -3
  416. package/src/rsc/shell-build-manifest.ts +20 -7
  417. package/src/rsc/shell-capture.ts +164 -12
  418. package/src/rsc/shell-serve.ts +27 -12
  419. package/src/static-handler.ts +18 -2
  420. package/src/urls/path-helper-types.ts +9 -10
@@ -0,0 +1,738 @@
1
+ import type { ComponentType, ReactNode } from "react";
2
+ import type { SegmentCacheStore } from "../cache/types.js";
3
+ import type { ErrorBoundaryHandler, NotFoundBoundaryHandler, OnErrorCallback } from "../types";
4
+ import type { NonceProvider } from "../rsc/types.js";
5
+ import type { ShellCaptureDebug } from "../rsc/shell-capture.js";
6
+ import type { ExecutionContext } from "../server/request-context.js";
7
+ import type { UrlPatterns } from "../urls.js";
8
+ import type { UrlBuilder } from "../urls/pattern-types.js";
9
+ import type { NamedRouteEntry } from "./content-negotiation.js";
10
+ import type { TelemetrySink } from "./telemetry.js";
11
+ import type { RouterTracingConfig } from "./tracing.js";
12
+ import type { RouterTimeouts, OnTimeoutCallback } from "./timeout.js";
13
+ /**
14
+ * SSR stream mode returned by resolveStreaming.
15
+ *
16
+ * - `"stream"` — start flushing HTML as soon as the shell is ready
17
+ * (default React SSR behavior via `renderToReadableStream`).
18
+ * - `"allReady"` — wait for every Suspense boundary to resolve before
19
+ * sending any bytes (equivalent to awaiting `stream.allReady`).
20
+ */
21
+ export type SSRStreamMode = "stream" | "allReady";
22
+ /**
23
+ * Context passed to the resolveStreaming callback.
24
+ */
25
+ export interface ResolveStreamingContext<TEnv = unknown> {
26
+ request: Request;
27
+ env: TEnv;
28
+ url: URL;
29
+ }
30
+ /**
31
+ * SSR configuration options.
32
+ */
33
+ export interface SSROptions<TEnv = unknown> {
34
+ /**
35
+ * Determine whether an HTML response should stream progressively or
36
+ * wait for full readiness before flushing.
37
+ *
38
+ * Called once per HTML request, before the HTML response is produced.
39
+ * Does NOT apply to RSC responses (`__rsc`, partial navigation, prefetch).
40
+ *
41
+ * Return `"stream"` (default) for progressive streaming or `"allReady"`
42
+ * to buffer the complete HTML before sending.
43
+ *
44
+ * @example Bot detection
45
+ * ```ts
46
+ * createRouter({
47
+ * ssr: {
48
+ * resolveStreaming: async ({ request, env }) => {
49
+ * const bot = await detectBot(request, env);
50
+ * return bot.isBot && !bot.supportsStreaming ? "allReady" : "stream";
51
+ * },
52
+ * },
53
+ * });
54
+ * ```
55
+ */
56
+ resolveStreaming?: (context: ResolveStreamingContext<TEnv>) => SSRStreamMode | Promise<SSRStreamMode>;
57
+ }
58
+ /**
59
+ * Props passed to the root layout component
60
+ */
61
+ export interface RootLayoutProps {
62
+ children: ReactNode;
63
+ }
64
+ /**
65
+ * Router configuration options
66
+ */
67
+ export interface RangoOptions<TEnv = any> {
68
+ /**
69
+ * Unique identifier for this router instance.
70
+ * Used to namespace static output files and route maps.
71
+ * Auto-generated if not provided.
72
+ */
73
+ id?: string;
74
+ /**
75
+ * Injected by the Vite transform at compile time.
76
+ * Hash of filename + line number for stable cross-environment ID.
77
+ * @internal
78
+ */
79
+ $$id?: string;
80
+ /**
81
+ * Injected by the Vite transform at compile time.
82
+ * Absolute path of the source file that defines this router,
83
+ * relative to project root. Eliminates runtime stack trace parsing.
84
+ * @internal
85
+ */
86
+ $$sourceFile?: string;
87
+ /**
88
+ * URL prefix applied to all routes registered with this router.
89
+ *
90
+ * Useful when the app is served under a sub-path (e.g. `/admin` or `/v2`).
91
+ * All `path()` patterns are automatically prefixed and `reverse()` returns
92
+ * full paths including the basename. Route names are NOT prefixed.
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * const router = createRouter({
97
+ * basename: "/admin",
98
+ * }).routes(({ path }) => [
99
+ * path("/", Dashboard, { name: "home" }), // matches /admin
100
+ * path("/users", Users, { name: "users" }), // matches /admin/users
101
+ * ]);
102
+ *
103
+ * router.reverse("home"); // "/admin"
104
+ * router.reverse("users"); // "/admin/users"
105
+ * ```
106
+ */
107
+ basename?: string;
108
+ /**
109
+ * Enable performance metrics collection
110
+ * When enabled, metrics are output to console and available via Server-Timing header
111
+ */
112
+ debugPerformance?: boolean;
113
+ /**
114
+ * DEVELOPMENT/TEST ONLY. Emit an `X-Rango-Cache` response header describing
115
+ * the cache status of the matched route, for use by testing primitives such
116
+ * as `assertCacheStatus`.
117
+ *
118
+ * Defaults to `false`. When neither this option nor the
119
+ * `RANGO_TEST_SIGNALS=1` environment flag is set, NO header is emitted and
120
+ * router output is byte-identical to the default.
121
+ *
122
+ * The header encodes per-segment (v1: coarse route-level) status keyed by the
123
+ * route NAME, e.g. `X-Rango-Cache: product.detail=hit`. Do NOT enable in
124
+ * production — it exposes internal cache decisions.
125
+ */
126
+ debugCacheSignal?: boolean;
127
+ /**
128
+ * Debug sink for the PPR shell-capture pipeline (routes with the `ppr` path
129
+ * option). `true` logs one structured line per capture attempt/skip to
130
+ * console (visible via `wrangler tail`); a function receives each
131
+ * `ShellCaptureDebugEvent` (outcome per attempt, snapshot bytes,
132
+ * write-barrier wait, backoff state) for programmatic capture. Off by
133
+ * default; the events also mirror into the dev Server-Timing surface when
134
+ * `debugPerformance` is on. Intended for validating capture behavior on a
135
+ * real deployment, not steady-state production.
136
+ */
137
+ debugShellCapture?: ShellCaptureDebug;
138
+ /**
139
+ * Document component that wraps the entire application.
140
+ *
141
+ * This component provides the HTML structure for your app and wraps
142
+ * both normal route content AND error states, preventing the app shell
143
+ * from unmounting during errors (avoids FOUC).
144
+ *
145
+ * Must be a client component ("use client") that accepts { children }.
146
+ *
147
+ * If not provided, a default document with basic HTML structure is used:
148
+ * `<html><head><meta charset/viewport></head><body>{children}</body></html>`
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * // components/Document.tsx
153
+ * "use client";
154
+ * export function Document({ children }: { children: ReactNode }) {
155
+ * return (
156
+ * <html lang="en">
157
+ * <head>
158
+ * <link rel="stylesheet" href="/styles.css" />
159
+ * </head>
160
+ * <body>
161
+ * <nav>...</nav>
162
+ * {children}
163
+ * </body>
164
+ * </html>
165
+ * );
166
+ * }
167
+ *
168
+ * // router.tsx
169
+ * const router = createRouter<AppEnv>({
170
+ * document: Document,
171
+ * });
172
+ * ```
173
+ */
174
+ document?: ComponentType<RootLayoutProps>;
175
+ /**
176
+ * Default error boundary fallback used when no error boundary is defined in the route tree
177
+ * If not provided, errors will propagate and crash the request
178
+ */
179
+ defaultErrorBoundary?: ReactNode | ErrorBoundaryHandler;
180
+ /**
181
+ * Default not-found boundary fallback used when no notFoundBoundary is defined in the route tree
182
+ * If not provided, DataNotFoundError will be treated as a regular error
183
+ */
184
+ defaultNotFoundBoundary?: ReactNode | NotFoundBoundaryHandler;
185
+ /**
186
+ * Component to render when no route matches the requested URL.
187
+ *
188
+ * This is rendered within your document/app shell with a 404 status code.
189
+ * Use this for a custom 404 page that maintains your app's look and feel.
190
+ *
191
+ * If not provided, a default "Page not found" component is rendered.
192
+ *
193
+ * Can be a static ReactNode or a function receiving the pathname.
194
+ *
195
+ * @example
196
+ * ```typescript
197
+ * // Simple static component
198
+ * const router = createRouter<AppEnv>({
199
+ * document: Document,
200
+ * notFound: <NotFound404 />,
201
+ * });
202
+ *
203
+ * // Dynamic component with pathname
204
+ * const router = createRouter<AppEnv>({
205
+ * document: Document,
206
+ * notFound: ({ pathname }) => (
207
+ * <div>
208
+ * <h1>404 - Not Found</h1>
209
+ * <p>No page exists at {pathname}</p>
210
+ * <a href="/">Go home</a>
211
+ * </div>
212
+ * ),
213
+ * });
214
+ * ```
215
+ */
216
+ notFound?: ReactNode | ((props: {
217
+ pathname: string;
218
+ }) => ReactNode);
219
+ /**
220
+ * Callback invoked when an error occurs during request handling.
221
+ *
222
+ * This callback is for notification/logging purposes - it cannot modify
223
+ * the error handling flow. Use errorBoundary() in route definitions to
224
+ * customize error UI.
225
+ *
226
+ * The callback receives comprehensive context about the error including:
227
+ * - The error itself
228
+ * - Phase where it occurred (routing, middleware, loader, handler, etc.)
229
+ * - Request info (URL, method, params)
230
+ * - Route info (routeKey, segmentId)
231
+ * - Environment/bindings
232
+ * - Duration from request start
233
+ *
234
+ * @example
235
+ * ```typescript
236
+ * const router = createRouter<AppEnv>({
237
+ * onError: (context) => {
238
+ * // Send to error tracking service
239
+ * Sentry.captureException(context.error, {
240
+ * tags: {
241
+ * phase: context.phase,
242
+ * route: context.routeKey,
243
+ * },
244
+ * extra: {
245
+ * url: context.url.toString(),
246
+ * params: context.params,
247
+ * duration: context.duration,
248
+ * },
249
+ * });
250
+ * },
251
+ * });
252
+ * ```
253
+ */
254
+ onError?: OnErrorCallback<TEnv>;
255
+ /**
256
+ * Cache store for segment caching.
257
+ *
258
+ * When provided, enables route-level caching via cache() boundaries.
259
+ * The store handles persistence (memory, KV, Redis, etc.).
260
+ *
261
+ * Can be a static config or a function receiving env for runtime bindings.
262
+ *
263
+ * @example Static config
264
+ * ```typescript
265
+ * import { MemorySegmentCacheStore } from "@rangojs/router/cache";
266
+ *
267
+ * const router = createRouter({
268
+ * cache: {
269
+ * store: new MemorySegmentCacheStore({ defaults: { ttl: 60 } }),
270
+ * },
271
+ * });
272
+ * ```
273
+ *
274
+ * @example Dynamic config with env (e.g., Cloudflare Workers with ExecutionContext)
275
+ * ```typescript
276
+ * const router = createRouter<AppBindings>({
277
+ * cache: (_env, ctx) => ({
278
+ * store: new CFCacheStore({
279
+ * defaults: { ttl: 60 },
280
+ * ctx: ctx!, // ExecutionContext for non-blocking writes
281
+ * }),
282
+ * }),
283
+ * });
284
+ * ```
285
+ */
286
+ cache?: {
287
+ store: SegmentCacheStore;
288
+ enabled?: boolean;
289
+ } | ((env: TEnv, ctx?: ExecutionContext) => {
290
+ store: SegmentCacheStore;
291
+ enabled?: boolean;
292
+ });
293
+ /**
294
+ * Named cache profiles for "use cache" directive.
295
+ * Profile names map to TTL/SWR configuration.
296
+ *
297
+ * - `"use cache"` (no name) resolves to the `default` profile.
298
+ * - `"use cache: short"` resolves to the `short` profile.
299
+ *
300
+ * @example
301
+ * ```typescript
302
+ * createRouter({
303
+ * cacheProfiles: {
304
+ * default: { ttl: 900, swr: 1800 },
305
+ * short: { ttl: 60, swr: 120 },
306
+ * long: { ttl: 3600, swr: 7200 },
307
+ * products: { ttl: 300, swr: 600, tags: ['products'] },
308
+ * },
309
+ * });
310
+ * ```
311
+ */
312
+ cacheProfiles?: Record<string, import("../cache/profile-registry.js").CacheProfile>;
313
+ /**
314
+ * Theme configuration for automatic theme management.
315
+ *
316
+ * When provided, enables:
317
+ * - ctx.theme and ctx.setTheme() in route handlers
318
+ * - useTheme() hook for client components
319
+ * - FOUC prevention via inline script in MetaTags
320
+ * - Automatic ThemeProvider wrapping in NavigationProvider
321
+ *
322
+ * @example
323
+ * ```typescript
324
+ * const router = createRouter<AppEnv>({
325
+ * theme: {
326
+ * defaultTheme: "system",
327
+ * themes: ["light", "dark"],
328
+ * }
329
+ * });
330
+ *
331
+ * // In route handler:
332
+ * route("settings", (ctx) => {
333
+ * const theme = ctx.theme; // "light" | "dark" | "system"
334
+ * ctx.setTheme("dark"); // Sets cookie
335
+ * return <SettingsPage />;
336
+ * });
337
+ *
338
+ * // In client component:
339
+ * import { useTheme } from "@rangojs/router/theme";
340
+ *
341
+ * function ThemeToggle() {
342
+ * const { theme, setTheme, themes } = useTheme();
343
+ * return <select value={theme} onChange={e => setTheme(e.target.value)}>
344
+ * {themes.map(t => <option key={t}>{t}</option>)}
345
+ * </select>;
346
+ * }
347
+ * ```
348
+ *
349
+ * Use `theme: true` to enable with all defaults.
350
+ */
351
+ theme?: import("../theme/types.js").ThemeConfig | true;
352
+ /**
353
+ * Default for whether the router wraps `transition()` segments in its own
354
+ * React `<ViewTransition>` boundary (experimental React only).
355
+ *
356
+ * - "auto" (default): every route/layout that opts in via `transition()`
357
+ * gets a router-owned cross-fade.
358
+ * - false: the router never places its own boundary. Routes that use
359
+ * `transition()` still drive navigation through startTransition (so loaders
360
+ * hold instead of flashing a skeleton) and still let consumer-placed
361
+ * `<ViewTransition>` elements animate — the router just contributes no
362
+ * cross-fade of its own. This is the "router triggers, you place the
363
+ * transitions" model.
364
+ *
365
+ * A per-segment `transition({ viewTransition })` overrides this default.
366
+ *
367
+ * @example
368
+ * ```typescript
369
+ * // App-wide: drive + hold, but never auto-wrap. Place <ViewTransition>
370
+ * // yourself in components where you want a morph.
371
+ * const router = createRouter<AppEnv>({ viewTransition: false });
372
+ * ```
373
+ */
374
+ viewTransition?: "auto" | false;
375
+ /**
376
+ * URL patterns to register with the router.
377
+ *
378
+ * Accepts either a `UrlPatterns` object from `urls()` or a builder function
379
+ * directly (urls() is called implicitly).
380
+ *
381
+ * @example
382
+ * ```typescript
383
+ * // With urls()
384
+ * createRouter<AppEnv>({
385
+ * document: Document,
386
+ * urls: urlpatterns,
387
+ * });
388
+ *
389
+ * // With builder function
390
+ * createRouter<AppEnv>({
391
+ * document: Document,
392
+ * urls: ({ path }) => [
393
+ * path("/", HomePage, { name: "home" }),
394
+ * path("/about", AboutPage, { name: "about" }),
395
+ * ],
396
+ * });
397
+ * ```
398
+ */
399
+ urls?: UrlPatterns<TEnv, any> | UrlBuilder<TEnv>;
400
+ /**
401
+ * Injected by the Vite transform at compile time.
402
+ * Static import of NamedRoutes from the generated named-routes file.
403
+ * Used to seed reverse() with the full named route map.
404
+ * @internal
405
+ */
406
+ $$routeNames?: Record<string, NamedRouteEntry>;
407
+ /**
408
+ * Nonce provider for Content Security Policy (CSP).
409
+ *
410
+ * Can be:
411
+ * - A function that returns a nonce string
412
+ * - A function that returns `true` to auto-generate a nonce
413
+ * - Undefined to disable nonce (default)
414
+ *
415
+ * The nonce will be applied to inline scripts injected by the RSC payload.
416
+ * It's also available to middleware via the typed `nonce` token:
417
+ * `import { nonce } from "@rangojs/router"; ctx.get(nonce)`
418
+ *
419
+ * @example Auto-generate nonce
420
+ * ```tsx
421
+ * createRouter({
422
+ * nonce: () => true,
423
+ * });
424
+ * ```
425
+ *
426
+ * @example Custom nonce from request context
427
+ * ```tsx
428
+ * createRouter({
429
+ * nonce: (request, env) => env.nonce,
430
+ * });
431
+ * ```
432
+ *
433
+ * @example Access nonce in middleware
434
+ * ```tsx
435
+ * import { nonce } from "@rangojs/router";
436
+ *
437
+ * const cspMiddleware: Middleware = async (ctx, next) => {
438
+ * const value = ctx.get(nonce); // string | undefined
439
+ * await next();
440
+ * };
441
+ * ```
442
+ */
443
+ nonce?: NonceProvider<TEnv>;
444
+ /**
445
+ * RSC version string included in metadata.
446
+ * The browser sends this back on partial requests to detect version mismatches.
447
+ *
448
+ * Defaults to the auto-generated VERSION from `@rangojs/router:version` virtual module.
449
+ * Only set this if you need a custom versioning strategy.
450
+ *
451
+ * @default VERSION from @rangojs/router:version
452
+ */
453
+ version?: string;
454
+ /**
455
+ * TTL (in seconds) for the in-memory prefetch cache and the
456
+ * Cache-Control header on prefetch responses.
457
+ *
458
+ * Controls how long prefetch responses are kept in the client-side
459
+ * in-memory cache and sets `Cache-Control: private, max-age=<ttl>`
460
+ * on server responses for CDN/edge caching.
461
+ *
462
+ * The cache is automatically invalidated on server actions regardless
463
+ * of TTL, so this is primarily a staleness safety net.
464
+ *
465
+ * Set to `false` to disable prefetch caching entirely.
466
+ *
467
+ * @default 300 (5 minutes)
468
+ */
469
+ prefetchCacheTTL?: number | false;
470
+ /**
471
+ * Maximum number of decoded prefetch payloads the client keeps in its
472
+ * in-memory prefetch cache. When the cache is full the oldest entry is
473
+ * evicted (FIFO) to make room for a new prefetch.
474
+ *
475
+ * Each entry retains a fully decoded RSC payload (and the route's client
476
+ * chunks pulled in while decoding), so this is the lever on client-side
477
+ * prefetch memory: a higher value warms more routes at the cost of more
478
+ * retained payloads. Staleness is bounded separately by `prefetchCacheTTL`;
479
+ * this bounds the entry COUNT.
480
+ *
481
+ * Values below 1 (or non-finite) fall back to the default. To turn
482
+ * prefetching off entirely, set `prefetchCacheTTL: false` instead.
483
+ *
484
+ * @default 100
485
+ */
486
+ prefetchCacheSize?: number;
487
+ /**
488
+ * Maximum number of speculative prefetch requests (viewport/render strategy)
489
+ * the client runs concurrently. Hover prefetches bypass this queue and fire
490
+ * immediately; this caps only the background, idle-gated queue so prefetches
491
+ * never saturate the browser's connection pool.
492
+ *
493
+ * Values below 1 (or non-finite) fall back to the default.
494
+ *
495
+ * @default 2
496
+ */
497
+ prefetchConcurrency?: number;
498
+ /**
499
+ * Prefix for the rango state cookie name. The resolved name is
500
+ * `{prefix}_{routerId}`; the prefix is sanitized to cookie-name-safe
501
+ * characters (`[A-Za-z0-9-]`) and an empty result falls back to the default.
502
+ *
503
+ * The rango state cookie keys the client's prefetch / HTTP caches. Overriding
504
+ * the prefix lets you align it with cookie-naming policies or consent-manager
505
+ * classification lists, or avoid colliding with an existing `rango-state`
506
+ * cookie. It is not a full-name override: the `_{routerId}` suffix is what
507
+ * keeps sibling apps on one origin from clobbering each other's state.
508
+ *
509
+ * @default "rango-state"
510
+ */
511
+ stateCookiePrefix?: string;
512
+ /**
513
+ * Enable connection warmup to keep TCP+TLS alive after idle periods.
514
+ *
515
+ * When enabled, the client sends a HEAD request after the user returns
516
+ * from an idle period (60s+), prewarming the TLS connection before
517
+ * the next navigation.
518
+ *
519
+ * @default true
520
+ */
521
+ warmup?: boolean;
522
+ /**
523
+ * Wrap the hydrated client tree in `React.StrictMode`.
524
+ *
525
+ * The Rango browser entry hydrates the app inside `<React.StrictMode>` by
526
+ * default. StrictMode double-invokes render and (in development) mounts,
527
+ * unmounts, then remounts every effect to surface impure renders and missing
528
+ * effect cleanup. Production builds treat StrictMode as a no-op, so this flag
529
+ * only changes development behavior in a normal app.
530
+ *
531
+ * Set to `false` to hydrate without the StrictMode wrapper. The main reason to
532
+ * opt out is to isolate StrictMode's intentional double-render/double-effect
533
+ * from genuine re-renders when measuring client-hook stability — with
534
+ * StrictMode off, render counts are exact in development too.
535
+ *
536
+ * The value is resolved server-side at router creation and shipped to the
537
+ * client in the initial payload metadata; the browser entry reads it once at
538
+ * hydration. Changing it does not affect the SSR HTML (StrictMode emits no
539
+ * DOM), so toggling it never causes a hydration mismatch.
540
+ *
541
+ * @default true
542
+ */
543
+ strictMode?: boolean;
544
+ /**
545
+ * Shorthand timeout (ms) applied to both action execution and render start.
546
+ * Does NOT apply to streamIdleMs.
547
+ * Overridden by individual values in `timeouts`.
548
+ *
549
+ * @example
550
+ * ```typescript
551
+ * createRouter({ timeout: 10_000 });
552
+ * ```
553
+ */
554
+ timeout?: number;
555
+ /**
556
+ * Structured timeout configuration per phase.
557
+ * Values here override the `timeout` shorthand.
558
+ *
559
+ * @example
560
+ * ```typescript
561
+ * createRouter({
562
+ * timeouts: {
563
+ * actionMs: 10_000,
564
+ * renderStartMs: 8_000,
565
+ * },
566
+ * });
567
+ * ```
568
+ */
569
+ timeouts?: RouterTimeouts;
570
+ /**
571
+ * Custom handler invoked when a timeout occurs.
572
+ * Receives context about which phase timed out and must return a Response.
573
+ * If not provided, returns a plain 504 with "Request timed out" body
574
+ * and X-Rango-Timeout-Phase header.
575
+ *
576
+ * If the callback throws, the default 504 response is used as fallback.
577
+ *
578
+ * @example
579
+ * ```typescript
580
+ * createRouter({
581
+ * timeout: 10_000,
582
+ * onTimeout: (ctx) => {
583
+ * return new Response(
584
+ * JSON.stringify({ error: "timeout", phase: ctx.phase }),
585
+ * { status: 504, headers: { "Content-Type": "application/json" } },
586
+ * );
587
+ * },
588
+ * });
589
+ * ```
590
+ */
591
+ onTimeout?: OnTimeoutCallback<TEnv>;
592
+ /**
593
+ * Telemetry sink for structured, discrete lifecycle EVENTS: request
594
+ * start/end/error, loader start/end/error, handler errors, cache decisions,
595
+ * revalidation decisions, timeouts, origin rejections.
596
+ *
597
+ * This is the EVENT surface. Phase-duration SPANS (request/middleware/action/
598
+ * handler/loader/render/ssr timing wired into a tracing backend) come from the
599
+ * separate `tracing` option below — a sink does not emit them, because async-context nesting
600
+ * cannot be faithfully reconstructed from after-the-fact start/end events.
601
+ *
602
+ * No-op when not configured (zero overhead).
603
+ *
604
+ * @example Console logging
605
+ * ```typescript
606
+ * import { createConsoleSink } from "@rangojs/router";
607
+ *
608
+ * const router = createRouter({
609
+ * telemetry: createConsoleSink(),
610
+ * });
611
+ * ```
612
+ *
613
+ * @example OpenTelemetry — pair the event sink with the tracing slot
614
+ * ```typescript
615
+ * import { createOTelTracing, createOTelSink } from "@rangojs/router";
616
+ * import { trace } from "@opentelemetry/api";
617
+ *
618
+ * const tracer = trace.getTracer("my-app");
619
+ * const router = createRouter({
620
+ * tracing: createOTelTracing(tracer), // phase spans
621
+ * telemetry: createOTelSink(tracer), // discrete-fact events
622
+ * });
623
+ * ```
624
+ *
625
+ * @example Custom sink
626
+ * ```typescript
627
+ * const router = createRouter({
628
+ * telemetry: {
629
+ * emit(event) {
630
+ * myTracer.record(event);
631
+ * },
632
+ * },
633
+ * });
634
+ * ```
635
+ */
636
+ telemetry?: TelemetrySink;
637
+ /**
638
+ * Span tracing for the router's performance phases (request, middleware, action,
639
+ * loaders, render, ssr). Connects the same phases shown in the
640
+ * `debugPerformance` timeline to the host platform's tracing system. This is
641
+ * the SPAN surface (the `telemetry` option above is the event surface).
642
+ *
643
+ * Two factories produce a config, both for this slot:
644
+ * - `createOTelTracing(tracer)` from `@rangojs/router` — any platform with an
645
+ * OpenTelemetry SDK (including Node). Bridges the phases onto
646
+ * `tracer.startActiveSpan`.
647
+ * - `createCloudflareTracing()` from `@rangojs/router/cloudflare` — Cloudflare
648
+ * Workers native custom spans, alongside the automatic KV/D1/fetch spans.
649
+ *
650
+ * When tracing is unset — or off-platform (no OTel SDK / no Cloudflare tracing
651
+ * destination) — every span call falls through to the work directly, so the
652
+ * request behaves exactly as if tracing were off.
653
+ *
654
+ * @example OpenTelemetry
655
+ * ```typescript
656
+ * import { createOTelTracing } from "@rangojs/router";
657
+ * import { trace } from "@opentelemetry/api";
658
+ *
659
+ * const router = createRouter({
660
+ * tracing: createOTelTracing(trace.getTracer("my-app")),
661
+ * });
662
+ * ```
663
+ *
664
+ * @example Cloudflare
665
+ * ```typescript
666
+ * import { createCloudflareTracing } from "@rangojs/router/cloudflare";
667
+ *
668
+ * const router = createRouter({
669
+ * tracing: createCloudflareTracing({ spans: { ssr: false } }),
670
+ * });
671
+ * ```
672
+ */
673
+ tracing?: RouterTracingConfig;
674
+ /**
675
+ * SSR configuration options.
676
+ *
677
+ * @example
678
+ * ```typescript
679
+ * createRouter({
680
+ * ssr: {
681
+ * resolveStreaming: async ({ request, env }) => {
682
+ * const bot = await detectBot(request, env);
683
+ * return bot.isBot ? "allReady" : "stream";
684
+ * },
685
+ * },
686
+ * });
687
+ * ```
688
+ */
689
+ ssr?: SSROptions<TEnv>;
690
+ /**
691
+ * Cross-origin request protection for server actions, loader fetches,
692
+ * and progressive enhancement form submissions.
693
+ *
694
+ * When enabled, the router validates that the request's Origin header
695
+ * (or Referer fallback) matches the Host before executing actions,
696
+ * loaders, or PE submissions. Requests without Origin/Referer are
697
+ * allowed (same-origin navigations, non-browser clients).
698
+ *
699
+ * The built-in check compares Origin against the Host header and
700
+ * url.protocol. It does NOT trust X-Forwarded-Host/Proto headers
701
+ * (they are client-controllable without a trusted proxy). On standard
702
+ * deployments (Cloudflare Workers, Node behind nginx/caddy) the Host
703
+ * header is already set to the public-facing host by the platform or
704
+ * proxy. For non-standard proxy setups where Host differs from the
705
+ * public origin, use a custom function that reads the appropriate
706
+ * forwarded headers from your trusted proxy.
707
+ *
708
+ * - `true` (default) -- enable built-in origin validation
709
+ * - `false` -- disable
710
+ * - function -- full custom control with access to env, phase,
711
+ * and the built-in check via `ctx.defaultCheck()`
712
+ *
713
+ * The callback receives `OriginCheckContext` with `request`, `url`,
714
+ * `env`, `routerId`, `phase` ("action" | "loader" | "pe-form"),
715
+ * and `defaultCheck()`. Return `true` to allow, `false` for default
716
+ * 403 rejection, or a `Response` for custom rejection.
717
+ *
718
+ * @default true
719
+ *
720
+ * @example Trusted proxy with X-Forwarded-Host
721
+ * ```ts
722
+ * createRouter({
723
+ * originCheck({ request, url, env, defaultCheck }) {
724
+ * if (env.TRUST_PROXY) {
725
+ * const origin = request.headers.get("origin");
726
+ * if (!origin) return true;
727
+ * if (origin === "null") return false;
728
+ * const host = request.headers.get("x-forwarded-host")
729
+ * ?? request.headers.get("host") ?? url.host;
730
+ * return origin.toLowerCase() === `${url.protocol}//${host}`.toLowerCase();
731
+ * }
732
+ * return defaultCheck();
733
+ * },
734
+ * });
735
+ * ```
736
+ */
737
+ originCheck?: import("../rsc/origin-guard.js").OriginCheckConfig<TEnv>;
738
+ }