react-router 8.5.1 → 8.5.3
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 +79 -3
- package/dist/development/dom-export.js +1 -1
- package/dist/development/index-react-server-client.js +1 -1
- package/dist/development/index-react-server.d.ts +46 -39
- package/dist/development/index-react-server.js +104 -41
- package/dist/development/index.js +1 -1
- package/dist/development/lib/actions.js +1 -1
- package/dist/development/lib/await.js +1 -1
- package/dist/development/lib/components.d.ts +42 -38
- package/dist/development/lib/components.js +34 -36
- package/dist/development/lib/context.js +3 -2
- package/dist/development/lib/dom/dom.js +16 -5
- package/dist/development/lib/dom/lib.d.ts +2 -2
- package/dist/development/lib/dom/lib.js +22 -8
- package/dist/development/lib/dom/server.js +5 -3
- package/dist/development/lib/dom/ssr/components.js +4 -1
- package/dist/development/lib/dom/ssr/data.js +1 -1
- package/dist/development/lib/dom/ssr/errorBoundaries.js +2 -1
- package/dist/development/lib/dom/ssr/fallback.js +2 -1
- package/dist/development/lib/dom/ssr/fog-of-war.js +1 -1
- package/dist/development/lib/dom/ssr/hydration.d.ts +1 -0
- package/dist/development/lib/dom/ssr/hydration.js +1 -1
- package/dist/development/lib/dom/ssr/invariant.js +1 -1
- package/dist/development/lib/dom/ssr/links.js +1 -1
- package/dist/development/lib/dom/ssr/markup.js +1 -1
- package/dist/development/lib/dom/ssr/route-discovery.js +1 -1
- package/dist/development/lib/dom/ssr/routeModules.js +1 -1
- package/dist/development/lib/dom/ssr/routes-test-stub.js +3 -1
- package/dist/development/lib/dom/ssr/routes.js +2 -1
- package/dist/development/lib/dom/ssr/server.js +1 -1
- package/dist/development/lib/dom/ssr/single-fetch.js +1 -1
- package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/development/lib/dom-export/hydrated-router.d.ts +1 -1
- package/dist/development/lib/dom-export/hydrated-router.js +4 -2
- package/dist/development/lib/errors.js +1 -1
- package/dist/development/lib/hooks.d.ts +30 -0
- package/dist/development/lib/hooks.js +46 -7
- package/dist/development/lib/href.js +4 -4
- package/dist/development/lib/router/history.js +10 -4
- package/dist/development/lib/router/instrumentation.js +1 -1
- package/dist/development/lib/router/matcher-route-pattern.js +1 -1
- package/dist/development/lib/router/matcher-route-pattern.preload.js +1 -1
- package/dist/development/lib/router/matcher.js +1 -1
- package/dist/development/lib/router/navigation.js +17 -2
- package/dist/development/lib/router/router.js +26 -9
- package/dist/development/lib/router/url.js +1 -1
- package/dist/development/lib/router/utils.d.ts +8 -5
- package/dist/development/lib/router/utils.js +24 -9
- package/dist/development/lib/rsc/browser.js +27 -4
- package/dist/development/lib/rsc/errorBoundaries.js +3 -2
- package/dist/development/lib/rsc/html-stream/browser.js +1 -1
- package/dist/development/lib/rsc/html-stream/server.js +1 -1
- package/dist/development/lib/rsc/route-modules.js +1 -1
- package/dist/development/lib/rsc/server.rsc.d.ts +4 -1
- package/dist/development/lib/rsc/server.ssr.d.ts +1 -0
- package/dist/development/lib/rsc/server.ssr.js +5 -4
- package/dist/development/lib/server-runtime/cookies.js +1 -1
- package/dist/development/lib/server-runtime/crypto.js +1 -1
- package/dist/development/lib/server-runtime/data.js +1 -1
- package/dist/development/lib/server-runtime/dev.js +1 -1
- package/dist/development/lib/server-runtime/entry.js +1 -1
- package/dist/development/lib/server-runtime/errors.js +1 -1
- package/dist/development/lib/server-runtime/headers.js +1 -1
- package/dist/development/lib/server-runtime/invariant.js +1 -1
- package/dist/development/lib/server-runtime/mode.js +1 -1
- package/dist/development/lib/server-runtime/routeMatching.js +1 -1
- package/dist/development/lib/server-runtime/routes.js +1 -1
- package/dist/development/lib/server-runtime/server.js +9 -6
- package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/development/lib/server-runtime/sessions/cookieStorage.js +3 -2
- package/dist/development/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/development/lib/server-runtime/sessions.d.ts +1 -1
- package/dist/development/lib/server-runtime/sessions.js +5 -3
- package/dist/development/lib/server-runtime/single-fetch.js +1 -1
- package/dist/development/lib/server-runtime/urls.js +1 -1
- package/dist/development/lib/server-runtime/warnings.js +1 -1
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/route-module-annotations.d.ts +16 -9
- package/dist/development/route-pattern.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +83 -73
- package/dist/development/vendor/turbo-stream-v2/unflatten.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/utils.js +1 -1
- package/dist/production/dom-export.js +1 -1
- package/dist/production/index-react-server-client.js +1 -1
- package/dist/production/index-react-server.d.ts +46 -39
- package/dist/production/index-react-server.js +104 -41
- package/dist/production/index.js +1 -1
- package/dist/production/lib/actions.js +1 -1
- package/dist/production/lib/await.js +1 -1
- package/dist/production/lib/components.d.ts +42 -38
- package/dist/production/lib/components.js +34 -36
- package/dist/production/lib/context.js +3 -2
- package/dist/production/lib/dom/dom.js +16 -5
- package/dist/production/lib/dom/lib.d.ts +2 -2
- package/dist/production/lib/dom/lib.js +22 -8
- package/dist/production/lib/dom/server.js +5 -3
- package/dist/production/lib/dom/ssr/components.js +4 -1
- package/dist/production/lib/dom/ssr/data.js +1 -1
- package/dist/production/lib/dom/ssr/errorBoundaries.js +2 -1
- package/dist/production/lib/dom/ssr/fallback.js +1 -1
- package/dist/production/lib/dom/ssr/fog-of-war.js +1 -1
- package/dist/production/lib/dom/ssr/hydration.d.ts +1 -0
- package/dist/production/lib/dom/ssr/hydration.js +1 -1
- package/dist/production/lib/dom/ssr/invariant.js +1 -1
- package/dist/production/lib/dom/ssr/links.js +1 -1
- package/dist/production/lib/dom/ssr/markup.js +1 -1
- package/dist/production/lib/dom/ssr/route-discovery.js +1 -1
- package/dist/production/lib/dom/ssr/routeModules.js +1 -1
- package/dist/production/lib/dom/ssr/routes-test-stub.js +3 -1
- package/dist/production/lib/dom/ssr/routes.js +2 -1
- package/dist/production/lib/dom/ssr/server.js +1 -1
- package/dist/production/lib/dom/ssr/single-fetch.js +1 -1
- package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/production/lib/dom-export/hydrated-router.d.ts +1 -1
- package/dist/production/lib/dom-export/hydrated-router.js +4 -2
- package/dist/production/lib/errors.js +1 -1
- package/dist/production/lib/hooks.d.ts +30 -0
- package/dist/production/lib/hooks.js +45 -6
- package/dist/production/lib/href.js +4 -4
- package/dist/production/lib/router/history.js +10 -4
- package/dist/production/lib/router/instrumentation.js +1 -1
- package/dist/production/lib/router/matcher-route-pattern.js +1 -1
- package/dist/production/lib/router/matcher-route-pattern.preload.js +1 -1
- package/dist/production/lib/router/matcher.js +1 -1
- package/dist/production/lib/router/navigation.js +17 -2
- package/dist/production/lib/router/router.js +26 -9
- package/dist/production/lib/router/url.js +1 -1
- package/dist/production/lib/router/utils.d.ts +8 -5
- package/dist/production/lib/router/utils.js +24 -9
- package/dist/production/lib/rsc/browser.js +27 -4
- package/dist/production/lib/rsc/errorBoundaries.js +3 -2
- package/dist/production/lib/rsc/html-stream/browser.js +1 -1
- package/dist/production/lib/rsc/html-stream/server.js +1 -1
- package/dist/production/lib/rsc/route-modules.js +1 -1
- package/dist/production/lib/rsc/server.rsc.d.ts +4 -1
- package/dist/production/lib/rsc/server.ssr.d.ts +1 -0
- package/dist/production/lib/rsc/server.ssr.js +5 -4
- package/dist/production/lib/server-runtime/cookies.js +1 -1
- package/dist/production/lib/server-runtime/crypto.js +1 -1
- package/dist/production/lib/server-runtime/data.js +1 -1
- package/dist/production/lib/server-runtime/dev.js +1 -1
- package/dist/production/lib/server-runtime/entry.js +1 -1
- package/dist/production/lib/server-runtime/errors.js +1 -1
- package/dist/production/lib/server-runtime/headers.js +1 -1
- package/dist/production/lib/server-runtime/invariant.js +1 -1
- package/dist/production/lib/server-runtime/mode.js +1 -1
- package/dist/production/lib/server-runtime/routeMatching.js +1 -1
- package/dist/production/lib/server-runtime/routes.js +1 -1
- package/dist/production/lib/server-runtime/server.js +9 -6
- package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/production/lib/server-runtime/sessions/cookieStorage.js +3 -2
- package/dist/production/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/production/lib/server-runtime/sessions.d.ts +1 -1
- package/dist/production/lib/server-runtime/sessions.js +5 -3
- package/dist/production/lib/server-runtime/single-fetch.js +1 -1
- package/dist/production/lib/server-runtime/urls.js +1 -1
- package/dist/production/lib/server-runtime/warnings.js +1 -1
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/route-module-annotations.d.ts +16 -9
- package/dist/production/route-pattern.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +83 -73
- package/dist/production/vendor/turbo-stream-v2/unflatten.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
- package/docs/upgrading/v7.md +11 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.3
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -83,6 +83,46 @@ function parsePath(path) {
|
|
|
83
83
|
return parsedPath;
|
|
84
84
|
}
|
|
85
85
|
//#endregion
|
|
86
|
+
//#region lib/router/navigation.ts
|
|
87
|
+
const DEFAULT_NAVIGATION_URL = new URL("http://localhost");
|
|
88
|
+
function isSameOrigin(a, b) {
|
|
89
|
+
return a.origin === b.origin && (a.origin !== "null" || a.protocol === b.protocol && a.host === b.host);
|
|
90
|
+
}
|
|
91
|
+
function isExplicitUrl(destination, target) {
|
|
92
|
+
if (destination.startsWith("//")) return true;
|
|
93
|
+
let protocol = target.protocol.toLowerCase();
|
|
94
|
+
if (!destination.toLowerCase().startsWith(protocol)) return false;
|
|
95
|
+
return target.host === "" || destination.slice(protocol.length).startsWith("//");
|
|
96
|
+
}
|
|
97
|
+
function validateDocumentNavigationTarget(destination) {
|
|
98
|
+
let normalized = destination.replace(/[\t\n\r]/g, "");
|
|
99
|
+
let start = 0;
|
|
100
|
+
while (normalized.charCodeAt(start) <= 32) start++;
|
|
101
|
+
normalized = normalized.slice(start);
|
|
102
|
+
if (!ABSOLUTE_URL_REGEX.test(normalized)) return;
|
|
103
|
+
let target;
|
|
104
|
+
try {
|
|
105
|
+
target = new URL(destination, DEFAULT_NAVIGATION_URL);
|
|
106
|
+
} catch {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (!isExplicitUrl(destination, target)) throw new Error("External navigation is not allowed");
|
|
110
|
+
}
|
|
111
|
+
function validateNavigationTarget(original, resolved, currentUrl, externalPolicy) {
|
|
112
|
+
let originalUrl = null;
|
|
113
|
+
try {
|
|
114
|
+
originalUrl = original == null ? null : new URL(original, currentUrl);
|
|
115
|
+
} catch {}
|
|
116
|
+
let resolvedUrl = new URL(resolved, currentUrl);
|
|
117
|
+
let originalIsExternal = originalUrl != null && !isSameOrigin(originalUrl, currentUrl);
|
|
118
|
+
let resolvedIsExternal = !isSameOrigin(resolvedUrl, currentUrl);
|
|
119
|
+
if (externalPolicy === "reject") {
|
|
120
|
+
if (originalIsExternal || resolvedIsExternal) throw new Error("External navigation is not allowed");
|
|
121
|
+
} else if (resolvedIsExternal) {
|
|
122
|
+
if (originalUrl == null || !isExplicitUrl(original, originalUrl) || !isSameOrigin(originalUrl, resolvedUrl)) throw new Error("External navigation is not allowed");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
86
126
|
//#region lib/router/utils.ts
|
|
87
127
|
/**
|
|
88
128
|
* Creates a type-safe {@link RouterContext} object that can be used to
|
|
@@ -481,10 +521,13 @@ const PATH_PARAM_OVERESCAPED = {
|
|
|
481
521
|
function encodePathParam(value) {
|
|
482
522
|
return encodeURIComponent(value).replace(/%(?:24|26|2B|2C|3A|3B|3D|40)/g, (match) => PATH_PARAM_OVERESCAPED[match]);
|
|
483
523
|
}
|
|
524
|
+
const MAX_OPTIONAL_PATH_SEGMENTS = 12;
|
|
484
525
|
/**
|
|
485
526
|
* Performs pattern matching on a URL pathname and returns information about
|
|
486
527
|
* the match.
|
|
487
528
|
*
|
|
529
|
+
* Throws if the pattern contains more than 12 optional (`?`) markers.
|
|
530
|
+
*
|
|
488
531
|
* @public
|
|
489
532
|
* @category Utils
|
|
490
533
|
* @param pattern The pattern to match against the URL pathname. This can be a
|
|
@@ -501,7 +544,10 @@ function matchPath(pattern, pathname) {
|
|
|
501
544
|
caseSensitive: false,
|
|
502
545
|
end: true
|
|
503
546
|
};
|
|
504
|
-
let
|
|
547
|
+
let { path } = pattern;
|
|
548
|
+
let optionalSegments = 0;
|
|
549
|
+
for (let index = path.indexOf("?"); index !== -1; index = path.indexOf("?", index + 1)) if (++optionalSegments > MAX_OPTIONAL_PATH_SEGMENTS) throw new Error(`Path pattern ${JSON.stringify(path)} exceeds the limit of ${MAX_OPTIONAL_PATH_SEGMENTS} optional segments.`);
|
|
550
|
+
let [matcher, compiledParams] = compilePath(path, pattern.caseSensitive, pattern.end);
|
|
505
551
|
return matchPathImpl(pattern, pathname, matcher, compiledParams);
|
|
506
552
|
}
|
|
507
553
|
function matchPathImpl(pattern, pathname, matcher, compiledParams) {
|
|
@@ -721,11 +767,15 @@ function data(data, init) {
|
|
|
721
767
|
* header.
|
|
722
768
|
*/
|
|
723
769
|
const redirect$1 = (url, init = 302) => {
|
|
770
|
+
validateDocumentNavigationTarget(url);
|
|
724
771
|
let responseInit = init;
|
|
725
772
|
if (typeof responseInit === "number") responseInit = { status: responseInit };
|
|
726
|
-
else if (typeof responseInit.status === "undefined") responseInit.status = 302;
|
|
727
773
|
let headers = new Headers(responseInit.headers);
|
|
728
774
|
headers.set("Location", url);
|
|
775
|
+
if (typeof responseInit.status === "undefined") responseInit = {
|
|
776
|
+
...responseInit,
|
|
777
|
+
status: 302
|
|
778
|
+
};
|
|
729
779
|
return new Response(null, {
|
|
730
780
|
...responseInit,
|
|
731
781
|
headers
|
|
@@ -2009,6 +2059,7 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
|
|
|
2009
2059
|
function normalizeRelativeRoutingRedirectResponse(response, request, routeId, matches, basename) {
|
|
2010
2060
|
let location = response.headers.get("Location");
|
|
2011
2061
|
invariant$1(location, "Redirects returned/thrown from loaders/actions must have a Location header");
|
|
2062
|
+
validateNavigationTarget(location, location, new URL(request.url), "allow-explicit");
|
|
2012
2063
|
if (!isAbsoluteUrl(location)) {
|
|
2013
2064
|
let trimmedMatches = matches.slice(0, matches.findIndex((m) => m.route.id === routeId) + 1);
|
|
2014
2065
|
location = normalizeTo(new URL(request.url), trimmedMatches, basename, location);
|
|
@@ -2450,7 +2501,8 @@ const Await = (async (props) => {
|
|
|
2450
2501
|
* @param opts.clientVersion A version derived from the client build output used
|
|
2451
2502
|
* to detect stale clients during lazy route discovery.
|
|
2452
2503
|
* @param opts.onError An optional error handler that will be called with any
|
|
2453
|
-
* errors that occur during the request processing.
|
|
2504
|
+
* errors that occur during the request processing. Defaults to logging errors
|
|
2505
|
+
* with `console.error` unless the request was aborted.
|
|
2454
2506
|
* @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
2455
2507
|
* to match against.
|
|
2456
2508
|
* @param opts.requestContext An instance of {@link RouterContextProvider}
|
|
@@ -2469,6 +2521,9 @@ async function matchRSCServerRequest({ allowedActionOrigins, createTemporaryRefe
|
|
|
2469
2521
|
return response;
|
|
2470
2522
|
};
|
|
2471
2523
|
let url = new URL(request.url);
|
|
2524
|
+
onError ??= (error) => {
|
|
2525
|
+
if (!request.signal.aborted) console.error(isRouteErrorResponse(error) && error.error ? error.error : error);
|
|
2526
|
+
};
|
|
2472
2527
|
basename = basename || "/";
|
|
2473
2528
|
let normalizedPath = url.pathname;
|
|
2474
2529
|
if (url.pathname.endsWith("/_.rsc")) normalizedPath = url.pathname.replace(/_\.rsc$/, "");
|
|
@@ -2491,9 +2546,20 @@ async function matchRSCServerRequest({ allowedActionOrigins, createTemporaryRefe
|
|
|
2491
2546
|
let matches = staticHandler.match(url.pathname);
|
|
2492
2547
|
if (matches) await Promise.all(matches.map((m) => explodeLazyRoute(m.route)));
|
|
2493
2548
|
const leafMatch = matches?.[matches.length - 1];
|
|
2494
|
-
if (!isDataRequest && leafMatch && !leafMatch.route.Component && !leafMatch.route.ErrorBoundary) return generateResourceResponse(routerRequest, staticHandler, leafMatch.route.id, requestContext, onError);
|
|
2549
|
+
if (!isDataRequest && leafMatch && !leafMatch.route.Component && !leafMatch.route.ErrorBoundary) return normalizeResourceResponse(request, await generateResourceResponse(routerRequest, staticHandler, leafMatch.route.id, requestContext, onError));
|
|
2495
2550
|
let response = await generateRenderResponse(routerRequest, staticHandler, basename, isDataRequest, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, generateResponse, temporaryReferences, allowedActionOrigins, routeDiscovery, clientVersion);
|
|
2496
2551
|
response.headers.set("X-Remix-Response", "yes");
|
|
2552
|
+
return normalizeResourceResponse(request, response);
|
|
2553
|
+
}
|
|
2554
|
+
function normalizeResourceResponse(request, response) {
|
|
2555
|
+
if (request.method === "HEAD" && response.headers.get("React-Router-Resource") === "true") {
|
|
2556
|
+
response.body?.cancel().catch(() => {});
|
|
2557
|
+
return new Response(null, {
|
|
2558
|
+
status: response.status,
|
|
2559
|
+
statusText: response.statusText,
|
|
2560
|
+
headers: response.headers
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2497
2563
|
return response;
|
|
2498
2564
|
}
|
|
2499
2565
|
async function generateManifestResponse(routes, basename, request, generateResponse, temporaryReferences, routeDiscovery, clientVersion) {
|
|
@@ -2656,11 +2722,18 @@ function tagResourceResponse(response) {
|
|
|
2656
2722
|
});
|
|
2657
2723
|
}
|
|
2658
2724
|
async function generateRenderResponse(request, staticHandler, basename, isDataRequest, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, generateResponse, temporaryReferences, allowedActionOrigins, routeDiscovery, clientVersion) {
|
|
2725
|
+
if (isMutationMethod(request.method)) try {
|
|
2726
|
+
throwIfPotentialCSRFAttack(request, allowedActionOrigins);
|
|
2727
|
+
} catch (error) {
|
|
2728
|
+
onError?.(error);
|
|
2729
|
+
return tagResourceResponse(new Response("Bad Request", { status: 400 }));
|
|
2730
|
+
}
|
|
2659
2731
|
let statusCode = 200;
|
|
2660
2732
|
let url = new URL(request.url);
|
|
2661
2733
|
let isSubmission = isMutationMethod(request.method);
|
|
2662
2734
|
let routeIdsToLoad = !isSubmission && url.searchParams.has("_routes") ? url.searchParams.get("_routes").split(",") : null;
|
|
2663
2735
|
let actionResult;
|
|
2736
|
+
let handledSubmission = false;
|
|
2664
2737
|
const ctx = {
|
|
2665
2738
|
request,
|
|
2666
2739
|
runningAction: false
|
|
@@ -2674,39 +2747,24 @@ async function generateRenderResponse(request, staticHandler, basename, isDataRe
|
|
|
2674
2747
|
async generateMiddlewareResponse(query) {
|
|
2675
2748
|
let formState;
|
|
2676
2749
|
let skipRevalidation = false;
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
}
|
|
2690
|
-
if (!potentialCSRFAttackError) {
|
|
2691
|
-
ctx.runningAction = true;
|
|
2692
|
-
let result = await processServerAction(request, basename, decodeReply, loadServerAction, decodeAction, decodeFormState, onError, temporaryReferences).finally(() => {
|
|
2693
|
-
ctx.runningAction = false;
|
|
2694
|
-
});
|
|
2695
|
-
if (isResponse(result)) return generateRedirectResponse(result, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, result === ctx.redirect ? void 0 : ctx.redirect?.headers);
|
|
2696
|
-
skipRevalidation = result?.skipRevalidation ?? false;
|
|
2697
|
-
actionResult = result?.actionResult;
|
|
2698
|
-
formState = result?.formState;
|
|
2699
|
-
request = result?.revalidationRequest ?? request;
|
|
2700
|
-
if (ctx.redirect) return generateRedirectResponse(ctx.redirect, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, void 0);
|
|
2701
|
-
}
|
|
2750
|
+
if (isSubmission && !handledSubmission) {
|
|
2751
|
+
handledSubmission = true;
|
|
2752
|
+
ctx.runningAction = true;
|
|
2753
|
+
let result = await processServerAction(request, basename, decodeReply, loadServerAction, decodeAction, decodeFormState, onError, temporaryReferences).finally(() => {
|
|
2754
|
+
ctx.runningAction = false;
|
|
2755
|
+
});
|
|
2756
|
+
if (isResponse(result)) return generateRedirectResponse(result, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, result === ctx.redirect ? void 0 : ctx.redirect?.headers);
|
|
2757
|
+
skipRevalidation = result?.skipRevalidation ?? false;
|
|
2758
|
+
actionResult = result?.actionResult;
|
|
2759
|
+
formState = result?.formState;
|
|
2760
|
+
request = result?.revalidationRequest ?? request;
|
|
2761
|
+
if (ctx.redirect) return generateRedirectResponse(ctx.redirect, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, void 0);
|
|
2702
2762
|
}
|
|
2703
2763
|
let staticContext = await query(request, skipRevalidation ? { filterMatchesToLoad: () => false } : void 0);
|
|
2704
2764
|
if (isResponse(staticContext)) return generateRedirectResponse(staticContext, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, ctx.redirect?.headers);
|
|
2705
|
-
if (
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
staticContext.statusCode = 400;
|
|
2709
|
-
}
|
|
2765
|
+
if (staticContext.errors) Object.values(staticContext.errors).forEach((error) => {
|
|
2766
|
+
if (!isRouteErrorResponse(error) || error.error) onError?.(error);
|
|
2767
|
+
});
|
|
2710
2768
|
return generateStaticContextResponse(staticHandler, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, skipRevalidation, ctx.redirect?.headers, routeDiscovery, clientVersion);
|
|
2711
2769
|
}
|
|
2712
2770
|
}));
|
|
@@ -2851,6 +2909,7 @@ async function getRSCRouteMatch({ staticContext, match, isBelowErrorBoundary, ro
|
|
|
2851
2909
|
return {
|
|
2852
2910
|
clientAction: route.clientAction,
|
|
2853
2911
|
clientLoader: route.clientLoader,
|
|
2912
|
+
clientMiddleware: route.clientMiddleware,
|
|
2854
2913
|
element,
|
|
2855
2914
|
errorElement,
|
|
2856
2915
|
handle: route.handle,
|
|
@@ -2878,6 +2937,7 @@ async function getManifestRoute(route) {
|
|
|
2878
2937
|
return {
|
|
2879
2938
|
clientAction: route.clientAction,
|
|
2880
2939
|
clientLoader: route.clientLoader,
|
|
2940
|
+
clientMiddleware: route.clientMiddleware,
|
|
2881
2941
|
handle: route.handle,
|
|
2882
2942
|
hasAction: !!route.action,
|
|
2883
2943
|
hasComponent: !!route.Component,
|
|
@@ -2987,14 +3047,14 @@ function href(path, ...args) {
|
|
|
2987
3047
|
let result = trimTrailingSplat(path).replace(/\/:([\w-]+)(\?)?/g, (_, param, questionMark) => {
|
|
2988
3048
|
const isRequired = questionMark === void 0;
|
|
2989
3049
|
const value = params?.[param];
|
|
2990
|
-
if (isRequired && value
|
|
3050
|
+
if (isRequired && value == null) throw new Error(`Path '${path}' requires param '${param}' but it was not provided`);
|
|
2991
3051
|
return value == null ? "" : "/" + encodePathParam(stringify(value));
|
|
2992
3052
|
});
|
|
2993
3053
|
if (path.endsWith("*")) {
|
|
2994
3054
|
const value = params?.["*"];
|
|
2995
|
-
if (value
|
|
3055
|
+
if (value != null) result += "/" + stringify(value).split("/").map(encodePathParam).join("/");
|
|
2996
3056
|
}
|
|
2997
|
-
return result || "/";
|
|
3057
|
+
return result.replace(/^\/{2,}/, "/") || "/";
|
|
2998
3058
|
}
|
|
2999
3059
|
/**
|
|
3000
3060
|
* Removes a trailing splat and any number of slashes from the end of the path.
|
|
@@ -3226,6 +3286,7 @@ const createSession = (initialData = {}, id = "") => {
|
|
|
3226
3286
|
},
|
|
3227
3287
|
unset(name) {
|
|
3228
3288
|
map.delete(name);
|
|
3289
|
+
map.delete(flash(name));
|
|
3229
3290
|
}
|
|
3230
3291
|
};
|
|
3231
3292
|
};
|
|
@@ -3259,8 +3320,9 @@ function createSessionStorage({ cookie: cookieArg, createData, readData, updateD
|
|
|
3259
3320
|
warnOnceAboutSigningSessionCookie(cookie);
|
|
3260
3321
|
return {
|
|
3261
3322
|
async getSession(cookieHeader, options) {
|
|
3262
|
-
let
|
|
3263
|
-
|
|
3323
|
+
let parsedId = cookieHeader && await cookie.parse(cookieHeader, options);
|
|
3324
|
+
let id = typeof parsedId === "string" && parsedId ? parsedId : "";
|
|
3325
|
+
return createSession((id ? await readData(id) : null) || {}, id);
|
|
3264
3326
|
},
|
|
3265
3327
|
async commitSession(session, options) {
|
|
3266
3328
|
let { id, data } = session;
|
|
@@ -3306,7 +3368,8 @@ function createCookieSessionStorage({ cookie: cookieArg } = {}) {
|
|
|
3306
3368
|
warnOnceAboutSigningSessionCookie(cookie);
|
|
3307
3369
|
return {
|
|
3308
3370
|
async getSession(cookieHeader, options) {
|
|
3309
|
-
|
|
3371
|
+
let data = cookieHeader && await cookie.parse(cookieHeader, options);
|
|
3372
|
+
return createSession(typeof data === "object" && data !== null && !Array.isArray(data) ? data : {});
|
|
3310
3373
|
},
|
|
3311
3374
|
async commitSession(session, options) {
|
|
3312
3375
|
let serializedCookie = await cookie.serialize(session.data, options);
|
package/dist/production/index.js
CHANGED
|
@@ -447,7 +447,7 @@ interface PathRouteProps {
|
|
|
447
447
|
action?: NonIndexRouteObject["action"];
|
|
448
448
|
/**
|
|
449
449
|
* The route shouldRevalidate function.
|
|
450
|
-
* See [`shouldRevalidate`](../../start/data/route-object#
|
|
450
|
+
* See [`shouldRevalidate`](../../start/data/route-object#shouldrevalidate).
|
|
451
451
|
*/
|
|
452
452
|
shouldRevalidate?: NonIndexRouteObject["shouldRevalidate"];
|
|
453
453
|
/**
|
|
@@ -537,7 +537,7 @@ interface IndexRouteProps {
|
|
|
537
537
|
action?: IndexRouteObject["action"];
|
|
538
538
|
/**
|
|
539
539
|
* The route shouldRevalidate function.
|
|
540
|
-
* See [`shouldRevalidate`](../../start/data/route-object#
|
|
540
|
+
* See [`shouldRevalidate`](../../start/data/route-object#shouldrevalidate).
|
|
541
541
|
*/
|
|
542
542
|
shouldRevalidate?: IndexRouteObject["shouldRevalidate"];
|
|
543
543
|
/**
|
|
@@ -768,7 +768,25 @@ interface AwaitResolveRenderFunction<Resolve = any> {
|
|
|
768
768
|
* @category Types
|
|
769
769
|
*/
|
|
770
770
|
interface AwaitProps<Resolve> {
|
|
771
|
-
/**
|
|
771
|
+
/**
|
|
772
|
+
* <docs-warning>This prop is currently unstable and may change in minor or patch
|
|
773
|
+
* releases.</docs-warning>
|
|
774
|
+
*
|
|
775
|
+
* A promise (or value) to read using React's `use()` API in client components.
|
|
776
|
+
* Unlike `resolve` in client components, this accepts promise-like values
|
|
777
|
+
* without modifying the source promise.
|
|
778
|
+
*
|
|
779
|
+
* `errorElement` handles promise rejections. Errors thrown while rendering
|
|
780
|
+
* children bubble to the nearest React error boundary.
|
|
781
|
+
*
|
|
782
|
+
* ```tsx
|
|
783
|
+
* <Await unstable_promise={reviewsPromise} errorElement={<ReviewsError />}>
|
|
784
|
+
* {(reviews) => <Reviews items={reviews} />}
|
|
785
|
+
* </Await>
|
|
786
|
+
* ```
|
|
787
|
+
*
|
|
788
|
+
* Pass exactly one of `unstable_promise` or `resolve`.
|
|
789
|
+
*/
|
|
772
790
|
unstable_promise?: never;
|
|
773
791
|
/**
|
|
774
792
|
* When using a function, the resolved value is provided as the parameter.
|
|
@@ -795,14 +813,17 @@ interface AwaitProps<Resolve> {
|
|
|
795
813
|
*/
|
|
796
814
|
children: React$1.ReactNode | AwaitResolveRenderFunction<Resolve>;
|
|
797
815
|
/**
|
|
798
|
-
* The error element renders instead of the `children` when the
|
|
816
|
+
* The error element renders instead of the `children` when the
|
|
817
|
+
* [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
|
|
799
818
|
* rejects.
|
|
800
819
|
*
|
|
820
|
+
* When using `resolve`, errors thrown while rendering `children` are
|
|
821
|
+
* also caught and rendered here. With `unstable_promise`, only promise
|
|
822
|
+
* rejections are handled; errors thrown while rendering `children` bubble to
|
|
823
|
+
* the nearest React error boundary.
|
|
824
|
+
*
|
|
801
825
|
* ```tsx
|
|
802
|
-
* <Await
|
|
803
|
-
* errorElement={<div>Oops</div>}
|
|
804
|
-
* resolve={reviewsPromise}
|
|
805
|
-
* >
|
|
826
|
+
* <Await resolve={reviewsPromise} errorElement={<div>Oops</div>}>
|
|
806
827
|
* <Reviews />
|
|
807
828
|
* </Await>
|
|
808
829
|
* ```
|
|
@@ -811,10 +832,7 @@ interface AwaitProps<Resolve> {
|
|
|
811
832
|
* child component
|
|
812
833
|
*
|
|
813
834
|
* ```tsx
|
|
814
|
-
* <Await
|
|
815
|
-
* errorElement={<ReviewsError />}
|
|
816
|
-
* resolve={reviewsPromise}
|
|
817
|
-
* >
|
|
835
|
+
* <Await resolve={reviewsPromise} errorElement={<ReviewsError />}>
|
|
818
836
|
* <Reviews />
|
|
819
837
|
* </Await>
|
|
820
838
|
*
|
|
@@ -894,22 +912,16 @@ interface AwaitPromiseProps<Resolve> extends Omit<AwaitProps<Resolve>, "resolve"
|
|
|
894
912
|
/**
|
|
895
913
|
* Used to render promise values with automatic error handling.
|
|
896
914
|
*
|
|
897
|
-
*
|
|
915
|
+
* Passing the promise through `resolve` uses React Router-specific promise tracking, while passing
|
|
916
|
+
* it through `unstable_promise` uses React's built-in [`use()`](https://react.dev/reference/react/use)
|
|
917
|
+
* API.
|
|
898
918
|
*
|
|
899
|
-
*
|
|
900
|
-
* [`use()`](https://react.dev/reference/react/use) implementation. With
|
|
901
|
-
* `unstable_promise`, `errorElement` handles promise rejections, while errors
|
|
902
|
-
* thrown by children bubble to the nearest React error boundary.
|
|
903
|
-
*
|
|
904
|
-
* In React Server Components, `resolve` already has this error-handling behavior:
|
|
905
|
-
* `errorElement` handles only input rejections, while child render errors
|
|
906
|
-
* propagate to the surrounding error boundary. Both props accept promise-like
|
|
907
|
-
* values without modifying the source promise. Both props treat a falsy
|
|
908
|
-
* `errorElement` as absent and propagate the rejection. Pass an empty fragment
|
|
909
|
-
* to handle a rejection without rendering any content.
|
|
919
|
+
* **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
|
|
910
920
|
*
|
|
911
|
-
* <docs-warning>The `unstable_promise` prop is
|
|
912
|
-
*
|
|
921
|
+
* <docs-warning>The `unstable_promise` prop is currently unstable and may change in minor or patch
|
|
922
|
+
* releases. We plan to stabilize `<Await promise>` and deprecate `<Await resolve>` during v8, and then
|
|
923
|
+
* drop `<Await resolve>` in v9. Please see below for minor `errorElement` behavioral differences
|
|
924
|
+
* between the two approaches.</docs-warning>
|
|
913
925
|
*
|
|
914
926
|
* @example
|
|
915
927
|
* import { Await, useLoaderData } from "react-router";
|
|
@@ -929,15 +941,9 @@ interface AwaitPromiseProps<Resolve> extends Omit<AwaitProps<Resolve>, "resolve"
|
|
|
929
941
|
* <h1>{book.title}</h1>
|
|
930
942
|
* <p>{book.description}</p>
|
|
931
943
|
* <React.Suspense fallback={<ReviewsSkeleton />}>
|
|
932
|
-
* <Await
|
|
933
|
-
*
|
|
934
|
-
*
|
|
935
|
-
* <div>Could not load reviews 😬</div>
|
|
936
|
-
* }
|
|
937
|
-
* children={(resolvedReviews) => (
|
|
938
|
-
* <Reviews items={resolvedReviews} />
|
|
939
|
-
* )}
|
|
940
|
-
* />
|
|
944
|
+
* <Await resolve={reviews} errorElement={<BookError />}>
|
|
945
|
+
* {(resolvedReviews) => <Reviews items={resolvedReviews} />}
|
|
946
|
+
* </Await>
|
|
941
947
|
* </React.Suspense>
|
|
942
948
|
* </div>
|
|
943
949
|
* );
|
|
@@ -951,9 +957,7 @@ interface AwaitPromiseProps<Resolve> extends Omit<AwaitProps<Resolve>, "resolve"
|
|
|
951
957
|
* @param {AwaitProps.children} props.children n/a
|
|
952
958
|
* @param {AwaitProps.errorElement} props.errorElement n/a
|
|
953
959
|
* @param {AwaitProps.resolve} props.resolve n/a
|
|
954
|
-
* @param props.unstable_promise
|
|
955
|
-
* API in client components. Accepts promise-like values without modifying the
|
|
956
|
-
* source promise. Pass exactly one of `unstable_promise` or `resolve`.
|
|
960
|
+
* @param {AwaitProps.unstable_promise} props.unstable_promise n/a
|
|
957
961
|
* @returns React element for the rendered awaited value
|
|
958
962
|
*/
|
|
959
963
|
declare function Await<Resolve>(props: AwaitProps<Resolve> | AwaitPromiseProps<Resolve>): React$1.JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.3
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import { createMemoryHistory, createPath, invariant, parsePath, warning } from "./router/history.js";
|
|
12
|
-
import { defaultMapRouteProperties, getResolveToMatches, getRoutePattern, resolveTo, stripBasename } from "./router/utils.js";
|
|
13
12
|
import { getNavigatorCurrentUrl, validateNavigationTarget } from "./router/navigation.js";
|
|
13
|
+
import { defaultMapRouteProperties, getResolveToMatches, getRoutePattern, resolveTo, stripBasename } from "./router/utils.js";
|
|
14
14
|
import { clientErrors, createRouter } from "./router/router.js";
|
|
15
15
|
import { AwaitContext, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, LocationContext, NavigationContext, RouteContext, ViewTransitionContext, useIsRSCRouterContext } from "./context.js";
|
|
16
16
|
import { getAwaitPromise, getPromiseResult } from "./await.js";
|
|
@@ -284,13 +284,14 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
|
|
|
284
284
|
encodeLocation: router.encodeLocation,
|
|
285
285
|
go: (n) => router.navigate(n),
|
|
286
286
|
push: (to, state, opts) => router.navigate(to, {
|
|
287
|
-
|
|
288
|
-
|
|
287
|
+
...opts,
|
|
288
|
+
replace: opts?.replace === false ? false : void 0,
|
|
289
|
+
state: state !== void 0 ? state : opts?.state
|
|
289
290
|
}),
|
|
290
291
|
replace: (to, state, opts) => router.navigate(to, {
|
|
292
|
+
...opts,
|
|
291
293
|
replace: true,
|
|
292
|
-
state
|
|
293
|
-
preventScrollReset: opts?.preventScrollReset
|
|
294
|
+
state: state !== void 0 ? state : opts?.state
|
|
294
295
|
})
|
|
295
296
|
};
|
|
296
297
|
}, [router]);
|
|
@@ -343,6 +344,7 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
|
|
|
343
344
|
fetchers: state.fetchers,
|
|
344
345
|
fetcherData: fetcherData.current
|
|
345
346
|
}), [state.fetchers]);
|
|
347
|
+
let discoveryRuntime = React$1.useContext(FrameworkContext)?.routeDiscoveryRuntime;
|
|
346
348
|
return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, /* @__PURE__ */ React$1.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React$1.createElement(DataRouterStateContext.Provider, { value: dataRouterState }, /* @__PURE__ */ React$1.createElement(DataRouterNavigationContext.Provider, { value: dataRouterNavigation }, /* @__PURE__ */ React$1.createElement(DataRouterDataContext.Provider, { value: dataRouterData }, /* @__PURE__ */ React$1.createElement(FetchersContext.Provider, { value: fetchersContext }, /* @__PURE__ */ React$1.createElement(ViewTransitionContext.Provider, { value: vtContext }, /* @__PURE__ */ React$1.createElement(Router, {
|
|
347
349
|
basename,
|
|
348
350
|
location: state.location,
|
|
@@ -354,7 +356,8 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
|
|
|
354
356
|
manifest: router.manifest,
|
|
355
357
|
state,
|
|
356
358
|
isStatic: false,
|
|
357
|
-
onError
|
|
359
|
+
onError,
|
|
360
|
+
discoveryRuntime
|
|
358
361
|
})))))))), null);
|
|
359
362
|
}
|
|
360
363
|
function getOptimisticRouterState(currentState, newState) {
|
|
@@ -367,10 +370,9 @@ function getOptimisticRouterState(currentState, newState) {
|
|
|
367
370
|
};
|
|
368
371
|
}
|
|
369
372
|
const MemoizedDataRoutes = React$1.memo(DataRoutes);
|
|
370
|
-
function DataRoutes({ routes, manifest, state, isStatic, onError }) {
|
|
373
|
+
function DataRoutes({ routes, manifest, state, isStatic, onError, discoveryRuntime }) {
|
|
371
374
|
let dataRouterContext = React$1.useContext(DataRouterContext);
|
|
372
375
|
invariant(dataRouterContext, "You must render this element inside a <DataRouterContext.Provider> element");
|
|
373
|
-
let discoveryRuntime = React$1.useContext(FrameworkContext)?.routeDiscoveryRuntime;
|
|
374
376
|
React$1.useEffect(() => {
|
|
375
377
|
if (state.initialized) discoveryRuntime?.markReady();
|
|
376
378
|
}, [state.initialized, discoveryRuntime]);
|
|
@@ -649,22 +651,16 @@ function Routes({ children, location }) {
|
|
|
649
651
|
/**
|
|
650
652
|
* Used to render promise values with automatic error handling.
|
|
651
653
|
*
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
*
|
|
655
|
-
* [`use()`](https://react.dev/reference/react/use) implementation. With
|
|
656
|
-
* `unstable_promise`, `errorElement` handles promise rejections, while errors
|
|
657
|
-
* thrown by children bubble to the nearest React error boundary.
|
|
654
|
+
* Passing the promise through `resolve` uses React Router-specific promise tracking, while passing
|
|
655
|
+
* it through `unstable_promise` uses React's built-in [`use()`](https://react.dev/reference/react/use)
|
|
656
|
+
* API.
|
|
658
657
|
*
|
|
659
|
-
*
|
|
660
|
-
* `errorElement` handles only input rejections, while child render errors
|
|
661
|
-
* propagate to the surrounding error boundary. Both props accept promise-like
|
|
662
|
-
* values without modifying the source promise. Both props treat a falsy
|
|
663
|
-
* `errorElement` as absent and propagate the rejection. Pass an empty fragment
|
|
664
|
-
* to handle a rejection without rendering any content.
|
|
658
|
+
* **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
|
|
665
659
|
*
|
|
666
|
-
* <docs-warning>The `unstable_promise` prop is
|
|
667
|
-
*
|
|
660
|
+
* <docs-warning>The `unstable_promise` prop is currently unstable and may change in minor or patch
|
|
661
|
+
* releases. We plan to stabilize `<Await promise>` and deprecate `<Await resolve>` during v8, and then
|
|
662
|
+
* drop `<Await resolve>` in v9. Please see below for minor `errorElement` behavioral differences
|
|
663
|
+
* between the two approaches.</docs-warning>
|
|
668
664
|
*
|
|
669
665
|
* @example
|
|
670
666
|
* import { Await, useLoaderData } from "react-router";
|
|
@@ -684,15 +680,9 @@ function Routes({ children, location }) {
|
|
|
684
680
|
* <h1>{book.title}</h1>
|
|
685
681
|
* <p>{book.description}</p>
|
|
686
682
|
* <React.Suspense fallback={<ReviewsSkeleton />}>
|
|
687
|
-
* <Await
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
* <div>Could not load reviews 😬</div>
|
|
691
|
-
* }
|
|
692
|
-
* children={(resolvedReviews) => (
|
|
693
|
-
* <Reviews items={resolvedReviews} />
|
|
694
|
-
* )}
|
|
695
|
-
* />
|
|
683
|
+
* <Await resolve={reviews} errorElement={<BookError />}>
|
|
684
|
+
* {(resolvedReviews) => <Reviews items={resolvedReviews} />}
|
|
685
|
+
* </Await>
|
|
696
686
|
* </React.Suspense>
|
|
697
687
|
* </div>
|
|
698
688
|
* );
|
|
@@ -706,9 +696,7 @@ function Routes({ children, location }) {
|
|
|
706
696
|
* @param {AwaitProps.children} props.children n/a
|
|
707
697
|
* @param {AwaitProps.errorElement} props.errorElement n/a
|
|
708
698
|
* @param {AwaitProps.resolve} props.resolve n/a
|
|
709
|
-
* @param props.unstable_promise
|
|
710
|
-
* API in client components. Accepts promise-like values without modifying the
|
|
711
|
-
* source promise. Pass exactly one of `unstable_promise` or `resolve`.
|
|
699
|
+
* @param {AwaitProps.unstable_promise} props.unstable_promise n/a
|
|
712
700
|
* @returns React element for the rendered awaited value
|
|
713
701
|
*/
|
|
714
702
|
function Await(props) {
|
|
@@ -746,11 +734,21 @@ function AwaitPromise({ value, children, errorElement, onError }) {
|
|
|
746
734
|
var AwaitErrorBoundary = class extends React$1.Component {
|
|
747
735
|
constructor(props) {
|
|
748
736
|
super(props);
|
|
749
|
-
this.state = {
|
|
737
|
+
this.state = {
|
|
738
|
+
error: null,
|
|
739
|
+
resolve: props.resolve
|
|
740
|
+
};
|
|
750
741
|
}
|
|
751
742
|
static getDerivedStateFromError(error) {
|
|
752
743
|
return { error };
|
|
753
744
|
}
|
|
745
|
+
static getDerivedStateFromProps(props, state) {
|
|
746
|
+
if (props.resolve !== state.resolve) return {
|
|
747
|
+
error: null,
|
|
748
|
+
resolve: props.resolve
|
|
749
|
+
};
|
|
750
|
+
return null;
|
|
751
|
+
}
|
|
754
752
|
componentDidCatch(error, errorInfo) {
|
|
755
753
|
if (this.props.onError) this.props.onError(error, errorInfo);
|
|
756
754
|
else console.error("<Await> caught the following error during render", error, errorInfo);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.3
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -19,6 +19,7 @@ DataRouterDataContext.displayName = "DataRouterData";
|
|
|
19
19
|
const DataRouterNavigationContext = React$1.createContext(null);
|
|
20
20
|
DataRouterNavigationContext.displayName = "DataRouterNavigation";
|
|
21
21
|
const RSCRouterContext = React$1.createContext(false);
|
|
22
|
+
const RSCErrorAlreadyReportedContext = React$1.createContext(false);
|
|
22
23
|
function useIsRSCRouterContext() {
|
|
23
24
|
return React$1.useContext(RSCRouterContext);
|
|
24
25
|
}
|
|
@@ -46,4 +47,4 @@ RouteIdContext.displayName = "RouteId";
|
|
|
46
47
|
const RouteErrorContext = React$1.createContext(null);
|
|
47
48
|
RouteErrorContext.displayName = "RouteError";
|
|
48
49
|
//#endregion
|
|
49
|
-
export { AwaitContext, AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, IsDataRouteContext, LocationContext, NavigationContext, RSCRouterContext, RouteContext, RouteErrorContext, RouteIdContext, ViewTransitionContext, useIsRSCRouterContext };
|
|
50
|
+
export { AwaitContext, AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, IsDataRouteContext, LocationContext, NavigationContext, RSCErrorAlreadyReportedContext, RSCRouterContext, RouteContext, RouteErrorContext, RouteIdContext, ViewTransitionContext, useIsRSCRouterContext };
|