react-router 0.0.0-experimental-a65d6f5 → 0.0.0-experimental-c19b79d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/{chunk-ZLVXSGFL.js → chunk-2G2U5HGB.js} +161 -164
- package/dist/development/{chunk-CWSJ6RYI.mjs → chunk-AGOH44BE.mjs} +51 -67
- package/dist/development/{chunk-47MIYFLC.mjs → chunk-IMKEG5CI.mjs} +29 -309
- package/dist/development/{chunk-QOFB7XZ5.js → chunk-LUB73E44.js} +70 -347
- package/dist/development/{router-DQIRhYoj.d.mts → context-BqL5Eckq.d.mts} +1288 -1441
- package/dist/development/dom-export.d.mts +4 -59
- package/dist/development/dom-export.d.ts +3 -59
- package/dist/development/dom-export.js +5 -8
- package/dist/development/dom-export.mjs +5 -8
- package/dist/{production/index-react-server-client-lf74v6ET.d.mts → development/index-react-server-client-2EDmGlsZ.d.mts} +77 -140
- package/dist/development/{index-react-server-client-lf74v6ET.d.mts → index-react-server-client-DKvU8YRr.d.ts} +134 -198
- package/dist/development/index-react-server-client.d.mts +3 -3
- package/dist/development/index-react-server-client.d.ts +2 -3
- 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.d.mts +1 -106
- package/dist/development/index-react-server.d.ts +1 -106
- package/dist/development/index-react-server.js +8 -181
- package/dist/development/index-react-server.mjs +8 -181
- package/dist/development/index.d.mts +20 -13
- package/dist/development/index.d.ts +18 -13
- package/dist/development/index.js +147 -161
- package/dist/development/index.mjs +5 -3
- package/dist/development/lib/types/internal.d.mts +3 -3
- package/dist/development/lib/types/internal.d.ts +2 -3
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/{register-DiOIlEq5.d.mts → register-BrVEYTED.d.mts} +7 -1
- package/dist/{production/register-DiOIlEq5.d.mts → development/register-D8NQoPsO.d.ts} +7 -1
- package/dist/development/{routeModules--SgCTStn.d.mts → route-data-CDwqkzPE.d.mts} +147 -157
- package/dist/{production/routeModules-rxNxBmdR.d.ts → development/routeModules-BmVo7q9e.d.ts} +1046 -73
- package/dist/production/{chunk-ZOHTOBOT.js → chunk-2L5AG5Y5.js} +70 -347
- package/dist/production/{chunk-UAAA7FTX.mjs → chunk-AODJW4D3.mjs} +51 -67
- package/dist/production/{chunk-4SPSFXAZ.js → chunk-FGRCWJDI.js} +161 -164
- package/dist/production/{chunk-MMAHTIVZ.mjs → chunk-UOQCOPF6.mjs} +29 -309
- package/dist/production/{router-DQIRhYoj.d.mts → context-BqL5Eckq.d.mts} +1288 -1441
- package/dist/production/dom-export.d.mts +4 -59
- package/dist/production/dom-export.d.ts +3 -59
- package/dist/production/dom-export.js +5 -8
- package/dist/production/dom-export.mjs +5 -8
- package/dist/{development/index-react-server-client-Iw2PMej2.d.ts → production/index-react-server-client-2EDmGlsZ.d.mts} +77 -140
- package/dist/production/{index-react-server-client-Iw2PMej2.d.ts → index-react-server-client-DKvU8YRr.d.ts} +134 -198
- package/dist/production/index-react-server-client.d.mts +3 -3
- package/dist/production/index-react-server-client.d.ts +2 -3
- 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.d.mts +1 -106
- package/dist/production/index-react-server.d.ts +1 -106
- package/dist/production/index-react-server.js +8 -181
- package/dist/production/index-react-server.mjs +8 -181
- package/dist/production/index.d.mts +20 -13
- package/dist/production/index.d.ts +18 -13
- package/dist/production/index.js +147 -161
- package/dist/production/index.mjs +5 -3
- package/dist/production/lib/types/internal.d.mts +3 -3
- package/dist/production/lib/types/internal.d.ts +2 -3
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/{development/register-DiOIlEq5.d.ts → production/register-BrVEYTED.d.mts} +7 -1
- package/dist/production/{register-DiOIlEq5.d.ts → register-D8NQoPsO.d.ts} +7 -1
- package/dist/production/{routeModules--SgCTStn.d.mts → route-data-CDwqkzPE.d.mts} +147 -157
- package/dist/{development/routeModules-rxNxBmdR.d.ts → production/routeModules-BmVo7q9e.d.ts} +1046 -73
- package/package.json +1 -1
- package/dist/development/instrumentation-BWRz1MRU.d.ts +0 -1138
- package/dist/production/instrumentation-BWRz1MRU.d.ts +0 -1138
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-c19b79d
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
isSession,
|
|
32
32
|
routeRSCServerRequest,
|
|
33
33
|
setDevServerHooks
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-AODJW4D3.mjs";
|
|
35
35
|
import {
|
|
36
36
|
Action,
|
|
37
37
|
Await,
|
|
@@ -131,6 +131,7 @@ import {
|
|
|
131
131
|
usePrompt,
|
|
132
132
|
useResolvedPath,
|
|
133
133
|
useRevalidator,
|
|
134
|
+
useRoute,
|
|
134
135
|
useRouteError,
|
|
135
136
|
useRouteLoaderData,
|
|
136
137
|
useRoutes,
|
|
@@ -141,7 +142,7 @@ import {
|
|
|
141
142
|
withComponentProps,
|
|
142
143
|
withErrorBoundaryProps,
|
|
143
144
|
withHydrateFallbackProps
|
|
144
|
-
} from "./chunk-
|
|
145
|
+
} from "./chunk-UOQCOPF6.mjs";
|
|
145
146
|
export {
|
|
146
147
|
Await,
|
|
147
148
|
BrowserRouter,
|
|
@@ -243,6 +244,7 @@ export {
|
|
|
243
244
|
routeRSCServerRequest as unstable_routeRSCServerRequest,
|
|
244
245
|
setDevServerHooks as unstable_setDevServerHooks,
|
|
245
246
|
usePrompt as unstable_usePrompt,
|
|
247
|
+
useRoute as unstable_useRoute,
|
|
246
248
|
useActionData,
|
|
247
249
|
useAsyncError,
|
|
248
250
|
useAsyncValue,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { R as RouteModule, L as LinkDescriptor, F as Func, P as Pretty, M as MetaDescriptor, G as GetLoaderData, S as ServerDataFunctionArgs, C as ClientDataFunctionArgs, a as ServerDataFrom, N as Normalize, b as GetActionData } from '../../
|
|
2
|
-
import { L as Location, M as MiddlewareNextFunction, D as DataStrategyResult } from '../../
|
|
3
|
-
import { R as RouteFiles, P as Pages } from '../../register-
|
|
1
|
+
import { R as RouteModule, L as LinkDescriptor, F as Func, P as Pretty, M as MetaDescriptor, G as GetLoaderData, S as ServerDataFunctionArgs, C as ClientDataFunctionArgs, a as ServerDataFrom, N as Normalize, b as GetActionData } from '../../route-data-CDwqkzPE.mjs';
|
|
2
|
+
import { L as Location, M as MiddlewareNextFunction, D as DataStrategyResult } from '../../context-BqL5Eckq.mjs';
|
|
3
|
+
import { R as RouteFiles, P as Pages } from '../../register-BrVEYTED.mjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
type MaybePromise<T> = T | Promise<T>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { R as RouteModule, L as LinkDescriptor, F as Func, P as Pretty, M as MetaDescriptor, G as GetLoaderData, S as ServerDataFunctionArgs, C as ClientDataFunctionArgs,
|
|
2
|
-
import {
|
|
3
|
-
import { R as RouteFiles, P as Pages } from '../../register-DiOIlEq5.js';
|
|
1
|
+
import { R as RouteModule, L as LinkDescriptor, a as Location, F as Func, P as Pretty, M as MetaDescriptor, G as GetLoaderData, S as ServerDataFunctionArgs, b as MiddlewareNextFunction, C as ClientDataFunctionArgs, D as DataStrategyResult, c as ServerDataFrom, N as Normalize, d as GetActionData } from '../../routeModules-BmVo7q9e.js';
|
|
2
|
+
import { R as RouteFiles, P as Pages } from '../../register-D8NQoPsO.js';
|
|
4
3
|
import 'react';
|
|
5
4
|
|
|
6
5
|
type MaybePromise<T> = T | Promise<T>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { R as RouteModule } from './route-data-CDwqkzPE.mjs';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Apps can use this interface to "register" app-wide types for React Router via interface declaration merging and module augmentation.
|
|
3
5
|
* React Router should handle this for you via type generation.
|
|
@@ -20,5 +22,9 @@ type AnyRouteFiles = Record<string, {
|
|
|
20
22
|
type RouteFiles = Register extends {
|
|
21
23
|
routeFiles: infer Registered extends AnyRouteFiles;
|
|
22
24
|
} ? Registered : AnyRouteFiles;
|
|
25
|
+
type AnyRouteModules = Record<string, RouteModule>;
|
|
26
|
+
type RouteModules = Register extends {
|
|
27
|
+
routeModules: infer Registered extends AnyRouteModules;
|
|
28
|
+
} ? Registered : AnyRouteModules;
|
|
23
29
|
|
|
24
|
-
export type { Pages as P, RouteFiles as R,
|
|
30
|
+
export type { Pages as P, RouteFiles as R, RouteModules as a, Register as b };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { R as RouteModule } from './routeModules-BmVo7q9e.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Apps can use this interface to "register" app-wide types for React Router via interface declaration merging and module augmentation.
|
|
3
5
|
* React Router should handle this for you via type generation.
|
|
@@ -20,5 +22,9 @@ type AnyRouteFiles = Record<string, {
|
|
|
20
22
|
type RouteFiles = Register extends {
|
|
21
23
|
routeFiles: infer Registered extends AnyRouteFiles;
|
|
22
24
|
} ? Registered : AnyRouteFiles;
|
|
25
|
+
type AnyRouteModules = Record<string, RouteModule>;
|
|
26
|
+
type RouteModules = Register extends {
|
|
27
|
+
routeModules: infer Registered extends AnyRouteModules;
|
|
28
|
+
} ? Registered : AnyRouteModules;
|
|
23
29
|
|
|
24
|
-
export type { Pages as P, RouteFiles as R,
|
|
30
|
+
export type { Pages as P, RouteFiles as R, RouteModules as a, Register as b };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentType, ReactElement } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { A as ActionFunctionArgs, b as LoaderFunctionArgs, c as ActionFunction, d as LoaderFunction, P as Params, L as Location, e as DataRouteMatch, f as MiddlewareFunction, D as DataStrategyResult, S as ShouldRevalidateFunction, g as RouterContextProvider, h as DataWithResponseInit, i as MiddlewareEnabled } from './context-BqL5Eckq.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* An object of unknown type for route loaders and actions provided by the
|
|
@@ -121,165 +121,13 @@ interface PageLinkDescriptor extends Omit<HtmlLinkDescriptor, "href" | "rel" | "
|
|
|
121
121
|
}
|
|
122
122
|
type LinkDescriptor = HtmlLinkDescriptor | PageLinkDescriptor;
|
|
123
123
|
|
|
124
|
-
type Serializable = undefined | null | boolean | string | symbol | number | Array<Serializable> | {
|
|
125
|
-
[key: PropertyKey]: Serializable;
|
|
126
|
-
} | bigint | Date | URL | RegExp | Error | Map<Serializable, Serializable> | Set<Serializable> | Promise<Serializable>;
|
|
127
|
-
|
|
128
|
-
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
|
129
|
-
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
130
|
-
type Func = (...args: any[]) => unknown;
|
|
131
|
-
type Pretty<T> = {
|
|
132
|
-
[K in keyof T]: T[K];
|
|
133
|
-
} & {};
|
|
134
|
-
type Normalize<T> = _Normalize<UnionKeys<T>, T>;
|
|
135
|
-
type _Normalize<Key extends keyof any, T> = T extends infer U ? Pretty<{
|
|
136
|
-
[K in Key as K extends keyof U ? undefined extends U[K] ? never : K : never]: K extends keyof U ? U[K] : never;
|
|
137
|
-
} & {
|
|
138
|
-
[K in Key as K extends keyof U ? undefined extends U[K] ? K : never : never]?: K extends keyof U ? U[K] : never;
|
|
139
|
-
} & {
|
|
140
|
-
[K in Key as K extends keyof U ? never : K]?: undefined;
|
|
141
|
-
}> : never;
|
|
142
|
-
type UnionKeys<T> = T extends any ? keyof T : never;
|
|
143
|
-
|
|
144
|
-
type RouteModule$1 = {
|
|
145
|
-
meta?: Func;
|
|
146
|
-
links?: Func;
|
|
147
|
-
headers?: Func;
|
|
148
|
-
loader?: Func;
|
|
149
|
-
clientLoader?: Func;
|
|
150
|
-
action?: Func;
|
|
151
|
-
clientAction?: Func;
|
|
152
|
-
HydrateFallback?: Func;
|
|
153
|
-
default?: Func;
|
|
154
|
-
ErrorBoundary?: Func;
|
|
155
|
-
[key: string]: unknown;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* A brand that can be applied to a type to indicate that it will serialize
|
|
160
|
-
* to a specific type when transported to the client from a loader.
|
|
161
|
-
* Only use this if you have additional serialization/deserialization logic
|
|
162
|
-
* in your application.
|
|
163
|
-
*/
|
|
164
|
-
type unstable_SerializesTo<T> = {
|
|
165
|
-
unstable__ReactRouter_SerializesTo: [T];
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
type Serialize<T> = T extends unstable_SerializesTo<infer To> ? To : T extends Serializable ? T : T extends (...args: any[]) => unknown ? undefined : T extends Promise<infer U> ? Promise<Serialize<U>> : T extends Map<infer K, infer V> ? Map<Serialize<K>, Serialize<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<Serialize<K>, Serialize<V>> : T extends Set<infer U> ? Set<Serialize<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<Serialize<U>> : T extends [] ? [] : T extends readonly [infer F, ...infer R] ? [Serialize<F>, ...Serialize<R>] : T extends Array<infer U> ? Array<Serialize<U>> : T extends readonly unknown[] ? readonly Serialize<T[number]>[] : T extends Record<any, any> ? {
|
|
169
|
-
[K in keyof T]: Serialize<T[K]>;
|
|
170
|
-
} : undefined;
|
|
171
|
-
type VoidToUndefined<T> = Equal<T, void> extends true ? undefined : T;
|
|
172
|
-
type DataFrom<T> = IsAny<T> extends true ? undefined : T extends Func ? VoidToUndefined<Awaited<ReturnType<T>>> : undefined;
|
|
173
|
-
type ClientData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? U : T;
|
|
174
|
-
type ServerData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? Serialize<U> : Serialize<T>;
|
|
175
|
-
type ServerDataFrom<T> = ServerData<DataFrom<T>>;
|
|
176
|
-
type ClientDataFrom<T> = ClientData<DataFrom<T>>;
|
|
177
|
-
type ClientDataFunctionArgs<Params> = {
|
|
178
|
-
/**
|
|
179
|
-
* A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the URL, the method, the "content-type" header, and the request body from the request.
|
|
180
|
-
*
|
|
181
|
-
* @note Because client data functions are called before a network request is made, the Request object does not include the headers which the browser automatically adds. React Router infers the "content-type" header from the enc-type of the form that performed the submission.
|
|
182
|
-
**/
|
|
183
|
-
request: Request;
|
|
184
|
-
/**
|
|
185
|
-
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
|
186
|
-
* @example
|
|
187
|
-
* // app/routes.ts
|
|
188
|
-
* route("teams/:teamId", "./team.tsx"),
|
|
189
|
-
*
|
|
190
|
-
* // app/team.tsx
|
|
191
|
-
* export function clientLoader({
|
|
192
|
-
* params,
|
|
193
|
-
* }: Route.ClientLoaderArgs) {
|
|
194
|
-
* params.teamId;
|
|
195
|
-
* // ^ string
|
|
196
|
-
* }
|
|
197
|
-
**/
|
|
198
|
-
params: Params;
|
|
199
|
-
/**
|
|
200
|
-
* Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
|
|
201
|
-
* Mostly useful as a identifier to aggregate on for logging/tracing/etc.
|
|
202
|
-
*/
|
|
203
|
-
unstable_pattern: string;
|
|
204
|
-
/**
|
|
205
|
-
* When `future.v8_middleware` is not enabled, this is undefined.
|
|
206
|
-
*
|
|
207
|
-
* When `future.v8_middleware` is enabled, this is an instance of
|
|
208
|
-
* `RouterContextProvider` and can be used to access context values
|
|
209
|
-
* from your route middlewares. You may pass in initial context values in your
|
|
210
|
-
* `<HydratedRouter getContext>` prop
|
|
211
|
-
*/
|
|
212
|
-
context: Readonly<RouterContextProvider>;
|
|
213
|
-
};
|
|
214
|
-
type ServerDataFunctionArgs<Params> = {
|
|
215
|
-
/** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the url, method, headers (such as cookies), and request body from the request. */
|
|
216
|
-
request: Request;
|
|
217
|
-
/**
|
|
218
|
-
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
|
219
|
-
* @example
|
|
220
|
-
* // app/routes.ts
|
|
221
|
-
* route("teams/:teamId", "./team.tsx"),
|
|
222
|
-
*
|
|
223
|
-
* // app/team.tsx
|
|
224
|
-
* export function loader({
|
|
225
|
-
* params,
|
|
226
|
-
* }: Route.LoaderArgs) {
|
|
227
|
-
* params.teamId;
|
|
228
|
-
* // ^ string
|
|
229
|
-
* }
|
|
230
|
-
**/
|
|
231
|
-
params: Params;
|
|
232
|
-
/**
|
|
233
|
-
* Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
|
|
234
|
-
* Mostly useful as a identifier to aggregate on for logging/tracing/etc.
|
|
235
|
-
*/
|
|
236
|
-
unstable_pattern: string;
|
|
237
|
-
/**
|
|
238
|
-
* Without `future.v8_middleware` enabled, this is the context passed in
|
|
239
|
-
* to your server adapter's `getLoadContext` function. It's a way to bridge the
|
|
240
|
-
* gap between the adapter's request/response API with your React Router app.
|
|
241
|
-
* It is only applicable if you are using a custom server adapter.
|
|
242
|
-
*
|
|
243
|
-
* With `future.v8_middleware` enabled, this is an instance of
|
|
244
|
-
* `RouterContextProvider` and can be used for type-safe access to
|
|
245
|
-
* context value set in your route middlewares. If you are using a custom
|
|
246
|
-
* server adapter, you may provide an initial set of context values from your
|
|
247
|
-
* `getLoadContext` function.
|
|
248
|
-
*/
|
|
249
|
-
context: MiddlewareEnabled extends true ? Readonly<RouterContextProvider> : AppLoadContext;
|
|
250
|
-
};
|
|
251
|
-
type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [
|
|
252
|
-
ClientLoaderFunctionArgs | ClientActionFunctionArgs | ClientDataFunctionArgs<unknown>
|
|
253
|
-
] ? ClientDataFrom<T> : ServerDataFrom<T> : T;
|
|
254
|
-
type IsDefined<T> = Equal<T, undefined> extends true ? false : true;
|
|
255
|
-
type IsHydrate<ClientLoader> = ClientLoader extends {
|
|
256
|
-
hydrate: true;
|
|
257
|
-
} ? true : ClientLoader extends {
|
|
258
|
-
hydrate: false;
|
|
259
|
-
} ? false : false;
|
|
260
|
-
type GetLoaderData<T extends RouteModule$1> = _DataLoaderData<ServerDataFrom<T["loader"]>, ClientDataFrom<T["clientLoader"]>, IsHydrate<T["clientLoader"]>, T extends {
|
|
261
|
-
HydrateFallback: Func;
|
|
262
|
-
} ? true : false>;
|
|
263
|
-
type _DataLoaderData<ServerLoaderData, ClientLoaderData, ClientLoaderHydrate extends boolean, HasHydrateFallback> = [
|
|
264
|
-
HasHydrateFallback,
|
|
265
|
-
ClientLoaderHydrate
|
|
266
|
-
] extends [true, true] ? IsDefined<ClientLoaderData> extends true ? ClientLoaderData : undefined : [
|
|
267
|
-
IsDefined<ClientLoaderData>,
|
|
268
|
-
IsDefined<ServerLoaderData>
|
|
269
|
-
] extends [true, true] ? ServerLoaderData | ClientLoaderData : IsDefined<ClientLoaderData> extends true ? ClientLoaderData : IsDefined<ServerLoaderData> extends true ? ServerLoaderData : undefined;
|
|
270
|
-
type GetActionData<T extends RouteModule$1> = _DataActionData<ServerDataFrom<T["action"]>, ClientDataFrom<T["clientAction"]>>;
|
|
271
|
-
type _DataActionData<ServerActionData, ClientActionData> = Awaited<[
|
|
272
|
-
IsDefined<ServerActionData>,
|
|
273
|
-
IsDefined<ClientActionData>
|
|
274
|
-
] extends [true, true] ? ServerActionData | ClientActionData : IsDefined<ClientActionData> extends true ? ClientActionData : IsDefined<ServerActionData> extends true ? ServerActionData : undefined>;
|
|
275
|
-
|
|
276
124
|
interface RouteModules {
|
|
277
|
-
[routeId: string]: RouteModule | undefined;
|
|
125
|
+
[routeId: string]: RouteModule$1 | undefined;
|
|
278
126
|
}
|
|
279
127
|
/**
|
|
280
128
|
* The shape of a route module shipped to the client
|
|
281
129
|
*/
|
|
282
|
-
interface RouteModule {
|
|
130
|
+
interface RouteModule$1 {
|
|
283
131
|
clientAction?: ClientActionFunction;
|
|
284
132
|
clientLoader?: ClientLoaderFunction;
|
|
285
133
|
clientMiddleware?: MiddlewareFunction<Record<string, DataStrategyResult>>[];
|
|
@@ -295,7 +143,7 @@ interface RouteModule {
|
|
|
295
143
|
/**
|
|
296
144
|
* The shape of a route module on the server
|
|
297
145
|
*/
|
|
298
|
-
interface ServerRouteModule extends RouteModule {
|
|
146
|
+
interface ServerRouteModule extends RouteModule$1 {
|
|
299
147
|
action?: ActionFunction;
|
|
300
148
|
headers?: HeadersFunction | {
|
|
301
149
|
[name: string]: string;
|
|
@@ -480,4 +328,146 @@ type RouteComponent = ComponentType<{}>;
|
|
|
480
328
|
*/
|
|
481
329
|
type RouteHandle = unknown;
|
|
482
330
|
|
|
483
|
-
|
|
331
|
+
type Serializable = undefined | null | boolean | string | symbol | number | Array<Serializable> | {
|
|
332
|
+
[key: PropertyKey]: Serializable;
|
|
333
|
+
} | bigint | Date | URL | RegExp | Error | Map<Serializable, Serializable> | Set<Serializable> | Promise<Serializable>;
|
|
334
|
+
|
|
335
|
+
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
|
336
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
337
|
+
type Func = (...args: any[]) => unknown;
|
|
338
|
+
type Pretty<T> = {
|
|
339
|
+
[K in keyof T]: T[K];
|
|
340
|
+
} & {};
|
|
341
|
+
type Normalize<T> = _Normalize<UnionKeys<T>, T>;
|
|
342
|
+
type _Normalize<Key extends keyof any, T> = T extends infer U ? Pretty<{
|
|
343
|
+
[K in Key as K extends keyof U ? undefined extends U[K] ? never : K : never]: K extends keyof U ? U[K] : never;
|
|
344
|
+
} & {
|
|
345
|
+
[K in Key as K extends keyof U ? undefined extends U[K] ? K : never : never]?: K extends keyof U ? U[K] : never;
|
|
346
|
+
} & {
|
|
347
|
+
[K in Key as K extends keyof U ? never : K]?: undefined;
|
|
348
|
+
}> : never;
|
|
349
|
+
type UnionKeys<T> = T extends any ? keyof T : never;
|
|
350
|
+
|
|
351
|
+
type RouteModule = {
|
|
352
|
+
meta?: Func;
|
|
353
|
+
links?: Func;
|
|
354
|
+
headers?: Func;
|
|
355
|
+
loader?: Func;
|
|
356
|
+
clientLoader?: Func;
|
|
357
|
+
action?: Func;
|
|
358
|
+
clientAction?: Func;
|
|
359
|
+
HydrateFallback?: Func;
|
|
360
|
+
default?: Func;
|
|
361
|
+
ErrorBoundary?: Func;
|
|
362
|
+
[key: string]: unknown;
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* A brand that can be applied to a type to indicate that it will serialize
|
|
367
|
+
* to a specific type when transported to the client from a loader.
|
|
368
|
+
* Only use this if you have additional serialization/deserialization logic
|
|
369
|
+
* in your application.
|
|
370
|
+
*/
|
|
371
|
+
type unstable_SerializesTo<T> = {
|
|
372
|
+
unstable__ReactRouter_SerializesTo: [T];
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
type Serialize<T> = T extends unstable_SerializesTo<infer To> ? To : T extends Serializable ? T : T extends (...args: any[]) => unknown ? undefined : T extends Promise<infer U> ? Promise<Serialize<U>> : T extends Map<infer K, infer V> ? Map<Serialize<K>, Serialize<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<Serialize<K>, Serialize<V>> : T extends Set<infer U> ? Set<Serialize<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<Serialize<U>> : T extends [] ? [] : T extends readonly [infer F, ...infer R] ? [Serialize<F>, ...Serialize<R>] : T extends Array<infer U> ? Array<Serialize<U>> : T extends readonly unknown[] ? readonly Serialize<T[number]>[] : T extends Record<any, any> ? {
|
|
376
|
+
[K in keyof T]: Serialize<T[K]>;
|
|
377
|
+
} : undefined;
|
|
378
|
+
type VoidToUndefined<T> = Equal<T, void> extends true ? undefined : T;
|
|
379
|
+
type DataFrom<T> = IsAny<T> extends true ? undefined : T extends Func ? VoidToUndefined<Awaited<ReturnType<T>>> : undefined;
|
|
380
|
+
type ClientData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? U : T;
|
|
381
|
+
type ServerData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? Serialize<U> : Serialize<T>;
|
|
382
|
+
type ServerDataFrom<T> = ServerData<DataFrom<T>>;
|
|
383
|
+
type ClientDataFrom<T> = ClientData<DataFrom<T>>;
|
|
384
|
+
type ClientDataFunctionArgs<Params> = {
|
|
385
|
+
/**
|
|
386
|
+
* A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the URL, the method, the "content-type" header, and the request body from the request.
|
|
387
|
+
*
|
|
388
|
+
* @note Because client data functions are called before a network request is made, the Request object does not include the headers which the browser automatically adds. React Router infers the "content-type" header from the enc-type of the form that performed the submission.
|
|
389
|
+
**/
|
|
390
|
+
request: Request;
|
|
391
|
+
/**
|
|
392
|
+
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
|
393
|
+
* @example
|
|
394
|
+
* // app/routes.ts
|
|
395
|
+
* route("teams/:teamId", "./team.tsx"),
|
|
396
|
+
*
|
|
397
|
+
* // app/team.tsx
|
|
398
|
+
* export function clientLoader({
|
|
399
|
+
* params,
|
|
400
|
+
* }: Route.ClientLoaderArgs) {
|
|
401
|
+
* params.teamId;
|
|
402
|
+
* // ^ string
|
|
403
|
+
* }
|
|
404
|
+
**/
|
|
405
|
+
params: Params;
|
|
406
|
+
/**
|
|
407
|
+
* When `future.v8_middleware` is not enabled, this is undefined.
|
|
408
|
+
*
|
|
409
|
+
* When `future.v8_middleware` is enabled, this is an instance of
|
|
410
|
+
* `RouterContextProvider` and can be used to access context values
|
|
411
|
+
* from your route middlewares. You may pass in initial context values in your
|
|
412
|
+
* `<HydratedRouter getContext>` prop
|
|
413
|
+
*/
|
|
414
|
+
context: Readonly<RouterContextProvider>;
|
|
415
|
+
};
|
|
416
|
+
type ServerDataFunctionArgs<Params> = {
|
|
417
|
+
/** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the url, method, headers (such as cookies), and request body from the request. */
|
|
418
|
+
request: Request;
|
|
419
|
+
/**
|
|
420
|
+
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
|
421
|
+
* @example
|
|
422
|
+
* // app/routes.ts
|
|
423
|
+
* route("teams/:teamId", "./team.tsx"),
|
|
424
|
+
*
|
|
425
|
+
* // app/team.tsx
|
|
426
|
+
* export function loader({
|
|
427
|
+
* params,
|
|
428
|
+
* }: Route.LoaderArgs) {
|
|
429
|
+
* params.teamId;
|
|
430
|
+
* // ^ string
|
|
431
|
+
* }
|
|
432
|
+
**/
|
|
433
|
+
params: Params;
|
|
434
|
+
/**
|
|
435
|
+
* Without `future.v8_middleware` enabled, this is the context passed in
|
|
436
|
+
* to your server adapter's `getLoadContext` function. It's a way to bridge the
|
|
437
|
+
* gap between the adapter's request/response API with your React Router app.
|
|
438
|
+
* It is only applicable if you are using a custom server adapter.
|
|
439
|
+
*
|
|
440
|
+
* With `future.v8_middleware` enabled, this is an instance of
|
|
441
|
+
* `RouterContextProvider` and can be used for type-safe access to
|
|
442
|
+
* context value set in your route middlewares. If you are using a custom
|
|
443
|
+
* server adapter, you may provide an initial set of context values from your
|
|
444
|
+
* `getLoadContext` function.
|
|
445
|
+
*/
|
|
446
|
+
context: MiddlewareEnabled extends true ? Readonly<RouterContextProvider> : AppLoadContext;
|
|
447
|
+
};
|
|
448
|
+
type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [
|
|
449
|
+
ClientLoaderFunctionArgs | ClientActionFunctionArgs | ClientDataFunctionArgs<unknown>
|
|
450
|
+
] ? ClientDataFrom<T> : ServerDataFrom<T> : T;
|
|
451
|
+
type IsDefined<T> = Equal<T, undefined> extends true ? false : true;
|
|
452
|
+
type IsHydrate<ClientLoader> = ClientLoader extends {
|
|
453
|
+
hydrate: true;
|
|
454
|
+
} ? true : ClientLoader extends {
|
|
455
|
+
hydrate: false;
|
|
456
|
+
} ? false : false;
|
|
457
|
+
type GetLoaderData<T extends RouteModule> = _DataLoaderData<ServerDataFrom<T["loader"]>, ClientDataFrom<T["clientLoader"]>, IsHydrate<T["clientLoader"]>, T extends {
|
|
458
|
+
HydrateFallback: Func;
|
|
459
|
+
} ? true : false>;
|
|
460
|
+
type _DataLoaderData<ServerLoaderData, ClientLoaderData, ClientLoaderHydrate extends boolean, HasHydrateFallback> = [
|
|
461
|
+
HasHydrateFallback,
|
|
462
|
+
ClientLoaderHydrate
|
|
463
|
+
] extends [true, true] ? IsDefined<ClientLoaderData> extends true ? ClientLoaderData : undefined : [
|
|
464
|
+
IsDefined<ClientLoaderData>,
|
|
465
|
+
IsDefined<ServerLoaderData>
|
|
466
|
+
] extends [true, true] ? ServerLoaderData | ClientLoaderData : IsDefined<ClientLoaderData> extends true ? ClientLoaderData : IsDefined<ServerLoaderData> extends true ? ServerLoaderData : undefined;
|
|
467
|
+
type GetActionData<T extends RouteModule> = _DataActionData<ServerDataFrom<T["action"]>, ClientDataFrom<T["clientAction"]>>;
|
|
468
|
+
type _DataActionData<ServerActionData, ClientActionData> = Awaited<[
|
|
469
|
+
IsDefined<ServerActionData>,
|
|
470
|
+
IsDefined<ClientActionData>
|
|
471
|
+
] extends [true, true] ? ServerActionData | ClientActionData : IsDefined<ClientActionData> extends true ? ClientActionData : IsDefined<ServerActionData> extends true ? ServerActionData : undefined>;
|
|
472
|
+
|
|
473
|
+
export type { AppLoadContext as A, ClientDataFunctionArgs as C, Equal as E, Func as F, GetLoaderData as G, HeadersFunction as H, LinkDescriptor as L, MetaDescriptor as M, Normalize as N, Pretty as P, RouteModule as R, ServerDataFunctionArgs as S, ServerDataFrom as a, GetActionData as b, RouteModules as c, SerializeFrom as d, MetaFunction as e, LinksFunction as f, ClientActionFunction as g, ClientLoaderFunction as h, ClientActionFunctionArgs as i, ClientLoaderFunctionArgs as j, HeadersArgs as k, MetaArgs as l, PageLinkDescriptor as m, HtmlLinkDescriptor as n, ServerRouteModule as o, unstable_SerializesTo as u };
|