react-router 7.14.1 → 7.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +105 -0
- package/dist/development/{browser-D-3-U2Jj.d.mts → browser-CRsXgNrY.d.mts} +2 -2
- package/dist/{production/browser-D-3-U2Jj.d.mts → development/browser-wDl1FZEL.d.ts} +2 -2
- package/dist/{production/chunk-3SUPTI2U.js → development/chunk-2D5H3HU3.js} +7 -7
- package/dist/development/{chunk-OE4NN4TA.mjs → chunk-5KNZJZUH.mjs} +362 -213
- package/dist/development/{chunk-YMKMFAYZ.js → chunk-AM3XM4LS.js} +314 -172
- package/dist/development/{chunk-BFXCU3MI.mjs → chunk-RMD3H4O3.mjs} +81 -62
- package/dist/development/{chunk-3F6IB66O.js → chunk-Z5YQYACE.js} +146 -139
- package/dist/{production/context-BzhbVly6.d.mts → development/context-BQs41HrG.d.mts} +94 -42
- package/dist/development/{routeModules-CM_clkdE.d.ts → data-BVUf681J.d.mts} +89 -56
- package/dist/{production/routeModules-CM_clkdE.d.ts → development/data-BqZ2x964.d.ts} +79 -46
- package/dist/development/dom-export.d.mts +9 -9
- package/dist/development/dom-export.d.ts +9 -9
- package/dist/development/dom-export.js +37 -40
- package/dist/development/dom-export.mjs +12 -15
- package/dist/development/{index-react-server-client-CimaPp9o.d.ts → index-react-server-client-CSv-KZBk.d.ts} +123 -121
- package/dist/{production/index-react-server-client-WSaoxloq.d.mts → development/index-react-server-client-Ck_yZ1qL.d.mts} +102 -100
- package/dist/development/index-react-server-client.d.mts +3 -3
- package/dist/development/index-react-server-client.d.ts +3 -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 +107 -36
- package/dist/development/index-react-server.d.ts +107 -36
- package/dist/development/index-react-server.js +60 -33
- package/dist/development/index-react-server.mjs +60 -33
- package/dist/development/index.d.mts +11 -11
- package/dist/development/index.d.ts +11 -11
- package/dist/development/index.js +174 -155
- package/dist/development/index.mjs +3 -3
- package/dist/{production/instrumentation-CMVbvxj9.d.ts → development/instrumentation-DlJ2QV7d.d.ts} +73 -21
- package/dist/development/lib/types/internal.d.mts +2 -2
- 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/development/{register-D1WlEpq9.d.ts → register-Bsscfj79.d.ts} +1 -1
- package/dist/{production/register-D1WlEpq9.d.ts → development/register-Df8okEea.d.mts} +1 -1
- package/dist/production/{browser-CtktEGQs.d.ts → browser-CRsXgNrY.d.mts} +2 -2
- package/dist/{development/browser-CtktEGQs.d.ts → production/browser-wDl1FZEL.d.ts} +2 -2
- package/dist/production/{chunk-G5ZWO7Q6.mjs → chunk-23ZOHYE5.mjs} +81 -62
- package/dist/{development/chunk-7VLQJKNG.js → production/chunk-7YXKJMLN.js} +7 -7
- package/dist/production/{chunk-SPR7R4GU.mjs → chunk-GM3PW4GX.mjs} +362 -213
- package/dist/production/{chunk-UVEQGZIH.js → chunk-LCJTIOKZ.js} +314 -172
- package/dist/production/{chunk-LIOP3ILM.js → chunk-YBQJ3ABE.js} +146 -139
- package/dist/{development/context-BzhbVly6.d.mts → production/context-BQs41HrG.d.mts} +94 -42
- package/dist/{development/routeModules-Djumx26z.d.mts → production/data-BVUf681J.d.mts} +79 -46
- package/dist/production/{routeModules-Djumx26z.d.mts → data-BqZ2x964.d.ts} +89 -56
- package/dist/production/dom-export.d.mts +9 -9
- package/dist/production/dom-export.d.ts +9 -9
- package/dist/production/dom-export.js +37 -40
- package/dist/production/dom-export.mjs +12 -15
- package/dist/production/{index-react-server-client-CimaPp9o.d.ts → index-react-server-client-CSv-KZBk.d.ts} +123 -121
- package/dist/{development/index-react-server-client-WSaoxloq.d.mts → production/index-react-server-client-Ck_yZ1qL.d.mts} +102 -100
- package/dist/production/index-react-server-client.d.mts +3 -3
- package/dist/production/index-react-server-client.d.ts +3 -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 +107 -36
- package/dist/production/index-react-server.d.ts +107 -36
- package/dist/production/index-react-server.js +60 -33
- package/dist/production/index-react-server.mjs +60 -33
- package/dist/production/index.d.mts +11 -11
- package/dist/production/index.d.ts +11 -11
- package/dist/production/index.js +174 -155
- package/dist/production/index.mjs +3 -3
- package/dist/{development/instrumentation-CMVbvxj9.d.ts → production/instrumentation-DlJ2QV7d.d.ts} +73 -21
- package/dist/production/lib/types/internal.d.mts +2 -2
- 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-aE9ob3TK.d.mts → production/register-Bsscfj79.d.ts} +1 -1
- package/dist/production/{register-aE9ob3TK.d.mts → register-Df8okEea.d.mts} +1 -1
- package/package.json +1 -1
|
@@ -64,7 +64,7 @@ interface Location<State = any> extends Path {
|
|
|
64
64
|
* The masked location displayed in the URL bar, which differs from the URL the
|
|
65
65
|
* router is operating on
|
|
66
66
|
*/
|
|
67
|
-
|
|
67
|
+
mask?: Path;
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* A change to the current location.
|
|
@@ -357,19 +357,19 @@ interface DataFunctionArgs<Context> {
|
|
|
357
357
|
/** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read headers (like cookies, and {@link https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams URLSearchParams} from the request. */
|
|
358
358
|
request: Request;
|
|
359
359
|
/**
|
|
360
|
-
* A URL instance representing the application location being navigated to or
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
360
|
+
* A URL instance representing the application location being navigated to or
|
|
361
|
+
* fetched. By default, this matches `request.url`.
|
|
362
|
+
*
|
|
363
|
+
* In Framework mode with `future.v8_passThroughRequests` enabled, this is a
|
|
364
|
+
* normalized URL with React-Router-specific implementation details removed
|
|
365
|
+
* (`.data` suffixes, `index`/`_routes` search params).
|
|
366
366
|
*/
|
|
367
|
-
|
|
367
|
+
url: URL;
|
|
368
368
|
/**
|
|
369
369
|
* Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
|
|
370
370
|
* Mostly useful as a identifier to aggregate on for logging/tracing/etc.
|
|
371
371
|
*/
|
|
372
|
-
|
|
372
|
+
pattern: string;
|
|
373
373
|
/**
|
|
374
374
|
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
|
375
375
|
* @example
|
|
@@ -756,6 +756,7 @@ type DataNonIndexRouteObject = NonIndexRouteObject & {
|
|
|
756
756
|
* A data route object, which is just a RouteObject with a required unique ID
|
|
757
757
|
*/
|
|
758
758
|
type DataRouteObject = DataIndexRouteObject | DataNonIndexRouteObject;
|
|
759
|
+
type RouteManifest<R = DataRouteObject> = Record<string, R | undefined>;
|
|
759
760
|
/**
|
|
760
761
|
* The parameters that were parsed from the URL path.
|
|
761
762
|
*/
|
|
@@ -839,6 +840,24 @@ interface UIMatch<Data = unknown, Handle = unknown> {
|
|
|
839
840
|
*/
|
|
840
841
|
handle: Handle;
|
|
841
842
|
}
|
|
843
|
+
interface RouteMeta<RouteObjectType extends RouteObject = RouteObject> {
|
|
844
|
+
relativePath: string;
|
|
845
|
+
caseSensitive: boolean;
|
|
846
|
+
childrenIndex: number;
|
|
847
|
+
route: RouteObjectType;
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* @private
|
|
851
|
+
* PRIVATE - DO NOT USE
|
|
852
|
+
*
|
|
853
|
+
* A "branch" of routes that match a given route pattern.
|
|
854
|
+
* This is an internal interface not intended for direct external usage.
|
|
855
|
+
*/
|
|
856
|
+
interface RouteBranch<RouteObjectType extends RouteObject = RouteObject> {
|
|
857
|
+
path: string;
|
|
858
|
+
score: number;
|
|
859
|
+
routesMeta: RouteMeta<RouteObjectType>[];
|
|
860
|
+
}
|
|
842
861
|
declare class DataWithResponseInit<D> {
|
|
843
862
|
type: string;
|
|
844
863
|
data: D;
|
|
@@ -1012,25 +1031,25 @@ interface AppLoadContext {
|
|
|
1012
1031
|
[key: string]: unknown;
|
|
1013
1032
|
}
|
|
1014
1033
|
|
|
1015
|
-
type
|
|
1016
|
-
handler?:
|
|
1017
|
-
route?:
|
|
1034
|
+
type ServerInstrumentation = {
|
|
1035
|
+
handler?: InstrumentRequestHandlerFunction;
|
|
1036
|
+
route?: InstrumentRouteFunction;
|
|
1018
1037
|
};
|
|
1019
|
-
type
|
|
1020
|
-
router?:
|
|
1021
|
-
route?:
|
|
1038
|
+
type ClientInstrumentation = {
|
|
1039
|
+
router?: InstrumentRouterFunction;
|
|
1040
|
+
route?: InstrumentRouteFunction;
|
|
1022
1041
|
};
|
|
1023
|
-
type
|
|
1024
|
-
type
|
|
1025
|
-
type
|
|
1026
|
-
type
|
|
1042
|
+
type InstrumentRequestHandlerFunction = (handler: InstrumentableRequestHandler) => void;
|
|
1043
|
+
type InstrumentRouterFunction = (router: InstrumentableRouter) => void;
|
|
1044
|
+
type InstrumentRouteFunction = (route: InstrumentableRoute) => void;
|
|
1045
|
+
type InstrumentationHandlerResult = {
|
|
1027
1046
|
status: "success";
|
|
1028
1047
|
error: undefined;
|
|
1029
1048
|
} | {
|
|
1030
1049
|
status: "error";
|
|
1031
1050
|
error: Error;
|
|
1032
1051
|
};
|
|
1033
|
-
type InstrumentFunction<T> = (handler: () => Promise<
|
|
1052
|
+
type InstrumentFunction<T> = (handler: () => Promise<InstrumentationHandlerResult>, info: T) => Promise<void>;
|
|
1034
1053
|
type ReadonlyRequest = {
|
|
1035
1054
|
method: string;
|
|
1036
1055
|
url: string;
|
|
@@ -1056,7 +1075,7 @@ type RouteLazyInstrumentationInfo = undefined;
|
|
|
1056
1075
|
type RouteHandlerInstrumentationInfo = Readonly<{
|
|
1057
1076
|
request: ReadonlyRequest;
|
|
1058
1077
|
params: LoaderFunctionArgs["params"];
|
|
1059
|
-
|
|
1078
|
+
pattern: string;
|
|
1060
1079
|
context: ReadonlyContext;
|
|
1061
1080
|
}>;
|
|
1062
1081
|
type InstrumentableRouter = {
|
|
@@ -1126,6 +1145,20 @@ interface Router {
|
|
|
1126
1145
|
* Return the routes for this router instance
|
|
1127
1146
|
*/
|
|
1128
1147
|
get routes(): DataRouteObject[];
|
|
1148
|
+
/**
|
|
1149
|
+
* @private
|
|
1150
|
+
* PRIVATE - DO NOT USE
|
|
1151
|
+
*
|
|
1152
|
+
* Return the route branches for this router instance
|
|
1153
|
+
*/
|
|
1154
|
+
get branches(): RouteBranch<DataRouteObject>[] | undefined;
|
|
1155
|
+
/**
|
|
1156
|
+
* @private
|
|
1157
|
+
* PRIVATE - DO NOT USE
|
|
1158
|
+
*
|
|
1159
|
+
* Return the manifest for this router instance
|
|
1160
|
+
*/
|
|
1161
|
+
get manifest(): RouteManifest;
|
|
1129
1162
|
/**
|
|
1130
1163
|
* @private
|
|
1131
1164
|
* PRIVATE - DO NOT USE
|
|
@@ -1373,7 +1406,6 @@ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "e
|
|
|
1373
1406
|
* Future flags to toggle new feature behavior
|
|
1374
1407
|
*/
|
|
1375
1408
|
interface FutureConfig {
|
|
1376
|
-
unstable_passThroughRequests: boolean;
|
|
1377
1409
|
}
|
|
1378
1410
|
/**
|
|
1379
1411
|
* Initialization options for createRouter
|
|
@@ -1383,7 +1415,7 @@ interface RouterInit {
|
|
|
1383
1415
|
history: History;
|
|
1384
1416
|
basename?: string;
|
|
1385
1417
|
getContext?: () => MaybePromise<RouterContextProvider>;
|
|
1386
|
-
|
|
1418
|
+
instrumentations?: ClientInstrumentation[];
|
|
1387
1419
|
mapRouteProperties?: MapRoutePropertiesFunction;
|
|
1388
1420
|
future?: Partial<FutureConfig>;
|
|
1389
1421
|
hydrationRouteProperties?: string[];
|
|
@@ -1411,7 +1443,33 @@ interface StaticHandlerContext {
|
|
|
1411
1443
|
* A StaticHandler instance manages a singular SSR navigation/fetch event
|
|
1412
1444
|
*/
|
|
1413
1445
|
interface StaticHandler {
|
|
1446
|
+
/**
|
|
1447
|
+
* The set of data routes managed by this handler
|
|
1448
|
+
*/
|
|
1414
1449
|
dataRoutes: DataRouteObject[];
|
|
1450
|
+
/**
|
|
1451
|
+
* @private
|
|
1452
|
+
* PRIVATE - DO NOT USE
|
|
1453
|
+
*
|
|
1454
|
+
* The route branches derived from the data routes, used for internal route
|
|
1455
|
+
* matching in Framework Mode
|
|
1456
|
+
*/
|
|
1457
|
+
_internalRouteBranches: RouteBranch<DataRouteObject>[];
|
|
1458
|
+
/**
|
|
1459
|
+
* Perform a query for a given request - executing all matched route
|
|
1460
|
+
* loaders/actions. Used for document requests.
|
|
1461
|
+
*
|
|
1462
|
+
* @param request The request to query
|
|
1463
|
+
* @param opts Optional query options
|
|
1464
|
+
* @param opts.dataStrategy Alternate dataStrategy implementation
|
|
1465
|
+
* @param opts.filterMatchesToLoad Predicate function to filter which matches should be loaded
|
|
1466
|
+
* @param opts.generateMiddlewareResponse To enable middleware, provide a function
|
|
1467
|
+
* to generate a response to bubble back up the middleware chain
|
|
1468
|
+
* @param opts.requestContext Context object to pass to loaders/actions
|
|
1469
|
+
* @param opts.skipLoaderErrorBubbling Skip loader error bubbling
|
|
1470
|
+
* @param opts.skipRevalidation Skip revalidation after action submission
|
|
1471
|
+
* @param opts.normalizePath Normalize the request path
|
|
1472
|
+
*/
|
|
1415
1473
|
query(request: Request, opts?: {
|
|
1416
1474
|
requestContext?: unknown;
|
|
1417
1475
|
filterMatchesToLoad?: (match: DataRouteMatch) => boolean;
|
|
@@ -1421,14 +1479,27 @@ interface StaticHandler {
|
|
|
1421
1479
|
generateMiddlewareResponse?: (query: (r: Request, args?: {
|
|
1422
1480
|
filterMatchesToLoad?: (match: DataRouteMatch) => boolean;
|
|
1423
1481
|
}) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
|
|
1424
|
-
|
|
1482
|
+
normalizePath?: (request: Request) => Path;
|
|
1425
1483
|
}): Promise<StaticHandlerContext | Response>;
|
|
1484
|
+
/**
|
|
1485
|
+
* Perform a query for a specific route. Used for resource requests.
|
|
1486
|
+
*
|
|
1487
|
+
* @param request The request to query
|
|
1488
|
+
* @param opts Optional queryRoute options
|
|
1489
|
+
* @param opts.dataStrategy Alternate dataStrategy implementation
|
|
1490
|
+
* @param opts.generateMiddlewareResponse To enable middleware, provide a function
|
|
1491
|
+
* to generate a response to bubble back up the middleware chain
|
|
1492
|
+
* @param opts.requestContext Context object to pass to loaders/actions
|
|
1493
|
+
* @param opts.routeId The ID of the route to query
|
|
1494
|
+
* @param opts.normalizePath Normalize the request path
|
|
1495
|
+
|
|
1496
|
+
*/
|
|
1426
1497
|
queryRoute(request: Request, opts?: {
|
|
1427
1498
|
routeId?: string;
|
|
1428
1499
|
requestContext?: unknown;
|
|
1429
1500
|
dataStrategy?: DataStrategyFunction<unknown>;
|
|
1430
1501
|
generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
|
|
1431
|
-
|
|
1502
|
+
normalizePath?: (request: Request) => Path;
|
|
1432
1503
|
}): Promise<any>;
|
|
1433
1504
|
}
|
|
1434
1505
|
type ViewTransitionOpts = {
|
|
@@ -1472,14 +1543,14 @@ type BaseNavigateOrFetchOptions = {
|
|
|
1472
1543
|
preventScrollReset?: boolean;
|
|
1473
1544
|
relative?: RelativeRoutingType;
|
|
1474
1545
|
flushSync?: boolean;
|
|
1475
|
-
|
|
1546
|
+
defaultShouldRevalidate?: boolean;
|
|
1476
1547
|
};
|
|
1477
1548
|
type BaseNavigateOptions = BaseNavigateOrFetchOptions & {
|
|
1478
1549
|
replace?: boolean;
|
|
1479
1550
|
state?: any;
|
|
1480
1551
|
fromRouteId?: string;
|
|
1481
1552
|
viewTransition?: boolean;
|
|
1482
|
-
|
|
1553
|
+
mask?: To;
|
|
1483
1554
|
};
|
|
1484
1555
|
type BaseSubmissionOptions = {
|
|
1485
1556
|
formMethod?: HTMLFormMethod;
|
|
@@ -1655,7 +1726,7 @@ type BlockerFunction = (args: {
|
|
|
1655
1726
|
interface CreateStaticHandlerOptions {
|
|
1656
1727
|
basename?: string;
|
|
1657
1728
|
mapRouteProperties?: MapRoutePropertiesFunction;
|
|
1658
|
-
|
|
1729
|
+
instrumentations?: Pick<ServerInstrumentation, "route">[];
|
|
1659
1730
|
future?: Partial<FutureConfig>;
|
|
1660
1731
|
}
|
|
1661
1732
|
declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
|
|
@@ -1805,14 +1876,14 @@ type ClientDataFunctionArgs<Params> = {
|
|
|
1805
1876
|
**/
|
|
1806
1877
|
request: Request;
|
|
1807
1878
|
/**
|
|
1808
|
-
* A URL instance representing the application location being navigated to or
|
|
1809
|
-
*
|
|
1810
|
-
*
|
|
1811
|
-
*
|
|
1812
|
-
*
|
|
1813
|
-
*
|
|
1879
|
+
* A URL instance representing the application location being navigated to or
|
|
1880
|
+
* fetched. By default, this matches `request.url`.
|
|
1881
|
+
*
|
|
1882
|
+
* In Framework mode with `future.v8_passThroughRequests` enabled, this is a
|
|
1883
|
+
* normalized URL with React-Router-specific implementation details removed
|
|
1884
|
+
* (`.data` suffixes, `index`/`_routes` search params).
|
|
1814
1885
|
*/
|
|
1815
|
-
|
|
1886
|
+
url: URL;
|
|
1816
1887
|
/**
|
|
1817
1888
|
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
|
1818
1889
|
* @example
|
|
@@ -1832,7 +1903,7 @@ type ClientDataFunctionArgs<Params> = {
|
|
|
1832
1903
|
* Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
|
|
1833
1904
|
* Mostly useful as a identifier to aggregate on for logging/tracing/etc.
|
|
1834
1905
|
*/
|
|
1835
|
-
|
|
1906
|
+
pattern: string;
|
|
1836
1907
|
/**
|
|
1837
1908
|
* When `future.v8_middleware` is not enabled, this is undefined.
|
|
1838
1909
|
*
|
|
@@ -64,7 +64,7 @@ interface Location<State = any> extends Path {
|
|
|
64
64
|
* The masked location displayed in the URL bar, which differs from the URL the
|
|
65
65
|
* router is operating on
|
|
66
66
|
*/
|
|
67
|
-
|
|
67
|
+
mask?: Path;
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* A change to the current location.
|
|
@@ -357,19 +357,19 @@ interface DataFunctionArgs<Context> {
|
|
|
357
357
|
/** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read headers (like cookies, and {@link https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams URLSearchParams} from the request. */
|
|
358
358
|
request: Request;
|
|
359
359
|
/**
|
|
360
|
-
* A URL instance representing the application location being navigated to or
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
360
|
+
* A URL instance representing the application location being navigated to or
|
|
361
|
+
* fetched. By default, this matches `request.url`.
|
|
362
|
+
*
|
|
363
|
+
* In Framework mode with `future.v8_passThroughRequests` enabled, this is a
|
|
364
|
+
* normalized URL with React-Router-specific implementation details removed
|
|
365
|
+
* (`.data` suffixes, `index`/`_routes` search params).
|
|
366
366
|
*/
|
|
367
|
-
|
|
367
|
+
url: URL;
|
|
368
368
|
/**
|
|
369
369
|
* Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
|
|
370
370
|
* Mostly useful as a identifier to aggregate on for logging/tracing/etc.
|
|
371
371
|
*/
|
|
372
|
-
|
|
372
|
+
pattern: string;
|
|
373
373
|
/**
|
|
374
374
|
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
|
375
375
|
* @example
|
|
@@ -756,6 +756,7 @@ type DataNonIndexRouteObject = NonIndexRouteObject & {
|
|
|
756
756
|
* A data route object, which is just a RouteObject with a required unique ID
|
|
757
757
|
*/
|
|
758
758
|
type DataRouteObject = DataIndexRouteObject | DataNonIndexRouteObject;
|
|
759
|
+
type RouteManifest<R = DataRouteObject> = Record<string, R | undefined>;
|
|
759
760
|
/**
|
|
760
761
|
* The parameters that were parsed from the URL path.
|
|
761
762
|
*/
|
|
@@ -839,6 +840,24 @@ interface UIMatch<Data = unknown, Handle = unknown> {
|
|
|
839
840
|
*/
|
|
840
841
|
handle: Handle;
|
|
841
842
|
}
|
|
843
|
+
interface RouteMeta<RouteObjectType extends RouteObject = RouteObject> {
|
|
844
|
+
relativePath: string;
|
|
845
|
+
caseSensitive: boolean;
|
|
846
|
+
childrenIndex: number;
|
|
847
|
+
route: RouteObjectType;
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* @private
|
|
851
|
+
* PRIVATE - DO NOT USE
|
|
852
|
+
*
|
|
853
|
+
* A "branch" of routes that match a given route pattern.
|
|
854
|
+
* This is an internal interface not intended for direct external usage.
|
|
855
|
+
*/
|
|
856
|
+
interface RouteBranch<RouteObjectType extends RouteObject = RouteObject> {
|
|
857
|
+
path: string;
|
|
858
|
+
score: number;
|
|
859
|
+
routesMeta: RouteMeta<RouteObjectType>[];
|
|
860
|
+
}
|
|
842
861
|
declare class DataWithResponseInit<D> {
|
|
843
862
|
type: string;
|
|
844
863
|
data: D;
|
|
@@ -1012,25 +1031,25 @@ interface AppLoadContext {
|
|
|
1012
1031
|
[key: string]: unknown;
|
|
1013
1032
|
}
|
|
1014
1033
|
|
|
1015
|
-
type
|
|
1016
|
-
handler?:
|
|
1017
|
-
route?:
|
|
1034
|
+
type ServerInstrumentation = {
|
|
1035
|
+
handler?: InstrumentRequestHandlerFunction;
|
|
1036
|
+
route?: InstrumentRouteFunction;
|
|
1018
1037
|
};
|
|
1019
|
-
type
|
|
1020
|
-
router?:
|
|
1021
|
-
route?:
|
|
1038
|
+
type ClientInstrumentation = {
|
|
1039
|
+
router?: InstrumentRouterFunction;
|
|
1040
|
+
route?: InstrumentRouteFunction;
|
|
1022
1041
|
};
|
|
1023
|
-
type
|
|
1024
|
-
type
|
|
1025
|
-
type
|
|
1026
|
-
type
|
|
1042
|
+
type InstrumentRequestHandlerFunction = (handler: InstrumentableRequestHandler) => void;
|
|
1043
|
+
type InstrumentRouterFunction = (router: InstrumentableRouter) => void;
|
|
1044
|
+
type InstrumentRouteFunction = (route: InstrumentableRoute) => void;
|
|
1045
|
+
type InstrumentationHandlerResult = {
|
|
1027
1046
|
status: "success";
|
|
1028
1047
|
error: undefined;
|
|
1029
1048
|
} | {
|
|
1030
1049
|
status: "error";
|
|
1031
1050
|
error: Error;
|
|
1032
1051
|
};
|
|
1033
|
-
type InstrumentFunction<T> = (handler: () => Promise<
|
|
1052
|
+
type InstrumentFunction<T> = (handler: () => Promise<InstrumentationHandlerResult>, info: T) => Promise<void>;
|
|
1034
1053
|
type ReadonlyRequest = {
|
|
1035
1054
|
method: string;
|
|
1036
1055
|
url: string;
|
|
@@ -1056,7 +1075,7 @@ type RouteLazyInstrumentationInfo = undefined;
|
|
|
1056
1075
|
type RouteHandlerInstrumentationInfo = Readonly<{
|
|
1057
1076
|
request: ReadonlyRequest;
|
|
1058
1077
|
params: LoaderFunctionArgs["params"];
|
|
1059
|
-
|
|
1078
|
+
pattern: string;
|
|
1060
1079
|
context: ReadonlyContext;
|
|
1061
1080
|
}>;
|
|
1062
1081
|
type InstrumentableRouter = {
|
|
@@ -1126,6 +1145,20 @@ interface Router {
|
|
|
1126
1145
|
* Return the routes for this router instance
|
|
1127
1146
|
*/
|
|
1128
1147
|
get routes(): DataRouteObject[];
|
|
1148
|
+
/**
|
|
1149
|
+
* @private
|
|
1150
|
+
* PRIVATE - DO NOT USE
|
|
1151
|
+
*
|
|
1152
|
+
* Return the route branches for this router instance
|
|
1153
|
+
*/
|
|
1154
|
+
get branches(): RouteBranch<DataRouteObject>[] | undefined;
|
|
1155
|
+
/**
|
|
1156
|
+
* @private
|
|
1157
|
+
* PRIVATE - DO NOT USE
|
|
1158
|
+
*
|
|
1159
|
+
* Return the manifest for this router instance
|
|
1160
|
+
*/
|
|
1161
|
+
get manifest(): RouteManifest;
|
|
1129
1162
|
/**
|
|
1130
1163
|
* @private
|
|
1131
1164
|
* PRIVATE - DO NOT USE
|
|
@@ -1373,7 +1406,6 @@ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "e
|
|
|
1373
1406
|
* Future flags to toggle new feature behavior
|
|
1374
1407
|
*/
|
|
1375
1408
|
interface FutureConfig {
|
|
1376
|
-
unstable_passThroughRequests: boolean;
|
|
1377
1409
|
}
|
|
1378
1410
|
/**
|
|
1379
1411
|
* Initialization options for createRouter
|
|
@@ -1383,7 +1415,7 @@ interface RouterInit {
|
|
|
1383
1415
|
history: History;
|
|
1384
1416
|
basename?: string;
|
|
1385
1417
|
getContext?: () => MaybePromise<RouterContextProvider>;
|
|
1386
|
-
|
|
1418
|
+
instrumentations?: ClientInstrumentation[];
|
|
1387
1419
|
mapRouteProperties?: MapRoutePropertiesFunction;
|
|
1388
1420
|
future?: Partial<FutureConfig>;
|
|
1389
1421
|
hydrationRouteProperties?: string[];
|
|
@@ -1411,7 +1443,33 @@ interface StaticHandlerContext {
|
|
|
1411
1443
|
* A StaticHandler instance manages a singular SSR navigation/fetch event
|
|
1412
1444
|
*/
|
|
1413
1445
|
interface StaticHandler {
|
|
1446
|
+
/**
|
|
1447
|
+
* The set of data routes managed by this handler
|
|
1448
|
+
*/
|
|
1414
1449
|
dataRoutes: DataRouteObject[];
|
|
1450
|
+
/**
|
|
1451
|
+
* @private
|
|
1452
|
+
* PRIVATE - DO NOT USE
|
|
1453
|
+
*
|
|
1454
|
+
* The route branches derived from the data routes, used for internal route
|
|
1455
|
+
* matching in Framework Mode
|
|
1456
|
+
*/
|
|
1457
|
+
_internalRouteBranches: RouteBranch<DataRouteObject>[];
|
|
1458
|
+
/**
|
|
1459
|
+
* Perform a query for a given request - executing all matched route
|
|
1460
|
+
* loaders/actions. Used for document requests.
|
|
1461
|
+
*
|
|
1462
|
+
* @param request The request to query
|
|
1463
|
+
* @param opts Optional query options
|
|
1464
|
+
* @param opts.dataStrategy Alternate dataStrategy implementation
|
|
1465
|
+
* @param opts.filterMatchesToLoad Predicate function to filter which matches should be loaded
|
|
1466
|
+
* @param opts.generateMiddlewareResponse To enable middleware, provide a function
|
|
1467
|
+
* to generate a response to bubble back up the middleware chain
|
|
1468
|
+
* @param opts.requestContext Context object to pass to loaders/actions
|
|
1469
|
+
* @param opts.skipLoaderErrorBubbling Skip loader error bubbling
|
|
1470
|
+
* @param opts.skipRevalidation Skip revalidation after action submission
|
|
1471
|
+
* @param opts.normalizePath Normalize the request path
|
|
1472
|
+
*/
|
|
1415
1473
|
query(request: Request, opts?: {
|
|
1416
1474
|
requestContext?: unknown;
|
|
1417
1475
|
filterMatchesToLoad?: (match: DataRouteMatch) => boolean;
|
|
@@ -1421,14 +1479,27 @@ interface StaticHandler {
|
|
|
1421
1479
|
generateMiddlewareResponse?: (query: (r: Request, args?: {
|
|
1422
1480
|
filterMatchesToLoad?: (match: DataRouteMatch) => boolean;
|
|
1423
1481
|
}) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
|
|
1424
|
-
|
|
1482
|
+
normalizePath?: (request: Request) => Path;
|
|
1425
1483
|
}): Promise<StaticHandlerContext | Response>;
|
|
1484
|
+
/**
|
|
1485
|
+
* Perform a query for a specific route. Used for resource requests.
|
|
1486
|
+
*
|
|
1487
|
+
* @param request The request to query
|
|
1488
|
+
* @param opts Optional queryRoute options
|
|
1489
|
+
* @param opts.dataStrategy Alternate dataStrategy implementation
|
|
1490
|
+
* @param opts.generateMiddlewareResponse To enable middleware, provide a function
|
|
1491
|
+
* to generate a response to bubble back up the middleware chain
|
|
1492
|
+
* @param opts.requestContext Context object to pass to loaders/actions
|
|
1493
|
+
* @param opts.routeId The ID of the route to query
|
|
1494
|
+
* @param opts.normalizePath Normalize the request path
|
|
1495
|
+
|
|
1496
|
+
*/
|
|
1426
1497
|
queryRoute(request: Request, opts?: {
|
|
1427
1498
|
routeId?: string;
|
|
1428
1499
|
requestContext?: unknown;
|
|
1429
1500
|
dataStrategy?: DataStrategyFunction<unknown>;
|
|
1430
1501
|
generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
|
|
1431
|
-
|
|
1502
|
+
normalizePath?: (request: Request) => Path;
|
|
1432
1503
|
}): Promise<any>;
|
|
1433
1504
|
}
|
|
1434
1505
|
type ViewTransitionOpts = {
|
|
@@ -1472,14 +1543,14 @@ type BaseNavigateOrFetchOptions = {
|
|
|
1472
1543
|
preventScrollReset?: boolean;
|
|
1473
1544
|
relative?: RelativeRoutingType;
|
|
1474
1545
|
flushSync?: boolean;
|
|
1475
|
-
|
|
1546
|
+
defaultShouldRevalidate?: boolean;
|
|
1476
1547
|
};
|
|
1477
1548
|
type BaseNavigateOptions = BaseNavigateOrFetchOptions & {
|
|
1478
1549
|
replace?: boolean;
|
|
1479
1550
|
state?: any;
|
|
1480
1551
|
fromRouteId?: string;
|
|
1481
1552
|
viewTransition?: boolean;
|
|
1482
|
-
|
|
1553
|
+
mask?: To;
|
|
1483
1554
|
};
|
|
1484
1555
|
type BaseSubmissionOptions = {
|
|
1485
1556
|
formMethod?: HTMLFormMethod;
|
|
@@ -1655,7 +1726,7 @@ type BlockerFunction = (args: {
|
|
|
1655
1726
|
interface CreateStaticHandlerOptions {
|
|
1656
1727
|
basename?: string;
|
|
1657
1728
|
mapRouteProperties?: MapRoutePropertiesFunction;
|
|
1658
|
-
|
|
1729
|
+
instrumentations?: Pick<ServerInstrumentation, "route">[];
|
|
1659
1730
|
future?: Partial<FutureConfig>;
|
|
1660
1731
|
}
|
|
1661
1732
|
declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
|
|
@@ -1805,14 +1876,14 @@ type ClientDataFunctionArgs<Params> = {
|
|
|
1805
1876
|
**/
|
|
1806
1877
|
request: Request;
|
|
1807
1878
|
/**
|
|
1808
|
-
* A URL instance representing the application location being navigated to or
|
|
1809
|
-
*
|
|
1810
|
-
*
|
|
1811
|
-
*
|
|
1812
|
-
*
|
|
1813
|
-
*
|
|
1879
|
+
* A URL instance representing the application location being navigated to or
|
|
1880
|
+
* fetched. By default, this matches `request.url`.
|
|
1881
|
+
*
|
|
1882
|
+
* In Framework mode with `future.v8_passThroughRequests` enabled, this is a
|
|
1883
|
+
* normalized URL with React-Router-specific implementation details removed
|
|
1884
|
+
* (`.data` suffixes, `index`/`_routes` search params).
|
|
1814
1885
|
*/
|
|
1815
|
-
|
|
1886
|
+
url: URL;
|
|
1816
1887
|
/**
|
|
1817
1888
|
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
|
1818
1889
|
* @example
|
|
@@ -1832,7 +1903,7 @@ type ClientDataFunctionArgs<Params> = {
|
|
|
1832
1903
|
* Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
|
|
1833
1904
|
* Mostly useful as a identifier to aggregate on for logging/tracing/etc.
|
|
1834
1905
|
*/
|
|
1835
|
-
|
|
1906
|
+
pattern: string;
|
|
1836
1907
|
/**
|
|
1837
1908
|
* When `future.v8_middleware` is not enabled, this is undefined.
|
|
1838
1909
|
*
|