react-router 0.0.0-experimental-c19b79d → 0.0.0-experimental-31a822c5f
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/CHANGELOG.md +105 -0
- package/dist/development/browser-B4aBBnx8.d.ts +310 -0
- package/dist/development/browser-CN2w9Cbu.d.mts +310 -0
- package/dist/development/{chunk-LUB73E44.js → chunk-CZ7KRWQZ.js} +827 -64
- package/dist/development/{chunk-AGOH44BE.mjs → chunk-FXUONXY4.mjs} +132 -808
- package/dist/development/chunk-SE36CWVW.js +1308 -0
- package/dist/development/chunk-T5RKBXBV.js +188 -0
- package/dist/development/{chunk-IMKEG5CI.mjs → chunk-WTUOISGV.mjs} +2 -2
- package/dist/development/dom-export.d.mts +48 -3
- package/dist/development/dom-export.d.ts +48 -1
- package/dist/development/dom-export.js +703 -18
- package/dist/development/dom-export.mjs +687 -9
- package/dist/development/{index-react-server-client-DKvU8YRr.d.ts → index-react-server-client-BOJoTiaG.d.ts} +134 -134
- package/dist/{production/index-react-server-client-2EDmGlsZ.d.mts → development/index-react-server-client-CuQLmpku.d.mts} +1 -2
- package/dist/development/index-react-server-client.d.mts +2 -3
- package/dist/development/index-react-server-client.d.ts +2 -2
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.js +1 -1
- package/dist/development/index-react-server.mjs +1 -1
- package/dist/development/index.d.mts +9 -316
- package/dist/development/index.d.ts +9 -358
- package/dist/development/index.js +82 -914
- package/dist/development/index.mjs +3 -9
- package/dist/development/lib/types/internal.d.mts +2 -3
- package/dist/development/lib/types/internal.d.ts +2 -2
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/{production/register-BrVEYTED.d.mts → development/register-BblEgJPm.d.mts} +1 -1
- package/dist/development/{register-D8NQoPsO.d.ts → register-D18raRVf.d.ts} +1 -1
- package/dist/development/{context-BqL5Eckq.d.mts → route-data-nQS6GSUI.d.mts} +472 -2
- package/dist/development/{routeModules-BmVo7q9e.d.ts → routeModules-9wlxglVk.d.ts} +12 -12
- package/dist/production/browser-B4aBBnx8.d.ts +310 -0
- package/dist/production/browser-CN2w9Cbu.d.mts +310 -0
- package/dist/production/{chunk-2L5AG5Y5.js → chunk-DRKUM6HW.js} +827 -64
- package/dist/production/{chunk-AODJW4D3.mjs → chunk-IGF74WUC.mjs} +132 -808
- package/dist/production/{chunk-UOQCOPF6.mjs → chunk-RUSRTUHT.mjs} +2 -2
- package/dist/production/chunk-UU3LJMU6.js +188 -0
- package/dist/production/chunk-YVVCGSEG.js +1308 -0
- package/dist/production/dom-export.d.mts +48 -3
- package/dist/production/dom-export.d.ts +48 -1
- package/dist/production/dom-export.js +703 -18
- package/dist/production/dom-export.mjs +687 -9
- package/dist/production/{index-react-server-client-DKvU8YRr.d.ts → index-react-server-client-BOJoTiaG.d.ts} +134 -134
- package/dist/{development/index-react-server-client-2EDmGlsZ.d.mts → production/index-react-server-client-CuQLmpku.d.mts} +1 -2
- package/dist/production/index-react-server-client.d.mts +2 -3
- package/dist/production/index-react-server-client.d.ts +2 -2
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.js +1 -1
- package/dist/production/index-react-server.mjs +1 -1
- package/dist/production/index.d.mts +9 -316
- package/dist/production/index.d.ts +9 -358
- package/dist/production/index.js +82 -914
- package/dist/production/index.mjs +3 -9
- package/dist/production/lib/types/internal.d.mts +2 -3
- package/dist/production/lib/types/internal.d.ts +2 -2
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/{development/register-BrVEYTED.d.mts → production/register-BblEgJPm.d.mts} +1 -1
- package/dist/production/{register-D8NQoPsO.d.ts → register-D18raRVf.d.ts} +1 -1
- package/dist/production/{context-BqL5Eckq.d.mts → route-data-nQS6GSUI.d.mts} +472 -2
- package/dist/production/{routeModules-BmVo7q9e.d.ts → routeModules-9wlxglVk.d.ts} +12 -12
- package/package.json +1 -1
- package/dist/development/browser-z32v5KVN.d.mts +0 -46
- package/dist/development/chunk-2G2U5HGB.js +0 -2089
- package/dist/development/route-data-CDwqkzPE.d.mts +0 -473
- package/dist/production/browser-z32v5KVN.d.mts +0 -46
- package/dist/production/chunk-FGRCWJDI.js +0 -2089
- package/dist/production/route-data-CDwqkzPE.d.mts +0 -473
|
@@ -1600,6 +1600,16 @@ interface CreateStaticHandlerOptions {
|
|
|
1600
1600
|
future?: {};
|
|
1601
1601
|
}
|
|
1602
1602
|
|
|
1603
|
+
/**
|
|
1604
|
+
* An object of unknown type for route loaders and actions provided by the
|
|
1605
|
+
* server's `getLoadContext()` function. This is defined as an empty interface
|
|
1606
|
+
* specifically so apps can leverage declaration merging to augment this type
|
|
1607
|
+
* globally: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
|
|
1608
|
+
*/
|
|
1609
|
+
interface AppLoadContext {
|
|
1610
|
+
[key: string]: unknown;
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1603
1613
|
declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
|
|
1604
1614
|
hasErrorBoundary: boolean;
|
|
1605
1615
|
};
|
|
@@ -2179,7 +2189,7 @@ interface RoutesProps {
|
|
|
2179
2189
|
* <Routes>
|
|
2180
2190
|
* <Route index element={<StepOne />} />
|
|
2181
2191
|
* <Route path="step-2" element={<StepTwo />} />
|
|
2182
|
-
* <Route path="step-3" element={<StepThree />}
|
|
2192
|
+
* <Route path="step-3" element={<StepThree />} />
|
|
2183
2193
|
* </Routes>
|
|
2184
2194
|
*
|
|
2185
2195
|
* @public
|
|
@@ -2676,16 +2686,6 @@ interface PageLinkDescriptor extends Omit<HtmlLinkDescriptor, "href" | "rel" | "
|
|
|
2676
2686
|
}
|
|
2677
2687
|
type LinkDescriptor = HtmlLinkDescriptor | PageLinkDescriptor;
|
|
2678
2688
|
|
|
2679
|
-
/**
|
|
2680
|
-
* An object of unknown type for route loaders and actions provided by the
|
|
2681
|
-
* server's `getLoadContext()` function. This is defined as an empty interface
|
|
2682
|
-
* specifically so apps can leverage declaration merging to augment this type
|
|
2683
|
-
* globally: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
|
|
2684
|
-
*/
|
|
2685
|
-
interface AppLoadContext {
|
|
2686
|
-
[key: string]: unknown;
|
|
2687
|
-
}
|
|
2688
|
-
|
|
2689
2689
|
type Serializable = undefined | null | boolean | string | symbol | number | Array<Serializable> | {
|
|
2690
2690
|
[key: PropertyKey]: Serializable;
|
|
2691
2691
|
} | bigint | Date | URL | RegExp | Error | Map<Serializable, Serializable> | Set<Serializable> | Promise<Serializable>;
|
|
@@ -3035,4 +3035,4 @@ type RouteComponent = ComponentType<{}>;
|
|
|
3035
3035
|
*/
|
|
3036
3036
|
type RouteHandle = unknown;
|
|
3037
3037
|
|
|
3038
|
-
export { type PatchRoutesOnNavigationFunction as $,
|
|
3038
|
+
export { type PatchRoutesOnNavigationFunction as $, type ActionFunction as A, type BlockerFunction as B, type ClientActionFunction as C, type DataStrategyResult as D, type RouteObject as E, type Func as F, type GetLoaderData as G, type HeadersFunction as H, type InitialEntry as I, type HydrationState as J, type IndexRouteObject as K, type Location as L, type MetaFunction as M, type Normalize as N, type RouteComponentType as O, type Params as P, type HydrateFallbackType as Q, type RouteModule$1 as R, type ShouldRevalidateFunction as S, type To as T, type UIMatch as U, type ErrorBoundaryType as V, type NonIndexRouteObject as W, type AppLoadContext as X, type MiddlewareEnabled as Y, type Equal as Z, type RouterState as _, type ClientLoaderFunction as a, Route as a$, type DataRouteObject as a0, type StaticHandler as a1, type GetScrollPositionFunction as a2, type GetScrollRestorationKeyFunction as a3, type StaticHandlerContext as a4, type Fetcher as a5, type NavigationStates as a6, type RouterSubscriber as a7, type RouterNavigateOptions as a8, type RouterFetchOptions as a9, matchRoutes as aA, redirect as aB, redirectDocument as aC, replace as aD, resolvePath as aE, type DataRouteMatch as aF, type Navigator as aG, type PatchRoutesOnNavigationFunctionArgs as aH, type RouteMatch as aI, AwaitContextProvider as aJ, type AwaitProps as aK, type IndexRouteProps as aL, type unstable_ClientOnErrorFunction as aM, type LayoutRouteProps as aN, type MemoryRouterOpts as aO, type MemoryRouterProps as aP, type NavigateProps as aQ, type OutletProps as aR, type PathRouteProps as aS, type RouteProps as aT, type RouterProps as aU, type RouterProviderProps as aV, type RoutesProps as aW, Await as aX, MemoryRouter as aY, Navigate as aZ, Outlet as a_, type RevalidationState as aa, type ActionFunctionArgs as ab, type DataStrategyFunctionArgs as ac, type DataStrategyMatch as ad, DataWithResponseInit as ae, type ErrorResponse as af, type FormEncType as ag, type FormMethod as ah, type HTMLFormMethod as ai, type LazyRouteFunction as aj, type LoaderFunctionArgs as ak, type MiddlewareFunction as al, type PathParam as am, type RedirectFunction as an, type RouterContext as ao, type ShouldRevalidateFunctionArgs as ap, createContext as aq, createPath as ar, parsePath as as, IDLE_NAVIGATION as at, IDLE_FETCHER as au, IDLE_BLOCKER as av, data as aw, generatePath as ax, isRouteErrorResponse as ay, matchPath as az, type LinksFunction as b, Router as b0, RouterProvider as b1, Routes as b2, createMemoryRouter as b3, createRoutesFromChildren as b4, createRoutesFromElements as b5, renderMatches as b6, type ClientActionFunctionArgs as b7, type ClientLoaderFunctionArgs as b8, type HeadersArgs as b9, type History as bA, type FutureConfig as bB, type CreateStaticHandlerOptions as bC, type MetaArgs as ba, type PageLinkDescriptor as bb, type HtmlLinkDescriptor as bc, type Future as bd, type unstable_SerializesTo as be, createBrowserHistory as bf, invariant as bg, createRouter as bh, ErrorResponseImpl as bi, DataRouterContext as bj, DataRouterStateContext as bk, FetchersContext as bl, LocationContext as bm, NavigationContext as bn, RouteContext as bo, ViewTransitionContext as bp, hydrationRouteProperties as bq, mapRouteProperties as br, WithComponentProps as bs, withComponentProps as bt, WithHydrateFallbackProps as bu, withHydrateFallbackProps as bv, WithErrorBoundaryProps as bw, withErrorBoundaryProps as bx, type RouteManifest as by, type ServerRouteModule as bz, RouterContextProvider as c, type LoaderFunction as d, type RouterInit as e, type LinkDescriptor as f, type Pretty as g, type MetaDescriptor as h, type ServerDataFunctionArgs as i, type MiddlewareNextFunction as j, type ClientDataFunctionArgs as k, type ServerDataFrom as l, type GetActionData as m, type Router$1 as n, type RouteModules as o, type DataStrategyFunction as p, type NavigateOptions as q, type Blocker as r, type SerializeFrom as s, type RelativeRoutingType as t, type ParamParseKey as u, type Path as v, type PathPattern as w, type PathMatch as x, type Navigation as y, Action as z };
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction, e as RouterInit } from './routeModules-9wlxglVk.js';
|
|
3
|
+
|
|
4
|
+
type RSCRouteConfigEntryBase = {
|
|
5
|
+
action?: ActionFunction;
|
|
6
|
+
clientAction?: ClientActionFunction;
|
|
7
|
+
clientLoader?: ClientLoaderFunction;
|
|
8
|
+
ErrorBoundary?: React.ComponentType<any>;
|
|
9
|
+
handle?: any;
|
|
10
|
+
headers?: HeadersFunction;
|
|
11
|
+
HydrateFallback?: React.ComponentType<any>;
|
|
12
|
+
Layout?: React.ComponentType<any>;
|
|
13
|
+
links?: LinksFunction;
|
|
14
|
+
loader?: LoaderFunction;
|
|
15
|
+
meta?: MetaFunction;
|
|
16
|
+
shouldRevalidate?: ShouldRevalidateFunction;
|
|
17
|
+
};
|
|
18
|
+
type RSCRouteConfigEntry = RSCRouteConfigEntryBase & {
|
|
19
|
+
id: string;
|
|
20
|
+
path?: string;
|
|
21
|
+
Component?: React.ComponentType<any>;
|
|
22
|
+
lazy?: () => Promise<RSCRouteConfigEntryBase & ({
|
|
23
|
+
default?: React.ComponentType<any>;
|
|
24
|
+
Component?: never;
|
|
25
|
+
} | {
|
|
26
|
+
default?: never;
|
|
27
|
+
Component?: React.ComponentType<any>;
|
|
28
|
+
})>;
|
|
29
|
+
} & ({
|
|
30
|
+
index: true;
|
|
31
|
+
} | {
|
|
32
|
+
children?: RSCRouteConfigEntry[];
|
|
33
|
+
});
|
|
34
|
+
type RSCRouteConfig = Array<RSCRouteConfigEntry>;
|
|
35
|
+
type RSCRouteManifest = {
|
|
36
|
+
clientAction?: ClientActionFunction;
|
|
37
|
+
clientLoader?: ClientLoaderFunction;
|
|
38
|
+
element?: React.ReactElement | false;
|
|
39
|
+
errorElement?: React.ReactElement;
|
|
40
|
+
handle?: any;
|
|
41
|
+
hasAction: boolean;
|
|
42
|
+
hasComponent: boolean;
|
|
43
|
+
hasErrorBoundary: boolean;
|
|
44
|
+
hasLoader: boolean;
|
|
45
|
+
hydrateFallbackElement?: React.ReactElement;
|
|
46
|
+
id: string;
|
|
47
|
+
index?: boolean;
|
|
48
|
+
links?: LinksFunction;
|
|
49
|
+
meta?: MetaFunction;
|
|
50
|
+
parentId?: string;
|
|
51
|
+
path?: string;
|
|
52
|
+
shouldRevalidate?: ShouldRevalidateFunction;
|
|
53
|
+
};
|
|
54
|
+
type RSCRouteMatch = RSCRouteManifest & {
|
|
55
|
+
params: Params;
|
|
56
|
+
pathname: string;
|
|
57
|
+
pathnameBase: string;
|
|
58
|
+
};
|
|
59
|
+
type RSCRenderPayload = {
|
|
60
|
+
type: "render";
|
|
61
|
+
actionData: Record<string, any> | null;
|
|
62
|
+
basename: string | undefined;
|
|
63
|
+
errors: Record<string, any> | null;
|
|
64
|
+
loaderData: Record<string, any>;
|
|
65
|
+
location: Location;
|
|
66
|
+
matches: RSCRouteMatch[];
|
|
67
|
+
patches?: RSCRouteManifest[];
|
|
68
|
+
nonce?: string;
|
|
69
|
+
formState?: unknown;
|
|
70
|
+
};
|
|
71
|
+
type RSCManifestPayload = {
|
|
72
|
+
type: "manifest";
|
|
73
|
+
patches: RSCRouteManifest[];
|
|
74
|
+
};
|
|
75
|
+
type RSCActionPayload = {
|
|
76
|
+
type: "action";
|
|
77
|
+
actionResult: Promise<unknown>;
|
|
78
|
+
rerender?: Promise<RSCRenderPayload | RSCRedirectPayload>;
|
|
79
|
+
};
|
|
80
|
+
type RSCRedirectPayload = {
|
|
81
|
+
type: "redirect";
|
|
82
|
+
status: number;
|
|
83
|
+
location: string;
|
|
84
|
+
replace: boolean;
|
|
85
|
+
reload: boolean;
|
|
86
|
+
actionResult?: Promise<unknown>;
|
|
87
|
+
};
|
|
88
|
+
type RSCPayload = RSCRenderPayload | RSCManifestPayload | RSCActionPayload | RSCRedirectPayload;
|
|
89
|
+
type RSCMatch = {
|
|
90
|
+
statusCode: number;
|
|
91
|
+
headers: Headers;
|
|
92
|
+
payload: RSCPayload;
|
|
93
|
+
};
|
|
94
|
+
type DecodeActionFunction = (formData: FormData) => Promise<() => Promise<unknown>>;
|
|
95
|
+
type DecodeFormStateFunction = (result: unknown, formData: FormData) => unknown;
|
|
96
|
+
type DecodeReplyFunction = (reply: FormData | string, { temporaryReferences }: {
|
|
97
|
+
temporaryReferences: unknown;
|
|
98
|
+
}) => Promise<unknown[]>;
|
|
99
|
+
type LoadServerActionFunction = (id: string) => Promise<Function>;
|
|
100
|
+
/**
|
|
101
|
+
* Matches the given routes to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
102
|
+
* and returns an [RSC](https://react.dev/reference/rsc/server-components)
|
|
103
|
+
* [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
104
|
+
* encoding an {@link unstable_RSCPayload} for consumption by an [RSC](https://react.dev/reference/rsc/server-components)
|
|
105
|
+
* enabled client router.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* import {
|
|
109
|
+
* createTemporaryReferenceSet,
|
|
110
|
+
* decodeAction,
|
|
111
|
+
* decodeReply,
|
|
112
|
+
* loadServerAction,
|
|
113
|
+
* renderToReadableStream,
|
|
114
|
+
* } from "@vitejs/plugin-rsc/rsc";
|
|
115
|
+
* import { unstable_matchRSCServerRequest as matchRSCServerRequest } from "react-router";
|
|
116
|
+
*
|
|
117
|
+
* matchRSCServerRequest({
|
|
118
|
+
* createTemporaryReferenceSet,
|
|
119
|
+
* decodeAction,
|
|
120
|
+
* decodeFormState,
|
|
121
|
+
* decodeReply,
|
|
122
|
+
* loadServerAction,
|
|
123
|
+
* request,
|
|
124
|
+
* routes: routes(),
|
|
125
|
+
* generateResponse(match) {
|
|
126
|
+
* return new Response(
|
|
127
|
+
* renderToReadableStream(match.payload),
|
|
128
|
+
* {
|
|
129
|
+
* status: match.statusCode,
|
|
130
|
+
* headers: match.headers,
|
|
131
|
+
* }
|
|
132
|
+
* );
|
|
133
|
+
* },
|
|
134
|
+
* });
|
|
135
|
+
*
|
|
136
|
+
* @name unstable_matchRSCServerRequest
|
|
137
|
+
* @public
|
|
138
|
+
* @category RSC
|
|
139
|
+
* @mode data
|
|
140
|
+
* @param opts Options
|
|
141
|
+
* @param opts.basename The basename to use when matching the request.
|
|
142
|
+
* @param opts.createTemporaryReferenceSet A function that returns a temporary
|
|
143
|
+
* reference set for the request, used to track temporary references in the [RSC](https://react.dev/reference/rsc/server-components)
|
|
144
|
+
* stream.
|
|
145
|
+
* @param opts.decodeAction Your `react-server-dom-xyz/server`'s `decodeAction`
|
|
146
|
+
* function, responsible for loading a server action.
|
|
147
|
+
* @param opts.decodeFormState A function responsible for decoding form state for
|
|
148
|
+
* progressively enhanceable forms with React's [`useActionState`](https://react.dev/reference/react/useActionState)
|
|
149
|
+
* using your `react-server-dom-xyz/server`'s `decodeFormState`.
|
|
150
|
+
* @param opts.decodeReply Your `react-server-dom-xyz/server`'s `decodeReply`
|
|
151
|
+
* function, used to decode the server function's arguments and bind them to the
|
|
152
|
+
* implementation for invocation by the router.
|
|
153
|
+
* @param opts.generateResponse A function responsible for using your
|
|
154
|
+
* `renderToReadableStream` to generate a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
155
|
+
* encoding the {@link unstable_RSCPayload}.
|
|
156
|
+
* @param opts.loadServerAction Your `react-server-dom-xyz/server`'s
|
|
157
|
+
* `loadServerAction` function, used to load a server action by ID.
|
|
158
|
+
* @param opts.onError An optional error handler that will be called with any
|
|
159
|
+
* errors that occur during the request processing.
|
|
160
|
+
* @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
161
|
+
* to match against.
|
|
162
|
+
* @param opts.requestContext An instance of {@link RouterContextProvider}
|
|
163
|
+
* that should be created per request, to be passed to [`action`](../../start/data/route-object#action)s,
|
|
164
|
+
* [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
|
|
165
|
+
* @param opts.routes Your {@link unstable_RSCRouteConfigEntry | route definitions}.
|
|
166
|
+
* @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
167
|
+
* that contains the [RSC](https://react.dev/reference/rsc/server-components)
|
|
168
|
+
* data for hydration.
|
|
169
|
+
*/
|
|
170
|
+
declare function matchRSCServerRequest({ createTemporaryReferenceSet, basename, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, request, routes, generateResponse, }: {
|
|
171
|
+
createTemporaryReferenceSet: () => unknown;
|
|
172
|
+
basename?: string;
|
|
173
|
+
decodeReply?: DecodeReplyFunction;
|
|
174
|
+
decodeAction?: DecodeActionFunction;
|
|
175
|
+
decodeFormState?: DecodeFormStateFunction;
|
|
176
|
+
requestContext?: RouterContextProvider;
|
|
177
|
+
loadServerAction?: LoadServerActionFunction;
|
|
178
|
+
onError?: (error: unknown) => void;
|
|
179
|
+
request: Request;
|
|
180
|
+
routes: RSCRouteConfigEntry[];
|
|
181
|
+
generateResponse: (match: RSCMatch, { temporaryReferences, }: {
|
|
182
|
+
temporaryReferences: unknown;
|
|
183
|
+
}) => Response;
|
|
184
|
+
}): Promise<Response>;
|
|
185
|
+
|
|
186
|
+
type BrowserCreateFromReadableStreamFunction = (body: ReadableStream<Uint8Array>, { temporaryReferences, }: {
|
|
187
|
+
temporaryReferences: unknown;
|
|
188
|
+
}) => Promise<unknown>;
|
|
189
|
+
type EncodeReplyFunction = (args: unknown[], options: {
|
|
190
|
+
temporaryReferences: unknown;
|
|
191
|
+
}) => Promise<BodyInit>;
|
|
192
|
+
/**
|
|
193
|
+
* Create a React `callServer` implementation for React Router.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* import {
|
|
197
|
+
* createFromReadableStream,
|
|
198
|
+
* createTemporaryReferenceSet,
|
|
199
|
+
* encodeReply,
|
|
200
|
+
* setServerCallback,
|
|
201
|
+
* } from "@vitejs/plugin-rsc/browser";
|
|
202
|
+
* import { unstable_createCallServer as createCallServer } from "react-router";
|
|
203
|
+
*
|
|
204
|
+
* setServerCallback(
|
|
205
|
+
* createCallServer({
|
|
206
|
+
* createFromReadableStream,
|
|
207
|
+
* createTemporaryReferenceSet,
|
|
208
|
+
* encodeReply,
|
|
209
|
+
* })
|
|
210
|
+
* );
|
|
211
|
+
*
|
|
212
|
+
* @name unstable_createCallServer
|
|
213
|
+
* @public
|
|
214
|
+
* @category RSC
|
|
215
|
+
* @mode data
|
|
216
|
+
* @param opts Options
|
|
217
|
+
* @param opts.createFromReadableStream Your `react-server-dom-xyz/client`'s
|
|
218
|
+
* `createFromReadableStream`. Used to decode payloads from the server.
|
|
219
|
+
* @param opts.createTemporaryReferenceSet A function that creates a temporary
|
|
220
|
+
* reference set for the [RSC](https://react.dev/reference/rsc/server-components)
|
|
221
|
+
* payload.
|
|
222
|
+
* @param opts.encodeReply Your `react-server-dom-xyz/client`'s `encodeReply`.
|
|
223
|
+
* Used when sending payloads to the server.
|
|
224
|
+
* @param opts.fetch Optional [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
|
|
225
|
+
* implementation. Defaults to global [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch).
|
|
226
|
+
* @returns A function that can be used to call server actions.
|
|
227
|
+
*/
|
|
228
|
+
declare function createCallServer({ createFromReadableStream, createTemporaryReferenceSet, encodeReply, fetch: fetchImplementation, }: {
|
|
229
|
+
createFromReadableStream: BrowserCreateFromReadableStreamFunction;
|
|
230
|
+
createTemporaryReferenceSet: () => unknown;
|
|
231
|
+
encodeReply: EncodeReplyFunction;
|
|
232
|
+
fetch?: (request: Request) => Promise<Response>;
|
|
233
|
+
}): (id: string, args: unknown[]) => Promise<unknown>;
|
|
234
|
+
/**
|
|
235
|
+
* Props for the {@link unstable_RSCHydratedRouter} component.
|
|
236
|
+
*
|
|
237
|
+
* @name unstable_RSCHydratedRouterProps
|
|
238
|
+
* @category Types
|
|
239
|
+
*/
|
|
240
|
+
interface RSCHydratedRouterProps {
|
|
241
|
+
/**
|
|
242
|
+
* Your `react-server-dom-xyz/client`'s `createFromReadableStream` function,
|
|
243
|
+
* used to decode payloads from the server.
|
|
244
|
+
*/
|
|
245
|
+
createFromReadableStream: BrowserCreateFromReadableStreamFunction;
|
|
246
|
+
/**
|
|
247
|
+
* Optional fetch implementation. Defaults to global [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch).
|
|
248
|
+
*/
|
|
249
|
+
fetch?: (request: Request) => Promise<Response>;
|
|
250
|
+
/**
|
|
251
|
+
* The decoded {@link unstable_RSCPayload} to hydrate.
|
|
252
|
+
*/
|
|
253
|
+
payload: RSCPayload;
|
|
254
|
+
/**
|
|
255
|
+
* `"eager"` or `"lazy"` - Determines if links are eagerly discovered, or
|
|
256
|
+
* delayed until clicked.
|
|
257
|
+
*/
|
|
258
|
+
routeDiscovery?: "eager" | "lazy";
|
|
259
|
+
/**
|
|
260
|
+
* A function that returns an {@link RouterContextProvider} instance
|
|
261
|
+
* which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
|
|
262
|
+
* [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
|
|
263
|
+
* This function is called to generate a fresh `context` instance on each
|
|
264
|
+
* navigation or fetcher call.
|
|
265
|
+
*/
|
|
266
|
+
getContext?: RouterInit["getContext"];
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Hydrates a server rendered {@link unstable_RSCPayload} in the browser.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* import { startTransition, StrictMode } from "react";
|
|
273
|
+
* import { hydrateRoot } from "react-dom/client";
|
|
274
|
+
* import {
|
|
275
|
+
* unstable_getRSCStream as getRSCStream,
|
|
276
|
+
* unstable_RSCHydratedRouter as RSCHydratedRouter,
|
|
277
|
+
* } from "react-router";
|
|
278
|
+
* import type { unstable_RSCPayload as RSCPayload } from "react-router";
|
|
279
|
+
*
|
|
280
|
+
* createFromReadableStream(getRSCStream()).then((payload) =>
|
|
281
|
+
* startTransition(async () => {
|
|
282
|
+
* hydrateRoot(
|
|
283
|
+
* document,
|
|
284
|
+
* <StrictMode>
|
|
285
|
+
* <RSCHydratedRouter
|
|
286
|
+
* createFromReadableStream={createFromReadableStream}
|
|
287
|
+
* payload={payload}
|
|
288
|
+
* />
|
|
289
|
+
* </StrictMode>,
|
|
290
|
+
* { formState: await getFormState(payload) },
|
|
291
|
+
* );
|
|
292
|
+
* }),
|
|
293
|
+
* );
|
|
294
|
+
*
|
|
295
|
+
* @name unstable_RSCHydratedRouter
|
|
296
|
+
* @public
|
|
297
|
+
* @category RSC
|
|
298
|
+
* @mode data
|
|
299
|
+
* @param props Props
|
|
300
|
+
* @param {unstable_RSCHydratedRouterProps.createFromReadableStream} props.createFromReadableStream n/a
|
|
301
|
+
* @param {unstable_RSCHydratedRouterProps.fetch} props.fetch n/a
|
|
302
|
+
* @param {unstable_RSCHydratedRouterProps.getContext} props.getContext n/a
|
|
303
|
+
* @param {unstable_RSCHydratedRouterProps.payload} props.payload n/a
|
|
304
|
+
* @param {unstable_RSCHydratedRouterProps.routeDiscovery} props.routeDiscovery n/a
|
|
305
|
+
* @returns A hydrated {@link DataRouter} that can be used to navigate and
|
|
306
|
+
* render routes.
|
|
307
|
+
*/
|
|
308
|
+
declare function RSCHydratedRouter({ createFromReadableStream, fetch: fetchImplementation, payload, routeDiscovery, getContext, }: RSCHydratedRouterProps): React.JSX.Element;
|
|
309
|
+
|
|
310
|
+
export { type BrowserCreateFromReadableStreamFunction as B, type DecodeActionFunction as D, type EncodeReplyFunction as E, type LoadServerActionFunction as L, RSCHydratedRouter as R, type DecodeFormStateFunction as a, type DecodeReplyFunction as b, createCallServer as c, type RSCManifestPayload as d, type RSCPayload as e, type RSCRenderPayload as f, type RSCHydratedRouterProps as g, type RSCMatch as h, type RSCRouteManifest as i, type RSCRouteMatch as j, type RSCRouteConfigEntry as k, type RSCRouteConfig as l, matchRSCServerRequest as m };
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction, e as RouterInit } from './route-data-nQS6GSUI.mjs';
|
|
3
|
+
|
|
4
|
+
type RSCRouteConfigEntryBase = {
|
|
5
|
+
action?: ActionFunction;
|
|
6
|
+
clientAction?: ClientActionFunction;
|
|
7
|
+
clientLoader?: ClientLoaderFunction;
|
|
8
|
+
ErrorBoundary?: React.ComponentType<any>;
|
|
9
|
+
handle?: any;
|
|
10
|
+
headers?: HeadersFunction;
|
|
11
|
+
HydrateFallback?: React.ComponentType<any>;
|
|
12
|
+
Layout?: React.ComponentType<any>;
|
|
13
|
+
links?: LinksFunction;
|
|
14
|
+
loader?: LoaderFunction;
|
|
15
|
+
meta?: MetaFunction;
|
|
16
|
+
shouldRevalidate?: ShouldRevalidateFunction;
|
|
17
|
+
};
|
|
18
|
+
type RSCRouteConfigEntry = RSCRouteConfigEntryBase & {
|
|
19
|
+
id: string;
|
|
20
|
+
path?: string;
|
|
21
|
+
Component?: React.ComponentType<any>;
|
|
22
|
+
lazy?: () => Promise<RSCRouteConfigEntryBase & ({
|
|
23
|
+
default?: React.ComponentType<any>;
|
|
24
|
+
Component?: never;
|
|
25
|
+
} | {
|
|
26
|
+
default?: never;
|
|
27
|
+
Component?: React.ComponentType<any>;
|
|
28
|
+
})>;
|
|
29
|
+
} & ({
|
|
30
|
+
index: true;
|
|
31
|
+
} | {
|
|
32
|
+
children?: RSCRouteConfigEntry[];
|
|
33
|
+
});
|
|
34
|
+
type RSCRouteConfig = Array<RSCRouteConfigEntry>;
|
|
35
|
+
type RSCRouteManifest = {
|
|
36
|
+
clientAction?: ClientActionFunction;
|
|
37
|
+
clientLoader?: ClientLoaderFunction;
|
|
38
|
+
element?: React.ReactElement | false;
|
|
39
|
+
errorElement?: React.ReactElement;
|
|
40
|
+
handle?: any;
|
|
41
|
+
hasAction: boolean;
|
|
42
|
+
hasComponent: boolean;
|
|
43
|
+
hasErrorBoundary: boolean;
|
|
44
|
+
hasLoader: boolean;
|
|
45
|
+
hydrateFallbackElement?: React.ReactElement;
|
|
46
|
+
id: string;
|
|
47
|
+
index?: boolean;
|
|
48
|
+
links?: LinksFunction;
|
|
49
|
+
meta?: MetaFunction;
|
|
50
|
+
parentId?: string;
|
|
51
|
+
path?: string;
|
|
52
|
+
shouldRevalidate?: ShouldRevalidateFunction;
|
|
53
|
+
};
|
|
54
|
+
type RSCRouteMatch = RSCRouteManifest & {
|
|
55
|
+
params: Params;
|
|
56
|
+
pathname: string;
|
|
57
|
+
pathnameBase: string;
|
|
58
|
+
};
|
|
59
|
+
type RSCRenderPayload = {
|
|
60
|
+
type: "render";
|
|
61
|
+
actionData: Record<string, any> | null;
|
|
62
|
+
basename: string | undefined;
|
|
63
|
+
errors: Record<string, any> | null;
|
|
64
|
+
loaderData: Record<string, any>;
|
|
65
|
+
location: Location;
|
|
66
|
+
matches: RSCRouteMatch[];
|
|
67
|
+
patches?: RSCRouteManifest[];
|
|
68
|
+
nonce?: string;
|
|
69
|
+
formState?: unknown;
|
|
70
|
+
};
|
|
71
|
+
type RSCManifestPayload = {
|
|
72
|
+
type: "manifest";
|
|
73
|
+
patches: RSCRouteManifest[];
|
|
74
|
+
};
|
|
75
|
+
type RSCActionPayload = {
|
|
76
|
+
type: "action";
|
|
77
|
+
actionResult: Promise<unknown>;
|
|
78
|
+
rerender?: Promise<RSCRenderPayload | RSCRedirectPayload>;
|
|
79
|
+
};
|
|
80
|
+
type RSCRedirectPayload = {
|
|
81
|
+
type: "redirect";
|
|
82
|
+
status: number;
|
|
83
|
+
location: string;
|
|
84
|
+
replace: boolean;
|
|
85
|
+
reload: boolean;
|
|
86
|
+
actionResult?: Promise<unknown>;
|
|
87
|
+
};
|
|
88
|
+
type RSCPayload = RSCRenderPayload | RSCManifestPayload | RSCActionPayload | RSCRedirectPayload;
|
|
89
|
+
type RSCMatch = {
|
|
90
|
+
statusCode: number;
|
|
91
|
+
headers: Headers;
|
|
92
|
+
payload: RSCPayload;
|
|
93
|
+
};
|
|
94
|
+
type DecodeActionFunction = (formData: FormData) => Promise<() => Promise<unknown>>;
|
|
95
|
+
type DecodeFormStateFunction = (result: unknown, formData: FormData) => unknown;
|
|
96
|
+
type DecodeReplyFunction = (reply: FormData | string, { temporaryReferences }: {
|
|
97
|
+
temporaryReferences: unknown;
|
|
98
|
+
}) => Promise<unknown[]>;
|
|
99
|
+
type LoadServerActionFunction = (id: string) => Promise<Function>;
|
|
100
|
+
/**
|
|
101
|
+
* Matches the given routes to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
102
|
+
* and returns an [RSC](https://react.dev/reference/rsc/server-components)
|
|
103
|
+
* [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
104
|
+
* encoding an {@link unstable_RSCPayload} for consumption by an [RSC](https://react.dev/reference/rsc/server-components)
|
|
105
|
+
* enabled client router.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* import {
|
|
109
|
+
* createTemporaryReferenceSet,
|
|
110
|
+
* decodeAction,
|
|
111
|
+
* decodeReply,
|
|
112
|
+
* loadServerAction,
|
|
113
|
+
* renderToReadableStream,
|
|
114
|
+
* } from "@vitejs/plugin-rsc/rsc";
|
|
115
|
+
* import { unstable_matchRSCServerRequest as matchRSCServerRequest } from "react-router";
|
|
116
|
+
*
|
|
117
|
+
* matchRSCServerRequest({
|
|
118
|
+
* createTemporaryReferenceSet,
|
|
119
|
+
* decodeAction,
|
|
120
|
+
* decodeFormState,
|
|
121
|
+
* decodeReply,
|
|
122
|
+
* loadServerAction,
|
|
123
|
+
* request,
|
|
124
|
+
* routes: routes(),
|
|
125
|
+
* generateResponse(match) {
|
|
126
|
+
* return new Response(
|
|
127
|
+
* renderToReadableStream(match.payload),
|
|
128
|
+
* {
|
|
129
|
+
* status: match.statusCode,
|
|
130
|
+
* headers: match.headers,
|
|
131
|
+
* }
|
|
132
|
+
* );
|
|
133
|
+
* },
|
|
134
|
+
* });
|
|
135
|
+
*
|
|
136
|
+
* @name unstable_matchRSCServerRequest
|
|
137
|
+
* @public
|
|
138
|
+
* @category RSC
|
|
139
|
+
* @mode data
|
|
140
|
+
* @param opts Options
|
|
141
|
+
* @param opts.basename The basename to use when matching the request.
|
|
142
|
+
* @param opts.createTemporaryReferenceSet A function that returns a temporary
|
|
143
|
+
* reference set for the request, used to track temporary references in the [RSC](https://react.dev/reference/rsc/server-components)
|
|
144
|
+
* stream.
|
|
145
|
+
* @param opts.decodeAction Your `react-server-dom-xyz/server`'s `decodeAction`
|
|
146
|
+
* function, responsible for loading a server action.
|
|
147
|
+
* @param opts.decodeFormState A function responsible for decoding form state for
|
|
148
|
+
* progressively enhanceable forms with React's [`useActionState`](https://react.dev/reference/react/useActionState)
|
|
149
|
+
* using your `react-server-dom-xyz/server`'s `decodeFormState`.
|
|
150
|
+
* @param opts.decodeReply Your `react-server-dom-xyz/server`'s `decodeReply`
|
|
151
|
+
* function, used to decode the server function's arguments and bind them to the
|
|
152
|
+
* implementation for invocation by the router.
|
|
153
|
+
* @param opts.generateResponse A function responsible for using your
|
|
154
|
+
* `renderToReadableStream` to generate a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
155
|
+
* encoding the {@link unstable_RSCPayload}.
|
|
156
|
+
* @param opts.loadServerAction Your `react-server-dom-xyz/server`'s
|
|
157
|
+
* `loadServerAction` function, used to load a server action by ID.
|
|
158
|
+
* @param opts.onError An optional error handler that will be called with any
|
|
159
|
+
* errors that occur during the request processing.
|
|
160
|
+
* @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
161
|
+
* to match against.
|
|
162
|
+
* @param opts.requestContext An instance of {@link RouterContextProvider}
|
|
163
|
+
* that should be created per request, to be passed to [`action`](../../start/data/route-object#action)s,
|
|
164
|
+
* [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
|
|
165
|
+
* @param opts.routes Your {@link unstable_RSCRouteConfigEntry | route definitions}.
|
|
166
|
+
* @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
167
|
+
* that contains the [RSC](https://react.dev/reference/rsc/server-components)
|
|
168
|
+
* data for hydration.
|
|
169
|
+
*/
|
|
170
|
+
declare function matchRSCServerRequest({ createTemporaryReferenceSet, basename, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, request, routes, generateResponse, }: {
|
|
171
|
+
createTemporaryReferenceSet: () => unknown;
|
|
172
|
+
basename?: string;
|
|
173
|
+
decodeReply?: DecodeReplyFunction;
|
|
174
|
+
decodeAction?: DecodeActionFunction;
|
|
175
|
+
decodeFormState?: DecodeFormStateFunction;
|
|
176
|
+
requestContext?: RouterContextProvider;
|
|
177
|
+
loadServerAction?: LoadServerActionFunction;
|
|
178
|
+
onError?: (error: unknown) => void;
|
|
179
|
+
request: Request;
|
|
180
|
+
routes: RSCRouteConfigEntry[];
|
|
181
|
+
generateResponse: (match: RSCMatch, { temporaryReferences, }: {
|
|
182
|
+
temporaryReferences: unknown;
|
|
183
|
+
}) => Response;
|
|
184
|
+
}): Promise<Response>;
|
|
185
|
+
|
|
186
|
+
type BrowserCreateFromReadableStreamFunction = (body: ReadableStream<Uint8Array>, { temporaryReferences, }: {
|
|
187
|
+
temporaryReferences: unknown;
|
|
188
|
+
}) => Promise<unknown>;
|
|
189
|
+
type EncodeReplyFunction = (args: unknown[], options: {
|
|
190
|
+
temporaryReferences: unknown;
|
|
191
|
+
}) => Promise<BodyInit>;
|
|
192
|
+
/**
|
|
193
|
+
* Create a React `callServer` implementation for React Router.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* import {
|
|
197
|
+
* createFromReadableStream,
|
|
198
|
+
* createTemporaryReferenceSet,
|
|
199
|
+
* encodeReply,
|
|
200
|
+
* setServerCallback,
|
|
201
|
+
* } from "@vitejs/plugin-rsc/browser";
|
|
202
|
+
* import { unstable_createCallServer as createCallServer } from "react-router";
|
|
203
|
+
*
|
|
204
|
+
* setServerCallback(
|
|
205
|
+
* createCallServer({
|
|
206
|
+
* createFromReadableStream,
|
|
207
|
+
* createTemporaryReferenceSet,
|
|
208
|
+
* encodeReply,
|
|
209
|
+
* })
|
|
210
|
+
* );
|
|
211
|
+
*
|
|
212
|
+
* @name unstable_createCallServer
|
|
213
|
+
* @public
|
|
214
|
+
* @category RSC
|
|
215
|
+
* @mode data
|
|
216
|
+
* @param opts Options
|
|
217
|
+
* @param opts.createFromReadableStream Your `react-server-dom-xyz/client`'s
|
|
218
|
+
* `createFromReadableStream`. Used to decode payloads from the server.
|
|
219
|
+
* @param opts.createTemporaryReferenceSet A function that creates a temporary
|
|
220
|
+
* reference set for the [RSC](https://react.dev/reference/rsc/server-components)
|
|
221
|
+
* payload.
|
|
222
|
+
* @param opts.encodeReply Your `react-server-dom-xyz/client`'s `encodeReply`.
|
|
223
|
+
* Used when sending payloads to the server.
|
|
224
|
+
* @param opts.fetch Optional [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
|
|
225
|
+
* implementation. Defaults to global [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch).
|
|
226
|
+
* @returns A function that can be used to call server actions.
|
|
227
|
+
*/
|
|
228
|
+
declare function createCallServer({ createFromReadableStream, createTemporaryReferenceSet, encodeReply, fetch: fetchImplementation, }: {
|
|
229
|
+
createFromReadableStream: BrowserCreateFromReadableStreamFunction;
|
|
230
|
+
createTemporaryReferenceSet: () => unknown;
|
|
231
|
+
encodeReply: EncodeReplyFunction;
|
|
232
|
+
fetch?: (request: Request) => Promise<Response>;
|
|
233
|
+
}): (id: string, args: unknown[]) => Promise<unknown>;
|
|
234
|
+
/**
|
|
235
|
+
* Props for the {@link unstable_RSCHydratedRouter} component.
|
|
236
|
+
*
|
|
237
|
+
* @name unstable_RSCHydratedRouterProps
|
|
238
|
+
* @category Types
|
|
239
|
+
*/
|
|
240
|
+
interface RSCHydratedRouterProps {
|
|
241
|
+
/**
|
|
242
|
+
* Your `react-server-dom-xyz/client`'s `createFromReadableStream` function,
|
|
243
|
+
* used to decode payloads from the server.
|
|
244
|
+
*/
|
|
245
|
+
createFromReadableStream: BrowserCreateFromReadableStreamFunction;
|
|
246
|
+
/**
|
|
247
|
+
* Optional fetch implementation. Defaults to global [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch).
|
|
248
|
+
*/
|
|
249
|
+
fetch?: (request: Request) => Promise<Response>;
|
|
250
|
+
/**
|
|
251
|
+
* The decoded {@link unstable_RSCPayload} to hydrate.
|
|
252
|
+
*/
|
|
253
|
+
payload: RSCPayload;
|
|
254
|
+
/**
|
|
255
|
+
* `"eager"` or `"lazy"` - Determines if links are eagerly discovered, or
|
|
256
|
+
* delayed until clicked.
|
|
257
|
+
*/
|
|
258
|
+
routeDiscovery?: "eager" | "lazy";
|
|
259
|
+
/**
|
|
260
|
+
* A function that returns an {@link RouterContextProvider} instance
|
|
261
|
+
* which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
|
|
262
|
+
* [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
|
|
263
|
+
* This function is called to generate a fresh `context` instance on each
|
|
264
|
+
* navigation or fetcher call.
|
|
265
|
+
*/
|
|
266
|
+
getContext?: RouterInit["getContext"];
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Hydrates a server rendered {@link unstable_RSCPayload} in the browser.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* import { startTransition, StrictMode } from "react";
|
|
273
|
+
* import { hydrateRoot } from "react-dom/client";
|
|
274
|
+
* import {
|
|
275
|
+
* unstable_getRSCStream as getRSCStream,
|
|
276
|
+
* unstable_RSCHydratedRouter as RSCHydratedRouter,
|
|
277
|
+
* } from "react-router";
|
|
278
|
+
* import type { unstable_RSCPayload as RSCPayload } from "react-router";
|
|
279
|
+
*
|
|
280
|
+
* createFromReadableStream(getRSCStream()).then((payload) =>
|
|
281
|
+
* startTransition(async () => {
|
|
282
|
+
* hydrateRoot(
|
|
283
|
+
* document,
|
|
284
|
+
* <StrictMode>
|
|
285
|
+
* <RSCHydratedRouter
|
|
286
|
+
* createFromReadableStream={createFromReadableStream}
|
|
287
|
+
* payload={payload}
|
|
288
|
+
* />
|
|
289
|
+
* </StrictMode>,
|
|
290
|
+
* { formState: await getFormState(payload) },
|
|
291
|
+
* );
|
|
292
|
+
* }),
|
|
293
|
+
* );
|
|
294
|
+
*
|
|
295
|
+
* @name unstable_RSCHydratedRouter
|
|
296
|
+
* @public
|
|
297
|
+
* @category RSC
|
|
298
|
+
* @mode data
|
|
299
|
+
* @param props Props
|
|
300
|
+
* @param {unstable_RSCHydratedRouterProps.createFromReadableStream} props.createFromReadableStream n/a
|
|
301
|
+
* @param {unstable_RSCHydratedRouterProps.fetch} props.fetch n/a
|
|
302
|
+
* @param {unstable_RSCHydratedRouterProps.getContext} props.getContext n/a
|
|
303
|
+
* @param {unstable_RSCHydratedRouterProps.payload} props.payload n/a
|
|
304
|
+
* @param {unstable_RSCHydratedRouterProps.routeDiscovery} props.routeDiscovery n/a
|
|
305
|
+
* @returns A hydrated {@link DataRouter} that can be used to navigate and
|
|
306
|
+
* render routes.
|
|
307
|
+
*/
|
|
308
|
+
declare function RSCHydratedRouter({ createFromReadableStream, fetch: fetchImplementation, payload, routeDiscovery, getContext, }: RSCHydratedRouterProps): React.JSX.Element;
|
|
309
|
+
|
|
310
|
+
export { type BrowserCreateFromReadableStreamFunction as B, type DecodeActionFunction as D, type EncodeReplyFunction as E, type LoadServerActionFunction as L, RSCHydratedRouter as R, type DecodeFormStateFunction as a, type DecodeReplyFunction as b, createCallServer as c, type RSCManifestPayload as d, type RSCPayload as e, type RSCRenderPayload as f, type RSCHydratedRouterProps as g, type RSCMatch as h, type RSCRouteManifest as i, type RSCRouteMatch as j, type RSCRouteConfigEntry as k, type RSCRouteConfig as l, matchRSCServerRequest as m };
|