react-router 7.4.0 → 7.4.1
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 +13 -1
- package/dist/development/{chunk-GNGMS2XR.mjs → chunk-XJI4KG32.mjs} +108 -37
- package/dist/development/dom-export.d.mts +2 -2
- package/dist/development/dom-export.d.ts +2 -2
- package/dist/development/dom-export.js +93 -28
- package/dist/development/dom-export.mjs +2 -2
- package/dist/{production/fog-of-war-BQyvjjKg.d.mts → development/fog-of-war-BaM-ohjc.d.ts} +3 -1
- package/dist/development/{fog-of-war-CGNKxM4z.d.ts → fog-of-war-BjgPfDmv.d.mts} +3 -1
- package/dist/development/index.d.mts +4 -4
- package/dist/development/index.d.ts +4 -4
- package/dist/development/index.js +108 -37
- package/dist/development/index.mjs +2 -2
- package/dist/development/lib/types/route-module.d.mts +3 -3
- package/dist/development/lib/types/route-module.d.ts +3 -3
- 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-CGHGzi13.d.ts → route-data-BL8ToWby.d.mts} +9 -3
- package/dist/{production/route-data-CGHGzi13.d.mts → development/route-data-BL8ToWby.d.ts} +9 -3
- package/dist/production/{chunk-SXJRHUAY.mjs → chunk-T6D7EGPT.mjs} +108 -37
- package/dist/production/dom-export.d.mts +2 -2
- package/dist/production/dom-export.d.ts +2 -2
- package/dist/production/dom-export.js +93 -28
- package/dist/production/dom-export.mjs +2 -2
- package/dist/{development/fog-of-war-BQyvjjKg.d.mts → production/fog-of-war-BaM-ohjc.d.ts} +3 -1
- package/dist/production/{fog-of-war-CGNKxM4z.d.ts → fog-of-war-BjgPfDmv.d.mts} +3 -1
- package/dist/production/index.d.mts +4 -4
- package/dist/production/index.d.ts +4 -4
- package/dist/production/index.js +108 -37
- package/dist/production/index.mjs +2 -2
- package/dist/production/lib/types/route-module.d.mts +3 -3
- package/dist/production/lib/types/route-module.d.ts +3 -3
- 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-CGHGzi13.d.ts → route-data-BL8ToWby.d.mts} +9 -3
- package/dist/{development/route-data-CGHGzi13.d.mts → production/route-data-BL8ToWby.d.ts} +9 -3
- package/package.json +1 -1
package/dist/production/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.4.
|
|
2
|
+
* react-router v7.4.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -531,12 +531,14 @@ var unstable_RouterContextProvider = class {
|
|
|
531
531
|
}
|
|
532
532
|
};
|
|
533
533
|
_map = new WeakMap();
|
|
534
|
-
var
|
|
534
|
+
var unsupportedLazyRouteFunctionKeys = /* @__PURE__ */ new Set([
|
|
535
535
|
"lazy",
|
|
536
536
|
"caseSensitive",
|
|
537
537
|
"path",
|
|
538
538
|
"id",
|
|
539
539
|
"index",
|
|
540
|
+
"unstable_middleware",
|
|
541
|
+
"unstable_lazyMiddleware",
|
|
540
542
|
"children"
|
|
541
543
|
]);
|
|
542
544
|
function isIndexRoute(route) {
|
|
@@ -2355,8 +2357,7 @@ function createRouter(init) {
|
|
|
2355
2357
|
fetcherKey,
|
|
2356
2358
|
manifest,
|
|
2357
2359
|
mapRouteProperties2,
|
|
2358
|
-
scopedContext
|
|
2359
|
-
future.unstable_middleware
|
|
2360
|
+
scopedContext
|
|
2360
2361
|
);
|
|
2361
2362
|
} catch (e) {
|
|
2362
2363
|
matchesToLoad.forEach((m) => {
|
|
@@ -2829,12 +2830,15 @@ function createStaticHandler(routes, opts) {
|
|
|
2829
2830
|
};
|
|
2830
2831
|
return respond ? respond(staticContext) : staticContext;
|
|
2831
2832
|
}
|
|
2832
|
-
if (respond && matches.some(
|
|
2833
|
+
if (respond && matches.some(
|
|
2834
|
+
(m) => m.route.unstable_middleware || m.route.unstable_lazyMiddleware
|
|
2835
|
+
)) {
|
|
2833
2836
|
invariant(
|
|
2834
2837
|
requestContext instanceof unstable_RouterContextProvider,
|
|
2835
2838
|
"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `unstable_RouterContextProvider`"
|
|
2836
2839
|
);
|
|
2837
2840
|
try {
|
|
2841
|
+
await loadLazyMiddlewareForMatches(matches, manifest);
|
|
2838
2842
|
let renderedStaticContext;
|
|
2839
2843
|
let response = await runMiddlewarePipeline(
|
|
2840
2844
|
{
|
|
@@ -2950,11 +2954,14 @@ function createStaticHandler(routes, opts) {
|
|
|
2950
2954
|
} else if (!match) {
|
|
2951
2955
|
throw getInternalRouterError(404, { pathname: location.pathname });
|
|
2952
2956
|
}
|
|
2953
|
-
if (respond && matches.some(
|
|
2957
|
+
if (respond && matches.some(
|
|
2958
|
+
(m) => m.route.unstable_middleware || m.route.unstable_lazyMiddleware
|
|
2959
|
+
)) {
|
|
2954
2960
|
invariant(
|
|
2955
2961
|
requestContext instanceof unstable_RouterContextProvider,
|
|
2956
2962
|
"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `unstable_RouterContextProvider`"
|
|
2957
2963
|
);
|
|
2964
|
+
await loadLazyMiddlewareForMatches(matches, manifest);
|
|
2958
2965
|
let response = await runMiddlewarePipeline(
|
|
2959
2966
|
{
|
|
2960
2967
|
request,
|
|
@@ -3271,9 +3278,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3271
3278
|
null,
|
|
3272
3279
|
manifest,
|
|
3273
3280
|
mapRouteProperties2,
|
|
3274
|
-
requestContext
|
|
3275
|
-
false
|
|
3276
|
-
// middleware not done via dataStrategy in the static handler
|
|
3281
|
+
requestContext
|
|
3277
3282
|
);
|
|
3278
3283
|
let dataResults = {};
|
|
3279
3284
|
await Promise.all(
|
|
@@ -3674,38 +3679,80 @@ function isSameRoute(newRoute, existingRoute) {
|
|
|
3674
3679
|
(aChild, i) => existingRoute.children?.some((bChild) => isSameRoute(aChild, bChild))
|
|
3675
3680
|
);
|
|
3676
3681
|
}
|
|
3682
|
+
var lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
|
|
3677
3683
|
async function loadLazyRouteModule(route, mapRouteProperties2, manifest) {
|
|
3684
|
+
let routeToUpdate = manifest[route.id];
|
|
3685
|
+
invariant(routeToUpdate, "No route found in manifest");
|
|
3678
3686
|
if (!route.lazy) {
|
|
3679
3687
|
return;
|
|
3680
3688
|
}
|
|
3681
|
-
let
|
|
3682
|
-
if (
|
|
3689
|
+
let cachedPromise = lazyRouteFunctionCache.get(routeToUpdate);
|
|
3690
|
+
if (cachedPromise) {
|
|
3691
|
+
await cachedPromise;
|
|
3692
|
+
return;
|
|
3693
|
+
}
|
|
3694
|
+
let lazyRoutePromise = route.lazy().then((lazyRoute) => {
|
|
3695
|
+
let routeUpdates = {};
|
|
3696
|
+
for (let lazyRouteProperty in lazyRoute) {
|
|
3697
|
+
let staticRouteValue = routeToUpdate[lazyRouteProperty];
|
|
3698
|
+
let isPropertyStaticallyDefined = staticRouteValue !== void 0 && // This property isn't static since it should always be updated based
|
|
3699
|
+
// on the route updates
|
|
3700
|
+
lazyRouteProperty !== "hasErrorBoundary";
|
|
3701
|
+
warning(
|
|
3702
|
+
!isPropertyStaticallyDefined,
|
|
3703
|
+
`Route "${routeToUpdate.id}" has a static property "${lazyRouteProperty}" defined but its lazy function is also returning a value for this property. The lazy route property "${lazyRouteProperty}" will be ignored.`
|
|
3704
|
+
);
|
|
3705
|
+
warning(
|
|
3706
|
+
!unsupportedLazyRouteFunctionKeys.has(
|
|
3707
|
+
lazyRouteProperty
|
|
3708
|
+
),
|
|
3709
|
+
"Route property " + lazyRouteProperty + " is not a supported property to be returned from a lazy route function. This property will be ignored."
|
|
3710
|
+
);
|
|
3711
|
+
if (!isPropertyStaticallyDefined && !unsupportedLazyRouteFunctionKeys.has(
|
|
3712
|
+
lazyRouteProperty
|
|
3713
|
+
)) {
|
|
3714
|
+
routeUpdates[lazyRouteProperty] = lazyRoute[lazyRouteProperty];
|
|
3715
|
+
}
|
|
3716
|
+
}
|
|
3717
|
+
Object.assign(routeToUpdate, routeUpdates);
|
|
3718
|
+
Object.assign(routeToUpdate, {
|
|
3719
|
+
// To keep things framework agnostic, we use the provided `mapRouteProperties`
|
|
3720
|
+
// function to set the framework-aware properties (`element`/`hasErrorBoundary`)
|
|
3721
|
+
// since the logic will differ between frameworks.
|
|
3722
|
+
...mapRouteProperties2(routeToUpdate),
|
|
3723
|
+
lazy: void 0
|
|
3724
|
+
});
|
|
3725
|
+
});
|
|
3726
|
+
lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise);
|
|
3727
|
+
await lazyRoutePromise;
|
|
3728
|
+
}
|
|
3729
|
+
async function loadLazyMiddleware(route, manifest) {
|
|
3730
|
+
if (!route.unstable_lazyMiddleware) {
|
|
3683
3731
|
return;
|
|
3684
3732
|
}
|
|
3685
3733
|
let routeToUpdate = manifest[route.id];
|
|
3686
3734
|
invariant(routeToUpdate, "No route found in manifest");
|
|
3687
|
-
|
|
3688
|
-
for (let lazyRouteProperty in lazyRoute) {
|
|
3689
|
-
let staticRouteValue = routeToUpdate[lazyRouteProperty];
|
|
3690
|
-
let isPropertyStaticallyDefined = staticRouteValue !== void 0 && // This property isn't static since it should always be updated based
|
|
3691
|
-
// on the route updates
|
|
3692
|
-
lazyRouteProperty !== "hasErrorBoundary";
|
|
3735
|
+
if (routeToUpdate.unstable_middleware) {
|
|
3693
3736
|
warning(
|
|
3694
|
-
|
|
3695
|
-
`Route "${routeToUpdate.id}" has a static property "
|
|
3737
|
+
false,
|
|
3738
|
+
`Route "${routeToUpdate.id}" has a static property "unstable_middleware" defined. The "unstable_lazyMiddleware" function will be ignored.`
|
|
3696
3739
|
);
|
|
3697
|
-
|
|
3698
|
-
|
|
3740
|
+
} else {
|
|
3741
|
+
let middleware = await route.unstable_lazyMiddleware();
|
|
3742
|
+
if (!route.unstable_lazyMiddleware) {
|
|
3743
|
+
return;
|
|
3744
|
+
}
|
|
3745
|
+
if (!routeToUpdate.unstable_middleware) {
|
|
3746
|
+
routeToUpdate.unstable_middleware = middleware;
|
|
3699
3747
|
}
|
|
3700
3748
|
}
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
});
|
|
3749
|
+
routeToUpdate.unstable_lazyMiddleware = void 0;
|
|
3750
|
+
}
|
|
3751
|
+
function loadLazyMiddlewareForMatches(matches, manifest) {
|
|
3752
|
+
let promises = matches.map(
|
|
3753
|
+
(m) => m.route.unstable_lazyMiddleware ? loadLazyMiddleware(m.route, manifest) : void 0
|
|
3754
|
+
).filter(Boolean);
|
|
3755
|
+
return promises.length > 0 ? Promise.all(promises) : void 0;
|
|
3709
3756
|
}
|
|
3710
3757
|
async function defaultDataStrategy(args) {
|
|
3711
3758
|
let matchesToLoad = args.matches.filter((m) => m.shouldLoad);
|
|
@@ -3821,12 +3868,13 @@ async function callRouteMiddleware(args, middlewares, propagateResult, middlewar
|
|
|
3821
3868
|
throw error;
|
|
3822
3869
|
}
|
|
3823
3870
|
}
|
|
3824
|
-
async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLoad, matches, fetcherKey, manifest, mapRouteProperties2, scopedContext
|
|
3871
|
+
async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLoad, matches, fetcherKey, manifest, mapRouteProperties2, scopedContext) {
|
|
3872
|
+
let loadMiddlewarePromise = loadLazyMiddlewareForMatches(matches, manifest);
|
|
3825
3873
|
let loadRouteDefinitionsPromises = matches.map(
|
|
3826
3874
|
(m) => m.route.lazy ? loadLazyRouteModule(m.route, mapRouteProperties2, manifest) : void 0
|
|
3827
3875
|
);
|
|
3828
|
-
if (
|
|
3829
|
-
await
|
|
3876
|
+
if (loadMiddlewarePromise) {
|
|
3877
|
+
await loadMiddlewarePromise;
|
|
3830
3878
|
}
|
|
3831
3879
|
let dsMatches = matches.map((match, i) => {
|
|
3832
3880
|
let loadRoutePromise = loadRouteDefinitionsPromises[i];
|
|
@@ -6888,6 +6936,21 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
6888
6936
|
});
|
|
6889
6937
|
};
|
|
6890
6938
|
}
|
|
6939
|
+
if (route.hasClientMiddleware) {
|
|
6940
|
+
dataRoute.unstable_lazyMiddleware = async () => {
|
|
6941
|
+
invariant2(route);
|
|
6942
|
+
let clientMiddlewareModule = await import(
|
|
6943
|
+
/* @vite-ignore */
|
|
6944
|
+
/* webpackIgnore: true */
|
|
6945
|
+
route.clientMiddlewareModule || route.module
|
|
6946
|
+
);
|
|
6947
|
+
invariant2(
|
|
6948
|
+
clientMiddlewareModule?.unstable_clientMiddleware,
|
|
6949
|
+
"No `unstable_clientMiddleware` export in chunk"
|
|
6950
|
+
);
|
|
6951
|
+
return clientMiddlewareModule.unstable_clientMiddleware;
|
|
6952
|
+
};
|
|
6953
|
+
}
|
|
6891
6954
|
dataRoute.lazy = async () => {
|
|
6892
6955
|
if (route.clientLoaderModule || route.clientActionModule) {
|
|
6893
6956
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
@@ -6922,7 +6985,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
6922
6985
|
return {
|
|
6923
6986
|
...lazyRoute.loader ? { loader: lazyRoute.loader } : {},
|
|
6924
6987
|
...lazyRoute.action ? { action: lazyRoute.action } : {},
|
|
6925
|
-
unstable_middleware: mod.unstable_clientMiddleware,
|
|
6926
6988
|
hasErrorBoundary: lazyRoute.hasErrorBoundary,
|
|
6927
6989
|
shouldRevalidate: getShouldRevalidateFunction(
|
|
6928
6990
|
lazyRoute,
|
|
@@ -7556,6 +7618,7 @@ ${matches.map((match, routeIndex) => {
|
|
|
7556
7618
|
let {
|
|
7557
7619
|
clientActionModule,
|
|
7558
7620
|
clientLoaderModule,
|
|
7621
|
+
clientMiddlewareModule,
|
|
7559
7622
|
hydrateFallbackModule,
|
|
7560
7623
|
module: module2
|
|
7561
7624
|
} = manifestEntry;
|
|
@@ -7572,6 +7635,12 @@ ${matches.map((match, routeIndex) => {
|
|
|
7572
7635
|
varName: `${routeVarName}_clientLoader`
|
|
7573
7636
|
}
|
|
7574
7637
|
] : [],
|
|
7638
|
+
...clientMiddlewareModule ? [
|
|
7639
|
+
{
|
|
7640
|
+
module: clientMiddlewareModule,
|
|
7641
|
+
varName: `${routeVarName}_clientMiddleware`
|
|
7642
|
+
}
|
|
7643
|
+
] : [],
|
|
7575
7644
|
...hydrateFallbackModule ? [
|
|
7576
7645
|
{
|
|
7577
7646
|
module: hydrateFallbackModule,
|
|
@@ -7665,7 +7734,7 @@ function mergeRefs(...refs) {
|
|
|
7665
7734
|
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
7666
7735
|
try {
|
|
7667
7736
|
if (isBrowser) {
|
|
7668
|
-
window.__reactRouterVersion = "7.4.
|
|
7737
|
+
window.__reactRouterVersion = "7.4.1";
|
|
7669
7738
|
}
|
|
7670
7739
|
} catch (e) {
|
|
7671
7740
|
}
|
|
@@ -8875,16 +8944,18 @@ function processRoutes(routes, manifest, routeModules, parentId) {
|
|
|
8875
8944
|
parentId,
|
|
8876
8945
|
hasAction: route.action != null,
|
|
8877
8946
|
hasLoader: route.loader != null,
|
|
8878
|
-
// When testing routes, you should
|
|
8879
|
-
// trying to re-implement the full loader/clientLoader/SSR/hydration
|
|
8880
|
-
// That is better tested via E2E tests.
|
|
8947
|
+
// When testing routes, you should be stubbing loader/action/middleware,
|
|
8948
|
+
// not trying to re-implement the full loader/clientLoader/SSR/hydration
|
|
8949
|
+
// flow. That is better tested via E2E tests.
|
|
8881
8950
|
hasClientAction: false,
|
|
8882
8951
|
hasClientLoader: false,
|
|
8952
|
+
hasClientMiddleware: false,
|
|
8883
8953
|
hasErrorBoundary: route.ErrorBoundary != null,
|
|
8884
8954
|
// any need for these?
|
|
8885
8955
|
module: "build/stub-path-to-module.js",
|
|
8886
8956
|
clientActionModule: void 0,
|
|
8887
8957
|
clientLoaderModule: void 0,
|
|
8958
|
+
clientMiddlewareModule: void 0,
|
|
8888
8959
|
hydrateFallbackModule: void 0
|
|
8889
8960
|
};
|
|
8890
8961
|
manifest.routes[newRoute.id] = entryRoute;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.4.
|
|
2
|
+
* react-router v7.4.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -123,7 +123,7 @@ import {
|
|
|
123
123
|
useSearchParams,
|
|
124
124
|
useSubmit,
|
|
125
125
|
useViewTransitionState
|
|
126
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-T6D7EGPT.mjs";
|
|
127
127
|
export {
|
|
128
128
|
Await,
|
|
129
129
|
BrowserRouter,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aE as LinkDescriptor, aB as MetaDescriptor, aT as ServerDataFrom, aU as ClientDataFrom, aV as Func, aW as unstable_MiddlewareNextFunction, E as Equal, u as unstable_RouterContextProvider, aX as Pretty } from '../../route-data-
|
|
1
|
+
import { aE as LinkDescriptor, aB as MetaDescriptor, aT as ServerDataFrom, aU as ClientDataFrom, aV as Func, aW as unstable_MiddlewareNextFunction, E as Equal, u as unstable_RouterContextProvider, aX as Pretty } from '../../route-data-BL8ToWby.mjs';
|
|
2
2
|
import { M as MiddlewareEnabled, A as AppLoadContext } from '../../future-ldDp5FKH.mjs';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -139,8 +139,8 @@ type ServerDataFunctionArgs<T extends RouteInfo> = {
|
|
|
139
139
|
*/
|
|
140
140
|
context: MiddlewareEnabled extends true ? unstable_RouterContextProvider : AppLoadContext;
|
|
141
141
|
};
|
|
142
|
-
type CreateServerMiddlewareFunction<T extends RouteInfo> = (args: ServerDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<Response>) => MaybePromise<Response |
|
|
143
|
-
type CreateClientMiddlewareFunction<T extends RouteInfo> = (args: ClientDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<undefined>) => MaybePromise<
|
|
142
|
+
type CreateServerMiddlewareFunction<T extends RouteInfo> = (args: ServerDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<Response>) => MaybePromise<Response | void>;
|
|
143
|
+
type CreateClientMiddlewareFunction<T extends RouteInfo> = (args: ClientDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<undefined>) => MaybePromise<void>;
|
|
144
144
|
type CreateServerLoaderArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
|
145
145
|
type CreateClientLoaderArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
|
146
146
|
/** This is an asynchronous function to get the data from the server loader for this route. On client-side navigations, this will make a {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server loader. If you opt-into running your clientLoader on hydration, then this function will return the data that was already loaded on the server (via Promise.resolve). */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aE as LinkDescriptor, aB as MetaDescriptor, aT as ServerDataFrom, aU as ClientDataFrom, aV as Func, aW as unstable_MiddlewareNextFunction, E as Equal, u as unstable_RouterContextProvider, aX as Pretty } from '../../route-data-
|
|
1
|
+
import { aE as LinkDescriptor, aB as MetaDescriptor, aT as ServerDataFrom, aU as ClientDataFrom, aV as Func, aW as unstable_MiddlewareNextFunction, E as Equal, u as unstable_RouterContextProvider, aX as Pretty } from '../../route-data-BL8ToWby.js';
|
|
2
2
|
import { M as MiddlewareEnabled, A as AppLoadContext } from '../../future-ldDp5FKH.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -139,8 +139,8 @@ type ServerDataFunctionArgs<T extends RouteInfo> = {
|
|
|
139
139
|
*/
|
|
140
140
|
context: MiddlewareEnabled extends true ? unstable_RouterContextProvider : AppLoadContext;
|
|
141
141
|
};
|
|
142
|
-
type CreateServerMiddlewareFunction<T extends RouteInfo> = (args: ServerDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<Response>) => MaybePromise<Response |
|
|
143
|
-
type CreateClientMiddlewareFunction<T extends RouteInfo> = (args: ClientDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<undefined>) => MaybePromise<
|
|
142
|
+
type CreateServerMiddlewareFunction<T extends RouteInfo> = (args: ServerDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<Response>) => MaybePromise<Response | void>;
|
|
143
|
+
type CreateClientMiddlewareFunction<T extends RouteInfo> = (args: ClientDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<undefined>) => MaybePromise<void>;
|
|
144
144
|
type CreateServerLoaderArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
|
145
145
|
type CreateClientLoaderArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
|
146
146
|
/** This is an asynchronous function to get the data from the server loader for this route. On client-side navigations, this will make a {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server loader. If you opt-into running your clientLoader on hydration, then this function will return the data that was already loaded on the server (via Promise.resolve). */
|
|
@@ -332,7 +332,7 @@ interface unstable_MiddlewareNextFunction<Result = unknown> {
|
|
|
332
332
|
* a `next` function as the second parameter which will call downstream handlers
|
|
333
333
|
* and then complete middlewares from the bottom-up
|
|
334
334
|
*/
|
|
335
|
-
type unstable_MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<unstable_RouterContextProvider>, next: unstable_MiddlewareNextFunction<Result>) => MaybePromise<Result |
|
|
335
|
+
type unstable_MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<unstable_RouterContextProvider>, next: unstable_MiddlewareNextFunction<Result>) => MaybePromise<Result | void>;
|
|
336
336
|
/**
|
|
337
337
|
* Arguments passed to loader functions
|
|
338
338
|
*/
|
|
@@ -468,7 +468,7 @@ interface MapRoutePropertiesFunction {
|
|
|
468
468
|
* onto the route. Either they're meaningful to the router, or they'll get
|
|
469
469
|
* ignored.
|
|
470
470
|
*/
|
|
471
|
-
type
|
|
471
|
+
type UnsupportedLazyRouteFunctionKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "unstable_middleware" | "unstable_lazyMiddleware" | "children";
|
|
472
472
|
type RequireOne<T, Key = keyof T> = Exclude<{
|
|
473
473
|
[K in keyof T]: K extends Key ? Omit<T, K> & Required<Pick<T, K>> : never;
|
|
474
474
|
}[keyof T], undefined>;
|
|
@@ -477,7 +477,10 @@ type RequireOne<T, Key = keyof T> = Exclude<{
|
|
|
477
477
|
* related properties to a route
|
|
478
478
|
*/
|
|
479
479
|
interface LazyRouteFunction<R extends AgnosticRouteObject> {
|
|
480
|
-
(): Promise<RequireOne<Omit<R,
|
|
480
|
+
(): Promise<RequireOne<Omit<R, UnsupportedLazyRouteFunctionKey>>>;
|
|
481
|
+
}
|
|
482
|
+
interface LazyMiddlewareFunction {
|
|
483
|
+
(): Promise<unstable_MiddlewareFunction[]>;
|
|
481
484
|
}
|
|
482
485
|
/**
|
|
483
486
|
* Base RouteObject with common props shared by all types of routes
|
|
@@ -487,6 +490,7 @@ type AgnosticBaseRouteObject = {
|
|
|
487
490
|
path?: string;
|
|
488
491
|
id?: string;
|
|
489
492
|
unstable_middleware?: unstable_MiddlewareFunction[];
|
|
493
|
+
unstable_lazyMiddleware?: LazyMiddlewareFunction;
|
|
490
494
|
loader?: LoaderFunction | boolean;
|
|
491
495
|
action?: ActionFunction | boolean;
|
|
492
496
|
hasErrorBoundary?: boolean;
|
|
@@ -1251,6 +1255,7 @@ interface IndexRouteObject {
|
|
|
1251
1255
|
path?: AgnosticIndexRouteObject["path"];
|
|
1252
1256
|
id?: AgnosticIndexRouteObject["id"];
|
|
1253
1257
|
unstable_middleware?: AgnosticIndexRouteObject["unstable_middleware"];
|
|
1258
|
+
unstable_lazyMiddleware?: AgnosticIndexRouteObject["unstable_lazyMiddleware"];
|
|
1254
1259
|
loader?: AgnosticIndexRouteObject["loader"];
|
|
1255
1260
|
action?: AgnosticIndexRouteObject["action"];
|
|
1256
1261
|
hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
|
|
@@ -1271,6 +1276,7 @@ interface NonIndexRouteObject {
|
|
|
1271
1276
|
path?: AgnosticNonIndexRouteObject["path"];
|
|
1272
1277
|
id?: AgnosticNonIndexRouteObject["id"];
|
|
1273
1278
|
unstable_middleware?: AgnosticNonIndexRouteObject["unstable_middleware"];
|
|
1279
|
+
unstable_lazyMiddleware?: AgnosticNonIndexRouteObject["unstable_lazyMiddleware"];
|
|
1274
1280
|
loader?: AgnosticNonIndexRouteObject["loader"];
|
|
1275
1281
|
action?: AgnosticNonIndexRouteObject["action"];
|
|
1276
1282
|
hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
|
|
@@ -332,7 +332,7 @@ interface unstable_MiddlewareNextFunction<Result = unknown> {
|
|
|
332
332
|
* a `next` function as the second parameter which will call downstream handlers
|
|
333
333
|
* and then complete middlewares from the bottom-up
|
|
334
334
|
*/
|
|
335
|
-
type unstable_MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<unstable_RouterContextProvider>, next: unstable_MiddlewareNextFunction<Result>) => MaybePromise<Result |
|
|
335
|
+
type unstable_MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<unstable_RouterContextProvider>, next: unstable_MiddlewareNextFunction<Result>) => MaybePromise<Result | void>;
|
|
336
336
|
/**
|
|
337
337
|
* Arguments passed to loader functions
|
|
338
338
|
*/
|
|
@@ -468,7 +468,7 @@ interface MapRoutePropertiesFunction {
|
|
|
468
468
|
* onto the route. Either they're meaningful to the router, or they'll get
|
|
469
469
|
* ignored.
|
|
470
470
|
*/
|
|
471
|
-
type
|
|
471
|
+
type UnsupportedLazyRouteFunctionKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "unstable_middleware" | "unstable_lazyMiddleware" | "children";
|
|
472
472
|
type RequireOne<T, Key = keyof T> = Exclude<{
|
|
473
473
|
[K in keyof T]: K extends Key ? Omit<T, K> & Required<Pick<T, K>> : never;
|
|
474
474
|
}[keyof T], undefined>;
|
|
@@ -477,7 +477,10 @@ type RequireOne<T, Key = keyof T> = Exclude<{
|
|
|
477
477
|
* related properties to a route
|
|
478
478
|
*/
|
|
479
479
|
interface LazyRouteFunction<R extends AgnosticRouteObject> {
|
|
480
|
-
(): Promise<RequireOne<Omit<R,
|
|
480
|
+
(): Promise<RequireOne<Omit<R, UnsupportedLazyRouteFunctionKey>>>;
|
|
481
|
+
}
|
|
482
|
+
interface LazyMiddlewareFunction {
|
|
483
|
+
(): Promise<unstable_MiddlewareFunction[]>;
|
|
481
484
|
}
|
|
482
485
|
/**
|
|
483
486
|
* Base RouteObject with common props shared by all types of routes
|
|
@@ -487,6 +490,7 @@ type AgnosticBaseRouteObject = {
|
|
|
487
490
|
path?: string;
|
|
488
491
|
id?: string;
|
|
489
492
|
unstable_middleware?: unstable_MiddlewareFunction[];
|
|
493
|
+
unstable_lazyMiddleware?: LazyMiddlewareFunction;
|
|
490
494
|
loader?: LoaderFunction | boolean;
|
|
491
495
|
action?: ActionFunction | boolean;
|
|
492
496
|
hasErrorBoundary?: boolean;
|
|
@@ -1251,6 +1255,7 @@ interface IndexRouteObject {
|
|
|
1251
1255
|
path?: AgnosticIndexRouteObject["path"];
|
|
1252
1256
|
id?: AgnosticIndexRouteObject["id"];
|
|
1253
1257
|
unstable_middleware?: AgnosticIndexRouteObject["unstable_middleware"];
|
|
1258
|
+
unstable_lazyMiddleware?: AgnosticIndexRouteObject["unstable_lazyMiddleware"];
|
|
1254
1259
|
loader?: AgnosticIndexRouteObject["loader"];
|
|
1255
1260
|
action?: AgnosticIndexRouteObject["action"];
|
|
1256
1261
|
hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
|
|
@@ -1271,6 +1276,7 @@ interface NonIndexRouteObject {
|
|
|
1271
1276
|
path?: AgnosticNonIndexRouteObject["path"];
|
|
1272
1277
|
id?: AgnosticNonIndexRouteObject["id"];
|
|
1273
1278
|
unstable_middleware?: AgnosticNonIndexRouteObject["unstable_middleware"];
|
|
1279
|
+
unstable_lazyMiddleware?: AgnosticNonIndexRouteObject["unstable_lazyMiddleware"];
|
|
1274
1280
|
loader?: AgnosticNonIndexRouteObject["loader"];
|
|
1275
1281
|
action?: AgnosticNonIndexRouteObject["action"];
|
|
1276
1282
|
hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
|