@rangojs/router 0.5.1 → 0.5.2

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 (448) hide show
  1. package/README.md +5 -1
  2. package/dist/types/browser/event-controller.d.ts +6 -0
  3. package/dist/types/cache/cf/cf-cache-constants.d.ts +8 -1
  4. package/dist/types/cache/cf/cf-cache-store.d.ts +15 -1
  5. package/dist/types/cache/cf/cf-cache-types.d.ts +1 -1
  6. package/dist/types/cache/cf/cf-kv-utils.d.ts +21 -0
  7. package/dist/types/handles/is-thenable.d.ts +2 -4
  8. package/dist/types/rsc/helpers.d.ts +3 -0
  9. package/dist/types/rsc/render-pipeline.d.ts +9 -0
  10. package/dist/types/rsc/routine-plan.d.ts +124 -0
  11. package/dist/types/rsc/shell-capture-constants.d.ts +17 -0
  12. package/dist/types/server/request-context.d.ts +4 -1
  13. package/dist/types/vite/encryption-key.d.ts +2 -0
  14. package/dist/types/vite/plugins/expose-internal-ids.d.ts +10 -0
  15. package/dist/types/vite/plugins/server-ref-hashing.d.ts +24 -0
  16. package/dist/types/vite/plugins/server-reference-pattern.d.ts +1 -0
  17. package/dist/types/vite/utils/shared-utils.d.ts +12 -0
  18. package/dist/vite/index.js +154 -57
  19. package/package.json +3 -3
  20. package/skills/caching/SKILL.md +1 -1
  21. package/skills/mime-routes/SKILL.md +3 -1
  22. package/skills/response-routes/SKILL.md +4 -2
  23. package/skills/typesafety/generated-files-and-cli.md +16 -9
  24. package/skills/typesafety/route-types.md +5 -1
  25. package/skills/use-cache/SKILL.md +47 -0
  26. package/src/browser/event-controller.ts +40 -15
  27. package/src/browser/partial-update.ts +26 -11
  28. package/src/browser/react/NavigationProvider.tsx +7 -0
  29. package/src/cache/cache-runtime.ts +89 -15
  30. package/src/cache/cf/cf-cache-constants.ts +8 -1
  31. package/src/cache/cf/cf-cache-store.ts +41 -64
  32. package/src/cache/cf/cf-cache-types.ts +1 -1
  33. package/src/cache/cf/cf-kv-utils.ts +38 -0
  34. package/src/cache/segment-codec.ts +21 -5
  35. package/src/handles/is-thenable.ts +2 -4
  36. package/src/router/match-middleware/cache-lookup.ts +24 -15
  37. package/src/rsc/handler.ts +26 -5
  38. package/src/rsc/helpers.ts +13 -0
  39. package/src/rsc/progressive-enhancement.ts +247 -70
  40. package/src/rsc/render-pipeline.ts +68 -24
  41. package/src/rsc/routine-plan.ts +359 -0
  42. package/src/rsc/rsc-rendering.ts +555 -302
  43. package/src/rsc/server-action.ts +180 -71
  44. package/src/rsc/shell-capture-constants.ts +18 -0
  45. package/src/rsc/shell-capture.ts +92 -21
  46. package/src/server/request-context.ts +6 -0
  47. package/src/ssr/ssr-root.tsx +1 -0
  48. package/src/vite/encryption-key.ts +29 -0
  49. package/src/vite/plugins/expose-action-id.ts +2 -2
  50. package/src/vite/plugins/expose-internal-ids.ts +46 -0
  51. package/src/vite/plugins/server-ref-hashing.ts +74 -0
  52. package/src/vite/plugins/server-reference-pattern.ts +10 -0
  53. package/src/vite/rango.ts +9 -0
  54. package/src/vite/router-discovery.ts +21 -2
  55. package/src/vite/utils/shared-utils.ts +12 -7
  56. package/dist/types.backup/__internal.d.ts +0 -127
  57. package/dist/types.backup/bin/rango.d.ts +0 -1
  58. package/dist/types.backup/browser/action-coordinator.d.ts +0 -57
  59. package/dist/types.backup/browser/action-fence.d.ts +0 -33
  60. package/dist/types.backup/browser/app-shell.d.ts +0 -34
  61. package/dist/types.backup/browser/app-version.d.ts +0 -6
  62. package/dist/types.backup/browser/connection-warmup.d.ts +0 -31
  63. package/dist/types.backup/browser/cookie-name.d.ts +0 -66
  64. package/dist/types.backup/browser/event-controller.d.ts +0 -221
  65. package/dist/types.backup/browser/history-state.d.ts +0 -26
  66. package/dist/types.backup/browser/index.d.ts +0 -1
  67. package/dist/types.backup/browser/intercept-utils.d.ts +0 -30
  68. package/dist/types.backup/browser/invalidate-client-cache.d.ts +0 -17
  69. package/dist/types.backup/browser/link-interceptor.d.ts +0 -43
  70. package/dist/types.backup/browser/logging.d.ts +0 -33
  71. package/dist/types.backup/browser/merge-segment-loaders.d.ts +0 -38
  72. package/dist/types.backup/browser/navigation-bridge.d.ts +0 -27
  73. package/dist/types.backup/browser/navigation-client.d.ts +0 -17
  74. package/dist/types.backup/browser/navigation-store-handle.d.ts +0 -25
  75. package/dist/types.backup/browser/navigation-store.d.ts +0 -95
  76. package/dist/types.backup/browser/navigation-transaction.d.ts +0 -75
  77. package/dist/types.backup/browser/network-error-handler.d.ts +0 -35
  78. package/dist/types.backup/browser/partial-update.d.ts +0 -61
  79. package/dist/types.backup/browser/prefetch/cache.d.ts +0 -183
  80. package/dist/types.backup/browser/prefetch/fetch.d.ts +0 -52
  81. package/dist/types.backup/browser/prefetch/observer.d.ts +0 -27
  82. package/dist/types.backup/browser/prefetch/policy.d.ts +0 -13
  83. package/dist/types.backup/browser/prefetch/queue.d.ts +0 -48
  84. package/dist/types.backup/browser/prefetch/resource-ready.d.ts +0 -28
  85. package/dist/types.backup/browser/rango-state.d.ts +0 -52
  86. package/dist/types.backup/browser/react/Link.d.ts +0 -140
  87. package/dist/types.backup/browser/react/NavigationProvider.d.ts +0 -88
  88. package/dist/types.backup/browser/react/ScrollRestoration.d.ts +0 -78
  89. package/dist/types.backup/browser/react/context.d.ts +0 -54
  90. package/dist/types.backup/browser/react/filter-segment-order.d.ts +0 -35
  91. package/dist/types.backup/browser/react/index.d.ts +0 -1
  92. package/dist/types.backup/browser/react/location-state-shared.d.ts +0 -162
  93. package/dist/types.backup/browser/react/location-state.d.ts +0 -29
  94. package/dist/types.backup/browser/react/mount-context.d.ts +0 -23
  95. package/dist/types.backup/browser/react/nonce-context.d.ts +0 -14
  96. package/dist/types.backup/browser/react/shallow-equal.d.ts +0 -5
  97. package/dist/types.backup/browser/react/use-action.d.ts +0 -61
  98. package/dist/types.backup/browser/react/use-handle.d.ts +0 -21
  99. package/dist/types.backup/browser/react/use-href.d.ts +0 -32
  100. package/dist/types.backup/browser/react/use-link-status.d.ts +0 -36
  101. package/dist/types.backup/browser/react/use-mount.d.ts +0 -24
  102. package/dist/types.backup/browser/react/use-navigation.d.ts +0 -15
  103. package/dist/types.backup/browser/react/use-params.d.ts +0 -21
  104. package/dist/types.backup/browser/react/use-pathname.d.ts +0 -13
  105. package/dist/types.backup/browser/react/use-reverse.d.ts +0 -40
  106. package/dist/types.backup/browser/react/use-router.d.ts +0 -23
  107. package/dist/types.backup/browser/react/use-search-params.d.ts +0 -19
  108. package/dist/types.backup/browser/react/use-segments.d.ts +0 -29
  109. package/dist/types.backup/browser/response-adapter.d.ts +0 -58
  110. package/dist/types.backup/browser/rsc-router.d.ts +0 -141
  111. package/dist/types.backup/browser/scroll-restoration.d.ts +0 -103
  112. package/dist/types.backup/browser/segment-reconciler.d.ts +0 -74
  113. package/dist/types.backup/browser/segment-structure-assert.d.ts +0 -16
  114. package/dist/types.backup/browser/server-action-bridge.d.ts +0 -29
  115. package/dist/types.backup/browser/types.d.ts +0 -530
  116. package/dist/types.backup/browser/validate-redirect-origin.d.ts +0 -28
  117. package/dist/types.backup/build/collect-fallback-refs.d.ts +0 -5
  118. package/dist/types.backup/build/generate-manifest.d.ts +0 -100
  119. package/dist/types.backup/build/generate-route-types.d.ts +0 -8
  120. package/dist/types.backup/build/index.d.ts +0 -21
  121. package/dist/types.backup/build/prefix-tree-utils.d.ts +0 -56
  122. package/dist/types.backup/build/route-trie.d.ts +0 -89
  123. package/dist/types.backup/build/route-types/ast-helpers.d.ts +0 -3
  124. package/dist/types.backup/build/route-types/ast-route-extraction.d.ts +0 -13
  125. package/dist/types.backup/build/route-types/codegen.d.ts +0 -16
  126. package/dist/types.backup/build/route-types/include-resolution.d.ts +0 -74
  127. package/dist/types.backup/build/route-types/param-extraction.d.ts +0 -13
  128. package/dist/types.backup/build/route-types/per-module-writer.d.ts +0 -18
  129. package/dist/types.backup/build/route-types/router-processing.d.ts +0 -82
  130. package/dist/types.backup/build/route-types/scan-filter.d.ts +0 -17
  131. package/dist/types.backup/build/route-types/source-scan.d.ts +0 -13
  132. package/dist/types.backup/build/runtime-discovery.d.ts +0 -24
  133. package/dist/types.backup/cache/background-task.d.ts +0 -21
  134. package/dist/types.backup/cache/cache-error.d.ts +0 -71
  135. package/dist/types.backup/cache/cache-key-utils.d.ts +0 -35
  136. package/dist/types.backup/cache/cache-policy.d.ts +0 -59
  137. package/dist/types.backup/cache/cache-runtime.d.ts +0 -51
  138. package/dist/types.backup/cache/cache-scope.d.ts +0 -134
  139. package/dist/types.backup/cache/cache-tag.d.ts +0 -79
  140. package/dist/types.backup/cache/cf/cf-base64.d.ts +0 -4
  141. package/dist/types.backup/cache/cf/cf-cache-constants.d.ts +0 -105
  142. package/dist/types.backup/cache/cf/cf-cache-store.d.ts +0 -481
  143. package/dist/types.backup/cache/cf/cf-cache-types.d.ts +0 -300
  144. package/dist/types.backup/cache/cf/cf-kv-utils.d.ts +0 -22
  145. package/dist/types.backup/cache/cf/cf-tag-marker-memo.d.ts +0 -15
  146. package/dist/types.backup/cache/cf/index.d.ts +0 -3
  147. package/dist/types.backup/cache/document-cache.d.ts +0 -69
  148. package/dist/types.backup/cache/handle-capture.d.ts +0 -23
  149. package/dist/types.backup/cache/handle-snapshot.d.ts +0 -39
  150. package/dist/types.backup/cache/index.d.ts +0 -7
  151. package/dist/types.backup/cache/memory-segment-store.d.ts +0 -163
  152. package/dist/types.backup/cache/profile-registry.d.ts +0 -40
  153. package/dist/types.backup/cache/read-through-swr.d.ts +0 -60
  154. package/dist/types.backup/cache/segment-codec.d.ts +0 -78
  155. package/dist/types.backup/cache/shell-snapshot.d.ts +0 -162
  156. package/dist/types.backup/cache/tag-invalidation.d.ts +0 -74
  157. package/dist/types.backup/cache/taint.d.ts +0 -71
  158. package/dist/types.backup/cache/types.d.ts +0 -407
  159. package/dist/types.backup/cache/vercel/index.d.ts +0 -1
  160. package/dist/types.backup/cache/vercel/vercel-cache-store.d.ts +0 -267
  161. package/dist/types.backup/client.d.ts +0 -184
  162. package/dist/types.backup/client.rsc.d.ts +0 -39
  163. package/dist/types.backup/cloudflare/index.d.ts +0 -7
  164. package/dist/types.backup/cloudflare/tracing.d.ts +0 -53
  165. package/dist/types.backup/component-utils.d.ts +0 -46
  166. package/dist/types.backup/components/DefaultDocument.d.ts +0 -13
  167. package/dist/types.backup/context-var.d.ts +0 -84
  168. package/dist/types.backup/debug.d.ts +0 -57
  169. package/dist/types.backup/decode-loader-results.d.ts +0 -5
  170. package/dist/types.backup/default-error-boundary.d.ts +0 -10
  171. package/dist/types.backup/defer.d.ts +0 -89
  172. package/dist/types.backup/deps/browser.d.ts +0 -1
  173. package/dist/types.backup/deps/html-stream-client.d.ts +0 -1
  174. package/dist/types.backup/deps/html-stream-server.d.ts +0 -1
  175. package/dist/types.backup/deps/rsc.d.ts +0 -1
  176. package/dist/types.backup/deps/ssr.d.ts +0 -1
  177. package/dist/types.backup/encode-kv.d.ts +0 -35
  178. package/dist/types.backup/errors.d.ts +0 -226
  179. package/dist/types.backup/escape-script.d.ts +0 -44
  180. package/dist/types.backup/handle.d.ts +0 -93
  181. package/dist/types.backup/handles/MetaTags.d.ts +0 -17
  182. package/dist/types.backup/handles/Scripts.d.ts +0 -38
  183. package/dist/types.backup/handles/breadcrumbs.d.ts +0 -43
  184. package/dist/types.backup/handles/deferred-resolution.d.ts +0 -53
  185. package/dist/types.backup/handles/is-thenable.d.ts +0 -12
  186. package/dist/types.backup/handles/meta.d.ts +0 -43
  187. package/dist/types.backup/handles/script.d.ts +0 -139
  188. package/dist/types.backup/host/cookie-handler.d.ts +0 -8
  189. package/dist/types.backup/host/errors.d.ts +0 -40
  190. package/dist/types.backup/host/index.d.ts +0 -33
  191. package/dist/types.backup/host/pattern-matcher.d.ts +0 -30
  192. package/dist/types.backup/host/router.d.ts +0 -12
  193. package/dist/types.backup/host/testing.d.ts +0 -41
  194. package/dist/types.backup/host/types.d.ts +0 -148
  195. package/dist/types.backup/host/utils.d.ts +0 -20
  196. package/dist/types.backup/href-client.d.ts +0 -214
  197. package/dist/types.backup/index.d.ts +0 -112
  198. package/dist/types.backup/index.rsc.d.ts +0 -51
  199. package/dist/types.backup/internal-debug.d.ts +0 -1
  200. package/dist/types.backup/loader-store.d.ts +0 -193
  201. package/dist/types.backup/loader.d.ts +0 -18
  202. package/dist/types.backup/loader.rsc.d.ts +0 -18
  203. package/dist/types.backup/missing-id-error.d.ts +0 -1
  204. package/dist/types.backup/outlet-context.d.ts +0 -12
  205. package/dist/types.backup/outlet-provider.d.ts +0 -12
  206. package/dist/types.backup/prerender/build-shell-capture.d.ts +0 -104
  207. package/dist/types.backup/prerender/param-hash.d.ts +0 -6
  208. package/dist/types.backup/prerender/shell-manifest-key.d.ts +0 -18
  209. package/dist/types.backup/prerender/store.d.ts +0 -62
  210. package/dist/types.backup/prerender.d.ts +0 -292
  211. package/dist/types.backup/redirect-origin.d.ts +0 -55
  212. package/dist/types.backup/regex-escape.d.ts +0 -6
  213. package/dist/types.backup/render-error-thrower.d.ts +0 -13
  214. package/dist/types.backup/response-utils.d.ts +0 -35
  215. package/dist/types.backup/reverse.d.ts +0 -206
  216. package/dist/types.backup/root-error-boundary.d.ts +0 -32
  217. package/dist/types.backup/route-content-wrapper.d.ts +0 -40
  218. package/dist/types.backup/route-definition/dsl-helpers.d.ts +0 -130
  219. package/dist/types.backup/route-definition/helper-factories.d.ts +0 -22
  220. package/dist/types.backup/route-definition/helpers-types.d.ts +0 -392
  221. package/dist/types.backup/route-definition/index.d.ts +0 -7
  222. package/dist/types.backup/route-definition/redirect.d.ts +0 -48
  223. package/dist/types.backup/route-definition/resolve-handler-use.d.ts +0 -19
  224. package/dist/types.backup/route-definition/use-item-types.d.ts +0 -1
  225. package/dist/types.backup/route-definition.d.ts +0 -1
  226. package/dist/types.backup/route-map-builder.d.ts +0 -127
  227. package/dist/types.backup/route-name.d.ts +0 -27
  228. package/dist/types.backup/route-types.d.ts +0 -172
  229. package/dist/types.backup/router/basename.d.ts +0 -10
  230. package/dist/types.backup/router/content-negotiation.d.ts +0 -91
  231. package/dist/types.backup/router/debug-manifest.d.ts +0 -7
  232. package/dist/types.backup/router/error-handling.d.ts +0 -76
  233. package/dist/types.backup/router/find-match.d.ts +0 -19
  234. package/dist/types.backup/router/handler-context.d.ts +0 -41
  235. package/dist/types.backup/router/instrument.d.ts +0 -161
  236. package/dist/types.backup/router/intercept-resolution.d.ts +0 -79
  237. package/dist/types.backup/router/lazy-includes.d.ts +0 -26
  238. package/dist/types.backup/router/loader-resolution.d.ts +0 -63
  239. package/dist/types.backup/router/logging.d.ts +0 -41
  240. package/dist/types.backup/router/manifest.d.ts +0 -8
  241. package/dist/types.backup/router/match-api.d.ts +0 -19
  242. package/dist/types.backup/router/match-context.d.ts +0 -184
  243. package/dist/types.backup/router/match-handlers.d.ts +0 -49
  244. package/dist/types.backup/router/match-middleware/background-revalidation.d.ts +0 -113
  245. package/dist/types.backup/router/match-middleware/cache-lookup.d.ts +0 -113
  246. package/dist/types.backup/router/match-middleware/cache-store.d.ts +0 -112
  247. package/dist/types.backup/router/match-middleware/index.d.ts +0 -80
  248. package/dist/types.backup/router/match-middleware/intercept-resolution.d.ts +0 -116
  249. package/dist/types.backup/router/match-middleware/segment-resolution.d.ts +0 -94
  250. package/dist/types.backup/router/match-pipelines.d.ts +0 -103
  251. package/dist/types.backup/router/match-result.d.ts +0 -114
  252. package/dist/types.backup/router/metrics.d.ts +0 -6
  253. package/dist/types.backup/router/middleware-types.d.ts +0 -74
  254. package/dist/types.backup/router/middleware.d.ts +0 -116
  255. package/dist/types.backup/router/navigation-snapshot.d.ts +0 -22
  256. package/dist/types.backup/router/params-util.d.ts +0 -8
  257. package/dist/types.backup/router/parse-pattern.d.ts +0 -38
  258. package/dist/types.backup/router/pattern-matching.d.ts +0 -169
  259. package/dist/types.backup/router/prefetch-cache-ttl.d.ts +0 -27
  260. package/dist/types.backup/router/prefetch-limits.d.ts +0 -20
  261. package/dist/types.backup/router/prerender-match.d.ts +0 -50
  262. package/dist/types.backup/router/preview-match.d.ts +0 -22
  263. package/dist/types.backup/router/request-classification.d.ts +0 -104
  264. package/dist/types.backup/router/revalidation.d.ts +0 -57
  265. package/dist/types.backup/router/route-snapshot.d.ts +0 -112
  266. package/dist/types.backup/router/router-context.d.ts +0 -137
  267. package/dist/types.backup/router/router-interfaces.d.ts +0 -432
  268. package/dist/types.backup/router/router-options.d.ts +0 -738
  269. package/dist/types.backup/router/router-registry.d.ts +0 -15
  270. package/dist/types.backup/router/segment-resolution/fresh.d.ts +0 -55
  271. package/dist/types.backup/router/segment-resolution/helpers.d.ts +0 -93
  272. package/dist/types.backup/router/segment-resolution/loader-cache.d.ts +0 -33
  273. package/dist/types.backup/router/segment-resolution/loader-mask.d.ts +0 -44
  274. package/dist/types.backup/router/segment-resolution/loader-snapshot.d.ts +0 -90
  275. package/dist/types.backup/router/segment-resolution/mask-nested.d.ts +0 -53
  276. package/dist/types.backup/router/segment-resolution/revalidation.d.ts +0 -85
  277. package/dist/types.backup/router/segment-resolution/static-store.d.ts +0 -17
  278. package/dist/types.backup/router/segment-resolution/streamed-handler-telemetry.d.ts +0 -16
  279. package/dist/types.backup/router/segment-resolution/view-transition-default.d.ts +0 -28
  280. package/dist/types.backup/router/segment-resolution.d.ts +0 -3
  281. package/dist/types.backup/router/segment-wrappers.d.ts +0 -53
  282. package/dist/types.backup/router/state-cookie-name.d.ts +0 -1
  283. package/dist/types.backup/router/substitute-pattern-params.d.ts +0 -23
  284. package/dist/types.backup/router/telemetry-otel.d.ts +0 -113
  285. package/dist/types.backup/router/telemetry.d.ts +0 -215
  286. package/dist/types.backup/router/timeout.d.ts +0 -68
  287. package/dist/types.backup/router/tracing.d.ts +0 -125
  288. package/dist/types.backup/router/trie-matching.d.ts +0 -32
  289. package/dist/types.backup/router/types.d.ts +0 -98
  290. package/dist/types.backup/router/url-params.d.ts +0 -26
  291. package/dist/types.backup/router.d.ts +0 -7
  292. package/dist/types.backup/rsc/capture-queue.d.ts +0 -6
  293. package/dist/types.backup/rsc/full-payload.d.ts +0 -22
  294. package/dist/types.backup/rsc/handler-context.d.ts +0 -31
  295. package/dist/types.backup/rsc/handler.d.ts +0 -9
  296. package/dist/types.backup/rsc/helpers.d.ts +0 -213
  297. package/dist/types.backup/rsc/index.d.ts +0 -17
  298. package/dist/types.backup/rsc/json-route-result.d.ts +0 -20
  299. package/dist/types.backup/rsc/loader-fetch.d.ts +0 -14
  300. package/dist/types.backup/rsc/manifest-init.d.ts +0 -18
  301. package/dist/types.backup/rsc/nonce.d.ts +0 -28
  302. package/dist/types.backup/rsc/origin-guard.d.ts +0 -50
  303. package/dist/types.backup/rsc/progressive-enhancement.d.ts +0 -19
  304. package/dist/types.backup/rsc/redirect-guard.d.ts +0 -35
  305. package/dist/types.backup/rsc/response-cache-serve.d.ts +0 -46
  306. package/dist/types.backup/rsc/response-error.d.ts +0 -19
  307. package/dist/types.backup/rsc/response-route-handler.d.ts +0 -29
  308. package/dist/types.backup/rsc/rsc-rendering.d.ts +0 -23
  309. package/dist/types.backup/rsc/runtime-warnings.d.ts +0 -22
  310. package/dist/types.backup/rsc/server-action.d.ts +0 -68
  311. package/dist/types.backup/rsc/shell-build-manifest.d.ts +0 -84
  312. package/dist/types.backup/rsc/shell-capture-constants.d.ts +0 -27
  313. package/dist/types.backup/rsc/shell-capture.d.ts +0 -374
  314. package/dist/types.backup/rsc/shell-serve.d.ts +0 -136
  315. package/dist/types.backup/rsc/ssr-setup.d.ts +0 -48
  316. package/dist/types.backup/rsc/transition-gate.d.ts +0 -27
  317. package/dist/types.backup/rsc/types.d.ts +0 -290
  318. package/dist/types.backup/runtime-env.d.ts +0 -1
  319. package/dist/types.backup/search-params.d.ts +0 -125
  320. package/dist/types.backup/segment-content-promise.d.ts +0 -13
  321. package/dist/types.backup/segment-fragments.d.ts +0 -56
  322. package/dist/types.backup/segment-loader-promise.d.ts +0 -22
  323. package/dist/types.backup/segment-system.d.ts +0 -84
  324. package/dist/types.backup/serialize.d.ts +0 -164
  325. package/dist/types.backup/server/context.d.ts +0 -494
  326. package/dist/types.backup/server/cookie-parse.d.ts +0 -10
  327. package/dist/types.backup/server/cookie-store.d.ts +0 -107
  328. package/dist/types.backup/server/fetchable-loader-store.d.ts +0 -20
  329. package/dist/types.backup/server/handle-store.d.ts +0 -100
  330. package/dist/types.backup/server/loader-registry.d.ts +0 -32
  331. package/dist/types.backup/server/request-context.d.ts +0 -596
  332. package/dist/types.backup/server/root-layout.d.ts +0 -3
  333. package/dist/types.backup/server.d.ts +0 -15
  334. package/dist/types.backup/ssr/index.d.ts +0 -233
  335. package/dist/types.backup/ssr/inject-rsc-eager.d.ts +0 -3
  336. package/dist/types.backup/ssr/preinit-client-references.d.ts +0 -71
  337. package/dist/types.backup/ssr/ssr-root.d.ts +0 -69
  338. package/dist/types.backup/static-handler.d.ts +0 -57
  339. package/dist/types.backup/testing/cache-status.d.ts +0 -63
  340. package/dist/types.backup/testing/collect-handle.d.ts +0 -20
  341. package/dist/types.backup/testing/dispatch.d.ts +0 -123
  342. package/dist/types.backup/testing/dom.entry.d.ts +0 -15
  343. package/dist/types.backup/testing/e2e/fixture.d.ts +0 -37
  344. package/dist/types.backup/testing/e2e/index.d.ts +0 -30
  345. package/dist/types.backup/testing/e2e/matchers.d.ts +0 -17
  346. package/dist/types.backup/testing/e2e/page-helpers.d.ts +0 -62
  347. package/dist/types.backup/testing/e2e/parity.d.ts +0 -111
  348. package/dist/types.backup/testing/e2e/server.d.ts +0 -35
  349. package/dist/types.backup/testing/flight-matchers.d.ts +0 -55
  350. package/dist/types.backup/testing/flight-normalize.d.ts +0 -1
  351. package/dist/types.backup/testing/flight-tree.d.ts +0 -192
  352. package/dist/types.backup/testing/flight.d.ts +0 -115
  353. package/dist/types.backup/testing/flight.entry.d.ts +0 -27
  354. package/dist/types.backup/testing/generated-routes.d.ts +0 -66
  355. package/dist/types.backup/testing/index.d.ts +0 -52
  356. package/dist/types.backup/testing/internal/context.d.ts +0 -225
  357. package/dist/types.backup/testing/internal/flight-client-globals.d.ts +0 -1
  358. package/dist/types.backup/testing/internal/seed-vars.d.ts +0 -30
  359. package/dist/types.backup/testing/render-handler.d.ts +0 -160
  360. package/dist/types.backup/testing/render-route.d.ts +0 -246
  361. package/dist/types.backup/testing/run-loader.d.ts +0 -186
  362. package/dist/types.backup/testing/run-middleware.d.ts +0 -132
  363. package/dist/types.backup/testing/run-transition-when.d.ts +0 -77
  364. package/dist/types.backup/testing/vitest-stubs/cloudflare-email.d.ts +0 -6
  365. package/dist/types.backup/testing/vitest-stubs/cloudflare-workers.d.ts +0 -13
  366. package/dist/types.backup/testing/vitest-stubs/plugin-rsc.d.ts +0 -7
  367. package/dist/types.backup/testing/vitest-stubs/version.d.ts +0 -1
  368. package/dist/types.backup/testing/vitest.d.ts +0 -205
  369. package/dist/types.backup/theme/ThemeProvider.d.ts +0 -13
  370. package/dist/types.backup/theme/ThemeScript.d.ts +0 -45
  371. package/dist/types.backup/theme/constants.d.ts +0 -39
  372. package/dist/types.backup/theme/index.d.ts +0 -29
  373. package/dist/types.backup/theme/theme-context.d.ts +0 -21
  374. package/dist/types.backup/theme/theme-script.d.ts +0 -26
  375. package/dist/types.backup/theme/types.d.ts +0 -162
  376. package/dist/types.backup/theme/use-theme.d.ts +0 -8
  377. package/dist/types.backup/types/boundaries.d.ts +0 -93
  378. package/dist/types.backup/types/cache-types.d.ts +0 -191
  379. package/dist/types.backup/types/error-types.d.ts +0 -114
  380. package/dist/types.backup/types/global-namespace.d.ts +0 -90
  381. package/dist/types.backup/types/handler-context.d.ts +0 -658
  382. package/dist/types.backup/types/index.d.ts +0 -11
  383. package/dist/types.backup/types/loader-types.d.ts +0 -182
  384. package/dist/types.backup/types/request-scope.d.ts +0 -93
  385. package/dist/types.backup/types/route-config.d.ts +0 -105
  386. package/dist/types.backup/types/route-entry.d.ts +0 -95
  387. package/dist/types.backup/types/segments.d.ts +0 -234
  388. package/dist/types.backup/types.d.ts +0 -1
  389. package/dist/types.backup/urls/include-helper.d.ts +0 -17
  390. package/dist/types.backup/urls/include-provider.d.ts +0 -27
  391. package/dist/types.backup/urls/index.d.ts +0 -6
  392. package/dist/types.backup/urls/path-helper-types.d.ts +0 -197
  393. package/dist/types.backup/urls/path-helper.d.ts +0 -12
  394. package/dist/types.backup/urls/pattern-types.d.ts +0 -166
  395. package/dist/types.backup/urls/response-types.d.ts +0 -67
  396. package/dist/types.backup/urls/type-extraction.d.ts +0 -157
  397. package/dist/types.backup/urls/urls-function.d.ts +0 -24
  398. package/dist/types.backup/urls.d.ts +0 -1
  399. package/dist/types.backup/use-loader.d.ts +0 -150
  400. package/dist/types.backup/vercel/index.d.ts +0 -10
  401. package/dist/types.backup/vercel/tracing.d.ts +0 -70
  402. package/dist/types.backup/vite/debug.d.ts +0 -80
  403. package/dist/types.backup/vite/discovery/bundle-postprocess.d.ts +0 -12
  404. package/dist/types.backup/vite/discovery/dev-prerender-cache.d.ts +0 -65
  405. package/dist/types.backup/vite/discovery/discover-routers.d.ts +0 -17
  406. package/dist/types.backup/vite/discovery/discovery-errors.d.ts +0 -113
  407. package/dist/types.backup/vite/discovery/gate-state.d.ts +0 -79
  408. package/dist/types.backup/vite/discovery/prerender-collection.d.ts +0 -24
  409. package/dist/types.backup/vite/discovery/route-types-writer.d.ts +0 -32
  410. package/dist/types.backup/vite/discovery/self-gen-tracking.d.ts +0 -22
  411. package/dist/types.backup/vite/discovery/shell-prerender-phase.d.ts +0 -40
  412. package/dist/types.backup/vite/discovery/state.d.ts +0 -162
  413. package/dist/types.backup/vite/discovery/virtual-module-codegen.d.ts +0 -15
  414. package/dist/types.backup/vite/index.d.ts +0 -11
  415. package/dist/types.backup/vite/inject-client-debug.d.ts +0 -56
  416. package/dist/types.backup/vite/plugin-types.d.ts +0 -298
  417. package/dist/types.backup/vite/plugins/cjs-to-esm.d.ts +0 -6
  418. package/dist/types.backup/vite/plugins/client-ref-dedup.d.ts +0 -40
  419. package/dist/types.backup/vite/plugins/client-ref-hashing.d.ts +0 -35
  420. package/dist/types.backup/vite/plugins/cloudflare-protocol-stub.d.ts +0 -64
  421. package/dist/types.backup/vite/plugins/expose-action-id.d.ts +0 -18
  422. package/dist/types.backup/vite/plugins/expose-id-utils.d.ts +0 -37
  423. package/dist/types.backup/vite/plugins/expose-ids/export-analysis.d.ts +0 -19
  424. package/dist/types.backup/vite/plugins/expose-ids/handler-transform.d.ts +0 -10
  425. package/dist/types.backup/vite/plugins/expose-ids/loader-transform.d.ts +0 -8
  426. package/dist/types.backup/vite/plugins/expose-ids/router-transform.d.ts +0 -13
  427. package/dist/types.backup/vite/plugins/expose-ids/types.d.ts +0 -29
  428. package/dist/types.backup/vite/plugins/expose-internal-ids.d.ts +0 -6
  429. package/dist/types.backup/vite/plugins/performance-tracks.d.ts +0 -25
  430. package/dist/types.backup/vite/plugins/refresh-cmd.d.ts +0 -20
  431. package/dist/types.backup/vite/plugins/use-cache-transform.d.ts +0 -20
  432. package/dist/types.backup/vite/plugins/vercel-output.d.ts +0 -85
  433. package/dist/types.backup/vite/plugins/version-injector.d.ts +0 -21
  434. package/dist/types.backup/vite/plugins/version-plugin.d.ts +0 -19
  435. package/dist/types.backup/vite/plugins/virtual-entries.d.ts +0 -36
  436. package/dist/types.backup/vite/plugins/virtual-stub-plugin.d.ts +0 -7
  437. package/dist/types.backup/vite/rango.d.ts +0 -29
  438. package/dist/types.backup/vite/router-discovery.d.ts +0 -23
  439. package/dist/types.backup/vite/utils/ast-handler-extract.d.ts +0 -64
  440. package/dist/types.backup/vite/utils/banner.d.ts +0 -2
  441. package/dist/types.backup/vite/utils/bundle-analysis.d.ts +0 -28
  442. package/dist/types.backup/vite/utils/client-chunks.d.ts +0 -55
  443. package/dist/types.backup/vite/utils/directive-prologue.d.ts +0 -16
  444. package/dist/types.backup/vite/utils/forward-user-plugins.d.ts +0 -37
  445. package/dist/types.backup/vite/utils/manifest-utils.d.ts +0 -7
  446. package/dist/types.backup/vite/utils/package-resolution.d.ts +0 -6
  447. package/dist/types.backup/vite/utils/prerender-utils.d.ts +0 -32
  448. package/dist/types.backup/vite/utils/shared-utils.d.ts +0 -55
@@ -1,658 +0,0 @@
1
- import type { ReactNode } from "react";
2
- import type { Handle } from "../handle.js";
3
- import type { HandlePush } from "../defer.js";
4
- import type { ContextVar } from "../context-var.js";
5
- import type { MiddlewareFn } from "../router/middleware.js";
6
- import type { Theme } from "../theme/types.js";
7
- import type { ScopedReverseFunction } from "../reverse.js";
8
- import type { SearchSchema, ResolveSearchSchema } from "../search-params.js";
9
- import type { LocationStateEntry } from "../browser/react/location-state-shared.js";
10
- import type { DefaultEnv, DefaultHandlerRouteMap, DefaultReverseRouteMap, DefaultRouteName, DefaultVars } from "./global-namespace.js";
11
- import type { ExtractParams, RouteDefinition, ResolvedRouteMap } from "./route-config.js";
12
- import type { LoaderDefinition } from "./loader-types.js";
13
- import type { UseItems, HandlerUseItem } from "../route-types.js";
14
- import type { RequestScope } from "./request-scope.js";
15
- export type { MiddlewareFn } from "../router/middleware.js";
16
- /**
17
- * Create a scoped view of a route map by stripping a name prefix.
18
- * Useful for handlers in modules mounted via include() -- use the local
19
- * route name instead of the fully qualified global name.
20
- *
21
- * @example
22
- * ```typescript
23
- * // Given GeneratedRouteMap: { "blog.index": "/blog"; "blog.post": "/blog/:postId"; ... }
24
- * type BlogRoutes = ScopedRouteMap<"blog">;
25
- * // Resolves to: { "index": "/blog"; "post": "/blog/:postId" }
26
- *
27
- * const handler: Handler<"post", BlogRoutes> = (ctx) => {
28
- * ctx.params.postId // string
29
- * };
30
- * ```
31
- */
32
- export type ScopedRouteMap<TPrefix extends string, TMap = Rango.GeneratedRouteMap> = {
33
- [K in keyof TMap as K extends `${TPrefix}.${infer Rest}` ? Rest : never]: TMap[K];
34
- };
35
- /**
36
- * Extract the search schema from a route map entry.
37
- * - string value (old format): no search schema -> {}
38
- * - { path, search } value: extract search
39
- * - { path, response } value (no search): -> {}
40
- */
41
- /** Extract params from a route map entry (string pattern or { path } object). */
42
- type ExtractParamsFromEntry<TEntry, TFallback> = TEntry extends string ? ExtractParams<TEntry> : TEntry extends {
43
- readonly path: infer P extends string;
44
- } ? ExtractParams<P> : TFallback;
45
- /** Extract search schema from a route map entry. */
46
- type ExtractSearchFromEntry<TMap, TKey> = TKey extends keyof TMap ? TMap[TKey] extends {
47
- readonly search: infer S extends SearchSchema;
48
- } ? S : {} : {};
49
- type IsEmptyObject<T> = keyof T extends never ? true : false;
50
- type AutofillParamsFromEntry<TEntry> = TEntry extends string ? string extends TEntry ? Record<string, string> : Partial<ExtractParams<TEntry>> : TEntry extends {
51
- readonly path: infer P extends string;
52
- } ? string extends P ? Record<string, string> : Partial<ExtractParams<P>> : Record<string, string>;
53
- type AutofillSearchFromEntry<TMap, TKey> = TKey extends keyof TMap ? TMap[TKey] extends {
54
- readonly search: infer S extends SearchSchema;
55
- } ? ResolveSearchSchema<S> : Record<string, unknown> : Record<string, unknown>;
56
- type AutofillAwareReverseFunction<TLocalRoutes, TGlobalRoutes> = ScopedReverseFunction<TLocalRoutes, TGlobalRoutes> & {
57
- <TName extends keyof TGlobalRoutes & string>(name: TName, params?: AutofillParamsFromEntry<TGlobalRoutes[TName]>, search?: AutofillSearchFromEntry<TGlobalRoutes, TName>): string;
58
- <TName extends keyof TLocalRoutes & string>(name: `.${TName}`, params?: AutofillParamsFromEntry<TLocalRoutes[TName]>, search?: AutofillSearchFromEntry<TLocalRoutes, TName>): string;
59
- };
60
- type StrictLocalParamsWithExtras<TEntry> = IsEmptyObject<ExtractParamsFromEntry<TEntry, {}>> extends true ? Record<string, string> : ExtractParamsFromEntry<TEntry, {}> & Record<string, string>;
61
- type StrictLocalAutofillGlobalReverseFunction<TLocalRoutes, TGlobalRoutes> = ScopedReverseFunction<TLocalRoutes, TGlobalRoutes> & {
62
- <TName extends keyof TGlobalRoutes & string>(name: TName, params?: AutofillParamsFromEntry<TGlobalRoutes[TName]>, search?: AutofillSearchFromEntry<TGlobalRoutes, TName>): string;
63
- <TName extends keyof TLocalRoutes & string>(name: `.${TName}`, params: StrictLocalParamsWithExtras<TLocalRoutes[TName]>, search?: AutofillSearchFromEntry<TLocalRoutes, TName>): string;
64
- };
65
- export type Handler<T extends keyof DefaultHandlerRouteMap | `.${keyof TRouteMap & string}` | `/${string}` | Record<string, any> = {}, TRouteMap extends {} = DefaultHandlerRouteMap, TEnv = DefaultEnv> = ((ctx: HandlerContext<T extends `.${infer Local}` ? Local extends keyof TRouteMap ? ExtractParamsFromEntry<TRouteMap[Local], T extends string ? ExtractParams<T> : T> : T extends string ? ExtractParams<T> : T : T extends keyof DefaultHandlerRouteMap ? ExtractParamsFromEntry<DefaultHandlerRouteMap[T], T extends string ? ExtractParams<T> : T> : T extends string ? ExtractParams<T> : T, TEnv, T extends `.${infer Local}` ? ExtractSearchFromEntry<TRouteMap, Local> : ExtractSearchFromEntry<DefaultHandlerRouteMap, T>, TRouteMap extends DefaultHandlerRouteMap ? never : TRouteMap>) => ReactNode | Response | Promise<ReactNode | Response>) & {
66
- /** Composable default DSL items merged when the handler is mounted. */
67
- use?: () => UseItems<HandlerUseItem>;
68
- };
69
- /**
70
- * Context passed to handlers (Hono-inspired type-safe context)
71
- *
72
- * Provides type-safe access to:
73
- * - Route params (from URL pattern)
74
- * - Cleaned route URL (`url`, `searchParams`, `pathname` — no `_rsc*` params)
75
- * - Original request (`request` — raw transport URL, headers, method, body)
76
- * - Platform bindings (env.DB, env.KV, env.SECRETS)
77
- * - Middleware variables (`get("user")`, `get("permissions")`)
78
- * - Getter/setter for variables (get('user'), set('user', ...))
79
- *
80
- * @example
81
- * ```typescript
82
- * const handler = (ctx: HandlerContext<{ slug: string }, AppEnv>) => {
83
- * ctx.params.slug // Route param (string)
84
- * ctx.env.DB // Binding (D1Database)
85
- * ctx.get('user') // Variable (User | undefined)
86
- * ctx.set('user', {...}) // Setter
87
- * ctx.url // Clean URL (no _rsc* params)
88
- * ctx.searchParams // Clean params (no _rsc* params)
89
- * ctx.request // Raw transport request (original URL intact)
90
- * }
91
- * ```
92
- */
93
- export type HandlerContext<TParams = {}, TEnv = DefaultEnv, TSearch extends SearchSchema = {}, TRouteMap = never> = RequestScope<TEnv> & {
94
- /**
95
- * Route parameters extracted from the URL pattern.
96
- * Type-safe when using Handler<"/path/:param"> or Handler<{ param: string }>.
97
- */
98
- params: TParams;
99
- /** @internal Phantom property for params type invariance. Prevents mounting handlers on wrong routes. */
100
- readonly _paramCheck?: (params: TParams) => TParams;
101
- /**
102
- * True during build-time pre-rendering, false at runtime.
103
- * Build-time collection and dev on-demand prerender use `true`.
104
- * Live request rendering, including passthrough fallback, uses `false`.
105
- */
106
- readonly build: boolean;
107
- /**
108
- * Opt this request out of PPR shell serving/capture.
109
- * Middleware can call this before a shell HIT commits. Handlers run after
110
- * that commit point, so they only prevent scheduling a new capture on MISS.
111
- *
112
- * Scope: this gates the PPR SHELL axis only. It does NOT disable prerender
113
- * B-segment (Prerender/Static) serving — a Prerender() route's build-baked
114
- * segments still replay at runtime — and it is inert in the prerender-collect
115
- * and static-render contexts, which have no live shell decision to influence.
116
- */
117
- dynamic(): void;
118
- /**
119
- * True when running in Vite dev mode, false during production build or
120
- * live request rendering. Use this to branch on runtime mode without
121
- * changing build semantics (e.g., skip expensive operations in dev).
122
- */
123
- dev: boolean;
124
- /**
125
- * Typed search parameters parsed from URL query string via the route's
126
- * search schema. Empty object when no schema is defined.
127
- */
128
- search: {} extends TSearch ? {} : ResolveSearchSchema<TSearch>;
129
- /**
130
- * Type-safe getter for middleware variables.
131
- * Preferred way to read middleware-injected variables.
132
- *
133
- * @example
134
- * ```typescript
135
- * const user = ctx.get("user"); // Type-safe!
136
- * ```
137
- */
138
- get: {
139
- <T>(contextVar: ContextVar<T>): T | undefined;
140
- } & (<K extends keyof DefaultVars>(key: K) => DefaultVars[K]);
141
- /**
142
- * Type-safe setter for middleware variables.
143
- * Use in middleware to pass data to handlers.
144
- *
145
- * @example
146
- * ```typescript
147
- * ctx.set("user", { id: "123", name: "John" }); // Type-safe!
148
- * ctx.set(MyVar, { ... }); // Type-safe via ContextVar token!
149
- * ```
150
- */
151
- set: {
152
- <T>(contextVar: ContextVar<T>, value: T, options?: {
153
- cache?: boolean;
154
- }): void;
155
- } & (<K extends keyof DefaultVars>(key: K, value: DefaultVars[K], options?: {
156
- cache?: boolean;
157
- }) => void);
158
- /**
159
- * Response headers. Headers set here are merged into the final response.
160
- *
161
- * @example
162
- * ```typescript
163
- * route("product", (ctx) => {
164
- * ctx.headers.set("Cache-Control", "s-maxage=60");
165
- * return <ProductPage />;
166
- * });
167
- * ```
168
- */
169
- headers: Headers;
170
- /**
171
- * Access loader data or push handle data.
172
- *
173
- * Available in route handlers, layout handlers, middleware, server actions,
174
- * and server components rendered within the request context.
175
- *
176
- * For loaders: Returns a promise that resolves to the loader data.
177
- * Loaders are executed in parallel and memoized per request.
178
- * Prefer DSL `loader()` + client `useLoader()` over `ctx.use(Loader)` —
179
- * DSL loaders are always fresh and cache-safe. Use `ctx.use(Loader)` only
180
- * when you need loader data in the handler itself (e.g., to set context
181
- * variables or make routing decisions).
182
- *
183
- * For handles: Returns a push function to add data for this segment.
184
- * Handle data accumulates across all matched route segments.
185
- * Push accepts: direct value, Promise, or async callback (executed immediately).
186
- * Or call `.defer()` to reserve the slot now and resolve it later (e.g. from a
187
- * deep async component), with a timeout safety net — see {@link HandlePush}.
188
- *
189
- * @example
190
- * ```typescript
191
- * // Loader escape hatch — use when handler needs the data directly
192
- * route("product", async (ctx) => {
193
- * const { product } = await ctx.use(ProductLoader);
194
- * ctx.set(Product, product); // make available to children
195
- * return <ProductPage />;
196
- * });
197
- *
198
- * // Handle usage - direct value
199
- * route("shop", (ctx) => {
200
- * const push = ctx.use(Breadcrumbs);
201
- * push({ label: "Shop", href: "/shop" });
202
- * return <ShopPage />;
203
- * });
204
- *
205
- * // Handle usage - Promise
206
- * route("product", (ctx) => {
207
- * const push = ctx.use(Breadcrumbs);
208
- * push(fetchProductBreadcrumb(ctx.params.id));
209
- * return <ProductPage />;
210
- * });
211
- *
212
- * // Handle usage - async callback (executed immediately)
213
- * route("product", (ctx) => {
214
- * const push = ctx.use(Breadcrumbs);
215
- * push(async () => {
216
- * const product = await db.getProduct(ctx.params.id);
217
- * return { label: product.name, href: `/product/${product.id}` };
218
- * });
219
- * return <ProductPage />;
220
- * });
221
- *
222
- * // Handle usage - deferred (reserve the slot now, resolve from a deep component)
223
- * route("product", (ctx) => {
224
- * const resolve = ctx.use(Breadcrumbs).defer({ timeoutMs: 5000, else: null });
225
- * loadCrumb(ctx.params.id).then(resolve); // resolver is push-equal
226
- * return <ProductPage />; // auto-resolves to `else` on timeout
227
- * });
228
- * ```
229
- */
230
- use: {
231
- <T, TLoaderParams = any>(loader: LoaderDefinition<T, TLoaderParams>): Promise<T>;
232
- <TData, TAccumulated = TData[]>(handle: Handle<TData, TAccumulated>): HandlePush<TData>;
233
- };
234
- /**
235
- * Current theme (from cookie or default).
236
- * Only available when theme is enabled in router config.
237
- *
238
- * @example
239
- * ```typescript
240
- * route("settings", (ctx) => {
241
- * const currentTheme = ctx.theme; // "light" | "dark" | "system" | undefined
242
- * return <SettingsPage theme={currentTheme} />;
243
- * });
244
- * ```
245
- */
246
- theme?: Theme;
247
- /**
248
- * Set the theme (only available when theme is enabled in router config).
249
- * Sets a cookie with the new theme value.
250
- *
251
- * @example
252
- * ```typescript
253
- * route("settings", async (ctx) => {
254
- * if (ctx.request.method === "POST") {
255
- * const formData = await ctx.request.formData();
256
- * const newTheme = formData.get("theme") as Theme;
257
- * ctx.setTheme?.(newTheme);
258
- * }
259
- * return <SettingsPage />;
260
- * });
261
- * ```
262
- */
263
- setTheme?: (theme: Theme) => void;
264
- /**
265
- * Attach location state entries to this response.
266
- * State is delivered to the client via history.pushState and accessible
267
- * through the useLocationState() hook.
268
- *
269
- * @example
270
- * ```typescript
271
- * route("product", (ctx) => {
272
- * ctx.setLocationState(ServerInfo({ data: "value" }));
273
- * return <ProductPage />;
274
- * });
275
- * ```
276
- */
277
- setLocationState(entries: LocationStateEntry | LocationStateEntry[]): void;
278
- /**
279
- * The matched route name, if the route has an explicit name.
280
- * Undefined for unnamed routes (those without a `name` option in path()).
281
- * Includes the namespace prefix from include() (e.g., "blog.post").
282
- *
283
- * @example
284
- * ```typescript
285
- * route("product", (ctx) => {
286
- * ctx.routeName // "product"
287
- * return <ProductPage />;
288
- * });
289
- * ```
290
- */
291
- routeName?: DefaultRouteName;
292
- /**
293
- * Generate URLs from route names.
294
- *
295
- * - `.name` -- local route, resolved within current include() scope
296
- * - `name` -- global route, from the named-routes definition
297
- *
298
- * @example
299
- * ```typescript
300
- * ctx.reverse(".article", { slug: "hello" }) // Local: magazine.article
301
- * ctx.reverse(".index") // Local: magazine.index
302
- * ctx.reverse("magazine.index") // Global: magazine.index
303
- * ctx.reverse("blog.post", { slug: "hello" }) // Global: blog.post
304
- * ```
305
- */
306
- reverse: [TRouteMap] extends [never] ? AutofillAwareReverseFunction<Record<string, string>, DefaultReverseRouteMap> : StrictLocalAutofillGlobalReverseFunction<TRouteMap, DefaultReverseRouteMap>;
307
- };
308
- /**
309
- * Internal handler context with additional props for router internals.
310
- * Use `HandlerContext` for user-facing code.
311
- * @internal
312
- */
313
- export type InternalHandlerContext<TParams = {}, TEnv = DefaultEnv, TSearch extends SearchSchema = {}> = HandlerContext<TParams, TEnv, TSearch> & {
314
- /** @internal Stub response for collecting headers/cookies. */
315
- res: Response;
316
- /** @internal Shared variable backing store for ctx.get()/ctx.set(). */
317
- _variables: Record<string, any>;
318
- /** Prerender-only control flow helper, attached when the runtime context supports it. */
319
- passthrough?: () => unknown;
320
- /** Current segment ID for handle data attribution. */
321
- _currentSegmentId?: string;
322
- /** Response type tag (json, text, html, etc.) for cache key differentiation. */
323
- _responseType?: string;
324
- /** Route name for cache key scoping (prevents cross-route collisions). */
325
- _routeName?: string;
326
- /**
327
- * @internal Loader-cache override table: loaderId -> memoized data promise.
328
- * A single stable ctx.use interceptor consults this instead of chaining one
329
- * wrapper per cached loader (avoids O(N) dispatch). See loader-cache.ts.
330
- */
331
- _loaderCacheOverrides?: Map<string, Promise<any>>;
332
- /**
333
- * @internal ctx.use captured before the loader-cache interceptor was installed.
334
- * The cache-miss execute runs the loader through this, bypassing the override
335
- * table (so a loader cannot await its own in-flight memoized promise).
336
- */
337
- _loaderCacheOriginalUse?: (item: any) => any;
338
- };
339
- /**
340
- * Generic params type - flexible object with string keys
341
- * Users can narrow this by explicitly typing their params:
342
- *
343
- * @example
344
- * ```typescript
345
- * [revalidate('post')]: (({ currentParams, nextParams }: RevalidateParams<{ slug: string }>) => {
346
- * currentParams.slug // typed as string
347
- * return currentParams.slug !== nextParams.slug;
348
- * })
349
- * ```
350
- */
351
- export type GenericParams = {
352
- [key: string]: string | undefined;
353
- };
354
- /**
355
- * Helper type for revalidation handler params
356
- * Allows inline type annotation for stricter param typing
357
- *
358
- * @example
359
- * ```typescript
360
- * [revalidate('post')]: (params: RevalidateParams<{ slug: string }>) => {
361
- * params.currentParams.slug // typed as string
362
- * return params.defaultShouldRevalidate;
363
- * }
364
- * ```
365
- */
366
- export type RevalidateParams<TParams = GenericParams, TEnv = any> = Parameters<ShouldRevalidateFn<TParams, TEnv>>[0];
367
- /**
368
- * Should revalidate function signature (inspired by React Router)
369
- *
370
- * Determines whether a route segment should re-render during partial navigation.
371
- * Multiple revalidation functions can be defined per route - they execute in order.
372
- *
373
- * **Return Types:**
374
- * - `boolean` - Hard decision: immediately returns this value (short-circuits)
375
- * - `{ defaultShouldRevalidate: boolean }` - Soft decision: updates suggestion for next revalidator
376
- * - `void` / `null` / `undefined` - Defer to the current suggestion (no opinion); the
377
- * loop continues to the next revalidator without changing the running default
378
- *
379
- * **Execution Flow:**
380
- * 1. Start with built-in `defaultShouldRevalidate` (true if params changed)
381
- * 2. Execute global revalidators first, then route-specific
382
- * 3. Hard decision (boolean): stop immediately and use that value
383
- * 4. Soft decision (object): update suggestion and continue to next revalidator
384
- * 5. Defer (`void` / `null` / `undefined`): leave suggestion unchanged and continue
385
- * 6. If no hard decision was returned: use the final running suggestion
386
- *
387
- * @param args.currentParams - Previous route params (generic by default, can be narrowed)
388
- * @param args.currentUrl - Previous URL
389
- * @param args.nextParams - Next route params (generic by default, can be narrowed)
390
- * @param args.nextUrl - Next URL
391
- * @param args.defaultShouldRevalidate - Current suggestion (updated by soft decisions)
392
- * @param args.context - App context (db, user, etc.)
393
- * @param args.actionResult - Result from action (future support)
394
- * @param args.formData - Form data from action (future support)
395
- * @param args.method - HTTP method: "GET" for navigation, "POST" for server actions
396
- *
397
- * @returns Hard decision (boolean), soft suggestion (object), or defer
398
- * (`void` / `null` / `undefined`) to keep the running suggestion as-is.
399
- *
400
- * @example
401
- * ```typescript
402
- * // Hard decision - definitive answer
403
- * [revalidate('post')]: ({ currentParams, nextParams }) => {
404
- * return currentParams.slug !== nextParams.slug; // boolean - short-circuits
405
- * }
406
- *
407
- * // Soft decision - allows downstream revalidators to override
408
- * [revalidate('*', 'global')]: ({ defaultShouldRevalidate }) => {
409
- * return { defaultShouldRevalidate: true }; // object - continues to next
410
- * }
411
- *
412
- * // Explicit typing for stricter params
413
- * [revalidate('post')]: ((params: RevalidateParams<{ slug: string }>) => {
414
- * return params.currentParams.slug !== params.nextParams.slug;
415
- * })
416
- * ```
417
- */
418
- /**
419
- * A reference to a server action, used by `isAction()` in a revalidate predicate.
420
- *
421
- * Either a directly imported action (`import { addToCart }`) or a namespace
422
- * import of an action module (`import * as CartActions`). Matching resolves the
423
- * action's build-injected id (`path#export`) — the same identity the router uses
424
- * for `actionId` — so a renamed or moved action breaks at compile time instead
425
- * of silently failing to match.
426
- */
427
- export type ActionRef = ((...args: never[]) => unknown) | Record<string, unknown>;
428
- /**
429
- * Revalidation function called during client-side navigation to decide whether
430
- * a segment (layout, route, parallel slot, or loader) should be re-rendered.
431
- *
432
- * Return `true` to re-render, `false` to skip (keep client's current version),
433
- * `{ defaultShouldRevalidate: boolean }` to update the running suggestion for
434
- * downstream revalidators, or nothing (`void` / `null` / `undefined`) to defer
435
- * to the current suggestion without changing it.
436
- *
437
- * Two idioms cover almost every case; they differ only in what an _unrelated_
438
- * action does. Match actions by reference with `ctx.isAction()` (rename-safe)
439
- * rather than `actionId?.includes("...")` (a renamed or moved action silently
440
- * stops matching). Because `isAction` returns a raw boolean, combine it with
441
- * `|| undefined` to defer or leave it bare to suppress.
442
- *
443
- * @example
444
- * ```ts
445
- * import * as CartActions from "./actions/cart";
446
- *
447
- * // Idiom A — "mine, else defer": re-render on my actions, otherwise return
448
- * // undefined so the segment's default decision still applies (and downstream
449
- * // revalidators get a say).
450
- * revalidate((ctx) => ctx.isAction(CartActions) || undefined)
451
- *
452
- * // Idiom B — "mine only": re-render on my actions and suppress everything
453
- * // else (isAction returns a raw boolean, so an unrelated action yields false).
454
- * revalidate((ctx) => ctx.isAction(CartActions))
455
- *
456
- * // Always re-render when params change (default behavior made explicit)
457
- * revalidate(({ defaultShouldRevalidate }) => defaultShouldRevalidate)
458
- * ```
459
- */
460
- export type ShouldRevalidateFn<TParams = GenericParams, TEnv = any> = (args: {
461
- /** Route params from the page being navigated away from. */
462
- currentParams: TParams;
463
- /** Full URL of the page being navigated away from. */
464
- currentUrl: URL;
465
- /** Route params for the navigation target. */
466
- nextParams: TParams;
467
- /** Full URL of the navigation target. */
468
- nextUrl: URL;
469
- /**
470
- * The router's default revalidation decision for this segment.
471
- * `true` when params changed or the segment is new to the client.
472
- * Return this when you want default behavior plus your own conditions.
473
- */
474
- defaultShouldRevalidate: boolean;
475
- /** Full handler context — access to `ctx.use()`, `ctx.env`, `ctx.params`, etc. */
476
- context: HandlerContext<TParams, TEnv>;
477
- /**
478
- * The type of segment being revalidated. `"loader"` is passed to revalidate
479
- * functions attached to a `loader(Fn, () => [revalidate(...)])` registration.
480
- */
481
- segmentType: "layout" | "route" | "parallel" | "loader";
482
- /** Layout name (e.g., `"root"`, `"shop"`, `"auth"`). Only set for layout segments. */
483
- layoutName?: string;
484
- /** Slot name (e.g., `"@sidebar"`, `"@modal"`). Only set for parallel segments. */
485
- slotName?: string;
486
- /**
487
- * Identifier of the server action that triggered revalidation.
488
- * `undefined` during normal navigation (no action involved).
489
- *
490
- * Format: `"src/<path>#<exportName>"` — the file path is the source path
491
- * relative to the project root, followed by `#` and the exported function name.
492
- *
493
- * This is stable and can be used for path-based matching to revalidate
494
- * when any action in a module or directory fires. Prefer `|| undefined`
495
- * (defer to the segment default / downstream revalidators) over `?? false`
496
- * (hard short-circuit that suppresses the default and ends the chain):
497
- *
498
- * @example
499
- * ```ts
500
- * // Match a specific action
501
- * revalidate(({ actionId }) => actionId === "src/actions/cart.ts#addToCart" || undefined)
502
- *
503
- * // Match any action in the cart module
504
- * revalidate(({ actionId }) => actionId?.includes("cart") || undefined)
505
- *
506
- * // Match any action under src/apps/store/actions/
507
- * revalidate(({ actionId }) => actionId?.startsWith("src/apps/store/actions/") || undefined)
508
- * ```
509
- */
510
- actionId?: string;
511
- /**
512
- * Typed, rename-safe action matching. Returns `true` when the action that
513
- * triggered this revalidation is one of the given references — or, for a
514
- * namespace import (`import * as CartActions`), any export of that module —
515
- * and `false` otherwise (including plain navigation with no action).
516
- *
517
- * Called with NO arguments it answers "is this request an action at all?":
518
- * `true` for any action, `false` on plain navigation. Use the bare form when
519
- * you want to revalidate on every action regardless of which one fired.
520
- *
521
- * Prefer this over hand-written `actionId` substring matches: it resolves the
522
- * action's stable `path#export` id from the imported reference, so a rename is
523
- * a type error in one place instead of silent drift across consumers. It
524
- * resolves the reference the same way the action boundary derives `actionId`
525
- * (`$id ?? $$id`), so it matches in both dev and production.
526
- *
527
- * Returns a raw boolean, so for the common "revalidate on match, else defer"
528
- * intent combine with `|| undefined`:
529
- *
530
- * @example
531
- * ```ts
532
- * import { addToCart, removeFromCart } from "./actions/cart";
533
- * import * as CartActions from "./actions/cart";
534
- *
535
- * revalidate((ctx) => ctx.isAction() || undefined); // any action
536
- * revalidate((ctx) => ctx.isAction(addToCart) || undefined); // one action
537
- * revalidate((ctx) => ctx.isAction(addToCart, removeFromCart) || undefined); // several
538
- * revalidate((ctx) => ctx.isAction(CartActions) || undefined); // any in the module
539
- * ```
540
- */
541
- isAction: (...actions: ActionRef[]) => boolean;
542
- /** URL where the action was executed (the page the user was on when they triggered the action). */
543
- actionUrl?: URL;
544
- /** Return value from the action execution. Can be used to conditionally revalidate based on the action's outcome. */
545
- actionResult?: any;
546
- /** FormData from the action request body. Only set for form-based actions (not inline `"use server"` actions). */
547
- formData?: FormData;
548
- /** HTTP method: `"GET"` for navigation, `"POST"` for server actions. */
549
- method?: string;
550
- /** Route name of the navigation target. Alias for `toRouteName`. */
551
- routeName?: DefaultRouteName;
552
- /**
553
- * Route name being navigated away from.
554
- * `undefined` for unnamed internal routes (those without a `name` option).
555
- */
556
- fromRouteName?: DefaultRouteName;
557
- /**
558
- * Route name being navigated to.
559
- * `undefined` for unnamed internal routes (those without a `name` option).
560
- */
561
- toRouteName?: DefaultRouteName;
562
- /**
563
- * `true` when the browser signals that data may be stale — typically because
564
- * a server action was executed in this or another tab (`_rsc_stale` header).
565
- *
566
- * This is NOT segment cache staleness (loaders are never segment-cached).
567
- * Use this to decide whether loader data should be re-fetched after an
568
- * action that may have mutated backend state.
569
- */
570
- stale?: boolean;
571
- }) => boolean | {
572
- defaultShouldRevalidate: boolean;
573
- } | null | void;
574
- /**
575
- * Extract all route keys from a route definition (includes flattened nested routes)
576
- */
577
- export type RouteKeys<T extends RouteDefinition> = keyof ResolvedRouteMap<T> & string;
578
- /**
579
- * Valid layout value - component or handler function
580
- * Note: Arrays are not supported. Use separate layout() declarations with unique names instead.
581
- */
582
- type LayoutValue<TEnv = any> = ReactNode | Handler<any, any, TEnv>;
583
- /**
584
- * Helper to extract params from a route key using the resolved (flattened) route map
585
- */
586
- export type ExtractRouteParams<T extends RouteDefinition, K extends string> = K extends keyof ResolvedRouteMap<T> ? ResolvedRouteMap<T>[K] extends string ? ExtractParams<ResolvedRouteMap<T>[K]> : GenericParams : GenericParams;
587
- /**
588
- * Handlers object that maps route names to handler functions with type-safe string patterns
589
- */
590
- export type HandlersForRouteMap<T extends RouteDefinition, TEnv = any> = {
591
- [K in RouteKeys<T>]?: Handler<ExtractRouteParams<T, K & string>, any, TEnv>;
592
- } & {
593
- [K in `$layout.${RouteKeys<T> | "*"}.${string}`]?: LayoutValue<TEnv>;
594
- } & {
595
- [K in `$parallel.${RouteKeys<T>}.${string}`]?: Record<`@${string}`, Handler<K extends `$parallel.${infer RouteKey}.${string}` ? RouteKey extends RouteKeys<T> ? ExtractRouteParams<T, RouteKey & string> : GenericParams : GenericParams, any, TEnv>>;
596
- } & {
597
- [K in `$parallel.${"*"}.${string}`]?: Record<`@${string}`, Handler<GenericParams, any, TEnv>>;
598
- } & {
599
- [K in `$middleware.${RouteKeys<T> | "*"}.${string}`]?: MiddlewareFn<TEnv, GenericParams>[];
600
- } & {
601
- [K in `$revalidate.route.${RouteKeys<T> | "*"}.${string}`]?: ShouldRevalidateFn<GenericParams, TEnv>;
602
- } & {
603
- [K in `$revalidate.layout.${RouteKeys<T> | "*"}.${string}.${string}`]?: ShouldRevalidateFn<GenericParams, TEnv>;
604
- } & {
605
- [K in `$revalidate.parallel.${RouteKeys<T> | "*"}.${string}.${string}.${string}`]?: ShouldRevalidateFn<GenericParams, TEnv>;
606
- };
607
- /**
608
- * Revalidation function with typed params
609
- *
610
- * @template T - Params object
611
- * @template TEnv - Environment type
612
- *
613
- * @example
614
- * ```typescript
615
- * const revalidate: Revalidate<{ slug: string }> = ({ currentParams, nextParams }) => {
616
- * return currentParams.slug !== nextParams.slug;
617
- * }
618
- * ```
619
- */
620
- export type Revalidate<T = GenericParams, TEnv = DefaultEnv> = ShouldRevalidateFn<T, TEnv>;
621
- /**
622
- * Middleware function with typed params and environment
623
- *
624
- * @template TParams - Params object (defaults to generic)
625
- * @template TEnv - Environment type (defaults to global Rango.Env)
626
- *
627
- * Note: Middleware cannot directly use route names for params typing because
628
- * middleware is defined during router setup, before RegisteredRoutes is populated.
629
- * Use ExtractParams<"/path/:id"> for typed params from a path pattern.
630
- *
631
- * @example
632
- * ```typescript
633
- * // Basic middleware (uses global Rango.Env via module augmentation)
634
- * const middleware: Middleware = async (ctx, next) => {
635
- * ctx.set("user", { id: "123" }); // Type-safe!
636
- * await next();
637
- * }
638
- *
639
- * // With explicit params (most common)
640
- * const middleware: Middleware<{ id: string }> = async (ctx, next) => {
641
- * console.log(ctx.params.id);
642
- * await next();
643
- * }
644
- *
645
- * // With params from path pattern
646
- * const middleware: Middleware<ExtractParams<"/products/:id">> = async (ctx, next) => {
647
- * console.log(ctx.params.id);
648
- * await next();
649
- * }
650
- *
651
- * // With both params and explicit env
652
- * const middleware: Middleware<{ id: string }, AppEnv> = async (ctx, next) => {
653
- * ctx.set("user", { id: ctx.params.id });
654
- * await next();
655
- * }
656
- * ```
657
- */
658
- export type Middleware<TParams = GenericParams, TEnv = DefaultEnv> = MiddlewareFn<TEnv, TParams>;
@@ -1,11 +0,0 @@
1
- export type { GetRegisteredRoutes, DefaultHandlerRouteMap, DefaultReverseRouteMap, DefaultEnv, } from "./global-namespace.js";
2
- import "./global-namespace.js";
3
- export type { DocumentProps, ExtractParams, TrailingSlashMode, RouteConfig, RouteDefinitionOptions, RouteDefinition, ResolvedRouteMap, } from "./route-config.js";
4
- export type { ErrorInfo, ErrorBoundaryFallbackProps, ErrorBoundaryHandler, ClientErrorBoundaryFallbackProps, LoaderDataResult, NotFoundInfo, NotFoundBoundaryFallbackProps, NotFoundBoundaryHandler, } from "./boundaries.js";
5
- export { isLoaderDataResult } from "./boundaries.js";
6
- export type { MiddlewareFn, ScopedRouteMap, Handler, HandlerContext, InternalHandlerContext, GenericParams, RevalidateParams, ShouldRevalidateFn, ActionRef, RouteKeys, ExtractRouteParams, HandlersForRouteMap, Revalidate, Middleware, } from "./handler-context.js";
7
- export type { ViewTransitionClass, TransitionConfig, TransitionWhenFn, TransitionWhenContext, ResolvedSegment, SegmentMetadata, SlotState, RootLayoutProps, MatchResult, } from "./segments.js";
8
- export type { LazyIncludeContext, RouteEntry } from "./route-entry.js";
9
- export type { LoaderContext, LoaderFn, FetchableLoaderOptions, LoadOptions, LoaderDefinition, } from "./loader-types.js";
10
- export type { CacheContext, CacheOptions, PartialCacheOptions, EntryCacheConfig, } from "./cache-types.js";
11
- export type { ErrorPhase, OnErrorContext, OnErrorCallback, } from "./error-types.js";