@rangojs/router 0.36.0 → 0.37.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.
- package/dist/bin/{chunk-THW7E5A2.js → chunk-A64EG6MI.js} +22 -19
- package/dist/bin/{client-urls-projection-DHUUOJZM.js → client-urls-projection-RLDSA3BL.js} +1 -1
- package/dist/bin/rango.js +1 -1
- package/dist/bin/{runtime-discovery-UECTPF6K.js → runtime-discovery-T7ZLA6E3.js} +2 -2
- package/dist/bin/{temp-rsc-server-QLNMTFEE.js → temp-rsc-server-FGGXPKVQ.js} +2 -2
- package/dist/types/browser/event-controller.d.ts +61 -0
- package/dist/types/browser/fetched-loader-handles.d.ts +76 -0
- package/dist/types/browser/navigation-store.d.ts +3 -2
- package/dist/types/browser/react/use-handle.d.ts +18 -5
- package/dist/types/browser/react/use-push-handle.d.ts +44 -0
- package/dist/types/browser/types.d.ts +44 -0
- package/dist/types/client.d.ts +1 -0
- package/dist/types/client.rsc.d.ts +1 -0
- package/dist/types/handle.d.ts +13 -5
- package/dist/types/handles/client-pushes.d.ts +51 -0
- package/dist/types/handles/deferred-resolution.d.ts +14 -0
- package/dist/types/handles/pushed-by.d.ts +36 -0
- package/dist/types/loader-store.d.ts +13 -0
- package/dist/types/rsc/prefetch-render-error.d.ts +2 -1
- package/dist/types/server/handle-store.d.ts +8 -0
- package/dist/types/testing/dom.entry.d.ts +1 -1
- package/dist/types/testing/flight.entry.d.ts +1 -1
- package/dist/types/testing/render-route.d.ts +76 -14
- package/dist/types/testing/serve-shell-request.d.ts +31 -0
- package/dist/vite/index.js +23 -20
- package/package.json +1 -1
- package/skills/breadcrumbs/SKILL.md +68 -6
- package/skills/caching/SKILL.md +4 -2
- package/skills/catalog.json +3 -3
- package/skills/client-urls/SKILL.md +13 -1
- package/skills/document-cache/SKILL.md +31 -1
- package/skills/hooks/SKILL.md +8 -4
- package/skills/hooks/data.md +10 -1
- package/skills/hooks/handle-and-actions.md +402 -26
- package/skills/hooks/navigation.md +4 -0
- package/skills/hooks/urls.md +3 -0
- package/skills/links/SKILL.md +5 -3
- package/skills/loader/SKILL.md +40 -1
- package/skills/migrate-nextjs/SKILL.md +5 -0
- package/skills/migrate-react-router/component-migration.md +4 -1
- package/skills/parallel/SKILL.md +8 -0
- package/skills/ppr/SKILL.md +1 -0
- package/skills/rango/SKILL.md +6 -3
- package/skills/testing/client-components.md +35 -32
- package/skills/testing/handles.md +58 -6
- package/skills/testing/serve-shell-request.md +33 -14
- package/skills/ux-architecture/SKILL.md +4 -0
- package/src/browser/event-controller.ts +311 -2
- package/src/browser/fetched-loader-handles.ts +269 -0
- package/src/browser/navigation-store.ts +261 -2
- package/src/browser/partial-update.ts +3 -2
- package/src/browser/react/use-handle.ts +74 -27
- package/src/browser/react/use-push-handle.ts +113 -0
- package/src/browser/rsc-router.tsx +11 -14
- package/src/browser/types.ts +48 -0
- package/src/cache/document-cache-policy.ts +6 -5
- package/src/client.rsc.tsx +1 -0
- package/src/client.tsx +31 -1
- package/src/handle.ts +13 -5
- package/src/handles/client-pushes.ts +120 -0
- package/src/handles/deferred-resolution.ts +41 -2
- package/src/handles/pushed-by.ts +130 -1
- package/src/loader-store.ts +26 -0
- package/src/rsc/loader-fetch.ts +64 -5
- package/src/rsc/prefetch-render-error.ts +2 -1
- package/src/rsc/request-stages.ts +7 -6
- package/src/rsc/rsc-rendering.ts +32 -14
- package/src/server/handle-store.ts +23 -0
- package/src/ssr/ssr-root.tsx +6 -0
- package/src/testing/dom.entry.ts +2 -0
- package/src/testing/flight.entry.ts +1 -0
- package/src/testing/render-route.tsx +319 -72
- package/src/testing/serve-shell-request.ts +62 -1
- package/src/use-loader.tsx +44 -4
|
@@ -13,6 +13,31 @@ export declare function withoutPushedBy(data: HandleData): HandleData;
|
|
|
13
13
|
* (navigation-store.ts) shares them.
|
|
14
14
|
*/
|
|
15
15
|
export declare function withSegmentHandles(target: HandleData, source: HandleData, ids: ReadonlySet<string>): HandleData;
|
|
16
|
+
/**
|
|
17
|
+
* What a fetched loader read pushed, settled: the values by handle $$id, and
|
|
18
|
+
* the loader whose run pushed each (index-aligned; null, or no entry for the
|
|
19
|
+
* handle, for the read loader's own body).
|
|
20
|
+
*/
|
|
21
|
+
export interface LoaderReadPushes {
|
|
22
|
+
values: Record<string, unknown[]>;
|
|
23
|
+
pushedBy: Record<string, (string | null)[]>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The handle data after a fetched read of loader `loaderId` (the `_rsc_loader`
|
|
27
|
+
* lane: `load()`, a `refreshGroup` refresh) pushed `pushes`. The read renders
|
|
28
|
+
* no segment, so its pushes go where the page's run of the loader put its
|
|
29
|
+
* own: the first segment of `segmentOrder` holding a value the loader pushed,
|
|
30
|
+
* else the first segment of `matched` (the raw list `current` was built from)
|
|
31
|
+
* that registers it, where a render files them (loader-resolution.ts
|
|
32
|
+
* loaderOwner). The loader's earlier values give way to these in their
|
|
33
|
+
* position, in every segment that registers it, and every other run keeps its
|
|
34
|
+
* own (mergePartialHandleData, with the loader as the run that ran). A value
|
|
35
|
+
* pushed by another loader the page registers, one the body read with
|
|
36
|
+
* ctx.use, belongs to that loader's run, which the read did not refresh: the
|
|
37
|
+
* page keeps that run's values, as it keeps its data. Undefined when no
|
|
38
|
+
* segment registers the loader: its pushes have no segment to belong to.
|
|
39
|
+
*/
|
|
40
|
+
export declare function mergeLoaderReadHandleData(current: HandleData, segmentOrder: readonly string[], matched: readonly string[], loaderId: string, pushes: LoaderReadPushes): HandleData | undefined;
|
|
16
41
|
/**
|
|
17
42
|
* The handle data after a partial response's snapshot `incoming` (each stream
|
|
18
43
|
* yield holds everything the response pushed so far). A segment outside
|
|
@@ -36,3 +61,14 @@ export declare function withSegmentHandles(target: HandleData, source: HandleDat
|
|
|
36
61
|
* the route it leaves.
|
|
37
62
|
*/
|
|
38
63
|
export declare function mergePartialHandleData(current: HandleData, incoming: HandleData, segmentOrder: readonly string[], matched: readonly string[], resolvedIds: readonly string[] | undefined): HandleData;
|
|
64
|
+
/**
|
|
65
|
+
* The handle data after a late handle yield of the document (`late`: the
|
|
66
|
+
* document render's full state so far, `matched` its segment ids) lands on
|
|
67
|
+
* `current`, the page's data. Swapped in whole, except the runs of the
|
|
68
|
+
* loaders in `refreshed`: a fetched read landed for each since the document
|
|
69
|
+
* rendered (NavigationStore.getPageReadLoaders), so the page's values of that
|
|
70
|
+
* run are newer than the yield's and stay. The yield's values of those runs
|
|
71
|
+
* are dropped and the rest goes in as a partial response in which every
|
|
72
|
+
* other run ran (mergePartialHandleData). `late` itself when no read landed.
|
|
73
|
+
*/
|
|
74
|
+
export declare function mergeLateHandleData(current: HandleData, late: HandleData, matched: readonly string[], refreshed: ReadonlySet<string>): HandleData;
|
|
@@ -200,6 +200,19 @@ export declare class LoaderStore {
|
|
|
200
200
|
* intentional: a successful refetch should hide the previous failure.
|
|
201
201
|
*/
|
|
202
202
|
finishData<T>(bucketKey: string, requestId: number, value: T): void;
|
|
203
|
+
/**
|
|
204
|
+
* True while a reader with route context subscribes to the bucket: a value
|
|
205
|
+
* committed to it shows on the page (browser/fetched-loader-handles.ts
|
|
206
|
+
* treats a read into it as the page's own).
|
|
207
|
+
*/
|
|
208
|
+
hasRouteReaders(bucketKey: string): boolean;
|
|
209
|
+
/**
|
|
210
|
+
* True while `requestId`'s result is what the bucket holds: finishData
|
|
211
|
+
* committed it and no newer request or clear() (a route-data change) has
|
|
212
|
+
* moved the bucket on since. A fetched read's handle values and history
|
|
213
|
+
* write land exactly when this holds (browser/fetched-loader-handles.ts).
|
|
214
|
+
*/
|
|
215
|
+
holdsRequest(bucketKey: string, requestId: number): boolean;
|
|
203
216
|
/**
|
|
204
217
|
* Commit an error. Preserves the last good `value` so consumers can keep
|
|
205
218
|
* showing previous data while displaying the error if they choose. No-op
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
* a prefetch with nothing live in it carries `private, max-age`
|
|
18
18
|
* (request-stages.ts applyStoredPrefetchCacheControl); a prefetch
|
|
19
19
|
* scoped to its source page or carrying deferred units is sent
|
|
20
|
-
* `private, no-cache` (rsc-rendering.ts NOT_REUSED)
|
|
20
|
+
* `private, no-cache` (rsc-rendering.ts NOT_REUSED), or the route's own
|
|
21
|
+
* `no-store`.
|
|
21
22
|
*
|
|
22
23
|
* The errors are the render's `_renderErrors`: a Flight error row, a streamed
|
|
23
24
|
* handler recovered into its boundary, a loader that threw (redirect() and
|
|
@@ -187,6 +187,14 @@ export interface HandleStore {
|
|
|
187
187
|
* follow the record's values.
|
|
188
188
|
*/
|
|
189
189
|
releaseRecordedValues(segmentId: string): void;
|
|
190
|
+
/**
|
|
191
|
+
* Stop recording pushes into `segmentId`: a later push() into it, a
|
|
192
|
+
* replayed copy included, records nothing and calls `onLate` with the
|
|
193
|
+
* handle's name. The fetchable-loader lane (rsc/loader-fetch.ts) closes
|
|
194
|
+
* its loader's segment once the reply holds the body's pushes, so a push
|
|
195
|
+
* the body makes after it returned is reported instead of lost unseen.
|
|
196
|
+
*/
|
|
197
|
+
closeSegment(segmentId: string, onLate: (handleName: string) => void): void;
|
|
190
198
|
/**
|
|
191
199
|
* Get all collected handle data after all handlers have settled.
|
|
192
200
|
* Waits for `settled` (handler lane), then returns the data at that point.
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
* (`happy-dom` or `jsdom`).
|
|
13
13
|
*/
|
|
14
14
|
export { renderRoute } from "./render-route.js";
|
|
15
|
-
export type { RenderRouteSpec, RenderRouteOptions, TestRouterHandle, RenderRouteResult, RenderRouteHydrateResult, HandleDataSeed, } from "./render-route.js";
|
|
15
|
+
export type { RenderRouteSpec, RenderRouteOptions, TestRouterHandle, RenderRouteResult, RenderRouteHydrateResult, HandleDataSeed, HandleSeed, HandleSegment, } from "./render-route.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 { ServeShellRequestAction, ServeShellRequestOptions, ServeShellRequestResult, ShellRequestAction, ShellRequestHandles, } from "./serve-shell-request.js";
|
|
36
|
+
export type { ServeShellRequestAction, ServeShellRequestOptions, ServeShellRequestResult, ShellRequestAction, ShellRequestHandles, ShellRequestLoader, } from "./serve-shell-request.js";
|
|
@@ -53,6 +53,8 @@
|
|
|
53
53
|
* rejection is the loader's error. Needs the testing kit's
|
|
54
54
|
* `@vitejs/plugin-rsc/browser` alias (rangoTestAliases). A load() with params
|
|
55
55
|
* is answered with a loaderError; a body and non-GET loads are not answered.
|
|
56
|
+
* The answer carries no handle values: what a loader pushes on a read is
|
|
57
|
+
* serveShellRequest's readLoader() and e2e territory.
|
|
56
58
|
* - A spec's transition({ when }) decides every commit with production's
|
|
57
59
|
* browser decision: navigate() and useRouter().push model kind "push",
|
|
58
60
|
* useRouter().replace kind "replace", refresh() kind "revalidate", and a
|
|
@@ -96,6 +98,17 @@ import type { PrefetchStrategy } from "../router/prefetch-default.js";
|
|
|
96
98
|
* an array of values pushed for that handle).
|
|
97
99
|
*/
|
|
98
100
|
export type HandleDataSeed = Record<string, Record<string, unknown[]>>;
|
|
101
|
+
/**
|
|
102
|
+
* Where a handle seed lands: the index of a spec in `routes` (its layout or
|
|
103
|
+
* route segment), or `[index, "@slot"]` for a slot that spec declares
|
|
104
|
+
* (`RenderRouteSpec.slots`). Omitted: the leaf route.
|
|
105
|
+
*/
|
|
106
|
+
export type HandleSegment = number | readonly [number, `@${string}`];
|
|
107
|
+
/**
|
|
108
|
+
* `[handle, values, segment?]`: the values the server pushed for `handle` in
|
|
109
|
+
* one segment (the leaf route when `segment` is omitted).
|
|
110
|
+
*/
|
|
111
|
+
export type HandleSeed = readonly [Handle<any, any>, unknown[], HandleSegment?];
|
|
99
112
|
export interface RenderRouteSpec {
|
|
100
113
|
/**
|
|
101
114
|
* The route pattern this node matches, e.g. "/products/:productId". The LAST
|
|
@@ -129,6 +142,18 @@ export interface RenderRouteSpec {
|
|
|
129
142
|
* `router.navigate(url, { loaders })` pins `useLoader().isLoading`.
|
|
130
143
|
*/
|
|
131
144
|
transition?: TransitionConfig;
|
|
145
|
+
/**
|
|
146
|
+
* Parallel slots this node declares (`parallel({ "@side": Side })`), each
|
|
147
|
+
* rendered where the node's component places `<ParallelOutlet name>`. A
|
|
148
|
+
* slot given as `{ Component, intercept: true }` is an intercept's: it
|
|
149
|
+
* renders through the same slot outlet, as an intercepting navigation's
|
|
150
|
+
* does. Each is a segment of its own (`L0.@side`), so a handle seed or a
|
|
151
|
+
* client push can land in it.
|
|
152
|
+
*/
|
|
153
|
+
slots?: Readonly<Record<`@${string}`, ComponentType | {
|
|
154
|
+
Component: ComponentType;
|
|
155
|
+
intercept: true;
|
|
156
|
+
}>>;
|
|
132
157
|
}
|
|
133
158
|
/**
|
|
134
159
|
* Options for renderRoute.
|
|
@@ -223,14 +248,15 @@ export interface RenderRouteOptions {
|
|
|
223
248
|
/**
|
|
224
249
|
* Handles to seed by REFERENCE, for components that read handle output via
|
|
225
250
|
* `useHandle(SomeHandle)` (e.g. a client `Breadcrumbs` trail). Each entry is
|
|
226
|
-
* `[handle, pushedValues[]]` — the values a
|
|
227
|
-
*
|
|
251
|
+
* `[handle, pushedValues[], segment?]` — the values a segment's handlers would
|
|
252
|
+
* have pushed, attached to the segment `segment` names (a spec's index in
|
|
253
|
+
* `routes`, or `[index, "@slot"]`), the leaf route when omitted.
|
|
228
254
|
* Built-in handles (Breadcrumbs/Meta) have stable ids and work directly.
|
|
229
255
|
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
256
|
+
* A handle's values are collected over every segment, in segment order — so
|
|
257
|
+
* ANY component in the chain reads the seeded values, a LAYOUT (e.g. a
|
|
258
|
+
* DetailLayout/ActionToolbar reading a handle) just as much as the leaf
|
|
259
|
+
* route. Most handle usage is server-side (`ctx.use(...)`) and is
|
|
234
260
|
* better covered by `renderToFlightString`/e2e; this seeds the client read path
|
|
235
261
|
* only.
|
|
236
262
|
*
|
|
@@ -239,7 +265,7 @@ export interface RenderRouteOptions {
|
|
|
239
265
|
* handles: [[Breadcrumbs, [{ label: "Home", href: "/" }, { label: "P", href: "/p" }]]],
|
|
240
266
|
* });
|
|
241
267
|
*/
|
|
242
|
-
handles?: ReadonlyArray<
|
|
268
|
+
handles?: ReadonlyArray<HandleSeed>;
|
|
243
269
|
/**
|
|
244
270
|
* Advanced: raw handle data in wire format
|
|
245
271
|
* `{ [handleId]: { [segmentId]: pushedValues[] } }`. Prefer `handles` (which
|
|
@@ -263,7 +289,7 @@ export interface RenderRouteOptions {
|
|
|
263
289
|
* lateHandles: [[Notes, ["from-handler", "from-loader"]]],
|
|
264
290
|
* });
|
|
265
291
|
*/
|
|
266
|
-
lateHandles?: ReadonlyArray<
|
|
292
|
+
lateHandles?: ReadonlyArray<HandleSeed>;
|
|
267
293
|
/**
|
|
268
294
|
* Route name -> pattern map. Informational for parity with the server test
|
|
269
295
|
* context; client useReverse takes its map directly as an argument, so this
|
|
@@ -398,8 +424,7 @@ export interface TestRouterHandle {
|
|
|
398
424
|
* `navigate(url, { replace: false })` are the same call.
|
|
399
425
|
*
|
|
400
426
|
* `options.handles` are the destination's handle pushes (`[handle,
|
|
401
|
-
* values]`,
|
|
402
|
-
* `handles`). They arrive on the response's handle stream, so `useHandle`
|
|
427
|
+
* values, segment?]`, as in `renderRoute`'s own `handles`). They arrive on the response's handle stream, so `useHandle`
|
|
403
428
|
* readers take them with the page's commit: while React holds the page,
|
|
404
429
|
* readers keep the values of the page being left.
|
|
405
430
|
*
|
|
@@ -437,9 +462,10 @@ export interface TestRouterHandle {
|
|
|
437
462
|
* Re-render the current location, as router.refresh() does: a spec's
|
|
438
463
|
* transition({ when }) decides it with kind "revalidate" (`to` is `from`).
|
|
439
464
|
* `options.loaders` is the loader data the response carries, merged over
|
|
440
|
-
* the render-time seeds as in navigate().
|
|
465
|
+
* the render-time seeds as in navigate(). `options.handles` are the handle
|
|
466
|
+
* values the response carries, on its handle stream, as in navigate().
|
|
441
467
|
*/
|
|
442
|
-
refresh(options?: Pick<RenderRouteOptions, "loaders">): Promise<void>;
|
|
468
|
+
refresh(options?: Pick<RenderRouteOptions, "loaders" | "handles">): Promise<void>;
|
|
443
469
|
/**
|
|
444
470
|
* Prefetch `url`, as a `<Link>` hover or viewport trigger does: the page is
|
|
445
471
|
* kept with the loader data its response would carry now (the render-time
|
|
@@ -476,20 +502,56 @@ export interface TestRouterHandle {
|
|
|
476
502
|
* fresh. The action's own lifecycle (`useAction()`), its follow-up and its
|
|
477
503
|
* redirect are e2e territory.
|
|
478
504
|
*/
|
|
479
|
-
action(options?: Pick<RenderRouteOptions, "loaders"> & {
|
|
505
|
+
action(options?: Pick<RenderRouteOptions, "loaders" | "handles"> & {
|
|
480
506
|
keepClientCache?: boolean;
|
|
481
507
|
}): Promise<void>;
|
|
508
|
+
/**
|
|
509
|
+
* A server push that arrives after the page committed (a settled
|
|
510
|
+
* `push(promise)` or `.defer()`, a streamed loader's push, a `ppr`
|
|
511
|
+
* live-lane push): each `[handle, values, segment?]` replaces that handle's
|
|
512
|
+
* server values in that segment, through production's late handle channel
|
|
513
|
+
* (`applyLateHandles`: the controller's late write, then the page's history
|
|
514
|
+
* entry). The other segments' server values stay. `pushedBy`: the loader
|
|
515
|
+
* whose run pushed the values (a streamed loader body's push, tagged as the
|
|
516
|
+
* server tags it), so a seed replaces only that run's values in the
|
|
517
|
+
* segment; omitted, the segment's handler pushed them. A loader whose data
|
|
518
|
+
* a `load()` refreshed since keeps the page's values: the read is newer.
|
|
519
|
+
*
|
|
520
|
+
* @example
|
|
521
|
+
* await router.pushLateHandles([[Meta, [{ title: "Late" }], 0]]);
|
|
522
|
+
* await router.pushLateHandles([[Meta, [{ title: "Item" }]]], {
|
|
523
|
+
* pushedBy: ItemLoader,
|
|
524
|
+
* });
|
|
525
|
+
*/
|
|
526
|
+
pushLateHandles(handles: ReadonlyArray<HandleSeed>, options?: {
|
|
527
|
+
pushedBy?: LoaderDefinition<any>;
|
|
528
|
+
}): Promise<void>;
|
|
529
|
+
/**
|
|
530
|
+
* What `useHandle(handle)` collects over, per segment id: the server's
|
|
531
|
+
* values followed by the client's pushes (`usePushHandle`), as readers
|
|
532
|
+
* merge them. Only segments with values are listed.
|
|
533
|
+
*/
|
|
534
|
+
handleData(handle: Handle<any, any>): Record<string, unknown[]>;
|
|
535
|
+
/** The segment id a `HandleSegment` names on the page on screen. */
|
|
536
|
+
segmentId(segment?: HandleSegment): string;
|
|
482
537
|
/**
|
|
483
538
|
* Set what the loader endpoint answers from now on: a later
|
|
484
539
|
* `useLoader().load()` or refreshGroup refresh of each loader resolves to
|
|
485
540
|
* its value (a pending Promise holds the answer, a rejection is the
|
|
486
541
|
* loader's error). Renders nothing; the page on screen keeps its data.
|
|
487
542
|
*
|
|
543
|
+
* `handles`: what the body of each loader in `loaders` pushes on such a
|
|
544
|
+
* read (`[handle, values]`). The reply carries them as rsc/loader-fetch.ts
|
|
545
|
+
* does, and the browser applies them to the loader's segment as it does a
|
|
546
|
+
* real read's (browser/fetched-loader-handles.ts).
|
|
547
|
+
*
|
|
488
548
|
* @example
|
|
489
549
|
* router.respondToLoads({ loaders: [[CartLoader, { count: 3 }]] });
|
|
490
550
|
* fireEvent.click(getByText("Refresh")); // load(): count 3
|
|
491
551
|
*/
|
|
492
|
-
respondToLoads(options: Pick<RenderRouteOptions, "loaders">
|
|
552
|
+
respondToLoads(options: Pick<RenderRouteOptions, "loaders"> & {
|
|
553
|
+
handles?: ReadonlyArray<readonly [Handle<any, any>, unknown[]]>;
|
|
554
|
+
}): void;
|
|
493
555
|
/**
|
|
494
556
|
* The background revalidations a click on a stale prefetch started, in
|
|
495
557
|
* order: the page's pathname and search, and the segment ids the request
|
|
@@ -169,6 +169,30 @@ export interface ShellRequestAction {
|
|
|
169
169
|
*/
|
|
170
170
|
revalidationError: Error | null;
|
|
171
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* A fetchable loader read's answer (`?_rsc_loader=<id>`), as `load()` and a
|
|
174
|
+
* `refreshGroup` refresh read it (use-loader.tsx).
|
|
175
|
+
*/
|
|
176
|
+
export interface ShellRequestLoader {
|
|
177
|
+
/** What the read resolves with; null when it rejects. */
|
|
178
|
+
result: unknown;
|
|
179
|
+
/** The message the read rejects with, or null. */
|
|
180
|
+
error: string | null;
|
|
181
|
+
/**
|
|
182
|
+
* The values the loader's body pushed to each handle, by handle $$id, in
|
|
183
|
+
* push order, a pending one settled (dropped when it rejects or resolves
|
|
184
|
+
* nullish, as the browser drops it). The browser applies them to the
|
|
185
|
+
* segment that registers the loader, in place of its earlier ones.
|
|
186
|
+
*/
|
|
187
|
+
handles: Record<string, unknown[]>;
|
|
188
|
+
/**
|
|
189
|
+
* Which loader's run pushed each of `handles`, index-aligned per handle:
|
|
190
|
+
* another loader the body read with `ctx.use()`, or null for the body's
|
|
191
|
+
* own. A handle with no entry holds only the body's own. The browser leaves
|
|
192
|
+
* a value another loader on the page pushed to that loader's own run.
|
|
193
|
+
*/
|
|
194
|
+
pushedBy: Record<string, (string | null)[]>;
|
|
195
|
+
}
|
|
172
196
|
/** Result of {@link serveShellRequest}. */
|
|
173
197
|
export interface ServeShellRequestResult {
|
|
174
198
|
/** The handler's Response. Its body is already read: see `body`. */
|
|
@@ -248,6 +272,13 @@ export interface ServeShellRequestResult {
|
|
|
248
272
|
* result.
|
|
249
273
|
*/
|
|
250
274
|
readAction(): Promise<ShellRequestAction | undefined>;
|
|
275
|
+
/**
|
|
276
|
+
* For a fetchable loader read (`?_rsc_loader=<id>` with an `accept:
|
|
277
|
+
* text/x-component` header), its answer as the browser reads it: the
|
|
278
|
+
* loader's value or error, and the handle values its body pushed.
|
|
279
|
+
* Undefined when no Flight was rendered or the payload is not a loader's.
|
|
280
|
+
*/
|
|
281
|
+
readLoader(): Promise<ShellRequestLoader | undefined>;
|
|
251
282
|
}
|
|
252
283
|
/**
|
|
253
284
|
* Reset the per-isolate PPR state requests leave behind, so the next test
|
package/dist/vite/index.js
CHANGED
|
@@ -4668,13 +4668,13 @@ import {
|
|
|
4668
4668
|
Component as Component3,
|
|
4669
4669
|
createElement as createElement4,
|
|
4670
4670
|
isValidElement as isValidElement2,
|
|
4671
|
-
useContext as
|
|
4671
|
+
useContext as useContext19,
|
|
4672
4672
|
useMemo as useMemo9,
|
|
4673
4673
|
Suspense as Suspense2
|
|
4674
4674
|
} from "react";
|
|
4675
4675
|
|
|
4676
4676
|
// src/browser/react/use-handle.ts
|
|
4677
|
-
import { useContext as useContext2,
|
|
4677
|
+
import { useContext as useContext2, useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
4678
4678
|
|
|
4679
4679
|
// src/missing-id-error.ts
|
|
4680
4680
|
var SELF_FILES = /* @__PURE__ */ new Set([
|
|
@@ -4959,7 +4959,7 @@ var Script = createHandle(collectScripts, "__rsc_router_script__");
|
|
|
4959
4959
|
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
4960
4960
|
|
|
4961
4961
|
// src/browser/react/ScrollRestoration.tsx
|
|
4962
|
-
import { useEffect as
|
|
4962
|
+
import { useEffect as useEffect2 } from "react";
|
|
4963
4963
|
|
|
4964
4964
|
// src/browser/scroll-restoration.ts
|
|
4965
4965
|
init_logging();
|
|
@@ -4978,7 +4978,7 @@ import {
|
|
|
4978
4978
|
} from "react";
|
|
4979
4979
|
|
|
4980
4980
|
// src/suspense-audit-react.tsx
|
|
4981
|
-
import { useEffect as
|
|
4981
|
+
import { useEffect as useEffect3, useLayoutEffect as useLayoutEffect3, useRef as useRef3 } from "react";
|
|
4982
4982
|
|
|
4983
4983
|
// src/suspense-audit.ts
|
|
4984
4984
|
init_internal_debug();
|
|
@@ -4993,7 +4993,7 @@ import { jsx as jsx3 } from "react/jsx-runtime";
|
|
|
4993
4993
|
import { createElement as createElement2 } from "react";
|
|
4994
4994
|
|
|
4995
4995
|
// src/loader-redirect.tsx
|
|
4996
|
-
import { useEffect as
|
|
4996
|
+
import { useEffect as useEffect4 } from "react";
|
|
4997
4997
|
|
|
4998
4998
|
// src/browser/react/use-router.ts
|
|
4999
4999
|
import { useContext as useContext7, useMemo as useMemo2 } from "react";
|
|
@@ -5198,7 +5198,7 @@ import {
|
|
|
5198
5198
|
use as use3,
|
|
5199
5199
|
useCallback,
|
|
5200
5200
|
useContext as useContext8,
|
|
5201
|
-
useEffect as
|
|
5201
|
+
useEffect as useEffect5,
|
|
5202
5202
|
useMemo as useMemo4,
|
|
5203
5203
|
useOptimistic,
|
|
5204
5204
|
useRef as useRef4,
|
|
@@ -5370,7 +5370,7 @@ function insertSegments(node, segments, index, leafBase, paramNames) {
|
|
|
5370
5370
|
init_prefetch_markers();
|
|
5371
5371
|
|
|
5372
5372
|
// src/browser/react/use-navigation.ts
|
|
5373
|
-
import { useContext as useContext9, useEffect as
|
|
5373
|
+
import { useContext as useContext9, useEffect as useEffect6, useRef as useRef5 } from "react";
|
|
5374
5374
|
|
|
5375
5375
|
// src/browser/react/use-pathname.ts
|
|
5376
5376
|
import { useContext as useContext10 } from "react";
|
|
@@ -5386,7 +5386,7 @@ import { useCallback as useCallback2, useContext as useContext11, useMemo as use
|
|
|
5386
5386
|
import { useContext as useContext12 } from "react";
|
|
5387
5387
|
|
|
5388
5388
|
// src/browser/react/use-action.ts
|
|
5389
|
-
import { useContext as useContext13, useState as useState5, useEffect as
|
|
5389
|
+
import { useContext as useContext13, useState as useState5, useEffect as useEffect7, useRef as useRef6 } from "react";
|
|
5390
5390
|
|
|
5391
5391
|
// src/browser/event-controller.ts
|
|
5392
5392
|
init_notify_listeners();
|
|
@@ -5449,13 +5449,13 @@ function subscribeToLocationChange(eventController, listener) {
|
|
|
5449
5449
|
}
|
|
5450
5450
|
|
|
5451
5451
|
// src/browser/react/use-segments.ts
|
|
5452
|
-
import { useContext as useContext14, useEffect as
|
|
5452
|
+
import { useContext as useContext14, useEffect as useEffect8, useRef as useRef7 } from "react";
|
|
5453
5453
|
|
|
5454
5454
|
// src/browser/react/NavigationProvider.tsx
|
|
5455
5455
|
import {
|
|
5456
5456
|
useState as useState8,
|
|
5457
|
-
useEffect as
|
|
5458
|
-
useLayoutEffect as
|
|
5457
|
+
useEffect as useEffect10,
|
|
5458
|
+
useLayoutEffect as useLayoutEffect5,
|
|
5459
5459
|
useCallback as useCallback4,
|
|
5460
5460
|
useMemo as useMemo7,
|
|
5461
5461
|
useRef as useRef9,
|
|
@@ -5470,8 +5470,8 @@ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
|
5470
5470
|
// src/theme/ThemeProvider.tsx
|
|
5471
5471
|
import {
|
|
5472
5472
|
useCallback as useCallback3,
|
|
5473
|
-
useEffect as
|
|
5474
|
-
useLayoutEffect as
|
|
5473
|
+
useEffect as useEffect9,
|
|
5474
|
+
useLayoutEffect as useLayoutEffect4,
|
|
5475
5475
|
useMemo as useMemo6,
|
|
5476
5476
|
useState as useState7
|
|
5477
5477
|
} from "react";
|
|
@@ -5509,7 +5509,7 @@ import {
|
|
|
5509
5509
|
forwardRef,
|
|
5510
5510
|
useCallback as useCallback5,
|
|
5511
5511
|
useContext as useContext16,
|
|
5512
|
-
useEffect as
|
|
5512
|
+
useEffect as useEffect12,
|
|
5513
5513
|
useId,
|
|
5514
5514
|
useMemo as useMemo8,
|
|
5515
5515
|
useRef as useRef10
|
|
@@ -5520,7 +5520,7 @@ import {
|
|
|
5520
5520
|
createContext as createContext7,
|
|
5521
5521
|
useContext as useContext15,
|
|
5522
5522
|
useState as useState9,
|
|
5523
|
-
useEffect as
|
|
5523
|
+
useEffect as useEffect11
|
|
5524
5524
|
} from "react";
|
|
5525
5525
|
var LinkContext = createContext7(null);
|
|
5526
5526
|
|
|
@@ -5802,7 +5802,7 @@ var Link = forwardRef(function Link2({
|
|
|
5802
5802
|
);
|
|
5803
5803
|
}
|
|
5804
5804
|
}, [configuredStrategy, resolvedTo, isExternal, ctx, prefetchKey]);
|
|
5805
|
-
|
|
5805
|
+
useEffect12(() => {
|
|
5806
5806
|
if (isExternal || !ctx?.store) return;
|
|
5807
5807
|
if (configuredStrategy !== "viewport" && configuredStrategy !== "render" && configuredStrategy !== "adaptive") {
|
|
5808
5808
|
return;
|
|
@@ -5894,6 +5894,9 @@ var Link = forwardRef(function Link2({
|
|
|
5894
5894
|
);
|
|
5895
5895
|
});
|
|
5896
5896
|
|
|
5897
|
+
// src/browser/react/use-push-handle.ts
|
|
5898
|
+
import { useContext as useContext17, useLayoutEffect as useLayoutEffect6, useState as useState10 } from "react";
|
|
5899
|
+
|
|
5897
5900
|
// src/handles/breadcrumbs.ts
|
|
5898
5901
|
function collectBreadcrumbs(segments) {
|
|
5899
5902
|
const all = segments.flat();
|
|
@@ -5922,7 +5925,7 @@ var Breadcrumbs = createHandle(
|
|
|
5922
5925
|
);
|
|
5923
5926
|
|
|
5924
5927
|
// src/browser/react/location-state.ts
|
|
5925
|
-
import { useContext as
|
|
5928
|
+
import { useContext as useContext18, useEffect as useEffect13 } from "react";
|
|
5926
5929
|
|
|
5927
5930
|
// src/browser/react/use-href.tsx
|
|
5928
5931
|
import { useCallback as useCallback6 } from "react";
|
|
@@ -6145,9 +6148,9 @@ import {
|
|
|
6145
6148
|
Fragment as Fragment4,
|
|
6146
6149
|
Suspense as Suspense3,
|
|
6147
6150
|
useDeferredValue,
|
|
6148
|
-
useLayoutEffect as
|
|
6151
|
+
useLayoutEffect as useLayoutEffect7,
|
|
6149
6152
|
useMemo as useMemo10,
|
|
6150
|
-
useState as
|
|
6153
|
+
useState as useState11
|
|
6151
6154
|
} from "react";
|
|
6152
6155
|
|
|
6153
6156
|
// src/client-urls/navigation.ts
|
|
@@ -7350,7 +7353,7 @@ function resolveVersionsFrom(table, routerId2) {
|
|
|
7350
7353
|
// package.json
|
|
7351
7354
|
var package_default = {
|
|
7352
7355
|
name: "@rangojs/router",
|
|
7353
|
-
version: "0.
|
|
7356
|
+
version: "0.37.0",
|
|
7354
7357
|
description: "Django-inspired RSC router with composable URL patterns",
|
|
7355
7358
|
keywords: [
|
|
7356
7359
|
"react",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: breadcrumbs
|
|
3
|
-
description: Built-in Breadcrumbs handle for accumulating breadcrumb navigation across route segments. Use when building a breadcrumb trail for nested routes,
|
|
3
|
+
description: Built-in Breadcrumbs handle for accumulating breadcrumb navigation across route segments. Use when building a breadcrumb trail for nested routes, asking how to show the current navigation path in a layout, or pushing a crumb from client state (usePushHandle).
|
|
4
4
|
argument-hint: "[setup]"
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -8,13 +8,16 @@ argument-hint: "[setup]"
|
|
|
8
8
|
|
|
9
9
|
Built-in handle for accumulating breadcrumb items across route segments.
|
|
10
10
|
Route, layout, and parallel-slot handlers and loader bodies push items via
|
|
11
|
-
`ctx.use(Breadcrumbs)`; client components
|
|
12
|
-
`
|
|
13
|
-
|
|
11
|
+
`ctx.use(Breadcrumbs)`; client components push items for data they learn or
|
|
12
|
+
change after render with `usePushHandle(Breadcrumbs)` and read the collected
|
|
13
|
+
trail with `useHandle(Breadcrumbs)`. Items are collected in parent-to-child
|
|
14
|
+
order with automatic deduplication by `href`. Where a crumb should come from
|
|
15
|
+
(handler, loader or client) is decided in one place:
|
|
16
|
+
[hooks → "Where should a handle value come from?"](../hooks/handle-and-actions.md#where-should-a-handle-value-come-from).
|
|
14
17
|
|
|
15
18
|
`Breadcrumbs` is exported from both `@rangojs/router` (server, for pushing) and
|
|
16
|
-
`@rangojs/router/client` (for `useHandle`). For page titles
|
|
17
|
-
the `Meta` handle the same way.
|
|
19
|
+
`@rangojs/router/client` (for `useHandle` and `usePushHandle`). For page titles
|
|
20
|
+
and meta tags, use the `Meta` handle the same way.
|
|
18
21
|
|
|
19
22
|
## BreadcrumbItem Type
|
|
20
23
|
|
|
@@ -114,6 +117,40 @@ replayed from the loader's cache entry. A crumb from a loader it awaits appears
|
|
|
114
117
|
once even when a sibling loader or the handler reads that loader too; that live
|
|
115
118
|
run's crumb replaces the cached one in the trail.
|
|
116
119
|
|
|
120
|
+
## Pushing from Client Components
|
|
121
|
+
|
|
122
|
+
A crumb from data the client learns or changes after render (a project a
|
|
123
|
+
`useFetchLoader()` read brought, a name being edited) is pushed by the
|
|
124
|
+
component that holds it, during render:
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
"use client";
|
|
128
|
+
import { Breadcrumbs, usePushHandle } from "@rangojs/router/client";
|
|
129
|
+
|
|
130
|
+
function ProjectCrumb({ project }: { project: { id: string; name: string } }) {
|
|
131
|
+
usePushHandle(Breadcrumbs)({
|
|
132
|
+
label: project.name,
|
|
133
|
+
href: `/projects/${project.id}`,
|
|
134
|
+
});
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The crumb lands in the component's own segment, after that segment's server
|
|
140
|
+
crumbs. A server crumb with the same `href` keeps its position in the trail
|
|
141
|
+
and takes the client's label (dedupe keeps the first position and the last
|
|
142
|
+
value), so a server crumb for the first paint and a client crumb for later
|
|
143
|
+
changes show as one crumb. The client crumb is never in the SSR HTML, leaves
|
|
144
|
+
with the component, and is never stored in a history entry. Rules and timing:
|
|
145
|
+
[hooks → usePushHandle()](../hooks/handle-and-actions.md#usepushhandle).
|
|
146
|
+
|
|
147
|
+
A client crumb's `content` is passed through as it is, as on the server: an
|
|
148
|
+
element, or a promise the reader resolves with `use()` (next section). A
|
|
149
|
+
promise compares by reference, so a client crumb whose `content` is a fresh
|
|
150
|
+
promise on every render publishes on every render, and a component that
|
|
151
|
+
also reads `Breadcrumbs` loops. Pass an element, or keep the promise stable
|
|
152
|
+
(from a loader, or `useMemo`).
|
|
153
|
+
|
|
117
154
|
## Async Content
|
|
118
155
|
|
|
119
156
|
The `content` field supports `Promise<ReactNode>` for streaming:
|
|
@@ -247,6 +284,31 @@ function BreadcrumbNav() {
|
|
|
247
284
|
}
|
|
248
285
|
```
|
|
249
286
|
|
|
287
|
+
The trail keeps its reference while its content is equal: an action's
|
|
288
|
+
revalidation or a refresh that re-delivers the same crumbs neither re-renders
|
|
289
|
+
the reader nor re-runs an effect keyed on the trail. That holds while each
|
|
290
|
+
crumb's `content` is plain text or host elements (`<b>`, `<span>`) holding
|
|
291
|
+
only those. Some `content` arrives fresh on every response and counts as a
|
|
292
|
+
change each time, nested inside a host element too, so the trail gets a new
|
|
293
|
+
reference on each re-delivery:
|
|
294
|
+
|
|
295
|
+
- a client component (`content: <OrderIcon />`), which the response decodes
|
|
296
|
+
as a new lazy reference;
|
|
297
|
+
- async server content (an async server component), decoded the same way;
|
|
298
|
+
- a `content` promise, compared by identity.
|
|
299
|
+
|
|
300
|
+
For crumbs like these, key the effect on a primitive the crumb carries
|
|
301
|
+
instead of the trail, such as its `href` or `label`:
|
|
302
|
+
|
|
303
|
+
```tsx
|
|
304
|
+
const href = useHandle(Breadcrumbs, (crumbs) => crumbs.at(-1)?.href);
|
|
305
|
+
useEffect(() => {
|
|
306
|
+
// runs once per crumb change, whatever `content` holds
|
|
307
|
+
}, [href]);
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
See `/hooks`, "useHandle()".
|
|
311
|
+
|
|
250
312
|
### With Selector
|
|
251
313
|
|
|
252
314
|
Re-render only when the selected value changes:
|
package/skills/caching/SKILL.md
CHANGED
|
@@ -480,8 +480,10 @@ already holds that layout; only a prefetch that defers the layout itself (it
|
|
|
480
480
|
is new to the page) leaves the record unread and unwritten. A response that
|
|
481
481
|
carries deferred work is never reused: the document cache refuses it, and it
|
|
482
482
|
is sent `cache-control: private, no-cache` with `X-Rango-Prefetch` added to
|
|
483
|
-
`Vary`,
|
|
484
|
-
|
|
483
|
+
`Vary`, in place of any `Cache-Control` the route set unless that one says
|
|
484
|
+
`no-store`, which it keeps, so no CDN keeps it and it never answers a
|
|
485
|
+
navigation (`/document-cache` → "Cache-Control on a partial nothing may
|
|
486
|
+
reuse"). A browser may keep a copy and answer the same
|
|
485
487
|
prefetch from it while it reloads the page for back/forward; the click
|
|
486
488
|
completes it like any other. A fill is never answered from a stored body.
|
|
487
489
|
Every body the document cache does hold is complete, so one entry answers a
|
package/skills/catalog.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"name": "breadcrumbs",
|
|
20
|
-
"description": "Built-in Breadcrumbs handle for accumulating breadcrumb navigation across route segments. Use when building a breadcrumb trail for nested routes,
|
|
20
|
+
"description": "Built-in Breadcrumbs handle for accumulating breadcrumb navigation across route segments. Use when building a breadcrumb trail for nested routes, asking how to show the current navigation path in a layout, or pushing a crumb from client state (usePushHandle).",
|
|
21
21
|
"argumentHint": "[setup]",
|
|
22
22
|
"path": "skills/breadcrumbs/SKILL.md"
|
|
23
23
|
},
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
"name": "client-urls",
|
|
44
|
-
"description": "Define client-component route groups with clientUrls() in a \"use client\" module — no handlers, useLoader at read sites, server-run revalidate predicates, loader-thrown notFound/redirect, loader handle writes, and the ssr:\"await\" SSR-completeness opt-in. Use when a route group's pages are client components, when building high-navigation-speed UIs (dashboards, admin panels, settings) where transitions must feel instant, when moving data reads from handler ctx.use() to useLoader at consumption sites, or when asking how routes defined in a \"use client\" file work.",
|
|
44
|
+
"description": "Define client-component route groups with clientUrls() in a \"use client\" module — no handlers, useLoader at read sites, server-run revalidate predicates, loader-thrown notFound/redirect, loader handle writes and client pushes (usePushHandle), and the ssr:\"await\" SSR-completeness opt-in. Use when a route group's pages are client components, when building high-navigation-speed UIs (dashboards, admin panels, settings) where transitions must feel instant, when moving data reads from handler ctx.use() to useLoader at consumption sites, or when asking how routes defined in a \"use client\" file work.",
|
|
45
45
|
"argumentHint": "[setup]",
|
|
46
46
|
"path": "skills/client-urls/SKILL.md"
|
|
47
47
|
},
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
},
|
|
108
108
|
{
|
|
109
109
|
"name": "hooks",
|
|
110
|
-
"description": "Client-side React hooks for navigation, loaders, and state in @rangojs/router. Use when a client component needs the current URL, params, search params, navigation state, or
|
|
110
|
+
"description": "Client-side React hooks for navigation, loaders, handles and state in @rangojs/router. Use when a client component needs the current URL, params, search params, navigation state, loader data, or handle data (useHandle), or pushes a handle value from client state (usePushHandle, for a page title, Meta tag or breadcrumb from a live value, a draft or a fetch) — e.g. \"how do I read the route param in a component\", \"set the page title from a client component\".",
|
|
111
111
|
"argumentHint": "[hook-name]",
|
|
112
112
|
"path": "skills/hooks/SKILL.md"
|
|
113
113
|
},
|