react-router 7.8.1 → 7.8.2-pre.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 +23 -0
- package/dist/development/{chunk-IFMMFE4R.mjs → chunk-7QFLQWWN.mjs} +34 -75
- package/dist/{production/chunk-YMYXECPK.js → development/chunk-IVOVRAK2.js} +210 -169
- package/dist/development/{chunk-UH6JLGW7.mjs → chunk-ZVD2KUIM.mjs} +187 -204
- package/dist/development/{chunk-TGXCWGPT.js → chunk-ZVMYUFGA.js} +125 -183
- package/dist/development/{context-DohQKLID.d.mts → context-jKip1TFB.d.mts} +846 -8
- 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-BKpa2trA.d.ts} +6 -816
- package/dist/{production/index-react-server-client-11fLy3qB.d.mts → development/index-react-server-client-DRhjXpk2.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 +4 -3
- package/dist/development/index-react-server.d.ts +4 -3
- package/dist/development/index-react-server.js +62 -53
- package/dist/development/index-react-server.mjs +62 -53
- 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-DAVP2QQ0.d.mts} +3 -3
- package/dist/development/{routeModules-C3oqzPpI.d.ts → routeModules-rOzWJJ9x.d.ts} +848 -10
- package/dist/production/{chunk-KHPQXKYM.js → chunk-5WPGWA23.js} +125 -183
- package/dist/{development/chunk-IIA3TUI2.js → production/chunk-IK7IYG3O.js} +210 -169
- package/dist/production/{chunk-5Y7ELDIJ.mjs → chunk-LR4OTIMG.mjs} +34 -75
- package/dist/production/{chunk-PFDCNQUK.mjs → chunk-VHBXOG2Z.mjs} +187 -204
- package/dist/production/{context-DohQKLID.d.mts → context-jKip1TFB.d.mts} +846 -8
- 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-BKpa2trA.d.ts} +6 -816
- package/dist/{development/index-react-server-client-11fLy3qB.d.mts → production/index-react-server-client-DRhjXpk2.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 +4 -3
- package/dist/production/index-react-server.d.ts +4 -3
- package/dist/production/index-react-server.js +62 -53
- package/dist/production/index-react-server.mjs +62 -53
- 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-DAVP2QQ0.d.mts} +3 -3
- package/dist/production/{routeModules-C3oqzPpI.d.ts → routeModules-rOzWJJ9x.d.ts} +848 -10
- 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.1
|
|
2
|
+
* react-router v7.8.2-pre.1
|
|
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,9 +1004,11 @@ 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
|
-
unstable_middleware: false,
|
|
1010
1012
|
...init.future
|
|
1011
1013
|
};
|
|
1012
1014
|
let unlistenHistory = null;
|
|
@@ -1553,6 +1555,19 @@ function createRouter(init) {
|
|
|
1553
1555
|
if (discoverResult.type === "aborted") {
|
|
1554
1556
|
return { shortCircuited: true };
|
|
1555
1557
|
} else if (discoverResult.type === "error") {
|
|
1558
|
+
if (discoverResult.partialMatches.length === 0) {
|
|
1559
|
+
let { matches: matches2, route } = getShortCircuitMatches(dataRoutes);
|
|
1560
|
+
return {
|
|
1561
|
+
matches: matches2,
|
|
1562
|
+
pendingActionResult: [
|
|
1563
|
+
route.id,
|
|
1564
|
+
{
|
|
1565
|
+
type: "error" /* error */,
|
|
1566
|
+
error: discoverResult.error
|
|
1567
|
+
}
|
|
1568
|
+
]
|
|
1569
|
+
};
|
|
1570
|
+
}
|
|
1556
1571
|
let boundaryId = findNearestBoundary(discoverResult.partialMatches).route.id;
|
|
1557
1572
|
return {
|
|
1558
1573
|
matches: discoverResult.partialMatches,
|
|
@@ -1684,6 +1699,16 @@ function createRouter(init) {
|
|
|
1684
1699
|
if (discoverResult.type === "aborted") {
|
|
1685
1700
|
return { shortCircuited: true };
|
|
1686
1701
|
} else if (discoverResult.type === "error") {
|
|
1702
|
+
if (discoverResult.partialMatches.length === 0) {
|
|
1703
|
+
let { matches: matches2, route } = getShortCircuitMatches(dataRoutes);
|
|
1704
|
+
return {
|
|
1705
|
+
matches: matches2,
|
|
1706
|
+
loaderData: {},
|
|
1707
|
+
errors: {
|
|
1708
|
+
[route.id]: discoverResult.error
|
|
1709
|
+
}
|
|
1710
|
+
};
|
|
1711
|
+
}
|
|
1687
1712
|
let boundaryId = findNearestBoundary(discoverResult.partialMatches).route.id;
|
|
1688
1713
|
return {
|
|
1689
1714
|
matches: discoverResult.partialMatches,
|
|
@@ -2801,7 +2826,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2801
2826
|
},
|
|
2802
2827
|
async () => {
|
|
2803
2828
|
let res = await generateMiddlewareResponse(
|
|
2804
|
-
async (revalidationRequest) => {
|
|
2829
|
+
async (revalidationRequest, opts2 = {}) => {
|
|
2805
2830
|
let result2 = await queryImpl(
|
|
2806
2831
|
revalidationRequest,
|
|
2807
2832
|
location,
|
|
@@ -2810,7 +2835,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2810
2835
|
dataStrategy || null,
|
|
2811
2836
|
skipLoaderErrorBubbling === true,
|
|
2812
2837
|
null,
|
|
2813
|
-
filterMatchesToLoad
|
|
2838
|
+
"filterMatchesToLoad" in opts2 ? opts2.filterMatchesToLoad ?? null : null,
|
|
2814
2839
|
skipRevalidation === true
|
|
2815
2840
|
);
|
|
2816
2841
|
if (isResponse(result2)) {
|
|
@@ -3947,198 +3972,116 @@ async function defaultDataStrategyWithMiddleware(args) {
|
|
|
3947
3972
|
if (!args.matches.some((m) => m.route.unstable_middleware)) {
|
|
3948
3973
|
return defaultDataStrategy(args);
|
|
3949
3974
|
}
|
|
3950
|
-
|
|
3951
|
-
|
|
3975
|
+
return runClientMiddlewarePipeline(args, () => defaultDataStrategy(args));
|
|
3976
|
+
}
|
|
3977
|
+
function runServerMiddlewarePipeline(args, handler, errorHandler) {
|
|
3978
|
+
return runMiddlewarePipeline(
|
|
3952
3979
|
args,
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
(error, routeId) => clientMiddlewareErrorHandler(
|
|
3958
|
-
error,
|
|
3959
|
-
routeId,
|
|
3960
|
-
args.matches,
|
|
3961
|
-
didCallHandler
|
|
3962
|
-
)
|
|
3980
|
+
handler,
|
|
3981
|
+
processResult,
|
|
3982
|
+
isResponse,
|
|
3983
|
+
errorHandler
|
|
3963
3984
|
);
|
|
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
|
-
};
|
|
3985
|
+
function processResult(result) {
|
|
3986
|
+
return isDataWithResponseInit(result) ? dataWithResponseInitToResponse(result) : result;
|
|
3984
3987
|
}
|
|
3985
3988
|
}
|
|
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,
|
|
3989
|
+
function runClientMiddlewarePipeline(args, handler) {
|
|
3990
|
+
return runMiddlewarePipeline(
|
|
3991
|
+
args,
|
|
3994
3992
|
handler,
|
|
3993
|
+
(r) => r,
|
|
3994
|
+
// No post-processing needed on the client
|
|
3995
|
+
isDataStrategyResults,
|
|
3995
3996
|
errorHandler
|
|
3996
3997
|
);
|
|
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
|
|
3998
|
+
function errorHandler(error, routeId, nextResult) {
|
|
3999
|
+
if (nextResult) {
|
|
4000
|
+
return Promise.resolve(
|
|
4001
|
+
Object.assign(nextResult.value, {
|
|
4002
|
+
[routeId]: { type: "error", result: error }
|
|
4003
|
+
})
|
|
4032
4004
|
);
|
|
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
4005
|
} else {
|
|
4060
|
-
|
|
4061
|
-
|
|
4006
|
+
let { matches } = args;
|
|
4007
|
+
let maxBoundaryIdx = Math.min(
|
|
4008
|
+
// Throwing route
|
|
4009
|
+
matches.findIndex((m) => m.route.id === routeId) || 0,
|
|
4010
|
+
// or the shallowest route that needs to load data
|
|
4011
|
+
matches.findIndex((m) => m.unstable_shouldCallHandler()) || 0
|
|
4012
|
+
);
|
|
4013
|
+
let boundaryRouteId = findNearestBoundary(
|
|
4014
|
+
matches,
|
|
4015
|
+
matches[maxBoundaryIdx].route.id
|
|
4016
|
+
).route.id;
|
|
4017
|
+
return Promise.resolve({
|
|
4018
|
+
[boundaryRouteId]: { type: "error", result: error }
|
|
4019
|
+
});
|
|
4062
4020
|
}
|
|
4063
|
-
} catch (e) {
|
|
4064
|
-
let response = await errorHandler(e, routeId);
|
|
4065
|
-
return response;
|
|
4066
4021
|
}
|
|
4067
4022
|
}
|
|
4068
|
-
async function
|
|
4023
|
+
async function runMiddlewarePipeline(args, handler, processResult, isResult, errorHandler) {
|
|
4069
4024
|
let { matches, request, params, context } = args;
|
|
4070
4025
|
let tuples = matches.flatMap(
|
|
4071
4026
|
(m) => m.route.unstable_middleware ? m.route.unstable_middleware.map((fn) => [m.route.id, fn]) : []
|
|
4072
4027
|
);
|
|
4073
|
-
let
|
|
4074
|
-
await callClientRouteMiddleware(
|
|
4028
|
+
let result = await callRouteMiddleware(
|
|
4075
4029
|
{ request, params, context },
|
|
4076
4030
|
tuples,
|
|
4077
4031
|
handler,
|
|
4078
|
-
|
|
4079
|
-
|
|
4032
|
+
processResult,
|
|
4033
|
+
isResult,
|
|
4034
|
+
errorHandler
|
|
4080
4035
|
);
|
|
4081
|
-
return
|
|
4036
|
+
return result;
|
|
4082
4037
|
}
|
|
4083
|
-
async function
|
|
4038
|
+
async function callRouteMiddleware(args, middlewares, handler, processResult, isResult, errorHandler, idx = 0) {
|
|
4084
4039
|
let { request } = args;
|
|
4085
4040
|
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
|
-
);
|
|
4041
|
+
throw request.signal.reason ?? new Error(`Request aborted: ${request.method} ${request.url}`);
|
|
4092
4042
|
}
|
|
4093
4043
|
let tuple = middlewares[idx];
|
|
4094
4044
|
if (!tuple) {
|
|
4095
4045
|
let result = await handler();
|
|
4096
|
-
|
|
4097
|
-
return;
|
|
4046
|
+
return result;
|
|
4098
4047
|
}
|
|
4099
4048
|
let [routeId, middleware] = tuple;
|
|
4100
|
-
let
|
|
4049
|
+
let nextResult;
|
|
4101
4050
|
let next = async () => {
|
|
4102
|
-
if (
|
|
4051
|
+
if (nextResult) {
|
|
4103
4052
|
throw new Error("You may only call `next()` once per middleware");
|
|
4104
4053
|
}
|
|
4105
|
-
nextCalled = true;
|
|
4106
4054
|
try {
|
|
4107
|
-
let result = await
|
|
4055
|
+
let result = await callRouteMiddleware(
|
|
4108
4056
|
args,
|
|
4109
4057
|
middlewares,
|
|
4110
4058
|
handler,
|
|
4059
|
+
processResult,
|
|
4060
|
+
isResult,
|
|
4111
4061
|
errorHandler,
|
|
4112
|
-
handlerResult,
|
|
4113
4062
|
idx + 1
|
|
4114
4063
|
);
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4064
|
+
nextResult = { value: result };
|
|
4065
|
+
return nextResult.value;
|
|
4066
|
+
} catch (error) {
|
|
4067
|
+
nextResult = { value: await errorHandler(error, routeId, nextResult) };
|
|
4068
|
+
return nextResult.value;
|
|
4119
4069
|
}
|
|
4120
4070
|
};
|
|
4121
4071
|
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();
|
|
4072
|
+
let value = await middleware(args, next);
|
|
4073
|
+
let result = value != null ? processResult(value) : void 0;
|
|
4074
|
+
if (isResult(result)) {
|
|
4075
|
+
return result;
|
|
4076
|
+
} else if (nextResult) {
|
|
4077
|
+
return result ?? nextResult.value;
|
|
4078
|
+
} else {
|
|
4079
|
+
nextResult = { value: await next() };
|
|
4080
|
+
return nextResult.value;
|
|
4138
4081
|
}
|
|
4139
4082
|
} catch (error) {
|
|
4140
|
-
let
|
|
4141
|
-
|
|
4083
|
+
let response = await errorHandler(error, routeId, nextResult);
|
|
4084
|
+
return response;
|
|
4142
4085
|
}
|
|
4143
4086
|
}
|
|
4144
4087
|
function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request, match, lazyRoutePropertiesToSkip) {
|
|
@@ -4249,28 +4192,17 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4249
4192
|
);
|
|
4250
4193
|
} : (cb) => {
|
|
4251
4194
|
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
|
-
);
|
|
4195
|
+
return runClientMiddlewarePipeline(typedDataStrategyArgs, () => {
|
|
4196
|
+
return cb({
|
|
4197
|
+
...typedDataStrategyArgs,
|
|
4198
|
+
fetcherKey,
|
|
4199
|
+
unstable_runClientMiddleware: () => {
|
|
4200
|
+
throw new Error(
|
|
4201
|
+
"Cannot call `unstable_runClientMiddleware()` from within an `unstable_runClientMiddleware` handler"
|
|
4202
|
+
);
|
|
4203
|
+
}
|
|
4204
|
+
});
|
|
4205
|
+
});
|
|
4274
4206
|
};
|
|
4275
4207
|
let results = await dataStrategyImpl({
|
|
4276
4208
|
...dataStrategyArgs,
|
|
@@ -4738,6 +4670,11 @@ function dataWithResponseInitToErrorResponse(data2) {
|
|
|
4738
4670
|
data2.data
|
|
4739
4671
|
);
|
|
4740
4672
|
}
|
|
4673
|
+
function isDataStrategyResults(result) {
|
|
4674
|
+
return result != null && typeof result === "object" && Object.entries(result).every(
|
|
4675
|
+
([key, value]) => typeof key === "string" && isDataStrategyResult(value)
|
|
4676
|
+
);
|
|
4677
|
+
}
|
|
4741
4678
|
function isDataStrategyResult(result) {
|
|
4742
4679
|
return result != null && typeof result === "object" && "type" in result && "result" in result && (result.type === "data" /* data */ || result.type === "error" /* error */);
|
|
4743
4680
|
}
|
|
@@ -5145,7 +5082,7 @@ function useResolvedPath(to, { relative } = {}) {
|
|
|
5145
5082
|
function useRoutes(routes, locationArg) {
|
|
5146
5083
|
return useRoutesImpl(routes, locationArg);
|
|
5147
5084
|
}
|
|
5148
|
-
function useRoutesImpl(routes, locationArg, dataRouterState, future) {
|
|
5085
|
+
function useRoutesImpl(routes, locationArg, dataRouterState, unstable_onError, future) {
|
|
5149
5086
|
invariant(
|
|
5150
5087
|
useInRouterContext(),
|
|
5151
5088
|
// TODO: This error is probably because they somehow have 2 versions of the
|
|
@@ -5217,6 +5154,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
5217
5154
|
),
|
|
5218
5155
|
parentMatches,
|
|
5219
5156
|
dataRouterState,
|
|
5157
|
+
unstable_onError,
|
|
5220
5158
|
future
|
|
5221
5159
|
);
|
|
5222
5160
|
if (locationArg && renderedMatches) {
|
|
@@ -5285,11 +5223,14 @@ var RenderErrorBoundary = class extends React2.Component {
|
|
|
5285
5223
|
};
|
|
5286
5224
|
}
|
|
5287
5225
|
componentDidCatch(error, errorInfo) {
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5226
|
+
if (this.props.unstable_onError) {
|
|
5227
|
+
this.props.unstable_onError(error, errorInfo);
|
|
5228
|
+
} else {
|
|
5229
|
+
console.error(
|
|
5230
|
+
"React Router caught the following error during render",
|
|
5231
|
+
error
|
|
5232
|
+
);
|
|
5233
|
+
}
|
|
5293
5234
|
}
|
|
5294
5235
|
render() {
|
|
5295
5236
|
return this.state.error !== void 0 ? /* @__PURE__ */ React2.createElement(RouteContext.Provider, { value: this.props.routeContext }, /* @__PURE__ */ React2.createElement(
|
|
@@ -5308,7 +5249,7 @@ function RenderedRoute({ routeContext, match, children }) {
|
|
|
5308
5249
|
}
|
|
5309
5250
|
return /* @__PURE__ */ React2.createElement(RouteContext.Provider, { value: routeContext }, children);
|
|
5310
5251
|
}
|
|
5311
|
-
function _renderMatches(matches, parentMatches = [], dataRouterState = null, future = null) {
|
|
5252
|
+
function _renderMatches(matches, parentMatches = [], dataRouterState = null, unstable_onError = null, future = null) {
|
|
5312
5253
|
if (matches == null) {
|
|
5313
5254
|
if (!dataRouterState) {
|
|
5314
5255
|
return null;
|
|
@@ -5420,7 +5361,8 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, fut
|
|
|
5420
5361
|
component: errorElement,
|
|
5421
5362
|
error,
|
|
5422
5363
|
children: getChildren(),
|
|
5423
|
-
routeContext: { outlet: null, matches: matches2, isDataRoute: true }
|
|
5364
|
+
routeContext: { outlet: null, matches: matches2, isDataRoute: true },
|
|
5365
|
+
unstable_onError
|
|
5424
5366
|
}
|
|
5425
5367
|
) : getChildren();
|
|
5426
5368
|
},
|
|
@@ -5686,7 +5628,8 @@ var Deferred = class {
|
|
|
5686
5628
|
};
|
|
5687
5629
|
function RouterProvider({
|
|
5688
5630
|
router,
|
|
5689
|
-
flushSync: reactDomFlushSyncImpl
|
|
5631
|
+
flushSync: reactDomFlushSyncImpl,
|
|
5632
|
+
unstable_onError
|
|
5690
5633
|
}) {
|
|
5691
5634
|
let [state, setStateImpl] = React3.useState(router.state);
|
|
5692
5635
|
let [pendingState, setPendingState] = React3.useState();
|
|
@@ -5697,6 +5640,21 @@ function RouterProvider({
|
|
|
5697
5640
|
let [transition, setTransition] = React3.useState();
|
|
5698
5641
|
let [interruption, setInterruption] = React3.useState();
|
|
5699
5642
|
let fetcherData = React3.useRef(/* @__PURE__ */ new Map());
|
|
5643
|
+
let logErrorsAndSetState = React3.useCallback(
|
|
5644
|
+
(newState) => {
|
|
5645
|
+
setStateImpl((prevState) => {
|
|
5646
|
+
if (newState.errors && unstable_onError) {
|
|
5647
|
+
Object.entries(newState.errors).forEach(([routeId, error]) => {
|
|
5648
|
+
if (prevState.errors?.[routeId] !== error) {
|
|
5649
|
+
unstable_onError(error);
|
|
5650
|
+
}
|
|
5651
|
+
});
|
|
5652
|
+
}
|
|
5653
|
+
return newState;
|
|
5654
|
+
});
|
|
5655
|
+
},
|
|
5656
|
+
[unstable_onError]
|
|
5657
|
+
);
|
|
5700
5658
|
let setState = React3.useCallback(
|
|
5701
5659
|
(newState, { deletedFetchers, flushSync, viewTransitionOpts }) => {
|
|
5702
5660
|
newState.fetchers.forEach((fetcher, key) => {
|
|
@@ -5716,9 +5674,9 @@ function RouterProvider({
|
|
|
5716
5674
|
);
|
|
5717
5675
|
if (!viewTransitionOpts || !isViewTransitionAvailable) {
|
|
5718
5676
|
if (reactDomFlushSyncImpl && flushSync) {
|
|
5719
|
-
reactDomFlushSyncImpl(() =>
|
|
5677
|
+
reactDomFlushSyncImpl(() => logErrorsAndSetState(newState));
|
|
5720
5678
|
} else {
|
|
5721
|
-
React3.startTransition(() =>
|
|
5679
|
+
React3.startTransition(() => logErrorsAndSetState(newState));
|
|
5722
5680
|
}
|
|
5723
5681
|
return;
|
|
5724
5682
|
}
|
|
@@ -5736,7 +5694,7 @@ function RouterProvider({
|
|
|
5736
5694
|
});
|
|
5737
5695
|
});
|
|
5738
5696
|
let t = router.window.document.startViewTransition(() => {
|
|
5739
|
-
reactDomFlushSyncImpl(() =>
|
|
5697
|
+
reactDomFlushSyncImpl(() => logErrorsAndSetState(newState));
|
|
5740
5698
|
});
|
|
5741
5699
|
t.finished.finally(() => {
|
|
5742
5700
|
reactDomFlushSyncImpl(() => {
|
|
@@ -5767,7 +5725,13 @@ function RouterProvider({
|
|
|
5767
5725
|
});
|
|
5768
5726
|
}
|
|
5769
5727
|
},
|
|
5770
|
-
[
|
|
5728
|
+
[
|
|
5729
|
+
router.window,
|
|
5730
|
+
reactDomFlushSyncImpl,
|
|
5731
|
+
transition,
|
|
5732
|
+
renderDfd,
|
|
5733
|
+
logErrorsAndSetState
|
|
5734
|
+
]
|
|
5771
5735
|
);
|
|
5772
5736
|
React3.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
|
|
5773
5737
|
React3.useEffect(() => {
|
|
@@ -5780,7 +5744,7 @@ function RouterProvider({
|
|
|
5780
5744
|
let newState = pendingState;
|
|
5781
5745
|
let renderPromise = renderDfd.promise;
|
|
5782
5746
|
let transition2 = router.window.document.startViewTransition(async () => {
|
|
5783
|
-
React3.startTransition(() =>
|
|
5747
|
+
React3.startTransition(() => logErrorsAndSetState(newState));
|
|
5784
5748
|
await renderPromise;
|
|
5785
5749
|
});
|
|
5786
5750
|
transition2.finished.finally(() => {
|
|
@@ -5791,7 +5755,7 @@ function RouterProvider({
|
|
|
5791
5755
|
});
|
|
5792
5756
|
setTransition(transition2);
|
|
5793
5757
|
}
|
|
5794
|
-
}, [pendingState, renderDfd, router.window]);
|
|
5758
|
+
}, [pendingState, renderDfd, router.window, logErrorsAndSetState]);
|
|
5795
5759
|
React3.useEffect(() => {
|
|
5796
5760
|
if (renderDfd && pendingState && state.location.key === pendingState.location.key) {
|
|
5797
5761
|
renderDfd.resolve();
|
|
@@ -5831,9 +5795,10 @@ function RouterProvider({
|
|
|
5831
5795
|
router,
|
|
5832
5796
|
navigator,
|
|
5833
5797
|
static: false,
|
|
5834
|
-
basename
|
|
5798
|
+
basename,
|
|
5799
|
+
unstable_onError
|
|
5835
5800
|
}),
|
|
5836
|
-
[router, navigator, basename]
|
|
5801
|
+
[router, navigator, basename, unstable_onError]
|
|
5837
5802
|
);
|
|
5838
5803
|
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React3.createElement(DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React3.createElement(FetchersContext.Provider, { value: fetcherData.current }, /* @__PURE__ */ React3.createElement(ViewTransitionContext.Provider, { value: vtContext }, /* @__PURE__ */ React3.createElement(
|
|
5839
5804
|
Router,
|
|
@@ -5848,7 +5813,8 @@ function RouterProvider({
|
|
|
5848
5813
|
{
|
|
5849
5814
|
routes: router.routes,
|
|
5850
5815
|
future: router.future,
|
|
5851
|
-
state
|
|
5816
|
+
state,
|
|
5817
|
+
unstable_onError
|
|
5852
5818
|
}
|
|
5853
5819
|
)
|
|
5854
5820
|
))))), null);
|
|
@@ -5857,9 +5823,10 @@ var MemoizedDataRoutes = React3.memo(DataRoutes);
|
|
|
5857
5823
|
function DataRoutes({
|
|
5858
5824
|
routes,
|
|
5859
5825
|
future,
|
|
5860
|
-
state
|
|
5826
|
+
state,
|
|
5827
|
+
unstable_onError
|
|
5861
5828
|
}) {
|
|
5862
|
-
return useRoutesImpl(routes, void 0, state, future);
|
|
5829
|
+
return useRoutesImpl(routes, void 0, state, unstable_onError, future);
|
|
5863
5830
|
}
|
|
5864
5831
|
function MemoryRouter({
|
|
5865
5832
|
basename,
|
|
@@ -6007,7 +5974,16 @@ function Await({
|
|
|
6007
5974
|
errorElement,
|
|
6008
5975
|
resolve
|
|
6009
5976
|
}) {
|
|
6010
|
-
|
|
5977
|
+
let dataRouterContext = React3.useContext(DataRouterContext);
|
|
5978
|
+
return /* @__PURE__ */ React3.createElement(
|
|
5979
|
+
AwaitErrorBoundary,
|
|
5980
|
+
{
|
|
5981
|
+
resolve,
|
|
5982
|
+
errorElement,
|
|
5983
|
+
unstable_onError: dataRouterContext?.unstable_onError
|
|
5984
|
+
},
|
|
5985
|
+
/* @__PURE__ */ React3.createElement(ResolveAwait, null, children)
|
|
5986
|
+
);
|
|
6011
5987
|
}
|
|
6012
5988
|
var AwaitErrorBoundary = class extends React3.Component {
|
|
6013
5989
|
constructor(props) {
|
|
@@ -6018,11 +5994,15 @@ var AwaitErrorBoundary = class extends React3.Component {
|
|
|
6018
5994
|
return { error };
|
|
6019
5995
|
}
|
|
6020
5996
|
componentDidCatch(error, errorInfo) {
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
5997
|
+
if (this.props.unstable_onError) {
|
|
5998
|
+
this.props.unstable_onError(error, errorInfo);
|
|
5999
|
+
} else {
|
|
6000
|
+
console.error(
|
|
6001
|
+
"<Await> caught the following error during render",
|
|
6002
|
+
error,
|
|
6003
|
+
errorInfo
|
|
6004
|
+
);
|
|
6005
|
+
}
|
|
6026
6006
|
}
|
|
6027
6007
|
render() {
|
|
6028
6008
|
let { children, errorElement, resolve } = this.props;
|
|
@@ -6048,7 +6028,10 @@ var AwaitErrorBoundary = class extends React3.Component {
|
|
|
6048
6028
|
Object.defineProperty(resolve, "_tracked", { get: () => true });
|
|
6049
6029
|
promise = resolve.then(
|
|
6050
6030
|
(data2) => Object.defineProperty(resolve, "_data", { get: () => data2 }),
|
|
6051
|
-
(error) =>
|
|
6031
|
+
(error) => {
|
|
6032
|
+
this.props.unstable_onError?.(error);
|
|
6033
|
+
Object.defineProperty(resolve, "_error", { get: () => error });
|
|
6034
|
+
}
|
|
6052
6035
|
);
|
|
6053
6036
|
}
|
|
6054
6037
|
if (status === 2 /* error */ && !errorElement) {
|
|
@@ -8986,7 +8969,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
8986
8969
|
try {
|
|
8987
8970
|
if (isBrowser) {
|
|
8988
8971
|
window.__reactRouterVersion = // @ts-expect-error
|
|
8989
|
-
"7.8.1";
|
|
8972
|
+
"7.8.2-pre.1";
|
|
8990
8973
|
}
|
|
8991
8974
|
} catch (e) {
|
|
8992
8975
|
}
|
|
@@ -9893,7 +9876,7 @@ function DataRoutes2({
|
|
|
9893
9876
|
future,
|
|
9894
9877
|
state
|
|
9895
9878
|
}) {
|
|
9896
|
-
return useRoutesImpl(routes, void 0, state, future);
|
|
9879
|
+
return useRoutesImpl(routes, void 0, state, void 0, future);
|
|
9897
9880
|
}
|
|
9898
9881
|
function serializeErrors(errors) {
|
|
9899
9882
|
if (!errors) return null;
|