react-router 0.0.0-experimental-1ebb6d403 → 0.0.0-experimental-e41ede670
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 +0 -10
- package/dist/development/{chunk-5XVYBMAF.mjs → chunk-H3OBLXFX.mjs} +767 -514
- package/dist/development/dom-export.d.mts +13 -3
- package/dist/development/dom-export.d.ts +13 -3
- package/dist/development/dom-export.js +272 -108
- package/dist/development/dom-export.mjs +9 -6
- package/dist/{production/fog-of-war-7V7BguJA.d.ts → development/fog-of-war-Bt7PejVF.d.ts} +91 -6
- package/dist/development/{fog-of-war-NQCW9yWR.d.mts → fog-of-war-Dz4n-TU-.d.mts} +91 -6
- package/dist/development/index.d.mts +10 -19
- package/dist/development/index.d.ts +10 -19
- package/dist/development/index.js +767 -514
- package/dist/development/index.mjs +2 -2
- package/dist/development/lib/types/route-module.d.mts +6 -2
- package/dist/development/lib/types/route-module.d.ts +6 -2
- package/dist/development/lib/types/route-module.js +1 -1
- package/dist/development/lib/types/route-module.mjs +1 -1
- package/dist/development/{route-data-JFOfNyPS.d.ts → route-data-C96IyGKo.d.mts} +37 -15
- package/dist/{production/route-data-JFOfNyPS.d.mts → development/route-data-C96IyGKo.d.ts} +37 -15
- package/dist/production/{chunk-CKFZHSMW.mjs → chunk-YBZNESR7.mjs} +767 -514
- package/dist/production/dom-export.d.mts +13 -3
- package/dist/production/dom-export.d.ts +13 -3
- package/dist/production/dom-export.js +272 -108
- package/dist/production/dom-export.mjs +9 -6
- package/dist/{development/fog-of-war-7V7BguJA.d.ts → production/fog-of-war-Bt7PejVF.d.ts} +91 -6
- package/dist/production/{fog-of-war-NQCW9yWR.d.mts → fog-of-war-Dz4n-TU-.d.mts} +91 -6
- package/dist/production/index.d.mts +10 -19
- package/dist/production/index.d.ts +10 -19
- package/dist/production/index.js +767 -514
- package/dist/production/index.mjs +2 -2
- package/dist/production/lib/types/route-module.d.mts +6 -2
- package/dist/production/lib/types/route-module.d.ts +6 -2
- package/dist/production/lib/types/route-module.js +1 -1
- package/dist/production/lib/types/route-module.mjs +1 -1
- package/dist/production/{route-data-JFOfNyPS.d.ts → route-data-C96IyGKo.d.mts} +37 -15
- package/dist/{development/route-data-JFOfNyPS.d.mts → production/route-data-C96IyGKo.d.ts} +37 -15
- package/package.json +2 -17
- package/dist/development/server.d.mts +0 -988
- package/dist/development/server.d.ts +0 -988
- package/dist/development/server.js +0 -1429
- package/dist/development/server.mjs +0 -1406
- package/dist/production/server.d.mts +0 -988
- package/dist/production/server.d.ts +0 -988
- package/dist/production/server.js +0 -1405
- package/dist/production/server.mjs +0 -1382
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-e41ede670
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -120,7 +120,7 @@ import {
|
|
|
120
120
|
useSearchParams,
|
|
121
121
|
useSubmit,
|
|
122
122
|
useViewTransitionState
|
|
123
|
-
} from "./chunk-
|
|
123
|
+
} from "./chunk-H3OBLXFX.mjs";
|
|
124
124
|
export {
|
|
125
125
|
Await,
|
|
126
126
|
BrowserRouter,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ay as LinkDescriptor, av as MetaDescriptor, aM as ServerDataFrom, aN as ClientDataFrom, aO as Func, M as MiddlewareFunction, d as ClientMiddlewareFunction, aP as Equal, aQ as Pretty } from '../../route-data-C96IyGKo.mjs';
|
|
2
2
|
import { A as AppLoadContext } from '../../data-CQbyyGzl.mjs';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -76,6 +76,10 @@ type ClientDataFunctionArgs<T extends RouteInfo> = {
|
|
|
76
76
|
type ServerDataFunctionArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
|
77
77
|
context: AppLoadContext;
|
|
78
78
|
};
|
|
79
|
+
type CreateServerMiddlewareArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
|
80
|
+
type ServerMiddlewareNextFunction = Parameters<MiddlewareFunction>[1];
|
|
81
|
+
type CreateClientMiddlewareArgs<T extends RouteInfo> = Parameters<ClientMiddlewareFunction>[0];
|
|
82
|
+
type ClientMiddlewareNextFunction = Parameters<ClientMiddlewareFunction>[1];
|
|
79
83
|
type CreateServerLoaderArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
|
80
84
|
type CreateClientLoaderArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
|
81
85
|
serverLoader: () => Promise<ServerDataFrom<T["module"]["loader"]>>;
|
|
@@ -106,4 +110,4 @@ type CreateErrorBoundaryProps<T extends RouteInfo> = {
|
|
|
106
110
|
actionData?: T["actionData"];
|
|
107
111
|
};
|
|
108
112
|
|
|
109
|
-
export type { CreateActionData, CreateClientActionArgs, CreateClientLoaderArgs, CreateComponentProps, CreateErrorBoundaryProps, CreateHydrateFallbackProps, CreateLoaderData, CreateMetaArgs, CreateServerActionArgs, CreateServerLoaderArgs, HeadersArgs, LinkDescriptors, MetaDescriptors };
|
|
113
|
+
export type { ClientMiddlewareNextFunction, CreateActionData, CreateClientActionArgs, CreateClientLoaderArgs, CreateClientMiddlewareArgs, CreateComponentProps, CreateErrorBoundaryProps, CreateHydrateFallbackProps, CreateLoaderData, CreateMetaArgs, CreateServerActionArgs, CreateServerLoaderArgs, CreateServerMiddlewareArgs, HeadersArgs, LinkDescriptors, MetaDescriptors, ServerMiddlewareNextFunction };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ay as LinkDescriptor, av as MetaDescriptor, aM as ServerDataFrom, aN as ClientDataFrom, aO as Func, M as MiddlewareFunction, d as ClientMiddlewareFunction, aP as Equal, aQ as Pretty } from '../../route-data-C96IyGKo.js';
|
|
2
2
|
import { A as AppLoadContext } from '../../data-CQbyyGzl.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -76,6 +76,10 @@ type ClientDataFunctionArgs<T extends RouteInfo> = {
|
|
|
76
76
|
type ServerDataFunctionArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
|
77
77
|
context: AppLoadContext;
|
|
78
78
|
};
|
|
79
|
+
type CreateServerMiddlewareArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
|
80
|
+
type ServerMiddlewareNextFunction = Parameters<MiddlewareFunction>[1];
|
|
81
|
+
type CreateClientMiddlewareArgs<T extends RouteInfo> = Parameters<ClientMiddlewareFunction>[0];
|
|
82
|
+
type ClientMiddlewareNextFunction = Parameters<ClientMiddlewareFunction>[1];
|
|
79
83
|
type CreateServerLoaderArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
|
80
84
|
type CreateClientLoaderArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
|
81
85
|
serverLoader: () => Promise<ServerDataFrom<T["module"]["loader"]>>;
|
|
@@ -106,4 +110,4 @@ type CreateErrorBoundaryProps<T extends RouteInfo> = {
|
|
|
106
110
|
actionData?: T["actionData"];
|
|
107
111
|
};
|
|
108
112
|
|
|
109
|
-
export type { CreateActionData, CreateClientActionArgs, CreateClientLoaderArgs, CreateComponentProps, CreateErrorBoundaryProps, CreateHydrateFallbackProps, CreateLoaderData, CreateMetaArgs, CreateServerActionArgs, CreateServerLoaderArgs, HeadersArgs, LinkDescriptors, MetaDescriptors };
|
|
113
|
+
export type { ClientMiddlewareNextFunction, CreateActionData, CreateClientActionArgs, CreateClientLoaderArgs, CreateClientMiddlewareArgs, CreateComponentProps, CreateErrorBoundaryProps, CreateHydrateFallbackProps, CreateLoaderData, CreateMetaArgs, CreateServerActionArgs, CreateServerLoaderArgs, CreateServerMiddlewareArgs, HeadersArgs, LinkDescriptors, MetaDescriptors, ServerMiddlewareNextFunction };
|
|
@@ -260,6 +260,12 @@ type Submission = {
|
|
|
260
260
|
json: undefined;
|
|
261
261
|
text: string;
|
|
262
262
|
};
|
|
263
|
+
/**
|
|
264
|
+
* @private
|
|
265
|
+
* Default context value type for `createRouter`, can be overridden via the generics
|
|
266
|
+
* on LoaderFunction/LoaderFunctionArgs/ActionFunction/ActionFunctionArgs
|
|
267
|
+
*/
|
|
268
|
+
type DefaultRouterContext = any;
|
|
263
269
|
/**
|
|
264
270
|
* @private
|
|
265
271
|
* Arguments passed to route loader/action functions. Same for now but we keep
|
|
@@ -268,29 +274,38 @@ type Submission = {
|
|
|
268
274
|
interface DataFunctionArgs<Context> {
|
|
269
275
|
request: Request;
|
|
270
276
|
params: Params;
|
|
271
|
-
context
|
|
277
|
+
context: Context;
|
|
272
278
|
}
|
|
279
|
+
type BaseMiddlewareFunction<Result, Context> = {
|
|
280
|
+
(args: DataFunctionArgs<Context>, next: () => Promise<Result>): Result | Promise<Result>;
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Server-side route middleware function signature
|
|
284
|
+
*/
|
|
285
|
+
type MiddlewareFunction<Context = DefaultRouterContext> = BaseMiddlewareFunction<unknown, Context>;
|
|
286
|
+
/**
|
|
287
|
+
* Client-side route middleware function signature
|
|
288
|
+
*/
|
|
289
|
+
type ClientMiddlewareFunction<Context = DefaultRouterContext> = BaseMiddlewareFunction<unknown, Context>;
|
|
273
290
|
/**
|
|
274
291
|
* Arguments passed to loader functions
|
|
275
292
|
*/
|
|
276
|
-
interface LoaderFunctionArgs<Context =
|
|
293
|
+
interface LoaderFunctionArgs<Context = DefaultRouterContext> extends DataFunctionArgs<Context> {
|
|
277
294
|
}
|
|
278
295
|
/**
|
|
279
296
|
* Arguments passed to action functions
|
|
280
297
|
*/
|
|
281
|
-
interface ActionFunctionArgs<Context =
|
|
298
|
+
interface ActionFunctionArgs<Context = DefaultRouterContext> extends DataFunctionArgs<Context> {
|
|
282
299
|
}
|
|
283
300
|
/**
|
|
284
|
-
* Loaders and actions can return anything
|
|
285
|
-
* valid return value if there is no data to return). Responses are preferred
|
|
286
|
-
* and will ease any future migration to Remix
|
|
301
|
+
* Loaders and actions can return anything
|
|
287
302
|
*/
|
|
288
|
-
type DataFunctionValue =
|
|
303
|
+
type DataFunctionValue = unknown;
|
|
289
304
|
type DataFunctionReturnValue = Promise<DataFunctionValue> | DataFunctionValue;
|
|
290
305
|
/**
|
|
291
306
|
* Route loader function signature
|
|
292
307
|
*/
|
|
293
|
-
type LoaderFunction<Context =
|
|
308
|
+
type LoaderFunction<Context = DefaultRouterContext> = {
|
|
294
309
|
(args: LoaderFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
|
|
295
310
|
} & {
|
|
296
311
|
hydrate?: boolean;
|
|
@@ -298,7 +313,7 @@ type LoaderFunction<Context = any> = {
|
|
|
298
313
|
/**
|
|
299
314
|
* Route action function signature
|
|
300
315
|
*/
|
|
301
|
-
interface ActionFunction<Context =
|
|
316
|
+
interface ActionFunction<Context = DefaultRouterContext> {
|
|
302
317
|
(args: ActionFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
|
|
303
318
|
}
|
|
304
319
|
/**
|
|
@@ -333,7 +348,7 @@ interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRoute
|
|
|
333
348
|
shouldLoad: boolean;
|
|
334
349
|
resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
|
|
335
350
|
}
|
|
336
|
-
interface DataStrategyFunctionArgs<Context =
|
|
351
|
+
interface DataStrategyFunctionArgs<Context = DefaultRouterContext> extends DataFunctionArgs<Context> {
|
|
337
352
|
matches: DataStrategyMatch[];
|
|
338
353
|
fetcherKey: string | null;
|
|
339
354
|
}
|
|
@@ -385,6 +400,7 @@ type AgnosticBaseRouteObject = {
|
|
|
385
400
|
caseSensitive?: boolean;
|
|
386
401
|
path?: string;
|
|
387
402
|
id?: string;
|
|
403
|
+
middleware?: ClientMiddlewareFunction[];
|
|
388
404
|
loader?: LoaderFunction | boolean;
|
|
389
405
|
action?: ActionFunction | boolean;
|
|
390
406
|
hasErrorBoundary?: boolean;
|
|
@@ -868,6 +884,7 @@ interface RouterInit {
|
|
|
868
884
|
routes: AgnosticRouteObject[];
|
|
869
885
|
history: History;
|
|
870
886
|
basename?: string;
|
|
887
|
+
context?: DefaultRouterContext;
|
|
871
888
|
mapRouteProperties?: MapRoutePropertiesFunction;
|
|
872
889
|
future?: Partial<FutureConfig>;
|
|
873
890
|
hydrationData?: HydrationState;
|
|
@@ -899,11 +916,13 @@ interface StaticHandler {
|
|
|
899
916
|
requestContext?: unknown;
|
|
900
917
|
skipLoaderErrorBubbling?: boolean;
|
|
901
918
|
dataStrategy?: DataStrategyFunction;
|
|
919
|
+
respond?: (staticContext: StaticHandlerContext) => Promise<Response>;
|
|
902
920
|
}): Promise<StaticHandlerContext | Response>;
|
|
903
921
|
queryRoute(request: Request, opts?: {
|
|
904
922
|
routeId?: string;
|
|
905
923
|
requestContext?: unknown;
|
|
906
924
|
dataStrategy?: DataStrategyFunction;
|
|
925
|
+
respond?: (staticContext: StaticHandlerContext) => Promise<Response>;
|
|
907
926
|
}): Promise<any>;
|
|
908
927
|
}
|
|
909
928
|
type ViewTransitionOpts = {
|
|
@@ -1137,6 +1156,7 @@ interface IndexRouteObject {
|
|
|
1137
1156
|
caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];
|
|
1138
1157
|
path?: AgnosticIndexRouteObject["path"];
|
|
1139
1158
|
id?: AgnosticIndexRouteObject["id"];
|
|
1159
|
+
middleware?: AgnosticIndexRouteObject["middleware"];
|
|
1140
1160
|
loader?: AgnosticIndexRouteObject["loader"];
|
|
1141
1161
|
action?: AgnosticIndexRouteObject["action"];
|
|
1142
1162
|
hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
|
|
@@ -1156,6 +1176,7 @@ interface NonIndexRouteObject {
|
|
|
1156
1176
|
caseSensitive?: AgnosticNonIndexRouteObject["caseSensitive"];
|
|
1157
1177
|
path?: AgnosticNonIndexRouteObject["path"];
|
|
1158
1178
|
id?: AgnosticNonIndexRouteObject["id"];
|
|
1179
|
+
middleware?: AgnosticNonIndexRouteObject["middleware"];
|
|
1159
1180
|
loader?: AgnosticNonIndexRouteObject["loader"];
|
|
1160
1181
|
action?: AgnosticNonIndexRouteObject["action"];
|
|
1161
1182
|
hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
|
|
@@ -1352,6 +1373,7 @@ interface RouteModules {
|
|
|
1352
1373
|
interface RouteModule {
|
|
1353
1374
|
clientAction?: ClientActionFunction;
|
|
1354
1375
|
clientLoader?: ClientLoaderFunction;
|
|
1376
|
+
clientMiddleware?: ClientMiddlewareFunction[];
|
|
1355
1377
|
ErrorBoundary?: ErrorBoundaryComponent;
|
|
1356
1378
|
HydrateFallback?: HydrateFallbackComponent;
|
|
1357
1379
|
Layout?: LayoutComponent;
|
|
@@ -1368,7 +1390,7 @@ type ClientActionFunction = (args: ClientActionFunctionArgs) => ReturnType<Actio
|
|
|
1368
1390
|
/**
|
|
1369
1391
|
* Arguments passed to a route `clientAction` function
|
|
1370
1392
|
*/
|
|
1371
|
-
type ClientActionFunctionArgs = ActionFunctionArgs
|
|
1393
|
+
type ClientActionFunctionArgs = ActionFunctionArgs & {
|
|
1372
1394
|
serverAction: <T = unknown>() => Promise<SerializeFrom<T>>;
|
|
1373
1395
|
};
|
|
1374
1396
|
/**
|
|
@@ -1380,7 +1402,7 @@ type ClientLoaderFunction = ((args: ClientLoaderFunctionArgs) => ReturnType<Load
|
|
|
1380
1402
|
/**
|
|
1381
1403
|
* Arguments passed to a route `clientLoader` function
|
|
1382
1404
|
*/
|
|
1383
|
-
type ClientLoaderFunctionArgs = LoaderFunctionArgs
|
|
1405
|
+
type ClientLoaderFunctionArgs = LoaderFunctionArgs & {
|
|
1384
1406
|
serverLoader: <T = unknown>() => Promise<SerializeFrom<T>>;
|
|
1385
1407
|
};
|
|
1386
1408
|
/**
|
|
@@ -1537,10 +1559,10 @@ type Serialize<T> = T extends Serializable ? T : T extends (...args: any[]) => u
|
|
|
1537
1559
|
} : undefined;
|
|
1538
1560
|
type VoidToUndefined<T> = Equal<T, void> extends true ? undefined : T;
|
|
1539
1561
|
type DataFrom<T> = IsAny<T> extends true ? undefined : T extends Func ? VoidToUndefined<Awaited<ReturnType<T>>> : undefined;
|
|
1540
|
-
type ClientData<T> = T extends
|
|
1541
|
-
type ServerData<T> = T extends
|
|
1562
|
+
type ClientData<T> = T extends DataWithResponseInit<infer U> ? U : T;
|
|
1563
|
+
type ServerData<T> = T extends DataWithResponseInit<infer U> ? Serialize<U> : Serialize<T>;
|
|
1542
1564
|
type ServerDataFrom<T> = ServerData<DataFrom<T>>;
|
|
1543
1565
|
type ClientDataFrom<T> = ClientData<DataFrom<T>>;
|
|
1544
1566
|
type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [ClientLoaderFunctionArgs | ClientActionFunctionArgs] ? ClientDataFrom<T> : ServerDataFrom<T> : T;
|
|
1545
1567
|
|
|
1546
|
-
export { type
|
|
1568
|
+
export { type ErrorResponse as $, type ActionFunction as A, type BlockerFunction as B, type ClientActionFunction as C, type DefaultRouterContext as D, type GetScrollRestorationKeyFunction as E, type FutureConfig as F, type GetScrollPositionFunction as G, type HydrationState as H, type InitialEntry as I, type Fetcher as J, type NavigationStates as K, type LoaderFunction as L, type MiddlewareFunction as M, type NavigateOptions as N, type RouterInit as O, type ParamParseKey as P, type RouterSubscriber as Q, type RouteModules as R, type SerializeFrom as S, type To as T, type UIMatch as U, type RouterNavigateOptions as V, type RouterFetchOptions as W, type DataStrategyFunctionArgs as X, type DataStrategyMatch as Y, type DataStrategyResult as Z, DataWithResponseInit as _, type Router as a, type FormEncType as a0, type FormMethod as a1, type HTMLFormMethod as a2, type LazyRouteFunction as a3, type PathParam as a4, type RedirectFunction as a5, type ShouldRevalidateFunction as a6, type ShouldRevalidateFunctionArgs as a7, createPath as a8, parsePath as a9, invariant as aA, createRouter as aB, ErrorResponseImpl as aC, DataRouterContext as aD, DataRouterStateContext as aE, FetchersContext as aF, LocationContext as aG, NavigationContext as aH, RouteContext as aI, ViewTransitionContext as aJ, type RouteModule as aK, type History as aL, type ServerDataFrom as aM, type ClientDataFrom as aN, type Func as aO, type Equal as aP, type Pretty as aQ, IDLE_NAVIGATION as aa, IDLE_FETCHER as ab, IDLE_BLOCKER as ac, data as ad, generatePath as ae, isRouteErrorResponse as af, matchPath as ag, matchRoutes as ah, redirect as ai, redirectDocument as aj, replace as ak, resolvePath as al, type DataRouteMatch as am, type DataRouteObject as an, type Navigator as ao, type PatchRoutesOnNavigationFunction as ap, type PatchRoutesOnNavigationFunctionArgs as aq, type RouteMatch as ar, type ClientActionFunctionArgs as as, type ClientLoaderFunctionArgs as at, type MetaArgs as au, type MetaDescriptor as av, type PageLinkDescriptor as aw, type HtmlLinkDescriptor as ax, type LinkDescriptor as ay, createBrowserHistory as az, type DataStrategyFunction as b, type ClientLoaderFunction as c, type ClientMiddlewareFunction as d, type LinksFunction as e, type MetaFunction as f, type RouteManifest as g, type LoaderFunctionArgs as h, type ActionFunctionArgs as i, type RelativeRoutingType as j, type Location as k, Action as l, type Path as m, type PathPattern as n, type PathMatch as o, type Params as p, type RouteObject as q, type Navigation as r, type RevalidationState as s, type Blocker as t, type StaticHandlerContext as u, type StaticHandler as v, type CreateStaticHandlerOptions as w, type IndexRouteObject as x, type NonIndexRouteObject as y, type RouterState as z };
|
|
@@ -260,6 +260,12 @@ type Submission = {
|
|
|
260
260
|
json: undefined;
|
|
261
261
|
text: string;
|
|
262
262
|
};
|
|
263
|
+
/**
|
|
264
|
+
* @private
|
|
265
|
+
* Default context value type for `createRouter`, can be overridden via the generics
|
|
266
|
+
* on LoaderFunction/LoaderFunctionArgs/ActionFunction/ActionFunctionArgs
|
|
267
|
+
*/
|
|
268
|
+
type DefaultRouterContext = any;
|
|
263
269
|
/**
|
|
264
270
|
* @private
|
|
265
271
|
* Arguments passed to route loader/action functions. Same for now but we keep
|
|
@@ -268,29 +274,38 @@ type Submission = {
|
|
|
268
274
|
interface DataFunctionArgs<Context> {
|
|
269
275
|
request: Request;
|
|
270
276
|
params: Params;
|
|
271
|
-
context
|
|
277
|
+
context: Context;
|
|
272
278
|
}
|
|
279
|
+
type BaseMiddlewareFunction<Result, Context> = {
|
|
280
|
+
(args: DataFunctionArgs<Context>, next: () => Promise<Result>): Result | Promise<Result>;
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Server-side route middleware function signature
|
|
284
|
+
*/
|
|
285
|
+
type MiddlewareFunction<Context = DefaultRouterContext> = BaseMiddlewareFunction<unknown, Context>;
|
|
286
|
+
/**
|
|
287
|
+
* Client-side route middleware function signature
|
|
288
|
+
*/
|
|
289
|
+
type ClientMiddlewareFunction<Context = DefaultRouterContext> = BaseMiddlewareFunction<unknown, Context>;
|
|
273
290
|
/**
|
|
274
291
|
* Arguments passed to loader functions
|
|
275
292
|
*/
|
|
276
|
-
interface LoaderFunctionArgs<Context =
|
|
293
|
+
interface LoaderFunctionArgs<Context = DefaultRouterContext> extends DataFunctionArgs<Context> {
|
|
277
294
|
}
|
|
278
295
|
/**
|
|
279
296
|
* Arguments passed to action functions
|
|
280
297
|
*/
|
|
281
|
-
interface ActionFunctionArgs<Context =
|
|
298
|
+
interface ActionFunctionArgs<Context = DefaultRouterContext> extends DataFunctionArgs<Context> {
|
|
282
299
|
}
|
|
283
300
|
/**
|
|
284
|
-
* Loaders and actions can return anything
|
|
285
|
-
* valid return value if there is no data to return). Responses are preferred
|
|
286
|
-
* and will ease any future migration to Remix
|
|
301
|
+
* Loaders and actions can return anything
|
|
287
302
|
*/
|
|
288
|
-
type DataFunctionValue =
|
|
303
|
+
type DataFunctionValue = unknown;
|
|
289
304
|
type DataFunctionReturnValue = Promise<DataFunctionValue> | DataFunctionValue;
|
|
290
305
|
/**
|
|
291
306
|
* Route loader function signature
|
|
292
307
|
*/
|
|
293
|
-
type LoaderFunction<Context =
|
|
308
|
+
type LoaderFunction<Context = DefaultRouterContext> = {
|
|
294
309
|
(args: LoaderFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
|
|
295
310
|
} & {
|
|
296
311
|
hydrate?: boolean;
|
|
@@ -298,7 +313,7 @@ type LoaderFunction<Context = any> = {
|
|
|
298
313
|
/**
|
|
299
314
|
* Route action function signature
|
|
300
315
|
*/
|
|
301
|
-
interface ActionFunction<Context =
|
|
316
|
+
interface ActionFunction<Context = DefaultRouterContext> {
|
|
302
317
|
(args: ActionFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
|
|
303
318
|
}
|
|
304
319
|
/**
|
|
@@ -333,7 +348,7 @@ interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRoute
|
|
|
333
348
|
shouldLoad: boolean;
|
|
334
349
|
resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
|
|
335
350
|
}
|
|
336
|
-
interface DataStrategyFunctionArgs<Context =
|
|
351
|
+
interface DataStrategyFunctionArgs<Context = DefaultRouterContext> extends DataFunctionArgs<Context> {
|
|
337
352
|
matches: DataStrategyMatch[];
|
|
338
353
|
fetcherKey: string | null;
|
|
339
354
|
}
|
|
@@ -385,6 +400,7 @@ type AgnosticBaseRouteObject = {
|
|
|
385
400
|
caseSensitive?: boolean;
|
|
386
401
|
path?: string;
|
|
387
402
|
id?: string;
|
|
403
|
+
middleware?: ClientMiddlewareFunction[];
|
|
388
404
|
loader?: LoaderFunction | boolean;
|
|
389
405
|
action?: ActionFunction | boolean;
|
|
390
406
|
hasErrorBoundary?: boolean;
|
|
@@ -868,6 +884,7 @@ interface RouterInit {
|
|
|
868
884
|
routes: AgnosticRouteObject[];
|
|
869
885
|
history: History;
|
|
870
886
|
basename?: string;
|
|
887
|
+
context?: DefaultRouterContext;
|
|
871
888
|
mapRouteProperties?: MapRoutePropertiesFunction;
|
|
872
889
|
future?: Partial<FutureConfig>;
|
|
873
890
|
hydrationData?: HydrationState;
|
|
@@ -899,11 +916,13 @@ interface StaticHandler {
|
|
|
899
916
|
requestContext?: unknown;
|
|
900
917
|
skipLoaderErrorBubbling?: boolean;
|
|
901
918
|
dataStrategy?: DataStrategyFunction;
|
|
919
|
+
respond?: (staticContext: StaticHandlerContext) => Promise<Response>;
|
|
902
920
|
}): Promise<StaticHandlerContext | Response>;
|
|
903
921
|
queryRoute(request: Request, opts?: {
|
|
904
922
|
routeId?: string;
|
|
905
923
|
requestContext?: unknown;
|
|
906
924
|
dataStrategy?: DataStrategyFunction;
|
|
925
|
+
respond?: (staticContext: StaticHandlerContext) => Promise<Response>;
|
|
907
926
|
}): Promise<any>;
|
|
908
927
|
}
|
|
909
928
|
type ViewTransitionOpts = {
|
|
@@ -1137,6 +1156,7 @@ interface IndexRouteObject {
|
|
|
1137
1156
|
caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];
|
|
1138
1157
|
path?: AgnosticIndexRouteObject["path"];
|
|
1139
1158
|
id?: AgnosticIndexRouteObject["id"];
|
|
1159
|
+
middleware?: AgnosticIndexRouteObject["middleware"];
|
|
1140
1160
|
loader?: AgnosticIndexRouteObject["loader"];
|
|
1141
1161
|
action?: AgnosticIndexRouteObject["action"];
|
|
1142
1162
|
hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
|
|
@@ -1156,6 +1176,7 @@ interface NonIndexRouteObject {
|
|
|
1156
1176
|
caseSensitive?: AgnosticNonIndexRouteObject["caseSensitive"];
|
|
1157
1177
|
path?: AgnosticNonIndexRouteObject["path"];
|
|
1158
1178
|
id?: AgnosticNonIndexRouteObject["id"];
|
|
1179
|
+
middleware?: AgnosticNonIndexRouteObject["middleware"];
|
|
1159
1180
|
loader?: AgnosticNonIndexRouteObject["loader"];
|
|
1160
1181
|
action?: AgnosticNonIndexRouteObject["action"];
|
|
1161
1182
|
hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
|
|
@@ -1352,6 +1373,7 @@ interface RouteModules {
|
|
|
1352
1373
|
interface RouteModule {
|
|
1353
1374
|
clientAction?: ClientActionFunction;
|
|
1354
1375
|
clientLoader?: ClientLoaderFunction;
|
|
1376
|
+
clientMiddleware?: ClientMiddlewareFunction[];
|
|
1355
1377
|
ErrorBoundary?: ErrorBoundaryComponent;
|
|
1356
1378
|
HydrateFallback?: HydrateFallbackComponent;
|
|
1357
1379
|
Layout?: LayoutComponent;
|
|
@@ -1368,7 +1390,7 @@ type ClientActionFunction = (args: ClientActionFunctionArgs) => ReturnType<Actio
|
|
|
1368
1390
|
/**
|
|
1369
1391
|
* Arguments passed to a route `clientAction` function
|
|
1370
1392
|
*/
|
|
1371
|
-
type ClientActionFunctionArgs = ActionFunctionArgs
|
|
1393
|
+
type ClientActionFunctionArgs = ActionFunctionArgs & {
|
|
1372
1394
|
serverAction: <T = unknown>() => Promise<SerializeFrom<T>>;
|
|
1373
1395
|
};
|
|
1374
1396
|
/**
|
|
@@ -1380,7 +1402,7 @@ type ClientLoaderFunction = ((args: ClientLoaderFunctionArgs) => ReturnType<Load
|
|
|
1380
1402
|
/**
|
|
1381
1403
|
* Arguments passed to a route `clientLoader` function
|
|
1382
1404
|
*/
|
|
1383
|
-
type ClientLoaderFunctionArgs = LoaderFunctionArgs
|
|
1405
|
+
type ClientLoaderFunctionArgs = LoaderFunctionArgs & {
|
|
1384
1406
|
serverLoader: <T = unknown>() => Promise<SerializeFrom<T>>;
|
|
1385
1407
|
};
|
|
1386
1408
|
/**
|
|
@@ -1537,10 +1559,10 @@ type Serialize<T> = T extends Serializable ? T : T extends (...args: any[]) => u
|
|
|
1537
1559
|
} : undefined;
|
|
1538
1560
|
type VoidToUndefined<T> = Equal<T, void> extends true ? undefined : T;
|
|
1539
1561
|
type DataFrom<T> = IsAny<T> extends true ? undefined : T extends Func ? VoidToUndefined<Awaited<ReturnType<T>>> : undefined;
|
|
1540
|
-
type ClientData<T> = T extends
|
|
1541
|
-
type ServerData<T> = T extends
|
|
1562
|
+
type ClientData<T> = T extends DataWithResponseInit<infer U> ? U : T;
|
|
1563
|
+
type ServerData<T> = T extends DataWithResponseInit<infer U> ? Serialize<U> : Serialize<T>;
|
|
1542
1564
|
type ServerDataFrom<T> = ServerData<DataFrom<T>>;
|
|
1543
1565
|
type ClientDataFrom<T> = ClientData<DataFrom<T>>;
|
|
1544
1566
|
type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [ClientLoaderFunctionArgs | ClientActionFunctionArgs] ? ClientDataFrom<T> : ServerDataFrom<T> : T;
|
|
1545
1567
|
|
|
1546
|
-
export { type
|
|
1568
|
+
export { type ErrorResponse as $, type ActionFunction as A, type BlockerFunction as B, type ClientActionFunction as C, type DefaultRouterContext as D, type GetScrollRestorationKeyFunction as E, type FutureConfig as F, type GetScrollPositionFunction as G, type HydrationState as H, type InitialEntry as I, type Fetcher as J, type NavigationStates as K, type LoaderFunction as L, type MiddlewareFunction as M, type NavigateOptions as N, type RouterInit as O, type ParamParseKey as P, type RouterSubscriber as Q, type RouteModules as R, type SerializeFrom as S, type To as T, type UIMatch as U, type RouterNavigateOptions as V, type RouterFetchOptions as W, type DataStrategyFunctionArgs as X, type DataStrategyMatch as Y, type DataStrategyResult as Z, DataWithResponseInit as _, type Router as a, type FormEncType as a0, type FormMethod as a1, type HTMLFormMethod as a2, type LazyRouteFunction as a3, type PathParam as a4, type RedirectFunction as a5, type ShouldRevalidateFunction as a6, type ShouldRevalidateFunctionArgs as a7, createPath as a8, parsePath as a9, invariant as aA, createRouter as aB, ErrorResponseImpl as aC, DataRouterContext as aD, DataRouterStateContext as aE, FetchersContext as aF, LocationContext as aG, NavigationContext as aH, RouteContext as aI, ViewTransitionContext as aJ, type RouteModule as aK, type History as aL, type ServerDataFrom as aM, type ClientDataFrom as aN, type Func as aO, type Equal as aP, type Pretty as aQ, IDLE_NAVIGATION as aa, IDLE_FETCHER as ab, IDLE_BLOCKER as ac, data as ad, generatePath as ae, isRouteErrorResponse as af, matchPath as ag, matchRoutes as ah, redirect as ai, redirectDocument as aj, replace as ak, resolvePath as al, type DataRouteMatch as am, type DataRouteObject as an, type Navigator as ao, type PatchRoutesOnNavigationFunction as ap, type PatchRoutesOnNavigationFunctionArgs as aq, type RouteMatch as ar, type ClientActionFunctionArgs as as, type ClientLoaderFunctionArgs as at, type MetaArgs as au, type MetaDescriptor as av, type PageLinkDescriptor as aw, type HtmlLinkDescriptor as ax, type LinkDescriptor as ay, createBrowserHistory as az, type DataStrategyFunction as b, type ClientLoaderFunction as c, type ClientMiddlewareFunction as d, type LinksFunction as e, type MetaFunction as f, type RouteManifest as g, type LoaderFunctionArgs as h, type ActionFunctionArgs as i, type RelativeRoutingType as j, type Location as k, Action as l, type Path as m, type PathPattern as n, type PathMatch as o, type Params as p, type RouteObject as q, type Navigation as r, type RevalidationState as s, type Blocker as t, type StaticHandlerContext as u, type StaticHandler as v, type CreateStaticHandlerOptions as w, type IndexRouteObject as x, type NonIndexRouteObject as y, type RouterState as z };
|