@rangojs/router 0.22.1 → 0.24.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 (259) hide show
  1. package/dist/bin/rango.js +10 -4
  2. package/dist/testing/vitest.js +31 -1
  3. package/dist/types/browser/defer.d.ts +48 -0
  4. package/dist/types/browser/document-revealed.d.ts +17 -0
  5. package/dist/types/browser/event-controller.d.ts +7 -1
  6. package/dist/types/browser/merge-segment-loaders.d.ts +5 -2
  7. package/dist/types/browser/navigation-transaction.d.ts +21 -7
  8. package/dist/types/browser/partial-update.d.ts +39 -8
  9. package/dist/types/browser/react/NavigationProvider.d.ts +19 -5
  10. package/dist/types/browser/react/context.d.ts +3 -2
  11. package/dist/types/browser/react/filter-segment-order.d.ts +7 -0
  12. package/dist/types/browser/response-adapter.d.ts +7 -0
  13. package/dist/types/browser/types.d.ts +24 -10
  14. package/dist/types/browser/validate-redirect-origin.d.ts +11 -0
  15. package/dist/types/build/generate-route-types.d.ts +1 -1
  16. package/dist/types/build/route-types/router-processing.d.ts +1 -1
  17. package/dist/types/build/route-types/scan-filter.d.ts +22 -2
  18. package/dist/types/cache/cf/cf-cache-store.d.ts +16 -1
  19. package/dist/types/cache/cf/cf-cache-types.d.ts +23 -2
  20. package/dist/types/cache/document-cache-policy.d.ts +24 -0
  21. package/dist/types/cache/document-cache.d.ts +2 -10
  22. package/dist/types/client-urls/client-urls.d.ts +1 -1
  23. package/dist/types/client-urls/hoisted-revalidate.d.ts +13 -0
  24. package/dist/types/client-urls/navigation.d.ts +0 -37
  25. package/dist/types/client-urls/revalidate-registry.d.ts +4 -0
  26. package/dist/types/client-urls/server-projection.d.ts +29 -1
  27. package/dist/types/client-urls/types.d.ts +34 -69
  28. package/dist/types/client.d.ts +0 -1
  29. package/dist/types/context-var.d.ts +12 -0
  30. package/dist/types/errors.d.ts +15 -0
  31. package/dist/types/handles/deferred-resolution.d.ts +2 -1
  32. package/dist/types/handles/pushed-by.d.ts +31 -0
  33. package/dist/types/index.d.ts +4 -0
  34. package/dist/types/index.rsc.d.ts +2 -0
  35. package/dist/types/loader-store.d.ts +8 -0
  36. package/dist/types/prefetch-markers.d.ts +11 -0
  37. package/dist/types/response-utils.d.ts +7 -0
  38. package/dist/types/reverse.d.ts +8 -8
  39. package/dist/types/route-definition/helpers-types.d.ts +27 -0
  40. package/dist/types/route-definition/rewrite.d.ts +56 -0
  41. package/dist/types/route-map-builder.d.ts +7 -2
  42. package/dist/types/router/basename.d.ts +7 -0
  43. package/dist/types/router/handler-context.d.ts +1 -5
  44. package/dist/types/router/internal-params.d.ts +8 -0
  45. package/dist/types/router/is-action.d.ts +2 -1
  46. package/dist/types/router/middleware-types.d.ts +15 -0
  47. package/dist/types/router/revalidation.d.ts +1 -2
  48. package/dist/types/router/route-trie-builder.d.ts +10 -0
  49. package/dist/types/router/segment-resolution/loader-mask.d.ts +3 -2
  50. package/dist/types/router/segment-resolution/mask-nested.d.ts +4 -2
  51. package/dist/types/router/segment-resolution/prefetch-deferral.d.ts +264 -0
  52. package/dist/types/rsc/full-payload.d.ts +11 -0
  53. package/dist/types/rsc/handler.d.ts +33 -0
  54. package/dist/types/rsc/helpers.d.ts +8 -0
  55. package/dist/types/rsc/loader-fetch.d.ts +16 -0
  56. package/dist/types/rsc/rewrite-passes.d.ts +74 -0
  57. package/dist/types/rsc/ssr-setup.d.ts +3 -1
  58. package/dist/types/server/context.d.ts +21 -1
  59. package/dist/types/server/handle-store.d.ts +9 -1
  60. package/dist/types/server/request-context.d.ts +52 -2
  61. package/dist/types/server/rewrite-trail.d.ts +49 -0
  62. package/dist/types/server/slot-accessors.d.ts +29 -0
  63. package/dist/types/server.d.ts +1 -0
  64. package/dist/types/testing/flight.entry.d.ts +1 -1
  65. package/dist/types/testing/index.d.ts +4 -4
  66. package/dist/types/testing/internal/action-id.d.ts +10 -1
  67. package/dist/types/testing/internal/client-urls-projection.d.ts +16 -0
  68. package/dist/types/testing/internal/test-action.d.ts +8 -0
  69. package/dist/types/testing/render-route.d.ts +8 -0
  70. package/dist/types/testing/run-loader.d.ts +2 -1
  71. package/dist/types/testing/run-middleware.d.ts +20 -0
  72. package/dist/types/testing/run-revalidate.d.ts +74 -0
  73. package/dist/types/testing/run-transition-when.d.ts +2 -3
  74. package/dist/types/testing/serve-shell-request.d.ts +40 -1
  75. package/dist/types/testing/vitest.d.ts +11 -0
  76. package/dist/types/thenable-status.d.ts +6 -0
  77. package/dist/types/types/boundaries.d.ts +9 -0
  78. package/dist/types/types/handler-context.d.ts +14 -0
  79. package/dist/types/types/loader-types.d.ts +30 -0
  80. package/dist/types/types/request-scope.d.ts +7 -0
  81. package/dist/types/types/segments.d.ts +21 -4
  82. package/dist/types/urls/path-helper-types.d.ts +25 -4
  83. package/dist/types/urls/type-extraction.d.ts +6 -2
  84. package/dist/types/vite/discovery/discover-routers.d.ts +9 -0
  85. package/dist/types/vite/discovery/state.d.ts +14 -4
  86. package/dist/types/vite/plugins/client-urls-revalidate-hoist.d.ts +54 -0
  87. package/dist/types/vite/plugins/hoist/literal.d.ts +83 -0
  88. package/dist/types/vite/plugins/hoist/scope.d.ts +40 -0
  89. package/dist/types/vite/plugins/hoist/source.d.ts +41 -0
  90. package/dist/types/vite/plugins/transition-when-hoist.d.ts +8 -11
  91. package/dist/types/vite/router-discovery.d.ts +10 -0
  92. package/dist/vite/index.js +974 -379
  93. package/package.json +1 -1
  94. package/skills/caching/SKILL.md +54 -5
  95. package/skills/catalog.json +3 -3
  96. package/skills/client-urls/SKILL.md +197 -24
  97. package/skills/cloudflare/SKILL.md +14 -9
  98. package/skills/hooks/SKILL.md +16 -3
  99. package/skills/hooks/data.md +3 -1
  100. package/skills/links/SKILL.md +24 -0
  101. package/skills/loader/SKILL.md +199 -2
  102. package/skills/middleware/SKILL.md +183 -2
  103. package/skills/migrate-nextjs/SKILL.md +2 -2
  104. package/skills/migrate-react-router/SKILL.md +10 -7
  105. package/skills/migrate-react-router/data-and-actions.md +1 -1
  106. package/skills/ppr/SKILL.md +22 -0
  107. package/skills/prerender/SKILL.md +22 -8
  108. package/skills/rango/SKILL.md +13 -7
  109. package/skills/route/SKILL.md +139 -0
  110. package/skills/server-actions/SKILL.md +27 -0
  111. package/skills/testing/SKILL.md +3 -2
  112. package/skills/testing/client-components.md +2 -1
  113. package/skills/testing/middleware.md +31 -10
  114. package/skills/testing/predicates.md +67 -32
  115. package/skills/testing/response-routes.md +1 -0
  116. package/skills/testing/serve-shell-request.md +107 -19
  117. package/skills/testing/setup.md +2 -2
  118. package/skills/typesafety/route-types.md +2 -2
  119. package/skills/use-cache/SKILL.md +4 -2
  120. package/skills/view-transitions/SKILL.md +26 -0
  121. package/src/__augment-tests__/augmented.check.ts +20 -0
  122. package/src/browser/defer.ts +82 -0
  123. package/src/browser/document-revealed.ts +52 -0
  124. package/src/browser/event-controller.ts +46 -32
  125. package/src/browser/merge-segment-loaders.ts +31 -18
  126. package/src/browser/navigation-bridge.ts +82 -16
  127. package/src/browser/navigation-client.ts +48 -36
  128. package/src/browser/navigation-store.ts +13 -0
  129. package/src/browser/navigation-transaction.ts +25 -8
  130. package/src/browser/partial-update.ts +554 -146
  131. package/src/browser/prefetch/fetch.ts +2 -1
  132. package/src/browser/react/Link.tsx +7 -9
  133. package/src/browser/react/NavigationProvider.tsx +88 -49
  134. package/src/browser/react/context.ts +3 -2
  135. package/src/browser/react/filter-segment-order.ts +13 -2
  136. package/src/browser/react/use-router.ts +2 -4
  137. package/src/browser/response-adapter.ts +20 -0
  138. package/src/browser/rsc-router.tsx +17 -45
  139. package/src/browser/server-action-bridge.ts +25 -63
  140. package/src/browser/types.ts +24 -10
  141. package/src/browser/validate-redirect-origin.ts +16 -0
  142. package/src/build/generate-route-types.ts +1 -0
  143. package/src/build/route-types/router-processing.ts +3 -6
  144. package/src/build/route-types/scan-filter.ts +45 -11
  145. package/src/cache/cf/cf-cache-store.ts +59 -21
  146. package/src/cache/cf/cf-cache-types.ts +24 -2
  147. package/src/cache/document-cache-policy.ts +131 -0
  148. package/src/cache/document-cache.ts +21 -107
  149. package/src/client-urls/client-urls.ts +22 -6
  150. package/src/client-urls/hoisted-revalidate.ts +25 -0
  151. package/src/client-urls/navigation.ts +0 -96
  152. package/src/client-urls/revalidate-registry.ts +30 -0
  153. package/src/client-urls/server-projection.ts +151 -65
  154. package/src/client-urls/types.ts +39 -71
  155. package/src/client.tsx +9 -5
  156. package/src/context-var.ts +32 -2
  157. package/src/errors.ts +34 -0
  158. package/src/handles/deferred-resolution.ts +28 -5
  159. package/src/handles/pushed-by.ts +148 -0
  160. package/src/index.rsc.ts +8 -0
  161. package/src/index.ts +7 -0
  162. package/src/loader-store.ts +18 -7
  163. package/src/prefetch-markers.ts +13 -0
  164. package/src/response-utils.ts +19 -0
  165. package/src/reverse.ts +17 -14
  166. package/src/route-content-wrapper.tsx +18 -4
  167. package/src/route-definition/dsl-helpers.ts +27 -4
  168. package/src/route-definition/helpers-types.ts +27 -1
  169. package/src/route-definition/redirect.ts +2 -15
  170. package/src/route-definition/rewrite.ts +146 -0
  171. package/src/route-map-builder.ts +14 -11
  172. package/src/router/basename.ts +20 -0
  173. package/src/router/handler-context.ts +3 -13
  174. package/src/router/intercept-resolution.ts +35 -16
  175. package/src/router/internal-params.ts +16 -0
  176. package/src/router/is-action.ts +2 -1
  177. package/src/router/loader-resolution.ts +85 -4
  178. package/src/router/match-api.ts +36 -1
  179. package/src/router/match-middleware/background-revalidation.ts +16 -4
  180. package/src/router/match-middleware/cache-lookup.ts +35 -7
  181. package/src/router/match-middleware/cache-store.ts +15 -1
  182. package/src/router/match-middleware/intercept-resolution.ts +4 -2
  183. package/src/router/match-result.ts +14 -2
  184. package/src/router/middleware-types.ts +16 -0
  185. package/src/router/middleware.ts +127 -49
  186. package/src/router/navigation-snapshot.ts +2 -1
  187. package/src/router/revalidation.ts +1 -1
  188. package/src/router/route-trie-builder.ts +28 -1
  189. package/src/router/segment-resolution/fresh.ts +22 -18
  190. package/src/router/segment-resolution/loader-cache.ts +2 -1
  191. package/src/router/segment-resolution/loader-mask.ts +5 -3
  192. package/src/router/segment-resolution/loader-snapshot.ts +18 -4
  193. package/src/router/segment-resolution/mask-nested.ts +8 -4
  194. package/src/router/segment-resolution/prefetch-deferral.ts +583 -0
  195. package/src/router/segment-resolution/revalidation.ts +215 -82
  196. package/src/rsc/full-payload.ts +37 -5
  197. package/src/rsc/handler.ts +82 -55
  198. package/src/rsc/helpers.ts +24 -0
  199. package/src/rsc/loader-fetch.ts +79 -24
  200. package/src/rsc/response-cache-serve.ts +18 -2
  201. package/src/rsc/response-route-handler.ts +4 -7
  202. package/src/rsc/rewrite-passes.ts +203 -0
  203. package/src/rsc/rsc-rendering.ts +54 -9
  204. package/src/rsc/shell-capture.ts +2 -1
  205. package/src/rsc/ssr-setup.ts +11 -5
  206. package/src/segment-loader-promise.ts +23 -20
  207. package/src/segment-system.tsx +60 -26
  208. package/src/server/context.ts +39 -5
  209. package/src/server/cookie-parse.ts +36 -12
  210. package/src/server/cookie-store.ts +7 -3
  211. package/src/server/handle-store.ts +152 -25
  212. package/src/server/request-context.ts +175 -64
  213. package/src/server/request-headers.ts +4 -14
  214. package/src/server/rewrite-trail.ts +190 -0
  215. package/src/server/slot-accessors.ts +57 -0
  216. package/src/server.ts +4 -0
  217. package/src/ssr/index.tsx +118 -16
  218. package/src/testing/action-form.ts +2 -11
  219. package/src/testing/dispatch.ts +138 -67
  220. package/src/testing/e2e/page-helpers.ts +3 -1
  221. package/src/testing/flight.entry.ts +1 -0
  222. package/src/testing/index.ts +7 -3
  223. package/src/testing/internal/action-id.ts +16 -1
  224. package/src/testing/internal/client-urls-projection.ts +70 -0
  225. package/src/testing/internal/test-action.ts +25 -0
  226. package/src/testing/render-route.tsx +16 -3
  227. package/src/testing/run-loader.ts +4 -1
  228. package/src/testing/run-middleware.ts +56 -11
  229. package/src/testing/run-revalidate.ts +142 -0
  230. package/src/testing/run-transition-when.ts +7 -8
  231. package/src/testing/serve-shell-request.ts +131 -8
  232. package/src/testing/vitest.ts +67 -1
  233. package/src/thenable-status.ts +11 -0
  234. package/src/types/boundaries.ts +12 -0
  235. package/src/types/handler-context.ts +14 -0
  236. package/src/types/loader-types.ts +30 -0
  237. package/src/types/request-scope.ts +8 -0
  238. package/src/types/segments.ts +26 -4
  239. package/src/urls/path-helper-types.ts +27 -5
  240. package/src/urls/type-extraction.ts +30 -10
  241. package/src/use-loader.tsx +18 -13
  242. package/src/vite/discovery/client-urls-projection.ts +20 -21
  243. package/src/vite/discovery/discover-routers.ts +94 -26
  244. package/src/vite/discovery/state.ts +28 -4
  245. package/src/vite/discovery/virtual-module-codegen.ts +22 -17
  246. package/src/vite/plugins/client-urls-revalidate-hoist.ts +564 -0
  247. package/src/vite/plugins/expose-internal-ids.ts +2 -3
  248. package/src/vite/plugins/hoist/literal.ts +417 -0
  249. package/src/vite/plugins/hoist/scope.ts +370 -0
  250. package/src/vite/plugins/hoist/source.ts +84 -0
  251. package/src/vite/plugins/transition-when-hoist.ts +113 -779
  252. package/src/vite/rango.ts +2 -0
  253. package/src/vite/router-discovery.ts +116 -53
  254. package/dist/types/client-urls/revalidate-chain.d.ts +0 -33
  255. package/dist/types/client-urls/revalidation-protocol.d.ts +0 -25
  256. package/dist/types/testing/run-client-revalidate.d.ts +0 -43
  257. package/src/client-urls/revalidate-chain.ts +0 -83
  258. package/src/client-urls/revalidation-protocol.ts +0 -56
  259. package/src/testing/run-client-revalidate.ts +0 -92
@@ -587,6 +587,26 @@ export interface RequestContext<TEnv = DefaultEnv, TParams = Record<string, stri
587
587
  * document cache does not store that response (#978).
588
588
  */
589
589
  _payloadVisitorTheme?: boolean;
590
+ /**
591
+ * @internal Set by the partial render when its payload carries deferred
592
+ * units (`prefetch: false`): what one page's prefetch left for the fill.
593
+ * The document cache does not store that response, whatever Cache-Control
594
+ * it ends up with (docs/design/prefetch-false.md, R7).
595
+ */
596
+ _payloadDeferred?: boolean;
597
+ /**
598
+ * @internal What the request says it is: a `<Link>` prefetch or a fill
599
+ * (`prefetch: false`), read once at creation
600
+ * (segment-resolution/prefetch-deferral.ts requestKind).
601
+ */
602
+ _requestKind?: "prefetch" | "fill";
603
+ /**
604
+ * @internal Set when a render shows the visitor's URL of a rewritten
605
+ * request: the payload or SSR seed (renderedLocation, rsc/full-payload.ts)
606
+ * or a `ctx.rewrittenFrom` read (server/rewrite-trail.ts). The document
607
+ * cache does not store that response: it is keyed by the target.
608
+ */
609
+ _payloadVisitorLocation?: boolean;
590
610
  /**
591
611
  * Attach location state entries to the current response.
592
612
  *
@@ -803,7 +823,7 @@ export interface RouteRecordWindow {
803
823
  * This is the type exported to library consumers. Internal code should
804
824
  * use the full RequestContext interface directly.
805
825
  */
806
- export type PublicRequestContext<TEnv = DefaultEnv, TParams = Record<string, string>> = Omit<RequestContext<TEnv, TParams>, "cookie" | "cookies" | "_readCookie" | "_readCookies" | "setCookie" | "deleteCookie" | "_handleStore" | "_transitionWhenRefs" | "_pprReplayPostMatchReason" | "_cacheStore" | "_prerender" | "_onDemandProducer" | "_searchParamsFilter" | "_shellCaptureRun" | "_shellImplicitCache" | "_shellLoaderSeed" | "_shellCaptureLoaderRecords" | "_shellCaptureUnrecordedLoaderPush" | "_shellCaptureLoaderLanes" | "_resolvedCacheKeys" | "_shellKey" | "_shellForcedMiss" | "_prerenderWarm" | "_runAtRequestEntry" | "_routeRecordWindow" | "_shellFragmentPayload" | "_shellCaptureGuardTripped" | "_shellCaptureGuardTrippedLoaderId" | "_explicitTaggedStores" | "_requestTags" | "_recordTagOwners" | "_recordLoaderTags" | "_cacheProfiles" | "_onResponseCallbacks" | "_pendingBackgroundTasks" | "_themeConfig" | "_readTheme" | "_documentCacheRender" | "_payloadVisitorTheme" | "_locationState" | "_routeName" | "_prevRouteKey" | "_inActionRevalidation" | "_reportedErrors" | "_renderErrors" | "_recoveredHandlerErrors" | "_renderBarrier" | "_resolveRenderBarrier" | "_renderBarrierSegmentOrder" | "_treeHasStreaming" | "_renderBarrierWaiters" | "_handlerLoaderDeps" | "_awaitBeforeFlushLoaderIds" | "_renderBarrierHandleSnapshot" | "_renderBarrierGuardClosed" | "_reportBackgroundError" | "_debugPerformance" | "_metricsStore" | "_renderForeground" | "_activeRoutine" | "_renderDiagnosticsEnabled" | "_handlerStart" | "_tracing" | "_basename" | "_routerId" | "_versions" | "_setStatus" | "_rotateStateCookie" | "_setKeepCacheDirective" | "_freshReads" | "_setFreshReadsCookie" | "_requestRoot" | "_requestStart" | "_responseSent" | "_variables" | "_classifiedRoute" | "_requestMode" | "_cacheSignal" | "_dynamic" | "res">;
826
+ export type PublicRequestContext<TEnv = DefaultEnv, TParams = Record<string, string>> = Omit<RequestContext<TEnv, TParams>, "cookie" | "cookies" | "_readCookie" | "_readCookies" | "setCookie" | "deleteCookie" | "_handleStore" | "_transitionWhenRefs" | "_pprReplayPostMatchReason" | "_cacheStore" | "_prerender" | "_onDemandProducer" | "_searchParamsFilter" | "_shellCaptureRun" | "_shellImplicitCache" | "_shellLoaderSeed" | "_shellCaptureLoaderRecords" | "_shellCaptureUnrecordedLoaderPush" | "_shellCaptureLoaderLanes" | "_resolvedCacheKeys" | "_shellKey" | "_shellForcedMiss" | "_prerenderWarm" | "_runAtRequestEntry" | "_routeRecordWindow" | "_shellFragmentPayload" | "_shellCaptureGuardTripped" | "_shellCaptureGuardTrippedLoaderId" | "_explicitTaggedStores" | "_requestTags" | "_recordTagOwners" | "_recordLoaderTags" | "_cacheProfiles" | "_onResponseCallbacks" | "_pendingBackgroundTasks" | "_themeConfig" | "_readTheme" | "_documentCacheRender" | "_payloadVisitorTheme" | "_payloadDeferred" | "_requestKind" | "_payloadVisitorLocation" | "_locationState" | "_routeName" | "_prevRouteKey" | "_inActionRevalidation" | "_reportedErrors" | "_renderErrors" | "_recoveredHandlerErrors" | "_renderBarrier" | "_resolveRenderBarrier" | "_renderBarrierSegmentOrder" | "_treeHasStreaming" | "_renderBarrierWaiters" | "_handlerLoaderDeps" | "_awaitBeforeFlushLoaderIds" | "_renderBarrierHandleSnapshot" | "_renderBarrierGuardClosed" | "_reportBackgroundError" | "_debugPerformance" | "_metricsStore" | "_renderForeground" | "_activeRoutine" | "_renderDiagnosticsEnabled" | "_handlerStart" | "_tracing" | "_basename" | "_routerId" | "_versions" | "_setStatus" | "_rotateStateCookie" | "_setKeepCacheDirective" | "_freshReads" | "_setFreshReadsCookie" | "_requestRoot" | "_requestStart" | "_responseSent" | "_variables" | "_classifiedRoute" | "_requestMode" | "_cacheSignal" | "_dynamic" | "res">;
807
827
  /**
808
828
  * Marker for a waitUntil-scheduled fn whose task promise must NOT enter
809
829
  * _pendingBackgroundTasks. Used by the PPR shell capture for its own task:
@@ -812,6 +832,13 @@ export type PublicRequestContext<TEnv = DefaultEnv, TParams = Record<string, str
812
832
  * @internal
813
833
  */
814
834
  export declare const UNTRACKED_BACKGROUND_TASK: unique symbol;
835
+ /**
836
+ * Define `ctx.res` as an own accessor that reads `get`. Assigning it throws
837
+ * the read-only error. A context derived from another (Object.create) gets
838
+ * its own response this way; copying the descriptor would read the
839
+ * prototype's slot.
840
+ */
841
+ export declare function bindRes(ctx: RequestContext<any, any>, get: () => Response): void;
815
842
  /**
816
843
  * Capture the current async context (RequestContext._runAtRequestEntry), taken
817
844
  * on handler entry before any router scope, so a nested dispatch (a
@@ -911,6 +938,26 @@ export interface CreateRequestContextOptions<TEnv> {
911
938
  * - Passed to handlers as ctx
912
939
  */
913
940
  export declare function createRequestContext<TEnv>(options: CreateRequestContextOptions<TEnv>): RequestContext<TEnv>;
941
+ /**
942
+ * Move a request context to a rewrite target for the next pass of the
943
+ * request (rsc/rewrite-passes.ts, `throw rewrite()`). The context object
944
+ * stays the same, so what the visitor's pass set is still there: variables
945
+ * (the rewrite trail among them), the response stub (status, headers,
946
+ * cookies), location state, theme, `dynamic()`, metrics, request tags,
947
+ * onResponse callbacks, the handle store.
948
+ *
949
+ * Moved to the target: the request (`rawUrl`, the visitor's `_rsc*` params
950
+ * included), url, originalUrl, pathname, searchParams and the request kind.
951
+ * Cleared for the target's match: params, route name, reverse, the
952
+ * classified route, the request mode, and the document cache's render mark
953
+ * (its middleware runs again for the target). The loader memo behind
954
+ * `getRequestContext().use()` is new: a loader that middleware started in
955
+ * the visitor's pass read the visitor's URL. A pass never renders before it
956
+ * rewrites: router/middleware.ts refuses a rewrite thrown after a next()
957
+ * unless that next() rejected with a Rewrite (a downstream middleware
958
+ * rewrote before its own next()), so there is no render state to reset.
959
+ */
960
+ export declare function rebaseRequestContext(ctx: RequestContext<any>, request: Request, rawUrl: URL): void;
914
961
  /**
915
962
  * Wire a fresh render barrier onto `ctx`, closure-bound to THIS ctx and THIS
916
963
  * handle store. Called by createRequestContext for every fresh context, and by
@@ -927,8 +974,11 @@ export declare function createRequestContext<TEnv>(options: CreateRequestContext
927
974
  * read the foreground's handle snapshot; the capture's fresh `_handleStore`
928
975
  * was invisible, so foreground per-request handle data could bake into the
929
976
  * shared shell.
977
+ *
978
+ * A derived context's `_renderBarrier` is non-enumerable (the default
979
+ * descriptor); a fresh context's is enumerable like its other fields.
930
980
  */
931
- export declare function wireRenderBarrier(ctx: RequestContext<any, any>, handleStore: HandleStore): void;
981
+ export declare function wireRenderBarrier(ctx: RequestContext<any, any>, handleStore: HandleStore, descriptor?: PropertyDescriptor): void;
932
982
  export { parseCookiesFromHeader };
933
983
  export declare function serializeCookieValue(name: string, value: string, options?: CookieOptions): string;
934
984
  /**
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The URLs a rewritten request moved through (`throw rewrite()`), and what
3
+ * each context sees of them.
4
+ *
5
+ * One source: the trail lives in the request's variables under a token no
6
+ * user code can reach, so a middleware cannot reset the loop count. The
7
+ * visitor's URL is its first entry (`ctx.rewrittenFrom`); the hops are its
8
+ * length minus one.
9
+ */
10
+ import type { RequestContext } from "./request-context.js";
11
+ /** Most rewrites one request may take; the next one is a RewriteLoopError. */
12
+ export declare const MAX_REWRITE_HOPS = 5;
13
+ type TrailContext = Pick<RequestContext<any>, "_variables">;
14
+ /** The trail of a rewritten request; undefined when nothing rewrote. */
15
+ export declare function rewriteTrail(reqCtx: TrailContext | undefined): readonly string[] | undefined;
16
+ /**
17
+ * Count one hop from `from` to `to` (clean URLs) and return its number.
18
+ * Throws RewriteLoopError past {@link MAX_REWRITE_HOPS}, or when `to` is the
19
+ * URL the request is on (pathname and search).
20
+ */
21
+ export declare function recordRewriteHop(reqCtx: TrailContext, from: URL, to: URL): number;
22
+ type AudienceContext = Pick<RequestContext<any>, "_shellCaptureRun" | "_documentCacheRender" | "res">;
23
+ /**
24
+ * A render other visitors may be served: a PPR shell capture, or a render
25
+ * the document cache stores (its response opted in before next()). It shows
26
+ * what a direct visit to its URL shows: no visitor theme, no visitor URL.
27
+ */
28
+ export declare function rendersForSharedAudience(reqCtx: AudienceContext): boolean;
29
+ /**
30
+ * The URL the visitor is on: the first URL of a rewritten request, else
31
+ * `url` with the internal `_rsc*` params stripped. A reload the router asks
32
+ * the browser for points here.
33
+ */
34
+ export declare function visitorUrl(reqCtx: TrailContext | undefined, url: URL): URL;
35
+ /**
36
+ * Who reads `rewrittenFrom`: "render" for the contexts a render reads
37
+ * (handler, loader, response route, getRequestContext()), "middleware" for a
38
+ * middleware ctx, which runs once per request and is never stored.
39
+ */
40
+ export type RewrittenFromReader = "render" | "middleware";
41
+ /**
42
+ * Define `ctx.rewrittenFrom` on a handler, loader, response-route or
43
+ * middleware ctx, read through `source` (the request context it belongs
44
+ * to). Each ctx gets its own copy of the URL.
45
+ */
46
+ export declare function defineRewrittenFrom(ctx: object, source: RequestContext<any> | undefined, reader?: RewrittenFromReader): void;
47
+ /** Define `rewrittenFrom` on a request context, read through itself. */
48
+ export declare function defineRequestRewrittenFrom(ctx: RequestContext<any>): void;
49
+ export {};
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Property definitions for per-request objects that keep V8 fast properties
3
+ * (#1109): the request context, the middleware ctx, the handle store and a
4
+ * guarded request.
5
+ *
6
+ * V8 puts an object in dictionary mode, where every property read is a hash
7
+ * lookup for the object's whole lifetime, when an object literal declares a
8
+ * get/set member, when a data property is redefined as an accessor after
9
+ * creation, or when an accessor is defined with a function its shape
10
+ * transition has not recorded: a closure created per request is a new
11
+ * function every time. So an accessor on a per-request object is a
12
+ * module-level descriptor, and one that needs per-object state reads a
13
+ * per-object closure from a non-enumerable symbol slot (slotAccessor +
14
+ * defineSlot). A derived object (Object.create(obj)) reads the slot through
15
+ * its prototype; the descriptor copied onto another object reads that
16
+ * object's slot instead. context-fast-properties.test.ts pins all of it.
17
+ *
18
+ * Dependency-free leaf: handle-store.ts is imported by request-context.ts,
19
+ * so these cannot live in either.
20
+ */
21
+ /**
22
+ * An accessor descriptor whose getter calls the receiver's `slot` closure.
23
+ * Call it once at module level and share the result.
24
+ */
25
+ export declare function slotAccessor(slot: symbol, enumerable: boolean): PropertyDescriptor;
26
+ /** Define `slot` on `target` as a non-enumerable, read-only data property. */
27
+ export declare function defineSlot(target: object, slot: symbol, value: unknown): void;
28
+ /** Define `key` on `target` as a non-enumerable, writable data property. */
29
+ export declare function defineHidden(target: object, key: PropertyKey, value: unknown): void;
@@ -15,3 +15,4 @@ export { createRequestContext, type CreateRequestContextOptions, } from "./serve
15
15
  export { isClientComponent, assertClientComponent } from "./component-utils.js";
16
16
  export { enableTransitionWhenValidation } from "./transition-when-ref.js";
17
17
  export { clearClientUrlProjections, setClientUrlProjection, type ClientUrlProjection, } from "./client-urls/server-projection.js";
18
+ export { registerClientUrlRevalidators } from "./client-urls/revalidate-registry.js";
@@ -33,4 +33,4 @@ export type { TestableHandler, RenderHandlerOptions, RenderHandlerResult, StateC
33
33
  export { createActionForm } from "./action-form.js";
34
34
  export type { CreateActionFormOptions } from "./action-form.js";
35
35
  export { serveShellRequest, resetShellTestState, } from "./serve-shell-request.js";
36
- export type { ServeShellRequestOptions, ServeShellRequestResult, ShellRequestHandles, } from "./serve-shell-request.js";
36
+ export type { ServeShellRequestAction, ServeShellRequestOptions, ServeShellRequestResult, ShellRequestHandles, } from "./serve-shell-request.js";
@@ -26,7 +26,7 @@
26
26
  * condition and would throw if pulled into this barrel.
27
27
  *
28
28
  * Layers:
29
- * - Unit: runMiddleware, runLoader, runClientRevalidate
29
+ * - Unit: runMiddleware, runLoader, runRevalidate, runTransitionWhen
30
30
  * - Integration: dispatch (request -> Response)
31
31
  * - Cross-cut: assertCacheStatus, assertShellStatus, assertGeneratedRoutesMatch
32
32
  * - Component: see @rangojs/router/testing/dom (renderRoute)
@@ -34,13 +34,13 @@
34
34
  * - RSC: see @rangojs/router/testing/flight
35
35
  */
36
36
  export { runMiddleware } from "./run-middleware.js";
37
- export type { RunMiddlewareOptions, RunMiddlewareResult, } from "./run-middleware.js";
37
+ export type { RunMiddlewareOptions, RunMiddlewareResult, RunMiddlewareRewrite, } from "./run-middleware.js";
38
38
  export { runLoader, runLoaderResult } from "./run-loader.js";
39
39
  export type { RunLoaderOptions, RunLoaderResult, UseResolver, TestLoaderContext, } from "./run-loader.js";
40
40
  export { runTransitionWhen } from "./run-transition-when.js";
41
41
  export type { RunTransitionWhenAction, RunTransitionWhenLocation, RunTransitionWhenOptions, RunTransitionWhenResult, } from "./run-transition-when.js";
42
- export { runClientRevalidate } from "./run-client-revalidate.js";
43
- export type { RunClientRevalidateOptions } from "./run-client-revalidate.js";
42
+ export { runRevalidate } from "./run-revalidate.js";
43
+ export type { RunRevalidateAction, RunRevalidateOptions, } from "./run-revalidate.js";
44
44
  export { dispatch } from "./dispatch.js";
45
45
  export type { DispatchOptions } from "./dispatch.js";
46
46
  export { createMemoryPrerenderStore } from "../prerender/memory-prerender-store.js";
@@ -1,7 +1,16 @@
1
+ /** An imported server action, as a testing primitive's `action` option takes it. */
2
+ export type ImportedAction = (...args: never[]) => unknown;
3
+ /**
4
+ * Normalizes a testing primitive's `action` option: a bare imported action or
5
+ * actionId string becomes `{ ref }`; the object form passes through.
6
+ */
7
+ export declare function normalizeTestAction<T extends {
8
+ ref?: ImportedAction | string;
9
+ }>(action: ImportedAction | string | T | undefined): T | undefined;
1
10
  /**
2
11
  * The id a testing primitive's `action` option names: a single imported
3
12
  * server action (its `$id ?? $$id`, as the action boundary derives it) or a
4
13
  * raw actionId string. A function without either id throws, naming the
5
14
  * primitive.
6
15
  */
7
- export declare function resolveTestActionId(action: ((...args: never[]) => unknown) | string | undefined, primitive: string): string | undefined;
16
+ export declare function resolveTestActionId(action: ImportedAction | string | undefined, primitive: string): string | undefined;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Install the projection of a `"use client"` clientUrls() module under its
3
+ * client reference id, as discovery installs it for an app
4
+ * (discoverClientUrlProjections in vite/discovery/client-urls-projection.ts):
5
+ * the same projection step, into the same registry include() materializes
6
+ * from. rangoUseClientTransform (testing/vitest.ts) appends a call to every
7
+ * such module, passing the module's own source evaluated without the
8
+ * transform, so a router under test mounts the group with no setup.
9
+ *
10
+ * A Vitest project runs no hoist plugin, so the source's revalidate()
11
+ * predicates are plain functions. Each is registered under a key named for
12
+ * its reference, route and loader, as the plugin's generated module registers
13
+ * its own, and the projection carries the keys: materialization attaches them
14
+ * and the server runs them, as in an app.
15
+ */
16
+ export declare function installClientUrlsProjection(referenceId: string, source: Readonly<Record<string, unknown>>): void;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Register `action` under its reference id, `<module id>#<export name>`,
3
+ * tagged as a server reference like a built "use server" export so it keeps
4
+ * its `$$id`, where the plugin-rsc stub's decodeAction / loadServerAction
5
+ * resolve it. `primitive` names the caller in the error for a malformed id.
6
+ * Loads the react-server build: callers run under the react-server condition.
7
+ */
8
+ export declare function registerTestAction(action: (...args: any[]) => unknown, id: string, primitive: string): void;
@@ -300,6 +300,14 @@ export interface RenderRouteOptions {
300
300
  * - Needs @testing-library/react >= 16.2.0; throws on older versions.
301
301
  */
302
302
  hydrate?: boolean;
303
+ /**
304
+ * The path middleware rewrote `request` to (`throw rewrite()`): the leaf
305
+ * route is matched against it for params, while the location stays
306
+ * `request`, as on a rewritten document. The server pass and hydration
307
+ * both see `request` (`usePathname()`, `useSearchParams()`), as production
308
+ * renders a rewritten page with the visitor's URL (`/middleware` skill).
309
+ */
310
+ rewrite?: string;
303
311
  }
304
312
  /**
305
313
  * Imperative handle returned alongside the RTL result.
@@ -20,8 +20,9 @@
20
20
  * - `ctx.reverse()` throws unless `routeMap` is provided (it does NOT fall back
21
21
  * to the global route map — that would leak whichever routes another test
22
22
  * registered).
23
- * - `ctx.use(handle)` follows the production rule: reading a handle before
23
+ * - `ctx.get(handle)` follows the production rule: reading a handle before
24
24
  * `await ctx.rendered()` throws (pass `rendered` to mock the barrier).
25
+ * `ctx.use(handle)` is the push and needs no barrier.
25
26
  * - `use cache` functions only cache (and only fire their taint/profile guards)
26
27
  * when a `cacheStore` is provided — without one, registerCachedFunction
27
28
  * bypasses (it checks for a store first). Pass `cacheStore`/`cacheProfiles`
@@ -13,6 +13,10 @@
13
13
  *
14
14
  * `nextCalled` counts how many times the terminal `next()` (the finalHandler)
15
15
  * ran: 0 when the chain short-circuited, 1 when it ran to completion.
16
+ *
17
+ * A `throw rewrite(target)` is reported as `result.rewrite` (the resolved
18
+ * target) instead of failing the run: production re-dispatches the request
19
+ * there, which this primitive does not do.
16
20
  */
17
21
  import { type RequestContext } from "../server/request-context.js";
18
22
  import type { MiddlewareFn } from "../router/middleware-types.js";
@@ -79,6 +83,12 @@ export interface RunMiddlewareOptions<TEnv = any> {
79
83
  */
80
84
  stateCookie?: StateCookieSeed;
81
85
  }
86
+ /** A rewrite the chain threw (RunMiddlewareResult.rewrite). */
87
+ export interface RunMiddlewareRewrite {
88
+ pathname: string;
89
+ search: string;
90
+ routeName?: string;
91
+ }
82
92
  /**
83
93
  * Result of runMiddleware.
84
94
  */
@@ -94,6 +104,16 @@ export interface RunMiddlewareResult<TEnv = any> {
94
104
  ctx: RequestContext<TEnv>;
95
105
  /** Number of times the terminal handler ran (0 = short-circuited, 1 = passed through). */
96
106
  nextCalled: number;
107
+ /**
108
+ * The target of a `throw rewrite(...)` from the chain, resolved as
109
+ * production resolves it (a path basename-prefixed, a route name through
110
+ * `routeMap`): `pathname` and `search` of the URL the request would render,
111
+ * and `routeName` when the rewrite named a route. `undefined` when the chain
112
+ * did not rewrite. On a rewrite, `response` carries what the chain set
113
+ * before the throw (status, headers, cookies), which production keeps for
114
+ * the target's response.
115
+ */
116
+ rewrite?: RunMiddlewareRewrite;
97
117
  /**
98
118
  * Whether the chain called `ctx.dynamic()` (the PPR shell opt-out). The public
99
119
  * way to assert the opt-out without reading the `@internal` `ctx._dynamic`.
@@ -0,0 +1,74 @@
1
+ /**
2
+ * runRevalidate — unit-test revalidate() predicates: a urls() segment's, or a
3
+ * clientUrls() loader's (which the build moves to the server, where it runs
4
+ * the same way).
5
+ *
6
+ * Evaluates the predicate(s) through the router's own evaluateRevalidation
7
+ * (router/revalidation.ts) inside a seeded request context: the default
8
+ * decision, the argument object, boolean short-circuit, soft-verdict
9
+ * threading and the fail-open on a throw are the production code paths, not
10
+ * a re-implementation. Pass an array to test a chain in declaration order.
11
+ */
12
+ import type { ShouldRevalidateFn } from "../types.js";
13
+ import { type ImportedAction } from "./internal/action-id.js";
14
+ import type { VarsInit } from "./internal/seed-vars.js";
15
+ type RevalidateArgs = Parameters<ShouldRevalidateFn<any, any>>[0];
16
+ /** The action fields a predicate receives on an action request. */
17
+ export interface RunRevalidateAction {
18
+ /** The triggering action: an imported server action or its actionId. */
19
+ ref?: ImportedAction | string;
20
+ /** `actionResult`: the action's return value. */
21
+ result?: unknown;
22
+ /** `formData`: the action's FormData argument. */
23
+ formData?: FormData;
24
+ /** `actionUrl`. Defaults to `currentUrl`. */
25
+ url?: string | URL;
26
+ }
27
+ /**
28
+ * Options for {@link runRevalidate}. Defaults model a same-URL navigation
29
+ * with no action, for a route-owned loader segment.
30
+ */
31
+ export interface RunRevalidateOptions<TEnv = any> {
32
+ /** The page being left. Defaults to `http://localhost/`. */
33
+ currentUrl?: string | URL;
34
+ /** The destination. Defaults to `currentUrl`. */
35
+ nextUrl?: string | URL;
36
+ currentParams?: Record<string, string>;
37
+ /** Defaults to `currentParams`. */
38
+ nextParams?: Record<string, string>;
39
+ /**
40
+ * The triggering action: an imported server action (id via
41
+ * `$id ?? $$id`), an actionId string, or `{ ref, result, formData, url }`.
42
+ * Makes the request a POST, as an action request is.
43
+ */
44
+ action?: ImportedAction | string | RunRevalidateAction;
45
+ /** Overrides the request method (`POST` with `action`, else `GET`). */
46
+ method?: string;
47
+ /** The segment the predicate is attached to. Defaults to `"loader"`. */
48
+ segmentType?: RevalidateArgs["segmentType"];
49
+ /**
50
+ * The segment belongs to the matched route (a route's own loaders, a
51
+ * clientUrls() group loader). Defaults to true; false models a layout's
52
+ * loader, which a navigation keeps by default.
53
+ */
54
+ belongsToRoute?: boolean;
55
+ /** `stale`: a history-entry background revalidation. */
56
+ stale?: boolean;
57
+ /** `toRouteName` (and `routeName`). */
58
+ routeName?: string;
59
+ /** `fromRouteName`. */
60
+ fromRouteName?: string;
61
+ /** Environment bindings of the seeded context. */
62
+ env?: TEnv;
63
+ /** Variables a middleware would have set, readable with `context.get()`. */
64
+ vars?: VarsInit;
65
+ /** `context`, in place of the seeded request context. */
66
+ context?: RevalidateArgs["context"];
67
+ }
68
+ /**
69
+ * Run one revalidate() predicate, or a chain in declaration order, the way
70
+ * the router does for a request. Resolves to the final decision: true
71
+ * re-runs the segment, false keeps the client's copy.
72
+ */
73
+ export declare function runRevalidate<TEnv = any>(fn: ShouldRevalidateFn<any, TEnv> | readonly ShouldRevalidateFn<any, TEnv>[], opts?: RunRevalidateOptions<TEnv>): Promise<boolean>;
74
+ export {};
@@ -11,8 +11,8 @@
11
11
  *
12
12
  * Synchronous: a transition predicate returns a boolean and has no I/O.
13
13
  */
14
+ import { type ImportedAction } from "./internal/action-id.js";
14
15
  import type { RouteLocation, TransitionConfig, TransitionWhenContext, TransitionWhenFn, TransitionWhenKind } from "../types/segments.js";
15
- type ImportedAction = (...args: never[]) => unknown;
16
16
  /** A navigation side: a URL, or a partial RouteLocation. */
17
17
  export type RunTransitionWhenLocation = string | URL | (Partial<Omit<RouteLocation, "url">> & {
18
18
  url?: string | URL;
@@ -35,7 +35,7 @@ export interface RunTransitionWhenOptions {
35
35
  /** The destination. Defaults to `from`; always `from` for "action" and "revalidate". */
36
36
  to?: RunTransitionWhenLocation;
37
37
  /**
38
- * The triggering action (like runClientRevalidate's): an imported server
38
+ * The triggering action (like runRevalidate's): an imported server
39
39
  * action (id via `$id ?? $$id`), an actionId string, or
40
40
  * `{ ref, formData, result, error }`.
41
41
  */
@@ -50,4 +50,3 @@ export interface RunTransitionWhenResult {
50
50
  context: TransitionWhenContext;
51
51
  }
52
52
  export declare function runTransitionWhen(whenOrConfig: TransitionWhenFn | TransitionConfig, opts?: RunTransitionWhenOptions): RunTransitionWhenResult;
53
- export {};
@@ -29,7 +29,8 @@
29
29
  *
30
30
  * A `Prerender` route serves its handler layer from the artifact
31
31
  * `router.matchForPrerender` bakes for the URL (on its first request, kept
32
- * until resetShellTestState), through the production prerender store. Its
32
+ * until resetShellTestState), through the production prerender store; an
33
+ * intercept of it serves from the intercept variant the bake keeps. Its
33
34
  * first `ppr` request is a MISS with a runtime capture, as a URL without a
34
35
  * build-time shell is in production; build-time shells are e2e-only. An
35
36
  * on-demand route (`Prerender(..., { onDemand })`) bakes nothing here: it
@@ -63,10 +64,19 @@ export interface ServeShellRequestOptions<TEnv = any> {
63
64
  * of a document GET: from `from` (default `/`) with `segments` mounted
64
65
  * (default none), advertising fragment passthrough. The replay decision is
65
66
  * `result.replayStatus`.
67
+ *
68
+ * `prefetch: true` sends it as a `<Link>` prefetch does (the
69
+ * `X-Rango-Prefetch` header), so `prefetch: false` loaders and `loading()`
70
+ * entries are deferred: `result.readDeferred()` lists them. `fill: true`
71
+ * sends the request the browser follows an adopted prefetch with
72
+ * (`_rsc_fill`): pass the ids the prefetch delivered, without the deferred
73
+ * ones, as `segments`, and the same URL as `from`.
66
74
  */
67
75
  partial?: true | {
68
76
  from?: string;
69
77
  segments?: readonly string[];
78
+ prefetch?: boolean;
79
+ fill?: boolean;
70
80
  };
71
81
  /**
72
82
  * POST this form as a submit before hydration: the no-JS request the
@@ -76,6 +86,29 @@ export interface ServeShellRequestOptions<TEnv = any> {
76
86
  * Not with `partial`.
77
87
  */
78
88
  form?: FormData;
89
+ /**
90
+ * Send the request a JS server action call makes from the page at `url`:
91
+ * a POST of `args` (encoded as the browser encodes them) for `ref`, with
92
+ * the page's mounted `segments` (default none), as
93
+ * browser/server-action-bridge.ts sends it. The response is the action's
94
+ * Flight payload (its return value and the re-rendered segments).
95
+ * Not with `partial` or `form`.
96
+ */
97
+ action?: ServeShellRequestAction;
98
+ }
99
+ /** The JS server action call of {@link ServeShellRequestOptions.action}. */
100
+ export interface ServeShellRequestAction {
101
+ /** The server action. */
102
+ ref: (...args: any[]) => unknown;
103
+ /**
104
+ * Its reference id, `<module id>#<export name>`, as the build gives a
105
+ * "use server" export; registered so the handler loads `ref` by it.
106
+ */
107
+ id: string;
108
+ /** The arguments the page calls it with. */
109
+ args?: readonly unknown[];
110
+ /** The segment ids the page holds (`_rsc_segments`). */
111
+ segments?: readonly string[];
79
112
  }
80
113
  /** A response's handle data, as the browser consumes it. */
81
114
  export interface ShellRequestHandles {
@@ -133,6 +166,12 @@ export interface ServeShellRequestResult {
133
166
  * values resolved. Undefined when no Flight was rendered.
134
167
  */
135
168
  readHandles(): Promise<ShellRequestHandles | undefined>;
169
+ /**
170
+ * The ids of the segments `flight` marks deferred (a prefetch skipped
171
+ * them; the fill request renders them), in payload order. Empty when
172
+ * nothing was deferred, undefined when no Flight was rendered.
173
+ */
174
+ readDeferred(): Promise<string[] | undefined>;
136
175
  /**
137
176
  * The form state the SSR render received (the `formState` render option),
138
177
  * or undefined when it received none.
@@ -146,6 +146,10 @@ export declare function rangoTestConfig(opts?: RangoTestAliasOptions): RangoTest
146
146
  /** A minimal Vite plugin shape (avoids a hard dependency on Vite's types). */
147
147
  interface FlightTransformPlugin {
148
148
  name: string;
149
+ resolveId: {
150
+ order: "pre";
151
+ handler(source: string, importer: string | undefined): string | undefined;
152
+ };
149
153
  transform(code: string, id: string): Promise<{
150
154
  code: string;
151
155
  map: unknown;
@@ -202,6 +206,13 @@ interface FlightTransformPlugin {
202
206
  * by the module's absolute path (the boundary id), the export name becoming the
203
207
  * boundary name. Modules without the directive (server components) are untouched,
204
208
  * so `renderToFlightString` of pure leaf trees is unaffected.
209
+ *
210
+ * A `"use client"` module whose default export is a `clientUrls()` definition
211
+ * also installs its server projection, as the rango plugin's discovery does for
212
+ * an app: the module imports its own source without this transform and projects
213
+ * it under its client reference. A router that mounts the group
214
+ * (`include("/shop", shopUrls)` or `.routes(shopUrls)`) then serves its routes
215
+ * through `serveShellRequest` and `dispatch` with no setup.
205
216
  */
206
217
  export declare function rangoUseClientTransform(): FlightTransformPlugin;
207
218
  /** The Vite plugin shape {@link rangoUseCacheTransform} returns. */
@@ -13,3 +13,9 @@ export declare function unwrapsSynchronously(stream: Promise<unknown>): boolean;
13
13
  * listing a 0 ms promise on every reader that calls it.
14
14
  */
15
15
  export declare const SETTLED_THENABLE: Promise<undefined>;
16
+ /**
17
+ * The value React reads from `value` without suspending: `value` itself when
18
+ * it is not a promise, a promise's `value` once it carries React's or Flight's
19
+ * `status: "fulfilled"`. Undefined while it is pending or rejected.
20
+ */
21
+ export declare function settledValue<T>(value: T | Promise<T>): T | undefined;
@@ -87,6 +87,15 @@ export type LoaderDataResult<T = unknown> = {
87
87
  };
88
88
  };
89
89
  export declare function isLoaderDataResult(value: unknown): value is LoaderDataResult;
90
+ /**
91
+ * A loading skeleton is renderable only when it is a real ReactNode value;
92
+ * `false` counts as "not renderable". This is the three-term gate. The
93
+ * distinct two-term gate at the LoaderBoundary site (segment-system.tsx)
94
+ * deliberately treats `false` as "create a boundary without a
95
+ * RouteContentWrapper" (tree-structure.md), so it must NOT use this helper.
96
+ * Leaf module: shared by client (segment-system) and server (DSL, resolution).
97
+ */
98
+ export declare function isRenderableLoading(loading: unknown): boolean;
90
99
  export interface NotFoundInfo {
91
100
  message: string;
92
101
  segmentId: string;
@@ -372,6 +372,20 @@ export type InternalHandlerContext<TParams = {}, TEnv = DefaultEnv, TSearch exte
372
372
  * setupLoaderAccess.
373
373
  */
374
374
  _bindLoaderCacheTags?: (loaderId: string, tags: Set<string>) => void;
375
+ /**
376
+ * @internal This match's `prefetch: false` plan: what a prefetch defers,
377
+ * whether the request is a fill, and the loaders that cannot call
378
+ * ctx.rendered(). Set by match-api.ts when the tree declares a flag or the
379
+ * request is a fill. See router/segment-resolution/prefetch-deferral.ts.
380
+ */
381
+ _prefetchDeferral?: import("../router/segment-resolution/prefetch-deferral.js").PrefetchDeferral;
382
+ /**
383
+ * @internal Whether a loader was started in this request: a run of it (a
384
+ * handler's or another loader's ctx.use()) or its cache() binding. A
385
+ * prefetch delivers such a loader instead of deferring it. See
386
+ * setupLoaderAccess.
387
+ */
388
+ _loaderStarted?: (loaderId: string) => boolean;
375
389
  };
376
390
  /**
377
391
  * Generic params type - flexible object with string keys
@@ -175,6 +175,36 @@ export type LoaderFn<T, TParams = Record<string, string | undefined>, TEnv = Def
175
175
  */
176
176
  export type LoaderOptions = {
177
177
  ssr?: boolean;
178
+ /**
179
+ * `prefetch: false` keeps this loader out of prefetches. A `<Link>`
180
+ * prefetch (a partial request with `X-Rango-Prefetch`) does not execute it;
181
+ * the payload marks it deferred. A document request and a navigation with
182
+ * no prefetch to adopt run it as usual.
183
+ *
184
+ * A deferred loader never blocks the navigation that adopts the prefetch:
185
+ * it behaves like a loader that is still streaming. Its own `<Suspense>`
186
+ * shows at once; if the nearest boundary is the route's `loading()`, that
187
+ * shows; with no boundary React holds the page until the fill returns. The
188
+ * fill is the one follow-up request that runs the loader.
189
+ *
190
+ * The fill reads through the loader's own `cache()` and any `"use cache"`
191
+ * function it calls. A prefetch reads neither, by intent: looking would
192
+ * mean running the loader on a miss.
193
+ *
194
+ * The flag applies only to a segment the client does not have yet. A
195
+ * loader the client already holds (the same route with new params, say)
196
+ * runs in the prefetch when it revalidates, exactly as without the flag:
197
+ * a click that adopts a prefetch is never worse than the same click with
198
+ * no prefetch at all.
199
+ *
200
+ * Limits: a handler that awaits the loader with `ctx.use()` makes it run in
201
+ * the prefetch anyway; the loader cannot call `ctx.rendered()` (it throws
202
+ * on every request); on a `ppr` route the flag is ignored for an
203
+ * `ssr: false` loader (the bake lane), with a dev warning. In the fill
204
+ * request only deferred work and middleware run, so values a held handler
205
+ * would have set with `ctx.set()` are not visible.
206
+ */
207
+ prefetch?: boolean;
178
208
  };
179
209
  /**
180
210
  * Options for fetchable loaders
@@ -48,6 +48,13 @@ export interface RequestScope<TEnv = DefaultEnv> {
48
48
  * cache keying.
49
49
  */
50
50
  originalUrl: URL;
51
+ /**
52
+ * The visitor's URL (the address bar, search included) when middleware
53
+ * rewrote this request with `throw rewrite()`; `undefined` otherwise. `url`,
54
+ * `pathname` and `searchParams` are the rewrite target's. After several
55
+ * rewrites this is still the first URL. Each context gets its own copy.
56
+ */
57
+ rewrittenFrom?: URL;
51
58
  /** URL pathname (same as `url.pathname`). */
52
59
  pathname: string;
53
60
  /**