@rangojs/router 0.24.4 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/bin/rango.js +363 -39
- package/dist/testing/vitest.js +37 -4
- package/dist/types/browser/event-controller.d.ts +24 -5
- package/dist/types/browser/intercept-utils.d.ts +5 -2
- package/dist/types/browser/merge-segment-loaders.d.ts +0 -23
- package/dist/types/browser/navigation-transaction.d.ts +5 -5
- package/dist/types/browser/partial-update.d.ts +21 -13
- package/dist/types/browser/prefetch/cache.d.ts +8 -0
- package/dist/types/browser/rango-marker.d.ts +7 -0
- package/dist/types/browser/react/filter-segment-order.d.ts +10 -0
- package/dist/types/browser/react/use-handle.d.ts +20 -0
- package/dist/types/browser/react/use-href.d.ts +6 -0
- package/dist/types/browser/react/use-router.d.ts +6 -1
- package/dist/types/browser/response-adapter.d.ts +5 -3
- package/dist/types/browser/scroll-restoration.d.ts +9 -3
- package/dist/types/browser/segment-reconciler.d.ts +10 -13
- package/dist/types/browser/types.d.ts +38 -8
- package/dist/types/build/route-types/per-module-writer.d.ts +12 -0
- package/dist/types/cache/cf/cf-shell-frame.d.ts +2 -0
- package/dist/types/cache/types.d.ts +8 -0
- package/dist/types/client-urls/client-urls.d.ts +6 -2
- package/dist/types/client-urls/revalidate-registry.d.ts +1 -1
- package/dist/types/client-urls/server-projection.d.ts +9 -5
- package/dist/types/client-urls/types.d.ts +29 -16
- package/dist/types/client.d.ts +2 -2
- package/dist/types/client.rsc.d.ts +2 -2
- package/dist/types/decode-loader-results.d.ts +28 -7
- package/dist/types/href-client.d.ts +3 -1
- package/dist/types/index.rsc.d.ts +1 -1
- package/dist/types/loader-redirect.d.ts +2 -3
- package/dist/types/outlet-context.d.ts +7 -6
- package/dist/types/prefetch-markers.d.ts +14 -5
- package/dist/types/route-content-wrapper.d.ts +17 -14
- package/dist/types/route-definition/helpers-types.d.ts +7 -2
- package/dist/types/route-definition/resolve-handler-use.d.ts +6 -1
- package/dist/types/route-definition/rewrite.d.ts +48 -5
- package/dist/types/route-types.d.ts +2 -2
- package/dist/types/router/handler-context.d.ts +14 -2
- package/dist/types/router/intercept-resolution.d.ts +19 -46
- package/dist/types/router/lazy-includes.d.ts +7 -0
- package/dist/types/router/match-middleware/intercept-resolution.d.ts +2 -2
- package/dist/types/router/middleware.d.ts +0 -16
- package/dist/types/router/navigation-snapshot.d.ts +2 -0
- package/dist/types/router/prefetch-cache-ttl.d.ts +8 -11
- package/dist/types/router/revalidation.d.ts +8 -1
- package/dist/types/router/router-context.d.ts +4 -16
- package/dist/types/router/router-interfaces.d.ts +0 -6
- package/dist/types/router/router-options.d.ts +4 -7
- package/dist/types/router/segment-resolution/prefetch-deferral.d.ts +31 -8
- package/dist/types/router/segment-resolution/revalidation.d.ts +38 -4
- package/dist/types/router/segment-resolution.d.ts +1 -1
- package/dist/types/router/segment-wrappers.d.ts +3 -5
- package/dist/types/router/substitute-pattern-params.d.ts +3 -2
- package/dist/types/router/tracing.d.ts +2 -2
- package/dist/types/rsc/full-payload.d.ts +14 -2
- package/dist/types/rsc/helpers.d.ts +8 -0
- package/dist/types/rsc/manifest-init.d.ts +20 -0
- package/dist/types/rsc/prefetch-render-error.d.ts +22 -0
- package/dist/types/rsc/progressive-enhancement.d.ts +20 -0
- package/dist/types/rsc/rewrite-passes.d.ts +12 -2
- package/dist/types/rsc/server-action.d.ts +6 -0
- package/dist/types/rsc/shell-capture-constants.d.ts +10 -1
- package/dist/types/rsc/shell-capture.d.ts +7 -0
- package/dist/types/rsc/types.d.ts +5 -0
- package/dist/types/segment-system.d.ts +15 -0
- package/dist/types/server/context.d.ts +64 -4
- package/dist/types/server/request-context.d.ts +41 -4
- package/dist/types/server/request-headers.d.ts +12 -0
- package/dist/types/server/rewrite-trail.d.ts +8 -1
- package/dist/types/testing/e2e/index.d.ts +1 -1
- package/dist/types/testing/flight.entry.d.ts +1 -1
- package/dist/types/testing/index.d.ts +1 -1
- package/dist/types/testing/internal/client-urls-projection.d.ts +4 -3
- package/dist/types/testing/render-route.d.ts +21 -11
- package/dist/types/testing/run-loader.d.ts +7 -0
- package/dist/types/testing/run-middleware.d.ts +7 -0
- package/dist/types/testing/run-revalidate.d.ts +5 -4
- package/dist/types/testing/serve-shell-request.d.ts +41 -4
- package/dist/types/testing/shell-status.d.ts +17 -0
- package/dist/types/testing/vitest-stubs/version.d.ts +1 -0
- package/dist/types/testing/vitest.d.ts +10 -1
- package/dist/types/thenable-status.d.ts +0 -6
- package/dist/types/types/handler-context.d.ts +12 -1
- package/dist/types/types/loader-types.d.ts +4 -3
- package/dist/types/types/route-entry.d.ts +2 -1
- package/dist/types/urls/path-helper-types.d.ts +4 -2
- package/dist/types/vite/discovery/client-urls-projection.d.ts +55 -5
- package/dist/types/vite/discovery/state.d.ts +20 -0
- package/dist/types/vite/plugins/client-urls-revalidate-hoist.d.ts +28 -16
- package/dist/types/vite/plugins/hoist/source.d.ts +8 -7
- package/dist/types/vite/plugins/virtual-entries.d.ts +6 -0
- package/dist/types/vite/utils/prerender-utils.d.ts +7 -0
- package/dist/vite/index.js +6816 -6547
- package/package.json +1 -1
- package/skills/app-structure/SKILL.md +255 -0
- package/skills/app-structure/content-site.md +333 -0
- package/skills/app-structure/e-commerce.md +435 -0
- package/skills/app-structure/large-app.md +885 -0
- package/skills/app-structure/multi-app.md +280 -0
- package/skills/breadcrumbs/SKILL.md +6 -1
- package/skills/caching/SKILL.md +3 -1
- package/skills/catalog.json +12 -0
- package/skills/client-urls/SKILL.md +185 -32
- package/skills/composability/SKILL.md +10 -8
- package/skills/handler-use/SKILL.md +48 -9
- package/skills/hooks/handle-and-actions.md +104 -0
- package/skills/hooks/navigation.md +24 -10
- package/skills/hooks/urls.md +1 -1
- package/skills/i18n/SKILL.md +2 -1
- package/skills/intercept/SKILL.md +60 -29
- package/skills/layout/SKILL.md +6 -3
- package/skills/links/SKILL.md +151 -17
- package/skills/loader/SKILL.md +32 -10
- package/skills/middleware/SKILL.md +111 -15
- package/skills/observability/SKILL.md +11 -0
- package/skills/parallel/SKILL.md +5 -5
- package/skills/ppr/SKILL.md +43 -8
- package/skills/prerender/SKILL.md +1 -2
- package/skills/rango/SKILL.md +3 -0
- package/skills/response-routes/SKILL.md +4 -1
- package/skills/scripts/SKILL.md +12 -1
- package/skills/server-actions/SKILL.md +60 -20
- package/skills/testing/SKILL.md +1 -0
- package/skills/testing/client-components.md +13 -10
- package/skills/testing/loader.md +25 -24
- package/skills/testing/middleware.md +11 -11
- package/skills/testing/response-routes.md +4 -1
- package/skills/testing/serve-shell-request.md +85 -21
- package/skills/ux-architecture/SKILL.md +980 -0
- package/skills/view-transitions/SKILL.md +43 -10
- package/src/__augment-tests__/augmented.check.ts +28 -0
- package/src/browser/event-controller.ts +44 -18
- package/src/browser/intercept-utils.ts +3 -2
- package/src/browser/merge-segment-loaders.ts +0 -85
- package/src/browser/navigation-bridge.ts +112 -84
- package/src/browser/navigation-client.ts +20 -15
- package/src/browser/navigation-store.ts +4 -2
- package/src/browser/navigation-transaction.ts +9 -8
- package/src/browser/partial-update.ts +90 -32
- package/src/browser/prefetch/cache.ts +8 -0
- package/src/browser/prefetch/fetch.ts +13 -3
- package/src/browser/rango-marker.ts +13 -0
- package/src/browser/react/NavigationProvider.tsx +25 -7
- package/src/browser/react/filter-segment-order.ts +13 -0
- package/src/browser/react/use-action.ts +9 -15
- package/src/browser/react/use-handle.ts +63 -71
- package/src/browser/react/use-href.tsx +24 -5
- package/src/browser/react/use-link-status.ts +1 -1
- package/src/browser/react/use-navigation.ts +30 -40
- package/src/browser/react/use-router.ts +37 -6
- package/src/browser/react/use-segments.ts +8 -12
- package/src/browser/response-adapter.ts +11 -5
- package/src/browser/rsc-router.tsx +3 -1
- package/src/browser/scroll-restoration.ts +34 -20
- package/src/browser/segment-reconciler.ts +11 -29
- package/src/browser/server-action-bridge.ts +52 -16
- package/src/browser/types.ts +40 -8
- package/src/build/generate-manifest.ts +12 -1
- package/src/build/route-types/codegen.ts +6 -2
- package/src/build/route-types/per-module-writer.ts +94 -61
- package/src/cache/cache-runtime.ts +9 -0
- package/src/cache/cache-scope.ts +2 -1
- package/src/cache/cf/cf-cache-store.ts +2 -0
- package/src/cache/cf/cf-shell-frame.ts +3 -0
- package/src/cache/types.ts +8 -0
- package/src/cache/vercel/vercel-cache-store.ts +6 -1
- package/src/client-urls/client-urls.ts +202 -153
- package/src/client-urls/revalidate-registry.ts +12 -3
- package/src/client-urls/server-projection.ts +137 -66
- package/src/client-urls/types.ts +30 -15
- package/src/client.rsc.tsx +11 -1
- package/src/client.tsx +9 -1
- package/src/decode-loader-results.ts +64 -31
- package/src/href-client.ts +3 -1
- package/src/index.rsc.ts +1 -0
- package/src/index.ts +12 -4
- package/src/loader-redirect.tsx +2 -3
- package/src/outlet-context.ts +7 -6
- package/src/prefetch-markers.ts +15 -5
- package/src/reverse.ts +3 -3
- package/src/route-content-wrapper.tsx +19 -17
- package/src/route-definition/dsl-helpers.ts +27 -7
- package/src/route-definition/helpers-types.ts +7 -2
- package/src/route-definition/resolve-handler-use.ts +23 -10
- package/src/route-definition/rewrite.ts +86 -19
- package/src/route-types.ts +1 -2
- package/src/router/find-match.ts +37 -1
- package/src/router/handler-context.ts +85 -40
- package/src/router/intercept-resolution.ts +161 -307
- package/src/router/lazy-includes.ts +43 -27
- package/src/router/loader-resolution.ts +21 -1
- package/src/router/manifest.ts +6 -8
- package/src/router/match-api.ts +11 -1
- package/src/router/match-middleware/background-revalidation.ts +2 -4
- package/src/router/match-middleware/cache-lookup.ts +16 -20
- package/src/router/match-middleware/intercept-resolution.ts +41 -60
- package/src/router/match-result.ts +31 -2
- package/src/router/middleware.ts +6 -147
- package/src/router/navigation-snapshot.ts +38 -2
- package/src/router/prefetch-cache-ttl.ts +10 -18
- package/src/router/prerender-match.ts +2 -1
- package/src/router/revalidation.ts +24 -3
- package/src/router/router-context.ts +5 -18
- package/src/router/router-interfaces.ts +0 -7
- package/src/router/router-options.ts +4 -7
- package/src/router/segment-resolution/fresh.ts +6 -2
- package/src/router/segment-resolution/helpers.ts +7 -1
- package/src/router/segment-resolution/prefetch-deferral.ts +62 -12
- package/src/router/segment-resolution/revalidation.ts +75 -35
- package/src/router/segment-resolution.ts +0 -1
- package/src/router/segment-wrappers.ts +8 -13
- package/src/router/substitute-pattern-params.ts +3 -2
- package/src/router/tracing.ts +2 -2
- package/src/router.ts +2 -9
- package/src/rsc/full-payload.ts +26 -4
- package/src/rsc/handler.ts +83 -41
- package/src/rsc/helpers.ts +13 -0
- package/src/rsc/manifest-init.ts +56 -3
- package/src/rsc/prefetch-render-error.ts +38 -0
- package/src/rsc/progressive-enhancement.ts +161 -211
- package/src/rsc/rewrite-passes.ts +56 -9
- package/src/rsc/rsc-rendering.ts +79 -23
- package/src/rsc/server-action.ts +25 -2
- package/src/rsc/shell-capture-constants.ts +22 -0
- package/src/rsc/shell-capture.ts +11 -0
- package/src/rsc/types.ts +5 -0
- package/src/segment-system.tsx +125 -119
- package/src/server/context.ts +96 -5
- package/src/server/handle-store.ts +3 -2
- package/src/server/request-context.ts +42 -3
- package/src/server/request-headers.ts +32 -0
- package/src/server/rewrite-trail.ts +55 -9
- package/src/ssr/ssr-root.tsx +6 -10
- package/src/testing/dispatch.ts +4 -5
- package/src/testing/e2e/index.ts +1 -0
- package/src/testing/flight.entry.ts +1 -0
- package/src/testing/index.ts +1 -0
- package/src/testing/internal/client-urls-projection.ts +31 -11
- package/src/testing/render-route.tsx +83 -40
- package/src/testing/run-loader.ts +26 -2
- package/src/testing/run-middleware.ts +10 -0
- package/src/testing/run-revalidate.ts +13 -6
- package/src/testing/serve-shell-request.ts +77 -4
- package/src/testing/shell-status.ts +40 -0
- package/src/testing/vitest-stubs/version.ts +1 -0
- package/src/testing/vitest.ts +74 -7
- package/src/thenable-status.ts +0 -11
- package/src/types/handler-context.ts +12 -1
- package/src/types/loader-types.ts +4 -3
- package/src/types/route-entry.ts +2 -1
- package/src/urls/include-helper.ts +38 -11
- package/src/urls/path-helper-types.ts +4 -2
- package/src/vite/discovery/client-urls-projection.ts +205 -16
- package/src/vite/discovery/discover-routers.ts +2 -2
- package/src/vite/discovery/prerender-collection.ts +2 -6
- package/src/vite/discovery/state.ts +26 -0
- package/src/vite/plugins/client-urls-revalidate-hoist.ts +190 -77
- package/src/vite/plugins/expose-internal-ids.ts +46 -40
- package/src/vite/plugins/hoist/source.ts +8 -7
- package/src/vite/plugins/transition-when-hoist.ts +1 -0
- package/src/vite/plugins/version-plugin.ts +7 -0
- package/src/vite/plugins/version.d.ts +7 -0
- package/src/vite/plugins/virtual-entries.ts +20 -0
- package/src/vite/rango.ts +4 -1
- package/src/vite/router-discovery.ts +39 -7
- package/src/vite/utils/prerender-utils.ts +17 -0
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { NavigationStore, NavigationClient, UpdateSubscriber, ResolvedSegment } from "./types.js";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
+
export declare const addTransitionType: ((type: string) => void) | undefined;
|
|
3
4
|
import type { RenderSegmentsOptions } from "../segment-system.js";
|
|
4
5
|
import type { BoundTransaction } from "./navigation-transaction.js";
|
|
5
|
-
import type { HandleData, NavigationUpdate, RscMetadata } from "./types.js";
|
|
6
|
+
import type { HandleData, NavigationUpdate, RscMetadata, ShownEntry } from "./types.js";
|
|
6
7
|
import type { LoaderStore } from "../loader-store.js";
|
|
7
8
|
import { type TransitionWhenActionInput } from "./transition-when.js";
|
|
9
|
+
import { type TransitionWhenKind } from "../types/segments.js";
|
|
8
10
|
/**
|
|
9
11
|
* Hold/animate decision for a commit: a non-intercept segment carries a
|
|
10
12
|
* transition, no intercept is presented, and this navigation's
|
|
@@ -18,8 +20,10 @@ export declare function shouldStartViewTransition(segments: readonly ResolvedSeg
|
|
|
18
20
|
* settled/cached segments make it a no-op. Urgent commits call onUpdate
|
|
19
21
|
* directly: nothing is held there, a reader of a pending stream suspends to
|
|
20
22
|
* its fallback. Also used by renderRoute's navigate() (testing/render-route.tsx).
|
|
23
|
+
* Every commit is tagged with its transition({ when }) `kind` (#1165), then
|
|
24
|
+
* `transitionTypes`.
|
|
21
25
|
*/
|
|
22
|
-
export declare function commitInTransition(loaders: LoaderStore, onUpdate: UpdateSubscriber, segments: readonly ResolvedSegment[], update: NavigationUpdate, transitionTypes: readonly string[]): void;
|
|
26
|
+
export declare function commitInTransition(loaders: LoaderStore, onUpdate: UpdateSubscriber, segments: readonly ResolvedSegment[], update: NavigationUpdate, kind: TransitionWhenKind, transitionTypes: readonly string[]): void;
|
|
23
27
|
/**
|
|
24
28
|
* Configuration for creating a partial updater
|
|
25
29
|
*/
|
|
@@ -45,13 +49,15 @@ export interface PartialUpdateConfig {
|
|
|
45
49
|
/** What the response's handlers pushed, to the handle store. */
|
|
46
50
|
handles(metadata: RscMetadata): void;
|
|
47
51
|
/**
|
|
48
|
-
* Deliver the navigation state to its readers now. A page
|
|
49
|
-
* holes commits in the task of its click, before the
|
|
50
|
-
* click has gone out (event-controller.ts
|
|
51
|
-
* React holds that commit where a hole is
|
|
52
|
-
* this useNavigation() reads idle, on the
|
|
53
|
-
* wait.
|
|
54
|
-
* handed over, and stays while React holds it,
|
|
52
|
+
* Deliver the navigation state to its readers now, and commit it. A page
|
|
53
|
+
* built with holes commits in the task of its click, before the
|
|
54
|
+
* notification of the click has gone out (event-controller.ts
|
|
55
|
+
* makeDebouncedNotifier), and React holds that commit where a hole is
|
|
56
|
+
* read with no boundary: without this useNavigation() reads idle, on the
|
|
57
|
+
* page being left, for the whole wait. Committed first, `loading` is on
|
|
58
|
+
* screen when the commit is handed over, and stays while React holds it,
|
|
59
|
+
* as for a plain click. Delivered at default priority it joins the
|
|
60
|
+
* commit's urgent batch, which brings idle with the URL, and never shows.
|
|
55
61
|
*/
|
|
56
62
|
flush(): void;
|
|
57
63
|
};
|
|
@@ -70,8 +76,8 @@ export interface CommitOverrides {
|
|
|
70
76
|
interceptSourceUrl?: string;
|
|
71
77
|
/** Server-set location state to merge into history.pushState */
|
|
72
78
|
serverState?: Record<string, unknown>;
|
|
73
|
-
/** The
|
|
74
|
-
|
|
79
|
+
/** The payload's metadata: its route name and rewrite target, remembered per history entry. */
|
|
80
|
+
metadata?: ShownEntry;
|
|
75
81
|
}
|
|
76
82
|
/**
|
|
77
83
|
* Discriminated update mode for partial updates.
|
|
@@ -120,8 +126,10 @@ export type UpdateMode = {
|
|
|
120
126
|
action?: TransitionWhenActionInput;
|
|
121
127
|
};
|
|
122
128
|
/**
|
|
123
|
-
* Type for the fetchPartialUpdate function
|
|
129
|
+
* Type for the fetchPartialUpdate function. In `action` mode it resolves with
|
|
130
|
+
* the error of a loader that threw while it re-ran (revalidationErrorOf);
|
|
131
|
+
* the loader throws at its read.
|
|
124
132
|
*/
|
|
125
|
-
export type PartialUpdater = (targetUrl: string, segmentIds: string[] | undefined, isRetry: boolean, signal: AbortSignal | undefined, tx: BoundTransaction, mode?: UpdateMode) => Promise<
|
|
133
|
+
export type PartialUpdater = (targetUrl: string, segmentIds: string[] | undefined, isRetry: boolean, signal: AbortSignal | undefined, tx: BoundTransaction, mode?: UpdateMode) => Promise<Error | undefined>;
|
|
126
134
|
export declare function createPartialUpdater(config: PartialUpdateConfig): PartialUpdater;
|
|
127
135
|
export { createPartialUpdater as default };
|
|
@@ -86,6 +86,14 @@ export interface DecodedPrefetch {
|
|
|
86
86
|
* one prefetch serves unlimited adoptions within TTL/state validity.
|
|
87
87
|
*/
|
|
88
88
|
respawn?: () => DecodedPrefetch;
|
|
89
|
+
/**
|
|
90
|
+
* The prefetch's stall timer (executePrefetchFetch). Navigation clears it on
|
|
91
|
+
* the entry it serves: from then on the click owns the stream, which runs to
|
|
92
|
+
* its end (a Flight response that arrived is never aborted mid-stream). A
|
|
93
|
+
* prefetch nobody adopted keeps it, so a stalled one is still aborted.
|
|
94
|
+
* Absent on a respawned entry, which has no timer.
|
|
95
|
+
*/
|
|
96
|
+
stallTimer?: ReturnType<typeof setTimeout>;
|
|
89
97
|
/**
|
|
90
98
|
* Release the buffered reserve bytes. Called when the entry is evicted
|
|
91
99
|
* without being consumed (expiry, FIFO, sweep, cache clear) so the tee
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Publishes `window.__rango = { version }` so outside tools can tell a page is
|
|
3
|
+
* a Rango app and which router release serves it. Write-only and informational:
|
|
4
|
+
* nothing in the router reads it (rango-marker.test.ts greps src/ for reads),
|
|
5
|
+
* and only the npm semver is exposed, no build hash, router id or config.
|
|
6
|
+
*/
|
|
7
|
+
export declare function publishRangoMarker(): void;
|
|
@@ -5,6 +5,16 @@
|
|
|
5
5
|
export declare const LOADER_SEGMENT_ID: RegExp;
|
|
6
6
|
/** True for a loader sub-id ("M0L0D1.user"), false for a layout/route/slot id. */
|
|
7
7
|
export declare function isLoaderSegmentId(id: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The parent of a loader sub-id (`${parentId}D${index}.${loaderId}`); any
|
|
10
|
+
* other id unchanged. parentId is a shortCode (never "D"), or
|
|
11
|
+
* `${shortCode}.${slotName}` for an intercept slot's loaders, where the
|
|
12
|
+
* user-chosen name may hold an uppercase "D" ("@Detail"). Strip from the first
|
|
13
|
+
* `D<index>.`: splitting on a bare "D" mis-cut "@Detail" to "@" and silently
|
|
14
|
+
* dropped the loader's data. Correct only because slot names cannot contain
|
|
15
|
+
* "." (assertValidSlotName, route-definition/dsl-helpers.ts).
|
|
16
|
+
*/
|
|
17
|
+
export declare function loaderParentId(id: string): string;
|
|
8
18
|
/**
|
|
9
19
|
* Build the handle-collection segment order from a raw `matched` list.
|
|
10
20
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Handle } from "../../handle.js";
|
|
2
|
+
import type { RouteStateSignal } from "../event-controller.js";
|
|
2
3
|
/**
|
|
3
4
|
* Hook to access collected handle data.
|
|
4
5
|
*
|
|
@@ -19,3 +20,22 @@ import type { Handle } from "../../handle.js";
|
|
|
19
20
|
*/
|
|
20
21
|
export declare function useHandle<T, A>(handle: Handle<T, A>): Rango.FlightSerialize<A>;
|
|
21
22
|
export declare function useHandle<T, A, S>(handle: Handle<T, A>, selector: (data: Rango.FlightSerialize<A>) => S): S;
|
|
23
|
+
/**
|
|
24
|
+
* Route state the controller's handle notifications drive (useHandle,
|
|
25
|
+
* useSegments) commits with the page it belongs to. NavigationProvider
|
|
26
|
+
* flushes the controller inside every payload update, so a value known then
|
|
27
|
+
* is set in the page's lane. A page handed over urgently (signal "release")
|
|
28
|
+
* takes a value that arrives before it commits the same way: set at default
|
|
29
|
+
* priority, it renders in the page's lane, and the page's effects read it.
|
|
30
|
+
* A page in a transition (signal "anchor") does not: until it commits
|
|
31
|
+
* (releaseRouteState() from the provider's layout effect, signal "release"),
|
|
32
|
+
* a new value waits, and is applied in the commit's task, right after the
|
|
33
|
+
* page's own commit. In the page's lane, a value that suspends in a revealed
|
|
34
|
+
* <Suspense> (a crumb's content) would hold the page; in a lane of its own,
|
|
35
|
+
* it commits over the page being left and takes the page's transition types
|
|
36
|
+
* (#1165); and a transition entangled with the page misses its commit when it
|
|
37
|
+
* is set after React rendered the page, before its view transition's
|
|
38
|
+
* mutation, and starts a view transition of its own. A value shallow-equal to
|
|
39
|
+
* the last one sets nothing, so a reader renders only when its value moves.
|
|
40
|
+
*/
|
|
41
|
+
export declare function useCommitAnchoredState<T>(init: () => T): [T, (value: T, signal?: RouteStateSignal) => void];
|
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
* include() mount prefix. Inside an include("/shop", ...) scope,
|
|
6
6
|
* the returned function resolves local paths relative to /shop.
|
|
7
7
|
*
|
|
8
|
+
* Under a parameterized mount (`include("/:accountId", ...)`) the mount's
|
|
9
|
+
* params are filled from the current route params, as `useReverse` does:
|
|
10
|
+
* `href("/issues")` at `/acme/board` returns `/acme/issues`. A mount param
|
|
11
|
+
* missing from the current match throws `Missing param` when the returned
|
|
12
|
+
* function is called.
|
|
13
|
+
*
|
|
8
14
|
* For absolute paths (outside the current mount), use the bare
|
|
9
15
|
* href() function directly instead.
|
|
10
16
|
*
|
|
@@ -13,7 +13,12 @@ import type { RouterInstance } from "../types.js";
|
|
|
13
13
|
*
|
|
14
14
|
* RELATIVE paths (no leading `/`, no scheme/query/hash) resolve against the
|
|
15
15
|
* current include() mount: `router.push("cart")` inside `include("/shop")`
|
|
16
|
-
* navigates to `/shop/cart`.
|
|
16
|
+
* navigates to `/shop/cart`. Under a parameterized mount
|
|
17
|
+
* (`include("/:accountId", ...)`) the mount's params are filled from the
|
|
18
|
+
* current route params: `router.push("issues")` at `/acme/board` navigates
|
|
19
|
+
* to `/acme/issues`, and a missing mount param rejects the push/replace
|
|
20
|
+
* promise with `Missing param` (a prefetch skips the target).
|
|
21
|
+
* Absolute paths stay APP-absolute — unlike
|
|
17
22
|
* basename, the mount is scoped, and absolute pushes legitimately target
|
|
18
23
|
* outside it, so they are never auto-prefixed.
|
|
19
24
|
*
|
|
@@ -48,9 +48,11 @@ export declare function handleReloadHeader(response: Response, opts: {
|
|
|
48
48
|
* end-of-stream, calling onComplete when done.
|
|
49
49
|
*
|
|
50
50
|
* `onComplete` receives `endedCleanly`: true only on a normal EOF drain, false
|
|
51
|
-
* on a read error
|
|
52
|
-
*
|
|
53
|
-
*
|
|
51
|
+
* on a read error, an abort (the signal cancelled the reader), or a body that
|
|
52
|
+
* ends with PREFETCH_FAILED_ROW (a prefetch whose render reported an error,
|
|
53
|
+
* rsc/prefetch-render-error.ts). Callers that gate a "fully complete" fast
|
|
54
|
+
* path (e.g. prefetch's `entry.complete`) must treat a non-clean end as
|
|
55
|
+
* incomplete — a broken stream is not complete data.
|
|
54
56
|
*
|
|
55
57
|
* If the response has no body, onComplete fires synchronously with `true`
|
|
56
58
|
* (an empty body is a clean, complete stream).
|
|
@@ -63,10 +63,12 @@ export declare function cancelScrollRestorationPolling(): void;
|
|
|
63
63
|
*
|
|
64
64
|
* @param options.retryIfStreaming - If true, poll while streaming until we can scroll to target
|
|
65
65
|
* @param options.isStreaming - Function to check if streaming is in progress
|
|
66
|
+
* @param options.committed - React has committed the restored tree (a layout effect)
|
|
66
67
|
*/
|
|
67
68
|
export declare function restoreScrollPosition(options?: {
|
|
68
69
|
retryIfStreaming?: boolean;
|
|
69
70
|
isStreaming?: () => boolean;
|
|
71
|
+
committed?: boolean;
|
|
70
72
|
}): boolean;
|
|
71
73
|
/**
|
|
72
74
|
* Handle hash link scrolling.
|
|
@@ -86,9 +88,11 @@ export declare function scrollToTop(): void;
|
|
|
86
88
|
export declare function handleNavigationStart(): void;
|
|
87
89
|
/**
|
|
88
90
|
* Handle scroll for a back/forward traversal, at popstate before anything
|
|
89
|
-
* renders: save the page
|
|
90
|
-
* so saveCurrentScrollPosition would use the destination's key)
|
|
91
|
-
*
|
|
91
|
+
* renders: save the page on screen under ITS key (history has already moved,
|
|
92
|
+
* so saveCurrentScrollPosition would use the destination's key). A second
|
|
93
|
+
* traversal before the first one's restore commits (a rapid double Back, a
|
|
94
|
+
* deferred animated restore) saves the page still on screen, never an entry
|
|
95
|
+
* it did not show.
|
|
92
96
|
*/
|
|
93
97
|
export declare function handleTraversalStart(): void;
|
|
94
98
|
/**
|
|
@@ -96,11 +100,13 @@ export declare function handleTraversalStart(): void;
|
|
|
96
100
|
* @param options.restore - If true, restore saved position (for popstate)
|
|
97
101
|
* @param options.scroll - If false, don't scroll at all
|
|
98
102
|
* @param options.isStreaming - Function to check if streaming is in progress (for retry logic)
|
|
103
|
+
* @param options.committed - Called after React committed the new tree
|
|
99
104
|
*/
|
|
100
105
|
export declare function handleNavigationEnd(options: {
|
|
101
106
|
restore?: boolean;
|
|
102
107
|
scroll?: boolean;
|
|
103
108
|
isStreaming?: () => boolean;
|
|
109
|
+
committed?: boolean;
|
|
104
110
|
}): void;
|
|
105
111
|
/**
|
|
106
112
|
* Update the history state key after pushState/replaceState.
|
|
@@ -2,15 +2,17 @@ import type { ResolvedSegment } from "./types.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Determines the merging behavior for segment reconciliation.
|
|
4
4
|
*
|
|
5
|
-
* - 'action': From server-action-bridge's own merge. Always
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* on cached segments not in server diff.
|
|
5
|
+
* - 'action': From server-action-bridge's own merge. Always preserves cached
|
|
6
|
+
* loading (even undefined), never clears cached segment loading.
|
|
7
|
+
* - 'navigation': From partial-update during normal navigation. Preserves
|
|
8
|
+
* cached loading only when defined, clears truthy loading on cached
|
|
9
|
+
* segments not in server diff.
|
|
11
10
|
* - 'stale-revalidation': From partial-update during stale revalidation or
|
|
12
|
-
* action-triggered refetch.
|
|
13
|
-
*
|
|
11
|
+
* action-triggered refetch. Always preserves cached loading (same as
|
|
12
|
+
* action), clears truthy loading on cached segments not in server diff.
|
|
13
|
+
*
|
|
14
|
+
* No actor merges loader data: a loader the server skipped, an intercept's
|
|
15
|
+
* included, is its own cached segment in `matched`.
|
|
14
16
|
*/
|
|
15
17
|
export type ReconcileActor = "navigation" | "action" | "stale-revalidation";
|
|
16
18
|
export interface ReconcileInput {
|
|
@@ -52,11 +54,6 @@ export interface ReconcileResult {
|
|
|
52
54
|
* (not undefined). When cached is undefined, lets server value through
|
|
53
55
|
* because we're building a new tree.
|
|
54
56
|
*
|
|
55
|
-
* Loader merging:
|
|
56
|
-
* - action/stale-revalidation: Merges partial loader data when server returns
|
|
57
|
-
* fewer loaders than cached (revalidation only updated some loaders).
|
|
58
|
-
* - navigation: Does not merge (full navigation fetches complete data).
|
|
59
|
-
*
|
|
60
57
|
* Cached segment handling (segments in matched but not in server response):
|
|
61
58
|
* - action: Returns cached segment as-is (preserve tree structure).
|
|
62
59
|
* - navigation/stale-revalidation: Clears truthy loading to undefined
|
|
@@ -29,6 +29,11 @@ export type HandleData = Record<string, Record<string, unknown[]>>;
|
|
|
29
29
|
*/
|
|
30
30
|
export interface RscMetadata {
|
|
31
31
|
pathname: string;
|
|
32
|
+
/**
|
|
33
|
+
* Path and search of the URL the route rendered, when middleware rewrote
|
|
34
|
+
* the request there. Kept per history entry and sent back as `_rsc_rt`.
|
|
35
|
+
*/
|
|
36
|
+
rewriteTarget?: string;
|
|
32
37
|
segments: ResolvedSegment[];
|
|
33
38
|
/** Router instance ID — the current app's identity. A mismatch with the
|
|
34
39
|
* client's id (sent as _rsc_rid) is detected server-side and answered with
|
|
@@ -223,6 +228,12 @@ export interface TrackedActionState {
|
|
|
223
228
|
error: unknown | null;
|
|
224
229
|
/** Result data from the action (preserved after completion) */
|
|
225
230
|
result: unknown | null;
|
|
231
|
+
/**
|
|
232
|
+
* The error of a loader that threw while it re-ran after this successful
|
|
233
|
+
* action (the first, when several did). The loader also throws at its
|
|
234
|
+
* useLoader read, where the nearest error boundary catches it.
|
|
235
|
+
*/
|
|
236
|
+
revalidationError: unknown | null;
|
|
226
237
|
}
|
|
227
238
|
/**
|
|
228
239
|
* The value returned by {@link useAction} when called without a selector.
|
|
@@ -262,13 +273,23 @@ export interface SegmentState {
|
|
|
262
273
|
currentUrl: string;
|
|
263
274
|
currentSegmentIds: string[];
|
|
264
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* What a committed payload says about the page it shows, remembered per
|
|
278
|
+
* history entry (NavigationStore.rememberDisplayedEntry).
|
|
279
|
+
*
|
|
280
|
+
* @internal This type is an implementation detail and may change without notice.
|
|
281
|
+
*/
|
|
282
|
+
export interface ShownEntry {
|
|
283
|
+
readonly routeName?: string;
|
|
284
|
+
readonly rewriteTarget?: string;
|
|
285
|
+
}
|
|
265
286
|
/**
|
|
266
287
|
* What the router remembers about one history entry for transition({ when })
|
|
267
|
-
* (NavigationStore.rememberDisplayedEntry).
|
|
288
|
+
* and the requests made from it (NavigationStore.rememberDisplayedEntry).
|
|
268
289
|
*
|
|
269
290
|
* @internal This type is an implementation detail and may change without notice.
|
|
270
291
|
*/
|
|
271
|
-
export interface HistoryEntryMemory {
|
|
292
|
+
export interface HistoryEntryMemory extends ShownEntry {
|
|
272
293
|
readonly routeName: string | undefined;
|
|
273
294
|
/** The entry's `history.state` as last recorded. */
|
|
274
295
|
readonly state: unknown;
|
|
@@ -295,6 +316,12 @@ export interface NavigationUpdate {
|
|
|
295
316
|
/** Function to check if streaming is in progress */
|
|
296
317
|
isStreaming?: () => boolean;
|
|
297
318
|
};
|
|
319
|
+
/**
|
|
320
|
+
* Handed to React inside startTransition (commitInTransition, an action's
|
|
321
|
+
* commit, a cached back/forward's): NavigationProvider joins the route
|
|
322
|
+
* state that arrives while React holds it to its commit.
|
|
323
|
+
*/
|
|
324
|
+
inTransition?: true;
|
|
298
325
|
}
|
|
299
326
|
/**
|
|
300
327
|
* Plain object accepted as {@link PlainHistoryState}. The `any` string index
|
|
@@ -504,12 +531,12 @@ export interface NavigationStore {
|
|
|
504
531
|
/**
|
|
505
532
|
* Per-history-entry memory for transition({ when }) sources: record the
|
|
506
533
|
* entry on screen (keyed by its `history.state.key`) with its current
|
|
507
|
-
* `history.state` and, when given, its route name
|
|
508
|
-
* record otherwise; every push/replace
|
|
509
|
-
* never carries to another entry).
|
|
510
|
-
* state merge.
|
|
534
|
+
* `history.state` and, when `shown` is given, its route name and rewrite
|
|
535
|
+
* target (both kept from the last record otherwise; every push/replace
|
|
536
|
+
* creates a new key, so a stale record never carries to another entry).
|
|
537
|
+
* Called after every commit, restore and state merge.
|
|
511
538
|
*/
|
|
512
|
-
rememberDisplayedEntry(
|
|
539
|
+
rememberDisplayedEntry(shown?: ShownEntry): void;
|
|
513
540
|
/**
|
|
514
541
|
* The memory of the entry on screen, or of `entryKey`. At popstate
|
|
515
542
|
* history.state already belongs to the destination, so back/forward reads
|
|
@@ -570,6 +597,8 @@ export interface FetchPartialOptions {
|
|
|
570
597
|
targetUrl: string;
|
|
571
598
|
segmentIds: string[];
|
|
572
599
|
previousUrl: string;
|
|
600
|
+
/** The page's RscMetadata.rewriteTarget, sent as `_rsc_rt`. */
|
|
601
|
+
rewriteTarget?: string;
|
|
573
602
|
signal?: AbortSignal;
|
|
574
603
|
/** If true, this is a stale cache revalidation request - server should force revalidators */
|
|
575
604
|
staleRevalidation?: boolean;
|
|
@@ -638,7 +667,8 @@ export interface ServerActionBridgeConfig {
|
|
|
638
667
|
export interface NavigationBridge {
|
|
639
668
|
navigate(url: string, options?: NavigateOptionsInternal): Promise<void>;
|
|
640
669
|
refresh(): Promise<void>;
|
|
641
|
-
|
|
670
|
+
/** `event`: the popstate event; a traversal the browser animated itself (hasUAVisualTransition) is not animated again. */
|
|
671
|
+
handlePopstate(event?: PopStateEvent): Promise<void>;
|
|
642
672
|
registerLinkInterception(): () => void;
|
|
643
673
|
registerDelegatedPrefetch(): () => void;
|
|
644
674
|
/** Current RSC version (live, reflects the latest updateVersion). */
|
|
@@ -11,6 +11,18 @@ export declare function writePerModuleRouteTypes(root: string, filter?: ScanFilt
|
|
|
11
11
|
* e.g. `export const patterns = urls(...)` -> ["patterns"]
|
|
12
12
|
*/
|
|
13
13
|
export declare function findUrlsVariableNames(code: string): string[];
|
|
14
|
+
export interface PerModuleRouteTypesPlan {
|
|
15
|
+
genPath: string;
|
|
16
|
+
/** A urls()/clientUrls() variable resolved to zero routes; content is empty. */
|
|
17
|
+
isPlaceholder: boolean;
|
|
18
|
+
content: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Pure half of the per-module writer: reads sources, never writes. Returns
|
|
22
|
+
* null when the file has no `urls(`/`clientUrls(` or no named routes and no
|
|
23
|
+
* urls() variable. Throws on failure.
|
|
24
|
+
*/
|
|
25
|
+
export declare function planPerModuleRouteTypesForFile(filePath: string): PerModuleRouteTypesPlan | null;
|
|
14
26
|
/**
|
|
15
27
|
* Generate per-module route types for a single url module file.
|
|
16
28
|
* Follows include() calls recursively to produce the full route tree.
|
|
@@ -37,6 +37,8 @@ export interface ShellFrameHead {
|
|
|
37
37
|
ta?: number;
|
|
38
38
|
/** ShellCacheEntry.initialTheme */
|
|
39
39
|
i?: string;
|
|
40
|
+
/** ShellCacheEntry.pathname (a visitor-keyed shell's rendered location). */
|
|
41
|
+
lp?: string;
|
|
40
42
|
/** ShellCacheEntry.docKey; navigation replay needs it after any round trip. */
|
|
41
43
|
dk?: string;
|
|
42
44
|
/** ShellCacheEntry.prunedRecords (diagnostic). */
|
|
@@ -412,6 +412,14 @@ export interface ShellCacheEntry {
|
|
|
412
412
|
* ThemeProvider.
|
|
413
413
|
*/
|
|
414
414
|
initialTheme?: string;
|
|
415
|
+
/**
|
|
416
|
+
* The payload pathname of a shell keyed by the visitor's URL
|
|
417
|
+
* (`rewrite(...).shell("visitor")`, visitorShellKey); absent when the
|
|
418
|
+
* capture rendered its key's own URL. The serve tail replays it as it does
|
|
419
|
+
* `initialTheme`, and the serve gate serves the entry only to a request
|
|
420
|
+
* that renders this location.
|
|
421
|
+
*/
|
|
422
|
+
pathname?: string;
|
|
415
423
|
/**
|
|
416
424
|
* The CAPTURE DATA SNAPSHOT, in stored/serialized form: the doc segment
|
|
417
425
|
* record every HIT replays the handler layer from (`docKey`) and the
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { type TrieNode } from "../router/route-trie-builder.js";
|
|
2
|
-
import type { ClientUrlBuilder, ClientUrlPatterns } from "./types.js";
|
|
2
|
+
import type { ClientUrlBuilder, ClientUrlHelpers, ClientUrlPatterns } from "./types.js";
|
|
3
3
|
import type { ExtractRoutes } from "../urls/type-extraction.js";
|
|
4
4
|
import type { ClientUrlItems } from "./types.js";
|
|
5
|
+
export declare const loader: ClientUrlHelpers["loader"];
|
|
6
|
+
export declare const revalidate: ClientUrlHelpers["revalidate"];
|
|
7
|
+
export declare const loading: ClientUrlHelpers["loading"];
|
|
8
|
+
export declare const transition: ClientUrlHelpers["transition"];
|
|
5
9
|
export declare function clientUrls<const TItems extends ClientUrlItems>(builder: ClientUrlBuilder<TItems>): ClientUrlPatterns<ExtractRoutes<TItems>>;
|
|
6
10
|
/**
|
|
7
11
|
* The router's trie over a group's routes, each pattern joined to the
|
|
@@ -24,4 +28,4 @@ export declare function buildClientUrlsTrie(routes: readonly {
|
|
|
24
28
|
readonly trailingSlash?: string;
|
|
25
29
|
};
|
|
26
30
|
}[], mount: string, foreign?: readonly string[]): TrieNode;
|
|
27
|
-
export type { ClientTransitionConfig, ClientUrlBuilder, ClientUrlHelpers, ClientUrlInterceptRecord, ClientUrlItem, ClientUrlItemInput, ClientUrlItems, ClientLayoutFn, ClientPathOptions, ClientUrlLoaderRecord, ClientPathFn, ClientUrlPatterns, ClientUrlRouteRecord, ClientUrlUse, } from "./types.js";
|
|
31
|
+
export type { ClientTransitionConfig, ClientUrlBuilder, ClientUrlComponent, ClientUrlHelpers, ClientUrlInterceptRecord, ClientUrlItem, ClientUrlItemInput, ClientUrlItems, ClientLayoutFn, ClientPathOptions, ClientUrlLoaderRecord, ClientPathFn, ClientUrlPatterns, ClientUrlRouteRecord, ClientUrlUse, } from "./types.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ShouldRevalidateFn } from "../types.js";
|
|
2
|
-
export declare function registerClientUrlRevalidators(fns: Readonly<Record<string, ShouldRevalidateFn<any, any
|
|
2
|
+
export declare function registerClientUrlRevalidators(fns: Readonly<Record<string, ShouldRevalidateFn<any, any> | boolean>>): void;
|
|
3
3
|
export declare function getClientUrlRevalidator(key: string): ShouldRevalidateFn<any, any> | undefined;
|
|
4
4
|
export declare function clearClientUrlRevalidators(): void;
|
|
@@ -38,11 +38,11 @@ export interface ClientUrlProjectionRoute {
|
|
|
38
38
|
* loader(), so a prefetch of the route defers them. Absent (= none) in
|
|
39
39
|
* projections serialized before the option existed. */
|
|
40
40
|
readonly deferrableLoaderIndices?: readonly number[];
|
|
41
|
-
/** Per loader (aligned with loaderIds),
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* loader declares one. */
|
|
45
|
-
readonly loaderRevalidate?: readonly (readonly string[])[];
|
|
41
|
+
/** Per loader (aligned with loaderIds), its revalidate() arguments in
|
|
42
|
+
* declaration order: a hoisted predicate's key, whose registration
|
|
43
|
+
* materialization attaches (revalidate-registry.ts), or a boolean
|
|
44
|
+
* literal. Absent when no loader declares one. */
|
|
45
|
+
readonly loaderRevalidate?: readonly (readonly (string | boolean)[])[];
|
|
46
46
|
/** One per leading loader its layout()s declare
|
|
47
47
|
* (ClientUrlRouteRecord.layoutLoaders): the record's ordinal in the
|
|
48
48
|
* definition. Two routes whose loader at an index carries the same ordinal
|
|
@@ -62,6 +62,10 @@ export interface ClientUrlProjectionIntercept {
|
|
|
62
62
|
readonly targetName: string;
|
|
63
63
|
readonly loaderIds: readonly string[];
|
|
64
64
|
readonly hasLoading: boolean;
|
|
65
|
+
/** As on a route (ClientUrlProjectionRoute.deferrableLoaderIndices). */
|
|
66
|
+
readonly deferrableLoaderIndices?: readonly number[];
|
|
67
|
+
/** As on a route (ClientUrlProjectionRoute.loaderRevalidate). */
|
|
68
|
+
readonly loaderRevalidate?: readonly (readonly (string | boolean)[])[];
|
|
65
69
|
}
|
|
66
70
|
export interface ClientUrlProjection {
|
|
67
71
|
readonly version: 1;
|
|
@@ -17,17 +17,29 @@ export interface ClientUrlItem {
|
|
|
17
17
|
export type ClientUrlItemInput = ClientUrlItem | readonly ClientUrlItemInput[];
|
|
18
18
|
export type ClientUrlItems = readonly ClientUrlItemInput[];
|
|
19
19
|
export type ClientUrlUse = () => ClientUrlItems;
|
|
20
|
+
/**
|
|
21
|
+
* A component path(), layout() or intercept() mounts. Its optional `use`
|
|
22
|
+
* carries its own items, as a server handler's `.use` does, built with the
|
|
23
|
+
* helpers `@rangojs/router/client` exports: they come before the mount
|
|
24
|
+
* site's explicit items (an explicit loading() or transition() wins, loaders
|
|
25
|
+
* accumulate). A page component may carry loader(), loading() and
|
|
26
|
+
* transition(); a layout or intercept component loader() and loading().
|
|
27
|
+
*/
|
|
28
|
+
export type ClientUrlComponent = ComponentType & {
|
|
29
|
+
readonly use?: ClientUrlUse;
|
|
30
|
+
};
|
|
20
31
|
export type ClientPathOptions<TName extends string = string, TSearch extends SearchSchema = SearchSchema> = Pick<PathOptions<TName, TSearch>, "name" | "search" | "trailingSlash" | "ppr">;
|
|
21
|
-
export type ClientPathFn = <const TPattern extends string, const TName extends string = UnnamedRoute, const TSearch extends SearchSchema = {}>(pattern: TPattern, component:
|
|
22
|
-
export type ClientLayoutFn = <const TItems extends ClientUrlItems>(component:
|
|
32
|
+
export type ClientPathFn = <const TPattern extends string, const TName extends string = UnnamedRoute, const TSearch extends SearchSchema = {}>(pattern: TPattern, component: ClientUrlComponent, optionsOrUse?: ClientPathOptions<TName, TSearch> | ClientUrlUse, use?: ClientUrlUse) => ClientUrlItem & TypedRouteItem<TName, TPattern, unknown, TSearch>;
|
|
33
|
+
export type ClientLayoutFn = <const TItems extends ClientUrlItems>(component: ClientUrlComponent, children: () => TItems) => ClientUrlItem & TypedLayoutItem<ExtractRoutes<TItems>>;
|
|
23
34
|
export interface ClientUrlLoaderRecord {
|
|
24
35
|
readonly loader: LoaderDefinition<any, any>;
|
|
25
36
|
/**
|
|
26
37
|
* Per-loader revalidate() predicates, run on the server; empty = the
|
|
27
38
|
* router's defaults. Under the rango Vite plugin the browser and SSR copies
|
|
28
|
-
* hold the marker the build left in place of each hoisted predicate
|
|
39
|
+
* hold the marker the build left in place of each hoisted predicate; a
|
|
40
|
+
* boolean literal stays in place.
|
|
29
41
|
*/
|
|
30
|
-
readonly revalidate: readonly (ShouldRevalidateFn<any, DefaultEnv> | HoistedRevalidateRef)[];
|
|
42
|
+
readonly revalidate: readonly (ShouldRevalidateFn<any, DefaultEnv> | HoistedRevalidateRef | boolean)[];
|
|
31
43
|
/**
|
|
32
44
|
* loader(Def, { ssr: false }): document renders await this loader before
|
|
33
45
|
* first flush (see {@link LoaderOptions}). Projected into the server tree,
|
|
@@ -36,11 +48,10 @@ export interface ClientUrlLoaderRecord {
|
|
|
36
48
|
*/
|
|
37
49
|
readonly ssr?: false;
|
|
38
50
|
/**
|
|
39
|
-
* loader(Def, { prefetch: false }): a prefetch of the route
|
|
40
|
-
*
|
|
41
|
-
* {@link LoaderOptions}).
|
|
42
|
-
*
|
|
43
|
-
* urls().
|
|
51
|
+
* loader(Def, { prefetch: false }): a prefetch of the route, or of an
|
|
52
|
+
* intercept's target from its source, defers this loader and the click
|
|
53
|
+
* that adopts it runs it in its fill request (see {@link LoaderOptions}).
|
|
54
|
+
* Projected onto the materialized stub.
|
|
44
55
|
*/
|
|
45
56
|
readonly prefetch?: false;
|
|
46
57
|
}
|
|
@@ -78,7 +89,7 @@ export interface ClientUrlRouteRecord {
|
|
|
78
89
|
}
|
|
79
90
|
/**
|
|
80
91
|
* A restricted intercept declared inside clientUrls(). Compared to the server
|
|
81
|
-
* intercept() there is no `when` selector,
|
|
92
|
+
* intercept() there is no `when` selector, and the target must
|
|
82
93
|
* be a dot-local NAMED route in the same definition — every field is
|
|
83
94
|
* JSON-projectable, which is what makes the declaration legal in a
|
|
84
95
|
* "use client" module. `targetName` is stored bare (no leading dot).
|
|
@@ -111,8 +122,8 @@ export interface ClientUrlHelpers {
|
|
|
111
122
|
* the destination at once, commits the adopted prefetch with the other
|
|
112
123
|
* loaders' data, and runs only the flagged loaders in its one fill
|
|
113
124
|
* request. A `layout()` loader with the flag is flagged on every route
|
|
114
|
-
* below it. Inside intercept() the
|
|
115
|
-
* urls().
|
|
125
|
+
* below it. Inside intercept() it defers the loader in a prefetch of the
|
|
126
|
+
* intercept from its source, as in urls().
|
|
116
127
|
*/
|
|
117
128
|
readonly loader: <TData>(definition: LoaderDefinition<TData>, optionsOrUse?: Pick<LoaderOptions, "ssr" | "prefetch"> | ClientUrlUse, use?: ClientUrlUse) => ClientUrlItem;
|
|
118
129
|
readonly loading: (component: ReactNode) => ClientUrlItem;
|
|
@@ -123,22 +134,24 @@ export interface ClientUrlHelpers {
|
|
|
123
134
|
* names, ...): the build moves it out of this "use client" module. It may
|
|
124
135
|
* reference imports and globals only; a binding of this module, `this`,
|
|
125
136
|
* `import()`, a browser global, an `async` function or an import from a
|
|
126
|
-
* "use client" module fails the build with its file and line.
|
|
137
|
+
* "use client" module fails the build with its file and line. A boolean
|
|
138
|
+
* is shorthand for `() => true` / `() => false`.
|
|
127
139
|
*/
|
|
128
|
-
readonly revalidate: (fn: ShouldRevalidateFn<any, DefaultEnv>) => ClientUrlItem;
|
|
140
|
+
readonly revalidate: (fn: ShouldRevalidateFn<any, DefaultEnv> | boolean) => ClientUrlItem;
|
|
129
141
|
/**
|
|
130
142
|
* Declare an intercept for a named route in THIS definition. The target is
|
|
131
143
|
* dot-local (`.detail`); scoping is module-local — only navigations whose
|
|
132
144
|
* origin is inside this clientUrls() group render the intercept. `use` may
|
|
133
145
|
* contain loader() and loading() only.
|
|
134
146
|
*/
|
|
135
|
-
readonly intercept: (slotName: `@${string}`, targetName: `.${string}`, component:
|
|
147
|
+
readonly intercept: (slotName: `@${string}`, targetName: `.${string}`, component: ClientUrlComponent, use?: ClientUrlUse) => ClientUrlItem;
|
|
136
148
|
/**
|
|
137
149
|
* Opt THIS route into transition-driven navigation: the canonical commit
|
|
138
150
|
* holds previous content instead of re-streaming the loading() fallback,
|
|
139
151
|
* and on experimental React the config's ViewTransition classes apply.
|
|
140
152
|
* Data-only — no `when` gate (server-executed; declare it in the server
|
|
141
|
-
* tree). Valid inside a path() use callback
|
|
153
|
+
* tree). Valid inside a path() use callback, or a page component's
|
|
154
|
+
* `.use`.
|
|
142
155
|
*/
|
|
143
156
|
readonly transition: (config: ClientTransitionConfig) => ClientUrlItem;
|
|
144
157
|
}
|
package/dist/types/client.d.ts
CHANGED
|
@@ -95,8 +95,8 @@ export interface OutletState {
|
|
|
95
95
|
}
|
|
96
96
|
export declare function useOutlet(): OutletState;
|
|
97
97
|
export { useLoader, useFetchLoader, useRefreshLoaders, type LoadFunction, type UseLoaderResult, type UseFetchLoaderResult, type UseLoaderOptions, } from "./use-loader.js";
|
|
98
|
-
export { clientUrls } from "./client-urls/client-urls.js";
|
|
99
|
-
export type { ClientUrlPatterns, ClientUrlRouteRecord, } from "./client-urls/client-urls.js";
|
|
98
|
+
export { clientUrls, loader, loading, revalidate, transition, } from "./client-urls/client-urls.js";
|
|
99
|
+
export type { ClientUrlComponent, ClientUrlPatterns, ClientUrlRouteRecord, ClientUrlUse, } from "./client-urls/client-urls.js";
|
|
100
100
|
/**
|
|
101
101
|
* Props for the ErrorBoundary component
|
|
102
102
|
*/
|
|
@@ -12,8 +12,8 @@ import * as Html from "./html.js";
|
|
|
12
12
|
export { Outlet, ParallelOutlet, useOutlet, type OutletState, useLoader, ErrorBoundary, type ErrorBoundaryProps, } from "./client.js";
|
|
13
13
|
export { useFetchLoader, useRefreshLoaders, type LoadFunction, type UseLoaderResult, type UseFetchLoaderResult, type UseLoaderOptions, } from "./use-loader.js";
|
|
14
14
|
export { createLoader } from "./route-definition.js";
|
|
15
|
-
export { clientUrls } from "./client-urls/client-urls.js";
|
|
16
|
-
export type { ClientUrlPatterns, ClientUrlRouteRecord, } from "./client-urls/client-urls.js";
|
|
15
|
+
export { clientUrls, loader, loading, revalidate, transition, } from "./client-urls/client-urls.js";
|
|
16
|
+
export type { ClientUrlComponent, ClientUrlPatterns, ClientUrlRouteRecord, ClientUrlUse, } from "./client-urls/client-urls.js";
|
|
17
17
|
export { useRouter } from "./browser/react/use-router.js";
|
|
18
18
|
export { usePathname } from "./browser/react/use-pathname.js";
|
|
19
19
|
export { useSearchParams } from "./browser/react/use-search-params.js";
|