react-router 0.0.0-experimental-c19b79d → 0.0.0-experimental-e0b6ce9
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-AGOH44BE.mjs → chunk-4FI4BC6Y.mjs} +67 -51
- package/dist/development/{chunk-IMKEG5CI.mjs → chunk-F6CT5MEB.mjs} +314 -30
- package/dist/development/{chunk-LUB73E44.js → chunk-INO4IHBF.js} +352 -71
- package/dist/development/{chunk-2G2U5HGB.js → chunk-ITZFCV4J.js} +164 -161
- package/dist/development/dom-export.d.mts +59 -4
- package/dist/development/dom-export.d.ts +59 -3
- package/dist/development/dom-export.js +8 -5
- package/dist/development/dom-export.mjs +8 -5
- package/dist/development/{index-react-server-client-DKvU8YRr.d.ts → index-react-server-client-CYIi6gi0.d.mts} +198 -134
- package/dist/{production/index-react-server-client-DKvU8YRr.d.ts → development/index-react-server-client-ChBGplLn.d.ts} +198 -134
- package/dist/development/index-react-server-client.d.mts +3 -3
- package/dist/development/index-react-server-client.d.ts +3 -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.d.mts +90 -1
- package/dist/development/index-react-server.d.ts +90 -1
- package/dist/development/index-react-server.js +188 -9
- package/dist/development/index-react-server.mjs +188 -9
- package/dist/development/index.d.mts +13 -20
- package/dist/development/index.d.ts +13 -18
- package/dist/development/index.js +161 -147
- package/dist/development/index.mjs +3 -5
- package/dist/development/instrumentation-BGrNA7uj.d.ts +1122 -0
- package/dist/development/lib/types/internal.d.mts +3 -3
- package/dist/development/lib/types/internal.d.ts +3 -2
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/{register-BrVEYTED.d.mts → register-DiOIlEq5.d.mts} +1 -7
- package/dist/{production/register-BrVEYTED.d.mts → development/register-DiOIlEq5.d.ts} +1 -7
- package/dist/development/{route-data-CDwqkzPE.d.mts → routeModules-Cy4Xsfoi.d.mts} +157 -147
- package/dist/{production/routeModules-BmVo7q9e.d.ts → development/routeModules-DqotkItD.d.ts} +73 -1046
- package/dist/{production/context-BqL5Eckq.d.mts → development/router-DWv6Clt-.d.mts} +1390 -1253
- package/dist/production/{chunk-AODJW4D3.mjs → chunk-52MYED7O.mjs} +67 -51
- package/dist/production/{chunk-FGRCWJDI.js → chunk-DASXXYNZ.js} +164 -161
- package/dist/production/{chunk-2L5AG5Y5.js → chunk-K7VXYOZD.js} +352 -71
- package/dist/production/{chunk-UOQCOPF6.mjs → chunk-LKSLGWXX.mjs} +314 -30
- package/dist/production/dom-export.d.mts +59 -4
- package/dist/production/dom-export.d.ts +59 -3
- package/dist/production/dom-export.js +8 -5
- package/dist/production/dom-export.mjs +8 -5
- package/dist/production/{index-react-server-client-2EDmGlsZ.d.mts → index-react-server-client-CYIi6gi0.d.mts} +140 -77
- package/dist/{development/index-react-server-client-2EDmGlsZ.d.mts → production/index-react-server-client-ChBGplLn.d.ts} +140 -77
- package/dist/production/index-react-server-client.d.mts +3 -3
- package/dist/production/index-react-server-client.d.ts +3 -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.d.mts +90 -1
- package/dist/production/index-react-server.d.ts +90 -1
- package/dist/production/index-react-server.js +188 -9
- package/dist/production/index-react-server.mjs +188 -9
- package/dist/production/index.d.mts +13 -20
- package/dist/production/index.d.ts +13 -18
- package/dist/production/index.js +161 -147
- package/dist/production/index.mjs +3 -5
- package/dist/production/instrumentation-BGrNA7uj.d.ts +1122 -0
- package/dist/production/lib/types/internal.d.mts +3 -3
- package/dist/production/lib/types/internal.d.ts +3 -2
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/{development/register-D8NQoPsO.d.ts → production/register-DiOIlEq5.d.mts} +1 -7
- package/dist/production/{register-D8NQoPsO.d.ts → register-DiOIlEq5.d.ts} +1 -7
- package/dist/production/{route-data-CDwqkzPE.d.mts → routeModules-Cy4Xsfoi.d.mts} +157 -147
- package/dist/{development/routeModules-BmVo7q9e.d.ts → production/routeModules-DqotkItD.d.ts} +73 -1046
- package/dist/{development/context-BqL5Eckq.d.mts → production/router-DWv6Clt-.d.mts} +1390 -1253
- package/package.json +1 -1
|
@@ -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 '../../routeModules-Cy4Xsfoi.mjs';
|
|
2
|
+
import { L as Location, M as MiddlewareNextFunction, D as DataStrategyResult } from '../../router-DWv6Clt-.mjs';
|
|
3
|
+
import { R as RouteFiles, P as Pages } from '../../register-DiOIlEq5.mjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
type MaybePromise<T> = T | Promise<T>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { R as RouteModule, L as LinkDescriptor,
|
|
2
|
-
import {
|
|
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 '../../routeModules-DqotkItD.js';
|
|
2
|
+
import { L as Location, M as MiddlewareNextFunction, D as DataStrategyResult } from '../../instrumentation-BGrNA7uj.js';
|
|
3
|
+
import { R as RouteFiles, P as Pages } from '../../register-DiOIlEq5.js';
|
|
3
4
|
import 'react';
|
|
4
5
|
|
|
5
6
|
type MaybePromise<T> = T | Promise<T>;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { R as RouteModule } from './route-data-CDwqkzPE.mjs';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Apps can use this interface to "register" app-wide types for React Router via interface declaration merging and module augmentation.
|
|
5
3
|
* React Router should handle this for you via type generation.
|
|
@@ -22,9 +20,5 @@ type AnyRouteFiles = Record<string, {
|
|
|
22
20
|
type RouteFiles = Register extends {
|
|
23
21
|
routeFiles: infer Registered extends AnyRouteFiles;
|
|
24
22
|
} ? Registered : AnyRouteFiles;
|
|
25
|
-
type AnyRouteModules = Record<string, RouteModule>;
|
|
26
|
-
type RouteModules = Register extends {
|
|
27
|
-
routeModules: infer Registered extends AnyRouteModules;
|
|
28
|
-
} ? Registered : AnyRouteModules;
|
|
29
23
|
|
|
30
|
-
export type { Pages as P, RouteFiles as R,
|
|
24
|
+
export type { Pages as P, RouteFiles as R, Register as a };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { R as RouteModule } from './route-data-CDwqkzPE.mjs';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Apps can use this interface to "register" app-wide types for React Router via interface declaration merging and module augmentation.
|
|
5
3
|
* React Router should handle this for you via type generation.
|
|
@@ -22,9 +20,5 @@ type AnyRouteFiles = Record<string, {
|
|
|
22
20
|
type RouteFiles = Register extends {
|
|
23
21
|
routeFiles: infer Registered extends AnyRouteFiles;
|
|
24
22
|
} ? Registered : AnyRouteFiles;
|
|
25
|
-
type AnyRouteModules = Record<string, RouteModule>;
|
|
26
|
-
type RouteModules = Register extends {
|
|
27
|
-
routeModules: infer Registered extends AnyRouteModules;
|
|
28
|
-
} ? Registered : AnyRouteModules;
|
|
29
23
|
|
|
30
|
-
export type { Pages as P, RouteFiles as R,
|
|
24
|
+
export type { Pages as P, RouteFiles as R, Register as a };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentType, ReactElement } from 'react';
|
|
2
|
-
import { A as ActionFunctionArgs,
|
|
2
|
+
import { c as RouterContextProvider, d as DataWithResponseInit, e as MiddlewareEnabled, A as ActionFunctionArgs, f as LoaderFunctionArgs, g as ActionFunction, h as LoaderFunction, P as Params, L as Location, i as DataRouteMatch, j as MiddlewareFunction, D as DataStrategyResult, S as ShouldRevalidateFunction } from './router-DWv6Clt-.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* An object of unknown type for route loaders and actions provided by the
|
|
@@ -121,13 +121,165 @@ 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
|
+
|
|
124
276
|
interface RouteModules {
|
|
125
|
-
[routeId: string]: RouteModule
|
|
277
|
+
[routeId: string]: RouteModule | undefined;
|
|
126
278
|
}
|
|
127
279
|
/**
|
|
128
280
|
* The shape of a route module shipped to the client
|
|
129
281
|
*/
|
|
130
|
-
interface RouteModule
|
|
282
|
+
interface RouteModule {
|
|
131
283
|
clientAction?: ClientActionFunction;
|
|
132
284
|
clientLoader?: ClientLoaderFunction;
|
|
133
285
|
clientMiddleware?: MiddlewareFunction<Record<string, DataStrategyResult>>[];
|
|
@@ -143,7 +295,7 @@ interface RouteModule$1 {
|
|
|
143
295
|
/**
|
|
144
296
|
* The shape of a route module on the server
|
|
145
297
|
*/
|
|
146
|
-
interface ServerRouteModule extends RouteModule
|
|
298
|
+
interface ServerRouteModule extends RouteModule {
|
|
147
299
|
action?: ActionFunction;
|
|
148
300
|
headers?: HeadersFunction | {
|
|
149
301
|
[name: string]: string;
|
|
@@ -328,146 +480,4 @@ type RouteComponent = ComponentType<{}>;
|
|
|
328
480
|
*/
|
|
329
481
|
type RouteHandle = unknown;
|
|
330
482
|
|
|
331
|
-
type
|
|
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 };
|
|
483
|
+
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$1 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 };
|