@rangojs/router 0.0.0-experimental.31 → 0.0.0-experimental.3232cd17

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 (376) hide show
  1. package/AGENTS.md +4 -0
  2. package/README.md +198 -44
  3. package/dist/bin/rango.js +287 -105
  4. package/dist/testing/vitest.js +82 -0
  5. package/dist/vite/index.js +3248 -1117
  6. package/dist/vite/plugins/cloudflare-protocol-loader-hook.mjs +76 -0
  7. package/package.json +73 -21
  8. package/skills/api-client/SKILL.md +211 -0
  9. package/skills/breadcrumbs/SKILL.md +107 -1
  10. package/skills/bundle-analysis/SKILL.md +159 -0
  11. package/skills/cache-guide/SKILL.md +245 -21
  12. package/skills/caching/SKILL.md +302 -6
  13. package/skills/composability/SKILL.md +27 -2
  14. package/skills/css/SKILL.md +76 -0
  15. package/skills/document-cache/SKILL.md +78 -55
  16. package/skills/handler-use/SKILL.md +364 -0
  17. package/skills/hooks/SKILL.md +270 -30
  18. package/skills/host-router/SKILL.md +82 -22
  19. package/skills/i18n/SKILL.md +276 -0
  20. package/skills/intercept/SKILL.md +49 -5
  21. package/skills/layout/SKILL.md +35 -9
  22. package/skills/links/SKILL.md +249 -17
  23. package/skills/loader/SKILL.md +294 -30
  24. package/skills/middleware/SKILL.md +52 -13
  25. package/skills/migrate-nextjs/SKILL.md +584 -0
  26. package/skills/migrate-react-router/SKILL.md +769 -0
  27. package/skills/mime-routes/SKILL.md +27 -0
  28. package/skills/observability/SKILL.md +137 -0
  29. package/skills/parallel/SKILL.md +203 -7
  30. package/skills/prerender/SKILL.md +123 -100
  31. package/skills/rango/SKILL.md +250 -22
  32. package/skills/react-compiler/SKILL.md +168 -0
  33. package/skills/response-routes/SKILL.md +122 -47
  34. package/skills/route/SKILL.md +97 -5
  35. package/skills/router-setup/SKILL.md +90 -5
  36. package/skills/server-actions/SKILL.md +775 -0
  37. package/skills/streams-and-websockets/SKILL.md +283 -0
  38. package/skills/tailwind/SKILL.md +27 -3
  39. package/skills/testing/SKILL.md +129 -0
  40. package/skills/testing/bindings.md +89 -0
  41. package/skills/testing/cache-prerender.md +124 -0
  42. package/skills/testing/client-components.md +122 -0
  43. package/skills/testing/e2e-parity.md +125 -0
  44. package/skills/testing/flight.md +92 -0
  45. package/skills/testing/handles.md +129 -0
  46. package/skills/testing/loader.md +128 -0
  47. package/skills/testing/middleware.md +99 -0
  48. package/skills/testing/render-handler.md +121 -0
  49. package/skills/testing/response-routes.md +95 -0
  50. package/skills/testing/reverse-and-types.md +84 -0
  51. package/skills/testing/server-actions.md +107 -0
  52. package/skills/testing/server-tree.md +128 -0
  53. package/skills/testing/setup.md +120 -0
  54. package/skills/typesafety/SKILL.md +329 -27
  55. package/skills/use-cache/SKILL.md +36 -5
  56. package/skills/view-transitions/SKILL.md +294 -0
  57. package/src/__augment-tests__/augment.ts +81 -0
  58. package/src/__augment-tests__/augmented.check.ts +116 -0
  59. package/src/__internal.ts +67 -40
  60. package/src/browser/action-coordinator.ts +53 -36
  61. package/src/browser/action-fence.ts +47 -0
  62. package/src/browser/app-shell.ts +39 -0
  63. package/src/browser/app-version.ts +14 -0
  64. package/src/browser/cookie-name.ts +140 -0
  65. package/src/browser/event-controller.ts +86 -147
  66. package/src/browser/history-state.ts +21 -0
  67. package/src/browser/index.ts +3 -3
  68. package/src/browser/invalidate-client-cache.ts +52 -0
  69. package/src/browser/link-interceptor.ts +4 -0
  70. package/src/browser/navigation-bridge.ts +148 -19
  71. package/src/browser/navigation-client.ts +187 -67
  72. package/src/browser/navigation-store-handle.ts +38 -0
  73. package/src/browser/navigation-store.ts +76 -67
  74. package/src/browser/navigation-transaction.ts +18 -66
  75. package/src/browser/partial-update.ts +123 -94
  76. package/src/browser/prefetch/cache.ts +214 -36
  77. package/src/browser/prefetch/fetch.ts +260 -38
  78. package/src/browser/prefetch/policy.ts +6 -0
  79. package/src/browser/prefetch/queue.ts +126 -20
  80. package/src/browser/prefetch/resource-ready.ts +77 -0
  81. package/src/browser/rango-state.ts +158 -76
  82. package/src/browser/react/Link.tsx +93 -11
  83. package/src/browser/react/NavigationProvider.tsx +115 -34
  84. package/src/browser/react/ScrollRestoration.tsx +10 -6
  85. package/src/browser/react/context.ts +7 -2
  86. package/src/browser/react/filter-segment-order.ts +49 -7
  87. package/src/browser/react/index.ts +0 -48
  88. package/src/browser/react/location-state-shared.ts +166 -8
  89. package/src/browser/react/location-state.ts +39 -14
  90. package/src/browser/react/use-action.ts +6 -15
  91. package/src/browser/react/use-handle.ts +23 -69
  92. package/src/browser/react/use-link-status.ts +0 -4
  93. package/src/browser/react/use-navigation.ts +22 -5
  94. package/src/browser/react/use-params.ts +20 -10
  95. package/src/browser/react/use-reverse.ts +106 -0
  96. package/src/browser/react/use-router.ts +46 -11
  97. package/src/browser/react/use-search-params.ts +0 -5
  98. package/src/browser/react/use-segments.ts +11 -21
  99. package/src/browser/response-adapter.ts +52 -1
  100. package/src/browser/rsc-router.tsx +215 -76
  101. package/src/browser/scroll-restoration.ts +46 -39
  102. package/src/browser/segment-reconciler.ts +36 -9
  103. package/src/browser/segment-structure-assert.ts +2 -2
  104. package/src/browser/server-action-bridge.ts +176 -50
  105. package/src/browser/types.ts +95 -11
  106. package/src/browser/validate-redirect-origin.ts +43 -16
  107. package/src/build/collect-fallback-refs.ts +107 -0
  108. package/src/build/generate-manifest.ts +65 -40
  109. package/src/build/generate-route-types.ts +5 -0
  110. package/src/build/index.ts +8 -2
  111. package/src/build/prefix-tree-utils.ts +123 -0
  112. package/src/build/route-trie.ts +137 -32
  113. package/src/build/route-types/codegen.ts +4 -4
  114. package/src/build/route-types/include-resolution.ts +9 -2
  115. package/src/build/route-types/param-extraction.ts +6 -3
  116. package/src/build/route-types/per-module-writer.ts +7 -4
  117. package/src/build/route-types/router-processing.ts +278 -96
  118. package/src/build/route-types/scan-filter.ts +9 -2
  119. package/src/build/route-types/source-scan.ts +118 -0
  120. package/src/build/runtime-discovery.ts +9 -20
  121. package/src/cache/cache-error.ts +104 -0
  122. package/src/cache/cache-policy.ts +68 -28
  123. package/src/cache/cache-runtime.ts +149 -43
  124. package/src/cache/cache-scope.ts +148 -81
  125. package/src/cache/cache-tag.ts +98 -0
  126. package/src/cache/cf/cf-cache-store.ts +2550 -93
  127. package/src/cache/cf/index.ts +11 -17
  128. package/src/cache/document-cache.ts +78 -27
  129. package/src/cache/handle-snapshot.ts +63 -0
  130. package/src/cache/index.ts +23 -20
  131. package/src/cache/memory-segment-store.ts +136 -37
  132. package/src/cache/profile-registry.ts +6 -30
  133. package/src/cache/read-through-swr.ts +41 -11
  134. package/src/cache/segment-codec.ts +0 -16
  135. package/src/cache/tag-invalidation.ts +230 -0
  136. package/src/cache/taint.ts +55 -0
  137. package/src/cache/types.ts +33 -100
  138. package/src/cache/vercel/index.ts +11 -0
  139. package/src/cache/vercel/vercel-cache-store.ts +799 -0
  140. package/src/client.rsc.tsx +6 -21
  141. package/src/client.tsx +108 -290
  142. package/src/component-utils.ts +19 -0
  143. package/src/context-var.ts +84 -2
  144. package/src/debug.ts +2 -2
  145. package/src/decode-loader-results.ts +36 -0
  146. package/src/defer.ts +196 -0
  147. package/src/deps/ssr.ts +0 -1
  148. package/src/errors.ts +30 -4
  149. package/src/handle.ts +70 -22
  150. package/src/handles/MetaTags.tsx +0 -14
  151. package/src/handles/breadcrumbs.ts +16 -5
  152. package/src/handles/meta.ts +0 -39
  153. package/src/host/cookie-handler.ts +0 -36
  154. package/src/host/errors.ts +0 -24
  155. package/src/host/index.ts +8 -2
  156. package/src/host/pattern-matcher.ts +7 -50
  157. package/src/host/router.ts +107 -99
  158. package/src/host/testing.ts +40 -27
  159. package/src/host/types.ts +37 -4
  160. package/src/host/utils.ts +1 -1
  161. package/src/href-client.ts +137 -22
  162. package/src/index.rsc.ts +52 -26
  163. package/src/index.ts +100 -38
  164. package/src/internal-debug.ts +2 -4
  165. package/src/loader-store.ts +500 -0
  166. package/src/loader.rsc.ts +20 -13
  167. package/src/loader.ts +12 -11
  168. package/src/missing-id-error.ts +68 -0
  169. package/src/network-error-thrower.tsx +1 -6
  170. package/src/outlet-context.ts +1 -1
  171. package/src/outlet-provider.tsx +1 -5
  172. package/src/prerender/param-hash.ts +10 -11
  173. package/src/prerender/store.ts +37 -41
  174. package/src/prerender.ts +198 -82
  175. package/src/redirect-origin.ts +100 -0
  176. package/src/response-utils.ts +37 -0
  177. package/src/reverse.ts +65 -15
  178. package/src/root-error-boundary.tsx +1 -19
  179. package/src/route-content-wrapper.tsx +7 -72
  180. package/src/route-definition/dsl-helpers.ts +437 -274
  181. package/src/route-definition/helper-factories.ts +29 -139
  182. package/src/route-definition/helpers-types.ts +113 -37
  183. package/src/route-definition/index.ts +3 -0
  184. package/src/route-definition/redirect.ts +52 -10
  185. package/src/route-definition/resolve-handler-use.ts +161 -0
  186. package/src/route-definition/use-item-types.ts +32 -0
  187. package/src/route-map-builder.ts +7 -17
  188. package/src/route-types.ts +37 -41
  189. package/src/router/basename.ts +14 -0
  190. package/src/router/content-negotiation.ts +108 -9
  191. package/src/router/error-handling.ts +13 -17
  192. package/src/router/find-match.ts +45 -22
  193. package/src/router/handler-context.ts +83 -41
  194. package/src/router/intercept-resolution.ts +25 -23
  195. package/src/router/lazy-includes.ts +19 -53
  196. package/src/router/loader-resolution.ts +213 -30
  197. package/src/router/logging.ts +5 -8
  198. package/src/router/manifest.ts +49 -45
  199. package/src/router/match-api.ts +121 -205
  200. package/src/router/match-context.ts +0 -22
  201. package/src/router/match-handlers.ts +58 -58
  202. package/src/router/match-middleware/background-revalidation.ts +27 -6
  203. package/src/router/match-middleware/cache-lookup.ts +205 -249
  204. package/src/router/match-middleware/cache-store.ts +45 -32
  205. package/src/router/match-middleware/intercept-resolution.ts +8 -28
  206. package/src/router/match-middleware/segment-resolution.ts +52 -18
  207. package/src/router/match-pipelines.ts +1 -42
  208. package/src/router/match-result.ts +104 -40
  209. package/src/router/metrics.ts +5 -34
  210. package/src/router/middleware-types.ts +13 -142
  211. package/src/router/middleware.ts +173 -143
  212. package/src/router/navigation-snapshot.ts +131 -0
  213. package/src/router/params-util.ts +23 -0
  214. package/src/router/pattern-matching.ts +109 -63
  215. package/src/router/prerender-match.ts +192 -54
  216. package/src/router/preview-match.ts +32 -102
  217. package/src/router/request-classification.ts +276 -0
  218. package/src/router/revalidation.ts +63 -55
  219. package/src/router/route-snapshot.ts +244 -0
  220. package/src/router/router-context.ts +6 -28
  221. package/src/router/router-interfaces.ts +100 -35
  222. package/src/router/router-options.ts +91 -11
  223. package/src/router/router-registry.ts +2 -5
  224. package/src/router/segment-resolution/fresh.ts +242 -75
  225. package/src/router/segment-resolution/helpers.ts +64 -25
  226. package/src/router/segment-resolution/loader-cache.ts +41 -37
  227. package/src/router/segment-resolution/revalidation.ts +456 -372
  228. package/src/router/segment-resolution/static-store.ts +19 -5
  229. package/src/router/segment-resolution/streamed-handler-telemetry.ts +52 -0
  230. package/src/router/segment-resolution/view-transition-default.ts +36 -0
  231. package/src/router/segment-resolution.ts +4 -1
  232. package/src/router/segment-wrappers.ts +2 -3
  233. package/src/router/state-cookie-name.ts +33 -0
  234. package/src/router/substitute-pattern-params.ts +56 -0
  235. package/src/router/telemetry-otel.ts +0 -20
  236. package/src/router/telemetry.ts +96 -19
  237. package/src/router/timeout.ts +0 -20
  238. package/src/router/trie-matching.ts +91 -46
  239. package/src/router/types.ts +10 -63
  240. package/src/router/url-params.ts +44 -0
  241. package/src/router.ts +134 -43
  242. package/src/rsc/handler-context.ts +3 -2
  243. package/src/rsc/handler.ts +492 -383
  244. package/src/rsc/helpers.ts +162 -46
  245. package/src/rsc/index.ts +1 -1
  246. package/src/rsc/json-route-result.ts +38 -0
  247. package/src/rsc/loader-fetch.ts +23 -3
  248. package/src/rsc/manifest-init.ts +33 -42
  249. package/src/rsc/origin-guard.ts +39 -25
  250. package/src/rsc/progressive-enhancement.ts +30 -3
  251. package/src/rsc/redirect-guard.ts +99 -0
  252. package/src/rsc/response-error.ts +79 -12
  253. package/src/rsc/response-route-handler.ts +90 -63
  254. package/src/rsc/rsc-rendering.ts +56 -54
  255. package/src/rsc/runtime-warnings.ts +23 -10
  256. package/src/rsc/server-action.ts +74 -67
  257. package/src/rsc/ssr-setup.ts +18 -2
  258. package/src/rsc/types.ts +25 -6
  259. package/src/runtime-env.ts +18 -0
  260. package/src/search-params.ts +4 -20
  261. package/src/segment-content-promise.ts +67 -0
  262. package/src/segment-loader-promise.ts +134 -0
  263. package/src/segment-system.tsx +272 -129
  264. package/src/serialize.ts +243 -0
  265. package/src/server/context.ts +309 -61
  266. package/src/server/cookie-store.ts +80 -5
  267. package/src/server/handle-store.ts +26 -24
  268. package/src/server/loader-registry.ts +10 -28
  269. package/src/server/request-context.ts +348 -128
  270. package/src/ssr/index.tsx +23 -15
  271. package/src/static-handler.ts +27 -18
  272. package/src/testing/cache-status.ts +162 -0
  273. package/src/testing/collect-handle.ts +40 -0
  274. package/src/testing/dispatch.ts +618 -0
  275. package/src/testing/dom.entry.ts +22 -0
  276. package/src/testing/e2e/fixture.ts +188 -0
  277. package/src/testing/e2e/index.ts +128 -0
  278. package/src/testing/e2e/matchers.ts +35 -0
  279. package/src/testing/e2e/page-helpers.ts +272 -0
  280. package/src/testing/e2e/parity.ts +387 -0
  281. package/src/testing/e2e/server.ts +195 -0
  282. package/src/testing/flight-matchers.ts +97 -0
  283. package/src/testing/flight-normalize.ts +11 -0
  284. package/src/testing/flight-runtime.d.ts +57 -0
  285. package/src/testing/flight-tree.ts +682 -0
  286. package/src/testing/flight.entry.ts +52 -0
  287. package/src/testing/flight.ts +232 -0
  288. package/src/testing/generated-routes.ts +183 -0
  289. package/src/testing/index.ts +99 -0
  290. package/src/testing/internal/context.ts +348 -0
  291. package/src/testing/internal/flight-client-globals.ts +30 -0
  292. package/src/testing/internal/seed-vars.ts +54 -0
  293. package/src/testing/render-handler.ts +330 -0
  294. package/src/testing/render-route.tsx +566 -0
  295. package/src/testing/run-loader.ts +378 -0
  296. package/src/testing/run-middleware.ts +205 -0
  297. package/src/testing/vitest-stubs/cloudflare-email.ts +9 -0
  298. package/src/testing/vitest-stubs/cloudflare-workers.ts +21 -0
  299. package/src/testing/vitest-stubs/plugin-rsc.ts +16 -0
  300. package/src/testing/vitest-stubs/version.ts +5 -0
  301. package/src/testing/vitest.ts +305 -0
  302. package/src/theme/ThemeProvider.tsx +0 -52
  303. package/src/theme/ThemeScript.tsx +0 -6
  304. package/src/theme/constants.ts +0 -12
  305. package/src/theme/index.ts +0 -7
  306. package/src/theme/theme-context.ts +1 -5
  307. package/src/theme/theme-script.ts +0 -14
  308. package/src/theme/use-theme.ts +0 -3
  309. package/src/types/boundaries.ts +0 -35
  310. package/src/types/cache-types.ts +17 -8
  311. package/src/types/error-types.ts +30 -90
  312. package/src/types/global-namespace.ts +54 -41
  313. package/src/types/handler-context.ts +233 -81
  314. package/src/types/index.ts +1 -10
  315. package/src/types/loader-types.ts +44 -15
  316. package/src/types/request-scope.ts +107 -0
  317. package/src/types/route-config.ts +6 -50
  318. package/src/types/route-entry.ts +19 -7
  319. package/src/types/segments.ts +37 -14
  320. package/src/urls/include-helper.ts +33 -70
  321. package/src/urls/index.ts +1 -11
  322. package/src/urls/path-helper-types.ts +58 -11
  323. package/src/urls/path-helper.ts +57 -111
  324. package/src/urls/pattern-types.ts +48 -19
  325. package/src/urls/response-types.ts +25 -22
  326. package/src/urls/type-extraction.ts +58 -139
  327. package/src/urls/urls-function.ts +1 -18
  328. package/src/use-loader.tsx +346 -89
  329. package/src/vite/debug.ts +185 -0
  330. package/src/vite/discovery/bundle-postprocess.ts +36 -38
  331. package/src/vite/discovery/discover-routers.ts +130 -85
  332. package/src/vite/discovery/discovery-errors.ts +194 -0
  333. package/src/vite/discovery/gate-state.ts +171 -0
  334. package/src/vite/discovery/prerender-collection.ts +192 -99
  335. package/src/vite/discovery/route-types-writer.ts +40 -84
  336. package/src/vite/discovery/self-gen-tracking.ts +27 -1
  337. package/src/vite/discovery/state.ts +51 -6
  338. package/src/vite/discovery/virtual-module-codegen.ts +14 -34
  339. package/src/vite/index.ts +8 -0
  340. package/src/vite/plugin-types.ts +187 -69
  341. package/src/vite/plugins/cjs-to-esm.ts +8 -18
  342. package/src/vite/plugins/client-ref-dedup.ts +16 -11
  343. package/src/vite/plugins/client-ref-hashing.ts +28 -15
  344. package/src/vite/plugins/cloudflare-protocol-loader-hook.d.mts +23 -0
  345. package/src/vite/plugins/cloudflare-protocol-loader-hook.mjs +76 -0
  346. package/src/vite/plugins/cloudflare-protocol-stub.ts +194 -0
  347. package/src/vite/plugins/expose-action-id.ts +49 -98
  348. package/src/vite/plugins/expose-id-utils.ts +11 -50
  349. package/src/vite/plugins/expose-ids/export-analysis.ts +76 -34
  350. package/src/vite/plugins/expose-ids/handler-transform.ts +10 -48
  351. package/src/vite/plugins/expose-ids/loader-transform.ts +3 -20
  352. package/src/vite/plugins/expose-ids/router-transform.ts +20 -16
  353. package/src/vite/plugins/expose-internal-ids.ts +554 -317
  354. package/src/vite/plugins/performance-tracks.ts +89 -0
  355. package/src/vite/plugins/refresh-cmd.ts +89 -27
  356. package/src/vite/plugins/use-cache-transform.ts +73 -83
  357. package/src/vite/plugins/vercel-output.ts +258 -0
  358. package/src/vite/plugins/version-injector.ts +21 -25
  359. package/src/vite/plugins/version-plugin.ts +41 -20
  360. package/src/vite/plugins/virtual-entries.ts +2 -17
  361. package/src/vite/rango.ts +257 -289
  362. package/src/vite/router-discovery.ts +930 -140
  363. package/src/vite/utils/ast-handler-extract.ts +15 -31
  364. package/src/vite/utils/banner.ts +4 -4
  365. package/src/vite/utils/bundle-analysis.ts +10 -15
  366. package/src/vite/utils/client-chunks.ts +184 -0
  367. package/src/vite/utils/forward-user-plugins.ts +171 -0
  368. package/src/vite/utils/manifest-utils.ts +4 -59
  369. package/src/vite/utils/package-resolution.ts +20 -52
  370. package/src/vite/utils/prerender-utils.ts +27 -29
  371. package/src/vite/utils/shared-utils.ts +92 -42
  372. package/src/browser/action-response-classifier.ts +0 -99
  373. package/src/browser/react/use-client-cache.ts +0 -58
  374. package/src/browser/shallow.ts +0 -40
  375. package/src/handles/index.ts +0 -7
  376. package/src/router/middleware-cookies.ts +0 -55
@@ -14,7 +14,6 @@ import type { RenderSegmentsOptions } from "../segment-system.js";
14
14
  export interface RscPayload<TMetadata = RscMetadata> {
15
15
  metadata?: TMetadata;
16
16
  returnValue?: ActionResult;
17
- formState?: unknown;
18
17
  }
19
18
 
20
19
  /**
@@ -32,10 +31,21 @@ export type HandleData = Record<string, Record<string, unknown[]>>;
32
31
  export interface RscMetadata {
33
32
  pathname: string;
34
33
  segments: ResolvedSegment[];
34
+ /** Router instance ID — the current app's identity. A mismatch with the
35
+ * client's id (sent as _rsc_rid) is detected server-side and answered with
36
+ * X-RSC-Reload (full document load), so the client never swaps apps
37
+ * in-session; within a session this always equals the current app. */
38
+ routerId?: string;
35
39
  isPartial?: boolean;
36
40
  isError?: boolean;
37
41
  matched?: string[];
38
42
  diff?: string[];
43
+ /**
44
+ * All segment ids re-resolved on the server, including null-component
45
+ * ones excluded from `segments`/`diff`. Drives client-side handle-bucket
46
+ * cleanup. Superset of `diff`. See MatchResult.resolvedIds.
47
+ */
48
+ resolvedIds?: string[];
39
49
  /** Merged route params from the matched route */
40
50
  params?: Record<string, string>;
41
51
  /**
@@ -60,6 +70,12 @@ export interface RscMetadata {
60
70
  * Sent on initial render so the browser can configure its cache duration.
61
71
  */
62
72
  prefetchCacheTTL?: number;
73
+ /**
74
+ * Server-resolved rango state cookie name (`{prefix}_{routerId}`). The client
75
+ * reads it verbatim and binds the rango state cookie to it; composition
76
+ * happens only server-side.
77
+ */
78
+ stateCookieName?: string;
63
79
  /**
64
80
  * Theme configuration from router.
65
81
  * Included when theme is enabled in router config.
@@ -70,10 +86,16 @@ export interface RscMetadata {
70
86
  * Included when theme is enabled in router config.
71
87
  */
72
88
  initialTheme?: Theme;
89
+ /** URL prefix for all routes (from createRouter({ basename })). */
90
+ basename?: string;
73
91
  /** Whether connection warmup is enabled */
74
92
  warmupEnabled?: boolean;
75
- /** Server-side redirect with optional state (for partial requests) */
76
- redirect?: { url: string };
93
+ /**
94
+ * Server-side redirect with optional state (for partial requests).
95
+ * `external: true` (from redirect(url, { external: true })) tells the client
96
+ * to hard-navigate to an off-host target instead of validating same-origin.
97
+ */
98
+ redirect?: { url: string; external?: boolean };
77
99
  /** Server-set location state to include in history.pushState */
78
100
  locationState?: Record<string, unknown>;
79
101
  }
@@ -174,6 +196,15 @@ export interface TrackedActionState {
174
196
  result: unknown | null;
175
197
  }
176
198
 
199
+ /**
200
+ * The value returned by {@link useAction} when called without a selector.
201
+ *
202
+ * This is the stable, public name for the action-state shape; consumers can
203
+ * name it in their own signatures (e.g. a wrapper hook). It aliases the
204
+ * internal {@link TrackedActionState}.
205
+ */
206
+ export type ActionState = TrackedActionState;
207
+
177
208
  /**
178
209
  * Listener for action state changes
179
210
  *
@@ -215,6 +246,15 @@ export interface SegmentState {
215
246
  export interface NavigationUpdate {
216
247
  root: ReactNode | Promise<ReactNode>;
217
248
  metadata: RscMetadata;
249
+ /** Scroll behavior to apply after React commits this update */
250
+ scroll?: {
251
+ /** For back/forward: restore saved position */
252
+ restore?: boolean;
253
+ /** Set to false to disable scrolling entirely */
254
+ enabled?: boolean;
255
+ /** Function to check if streaming is in progress */
256
+ isStreaming?: () => boolean;
257
+ };
218
258
  }
219
259
 
220
260
  /**
@@ -232,6 +272,25 @@ export type HistoryState =
232
272
  export interface NavigateOptions {
233
273
  replace?: boolean;
234
274
  scroll?: boolean;
275
+ /**
276
+ * Whether to revalidate server data on navigation.
277
+ * Set to `false` to skip the RSC server fetch and only update the URL.
278
+ *
279
+ * Only takes effect when the pathname stays the same (search param / hash changes).
280
+ * If the pathname changes, this option is ignored and a full navigation occurs.
281
+ *
282
+ * All location-aware hooks (`useSearchParams`, `useNavigation`, etc.) still update.
283
+ * Server components do not re-render.
284
+ *
285
+ * @default true
286
+ *
287
+ * @example
288
+ * ```tsx
289
+ * router.push("/products?color=blue", { revalidate: false });
290
+ * router.replace("/products?page=3", { revalidate: false });
291
+ * ```
292
+ */
293
+ revalidate?: boolean;
235
294
  /**
236
295
  * State to pass to history.pushState/replaceState
237
296
  * Accessible via useLocationState() hook.
@@ -283,8 +342,14 @@ export interface RouterInstance {
283
342
  replace(url: string, options?: RouterNavigateOptions): Promise<void>;
284
343
  /** Refresh the current route (re-fetch server data, preserve client state) */
285
344
  refresh(): Promise<void>;
286
- /** Prefetch a URL for faster client-side transition */
287
- prefetch(url: string): void;
345
+ /**
346
+ * Prefetch a URL for faster client-side transition.
347
+ *
348
+ * Pass `{ key: ":source" }` to source-scope the prefetch cache entry (parity
349
+ * with `<Link prefetchKey=":source">`) when the target's response can differ
350
+ * by source page.
351
+ */
352
+ prefetch(url: string, options?: { key?: ":source" }): void;
288
353
  /** Go back in browser history */
289
354
  back(): void;
290
355
  /** Go forward in browser history */
@@ -313,7 +378,13 @@ export type ReadonlyURLSearchParams = Omit<
313
378
  export interface RscBrowserDependencies {
314
379
  createFromFetch: <T>(
315
380
  response: Promise<Response>,
316
- options?: { temporaryReferences?: any },
381
+ options?: {
382
+ temporaryReferences?: any;
383
+ findSourceMapURL?: (
384
+ filename: string,
385
+ environmentName: string,
386
+ ) => string | null;
387
+ },
317
388
  ) => Promise<T>;
318
389
  createFromReadableStream: <T>(stream: ReadableStream) => Promise<T>;
319
390
  encodeReply: (
@@ -375,17 +446,20 @@ export interface NavigationStore {
375
446
  segments: ResolvedSegment[],
376
447
  handleData?: HandleData,
377
448
  ): void;
378
- getCachedSegments(
379
- historyKey: string,
380
- ):
381
- | { segments: ResolvedSegment[]; stale: boolean; handleData?: HandleData }
449
+ getCachedSegments(historyKey: string):
450
+ | {
451
+ segments: ResolvedSegment[];
452
+ stale: boolean;
453
+ handleData?: HandleData;
454
+ routerId?: string;
455
+ }
382
456
  | undefined;
383
457
  hasHistoryCache(historyKey: string): boolean;
384
458
  updateCacheHandleData(historyKey: string, handleData: HandleData): void;
385
459
  markCacheAsStale(): void;
460
+ markHistoryCacheStale(): void;
386
461
  markCacheAsStaleAndBroadcast(): void;
387
462
  clearHistoryCache(): void;
388
- broadcastCacheInvalidation(): void;
389
463
 
390
464
  // Cross-tab refresh callback (set by navigation bridge)
391
465
  setCrossTabRefreshCallback(callback: () => void): void;
@@ -394,6 +468,10 @@ export interface NavigationStore {
394
468
  getInterceptSourceUrl(): string | null;
395
469
  setInterceptSourceUrl(url: string | null): void;
396
470
 
471
+ // Router identity tracking (for cross-app navigation detection)
472
+ getRouterId?(): string | undefined;
473
+ setRouterId?(id: string): void;
474
+
397
475
  // UI update notifications
398
476
  onUpdate(callback: UpdateSubscriber): () => void;
399
477
  emitUpdate(update: NavigationUpdate): void;
@@ -424,6 +502,8 @@ export interface FetchPartialOptions {
424
502
  interceptSourceUrl?: string;
425
503
  /** RSC version for cache invalidation detection */
426
504
  version?: string;
505
+ /** Current router ID — server detects app switch and returns full response */
506
+ routerId?: string;
427
507
  /** If true, this is an HMR refetch - server should invalidate manifest cache */
428
508
  hmr?: boolean;
429
509
  }
@@ -492,6 +572,10 @@ export interface NavigationBridge {
492
572
  refresh(): Promise<void>;
493
573
  handlePopstate(): Promise<void>;
494
574
  registerLinkInterception(): () => void;
575
+ /** Current RSC version (live, reflects the latest updateVersion). */
576
+ getVersion(): string | undefined;
577
+ /** Update the RSC version (e.g. after HMR). Clears prefetch cache. */
578
+ updateVersion(newVersion: string): void;
495
579
  }
496
580
 
497
581
  /**
@@ -1,29 +1,56 @@
1
+ import {
2
+ resolveSameOriginRedirect,
3
+ resolveExternalRedirect,
4
+ } from "../redirect-origin.js";
5
+
1
6
  /**
2
7
  * Validate that a client-consumed redirect URL (from headers or Flight payload)
3
8
  * targets the same origin as the current page. Prevents open-redirect attacks
4
9
  * via crafted responses.
5
10
  *
11
+ * Thin wrapper over the shared {@link resolveSameOriginRedirect} rule (also used
12
+ * by the server guard in `rsc/redirect-guard.ts`) so client and server enforce
13
+ * the identical same-origin contract. Adds the client-side `console.error` on a
14
+ * block; the resolver itself stays pure.
15
+ *
6
16
  * @returns The canonical (normalized) URL string on success, or null if blocked.
7
17
  */
8
18
  export function validateRedirectOrigin(
9
19
  url: string,
10
20
  currentOrigin: string,
11
21
  ): string | null {
12
- try {
13
- const target = new URL(url, currentOrigin);
14
- if (target.origin !== currentOrigin) {
15
- console.error(
16
- `[rango] Redirect blocked: origin mismatch (${target.origin})`,
17
- );
18
- return null;
19
- }
20
- // Return pathname+search+hash for relative inputs, full href for absolute.
21
- // This normalizes protocol-relative and other ambiguous forms.
22
- return target.href.startsWith(currentOrigin)
23
- ? target.href
24
- : target.pathname + target.search + target.hash;
25
- } catch {
26
- console.error(`[rango] Redirect blocked: invalid URL "${url}"`);
27
- return null;
22
+ const resolved = resolveSameOriginRedirect(url, currentOrigin);
23
+ if (resolved === null) {
24
+ console.error(
25
+ `[rango] Redirect blocked: cross-origin or invalid target "${url}"`,
26
+ );
27
+ }
28
+ return resolved;
29
+ }
30
+
31
+ /**
32
+ * Validate an explicit off-origin redirect (`redirect(url, { external: true })`)
33
+ * the client is about to hard-navigate to via `window.location.assign()`.
34
+ *
35
+ * Thin wrapper over the shared {@link resolveExternalRedirect} rule (also used by
36
+ * the server guard in `rsc/redirect-guard.ts`) so client and server enforce the
37
+ * identical contract: `external` allows an off-origin target but only an
38
+ * http(s) scheme. This stops a forged or mistaken external payload carrying a
39
+ * `javascript:`/`data:` URL from turning `location.assign` into a scriptable
40
+ * navigation. Adds the client-side `console.error` on a block; the resolver
41
+ * itself stays pure.
42
+ *
43
+ * @returns The normalized URL string on success, or null if blocked.
44
+ */
45
+ export function validateExternalRedirect(
46
+ url: string,
47
+ currentOrigin: string,
48
+ ): string | null {
49
+ const resolved = resolveExternalRedirect(url, currentOrigin);
50
+ if (resolved === null) {
51
+ console.error(
52
+ `[rango] External redirect blocked: non-http(s) target "${url}"`,
53
+ );
28
54
  }
55
+ return resolved;
29
56
  }
@@ -0,0 +1,107 @@
1
+ // Collect the `"use client"` client-reference keys reachable from an error /
2
+ // notFound boundary registration, for routing them into the dedicated
3
+ // `app-fallback` chunk (see vite/utils/client-chunks.ts).
4
+ //
5
+ // A boundary registration is not always a bare client element. The common,
6
+ // load-bearing pattern wraps the client boundary in providers a thrown handler
7
+ // needs (the layout that would normally supply them did not mount):
8
+ //
9
+ // defaultErrorBoundary: ({ error }) => (
10
+ // <FallbackIntl locales={...}>
11
+ // <ThemedError error={error} /> // <- the real "use client" boundary
12
+ // </FallbackIntl>
13
+ // )
14
+ //
15
+ // So the value may be (a) a handler FUNCTION returning a tree, or (b) an element
16
+ // tree with the client boundary nested below server wrappers. We:
17
+ // 1. If it's a function, CALL it with synthetic props to get the returned tree.
18
+ // This only constructs JSX — the inner components are element `type`s, never
19
+ // invoked — so no hooks run. Guarded: a boundary that needs a real render
20
+ // context (request globals, etc.) throws and is skipped (graceful: it simply
21
+ // stays on the default grouping, as before).
22
+ // 2. Walk the resulting tree and report every element whose `.type` is a
23
+ // plugin-rsc client reference.
24
+ //
25
+ // Limit: a boundary that *conditionally* renders different client components based
26
+ // on the runtime error cannot be resolved statically — only the branch taken with
27
+ // the synthetic error is seen. Such cases fall back to the default chunk; the
28
+ // custom `clientChunks` function is the escape hatch.
29
+
30
+ const CLIENT_REF = Symbol.for("react.client.reference");
31
+ const MAX_DEPTH = 40;
32
+
33
+ // Synthetic props covering the error-boundary (`{ error, reset }`) and notFound
34
+ // (`{ pathname }`) handler shapes. The handler destructures what it needs.
35
+ const SYNTHETIC_PROPS = {
36
+ error: new Error("rango: build-time fallback-chunk discovery"),
37
+ reset: () => {},
38
+ pathname: "/",
39
+ info: { componentStack: "" },
40
+ };
41
+
42
+ interface MaybeElement {
43
+ type?: { $$typeof?: symbol; $$id?: string };
44
+ props?: Record<string, unknown>;
45
+ }
46
+
47
+ function isReactNodeLike(v: unknown): boolean {
48
+ return (
49
+ Array.isArray(v) ||
50
+ (typeof v === "object" && v !== null && "$$typeof" in (v as object))
51
+ );
52
+ }
53
+
54
+ function walkElementTree(
55
+ node: unknown,
56
+ report: (refKey: string) => void,
57
+ depth: number,
58
+ ): void {
59
+ if (node == null || depth > MAX_DEPTH) return;
60
+ if (Array.isArray(node)) {
61
+ for (const child of node) walkElementTree(child, report, depth + 1);
62
+ return;
63
+ }
64
+ if (typeof node !== "object") return;
65
+
66
+ const el = node as MaybeElement;
67
+ const type = el.type;
68
+ if (type?.$$typeof === CLIENT_REF && typeof type.$$id === "string") {
69
+ // $$id is `<referenceKey>#<exportName>` in build mode — keep the referenceKey.
70
+ report(type.$$id.split("#")[0]);
71
+ }
72
+
73
+ const props = el.props;
74
+ if (props && typeof props === "object") {
75
+ // Children are always nodes; other props are followed only when they look
76
+ // like React nodes (slots/icons), never arbitrary data objects.
77
+ walkElementTree(props.children, report, depth + 1);
78
+ for (const key in props) {
79
+ if (key === "children") continue;
80
+ const value = props[key];
81
+ if (isReactNodeLike(value)) walkElementTree(value, report, depth + 1);
82
+ }
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Report every `"use client"` client-reference key reachable from a single
88
+ * error/notFound boundary registration (handler function or element tree).
89
+ */
90
+ export function collectFallbackClientRefs(
91
+ boundary: unknown,
92
+ report: (refKey: string) => void,
93
+ ): void {
94
+ try {
95
+ let node = boundary;
96
+ if (typeof node === "function") {
97
+ node = (node as (props: unknown) => unknown)(SYNTHETIC_PROPS);
98
+ }
99
+ walkElementTree(node, report, 0);
100
+ } catch {
101
+ // The boundary needs a real render context (request globals, hooks at the
102
+ // top level) or its tree has hostile getters. Its client refs can't be
103
+ // resolved statically — skip. It stays on the default grouping (no
104
+ // regression vs. not collecting), and the custom clientChunks fn is the
105
+ // escape hatch for such cases.
106
+ }
107
+ }
@@ -11,11 +11,12 @@
11
11
  import type { UrlPatterns } from "../urls.js";
12
12
  import type { AllUseItems } from "../route-types.js";
13
13
  import { extractStaticPrefix } from "../router/pattern-matching.js";
14
- import { RSCRouterContext, runWithPrefixes } from "../server/context.js";
14
+ import { RangoContext, runWithPrefixes } from "../server/context.js";
15
15
  import type { EntryData, TrackedInclude } from "../server/context.js";
16
16
  import type { TrailingSlashMode } from "../types.js";
17
17
  import { createRouteHelpers } from "../route-definition.js";
18
18
  import MapRootLayout from "../server/root-layout.js";
19
+ import { collectFallbackClientRefs } from "./collect-fallback-refs.js";
19
20
 
20
21
  /**
21
22
  * Node in the prefix tree
@@ -45,7 +46,7 @@ export interface GeneratedManifest {
45
46
  routeTrailingSlash?: Record<string, string>;
46
47
  /** Route names using Prerender (for dev-mode Node.js delegation) */
47
48
  prerenderRoutes?: string[];
48
- /** Route names with passthrough: true (handler kept in bundle for live fallback) */
49
+ /** Route names wrapped with Passthrough() (live handler for runtime fallback) */
49
50
  passthroughRoutes?: string[];
50
51
  /** Route name → response type for non-RSC routes */
51
52
  responseTypeRoutes?: Record<string, string>;
@@ -57,6 +58,26 @@ export interface GeneratedManifest {
57
58
  * Build prefix tree node by running the patterns with proper context.
58
59
  * Uses a visited set to detect circular includes and prevent infinite recursion.
59
60
  */
61
+ // Merge tracked nested includes into `target`. Multiple includes can share a
62
+ // fullPrefix (e.g. include("/", a), include("/", b)) — concat their routes and
63
+ // Object.assign children rather than overwrite.
64
+ function mergeIncludeNodes(
65
+ target: Record<string, PrefixTreeNode>,
66
+ includes: TrackedInclude[],
67
+ buildChild: (include: TrackedInclude) => PrefixTreeNode,
68
+ ): void {
69
+ for (const include of includes) {
70
+ const node = buildChild(include);
71
+ const existing = target[include.fullPrefix];
72
+ if (existing) {
73
+ existing.routes.push(...node.routes);
74
+ Object.assign(existing.children, node.children);
75
+ } else {
76
+ target[include.fullPrefix] = node;
77
+ }
78
+ }
79
+ }
80
+
60
81
  function buildPrefixTreeNode(
61
82
  urlPrefix: string,
62
83
  namePrefix: string | undefined,
@@ -93,7 +114,7 @@ function buildPrefixTreeNode(
93
114
  const searchSchemasMap = new Map<string, Record<string, string>>();
94
115
  const trackedIncludes: TrackedInclude[] = [];
95
116
 
96
- RSCRouterContext.run(
117
+ RangoContext.run(
97
118
  {
98
119
  manifest,
99
120
  patterns: patternsMap,
@@ -150,10 +171,7 @@ function buildPrefixTreeNode(
150
171
  if (prerenderDefs && entry.prerenderDef) {
151
172
  prerenderDefs[name] = entry.prerenderDef;
152
173
  }
153
- if (
154
- passthroughRoutes &&
155
- entry.prerenderDef?.options?.passthrough === true
156
- ) {
174
+ if (passthroughRoutes && entry.isPassthrough === true) {
157
175
  passthroughRoutes.push(name);
158
176
  }
159
177
  }
@@ -169,13 +187,9 @@ function buildPrefixTreeNode(
169
187
  }
170
188
  }
171
189
 
172
- // Build children from tracked nested includes.
173
- // Multiple includes can share the same fullPrefix (e.g., include("/", patternsA),
174
- // include("/", patternsB)). Merge their routes instead of overwriting.
175
190
  const children: Record<string, PrefixTreeNode> = {};
176
-
177
- for (const include of trackedIncludes) {
178
- const childNode = buildPrefixTreeNode(
191
+ mergeIncludeNodes(children, trackedIncludes, (include) =>
192
+ buildPrefixTreeNode(
179
193
  include.fullPrefix,
180
194
  include.namePrefix,
181
195
  include.patterns as UrlPatterns<any>,
@@ -189,16 +203,8 @@ function buildPrefixTreeNode(
189
203
  passthroughRoutes,
190
204
  responseTypeRoutes,
191
205
  routeSearchSchemas,
192
- );
193
-
194
- const existing = children[include.fullPrefix];
195
- if (existing) {
196
- existing.routes.push(...childNode.routes);
197
- Object.assign(existing.children, childNode.children);
198
- } else {
199
- children[include.fullPrefix] = childNode;
200
- }
201
- }
206
+ ),
207
+ );
202
208
 
203
209
  // Remove from visited so sibling branches can reuse the same patterns
204
210
  // without false circular-include detection. Only ancestors in the current
@@ -285,6 +291,17 @@ export function generateManifest<TEnv>(
285
291
  export function generateManifestFull<TEnv>(
286
292
  urlpatterns: UrlPatterns<TEnv, any>,
287
293
  mountIndex: number = 0,
294
+ options?: {
295
+ urlPrefix?: string;
296
+ /**
297
+ * Called once per `"use client"` component registered as an
298
+ * errorBoundary/notFoundBoundary fallback, with its client-reference key
299
+ * (`$$id`). Lets the build collect fallback module ids for dedicated
300
+ * chunking without exposing the otherwise-discarded EntryData tree. The
301
+ * EntryData map built below is local; this is the only seam that surfaces it.
302
+ */
303
+ collectClientFallbackRef?: (refKey: string) => void;
304
+ },
288
305
  ): FullManifest {
289
306
  const routeManifest: Record<string, string> = {};
290
307
  const routeAncestry: Record<string, string[]> = {};
@@ -298,7 +315,7 @@ export function generateManifestFull<TEnv>(
298
315
  const searchSchemasMap = new Map<string, Record<string, string>>();
299
316
  const trackedIncludes: TrackedInclude[] = [];
300
317
 
301
- RSCRouterContext.run(
318
+ RangoContext.run(
302
319
  {
303
320
  manifest,
304
321
  patterns: patternsMap,
@@ -310,6 +327,8 @@ export function generateManifestFull<TEnv>(
310
327
  counters: {},
311
328
  mountIndex,
312
329
  trackedIncludes, // Enable include tracking
330
+ // basename sets the initial URL prefix for all path() registrations
331
+ ...(options?.urlPrefix ? { urlPrefix: options.urlPrefix } : {}),
313
332
  },
314
333
  () => {
315
334
  const helpers = createRouteHelpers();
@@ -320,6 +339,22 @@ export function generateManifestFull<TEnv>(
320
339
  },
321
340
  );
322
341
 
342
+ // Surface the "use client" components registered as error/notFound fallbacks
343
+ // (route-tree errorBoundary()/notFoundBoundary() helpers, stored on EntryData).
344
+ // The boundary may be a handler function and/or wrap the client boundary in
345
+ // server providers, so walk the whole tree (see collectFallbackClientRefs).
346
+ if (options?.collectClientFallbackRef) {
347
+ const report = options.collectClientFallbackRef;
348
+ const collect = (boundary: unknown[] | undefined) => {
349
+ for (const item of boundary ?? [])
350
+ collectFallbackClientRefs(item, report);
351
+ };
352
+ for (const entry of manifest.values()) {
353
+ collect(entry.errorBoundary);
354
+ collect(entry.notFoundBoundary);
355
+ }
356
+ }
357
+
323
358
  // Collect root-level routes and trailing slash config
324
359
  const routeTrailingSlash: Record<string, string> = {};
325
360
  for (const [name, pattern] of patternsMap.entries()) {
@@ -347,7 +382,7 @@ export function generateManifestFull<TEnv>(
347
382
  if (entry.prerenderDef) {
348
383
  prerenderDefs[name] = entry.prerenderDef;
349
384
  }
350
- if (entry.prerenderDef?.options?.passthrough === true) {
385
+ if (entry.isPassthrough === true) {
351
386
  passthroughRoutes.push(name);
352
387
  }
353
388
  }
@@ -356,12 +391,10 @@ export function generateManifestFull<TEnv>(
356
391
  }
357
392
  }
358
393
 
359
- // Build prefix tree from tracked includes (shared visited set for cycle detection).
360
- // Multiple includes can share the same fullPrefix (e.g., include("/", patternsA),
361
- // include("/", patternsB)). Merge their routes instead of overwriting.
394
+ // Shared visited set for cycle detection across all root-level includes.
362
395
  const visited = new Set<unknown>();
363
- for (const include of trackedIncludes) {
364
- const node = buildPrefixTreeNode(
396
+ mergeIncludeNodes(prefixTree, trackedIncludes, (include) =>
397
+ buildPrefixTreeNode(
365
398
  include.fullPrefix,
366
399
  include.namePrefix,
367
400
  include.patterns as UrlPatterns<any>,
@@ -375,16 +408,8 @@ export function generateManifestFull<TEnv>(
375
408
  passthroughRoutes,
376
409
  responseTypeRoutes,
377
410
  routeSearchSchemas,
378
- );
379
-
380
- const existing = prefixTree[include.fullPrefix];
381
- if (existing) {
382
- existing.routes.push(...node.routes);
383
- Object.assign(existing.children, node.children);
384
- } else {
385
- prefixTree[include.fullPrefix] = node;
386
- }
387
- }
411
+ ),
412
+ );
388
413
 
389
414
  return {
390
415
  prefixTree,
@@ -25,6 +25,9 @@ export {
25
25
  } from "./route-types/include-resolution.js";
26
26
  export {
27
27
  extractUrlsVariableFromRouter,
28
+ extractUrlsFromRouter,
29
+ extractBasenameFromRouter,
30
+ type UrlsExtractionResult,
28
31
  buildCombinedRouteMapForRouterFile,
29
32
  detectUnresolvableIncludes,
30
33
  detectUnresolvableIncludesForUrlsFile,
@@ -32,5 +35,7 @@ export {
32
35
  formatNestedRouterConflictError,
33
36
  findRouterFiles,
34
37
  writeCombinedRouteTypes,
38
+ genFileTsPath,
39
+ resolveSearchSchemas,
35
40
  } from "./route-types/router-processing.js";
36
41
  export { findUrlsVariableNames } from "./route-types/per-module-writer.js";
@@ -22,8 +22,14 @@ export {
22
22
  type GeneratedManifest,
23
23
  } from "./generate-manifest.js";
24
24
 
25
- export { buildRouteTrie, type TrieNode, type TrieLeaf } from "./route-trie.js";
26
-
25
+ // buildRouteTrie / buildPerRouterTrie / collectFallbackClientRefs and the
26
+ // TrieNode/TrieLeaf types are NOT exported here: they are build-pipeline
27
+ // internals, not public API. Their only build-time consumer (the Vite
28
+ // discovery pass) imports them directly from source via a relative path
29
+ // (vite/discovery/discover-routers.ts), and the runtime RSC realm likewise
30
+ // imports route-trie.js directly (rsc/manifest-init.ts). Keeping them off the
31
+ // public ./build surface (#569 decision 6) means consumers can't mistake them
32
+ // for intended API. generateManifest* / route-types / hashParams stay public.
27
33
  export {
28
34
  writePerModuleRouteTypes,
29
35
  extractRoutesFromSource,