react-router 7.8.1 → 7.8.2-pre.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 +12 -0
- package/dist/development/{chunk-UH6JLGW7.mjs → chunk-5LNVHL6T.mjs} +185 -201
- package/dist/development/{chunk-TGXCWGPT.js → chunk-KUJAVZYD.js} +123 -180
- package/dist/development/{chunk-IFMMFE4R.mjs → chunk-RVSOEW4N.mjs} +34 -75
- package/dist/development/{chunk-IIA3TUI2.js → chunk-UMVNFWBW.js} +210 -169
- package/dist/development/{context-DohQKLID.d.mts → context-D5hQ2yCL.d.mts} +843 -6
- package/dist/development/dom-export.d.mts +20 -2
- package/dist/development/dom-export.d.ts +20 -1
- package/dist/development/dom-export.js +10 -4
- package/dist/development/dom-export.mjs +10 -4
- package/dist/{production/index-react-server-client-BQ6FxdA_.d.ts → development/index-react-server-client-C4AMmMi3.d.ts} +6 -816
- package/dist/{production/index-react-server-client-11fLy3qB.d.mts → development/index-react-server-client-DgVbd8DS.d.mts} +2 -3
- package/dist/development/index-react-server-client.d.mts +3 -4
- package/dist/development/index-react-server-client.d.ts +2 -2
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.d.mts +1 -1
- package/dist/development/index-react-server.d.ts +1 -1
- package/dist/development/index-react-server.js +39 -45
- package/dist/development/index-react-server.mjs +39 -45
- package/dist/development/index.d.mts +7 -9
- package/dist/development/index.d.ts +5 -5
- package/dist/development/index.js +122 -163
- package/dist/development/index.mjs +3 -3
- package/dist/development/lib/types/internal.d.mts +3 -3
- 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/{route-data-CNjObrhZ.d.mts → route-data-B3sNokxM.d.mts} +2 -2
- package/dist/development/{routeModules-C3oqzPpI.d.ts → routeModules-DRWHoPcT.d.ts} +844 -7
- package/dist/production/{chunk-YMYXECPK.js → chunk-3PSRBVDP.js} +210 -169
- package/dist/production/{chunk-5Y7ELDIJ.mjs → chunk-4HHN5NDL.mjs} +34 -75
- package/dist/production/{chunk-KHPQXKYM.js → chunk-NCRSBAFG.js} +123 -180
- package/dist/production/{chunk-PFDCNQUK.mjs → chunk-O46NJYOA.mjs} +185 -201
- package/dist/production/{context-DohQKLID.d.mts → context-D5hQ2yCL.d.mts} +843 -6
- package/dist/production/dom-export.d.mts +20 -2
- package/dist/production/dom-export.d.ts +20 -1
- package/dist/production/dom-export.js +10 -4
- package/dist/production/dom-export.mjs +10 -4
- package/dist/{development/index-react-server-client-BQ6FxdA_.d.ts → production/index-react-server-client-C4AMmMi3.d.ts} +6 -816
- package/dist/{development/index-react-server-client-11fLy3qB.d.mts → production/index-react-server-client-DgVbd8DS.d.mts} +2 -3
- package/dist/production/index-react-server-client.d.mts +3 -4
- package/dist/production/index-react-server-client.d.ts +2 -2
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.d.mts +1 -1
- package/dist/production/index-react-server.d.ts +1 -1
- package/dist/production/index-react-server.js +39 -45
- package/dist/production/index-react-server.mjs +39 -45
- package/dist/production/index.d.mts +7 -9
- package/dist/production/index.d.ts +5 -5
- package/dist/production/index.js +122 -163
- package/dist/production/index.mjs +3 -3
- package/dist/production/lib/types/internal.d.mts +3 -3
- 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/production/{route-data-CNjObrhZ.d.mts → route-data-B3sNokxM.d.mts} +2 -2
- package/dist/production/{routeModules-C3oqzPpI.d.ts → routeModules-DRWHoPcT.d.ts} +844 -7
- package/package.json +1 -1
- package/dist/development/components-CuPfnyiZ.d.mts +0 -814
- package/dist/production/components-CuPfnyiZ.d.mts +0 -814
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.8.
|
|
2
|
+
* react-router v7.8.2-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -58,7 +58,7 @@ import {
|
|
|
58
58
|
withComponentProps,
|
|
59
59
|
withErrorBoundaryProps,
|
|
60
60
|
withHydrateFallbackProps
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-O46NJYOA.mjs";
|
|
62
62
|
|
|
63
63
|
// lib/dom/ssr/server.tsx
|
|
64
64
|
import * as React from "react";
|
|
@@ -799,21 +799,7 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
|
|
|
799
799
|
return handleQueryError(error);
|
|
800
800
|
}
|
|
801
801
|
function handleQueryResult(result) {
|
|
802
|
-
|
|
803
|
-
result = staticContextToResponse(result);
|
|
804
|
-
}
|
|
805
|
-
if (isRedirectResponse(result)) {
|
|
806
|
-
return generateSingleFetchResponse(request, build, serverMode, {
|
|
807
|
-
result: getSingleFetchRedirect(
|
|
808
|
-
result.status,
|
|
809
|
-
result.headers,
|
|
810
|
-
build.basename
|
|
811
|
-
),
|
|
812
|
-
headers: result.headers,
|
|
813
|
-
status: SINGLE_FETCH_REDIRECT_STATUS
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
return result;
|
|
802
|
+
return isResponse(result) ? result : staticContextToResponse(result);
|
|
817
803
|
}
|
|
818
804
|
function handleQueryError(error) {
|
|
819
805
|
handleError(error);
|
|
@@ -826,15 +812,7 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
|
|
|
826
812
|
function staticContextToResponse(context) {
|
|
827
813
|
let headers = getDocumentHeaders(context, build);
|
|
828
814
|
if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
|
|
829
|
-
return
|
|
830
|
-
result: getSingleFetchRedirect(
|
|
831
|
-
context.statusCode,
|
|
832
|
-
headers,
|
|
833
|
-
build.basename
|
|
834
|
-
),
|
|
835
|
-
headers,
|
|
836
|
-
status: SINGLE_FETCH_REDIRECT_STATUS
|
|
837
|
-
});
|
|
815
|
+
return new Response(null, { status: context.statusCode, headers });
|
|
838
816
|
}
|
|
839
817
|
if (context.errors) {
|
|
840
818
|
Object.values(context.errors).forEach((err) => {
|
|
@@ -885,21 +863,7 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, han
|
|
|
885
863
|
return handleQueryError(error);
|
|
886
864
|
}
|
|
887
865
|
function handleQueryResult(result) {
|
|
888
|
-
|
|
889
|
-
if (isRedirectResponse(response)) {
|
|
890
|
-
return generateSingleFetchResponse(request, build, serverMode, {
|
|
891
|
-
result: {
|
|
892
|
-
[SingleFetchRedirectSymbol]: getSingleFetchRedirect(
|
|
893
|
-
response.status,
|
|
894
|
-
response.headers,
|
|
895
|
-
build.basename
|
|
896
|
-
)
|
|
897
|
-
},
|
|
898
|
-
headers: response.headers,
|
|
899
|
-
status: SINGLE_FETCH_REDIRECT_STATUS
|
|
900
|
-
});
|
|
901
|
-
}
|
|
902
|
-
return response;
|
|
866
|
+
return isResponse(result) ? result : staticContextToResponse(result);
|
|
903
867
|
}
|
|
904
868
|
function handleQueryError(error) {
|
|
905
869
|
handleError(error);
|
|
@@ -912,17 +876,7 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, han
|
|
|
912
876
|
function staticContextToResponse(context) {
|
|
913
877
|
let headers = getDocumentHeaders(context, build);
|
|
914
878
|
if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
|
|
915
|
-
return
|
|
916
|
-
result: {
|
|
917
|
-
[SingleFetchRedirectSymbol]: getSingleFetchRedirect(
|
|
918
|
-
context.statusCode,
|
|
919
|
-
headers,
|
|
920
|
-
build.basename
|
|
921
|
-
)
|
|
922
|
-
},
|
|
923
|
-
headers,
|
|
924
|
-
status: SINGLE_FETCH_REDIRECT_STATUS
|
|
925
|
-
});
|
|
879
|
+
return new Response(null, { status: context.statusCode, headers });
|
|
926
880
|
}
|
|
927
881
|
if (context.errors) {
|
|
928
882
|
Object.values(context.errors).forEach((err) => {
|
|
@@ -980,6 +934,21 @@ function generateSingleFetchResponse(request, build, serverMode, {
|
|
|
980
934
|
}
|
|
981
935
|
);
|
|
982
936
|
}
|
|
937
|
+
function generateSingleFetchRedirectResponse(redirectResponse, request, build, serverMode) {
|
|
938
|
+
let redirect2 = getSingleFetchRedirect(
|
|
939
|
+
redirectResponse.status,
|
|
940
|
+
redirectResponse.headers,
|
|
941
|
+
build.basename
|
|
942
|
+
);
|
|
943
|
+
let headers = new Headers(redirectResponse.headers);
|
|
944
|
+
headers.delete("Location");
|
|
945
|
+
headers.set("Content-Type", "text/x-script");
|
|
946
|
+
return generateSingleFetchResponse(request, build, serverMode, {
|
|
947
|
+
result: request.method === "GET" ? { [SingleFetchRedirectSymbol]: redirect2 } : redirect2,
|
|
948
|
+
headers,
|
|
949
|
+
status: SINGLE_FETCH_REDIRECT_STATUS
|
|
950
|
+
});
|
|
951
|
+
}
|
|
983
952
|
function getSingleFetchRedirect(status, headers, basename) {
|
|
984
953
|
let redirect2 = headers.get("Location");
|
|
985
954
|
if (basename) {
|
|
@@ -1205,6 +1174,14 @@ var createRequestHandler = (build, mode) => {
|
|
|
1205
1174
|
loadContext,
|
|
1206
1175
|
handleError
|
|
1207
1176
|
);
|
|
1177
|
+
if (isRedirectResponse(response)) {
|
|
1178
|
+
response = generateSingleFetchRedirectResponse(
|
|
1179
|
+
response,
|
|
1180
|
+
request,
|
|
1181
|
+
_build,
|
|
1182
|
+
serverMode
|
|
1183
|
+
);
|
|
1184
|
+
}
|
|
1208
1185
|
if (_build.entry.module.handleDataRequest) {
|
|
1209
1186
|
response = await _build.entry.module.handleDataRequest(response, {
|
|
1210
1187
|
context: loadContext,
|
|
@@ -1212,29 +1189,11 @@ var createRequestHandler = (build, mode) => {
|
|
|
1212
1189
|
request
|
|
1213
1190
|
});
|
|
1214
1191
|
if (isRedirectResponse(response)) {
|
|
1215
|
-
|
|
1216
|
-
response
|
|
1217
|
-
|
|
1218
|
-
_build
|
|
1219
|
-
|
|
1220
|
-
if (request.method === "GET") {
|
|
1221
|
-
result = {
|
|
1222
|
-
[SingleFetchRedirectSymbol]: result
|
|
1223
|
-
};
|
|
1224
|
-
}
|
|
1225
|
-
let headers = new Headers(response.headers);
|
|
1226
|
-
headers.set("Content-Type", "text/x-script");
|
|
1227
|
-
return new Response(
|
|
1228
|
-
encodeViaTurboStream(
|
|
1229
|
-
result,
|
|
1230
|
-
request.signal,
|
|
1231
|
-
_build.entry.module.streamTimeout,
|
|
1232
|
-
serverMode
|
|
1233
|
-
),
|
|
1234
|
-
{
|
|
1235
|
-
status: SINGLE_FETCH_REDIRECT_STATUS,
|
|
1236
|
-
headers
|
|
1237
|
-
}
|
|
1192
|
+
response = generateSingleFetchRedirectResponse(
|
|
1193
|
+
response,
|
|
1194
|
+
request,
|
|
1195
|
+
_build,
|
|
1196
|
+
serverMode
|
|
1238
1197
|
);
|
|
1239
1198
|
}
|
|
1240
1199
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
|
|
2
|
-
* react-router v7.8.
|
|
2
|
+
* react-router v7.8.2-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -699,7 +699,7 @@ function generatePath(originalPath, params = {}) {
|
|
|
699
699
|
const [, key, optional] = keyMatch;
|
|
700
700
|
let param = params[key];
|
|
701
701
|
invariant(optional === "?" || param != null, `Missing ":${key}" param`);
|
|
702
|
-
return stringify2(param);
|
|
702
|
+
return encodeURIComponent(stringify2(param));
|
|
703
703
|
}
|
|
704
704
|
return segment.replace(/\?$/g, "");
|
|
705
705
|
}).filter((segment) => !!segment);
|
|
@@ -1004,6 +1004,9 @@ function createRouter(init) {
|
|
|
1004
1004
|
);
|
|
1005
1005
|
let inFlightDataRoutes;
|
|
1006
1006
|
let basename = init.basename || "/";
|
|
1007
|
+
if (!basename.startsWith("/")) {
|
|
1008
|
+
basename = `/${basename}`;
|
|
1009
|
+
}
|
|
1007
1010
|
let dataStrategyImpl = init.dataStrategy || defaultDataStrategyWithMiddleware;
|
|
1008
1011
|
let future = {
|
|
1009
1012
|
unstable_middleware: false,
|
|
@@ -1553,6 +1556,19 @@ function createRouter(init) {
|
|
|
1553
1556
|
if (discoverResult.type === "aborted") {
|
|
1554
1557
|
return { shortCircuited: true };
|
|
1555
1558
|
} else if (discoverResult.type === "error") {
|
|
1559
|
+
if (discoverResult.partialMatches.length === 0) {
|
|
1560
|
+
let { matches: matches2, route } = getShortCircuitMatches(dataRoutes);
|
|
1561
|
+
return {
|
|
1562
|
+
matches: matches2,
|
|
1563
|
+
pendingActionResult: [
|
|
1564
|
+
route.id,
|
|
1565
|
+
{
|
|
1566
|
+
type: "error" /* error */,
|
|
1567
|
+
error: discoverResult.error
|
|
1568
|
+
}
|
|
1569
|
+
]
|
|
1570
|
+
};
|
|
1571
|
+
}
|
|
1556
1572
|
let boundaryId = findNearestBoundary(discoverResult.partialMatches).route.id;
|
|
1557
1573
|
return {
|
|
1558
1574
|
matches: discoverResult.partialMatches,
|
|
@@ -1684,6 +1700,16 @@ function createRouter(init) {
|
|
|
1684
1700
|
if (discoverResult.type === "aborted") {
|
|
1685
1701
|
return { shortCircuited: true };
|
|
1686
1702
|
} else if (discoverResult.type === "error") {
|
|
1703
|
+
if (discoverResult.partialMatches.length === 0) {
|
|
1704
|
+
let { matches: matches2, route } = getShortCircuitMatches(dataRoutes);
|
|
1705
|
+
return {
|
|
1706
|
+
matches: matches2,
|
|
1707
|
+
loaderData: {},
|
|
1708
|
+
errors: {
|
|
1709
|
+
[route.id]: discoverResult.error
|
|
1710
|
+
}
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1687
1713
|
let boundaryId = findNearestBoundary(discoverResult.partialMatches).route.id;
|
|
1688
1714
|
return {
|
|
1689
1715
|
matches: discoverResult.partialMatches,
|
|
@@ -3947,198 +3973,116 @@ async function defaultDataStrategyWithMiddleware(args) {
|
|
|
3947
3973
|
if (!args.matches.some((m) => m.route.unstable_middleware)) {
|
|
3948
3974
|
return defaultDataStrategy(args);
|
|
3949
3975
|
}
|
|
3950
|
-
|
|
3951
|
-
|
|
3976
|
+
return runClientMiddlewarePipeline(args, () => defaultDataStrategy(args));
|
|
3977
|
+
}
|
|
3978
|
+
function runServerMiddlewarePipeline(args, handler, errorHandler) {
|
|
3979
|
+
return runMiddlewarePipeline(
|
|
3952
3980
|
args,
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
(error, routeId) => clientMiddlewareErrorHandler(
|
|
3958
|
-
error,
|
|
3959
|
-
routeId,
|
|
3960
|
-
args.matches,
|
|
3961
|
-
didCallHandler
|
|
3962
|
-
)
|
|
3981
|
+
handler,
|
|
3982
|
+
processResult,
|
|
3983
|
+
isResponse,
|
|
3984
|
+
errorHandler
|
|
3963
3985
|
);
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
if (didCallHandler) {
|
|
3967
|
-
return {
|
|
3968
|
-
[routeId]: { type: "error", result: error }
|
|
3969
|
-
};
|
|
3970
|
-
} else {
|
|
3971
|
-
let maxBoundaryIdx = Math.min(
|
|
3972
|
-
// Throwing route
|
|
3973
|
-
matches.findIndex((m) => m.route.id === routeId) || 0,
|
|
3974
|
-
// or the shallowest route that needs to load data
|
|
3975
|
-
matches.findIndex((m) => m.unstable_shouldCallHandler()) || 0
|
|
3976
|
-
);
|
|
3977
|
-
let boundaryRouteId = findNearestBoundary(
|
|
3978
|
-
matches,
|
|
3979
|
-
matches[maxBoundaryIdx].route.id
|
|
3980
|
-
).route.id;
|
|
3981
|
-
return {
|
|
3982
|
-
[boundaryRouteId]: { type: "error", result: error }
|
|
3983
|
-
};
|
|
3986
|
+
function processResult(result) {
|
|
3987
|
+
return isDataWithResponseInit(result) ? dataWithResponseInitToResponse(result) : result;
|
|
3984
3988
|
}
|
|
3985
3989
|
}
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
(m) => m.route.unstable_middleware ? m.route.unstable_middleware.map((fn) => [m.route.id, fn]) : []
|
|
3990
|
-
);
|
|
3991
|
-
let result = await callServerRouteMiddleware(
|
|
3992
|
-
{ request, params, context },
|
|
3993
|
-
tuples,
|
|
3990
|
+
function runClientMiddlewarePipeline(args, handler) {
|
|
3991
|
+
return runMiddlewarePipeline(
|
|
3992
|
+
args,
|
|
3994
3993
|
handler,
|
|
3994
|
+
(r) => r,
|
|
3995
|
+
// No post-processing needed on the client
|
|
3996
|
+
isDataStrategyResults,
|
|
3995
3997
|
errorHandler
|
|
3996
3998
|
);
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
}
|
|
4002
|
-
|
|
4003
|
-
let { request } = args;
|
|
4004
|
-
if (request.signal.aborted) {
|
|
4005
|
-
if (request.signal.reason) {
|
|
4006
|
-
throw request.signal.reason;
|
|
4007
|
-
}
|
|
4008
|
-
throw new Error(
|
|
4009
|
-
`Request aborted without an \`AbortSignal.reason\`: ${request.method} ${request.url}`
|
|
4010
|
-
);
|
|
4011
|
-
}
|
|
4012
|
-
let tuple = middlewares[idx];
|
|
4013
|
-
if (!tuple) {
|
|
4014
|
-
let result = await handler();
|
|
4015
|
-
return result;
|
|
4016
|
-
}
|
|
4017
|
-
let [routeId, middleware] = tuple;
|
|
4018
|
-
let nextCalled = false;
|
|
4019
|
-
let nextResult = void 0;
|
|
4020
|
-
let next = async () => {
|
|
4021
|
-
if (nextCalled) {
|
|
4022
|
-
throw new Error("You may only call `next()` once per middleware");
|
|
4023
|
-
}
|
|
4024
|
-
nextCalled = true;
|
|
4025
|
-
try {
|
|
4026
|
-
let result = await callServerRouteMiddleware(
|
|
4027
|
-
args,
|
|
4028
|
-
middlewares,
|
|
4029
|
-
handler,
|
|
4030
|
-
errorHandler,
|
|
4031
|
-
idx + 1
|
|
3999
|
+
function errorHandler(error, routeId, nextResult) {
|
|
4000
|
+
if (nextResult) {
|
|
4001
|
+
return Promise.resolve(
|
|
4002
|
+
Object.assign(nextResult.value, {
|
|
4003
|
+
[routeId]: { type: "error", result: error }
|
|
4004
|
+
})
|
|
4032
4005
|
);
|
|
4033
|
-
if (isDataWithResponseInit(result)) {
|
|
4034
|
-
result = dataWithResponseInitToResponse(result);
|
|
4035
|
-
}
|
|
4036
|
-
nextResult = result;
|
|
4037
|
-
return nextResult;
|
|
4038
|
-
} catch (e) {
|
|
4039
|
-
nextResult = await errorHandler(e, routeId);
|
|
4040
|
-
return nextResult;
|
|
4041
|
-
}
|
|
4042
|
-
};
|
|
4043
|
-
try {
|
|
4044
|
-
let result = await middleware(
|
|
4045
|
-
{
|
|
4046
|
-
request: args.request,
|
|
4047
|
-
params: args.params,
|
|
4048
|
-
context: args.context
|
|
4049
|
-
},
|
|
4050
|
-
next
|
|
4051
|
-
);
|
|
4052
|
-
if (isDataWithResponseInit(result)) {
|
|
4053
|
-
result = dataWithResponseInitToResponse(result);
|
|
4054
|
-
}
|
|
4055
|
-
if (nextCalled) {
|
|
4056
|
-
return typeof result === "undefined" ? nextResult : result;
|
|
4057
|
-
} else if (isResponse(result)) {
|
|
4058
|
-
return result;
|
|
4059
4006
|
} else {
|
|
4060
|
-
|
|
4061
|
-
|
|
4007
|
+
let { matches } = args;
|
|
4008
|
+
let maxBoundaryIdx = Math.min(
|
|
4009
|
+
// Throwing route
|
|
4010
|
+
matches.findIndex((m) => m.route.id === routeId) || 0,
|
|
4011
|
+
// or the shallowest route that needs to load data
|
|
4012
|
+
matches.findIndex((m) => m.unstable_shouldCallHandler()) || 0
|
|
4013
|
+
);
|
|
4014
|
+
let boundaryRouteId = findNearestBoundary(
|
|
4015
|
+
matches,
|
|
4016
|
+
matches[maxBoundaryIdx].route.id
|
|
4017
|
+
).route.id;
|
|
4018
|
+
return Promise.resolve({
|
|
4019
|
+
[boundaryRouteId]: { type: "error", result: error }
|
|
4020
|
+
});
|
|
4062
4021
|
}
|
|
4063
|
-
} catch (e) {
|
|
4064
|
-
let response = await errorHandler(e, routeId);
|
|
4065
|
-
return response;
|
|
4066
4022
|
}
|
|
4067
4023
|
}
|
|
4068
|
-
async function
|
|
4024
|
+
async function runMiddlewarePipeline(args, handler, processResult, isResult, errorHandler) {
|
|
4069
4025
|
let { matches, request, params, context } = args;
|
|
4070
4026
|
let tuples = matches.flatMap(
|
|
4071
4027
|
(m) => m.route.unstable_middleware ? m.route.unstable_middleware.map((fn) => [m.route.id, fn]) : []
|
|
4072
4028
|
);
|
|
4073
|
-
let
|
|
4074
|
-
await callClientRouteMiddleware(
|
|
4029
|
+
let result = await callRouteMiddleware(
|
|
4075
4030
|
{ request, params, context },
|
|
4076
4031
|
tuples,
|
|
4077
4032
|
handler,
|
|
4078
|
-
|
|
4079
|
-
|
|
4033
|
+
processResult,
|
|
4034
|
+
isResult,
|
|
4035
|
+
errorHandler
|
|
4080
4036
|
);
|
|
4081
|
-
return
|
|
4037
|
+
return result;
|
|
4082
4038
|
}
|
|
4083
|
-
async function
|
|
4039
|
+
async function callRouteMiddleware(args, middlewares, handler, processResult, isResult, errorHandler, idx = 0) {
|
|
4084
4040
|
let { request } = args;
|
|
4085
4041
|
if (request.signal.aborted) {
|
|
4086
|
-
|
|
4087
|
-
throw request.signal.reason;
|
|
4088
|
-
}
|
|
4089
|
-
throw new Error(
|
|
4090
|
-
`Request aborted without an \`AbortSignal.reason\`: ${request.method} ${request.url}`
|
|
4091
|
-
);
|
|
4042
|
+
throw _nullishCoalesce(request.signal.reason, () => ( new Error(`Request aborted: ${request.method} ${request.url}`)));
|
|
4092
4043
|
}
|
|
4093
4044
|
let tuple = middlewares[idx];
|
|
4094
4045
|
if (!tuple) {
|
|
4095
4046
|
let result = await handler();
|
|
4096
|
-
|
|
4097
|
-
return;
|
|
4047
|
+
return result;
|
|
4098
4048
|
}
|
|
4099
4049
|
let [routeId, middleware] = tuple;
|
|
4100
|
-
let
|
|
4050
|
+
let nextResult;
|
|
4101
4051
|
let next = async () => {
|
|
4102
|
-
if (
|
|
4052
|
+
if (nextResult) {
|
|
4103
4053
|
throw new Error("You may only call `next()` once per middleware");
|
|
4104
4054
|
}
|
|
4105
|
-
nextCalled = true;
|
|
4106
4055
|
try {
|
|
4107
|
-
let result = await
|
|
4056
|
+
let result = await callRouteMiddleware(
|
|
4108
4057
|
args,
|
|
4109
4058
|
middlewares,
|
|
4110
4059
|
handler,
|
|
4060
|
+
processResult,
|
|
4061
|
+
isResult,
|
|
4111
4062
|
errorHandler,
|
|
4112
|
-
handlerResult,
|
|
4113
4063
|
idx + 1
|
|
4114
4064
|
);
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4065
|
+
nextResult = { value: result };
|
|
4066
|
+
return nextResult.value;
|
|
4067
|
+
} catch (error) {
|
|
4068
|
+
nextResult = { value: await errorHandler(error, routeId, nextResult) };
|
|
4069
|
+
return nextResult.value;
|
|
4119
4070
|
}
|
|
4120
4071
|
};
|
|
4121
4072
|
try {
|
|
4122
|
-
let
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
console.warn(
|
|
4132
|
-
"client middlewares are not intended to return values, the value will be ignored",
|
|
4133
|
-
result
|
|
4134
|
-
);
|
|
4135
|
-
}
|
|
4136
|
-
if (!nextCalled) {
|
|
4137
|
-
await next();
|
|
4073
|
+
let value = await middleware(args, next);
|
|
4074
|
+
let result = value != null ? processResult(value) : void 0;
|
|
4075
|
+
if (isResult(result)) {
|
|
4076
|
+
return result;
|
|
4077
|
+
} else if (nextResult) {
|
|
4078
|
+
return _nullishCoalesce(result, () => ( nextResult.value));
|
|
4079
|
+
} else {
|
|
4080
|
+
nextResult = { value: await next() };
|
|
4081
|
+
return nextResult.value;
|
|
4138
4082
|
}
|
|
4139
4083
|
} catch (error) {
|
|
4140
|
-
let
|
|
4141
|
-
|
|
4084
|
+
let response = await errorHandler(error, routeId, nextResult);
|
|
4085
|
+
return response;
|
|
4142
4086
|
}
|
|
4143
4087
|
}
|
|
4144
4088
|
function getDataStrategyMatchLazyPromises(mapRouteProperties, manifest, request, match, lazyRoutePropertiesToSkip) {
|
|
@@ -4249,28 +4193,17 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4249
4193
|
);
|
|
4250
4194
|
} : (cb) => {
|
|
4251
4195
|
let typedDataStrategyArgs = dataStrategyArgs;
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
);
|
|
4264
|
-
}
|
|
4265
|
-
});
|
|
4266
|
-
},
|
|
4267
|
-
(error, routeId) => clientMiddlewareErrorHandler(
|
|
4268
|
-
error,
|
|
4269
|
-
routeId,
|
|
4270
|
-
matches,
|
|
4271
|
-
didCallHandler
|
|
4272
|
-
)
|
|
4273
|
-
);
|
|
4196
|
+
return runClientMiddlewarePipeline(typedDataStrategyArgs, () => {
|
|
4197
|
+
return cb({
|
|
4198
|
+
...typedDataStrategyArgs,
|
|
4199
|
+
fetcherKey,
|
|
4200
|
+
unstable_runClientMiddleware: () => {
|
|
4201
|
+
throw new Error(
|
|
4202
|
+
"Cannot call `unstable_runClientMiddleware()` from within an `unstable_runClientMiddleware` handler"
|
|
4203
|
+
);
|
|
4204
|
+
}
|
|
4205
|
+
});
|
|
4206
|
+
});
|
|
4274
4207
|
};
|
|
4275
4208
|
let results = await dataStrategyImpl({
|
|
4276
4209
|
...dataStrategyArgs,
|
|
@@ -4738,6 +4671,11 @@ function dataWithResponseInitToErrorResponse(data2) {
|
|
|
4738
4671
|
data2.data
|
|
4739
4672
|
);
|
|
4740
4673
|
}
|
|
4674
|
+
function isDataStrategyResults(result) {
|
|
4675
|
+
return result != null && typeof result === "object" && Object.entries(result).every(
|
|
4676
|
+
([key, value]) => typeof key === "string" && isDataStrategyResult(value)
|
|
4677
|
+
);
|
|
4678
|
+
}
|
|
4741
4679
|
function isDataStrategyResult(result) {
|
|
4742
4680
|
return result != null && typeof result === "object" && "type" in result && "result" in result && (result.type === "data" /* data */ || result.type === "error" /* error */);
|
|
4743
4681
|
}
|
|
@@ -6326,7 +6264,7 @@ function useResolvedPath(to, { relative } = {}) {
|
|
|
6326
6264
|
function useRoutes(routes, locationArg) {
|
|
6327
6265
|
return useRoutesImpl(routes, locationArg);
|
|
6328
6266
|
}
|
|
6329
|
-
function useRoutesImpl(routes, locationArg, dataRouterState, future) {
|
|
6267
|
+
function useRoutesImpl(routes, locationArg, dataRouterState, unstable_onError, future) {
|
|
6330
6268
|
invariant(
|
|
6331
6269
|
useInRouterContext(),
|
|
6332
6270
|
// TODO: This error is probably because they somehow have 2 versions of the
|
|
@@ -6398,6 +6336,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
6398
6336
|
),
|
|
6399
6337
|
parentMatches,
|
|
6400
6338
|
dataRouterState,
|
|
6339
|
+
unstable_onError,
|
|
6401
6340
|
future
|
|
6402
6341
|
);
|
|
6403
6342
|
if (locationArg && renderedMatches) {
|
|
@@ -6466,11 +6405,14 @@ var RenderErrorBoundary = class extends React3.Component {
|
|
|
6466
6405
|
};
|
|
6467
6406
|
}
|
|
6468
6407
|
componentDidCatch(error, errorInfo) {
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6408
|
+
if (this.props.unstable_onError) {
|
|
6409
|
+
this.props.unstable_onError(error, errorInfo);
|
|
6410
|
+
} else {
|
|
6411
|
+
console.error(
|
|
6412
|
+
"React Router caught the following error during render",
|
|
6413
|
+
error
|
|
6414
|
+
);
|
|
6415
|
+
}
|
|
6474
6416
|
}
|
|
6475
6417
|
render() {
|
|
6476
6418
|
return this.state.error !== void 0 ? /* @__PURE__ */ React3.createElement(RouteContext.Provider, { value: this.props.routeContext }, /* @__PURE__ */ React3.createElement(
|
|
@@ -6489,7 +6431,7 @@ function RenderedRoute({ routeContext, match, children }) {
|
|
|
6489
6431
|
}
|
|
6490
6432
|
return /* @__PURE__ */ React3.createElement(RouteContext.Provider, { value: routeContext }, children);
|
|
6491
6433
|
}
|
|
6492
|
-
function _renderMatches(matches, parentMatches = [], dataRouterState = null, future = null) {
|
|
6434
|
+
function _renderMatches(matches, parentMatches = [], dataRouterState = null, unstable_onError = null, future = null) {
|
|
6493
6435
|
if (matches == null) {
|
|
6494
6436
|
if (!dataRouterState) {
|
|
6495
6437
|
return null;
|
|
@@ -6601,7 +6543,8 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, fut
|
|
|
6601
6543
|
component: errorElement,
|
|
6602
6544
|
error,
|
|
6603
6545
|
children: getChildren(),
|
|
6604
|
-
routeContext: { outlet: null, matches: matches2, isDataRoute: true }
|
|
6546
|
+
routeContext: { outlet: null, matches: matches2, isDataRoute: true },
|
|
6547
|
+
unstable_onError
|
|
6605
6548
|
}
|
|
6606
6549
|
) : getChildren();
|
|
6607
6550
|
},
|