react-router 0.0.0-experimental-3d7dcee → 0.0.0-experimental-7ed11be
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 +15 -2
- package/dist/development/{chunk-QMIAKNRH.mjs → chunk-2OYLVAZB.mjs} +2 -2
- package/dist/development/{chunk-S2WJDCRE.js → chunk-BELBAVMB.js} +193 -254
- package/dist/development/{chunk-WJ2QP6HN.mjs → chunk-MUVPFEOF.mjs} +154 -210
- package/dist/development/{chunk-LSB26UC6.js → chunk-X5OYM2ET.js} +137 -132
- package/dist/{production/context-DnZM5brG.d.mts → development/context-CRZ6DK7I.d.mts} +11 -1
- package/dist/development/dom-export.d.mts +1 -1
- package/dist/development/dom-export.js +3 -3
- package/dist/development/dom-export.mjs +3 -3
- package/dist/development/{index-react-server-client-zr5eNeut.d.ts → index-react-server-client-DM3R9ovf.d.ts} +39 -23
- package/dist/{production/index-react-server-client-9rHNv-U3.d.mts → development/index-react-server-client-DbUtZHNh.d.mts} +40 -24
- package/dist/development/index-react-server-client.d.mts +3 -3
- 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 +49 -2
- package/dist/development/index-react-server.d.ts +49 -2
- package/dist/development/index-react-server.js +72 -81
- package/dist/development/index-react-server.mjs +72 -82
- package/dist/development/index.d.mts +44 -6
- package/dist/development/index.d.ts +42 -4
- package/dist/development/index.js +102 -102
- package/dist/development/index.mjs +3 -3
- package/dist/development/lib/types/internal.d.mts +8 -5
- package/dist/development/lib/types/internal.d.ts +7 -4
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/{route-data-C24VEkoE.d.mts → route-data-gwXJPIqL.d.mts} +3 -3
- package/dist/development/{routeModules-FY5IBiA_.d.ts → routeModules-Dz64j-T-.d.ts} +12 -2
- package/dist/production/{chunk-OFC37UQM.mjs → chunk-7A6GBCQS.mjs} +2 -2
- package/dist/production/{chunk-7CWVKQLP.js → chunk-A4J35SEJ.js} +193 -254
- package/dist/production/{chunk-2BFZ6QQU.mjs → chunk-IC5TORKA.mjs} +154 -210
- package/dist/production/{chunk-NIW37A6Q.js → chunk-W6BB3ISI.js} +137 -132
- package/dist/{development/context-DnZM5brG.d.mts → production/context-CRZ6DK7I.d.mts} +11 -1
- package/dist/production/dom-export.d.mts +1 -1
- package/dist/production/dom-export.js +3 -3
- package/dist/production/dom-export.mjs +3 -3
- package/dist/production/{index-react-server-client-zr5eNeut.d.ts → index-react-server-client-DM3R9ovf.d.ts} +39 -23
- package/dist/{development/index-react-server-client-9rHNv-U3.d.mts → production/index-react-server-client-DbUtZHNh.d.mts} +40 -24
- package/dist/production/index-react-server-client.d.mts +3 -3
- 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 +49 -2
- package/dist/production/index-react-server.d.ts +49 -2
- package/dist/production/index-react-server.js +72 -81
- package/dist/production/index-react-server.mjs +72 -82
- package/dist/production/index.d.mts +44 -6
- package/dist/production/index.d.ts +42 -4
- package/dist/production/index.js +102 -102
- package/dist/production/index.mjs +3 -3
- package/dist/production/lib/types/internal.d.mts +8 -5
- package/dist/production/lib/types/internal.d.ts +7 -4
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/production/{route-data-C24VEkoE.d.mts → route-data-gwXJPIqL.d.mts} +3 -3
- package/dist/production/{routeModules-FY5IBiA_.d.ts → routeModules-Dz64j-T-.d.ts} +12 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-7ed11be
|
|
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,
|
|
@@ -2412,6 +2438,10 @@ function createRouter(init) {
|
|
|
2412
2438
|
}
|
|
2413
2439
|
return state.fetchers.get(key) || IDLE_FETCHER;
|
|
2414
2440
|
}
|
|
2441
|
+
function resetFetcher(key, opts) {
|
|
2442
|
+
abortFetcher(key, opts?.reason);
|
|
2443
|
+
updateFetcherState(key, getDoneFetcher(null));
|
|
2444
|
+
}
|
|
2415
2445
|
function deleteFetcher(key) {
|
|
2416
2446
|
let fetcher = state.fetchers.get(key);
|
|
2417
2447
|
if (fetchControllers.has(key) && !(fetcher && fetcher.state === "loading" && fetchReloadIds.has(key))) {
|
|
@@ -2434,10 +2464,10 @@ function createRouter(init) {
|
|
|
2434
2464
|
}
|
|
2435
2465
|
updateState({ fetchers: new Map(state.fetchers) });
|
|
2436
2466
|
}
|
|
2437
|
-
function abortFetcher(key) {
|
|
2467
|
+
function abortFetcher(key, reason) {
|
|
2438
2468
|
let controller = fetchControllers.get(key);
|
|
2439
2469
|
if (controller) {
|
|
2440
|
-
controller.abort();
|
|
2470
|
+
controller.abort(reason);
|
|
2441
2471
|
fetchControllers.delete(key);
|
|
2442
2472
|
}
|
|
2443
2473
|
}
|
|
@@ -2701,6 +2731,7 @@ function createRouter(init) {
|
|
|
2701
2731
|
createHref: (to) => init.history.createHref(to),
|
|
2702
2732
|
encodeLocation: (to) => init.history.encodeLocation(to),
|
|
2703
2733
|
getFetcher,
|
|
2734
|
+
resetFetcher,
|
|
2704
2735
|
deleteFetcher: queueFetcherForDeletion,
|
|
2705
2736
|
dispose,
|
|
2706
2737
|
getBlocker,
|
|
@@ -2823,9 +2854,23 @@ function createStaticHandler(routes, opts) {
|
|
|
2823
2854
|
return res;
|
|
2824
2855
|
},
|
|
2825
2856
|
async (error, routeId) => {
|
|
2826
|
-
if (
|
|
2857
|
+
if (isRedirectResponse(error)) {
|
|
2827
2858
|
return error;
|
|
2828
2859
|
}
|
|
2860
|
+
if (isResponse(error)) {
|
|
2861
|
+
try {
|
|
2862
|
+
error = new ErrorResponseImpl(
|
|
2863
|
+
error.status,
|
|
2864
|
+
error.statusText,
|
|
2865
|
+
await parseResponseBody(error)
|
|
2866
|
+
);
|
|
2867
|
+
} catch (e) {
|
|
2868
|
+
error = e;
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
if (isDataWithResponseInit(error)) {
|
|
2872
|
+
error = dataWithResponseInitToErrorResponse(error);
|
|
2873
|
+
}
|
|
2829
2874
|
if (renderedStaticContext) {
|
|
2830
2875
|
if (routeId in renderedStaticContext.loaderData) {
|
|
2831
2876
|
renderedStaticContext.loaderData[routeId] = void 0;
|
|
@@ -2951,8 +2996,8 @@ function createStaticHandler(routes, opts) {
|
|
|
2951
2996
|
return res;
|
|
2952
2997
|
},
|
|
2953
2998
|
(error) => {
|
|
2954
|
-
if (
|
|
2955
|
-
return Promise.resolve(
|
|
2999
|
+
if (isDataWithResponseInit(error)) {
|
|
3000
|
+
return Promise.resolve(dataWithResponseInitToResponse(error));
|
|
2956
3001
|
}
|
|
2957
3002
|
if (isResponse(error)) {
|
|
2958
3003
|
return Promise.resolve(error);
|
|
@@ -3281,8 +3326,12 @@ function createStaticHandler(routes, opts) {
|
|
|
3281
3326
|
basename
|
|
3282
3327
|
);
|
|
3283
3328
|
}
|
|
3284
|
-
if (
|
|
3285
|
-
|
|
3329
|
+
if (isRouteRequest) {
|
|
3330
|
+
if (isResponse(result.result)) {
|
|
3331
|
+
throw result;
|
|
3332
|
+
} else if (isDataWithResponseInit(result.result)) {
|
|
3333
|
+
throw dataWithResponseInitToResponse(result.result);
|
|
3334
|
+
}
|
|
3286
3335
|
}
|
|
3287
3336
|
dataResults[match.route.id] = await convertDataStrategyResultToDataResult(result);
|
|
3288
3337
|
})
|
|
@@ -3929,206 +3978,116 @@ async function defaultDataStrategyWithMiddleware(args) {
|
|
|
3929
3978
|
if (!args.matches.some((m) => m.route.unstable_middleware)) {
|
|
3930
3979
|
return defaultDataStrategy(args);
|
|
3931
3980
|
}
|
|
3932
|
-
|
|
3933
|
-
|
|
3981
|
+
return runClientMiddlewarePipeline(args, () => defaultDataStrategy(args));
|
|
3982
|
+
}
|
|
3983
|
+
function runServerMiddlewarePipeline(args, handler, errorHandler) {
|
|
3984
|
+
return runMiddlewarePipeline(
|
|
3934
3985
|
args,
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
(error, routeId) => clientMiddlewareErrorHandler(
|
|
3940
|
-
error,
|
|
3941
|
-
routeId,
|
|
3942
|
-
args.matches,
|
|
3943
|
-
didCallHandler
|
|
3944
|
-
)
|
|
3986
|
+
handler,
|
|
3987
|
+
processResult,
|
|
3988
|
+
isResponse,
|
|
3989
|
+
errorHandler
|
|
3945
3990
|
);
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
if (didCallHandler) {
|
|
3949
|
-
return {
|
|
3950
|
-
[routeId]: { type: "error", result: error }
|
|
3951
|
-
};
|
|
3952
|
-
} else {
|
|
3953
|
-
let maxBoundaryIdx = Math.min(
|
|
3954
|
-
// Throwing route
|
|
3955
|
-
matches.findIndex((m) => m.route.id === routeId) || 0,
|
|
3956
|
-
// or the shallowest route that needs to load data
|
|
3957
|
-
matches.findIndex((m) => m.unstable_shouldCallHandler()) || 0
|
|
3958
|
-
);
|
|
3959
|
-
let boundaryRouteId = findNearestBoundary(
|
|
3960
|
-
matches,
|
|
3961
|
-
matches[maxBoundaryIdx].route.id
|
|
3962
|
-
).route.id;
|
|
3963
|
-
return {
|
|
3964
|
-
[boundaryRouteId]: { type: "error", result: error }
|
|
3965
|
-
};
|
|
3991
|
+
function processResult(result) {
|
|
3992
|
+
return isDataWithResponseInit(result) ? dataWithResponseInitToResponse(result) : result;
|
|
3966
3993
|
}
|
|
3967
3994
|
}
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
(m) => m.route.unstable_middleware ? m.route.unstable_middleware.map((fn) => [m.route.id, fn]) : []
|
|
3972
|
-
);
|
|
3973
|
-
let result = await callServerRouteMiddleware(
|
|
3974
|
-
{ request, params, context },
|
|
3975
|
-
tuples,
|
|
3995
|
+
function runClientMiddlewarePipeline(args, handler) {
|
|
3996
|
+
return runMiddlewarePipeline(
|
|
3997
|
+
args,
|
|
3976
3998
|
handler,
|
|
3999
|
+
(r) => r,
|
|
4000
|
+
// No post-processing needed on the client
|
|
4001
|
+
isDataStrategyResults,
|
|
3977
4002
|
errorHandler
|
|
3978
4003
|
);
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
}
|
|
3984
|
-
|
|
3985
|
-
let { request } = args;
|
|
3986
|
-
if (request.signal.aborted) {
|
|
3987
|
-
if (request.signal.reason) {
|
|
3988
|
-
throw request.signal.reason;
|
|
3989
|
-
}
|
|
3990
|
-
throw new Error(
|
|
3991
|
-
`Request aborted without an \`AbortSignal.reason\`: ${request.method} ${request.url}`
|
|
3992
|
-
);
|
|
3993
|
-
}
|
|
3994
|
-
let tuple = middlewares[idx];
|
|
3995
|
-
if (!tuple) {
|
|
3996
|
-
let result = await handler();
|
|
3997
|
-
return result;
|
|
3998
|
-
}
|
|
3999
|
-
let [routeId, middleware] = tuple;
|
|
4000
|
-
let nextCalled = false;
|
|
4001
|
-
let nextResult = void 0;
|
|
4002
|
-
let next = async () => {
|
|
4003
|
-
if (nextCalled) {
|
|
4004
|
-
throw new Error("You may only call `next()` once per middleware");
|
|
4005
|
-
}
|
|
4006
|
-
nextCalled = true;
|
|
4007
|
-
try {
|
|
4008
|
-
let result = await callServerRouteMiddleware(
|
|
4009
|
-
args,
|
|
4010
|
-
middlewares,
|
|
4011
|
-
handler,
|
|
4012
|
-
errorHandler,
|
|
4013
|
-
idx + 1
|
|
4014
|
-
);
|
|
4015
|
-
if (isDataWithResponseInit(result)) {
|
|
4016
|
-
result = dataWithResponseInitToResponse(result);
|
|
4017
|
-
}
|
|
4018
|
-
nextResult = result;
|
|
4019
|
-
return nextResult;
|
|
4020
|
-
} catch (e) {
|
|
4021
|
-
nextResult = await errorHandler(
|
|
4022
|
-
// Convert thrown data() values to ErrorResponses
|
|
4023
|
-
isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
|
|
4024
|
-
routeId
|
|
4004
|
+
function errorHandler(error, routeId, nextResult) {
|
|
4005
|
+
if (nextResult) {
|
|
4006
|
+
return Promise.resolve(
|
|
4007
|
+
Object.assign(nextResult.value, {
|
|
4008
|
+
[routeId]: { type: "error", result: error }
|
|
4009
|
+
})
|
|
4025
4010
|
);
|
|
4026
|
-
return nextResult;
|
|
4027
|
-
}
|
|
4028
|
-
};
|
|
4029
|
-
try {
|
|
4030
|
-
let result = await middleware(
|
|
4031
|
-
{
|
|
4032
|
-
request: args.request,
|
|
4033
|
-
params: args.params,
|
|
4034
|
-
context: args.context
|
|
4035
|
-
},
|
|
4036
|
-
next
|
|
4037
|
-
);
|
|
4038
|
-
if (isDataWithResponseInit(result)) {
|
|
4039
|
-
result = dataWithResponseInitToResponse(result);
|
|
4040
|
-
}
|
|
4041
|
-
if (nextCalled) {
|
|
4042
|
-
return typeof result === "undefined" ? nextResult : result;
|
|
4043
|
-
} else if (isResponse(result)) {
|
|
4044
|
-
return result;
|
|
4045
4011
|
} else {
|
|
4046
|
-
|
|
4047
|
-
|
|
4012
|
+
let { matches } = args;
|
|
4013
|
+
let maxBoundaryIdx = Math.min(
|
|
4014
|
+
// Throwing route
|
|
4015
|
+
matches.findIndex((m) => m.route.id === routeId) || 0,
|
|
4016
|
+
// or the shallowest route that needs to load data
|
|
4017
|
+
matches.findIndex((m) => m.unstable_shouldCallHandler()) || 0
|
|
4018
|
+
);
|
|
4019
|
+
let boundaryRouteId = findNearestBoundary(
|
|
4020
|
+
matches,
|
|
4021
|
+
matches[maxBoundaryIdx].route.id
|
|
4022
|
+
).route.id;
|
|
4023
|
+
return Promise.resolve({
|
|
4024
|
+
[boundaryRouteId]: { type: "error", result: error }
|
|
4025
|
+
});
|
|
4048
4026
|
}
|
|
4049
|
-
} catch (e) {
|
|
4050
|
-
let response = await errorHandler(
|
|
4051
|
-
// Convert thrown data() values to ErrorResponses
|
|
4052
|
-
isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
|
|
4053
|
-
routeId
|
|
4054
|
-
);
|
|
4055
|
-
return response;
|
|
4056
4027
|
}
|
|
4057
4028
|
}
|
|
4058
|
-
async function
|
|
4029
|
+
async function runMiddlewarePipeline(args, handler, processResult, isResult, errorHandler) {
|
|
4059
4030
|
let { matches, request, params, context } = args;
|
|
4060
4031
|
let tuples = matches.flatMap(
|
|
4061
4032
|
(m) => m.route.unstable_middleware ? m.route.unstable_middleware.map((fn) => [m.route.id, fn]) : []
|
|
4062
4033
|
);
|
|
4063
|
-
let
|
|
4064
|
-
await callClientRouteMiddleware(
|
|
4034
|
+
let result = await callRouteMiddleware(
|
|
4065
4035
|
{ request, params, context },
|
|
4066
4036
|
tuples,
|
|
4067
4037
|
handler,
|
|
4068
|
-
|
|
4069
|
-
|
|
4038
|
+
processResult,
|
|
4039
|
+
isResult,
|
|
4040
|
+
errorHandler
|
|
4070
4041
|
);
|
|
4071
|
-
return
|
|
4042
|
+
return result;
|
|
4072
4043
|
}
|
|
4073
|
-
async function
|
|
4044
|
+
async function callRouteMiddleware(args, middlewares, handler, processResult, isResult, errorHandler, idx = 0) {
|
|
4074
4045
|
let { request } = args;
|
|
4075
4046
|
if (request.signal.aborted) {
|
|
4076
|
-
|
|
4077
|
-
throw request.signal.reason;
|
|
4078
|
-
}
|
|
4079
|
-
throw new Error(
|
|
4080
|
-
`Request aborted without an \`AbortSignal.reason\`: ${request.method} ${request.url}`
|
|
4081
|
-
);
|
|
4047
|
+
throw request.signal.reason ?? new Error(`Request aborted: ${request.method} ${request.url}`);
|
|
4082
4048
|
}
|
|
4083
4049
|
let tuple = middlewares[idx];
|
|
4084
4050
|
if (!tuple) {
|
|
4085
4051
|
let result = await handler();
|
|
4086
|
-
|
|
4087
|
-
return;
|
|
4052
|
+
return result;
|
|
4088
4053
|
}
|
|
4089
4054
|
let [routeId, middleware] = tuple;
|
|
4090
|
-
let
|
|
4055
|
+
let nextResult;
|
|
4091
4056
|
let next = async () => {
|
|
4092
|
-
if (
|
|
4057
|
+
if (nextResult) {
|
|
4093
4058
|
throw new Error("You may only call `next()` once per middleware");
|
|
4094
4059
|
}
|
|
4095
|
-
nextCalled = true;
|
|
4096
4060
|
try {
|
|
4097
|
-
let result = await
|
|
4061
|
+
let result = await callRouteMiddleware(
|
|
4098
4062
|
args,
|
|
4099
4063
|
middlewares,
|
|
4100
4064
|
handler,
|
|
4065
|
+
processResult,
|
|
4066
|
+
isResult,
|
|
4101
4067
|
errorHandler,
|
|
4102
|
-
handlerResult,
|
|
4103
4068
|
idx + 1
|
|
4104
4069
|
);
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4070
|
+
nextResult = { value: result };
|
|
4071
|
+
return nextResult.value;
|
|
4072
|
+
} catch (error) {
|
|
4073
|
+
nextResult = { value: await errorHandler(error, routeId, nextResult) };
|
|
4074
|
+
return nextResult.value;
|
|
4109
4075
|
}
|
|
4110
4076
|
};
|
|
4111
4077
|
try {
|
|
4112
|
-
let
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
console.warn(
|
|
4122
|
-
"client middlewares are not intended to return values, the value will be ignored",
|
|
4123
|
-
result
|
|
4124
|
-
);
|
|
4125
|
-
}
|
|
4126
|
-
if (!nextCalled) {
|
|
4127
|
-
await next();
|
|
4078
|
+
let value = await middleware(args, next);
|
|
4079
|
+
let result = value != null ? processResult(value) : void 0;
|
|
4080
|
+
if (isResult(result)) {
|
|
4081
|
+
return result;
|
|
4082
|
+
} else if (nextResult) {
|
|
4083
|
+
return result ?? nextResult.value;
|
|
4084
|
+
} else {
|
|
4085
|
+
nextResult = { value: await next() };
|
|
4086
|
+
return nextResult.value;
|
|
4128
4087
|
}
|
|
4129
4088
|
} catch (error) {
|
|
4130
|
-
let
|
|
4131
|
-
|
|
4089
|
+
let response = await errorHandler(error, routeId, nextResult);
|
|
4090
|
+
return response;
|
|
4132
4091
|
}
|
|
4133
4092
|
}
|
|
4134
4093
|
function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request, match, lazyRoutePropertiesToSkip) {
|
|
@@ -4239,28 +4198,17 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4239
4198
|
);
|
|
4240
4199
|
} : (cb) => {
|
|
4241
4200
|
let typedDataStrategyArgs = dataStrategyArgs;
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
);
|
|
4254
|
-
}
|
|
4255
|
-
});
|
|
4256
|
-
},
|
|
4257
|
-
(error, routeId) => clientMiddlewareErrorHandler(
|
|
4258
|
-
error,
|
|
4259
|
-
routeId,
|
|
4260
|
-
matches,
|
|
4261
|
-
didCallHandler
|
|
4262
|
-
)
|
|
4263
|
-
);
|
|
4201
|
+
return runClientMiddlewarePipeline(typedDataStrategyArgs, () => {
|
|
4202
|
+
return cb({
|
|
4203
|
+
...typedDataStrategyArgs,
|
|
4204
|
+
fetcherKey,
|
|
4205
|
+
unstable_runClientMiddleware: () => {
|
|
4206
|
+
throw new Error(
|
|
4207
|
+
"Cannot call `unstable_runClientMiddleware()` from within an `unstable_runClientMiddleware` handler"
|
|
4208
|
+
);
|
|
4209
|
+
}
|
|
4210
|
+
});
|
|
4211
|
+
});
|
|
4264
4212
|
};
|
|
4265
4213
|
let results = await dataStrategyImpl({
|
|
4266
4214
|
...dataStrategyArgs,
|
|
@@ -4377,21 +4325,19 @@ async function callLoaderOrAction({
|
|
|
4377
4325
|
}
|
|
4378
4326
|
return result;
|
|
4379
4327
|
}
|
|
4328
|
+
async function parseResponseBody(response) {
|
|
4329
|
+
let contentType = response.headers.get("Content-Type");
|
|
4330
|
+
if (contentType && /\bapplication\/json\b/.test(contentType)) {
|
|
4331
|
+
return response.body == null ? null : response.json();
|
|
4332
|
+
}
|
|
4333
|
+
return response.text();
|
|
4334
|
+
}
|
|
4380
4335
|
async function convertDataStrategyResultToDataResult(dataStrategyResult) {
|
|
4381
4336
|
let { result, type } = dataStrategyResult;
|
|
4382
4337
|
if (isResponse(result)) {
|
|
4383
4338
|
let data2;
|
|
4384
4339
|
try {
|
|
4385
|
-
|
|
4386
|
-
if (contentType && /\bapplication\/json\b/.test(contentType)) {
|
|
4387
|
-
if (result.body == null) {
|
|
4388
|
-
data2 = null;
|
|
4389
|
-
} else {
|
|
4390
|
-
data2 = await result.json();
|
|
4391
|
-
}
|
|
4392
|
-
} else {
|
|
4393
|
-
data2 = await result.text();
|
|
4394
|
-
}
|
|
4340
|
+
data2 = await parseResponseBody(result);
|
|
4395
4341
|
} catch (e) {
|
|
4396
4342
|
return { type: "error" /* error */, error: e };
|
|
4397
4343
|
}
|
|
@@ -4721,10 +4667,7 @@ function isHashChangeOnly(a, b) {
|
|
|
4721
4667
|
return false;
|
|
4722
4668
|
}
|
|
4723
4669
|
function dataWithResponseInitToResponse(data2) {
|
|
4724
|
-
return
|
|
4725
|
-
typeof data2.data === "string" ? data2.data : JSON.stringify(data2.data),
|
|
4726
|
-
data2.init || void 0
|
|
4727
|
-
);
|
|
4670
|
+
return Response.json(data2.data, data2.init ?? void 0);
|
|
4728
4671
|
}
|
|
4729
4672
|
function dataWithResponseInitToErrorResponse(data2) {
|
|
4730
4673
|
return new ErrorResponseImpl(
|
|
@@ -4733,13 +4676,9 @@ function dataWithResponseInitToErrorResponse(data2) {
|
|
|
4733
4676
|
data2.data
|
|
4734
4677
|
);
|
|
4735
4678
|
}
|
|
4736
|
-
function
|
|
4737
|
-
return
|
|
4738
|
-
typeof
|
|
4739
|
-
{
|
|
4740
|
-
status: error.status,
|
|
4741
|
-
statusText: error.statusText
|
|
4742
|
-
}
|
|
4679
|
+
function isDataStrategyResults(result) {
|
|
4680
|
+
return result != null && typeof result === "object" && Object.entries(result).every(
|
|
4681
|
+
([key, value]) => typeof key === "string" && isDataStrategyResult(value)
|
|
4743
4682
|
);
|
|
4744
4683
|
}
|
|
4745
4684
|
function isDataStrategyResult(result) {
|
|
@@ -9036,7 +8975,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
9036
8975
|
try {
|
|
9037
8976
|
if (isBrowser) {
|
|
9038
8977
|
window.__reactRouterVersion = // @ts-expect-error
|
|
9039
|
-
"0.0.0-experimental-
|
|
8978
|
+
"0.0.0-experimental-7ed11be";
|
|
9040
8979
|
}
|
|
9041
8980
|
} catch (e) {
|
|
9042
8981
|
}
|
|
@@ -9650,6 +9589,7 @@ function useFetcher({
|
|
|
9650
9589
|
},
|
|
9651
9590
|
[fetcherKey, submitImpl]
|
|
9652
9591
|
);
|
|
9592
|
+
let unstable_reset = React10.useCallback((opts) => router.resetFetcher(fetcherKey, opts), [router, fetcherKey]);
|
|
9653
9593
|
let FetcherForm = React10.useMemo(() => {
|
|
9654
9594
|
let FetcherForm2 = React10.forwardRef(
|
|
9655
9595
|
(props, ref) => {
|
|
@@ -9666,10 +9606,11 @@ function useFetcher({
|
|
|
9666
9606
|
Form: FetcherForm,
|
|
9667
9607
|
submit,
|
|
9668
9608
|
load,
|
|
9609
|
+
unstable_reset,
|
|
9669
9610
|
...fetcher,
|
|
9670
9611
|
data: data2
|
|
9671
9612
|
}),
|
|
9672
|
-
[FetcherForm, submit, load, fetcher, data2]
|
|
9613
|
+
[FetcherForm, submit, load, unstable_reset, fetcher, data2]
|
|
9673
9614
|
);
|
|
9674
9615
|
return fetcherWithComponents;
|
|
9675
9616
|
}
|
|
@@ -10080,6 +10021,9 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
10080
10021
|
deleteFetcher() {
|
|
10081
10022
|
throw msg("deleteFetcher");
|
|
10082
10023
|
},
|
|
10024
|
+
resetFetcher() {
|
|
10025
|
+
throw msg("resetFetcher");
|
|
10026
|
+
},
|
|
10083
10027
|
dispose() {
|
|
10084
10028
|
throw msg("dispose");
|
|
10085
10029
|
},
|