react-router 7.3.0 → 7.4.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 +11 -0
- package/dist/development/{chunk-K6CSEXPM.mjs → chunk-GNGMS2XR.mjs} +60 -47
- package/dist/development/dom-export.d.mts +2 -2
- package/dist/development/dom-export.d.ts +2 -2
- package/dist/development/dom-export.js +37 -29
- package/dist/development/dom-export.mjs +9 -3
- package/dist/development/{fog-of-war-Da8gpnoZ.d.mts → fog-of-war-BQyvjjKg.d.mts} +1 -1
- package/dist/{production/fog-of-war-CvttGpNz.d.ts → development/fog-of-war-CGNKxM4z.d.ts} +1 -1
- package/dist/development/index.d.mts +6 -6
- package/dist/development/index.d.ts +6 -6
- package/dist/development/index.js +60 -47
- package/dist/development/index.mjs +2 -2
- package/dist/development/lib/types/route-module.d.mts +2 -2
- package/dist/development/lib/types/route-module.d.ts +2 -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-H2S3hwhf.d.ts → route-data-CGHGzi13.d.mts} +5 -5
- package/dist/{production/route-data-H2S3hwhf.d.mts → development/route-data-CGHGzi13.d.ts} +5 -5
- package/dist/production/{chunk-RFJZTPXA.mjs → chunk-SXJRHUAY.mjs} +60 -47
- package/dist/production/dom-export.d.mts +2 -2
- package/dist/production/dom-export.d.ts +2 -2
- package/dist/production/dom-export.js +37 -29
- package/dist/production/dom-export.mjs +9 -3
- package/dist/production/{fog-of-war-Da8gpnoZ.d.mts → fog-of-war-BQyvjjKg.d.mts} +1 -1
- package/dist/{development/fog-of-war-CvttGpNz.d.ts → production/fog-of-war-CGNKxM4z.d.ts} +1 -1
- package/dist/production/index.d.mts +6 -6
- package/dist/production/index.d.ts +6 -6
- package/dist/production/index.js +60 -47
- package/dist/production/index.mjs +2 -2
- package/dist/production/lib/types/route-module.d.mts +2 -2
- package/dist/production/lib/types/route-module.d.ts +2 -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-H2S3hwhf.d.ts → route-data-CGHGzi13.d.mts} +5 -5
- package/dist/{development/route-data-H2S3hwhf.d.mts → production/route-data-CGHGzi13.d.ts} +5 -5
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.
|
|
2
|
+
* react-router v7.4.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -2832,7 +2832,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2832
2832
|
if (respond && matches.some((m) => m.route.unstable_middleware)) {
|
|
2833
2833
|
invariant(
|
|
2834
2834
|
requestContext instanceof unstable_RouterContextProvider,
|
|
2835
|
-
"When using middleware in `staticHandler.query()`, any provided `requestContext` must
|
|
2835
|
+
"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `unstable_RouterContextProvider`"
|
|
2836
2836
|
);
|
|
2837
2837
|
try {
|
|
2838
2838
|
let renderedStaticContext;
|
|
@@ -2865,20 +2865,20 @@ function createStaticHandler(routes, opts) {
|
|
|
2865
2865
|
let res = await respond(renderedStaticContext);
|
|
2866
2866
|
return res;
|
|
2867
2867
|
},
|
|
2868
|
-
async (
|
|
2869
|
-
if (isResponse(
|
|
2870
|
-
return
|
|
2868
|
+
async (error, routeId) => {
|
|
2869
|
+
if (isResponse(error)) {
|
|
2870
|
+
return error;
|
|
2871
2871
|
}
|
|
2872
2872
|
if (renderedStaticContext) {
|
|
2873
|
-
if (
|
|
2874
|
-
renderedStaticContext.loaderData[
|
|
2873
|
+
if (routeId in renderedStaticContext.loaderData) {
|
|
2874
|
+
renderedStaticContext.loaderData[routeId] = void 0;
|
|
2875
2875
|
}
|
|
2876
2876
|
return respond(
|
|
2877
2877
|
getStaticContextFromError(
|
|
2878
2878
|
dataRoutes,
|
|
2879
2879
|
renderedStaticContext,
|
|
2880
|
-
|
|
2881
|
-
findNearestBoundary(matches,
|
|
2880
|
+
error,
|
|
2881
|
+
findNearestBoundary(matches, routeId).route.id
|
|
2882
2882
|
)
|
|
2883
2883
|
);
|
|
2884
2884
|
} else {
|
|
@@ -2891,9 +2891,9 @@ function createStaticHandler(routes, opts) {
|
|
|
2891
2891
|
loaderData: {},
|
|
2892
2892
|
actionData: null,
|
|
2893
2893
|
errors: {
|
|
2894
|
-
[boundary.route.id]:
|
|
2894
|
+
[boundary.route.id]: error
|
|
2895
2895
|
},
|
|
2896
|
-
statusCode: isRouteErrorResponse(
|
|
2896
|
+
statusCode: isRouteErrorResponse(error) ? error.status : 500,
|
|
2897
2897
|
actionHeaders: {},
|
|
2898
2898
|
loaderHeaders: {}
|
|
2899
2899
|
});
|
|
@@ -2953,7 +2953,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2953
2953
|
if (respond && matches.some((m) => m.route.unstable_middleware)) {
|
|
2954
2954
|
invariant(
|
|
2955
2955
|
requestContext instanceof unstable_RouterContextProvider,
|
|
2956
|
-
"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must
|
|
2956
|
+
"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `unstable_RouterContextProvider`"
|
|
2957
2957
|
);
|
|
2958
2958
|
let response = await runMiddlewarePipeline(
|
|
2959
2959
|
{
|
|
@@ -2987,11 +2987,11 @@ function createStaticHandler(routes, opts) {
|
|
|
2987
2987
|
let value = result2.actionData ? Object.values(result2.actionData)[0] : Object.values(result2.loaderData)[0];
|
|
2988
2988
|
return typeof value === "string" ? new Response(value) : Response.json(value);
|
|
2989
2989
|
},
|
|
2990
|
-
(
|
|
2991
|
-
if (isResponse(
|
|
2992
|
-
return respond(
|
|
2990
|
+
(error2) => {
|
|
2991
|
+
if (isResponse(error2)) {
|
|
2992
|
+
return respond(error2);
|
|
2993
2993
|
}
|
|
2994
|
-
return new Response(String(
|
|
2994
|
+
return new Response(String(error2), {
|
|
2995
2995
|
status: 500,
|
|
2996
2996
|
statusText: "Unexpected Server Error"
|
|
2997
2997
|
});
|
|
@@ -3724,14 +3724,13 @@ async function defaultDataStrategyWithMiddleware(args) {
|
|
|
3724
3724
|
args,
|
|
3725
3725
|
false,
|
|
3726
3726
|
() => defaultDataStrategy(args),
|
|
3727
|
-
(
|
|
3727
|
+
(error, routeId) => ({ [routeId]: { type: "error", result: error } })
|
|
3728
3728
|
);
|
|
3729
3729
|
}
|
|
3730
3730
|
async function runMiddlewarePipeline(args, propagateResult, handler, errorHandler) {
|
|
3731
3731
|
let { matches, request, params, context } = args;
|
|
3732
3732
|
let middlewareState = {
|
|
3733
|
-
handlerResult: void 0
|
|
3734
|
-
propagateResult
|
|
3733
|
+
handlerResult: void 0
|
|
3735
3734
|
};
|
|
3736
3735
|
try {
|
|
3737
3736
|
let tuples = matches.flatMap(
|
|
@@ -3740,28 +3739,26 @@ async function runMiddlewarePipeline(args, propagateResult, handler, errorHandle
|
|
|
3740
3739
|
let result = await callRouteMiddleware(
|
|
3741
3740
|
{ request, params, context },
|
|
3742
3741
|
tuples,
|
|
3742
|
+
propagateResult,
|
|
3743
3743
|
middlewareState,
|
|
3744
3744
|
handler
|
|
3745
3745
|
);
|
|
3746
|
-
return
|
|
3746
|
+
return propagateResult ? result : middlewareState.handlerResult;
|
|
3747
3747
|
} catch (e) {
|
|
3748
|
-
if (!
|
|
3748
|
+
if (!middlewareState.middlewareError) {
|
|
3749
3749
|
throw e;
|
|
3750
3750
|
}
|
|
3751
|
-
let result = await errorHandler(
|
|
3751
|
+
let result = await errorHandler(
|
|
3752
|
+
middlewareState.middlewareError.error,
|
|
3753
|
+
middlewareState.middlewareError.routeId
|
|
3754
|
+
);
|
|
3752
3755
|
if (propagateResult || !middlewareState.handlerResult) {
|
|
3753
3756
|
return result;
|
|
3754
3757
|
}
|
|
3755
3758
|
return Object.assign(middlewareState.handlerResult, result);
|
|
3756
3759
|
}
|
|
3757
3760
|
}
|
|
3758
|
-
|
|
3759
|
-
constructor(routeId, error) {
|
|
3760
|
-
this.routeId = routeId;
|
|
3761
|
-
this.error = error;
|
|
3762
|
-
}
|
|
3763
|
-
};
|
|
3764
|
-
async function callRouteMiddleware(args, middlewares, middlewareState, handler, idx = 0) {
|
|
3761
|
+
async function callRouteMiddleware(args, middlewares, propagateResult, middlewareState, handler, idx = 0) {
|
|
3765
3762
|
let { request } = args;
|
|
3766
3763
|
if (request.signal.aborted) {
|
|
3767
3764
|
if (request.signal.reason) {
|
|
@@ -3787,11 +3784,12 @@ async function callRouteMiddleware(args, middlewares, middlewareState, handler,
|
|
|
3787
3784
|
let result = await callRouteMiddleware(
|
|
3788
3785
|
args,
|
|
3789
3786
|
middlewares,
|
|
3787
|
+
propagateResult,
|
|
3790
3788
|
middlewareState,
|
|
3791
3789
|
handler,
|
|
3792
3790
|
idx + 1
|
|
3793
3791
|
);
|
|
3794
|
-
if (
|
|
3792
|
+
if (propagateResult) {
|
|
3795
3793
|
nextResult = result;
|
|
3796
3794
|
return nextResult;
|
|
3797
3795
|
}
|
|
@@ -3814,11 +3812,13 @@ async function callRouteMiddleware(args, middlewares, middlewareState, handler,
|
|
|
3814
3812
|
} else {
|
|
3815
3813
|
return next();
|
|
3816
3814
|
}
|
|
3817
|
-
} catch (
|
|
3818
|
-
if (
|
|
3819
|
-
|
|
3815
|
+
} catch (error) {
|
|
3816
|
+
if (!middlewareState.middlewareError) {
|
|
3817
|
+
middlewareState.middlewareError = { routeId, error };
|
|
3818
|
+
} else if (middlewareState.middlewareError.error !== error) {
|
|
3819
|
+
middlewareState.middlewareError = { routeId, error };
|
|
3820
3820
|
}
|
|
3821
|
-
throw
|
|
3821
|
+
throw error;
|
|
3822
3822
|
}
|
|
3823
3823
|
}
|
|
3824
3824
|
async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLoad, matches, fetcherKey, manifest, mapRouteProperties2, scopedContext, enableMiddleware) {
|
|
@@ -6152,6 +6152,9 @@ function StreamTransfer({
|
|
|
6152
6152
|
)));
|
|
6153
6153
|
}
|
|
6154
6154
|
}
|
|
6155
|
+
function handleMiddlewareError(error, routeId) {
|
|
6156
|
+
return { [routeId]: { type: "error", result: error } };
|
|
6157
|
+
}
|
|
6155
6158
|
function getSingleFetchDataStrategy(manifest, routeModules, ssr, basename, getRouter) {
|
|
6156
6159
|
return async (args) => {
|
|
6157
6160
|
let { request, matches, fetcherKey } = args;
|
|
@@ -6160,7 +6163,7 @@ function getSingleFetchDataStrategy(manifest, routeModules, ssr, basename, getRo
|
|
|
6160
6163
|
args,
|
|
6161
6164
|
false,
|
|
6162
6165
|
() => singleFetchActionStrategy(request, matches, basename),
|
|
6163
|
-
|
|
6166
|
+
handleMiddlewareError
|
|
6164
6167
|
);
|
|
6165
6168
|
}
|
|
6166
6169
|
if (!ssr) {
|
|
@@ -6172,7 +6175,7 @@ function getSingleFetchDataStrategy(manifest, routeModules, ssr, basename, getRo
|
|
|
6172
6175
|
args,
|
|
6173
6176
|
false,
|
|
6174
6177
|
() => nonSsrStrategy(manifest, request, matches, basename),
|
|
6175
|
-
|
|
6178
|
+
handleMiddlewareError
|
|
6176
6179
|
);
|
|
6177
6180
|
}
|
|
6178
6181
|
}
|
|
@@ -6181,7 +6184,7 @@ function getSingleFetchDataStrategy(manifest, routeModules, ssr, basename, getRo
|
|
|
6181
6184
|
args,
|
|
6182
6185
|
false,
|
|
6183
6186
|
() => singleFetchLoaderFetcherStrategy(request, matches, basename),
|
|
6184
|
-
|
|
6187
|
+
handleMiddlewareError
|
|
6185
6188
|
);
|
|
6186
6189
|
}
|
|
6187
6190
|
return runMiddlewarePipeline(
|
|
@@ -6196,7 +6199,7 @@ function getSingleFetchDataStrategy(manifest, routeModules, ssr, basename, getRo
|
|
|
6196
6199
|
matches,
|
|
6197
6200
|
basename
|
|
6198
6201
|
),
|
|
6199
|
-
|
|
6202
|
+
handleMiddlewareError
|
|
6200
6203
|
);
|
|
6201
6204
|
};
|
|
6202
6205
|
}
|
|
@@ -6246,9 +6249,6 @@ async function nonSsrStrategy(manifest, request, matches, basename) {
|
|
|
6246
6249
|
);
|
|
6247
6250
|
return results;
|
|
6248
6251
|
}
|
|
6249
|
-
function isOptedOut(manifestRoute, routeModule, match, router) {
|
|
6250
|
-
return match.route.id in router.state.loaderData && manifestRoute && manifestRoute.hasLoader && routeModule && routeModule.shouldRevalidate;
|
|
6251
|
-
}
|
|
6252
6252
|
async function singleFetchLoaderNavigationStrategy(manifest, routeModules, ssr, router, request, matches, basename) {
|
|
6253
6253
|
let routesParams = /* @__PURE__ */ new Set();
|
|
6254
6254
|
let foundOptOutRoute = false;
|
|
@@ -6267,8 +6267,10 @@ async function singleFetchLoaderNavigationStrategy(manifest, routeModules, ssr,
|
|
|
6267
6267
|
if (!router.state.initialized) {
|
|
6268
6268
|
return;
|
|
6269
6269
|
}
|
|
6270
|
-
if (
|
|
6271
|
-
|
|
6270
|
+
if (m.route.id in router.state.loaderData && manifestRoute && m.route.shouldRevalidate) {
|
|
6271
|
+
if (manifestRoute.hasLoader) {
|
|
6272
|
+
foundOptOutRoute = true;
|
|
6273
|
+
}
|
|
6272
6274
|
return;
|
|
6273
6275
|
}
|
|
6274
6276
|
}
|
|
@@ -7663,7 +7665,7 @@ function mergeRefs(...refs) {
|
|
|
7663
7665
|
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
7664
7666
|
try {
|
|
7665
7667
|
if (isBrowser) {
|
|
7666
|
-
window.__reactRouterVersion = "7.
|
|
7668
|
+
window.__reactRouterVersion = "7.4.0";
|
|
7667
7669
|
}
|
|
7668
7670
|
} catch (e) {
|
|
7669
7671
|
}
|
|
@@ -9824,8 +9826,8 @@ var createRequestHandler = (build, mode) => {
|
|
|
9824
9826
|
} else {
|
|
9825
9827
|
let { pathname } = url;
|
|
9826
9828
|
let criticalCss = void 0;
|
|
9827
|
-
if (_build.
|
|
9828
|
-
criticalCss = await _build.
|
|
9829
|
+
if (_build.unstable_getCriticalCss) {
|
|
9830
|
+
criticalCss = await _build.unstable_getCriticalCss({ pathname });
|
|
9829
9831
|
} else if (mode === "development" /* Development */ && getDevServerHooks()?.getCriticalCss) {
|
|
9830
9832
|
criticalCss = await getDevServerHooks()?.getCriticalCss?.(pathname);
|
|
9831
9833
|
}
|
|
@@ -9860,7 +9862,18 @@ async function handleManifestRequest(build, routes, url) {
|
|
|
9860
9862
|
}
|
|
9861
9863
|
let patches = {};
|
|
9862
9864
|
if (url.searchParams.has("p")) {
|
|
9863
|
-
|
|
9865
|
+
let paths = /* @__PURE__ */ new Set();
|
|
9866
|
+
url.searchParams.getAll("p").forEach((path) => {
|
|
9867
|
+
if (!path.startsWith("/")) {
|
|
9868
|
+
path = `/${path}`;
|
|
9869
|
+
}
|
|
9870
|
+
let segments = path.split("/").slice(1);
|
|
9871
|
+
segments.forEach((_, i) => {
|
|
9872
|
+
let partialPath = segments.slice(0, i + 1).join("/");
|
|
9873
|
+
paths.add(`/${partialPath}`);
|
|
9874
|
+
});
|
|
9875
|
+
});
|
|
9876
|
+
for (let path of paths) {
|
|
9864
9877
|
let matches = matchServerRoutes(routes, path, build.basename);
|
|
9865
9878
|
if (matches) {
|
|
9866
9879
|
for (let match of matches) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.
|
|
2
|
+
* react-router v7.4.0
|
|
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-GNGMS2XR.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-CGHGzi13.mjs';
|
|
2
2
|
import { M as MiddlewareEnabled, A as AppLoadContext } from '../../future-ldDp5FKH.mjs';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -139,7 +139,7 @@ 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 |
|
|
142
|
+
type CreateServerMiddlewareFunction<T extends RouteInfo> = (args: ServerDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<Response>) => MaybePromise<Response | undefined>;
|
|
143
143
|
type CreateClientMiddlewareFunction<T extends RouteInfo> = (args: ClientDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<undefined>) => MaybePromise<undefined>;
|
|
144
144
|
type CreateServerLoaderArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
|
145
145
|
type CreateClientLoaderArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
|
@@ -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-CGHGzi13.js';
|
|
2
2
|
import { M as MiddlewareEnabled, A as AppLoadContext } from '../../future-ldDp5FKH.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -139,7 +139,7 @@ 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 |
|
|
142
|
+
type CreateServerMiddlewareFunction<T extends RouteInfo> = (args: ServerDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<Response>) => MaybePromise<Response | undefined>;
|
|
143
143
|
type CreateClientMiddlewareFunction<T extends RouteInfo> = (args: ClientDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<undefined>) => MaybePromise<undefined>;
|
|
144
144
|
type CreateServerLoaderArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
|
145
145
|
type CreateClientLoaderArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
|
@@ -206,6 +206,7 @@ type UrlHistoryOptions = {
|
|
|
206
206
|
v5Compat?: boolean;
|
|
207
207
|
};
|
|
208
208
|
|
|
209
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
209
210
|
/**
|
|
210
211
|
* Map of routeId -> data returned from a loader/action/error
|
|
211
212
|
*/
|
|
@@ -323,7 +324,7 @@ interface DataFunctionArgs<Context> {
|
|
|
323
324
|
* middlewares from the bottom-up
|
|
324
325
|
*/
|
|
325
326
|
interface unstable_MiddlewareNextFunction<Result = unknown> {
|
|
326
|
-
():
|
|
327
|
+
(): MaybePromise<Result>;
|
|
327
328
|
}
|
|
328
329
|
/**
|
|
329
330
|
* Route middleware function signature. Receives the same "data" arguments as a
|
|
@@ -331,7 +332,7 @@ interface unstable_MiddlewareNextFunction<Result = unknown> {
|
|
|
331
332
|
* a `next` function as the second parameter which will call downstream handlers
|
|
332
333
|
* and then complete middlewares from the bottom-up
|
|
333
334
|
*/
|
|
334
|
-
type unstable_MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<unstable_RouterContextProvider>, next: unstable_MiddlewareNextFunction<Result>) => Result |
|
|
335
|
+
type unstable_MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<unstable_RouterContextProvider>, next: unstable_MiddlewareNextFunction<Result>) => MaybePromise<Result | undefined>;
|
|
335
336
|
/**
|
|
336
337
|
* Arguments passed to loader functions
|
|
337
338
|
*/
|
|
@@ -346,7 +347,7 @@ interface ActionFunctionArgs<Context = any> extends DataFunctionArgs<Context> {
|
|
|
346
347
|
* Loaders and actions can return anything
|
|
347
348
|
*/
|
|
348
349
|
type DataFunctionValue = unknown;
|
|
349
|
-
type DataFunctionReturnValue =
|
|
350
|
+
type DataFunctionReturnValue = MaybePromise<DataFunctionValue>;
|
|
350
351
|
/**
|
|
351
352
|
* Route loader function signature
|
|
352
353
|
*/
|
|
@@ -452,7 +453,7 @@ type AgnosticPatchRoutesOnNavigationFunctionArgs<O extends AgnosticRouteObject =
|
|
|
452
453
|
fetcherKey: string | undefined;
|
|
453
454
|
patch: (routeId: string | null, children: O[]) => void;
|
|
454
455
|
};
|
|
455
|
-
type AgnosticPatchRoutesOnNavigationFunction<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = (opts: AgnosticPatchRoutesOnNavigationFunctionArgs<O, M>) =>
|
|
456
|
+
type AgnosticPatchRoutesOnNavigationFunction<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = (opts: AgnosticPatchRoutesOnNavigationFunctionArgs<O, M>) => MaybePromise<void>;
|
|
456
457
|
/**
|
|
457
458
|
* Function provided by the framework-aware layers to set any framework-specific
|
|
458
459
|
* properties from framework-agnostic properties
|
|
@@ -711,7 +712,6 @@ declare class ErrorResponseImpl implements ErrorResponse {
|
|
|
711
712
|
*/
|
|
712
713
|
declare function isRouteErrorResponse(error: any): error is ErrorResponse;
|
|
713
714
|
|
|
714
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
715
715
|
/**
|
|
716
716
|
* A Router instance manages all navigation and data loading/mutations
|
|
717
717
|
*/
|
|
@@ -206,6 +206,7 @@ type UrlHistoryOptions = {
|
|
|
206
206
|
v5Compat?: boolean;
|
|
207
207
|
};
|
|
208
208
|
|
|
209
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
209
210
|
/**
|
|
210
211
|
* Map of routeId -> data returned from a loader/action/error
|
|
211
212
|
*/
|
|
@@ -323,7 +324,7 @@ interface DataFunctionArgs<Context> {
|
|
|
323
324
|
* middlewares from the bottom-up
|
|
324
325
|
*/
|
|
325
326
|
interface unstable_MiddlewareNextFunction<Result = unknown> {
|
|
326
|
-
():
|
|
327
|
+
(): MaybePromise<Result>;
|
|
327
328
|
}
|
|
328
329
|
/**
|
|
329
330
|
* Route middleware function signature. Receives the same "data" arguments as a
|
|
@@ -331,7 +332,7 @@ interface unstable_MiddlewareNextFunction<Result = unknown> {
|
|
|
331
332
|
* a `next` function as the second parameter which will call downstream handlers
|
|
332
333
|
* and then complete middlewares from the bottom-up
|
|
333
334
|
*/
|
|
334
|
-
type unstable_MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<unstable_RouterContextProvider>, next: unstable_MiddlewareNextFunction<Result>) => Result |
|
|
335
|
+
type unstable_MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<unstable_RouterContextProvider>, next: unstable_MiddlewareNextFunction<Result>) => MaybePromise<Result | undefined>;
|
|
335
336
|
/**
|
|
336
337
|
* Arguments passed to loader functions
|
|
337
338
|
*/
|
|
@@ -346,7 +347,7 @@ interface ActionFunctionArgs<Context = any> extends DataFunctionArgs<Context> {
|
|
|
346
347
|
* Loaders and actions can return anything
|
|
347
348
|
*/
|
|
348
349
|
type DataFunctionValue = unknown;
|
|
349
|
-
type DataFunctionReturnValue =
|
|
350
|
+
type DataFunctionReturnValue = MaybePromise<DataFunctionValue>;
|
|
350
351
|
/**
|
|
351
352
|
* Route loader function signature
|
|
352
353
|
*/
|
|
@@ -452,7 +453,7 @@ type AgnosticPatchRoutesOnNavigationFunctionArgs<O extends AgnosticRouteObject =
|
|
|
452
453
|
fetcherKey: string | undefined;
|
|
453
454
|
patch: (routeId: string | null, children: O[]) => void;
|
|
454
455
|
};
|
|
455
|
-
type AgnosticPatchRoutesOnNavigationFunction<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = (opts: AgnosticPatchRoutesOnNavigationFunctionArgs<O, M>) =>
|
|
456
|
+
type AgnosticPatchRoutesOnNavigationFunction<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = (opts: AgnosticPatchRoutesOnNavigationFunctionArgs<O, M>) => MaybePromise<void>;
|
|
456
457
|
/**
|
|
457
458
|
* Function provided by the framework-aware layers to set any framework-specific
|
|
458
459
|
* properties from framework-agnostic properties
|
|
@@ -711,7 +712,6 @@ declare class ErrorResponseImpl implements ErrorResponse {
|
|
|
711
712
|
*/
|
|
712
713
|
declare function isRouteErrorResponse(error: any): error is ErrorResponse;
|
|
713
714
|
|
|
714
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
715
715
|
/**
|
|
716
716
|
* A Router instance manages all navigation and data loading/mutations
|
|
717
717
|
*/
|