@rangojs/router 0.24.3 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (274) hide show
  1. package/README.md +1 -0
  2. package/dist/bin/rango.js +363 -39
  3. package/dist/testing/vitest.js +37 -4
  4. package/dist/types/browser/event-controller.d.ts +24 -5
  5. package/dist/types/browser/intercept-utils.d.ts +5 -2
  6. package/dist/types/browser/merge-segment-loaders.d.ts +0 -23
  7. package/dist/types/browser/navigation-transaction.d.ts +5 -5
  8. package/dist/types/browser/partial-update.d.ts +21 -13
  9. package/dist/types/browser/prefetch/cache.d.ts +8 -0
  10. package/dist/types/browser/rango-marker.d.ts +7 -0
  11. package/dist/types/browser/react/filter-segment-order.d.ts +10 -0
  12. package/dist/types/browser/react/use-handle.d.ts +20 -0
  13. package/dist/types/browser/react/use-href.d.ts +6 -0
  14. package/dist/types/browser/react/use-router.d.ts +6 -1
  15. package/dist/types/browser/response-adapter.d.ts +5 -3
  16. package/dist/types/browser/scroll-restoration.d.ts +9 -3
  17. package/dist/types/browser/segment-reconciler.d.ts +10 -13
  18. package/dist/types/browser/types.d.ts +38 -8
  19. package/dist/types/build/route-types/per-module-writer.d.ts +12 -0
  20. package/dist/types/cache/cf/cf-shell-frame.d.ts +2 -0
  21. package/dist/types/cache/types.d.ts +8 -0
  22. package/dist/types/client-urls/client-root.d.ts +4 -1
  23. package/dist/types/client-urls/client-urls.d.ts +28 -2
  24. package/dist/types/client-urls/navigation.d.ts +6 -8
  25. package/dist/types/client-urls/revalidate-registry.d.ts +1 -1
  26. package/dist/types/client-urls/server-projection.d.ts +20 -5
  27. package/dist/types/client-urls/types.d.ts +35 -17
  28. package/dist/types/client.d.ts +2 -2
  29. package/dist/types/client.rsc.d.ts +2 -2
  30. package/dist/types/decode-loader-results.d.ts +28 -7
  31. package/dist/types/href-client.d.ts +3 -1
  32. package/dist/types/index.rsc.d.ts +1 -1
  33. package/dist/types/loader-redirect.d.ts +2 -3
  34. package/dist/types/outlet-context.d.ts +7 -6
  35. package/dist/types/prefetch-markers.d.ts +14 -5
  36. package/dist/types/route-content-wrapper.d.ts +17 -14
  37. package/dist/types/route-definition/helpers-types.d.ts +7 -2
  38. package/dist/types/route-definition/resolve-handler-use.d.ts +6 -1
  39. package/dist/types/route-definition/rewrite.d.ts +48 -5
  40. package/dist/types/route-types.d.ts +2 -2
  41. package/dist/types/router/handler-context.d.ts +14 -2
  42. package/dist/types/router/intercept-resolution.d.ts +19 -46
  43. package/dist/types/router/lazy-includes.d.ts +7 -0
  44. package/dist/types/router/match-middleware/intercept-resolution.d.ts +2 -2
  45. package/dist/types/router/middleware.d.ts +0 -16
  46. package/dist/types/router/navigation-snapshot.d.ts +2 -0
  47. package/dist/types/router/prefetch-cache-ttl.d.ts +8 -11
  48. package/dist/types/router/revalidation.d.ts +8 -1
  49. package/dist/types/router/router-context.d.ts +4 -16
  50. package/dist/types/router/router-interfaces.d.ts +0 -6
  51. package/dist/types/router/router-options.d.ts +4 -7
  52. package/dist/types/router/segment-resolution/prefetch-deferral.d.ts +31 -8
  53. package/dist/types/router/segment-resolution/revalidation.d.ts +38 -4
  54. package/dist/types/router/segment-resolution.d.ts +1 -1
  55. package/dist/types/router/segment-wrappers.d.ts +3 -5
  56. package/dist/types/router/substitute-pattern-params.d.ts +19 -2
  57. package/dist/types/router/tracing.d.ts +2 -2
  58. package/dist/types/rsc/full-payload.d.ts +14 -2
  59. package/dist/types/rsc/helpers.d.ts +8 -0
  60. package/dist/types/rsc/manifest-init.d.ts +20 -0
  61. package/dist/types/rsc/prefetch-render-error.d.ts +22 -0
  62. package/dist/types/rsc/progressive-enhancement.d.ts +20 -0
  63. package/dist/types/rsc/rewrite-passes.d.ts +12 -2
  64. package/dist/types/rsc/server-action.d.ts +6 -0
  65. package/dist/types/rsc/shell-capture-constants.d.ts +10 -1
  66. package/dist/types/rsc/shell-capture.d.ts +7 -0
  67. package/dist/types/rsc/types.d.ts +5 -0
  68. package/dist/types/segment-system.d.ts +15 -0
  69. package/dist/types/server/context.d.ts +64 -4
  70. package/dist/types/server/request-context.d.ts +41 -4
  71. package/dist/types/server/request-headers.d.ts +12 -0
  72. package/dist/types/server/rewrite-trail.d.ts +8 -1
  73. package/dist/types/testing/e2e/index.d.ts +1 -1
  74. package/dist/types/testing/flight.entry.d.ts +1 -1
  75. package/dist/types/testing/index.d.ts +1 -1
  76. package/dist/types/testing/internal/client-urls-projection.d.ts +4 -3
  77. package/dist/types/testing/render-route.d.ts +21 -11
  78. package/dist/types/testing/run-loader.d.ts +7 -0
  79. package/dist/types/testing/run-middleware.d.ts +7 -0
  80. package/dist/types/testing/run-revalidate.d.ts +5 -4
  81. package/dist/types/testing/serve-shell-request.d.ts +41 -4
  82. package/dist/types/testing/shell-status.d.ts +17 -0
  83. package/dist/types/testing/vitest-stubs/version.d.ts +1 -0
  84. package/dist/types/testing/vitest.d.ts +10 -1
  85. package/dist/types/thenable-status.d.ts +0 -6
  86. package/dist/types/types/handler-context.d.ts +12 -1
  87. package/dist/types/types/loader-types.d.ts +4 -3
  88. package/dist/types/types/route-entry.d.ts +2 -1
  89. package/dist/types/urls/path-helper-types.d.ts +4 -2
  90. package/dist/types/urls/path-helper.d.ts +5 -0
  91. package/dist/types/vite/discovery/client-urls-projection.d.ts +55 -5
  92. package/dist/types/vite/discovery/state.d.ts +20 -0
  93. package/dist/types/vite/plugins/client-urls-revalidate-hoist.d.ts +28 -16
  94. package/dist/types/vite/plugins/hoist/source.d.ts +8 -7
  95. package/dist/types/vite/plugins/virtual-entries.d.ts +6 -0
  96. package/dist/types/vite/utils/prerender-utils.d.ts +7 -0
  97. package/dist/vite/index.js +6816 -6547
  98. package/package.json +1 -1
  99. package/skills/app-structure/SKILL.md +255 -0
  100. package/skills/app-structure/content-site.md +333 -0
  101. package/skills/app-structure/e-commerce.md +435 -0
  102. package/skills/app-structure/large-app.md +885 -0
  103. package/skills/app-structure/multi-app.md +280 -0
  104. package/skills/breadcrumbs/SKILL.md +6 -1
  105. package/skills/caching/SKILL.md +3 -1
  106. package/skills/catalog.json +12 -0
  107. package/skills/client-urls/SKILL.md +195 -32
  108. package/skills/composability/SKILL.md +10 -8
  109. package/skills/handler-use/SKILL.md +48 -9
  110. package/skills/hooks/handle-and-actions.md +104 -0
  111. package/skills/hooks/navigation.md +24 -10
  112. package/skills/hooks/urls.md +1 -1
  113. package/skills/i18n/SKILL.md +2 -1
  114. package/skills/intercept/SKILL.md +60 -29
  115. package/skills/layout/SKILL.md +6 -3
  116. package/skills/links/SKILL.md +151 -17
  117. package/skills/loader/SKILL.md +32 -10
  118. package/skills/middleware/SKILL.md +111 -15
  119. package/skills/observability/SKILL.md +11 -0
  120. package/skills/parallel/SKILL.md +5 -5
  121. package/skills/ppr/SKILL.md +43 -8
  122. package/skills/prerender/SKILL.md +1 -2
  123. package/skills/rango/SKILL.md +3 -0
  124. package/skills/response-routes/SKILL.md +4 -1
  125. package/skills/scripts/SKILL.md +12 -1
  126. package/skills/server-actions/SKILL.md +60 -20
  127. package/skills/testing/SKILL.md +1 -0
  128. package/skills/testing/client-components.md +13 -10
  129. package/skills/testing/loader.md +25 -24
  130. package/skills/testing/middleware.md +11 -11
  131. package/skills/testing/response-routes.md +4 -1
  132. package/skills/testing/serve-shell-request.md +85 -21
  133. package/skills/ux-architecture/SKILL.md +980 -0
  134. package/skills/view-transitions/SKILL.md +43 -10
  135. package/src/__augment-tests__/augmented.check.ts +28 -0
  136. package/src/browser/event-controller.ts +44 -18
  137. package/src/browser/intercept-utils.ts +3 -2
  138. package/src/browser/merge-segment-loaders.ts +0 -85
  139. package/src/browser/navigation-bridge.ts +119 -98
  140. package/src/browser/navigation-client.ts +20 -15
  141. package/src/browser/navigation-store.ts +4 -2
  142. package/src/browser/navigation-transaction.ts +9 -8
  143. package/src/browser/partial-update.ts +90 -32
  144. package/src/browser/prefetch/cache.ts +8 -0
  145. package/src/browser/prefetch/fetch.ts +13 -3
  146. package/src/browser/rango-marker.ts +13 -0
  147. package/src/browser/react/NavigationProvider.tsx +25 -7
  148. package/src/browser/react/filter-segment-order.ts +13 -0
  149. package/src/browser/react/use-action.ts +9 -15
  150. package/src/browser/react/use-handle.ts +63 -71
  151. package/src/browser/react/use-href.tsx +24 -5
  152. package/src/browser/react/use-link-status.ts +1 -1
  153. package/src/browser/react/use-navigation.ts +30 -40
  154. package/src/browser/react/use-reverse.ts +4 -17
  155. package/src/browser/react/use-router.ts +37 -6
  156. package/src/browser/react/use-segments.ts +8 -12
  157. package/src/browser/response-adapter.ts +11 -5
  158. package/src/browser/rsc-router.tsx +3 -1
  159. package/src/browser/scroll-restoration.ts +34 -20
  160. package/src/browser/segment-reconciler.ts +11 -29
  161. package/src/browser/server-action-bridge.ts +52 -16
  162. package/src/browser/types.ts +40 -8
  163. package/src/build/generate-manifest.ts +12 -1
  164. package/src/build/route-types/codegen.ts +6 -2
  165. package/src/build/route-types/per-module-writer.ts +94 -61
  166. package/src/cache/cache-runtime.ts +9 -0
  167. package/src/cache/cache-scope.ts +2 -1
  168. package/src/cache/cf/cf-cache-store.ts +2 -0
  169. package/src/cache/cf/cf-shell-frame.ts +3 -0
  170. package/src/cache/types.ts +8 -0
  171. package/src/cache/vercel/vercel-cache-store.ts +6 -1
  172. package/src/client-urls/client-root.tsx +10 -5
  173. package/src/client-urls/client-urls.ts +246 -166
  174. package/src/client-urls/navigation.ts +45 -38
  175. package/src/client-urls/revalidate-registry.ts +12 -3
  176. package/src/client-urls/server-projection.ts +286 -75
  177. package/src/client-urls/types.ts +40 -16
  178. package/src/client.rsc.tsx +11 -1
  179. package/src/client.tsx +9 -1
  180. package/src/decode-loader-results.ts +64 -31
  181. package/src/href-client.ts +3 -1
  182. package/src/index.rsc.ts +1 -0
  183. package/src/index.ts +12 -4
  184. package/src/loader-redirect.tsx +2 -3
  185. package/src/outlet-context.ts +7 -6
  186. package/src/prefetch-markers.ts +15 -5
  187. package/src/reverse.ts +3 -3
  188. package/src/route-content-wrapper.tsx +19 -17
  189. package/src/route-definition/dsl-helpers.ts +27 -7
  190. package/src/route-definition/helpers-types.ts +7 -2
  191. package/src/route-definition/resolve-handler-use.ts +23 -10
  192. package/src/route-definition/rewrite.ts +86 -19
  193. package/src/route-types.ts +1 -2
  194. package/src/router/find-match.ts +37 -1
  195. package/src/router/handler-context.ts +85 -40
  196. package/src/router/intercept-resolution.ts +161 -307
  197. package/src/router/lazy-includes.ts +43 -27
  198. package/src/router/loader-resolution.ts +21 -1
  199. package/src/router/manifest.ts +6 -8
  200. package/src/router/match-api.ts +11 -1
  201. package/src/router/match-middleware/background-revalidation.ts +2 -4
  202. package/src/router/match-middleware/cache-lookup.ts +16 -20
  203. package/src/router/match-middleware/intercept-resolution.ts +41 -60
  204. package/src/router/match-result.ts +31 -2
  205. package/src/router/middleware.ts +6 -147
  206. package/src/router/navigation-snapshot.ts +38 -2
  207. package/src/router/prefetch-cache-ttl.ts +10 -18
  208. package/src/router/prerender-match.ts +2 -1
  209. package/src/router/revalidation.ts +24 -3
  210. package/src/router/router-context.ts +5 -18
  211. package/src/router/router-interfaces.ts +0 -7
  212. package/src/router/router-options.ts +4 -7
  213. package/src/router/segment-resolution/fresh.ts +6 -2
  214. package/src/router/segment-resolution/helpers.ts +7 -1
  215. package/src/router/segment-resolution/prefetch-deferral.ts +62 -12
  216. package/src/router/segment-resolution/revalidation.ts +75 -35
  217. package/src/router/segment-resolution.ts +0 -1
  218. package/src/router/segment-wrappers.ts +8 -13
  219. package/src/router/substitute-pattern-params.ts +37 -2
  220. package/src/router/tracing.ts +2 -2
  221. package/src/router.ts +2 -9
  222. package/src/rsc/full-payload.ts +26 -4
  223. package/src/rsc/handler.ts +83 -41
  224. package/src/rsc/helpers.ts +13 -0
  225. package/src/rsc/manifest-init.ts +56 -3
  226. package/src/rsc/prefetch-render-error.ts +38 -0
  227. package/src/rsc/progressive-enhancement.ts +161 -211
  228. package/src/rsc/rewrite-passes.ts +56 -9
  229. package/src/rsc/rsc-rendering.ts +79 -23
  230. package/src/rsc/server-action.ts +25 -2
  231. package/src/rsc/shell-capture-constants.ts +22 -0
  232. package/src/rsc/shell-capture.ts +11 -0
  233. package/src/rsc/types.ts +5 -0
  234. package/src/segment-system.tsx +125 -119
  235. package/src/server/context.ts +96 -5
  236. package/src/server/handle-store.ts +3 -2
  237. package/src/server/request-context.ts +42 -3
  238. package/src/server/request-headers.ts +32 -0
  239. package/src/server/rewrite-trail.ts +55 -9
  240. package/src/ssr/ssr-root.tsx +6 -10
  241. package/src/testing/dispatch.ts +4 -5
  242. package/src/testing/e2e/index.ts +1 -0
  243. package/src/testing/flight.entry.ts +1 -0
  244. package/src/testing/index.ts +1 -0
  245. package/src/testing/internal/client-urls-projection.ts +31 -11
  246. package/src/testing/render-route.tsx +83 -40
  247. package/src/testing/run-loader.ts +26 -2
  248. package/src/testing/run-middleware.ts +10 -0
  249. package/src/testing/run-revalidate.ts +13 -6
  250. package/src/testing/serve-shell-request.ts +77 -4
  251. package/src/testing/shell-status.ts +40 -0
  252. package/src/testing/vitest-stubs/version.ts +1 -0
  253. package/src/testing/vitest.ts +74 -7
  254. package/src/thenable-status.ts +0 -11
  255. package/src/types/handler-context.ts +12 -1
  256. package/src/types/loader-types.ts +4 -3
  257. package/src/types/route-entry.ts +2 -1
  258. package/src/urls/include-helper.ts +38 -11
  259. package/src/urls/path-helper-types.ts +4 -2
  260. package/src/urls/path-helper.ts +16 -3
  261. package/src/vite/discovery/client-urls-projection.ts +205 -16
  262. package/src/vite/discovery/discover-routers.ts +2 -2
  263. package/src/vite/discovery/prerender-collection.ts +2 -6
  264. package/src/vite/discovery/state.ts +26 -0
  265. package/src/vite/plugins/client-urls-revalidate-hoist.ts +190 -77
  266. package/src/vite/plugins/expose-internal-ids.ts +46 -40
  267. package/src/vite/plugins/hoist/source.ts +8 -7
  268. package/src/vite/plugins/transition-when-hoist.ts +1 -0
  269. package/src/vite/plugins/version-plugin.ts +7 -0
  270. package/src/vite/plugins/version.d.ts +7 -0
  271. package/src/vite/plugins/virtual-entries.ts +20 -0
  272. package/src/vite/rango.ts +4 -1
  273. package/src/vite/router-discovery.ts +39 -7
  274. package/src/vite/utils/prerender-utils.ts +17 -0
@@ -2,7 +2,7 @@ import type { ContextVar } from "../context-var.js";
2
2
  import type { Handle } from "../handle.js";
3
3
  import type { HandlePush } from "../defer.js";
4
4
  import type { MiddlewareFn } from "../router/middleware.js";
5
- import type { ScopedReverseFunction } from "../reverse.js";
5
+ import type { AutofillAwareReverseFunction } from "./handler-context.js";
6
6
  import type { SearchSchema, ResolveSearchSchema } from "../search-params.js";
7
7
  import type { UseItems, LoaderUseItem } from "../route-types.js";
8
8
  import type { DefaultEnv, DefaultReverseRouteMap, DefaultVars } from "./global-namespace.js";
@@ -118,9 +118,10 @@ export type LoaderContext<TParams = Record<string, string | undefined>, TEnv = D
118
118
  /**
119
119
  * Generate URLs from route names.
120
120
  * Same scoped reverse as route handlers — `.name` resolves within the
121
- * current include() scope, `name` resolves globally.
121
+ * current include() scope, `name` resolves globally, and params the matched
122
+ * route already carries (e.g. include() mount params) are filled in.
122
123
  */
123
- reverse: ScopedReverseFunction<Record<string, string>, DefaultReverseRouteMap>;
124
+ reverse: AutofillAwareReverseFunction<Record<string, string>, DefaultReverseRouteMap>;
124
125
  };
125
126
  /**
126
127
  * Loader function signature
@@ -1,6 +1,7 @@
1
1
  import type { AllUseItems } from "../route-types.js";
2
+ import type { IncludeScopePosition } from "../server/context.js";
2
3
  import type { TrailingSlashMode, ResolvedRouteMap } from "./route-config.js";
3
- export interface LazyIncludeContext {
4
+ export interface LazyIncludeContext extends IncludeScopePosition {
4
5
  urlPrefix: string;
5
6
  namePrefix: string | undefined;
6
7
  parent: unknown;
@@ -144,9 +144,11 @@ export type PathHelpers<TEnv> = {
144
144
  (fns: MiddlewareFn<TEnv>[], children: () => UseItems<LayoutUseItem>): MiddlewareItem;
145
145
  };
146
146
  /**
147
- * Control when a segment should revalidate during navigation
147
+ * Control when a segment should revalidate during navigation.
148
+ * `revalidate(true)` / `revalidate(false)` are shorthand for
149
+ * `revalidate(() => true)` / `revalidate(() => false)`.
148
150
  */
149
- revalidate: (fn: ShouldRevalidateFn<any, TEnv>) => RevalidateItem;
151
+ revalidate: (fn: ShouldRevalidateFn<any, TEnv> | boolean) => RevalidateItem;
150
152
  /**
151
153
  * Attach a data loader to the current route/layout.
152
154
  *
@@ -1,5 +1,10 @@
1
1
  import type { Handler } from "../types.js";
2
2
  import type { PathFn, ResponsePathFn, JsonResponsePathFn, TextResponsePathFn } from "./path-helper-types.js";
3
+ /**
4
+ * The key path() registers a route under: its name, or a `$path_` name built
5
+ * from its pattern, behind the include's name prefix.
6
+ */
7
+ export declare function routeKeyOf(namePrefix: string | undefined, pattern: string, name: string | undefined): string;
3
8
  /**
4
9
  * A retained on-demand producer must never render on a live production
5
10
  * request: bundle eviction is skipped for onDemand routes (the producer body
@@ -1,3 +1,4 @@
1
+ import { type EnvironmentModuleNode } from "vite";
1
2
  import { type ClientUrlProjection } from "../../client-urls/server-projection.js";
2
3
  import type { DiscoveryState } from "./state.js";
3
4
  interface ClientUrlSsrEnvironment {
@@ -9,7 +10,40 @@ interface ClientUrlProjectionServerModule {
9
10
  clearClientUrlProjections(): void;
10
11
  setClientUrlProjection(referenceId: string, projection: ClientUrlProjection): void;
11
12
  }
13
+ /** The RSC environment whose realm `ClientUrlProjectionServerModule` is. */
14
+ interface ClientUrlRscEnvironment {
15
+ readonly runner: {
16
+ import(id: string): Promise<unknown>;
17
+ };
18
+ readonly moduleGraph?: {
19
+ getModuleById(id: string): EnvironmentModuleNode | undefined;
20
+ invalidateModule(mod: EnvironmentModuleNode): void;
21
+ };
22
+ }
23
+ export declare const CLIENT_URLS_REVALIDATE_QUERY = "rango-revalidate";
24
+ /** The id of the module registering `file`'s hoisted revalidate() predicates. */
25
+ export declare function hoistedRevalidateId(file: string): string;
12
26
  export declare function recordClientUrlsModule(state: DiscoveryState, code: string, id: string): void;
27
+ /** A module that imports the router's client entry (a cheap pre-filter). */
28
+ export declare const CLIENT_IMPORT_RE: RegExp;
29
+ /**
30
+ * Whether an edited module can carry a clientUrls() component's own items: it
31
+ * imports "@rangojs/router/client" and assigns a `.use` in code (not in a
32
+ * comment or string). Such a module changes its groups' projections and
33
+ * hoisted revalidate() registrations like a group edit, with or without
34
+ * "use client".
35
+ */
36
+ export declare function isClientUrlsComponentUseSource(source: string): boolean;
37
+ /**
38
+ * A hash of the text of every `X.use = ...` assignment of a component-use
39
+ * module (isClientUrlsComponentUseSource), or undefined for any other module.
40
+ * Equal before and after a save, the edit (markup, hooks) left what its
41
+ * groups read unchanged: the dev watcher skips re-discovery and the client
42
+ * keeps Fast Refresh. An edit outside the assignments that changes what one
43
+ * means (a helper it calls, an import's source) is not seen. A module that
44
+ * does not parse hashes whole.
45
+ */
46
+ export declare function componentUseSignature(source: string, file: string): string | undefined;
13
47
  export declare function resolveClientUrlsSource(state: DiscoveryState, referenceId: string): string | undefined;
14
48
  /**
15
49
  * Deterministic filesystem discovery of clientUrls modules. Transform-based
@@ -33,11 +67,13 @@ export declare function scanForClientUrlModules(state: DiscoveryState): void;
33
67
  * import, so `.routes(reference)` materialized the previous pass's projection.
34
68
  *
35
69
  * Errors are deliberately swallowed per source (a module mid-edit keeps its
36
- * last-known projection); the strict discoverClientUrlProjections() pass still
37
- * surfaces real failures afterwards. No-ops on cold start (nothing recorded
38
- * yet) and when the SSR runner is unavailable.
70
+ * last-known projection), and all refreshed projections keep their
71
+ * last-known state when any registration fails to load; the strict
72
+ * discoverClientUrlProjections() pass still surfaces real failures afterwards.
73
+ * No-ops on cold start (nothing recorded yet) and when the SSR runner is
74
+ * unavailable.
39
75
  */
40
- export declare function refreshRecordedClientUrlProjections(state: DiscoveryState, ssrEnv: ClientUrlSsrEnvironment | undefined, serverMod: ClientUrlProjectionServerModule): Promise<void>;
76
+ export declare function refreshRecordedClientUrlProjections(state: DiscoveryState, ssrEnv: ClientUrlSsrEnvironment | undefined, serverMod: ClientUrlProjectionServerModule, rscEnv: ClientUrlRscEnvironment): Promise<void>;
41
77
  /**
42
78
  * Strict projection discovery over every RECORDED clientUrls module. Recorded
43
79
  * modules — not router references — are the source of truth: include() mounts
@@ -49,5 +85,19 @@ export declare function refreshRecordedClientUrlProjections(state: DiscoveryStat
49
85
  * (recordClientUrlsModule never un-records, so deletions must self-heal here).
50
86
  * A present-but-broken module is a hard error: it is part of the app graph.
51
87
  */
52
- export declare function discoverClientUrlProjections(state: DiscoveryState, ssrEnv: ClientUrlSsrEnvironment | undefined, serverMod: ClientUrlProjectionServerModule): Promise<void>;
88
+ export declare function discoverClientUrlProjections(state: DiscoveryState, ssrEnv: ClientUrlSsrEnvironment | undefined, serverMod: ClientUrlProjectionServerModule, rscEnv: ClientUrlRscEnvironment): Promise<void>;
89
+ /**
90
+ * Assign each group of `projections` the other files holding the predicates
91
+ * it reads (each key's file, as the hoist transform recorded it: a key with
92
+ * none stays unregistered, and materialization names it), after loading their
93
+ * registrations into `rscEnv`. The group's own registrations load with its
94
+ * proxy, and its `?rango-revalidate` module imports the assigned files'
95
+ * (plugins/client-urls-revalidate-hoist.ts). When a group's files change, that
96
+ * module is invalidated, so a later evaluation (a reload, a request realm)
97
+ * imports the current ones. Another realm (workerd, a production bundle)
98
+ * loads a group only after discovery: its entry imports the routes-manifest
99
+ * module first, whose load waits for discovery (RSC_ENTRY_BOOTSTRAP_IMPORTS),
100
+ * and a build discovers in buildStart.
101
+ */
102
+ export declare function assignClientUrlRevalidateFiles(state: Pick<DiscoveryState, "clientUrlRevalidate" | "clientUrlSourceByReferenceId">, rscEnv: ClientUrlRscEnvironment, projections: ReadonlyMap<string, ClientUrlProjection>): Promise<void>;
53
103
  export {};
@@ -52,7 +52,26 @@ export interface PluginOptions {
52
52
  * budget into its capture/render handlers.
53
53
  */
54
54
  progressiveChunkSize?: number;
55
+ /**
56
+ * The index rango()'s clientUrls() revalidate() hoist plugin shares, so
57
+ * discovery's temp server records keys into it and assigns the files the
58
+ * dev server's or build's group modules import.
59
+ */
60
+ clientUrlRevalidate?: ClientUrlRevalidateIndex;
61
+ }
62
+ /**
63
+ * What the clientUrls() revalidate() hoist
64
+ * (plugins/client-urls-revalidate-hoist.ts) shares with discovery across the
65
+ * plugin instances of one rango(), the dev server or build and discovery's
66
+ * temp server: the file of every key the hoist transform saw, in any
67
+ * environment, and each group's files, which discovery assigns from the
68
+ * group's projection and the group's `?rango-revalidate` module imports.
69
+ */
70
+ export interface ClientUrlRevalidateIndex {
71
+ readonly fileByKey: Map<string, string>;
72
+ readonly filesByGroup: Map<string, readonly string[]>;
55
73
  }
74
+ export declare function createClientUrlRevalidateIndex(): ClientUrlRevalidateIndex;
56
75
  export interface PrecomputedEntry {
57
76
  staticPrefix: string;
58
77
  routes: Record<string, string>;
@@ -122,6 +141,7 @@ export interface DiscoveryState {
122
141
  perRouterManifestDataMap: Map<string, Record<string, string>>;
123
142
  clientUrlSourceByReferenceId?: Map<string, string>;
124
143
  clientUrlProjectionMap?: Map<string, ClientUrlProjection>;
144
+ clientUrlRevalidate: ClientUrlRevalidateIndex;
125
145
  prerenderManifestEntries: Record<string, string> | null;
126
146
  staticManifestEntries: Record<string, string> | null;
127
147
  /**
@@ -1,5 +1,6 @@
1
1
  import type { Plugin } from "vite";
2
2
  import MagicString from "magic-string";
3
+ import type { ClientUrlRevalidateIndex } from "../discovery/state.js";
3
4
  /**
4
5
  * The key of the predicate `source` declared in `relativeFile` (relative to
5
6
  * the project root): a hash of the file and the predicate's syntax, so the
@@ -26,29 +27,40 @@ interface HoistClientUrlsRevalidateResult {
26
27
  readonly keys: readonly string[];
27
28
  }
28
29
  /**
29
- * Hoist every clientUrls() `revalidate()` predicate of a "use client"
30
- * module. Returns null when there is none. Throws, naming file:line, for a
31
- * predicate that is not pure.
30
+ * Hoist every clientUrls() `revalidate()` predicate of a module. Returns null
31
+ * when there is none (boolean literals stay in place). Throws, naming
32
+ * file:line, for a predicate that is not pure.
32
33
  */
33
34
  export declare function hoistClientUrlsRevalidates(code: string, id: string, deps: HoistClientUrlsRevalidateDeps): Promise<HoistClientUrlsRevalidateResult | null>;
34
35
  /** The file a `?rango-revalidate` id names, or null. */
35
36
  export declare function parseHoistedRevalidateId(id: string): string | null;
36
37
  /**
37
38
  * The plugins: a pre transform that hoists in every environment (markers in
38
- * the client and SSR copies, the server module recorded from the RSC
39
- * transform) and serves `?rango-revalidate`, and a post transform that
40
- * appends its import to the RSC client-reference proxy.
39
+ * the client and SSR copies, each key's file in `index`, the server module
40
+ * recorded from the RSC transform, the groups noted) and serves
41
+ * `?rango-revalidate`, a post transform that appends its import to the RSC
42
+ * client-reference proxy of each group, and in dev the client's `.use`
43
+ * update propagation. Pass one `index` to every instance of one rango():
44
+ * discovery's temp server records keys the dev server or build reads.
41
45
  *
42
- * `load` serves the module the RSC transform emitted, which hoisted the
43
- * pipeline code; the disk source is re-hoisted only when the transform has
44
- * not seen the current file (loadEmittedOrDisk). A file whose edit removed
45
- * every predicate serves an empty module to a proxy that still imports it.
46
+ * `load` serves the registrations the RSC transform emitted, which hoisted
47
+ * the pipeline code; the disk source is re-hoisted when the transform has not
48
+ * seen the current file (loadEmittedOrDisk), which is always the case for a
49
+ * component module: the RSC environment never transforms a module only a
50
+ * group imports. A group's module also imports the registrations of the
51
+ * files discovery assigned it. A file with neither serves an empty module.
46
52
  *
47
- * The transform's code filter skips a module that never mentions clientUrls,
48
- * so a file that stops doing so would keep its `emitted` entry: watchChange
49
- * drops it, together with the cached "use client" answer for an edited
50
- * dependency (isClientModule memoizes per resolved file; buildStart resets
51
- * it).
53
+ * A component module that exports only components is a Fast Refresh
54
+ * boundary, so a `.use` edit would leave the browser's group records stale
55
+ * (the group never re-evaluates). In dev, an update that changes a module's
56
+ * componentUseSignature also updates its importers, as a group edit does;
57
+ * any other edit keeps Fast Refresh.
58
+ *
59
+ * The transform's code filter skips a module that names neither clientUrls
60
+ * nor revalidate, so a file that stops doing so would keep its `emitted`
61
+ * entry: watchChange drops it, its group mark, and the cached "use client"
62
+ * answer for an edited dependency (isClientModule memoizes per resolved
63
+ * file; buildStart resets it).
52
64
  */
53
- export declare function clientUrlsRevalidateHoistPlugin(): Plugin[];
65
+ export declare function clientUrlsRevalidateHoistPlugin(index: ClientUrlRevalidateIndex): Plugin[];
54
66
  export {};
@@ -31,11 +31,12 @@ export interface EmittedEntry<T> {
31
31
  }
32
32
  export declare function recordEmitted<T>(emitted: Map<string, EmittedEntry<T>>, file: string, value: T): Promise<void>;
33
33
  /**
34
- * What a `?rango-*` load serves for `hoistedFile`: the transform's emission
35
- * when it saw the current disk source (or the file is gone), else
36
- * `rehoist(disk)`. The transform hoists the pipeline code, which an earlier
37
- * plugin may have changed, so re-hoisting the disk source is the fallback only
38
- * for an environment loading before the RSC transform ran or for an edit the
39
- * RSC environment has not re-transformed yet. Undefined when neither exists.
34
+ * What a `?rango-*` load serves for `hoistedFile`, whose source on disk is
35
+ * `disk` (readSource): the transform's emission when it saw that source (or
36
+ * the file is gone), else `rehoist(disk)`. The transform hoists the pipeline
37
+ * code, which an earlier plugin may have changed, so re-hoisting the disk
38
+ * source is the fallback only for an environment loading before the RSC
39
+ * transform ran or for an edit the RSC environment has not re-transformed
40
+ * yet. Undefined when neither exists.
40
41
  */
41
- export declare function loadEmittedOrDisk<T>(emitted: ReadonlyMap<string, EmittedEntry<T>>, hoistedFile: string, rehoist: (disk: string) => Promise<T | undefined>): Promise<T | undefined>;
42
+ export declare function loadEmittedOrDisk<T>(emitted: ReadonlyMap<string, EmittedEntry<T>>, hoistedFile: string, disk: string | null, rehoist: (disk: string) => Promise<T | undefined>): Promise<T | undefined>;
@@ -36,6 +36,12 @@ export declare const VIRTUAL_IDS: {
36
36
  readonly rsc: "virtual:rsc-router/entry.rsc.js";
37
37
  readonly version: "@rangojs/router:version";
38
38
  };
39
+ /**
40
+ * Non-RSC environments (client, ssr) get only PACKAGE_VERSION: the build
41
+ * module's ROUTER_VERSIONS token is replaced in server chunks only, so a
42
+ * client import of the full module would throw a ReferenceError.
43
+ */
44
+ export declare function getVirtualPackageVersionContent(): string;
39
45
  /** Dev: one stamp for both versions of every router, bumped on RSC edits. */
40
46
  export declare function getVirtualVersionContent(version: string): string;
41
47
  /**
@@ -1,4 +1,11 @@
1
1
  export declare function encodePathParam(value: unknown): string;
2
+ /**
3
+ * `ctx.reverse` of a build-time `getParams()`. Substitutes like the dev-mode
4
+ * one (`createReverseFunction`, router/prerender-match.ts): a missing required
5
+ * param throws `Missing param`, with or without a params object, instead of
6
+ * leaving a literal `:param` in the URL.
7
+ */
8
+ export declare function createGetParamsReverse(routes: Record<string, string>): (name: string, params?: Record<string, string>) => string;
2
9
  export declare function substituteRouteParams(pattern: string, params: Record<string, string>, encode?: (value: string) => string): string;
3
10
  export declare function runWithConcurrency<T>(items: T[], concurrency: number, fn: (item: T) => Promise<void>): Promise<void>;
4
11
  export declare function groupByConcurrency<T extends {