react-router 7.10.1 → 7.11.0-pre.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -11
- package/dist/development/{browser-BpxEZgZC.d.ts → browser-Cv4JZyZ5.d.mts} +4 -3
- package/dist/{production/browser-BpxEZgZC.d.ts → development/browser-o-qhcuhA.d.ts} +4 -3
- package/dist/{production/chunk-B3F6YMOF.js → development/chunk-JKMHOZYW.js} +111 -121
- package/dist/development/{chunk-WWGJGFF6.mjs → chunk-KRMLYMWA.mjs} +231 -74
- package/dist/{production/chunk-YO5R3LGQ.js → development/chunk-OVG6YSZ5.js} +7 -7
- package/dist/development/{chunk-PMGK554W.mjs → chunk-QMKP6CC3.mjs} +147 -38
- package/dist/development/{chunk-RBZI3ZHD.js → chunk-UO7KGW2U.js} +279 -110
- package/dist/development/dom-export.d.mts +11 -10
- package/dist/development/dom-export.d.ts +12 -11
- package/dist/development/dom-export.js +30 -31
- package/dist/development/dom-export.mjs +6 -7
- package/dist/{production/index-react-server-client-CCjKYJTH.d.ts → development/index-react-server-client-Cv5Q9lf0.d.ts} +60 -14
- package/dist/development/{index-react-server-client-CipGfVBI.d.mts → index-react-server-client-P7VgYu6T.d.mts} +60 -14
- package/dist/development/index-react-server-client.d.mts +2 -2
- 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 -2
- package/dist/development/index-react-server.d.ts +4 -2
- package/dist/development/index-react-server.js +72 -19
- package/dist/development/index-react-server.mjs +72 -19
- package/dist/development/index.d.mts +17 -16
- package/dist/development/index.d.ts +17 -16
- package/dist/development/index.js +220 -111
- package/dist/development/index.mjs +3 -3
- package/dist/{production/instrumentation-BB0wRuqz.d.ts → development/instrumentation-BlrVzjbg.d.ts} +30 -15
- package/dist/development/lib/types/internal.d.mts +2 -2
- 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/{register-ODDAAYlf.d.ts → register-BGQUMCK4.d.ts} +1 -1
- package/dist/development/{register-C1RwVJAt.d.mts → register-DTJJbt1o.d.mts} +1 -1
- package/dist/development/{router-CwNp5l9u.d.mts → router-5fbeEIMQ.d.mts} +30 -15
- package/dist/{development/browser-C5z6FZmz.d.mts → production/browser-Cv4JZyZ5.d.mts} +4 -3
- package/dist/production/{browser-C5z6FZmz.d.mts → browser-o-qhcuhA.d.ts} +4 -3
- package/dist/production/{chunk-UQPBOMFP.js → chunk-AO22ZXHI.js} +279 -110
- package/dist/production/{chunk-ANIOYBQK.mjs → chunk-IDHO4Q57.mjs} +231 -74
- package/dist/production/{chunk-TDCOAFPJ.mjs → chunk-J4JITZ76.mjs} +147 -38
- package/dist/{development/chunk-HMTWJNYB.js → production/chunk-M5W3Q3T5.js} +111 -121
- package/dist/{development/chunk-FKYGG5Z2.js → production/chunk-YGB3JEIP.js} +7 -7
- package/dist/production/dom-export.d.mts +11 -10
- package/dist/production/dom-export.d.ts +12 -11
- package/dist/production/dom-export.js +30 -31
- package/dist/production/dom-export.mjs +6 -7
- package/dist/{development/index-react-server-client-CCjKYJTH.d.ts → production/index-react-server-client-Cv5Q9lf0.d.ts} +60 -14
- package/dist/production/{index-react-server-client-CipGfVBI.d.mts → index-react-server-client-P7VgYu6T.d.mts} +60 -14
- package/dist/production/index-react-server-client.d.mts +2 -2
- 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 -2
- package/dist/production/index-react-server.d.ts +4 -2
- package/dist/production/index-react-server.js +72 -19
- package/dist/production/index-react-server.mjs +72 -19
- package/dist/production/index.d.mts +17 -16
- package/dist/production/index.d.ts +17 -16
- package/dist/production/index.js +220 -111
- package/dist/production/index.mjs +3 -3
- package/dist/{development/instrumentation-BB0wRuqz.d.ts → production/instrumentation-BlrVzjbg.d.ts} +30 -15
- package/dist/production/lib/types/internal.d.mts +2 -2
- 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/{register-ODDAAYlf.d.ts → register-BGQUMCK4.d.ts} +1 -1
- package/dist/production/{register-C1RwVJAt.d.mts → register-DTJJbt1o.d.mts} +1 -1
- package/dist/production/{router-CwNp5l9u.d.mts → router-5fbeEIMQ.d.mts} +30 -15
- package/package.json +5 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.
|
|
2
|
+
* react-router v7.11.0-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -976,6 +976,41 @@ function isRouteErrorResponse(error) {
|
|
|
976
976
|
function getRoutePattern(matches) {
|
|
977
977
|
return matches.map((m) => m.route.path).filter(Boolean).join("/").replace(/\/\/*/g, "/") || "/";
|
|
978
978
|
}
|
|
979
|
+
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
980
|
+
function parseToInfo(_to, basename) {
|
|
981
|
+
let to = _to;
|
|
982
|
+
if (typeof to !== "string" || !ABSOLUTE_URL_REGEX.test(to)) {
|
|
983
|
+
return {
|
|
984
|
+
absoluteURL: void 0,
|
|
985
|
+
isExternal: false,
|
|
986
|
+
to
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
let absoluteURL = to;
|
|
990
|
+
let isExternal = false;
|
|
991
|
+
if (isBrowser) {
|
|
992
|
+
try {
|
|
993
|
+
let currentUrl = new URL(window.location.href);
|
|
994
|
+
let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
|
|
995
|
+
let path = stripBasename(targetUrl.pathname, basename);
|
|
996
|
+
if (targetUrl.origin === currentUrl.origin && path != null) {
|
|
997
|
+
to = path + targetUrl.search + targetUrl.hash;
|
|
998
|
+
} else {
|
|
999
|
+
isExternal = true;
|
|
1000
|
+
}
|
|
1001
|
+
} catch (e) {
|
|
1002
|
+
warning(
|
|
1003
|
+
false,
|
|
1004
|
+
`<Link to="${to}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`
|
|
1005
|
+
);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
return {
|
|
1009
|
+
absoluteURL,
|
|
1010
|
+
isExternal,
|
|
1011
|
+
to
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
979
1014
|
|
|
980
1015
|
// lib/router/instrumentation.ts
|
|
981
1016
|
var UninstrumentedSymbol = Symbol("Uninstrumented");
|
|
@@ -1295,7 +1330,7 @@ var TRANSITIONS_STORAGE_KEY = "remix-router-transitions";
|
|
|
1295
1330
|
var ResetLoaderDataSymbol = Symbol("ResetLoaderData");
|
|
1296
1331
|
function createRouter(init) {
|
|
1297
1332
|
const routerWindow = init.window ? init.window : typeof window !== "undefined" ? window : void 0;
|
|
1298
|
-
const
|
|
1333
|
+
const isBrowser3 = typeof routerWindow !== "undefined" && typeof routerWindow.document !== "undefined" && typeof routerWindow.document.createElement !== "undefined";
|
|
1299
1334
|
invariant(
|
|
1300
1335
|
init.routes.length > 0,
|
|
1301
1336
|
"You must provide a non-empty routes array to createRouter"
|
|
@@ -1478,7 +1513,7 @@ function createRouter(init) {
|
|
|
1478
1513
|
return startNavigation(historyAction, location);
|
|
1479
1514
|
}
|
|
1480
1515
|
);
|
|
1481
|
-
if (
|
|
1516
|
+
if (isBrowser3) {
|
|
1482
1517
|
restoreAppliedTransitions(routerWindow, appliedViewTransitions);
|
|
1483
1518
|
let _saveAppliedTransitions = () => persistAppliedTransitions(routerWindow, appliedViewTransitions);
|
|
1484
1519
|
routerWindow.addEventListener("pagehide", _saveAppliedTransitions);
|
|
@@ -1721,7 +1756,8 @@ function createRouter(init) {
|
|
|
1721
1756
|
preventScrollReset,
|
|
1722
1757
|
replace: opts && opts.replace,
|
|
1723
1758
|
enableViewTransition: opts && opts.viewTransition,
|
|
1724
|
-
flushSync
|
|
1759
|
+
flushSync,
|
|
1760
|
+
callSiteDefaultShouldRevalidate: opts && opts.unstable_defaultShouldRevalidate
|
|
1725
1761
|
});
|
|
1726
1762
|
}
|
|
1727
1763
|
function revalidate() {
|
|
@@ -1861,7 +1897,8 @@ function createRouter(init) {
|
|
|
1861
1897
|
opts && opts.replace,
|
|
1862
1898
|
opts && opts.initialHydration === true,
|
|
1863
1899
|
flushSync,
|
|
1864
|
-
pendingActionResult
|
|
1900
|
+
pendingActionResult,
|
|
1901
|
+
opts && opts.callSiteDefaultShouldRevalidate
|
|
1865
1902
|
);
|
|
1866
1903
|
if (shortCircuited) {
|
|
1867
1904
|
return;
|
|
@@ -2006,7 +2043,7 @@ function createRouter(init) {
|
|
|
2006
2043
|
pendingActionResult: [actionMatch.route.id, result]
|
|
2007
2044
|
};
|
|
2008
2045
|
}
|
|
2009
|
-
async function handleLoaders(request, location, matches, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult) {
|
|
2046
|
+
async function handleLoaders(request, location, matches, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult, callSiteDefaultShouldRevalidate) {
|
|
2010
2047
|
let loadingNavigation = overrideNavigation || getLoadingNavigation(location, submission);
|
|
2011
2048
|
let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation);
|
|
2012
2049
|
let shouldUpdateNavigationState = !isUninterruptedRevalidation && !initialHydration;
|
|
@@ -2085,7 +2122,8 @@ function createRouter(init) {
|
|
|
2085
2122
|
routesToUse,
|
|
2086
2123
|
basename,
|
|
2087
2124
|
init.patchRoutesOnNavigation != null,
|
|
2088
|
-
pendingActionResult
|
|
2125
|
+
pendingActionResult,
|
|
2126
|
+
callSiteDefaultShouldRevalidate
|
|
2089
2127
|
);
|
|
2090
2128
|
pendingNavigationLoadId = ++incrementingLoadId;
|
|
2091
2129
|
if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && !dsMatches.some(
|
|
@@ -2256,7 +2294,8 @@ function createRouter(init) {
|
|
|
2256
2294
|
fogOfWar.active,
|
|
2257
2295
|
flushSync,
|
|
2258
2296
|
preventScrollReset,
|
|
2259
|
-
submission
|
|
2297
|
+
submission,
|
|
2298
|
+
opts && opts.unstable_defaultShouldRevalidate
|
|
2260
2299
|
);
|
|
2261
2300
|
return;
|
|
2262
2301
|
}
|
|
@@ -2273,7 +2312,7 @@ function createRouter(init) {
|
|
|
2273
2312
|
submission
|
|
2274
2313
|
);
|
|
2275
2314
|
}
|
|
2276
|
-
async function handleFetcherAction(key, routeId, path, requestMatches, scopedContext, isFogOfWar, flushSync, preventScrollReset, submission) {
|
|
2315
|
+
async function handleFetcherAction(key, routeId, path, requestMatches, scopedContext, isFogOfWar, flushSync, preventScrollReset, submission, callSiteDefaultShouldRevalidate) {
|
|
2277
2316
|
interruptActiveLoads();
|
|
2278
2317
|
fetchLoadMatches.delete(key);
|
|
2279
2318
|
let existingFetcher = state.fetchers.get(key);
|
|
@@ -2411,7 +2450,8 @@ function createRouter(init) {
|
|
|
2411
2450
|
routesToUse,
|
|
2412
2451
|
basename,
|
|
2413
2452
|
init.patchRoutesOnNavigation != null,
|
|
2414
|
-
[match.route.id, actionResult]
|
|
2453
|
+
[match.route.id, actionResult],
|
|
2454
|
+
callSiteDefaultShouldRevalidate
|
|
2415
2455
|
);
|
|
2416
2456
|
revalidatingFetchers.filter((rf) => rf.key !== key).forEach((rf) => {
|
|
2417
2457
|
let staleKey = rf.key;
|
|
@@ -2613,7 +2653,7 @@ function createRouter(init) {
|
|
|
2613
2653
|
let redirectLocation = createLocation(state.location, location, {
|
|
2614
2654
|
_isRedirect: true
|
|
2615
2655
|
});
|
|
2616
|
-
if (
|
|
2656
|
+
if (isBrowser3) {
|
|
2617
2657
|
let isDocumentReload = false;
|
|
2618
2658
|
if (redirect2.response.headers.has("X-Remix-Reload-Document")) {
|
|
2619
2659
|
isDocumentReload = true;
|
|
@@ -2688,6 +2728,21 @@ function createRouter(init) {
|
|
|
2688
2728
|
if (request.signal.aborted) {
|
|
2689
2729
|
return dataResults;
|
|
2690
2730
|
}
|
|
2731
|
+
if (!isMutationMethod(request.method)) {
|
|
2732
|
+
for (let match of matches) {
|
|
2733
|
+
if (results[match.route.id]?.type === "error" /* error */) {
|
|
2734
|
+
break;
|
|
2735
|
+
}
|
|
2736
|
+
if (!results.hasOwnProperty(match.route.id) && !state.loaderData.hasOwnProperty(match.route.id) && (!state.errors || !state.errors.hasOwnProperty(match.route.id)) && match.shouldCallHandler()) {
|
|
2737
|
+
results[match.route.id] = {
|
|
2738
|
+
type: "error" /* error */,
|
|
2739
|
+
result: new Error(
|
|
2740
|
+
`No result returned from dataStrategy for route ${match.route.id}`
|
|
2741
|
+
)
|
|
2742
|
+
};
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2691
2746
|
for (let [routeId, result] of Object.entries(results)) {
|
|
2692
2747
|
if (isRedirectDataStrategyResult(result)) {
|
|
2693
2748
|
let response = result.result;
|
|
@@ -3906,7 +3961,7 @@ function normalizeNavigateOptions(isFetcher, path, opts) {
|
|
|
3906
3961
|
parsedPath.search = `?${searchParams}`;
|
|
3907
3962
|
return { path: createPath(parsedPath), submission };
|
|
3908
3963
|
}
|
|
3909
|
-
function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, hasPatchRoutesOnNavigation, pendingActionResult) {
|
|
3964
|
+
function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, hasPatchRoutesOnNavigation, pendingActionResult, callSiteDefaultShouldRevalidate) {
|
|
3910
3965
|
let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
|
|
3911
3966
|
let currentUrl = history.createURL(state.location);
|
|
3912
3967
|
let nextUrl = history.createURL(location);
|
|
@@ -3960,11 +4015,20 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
3960
4015
|
forceShouldLoad
|
|
3961
4016
|
);
|
|
3962
4017
|
}
|
|
3963
|
-
let defaultShouldRevalidate =
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
4018
|
+
let defaultShouldRevalidate = false;
|
|
4019
|
+
if (typeof callSiteDefaultShouldRevalidate === "boolean") {
|
|
4020
|
+
defaultShouldRevalidate = callSiteDefaultShouldRevalidate;
|
|
4021
|
+
} else if (shouldSkipRevalidation) {
|
|
4022
|
+
defaultShouldRevalidate = false;
|
|
4023
|
+
} else if (isRevalidationRequired) {
|
|
4024
|
+
defaultShouldRevalidate = true;
|
|
4025
|
+
} else if (currentUrl.pathname + currentUrl.search === nextUrl.pathname + nextUrl.search) {
|
|
4026
|
+
defaultShouldRevalidate = true;
|
|
4027
|
+
} else if (currentUrl.search !== nextUrl.search) {
|
|
4028
|
+
defaultShouldRevalidate = true;
|
|
4029
|
+
} else if (isNewRouteInstance(state.matches[index], match)) {
|
|
4030
|
+
defaultShouldRevalidate = true;
|
|
4031
|
+
}
|
|
3968
4032
|
let shouldRevalidateArgs = {
|
|
3969
4033
|
...baseShouldRevalidateArgs,
|
|
3970
4034
|
defaultShouldRevalidate
|
|
@@ -3979,7 +4043,8 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
3979
4043
|
lazyRoutePropertiesToSkip,
|
|
3980
4044
|
scopedContext,
|
|
3981
4045
|
shouldLoad,
|
|
3982
|
-
shouldRevalidateArgs
|
|
4046
|
+
shouldRevalidateArgs,
|
|
4047
|
+
callSiteDefaultShouldRevalidate
|
|
3983
4048
|
);
|
|
3984
4049
|
});
|
|
3985
4050
|
let revalidatingFetchers = [];
|
|
@@ -4040,9 +4105,17 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
4040
4105
|
);
|
|
4041
4106
|
}
|
|
4042
4107
|
} else {
|
|
4108
|
+
let defaultShouldRevalidate;
|
|
4109
|
+
if (typeof callSiteDefaultShouldRevalidate === "boolean") {
|
|
4110
|
+
defaultShouldRevalidate = callSiteDefaultShouldRevalidate;
|
|
4111
|
+
} else if (shouldSkipRevalidation) {
|
|
4112
|
+
defaultShouldRevalidate = false;
|
|
4113
|
+
} else {
|
|
4114
|
+
defaultShouldRevalidate = isRevalidationRequired;
|
|
4115
|
+
}
|
|
4043
4116
|
let shouldRevalidateArgs = {
|
|
4044
4117
|
...baseShouldRevalidateArgs,
|
|
4045
|
-
defaultShouldRevalidate
|
|
4118
|
+
defaultShouldRevalidate
|
|
4046
4119
|
};
|
|
4047
4120
|
if (shouldRevalidateLoader(fetcherMatch, shouldRevalidateArgs)) {
|
|
4048
4121
|
fetcherDsMatches = getTargetedDataStrategyMatches(
|
|
@@ -4391,8 +4464,12 @@ function runClientMiddlewarePipeline(args, handler) {
|
|
|
4391
4464
|
return runMiddlewarePipeline(
|
|
4392
4465
|
args,
|
|
4393
4466
|
handler,
|
|
4394
|
-
(r) =>
|
|
4395
|
-
|
|
4467
|
+
(r) => {
|
|
4468
|
+
if (isRedirectResponse(r)) {
|
|
4469
|
+
throw r;
|
|
4470
|
+
}
|
|
4471
|
+
return r;
|
|
4472
|
+
},
|
|
4396
4473
|
isDataStrategyResults,
|
|
4397
4474
|
errorHandler
|
|
4398
4475
|
);
|
|
@@ -4516,7 +4593,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request
|
|
|
4516
4593
|
handler: lazyRoutePromises.lazyHandlerPromise
|
|
4517
4594
|
};
|
|
4518
4595
|
}
|
|
4519
|
-
function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null) {
|
|
4596
|
+
function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null, callSiteDefaultShouldRevalidate) {
|
|
4520
4597
|
let isUsingNewApi = false;
|
|
4521
4598
|
let _lazyPromises = getDataStrategyMatchLazyPromises(
|
|
4522
4599
|
mapRouteProperties2,
|
|
@@ -4535,6 +4612,12 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_p
|
|
|
4535
4612
|
if (!shouldRevalidateArgs) {
|
|
4536
4613
|
return shouldLoad;
|
|
4537
4614
|
}
|
|
4615
|
+
if (typeof callSiteDefaultShouldRevalidate === "boolean") {
|
|
4616
|
+
return shouldRevalidateLoader(match, {
|
|
4617
|
+
...shouldRevalidateArgs,
|
|
4618
|
+
defaultShouldRevalidate: callSiteDefaultShouldRevalidate
|
|
4619
|
+
});
|
|
4620
|
+
}
|
|
4538
4621
|
if (typeof defaultShouldRevalidate === "boolean") {
|
|
4539
4622
|
return shouldRevalidateLoader(match, {
|
|
4540
4623
|
...shouldRevalidateArgs,
|
|
@@ -5363,6 +5446,41 @@ var ENABLE_DEV_WARNINGS = true;
|
|
|
5363
5446
|
|
|
5364
5447
|
// lib/hooks.tsx
|
|
5365
5448
|
import * as React2 from "react";
|
|
5449
|
+
|
|
5450
|
+
// lib/errors.ts
|
|
5451
|
+
var ERROR_DIGEST_BASE = "REACT_ROUTER_ERROR";
|
|
5452
|
+
var ERROR_DIGEST_REDIRECT = "REDIRECT";
|
|
5453
|
+
var ERROR_DIGEST_ROUTE_ERROR_RESPONSE = "ROUTE_ERROR_RESPONSE";
|
|
5454
|
+
function decodeRedirectErrorDigest(digest) {
|
|
5455
|
+
if (digest.startsWith(`${ERROR_DIGEST_BASE}:${ERROR_DIGEST_REDIRECT}:{`)) {
|
|
5456
|
+
try {
|
|
5457
|
+
let parsed = JSON.parse(digest.slice(28));
|
|
5458
|
+
if (typeof parsed === "object" && parsed && typeof parsed.status === "number" && typeof parsed.statusText === "string" && typeof parsed.location === "string" && typeof parsed.reloadDocument === "boolean" && typeof parsed.replace === "boolean") {
|
|
5459
|
+
return parsed;
|
|
5460
|
+
}
|
|
5461
|
+
} catch {
|
|
5462
|
+
}
|
|
5463
|
+
}
|
|
5464
|
+
}
|
|
5465
|
+
function decodeRouteErrorResponseDigest(digest) {
|
|
5466
|
+
if (digest.startsWith(
|
|
5467
|
+
`${ERROR_DIGEST_BASE}:${ERROR_DIGEST_ROUTE_ERROR_RESPONSE}:{`
|
|
5468
|
+
)) {
|
|
5469
|
+
try {
|
|
5470
|
+
let parsed = JSON.parse(digest.slice(40));
|
|
5471
|
+
if (typeof parsed === "object" && parsed && typeof parsed.status === "number" && typeof parsed.statusText === "string") {
|
|
5472
|
+
return new ErrorResponseImpl(
|
|
5473
|
+
parsed.status,
|
|
5474
|
+
parsed.statusText,
|
|
5475
|
+
parsed.data
|
|
5476
|
+
);
|
|
5477
|
+
}
|
|
5478
|
+
} catch {
|
|
5479
|
+
}
|
|
5480
|
+
}
|
|
5481
|
+
}
|
|
5482
|
+
|
|
5483
|
+
// lib/hooks.tsx
|
|
5366
5484
|
function useHref(to, { relative } = {}) {
|
|
5367
5485
|
invariant(
|
|
5368
5486
|
useInRouterContext(),
|
|
@@ -5499,7 +5617,7 @@ function useResolvedPath(to, { relative } = {}) {
|
|
|
5499
5617
|
function useRoutes(routes, locationArg) {
|
|
5500
5618
|
return useRoutesImpl(routes, locationArg);
|
|
5501
5619
|
}
|
|
5502
|
-
function useRoutesImpl(routes, locationArg, dataRouterState,
|
|
5620
|
+
function useRoutesImpl(routes, locationArg, dataRouterState, onError, future) {
|
|
5503
5621
|
invariant(
|
|
5504
5622
|
useInRouterContext(),
|
|
5505
5623
|
// TODO: This error is probably because they somehow have 2 versions of the
|
|
@@ -5581,7 +5699,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
5581
5699
|
),
|
|
5582
5700
|
parentMatches,
|
|
5583
5701
|
dataRouterState,
|
|
5584
|
-
|
|
5702
|
+
onError,
|
|
5585
5703
|
future
|
|
5586
5704
|
);
|
|
5587
5705
|
if (locationArg && renderedMatches) {
|
|
@@ -5660,15 +5778,61 @@ var RenderErrorBoundary = class extends React2.Component {
|
|
|
5660
5778
|
}
|
|
5661
5779
|
}
|
|
5662
5780
|
render() {
|
|
5663
|
-
|
|
5781
|
+
let error = this.state.error;
|
|
5782
|
+
if (this.context && typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
|
|
5783
|
+
const decoded = decodeRouteErrorResponseDigest(error.digest);
|
|
5784
|
+
if (decoded) error = decoded;
|
|
5785
|
+
}
|
|
5786
|
+
let result = error !== void 0 ? /* @__PURE__ */ React2.createElement(RouteContext.Provider, { value: this.props.routeContext }, /* @__PURE__ */ React2.createElement(
|
|
5664
5787
|
RouteErrorContext.Provider,
|
|
5665
5788
|
{
|
|
5666
|
-
value:
|
|
5789
|
+
value: error,
|
|
5667
5790
|
children: this.props.component
|
|
5668
5791
|
}
|
|
5669
5792
|
)) : this.props.children;
|
|
5793
|
+
if (this.context) {
|
|
5794
|
+
return /* @__PURE__ */ React2.createElement(RSCErrorHandler, { error }, result);
|
|
5795
|
+
}
|
|
5796
|
+
return result;
|
|
5670
5797
|
}
|
|
5671
5798
|
};
|
|
5799
|
+
RenderErrorBoundary.contextType = RSCRouterContext;
|
|
5800
|
+
var errorRedirectHandledMap = /* @__PURE__ */ new WeakMap();
|
|
5801
|
+
function RSCErrorHandler({
|
|
5802
|
+
children,
|
|
5803
|
+
error
|
|
5804
|
+
}) {
|
|
5805
|
+
let { basename } = React2.useContext(NavigationContext);
|
|
5806
|
+
if (typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
|
|
5807
|
+
let redirect2 = decodeRedirectErrorDigest(error.digest);
|
|
5808
|
+
if (redirect2) {
|
|
5809
|
+
let existingRedirect = errorRedirectHandledMap.get(error);
|
|
5810
|
+
if (existingRedirect) throw existingRedirect;
|
|
5811
|
+
let parsed = parseToInfo(redirect2.location, basename);
|
|
5812
|
+
if (isBrowser && !errorRedirectHandledMap.get(error)) {
|
|
5813
|
+
if (parsed.isExternal || redirect2.reloadDocument) {
|
|
5814
|
+
window.location.href = parsed.absoluteURL || parsed.to;
|
|
5815
|
+
} else {
|
|
5816
|
+
const redirectPromise = Promise.resolve().then(
|
|
5817
|
+
() => window.__reactRouterDataRouter.navigate(parsed.to, {
|
|
5818
|
+
replace: redirect2.replace
|
|
5819
|
+
})
|
|
5820
|
+
);
|
|
5821
|
+
errorRedirectHandledMap.set(error, redirectPromise);
|
|
5822
|
+
throw redirectPromise;
|
|
5823
|
+
}
|
|
5824
|
+
}
|
|
5825
|
+
return /* @__PURE__ */ React2.createElement(
|
|
5826
|
+
"meta",
|
|
5827
|
+
{
|
|
5828
|
+
httpEquiv: "refresh",
|
|
5829
|
+
content: `0;url=${parsed.absoluteURL || parsed.to}`
|
|
5830
|
+
}
|
|
5831
|
+
);
|
|
5832
|
+
}
|
|
5833
|
+
}
|
|
5834
|
+
return children;
|
|
5835
|
+
}
|
|
5672
5836
|
function RenderedRoute({ routeContext, match, children }) {
|
|
5673
5837
|
let dataRouterContext = React2.useContext(DataRouterContext);
|
|
5674
5838
|
if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
|
|
@@ -5676,7 +5840,7 @@ function RenderedRoute({ routeContext, match, children }) {
|
|
|
5676
5840
|
}
|
|
5677
5841
|
return /* @__PURE__ */ React2.createElement(RouteContext.Provider, { value: routeContext }, children);
|
|
5678
5842
|
}
|
|
5679
|
-
function _renderMatches(matches, parentMatches = [], dataRouterState = null,
|
|
5843
|
+
function _renderMatches(matches, parentMatches = [], dataRouterState = null, onErrorHandler = null, future = null) {
|
|
5680
5844
|
if (matches == null) {
|
|
5681
5845
|
if (!dataRouterState) {
|
|
5682
5846
|
return null;
|
|
@@ -5729,8 +5893,8 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, uns
|
|
|
5729
5893
|
}
|
|
5730
5894
|
}
|
|
5731
5895
|
}
|
|
5732
|
-
let onError = dataRouterState &&
|
|
5733
|
-
|
|
5896
|
+
let onError = dataRouterState && onErrorHandler ? (error, errorInfo) => {
|
|
5897
|
+
onErrorHandler(error, {
|
|
5734
5898
|
location: dataRouterState.location,
|
|
5735
5899
|
params: dataRouterState.matches?.[0]?.params ?? {},
|
|
5736
5900
|
unstable_pattern: getRoutePattern(dataRouterState.matches),
|
|
@@ -6089,9 +6253,11 @@ var Deferred = class {
|
|
|
6089
6253
|
function RouterProvider({
|
|
6090
6254
|
router,
|
|
6091
6255
|
flushSync: reactDomFlushSyncImpl,
|
|
6092
|
-
|
|
6256
|
+
onError,
|
|
6093
6257
|
unstable_useTransitions
|
|
6094
6258
|
}) {
|
|
6259
|
+
let unstable_rsc = useIsRSCRouterContext();
|
|
6260
|
+
unstable_useTransitions = unstable_rsc || unstable_useTransitions;
|
|
6095
6261
|
let [_state, setStateImpl] = React3.useState(router.state);
|
|
6096
6262
|
let [state, setOptimisticState] = useOptimisticSafe(_state);
|
|
6097
6263
|
let [pendingState, setPendingState] = React3.useState();
|
|
@@ -6104,9 +6270,9 @@ function RouterProvider({
|
|
|
6104
6270
|
let fetcherData = React3.useRef(/* @__PURE__ */ new Map());
|
|
6105
6271
|
let setState = React3.useCallback(
|
|
6106
6272
|
(newState, { deletedFetchers, newErrors, flushSync, viewTransitionOpts }) => {
|
|
6107
|
-
if (newErrors &&
|
|
6273
|
+
if (newErrors && onError) {
|
|
6108
6274
|
Object.values(newErrors).forEach(
|
|
6109
|
-
(error) =>
|
|
6275
|
+
(error) => onError(error, {
|
|
6110
6276
|
location: newState.location,
|
|
6111
6277
|
params: newState.matches[0]?.params ?? {},
|
|
6112
6278
|
unstable_pattern: getRoutePattern(newState.matches)
|
|
@@ -6195,7 +6361,7 @@ function RouterProvider({
|
|
|
6195
6361
|
renderDfd,
|
|
6196
6362
|
unstable_useTransitions,
|
|
6197
6363
|
setOptimisticState,
|
|
6198
|
-
|
|
6364
|
+
onError
|
|
6199
6365
|
]
|
|
6200
6366
|
);
|
|
6201
6367
|
React3.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
|
|
@@ -6276,9 +6442,9 @@ function RouterProvider({
|
|
|
6276
6442
|
navigator,
|
|
6277
6443
|
static: false,
|
|
6278
6444
|
basename,
|
|
6279
|
-
|
|
6445
|
+
onError
|
|
6280
6446
|
}),
|
|
6281
|
-
[router, navigator, basename,
|
|
6447
|
+
[router, navigator, basename, onError]
|
|
6282
6448
|
);
|
|
6283
6449
|
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(
|
|
6284
6450
|
Router,
|
|
@@ -6287,7 +6453,7 @@ function RouterProvider({
|
|
|
6287
6453
|
location: state.location,
|
|
6288
6454
|
navigationType: state.historyAction,
|
|
6289
6455
|
navigator,
|
|
6290
|
-
unstable_useTransitions
|
|
6456
|
+
unstable_useTransitions
|
|
6291
6457
|
},
|
|
6292
6458
|
/* @__PURE__ */ React3.createElement(
|
|
6293
6459
|
MemoizedDataRoutes,
|
|
@@ -6295,7 +6461,7 @@ function RouterProvider({
|
|
|
6295
6461
|
routes: router.routes,
|
|
6296
6462
|
future: router.future,
|
|
6297
6463
|
state,
|
|
6298
|
-
|
|
6464
|
+
onError
|
|
6299
6465
|
}
|
|
6300
6466
|
)
|
|
6301
6467
|
))))), null);
|
|
@@ -6319,9 +6485,9 @@ function DataRoutes({
|
|
|
6319
6485
|
routes,
|
|
6320
6486
|
future,
|
|
6321
6487
|
state,
|
|
6322
|
-
|
|
6488
|
+
onError
|
|
6323
6489
|
}) {
|
|
6324
|
-
return useRoutesImpl(routes, void 0, state,
|
|
6490
|
+
return useRoutesImpl(routes, void 0, state, onError, future);
|
|
6325
6491
|
}
|
|
6326
6492
|
function MemoryRouter({
|
|
6327
6493
|
basename,
|
|
@@ -6362,7 +6528,7 @@ function MemoryRouter({
|
|
|
6362
6528
|
location: state.location,
|
|
6363
6529
|
navigationType: state.action,
|
|
6364
6530
|
navigator: history,
|
|
6365
|
-
unstable_useTransitions
|
|
6531
|
+
unstable_useTransitions
|
|
6366
6532
|
}
|
|
6367
6533
|
);
|
|
6368
6534
|
}
|
|
@@ -6481,8 +6647,8 @@ function Await({
|
|
|
6481
6647
|
let dataRouterStateContext = React3.useContext(DataRouterStateContext);
|
|
6482
6648
|
let onError = React3.useCallback(
|
|
6483
6649
|
(error, errorInfo) => {
|
|
6484
|
-
if (dataRouterContext && dataRouterContext.
|
|
6485
|
-
dataRouterContext.
|
|
6650
|
+
if (dataRouterContext && dataRouterContext.onError && dataRouterStateContext) {
|
|
6651
|
+
dataRouterContext.onError(error, {
|
|
6486
6652
|
location: dataRouterStateContext.location,
|
|
6487
6653
|
params: dataRouterStateContext.matches[0]?.params || {},
|
|
6488
6654
|
unstable_pattern: getRoutePattern(dataRouterStateContext.matches),
|
|
@@ -9479,11 +9645,11 @@ function BoundaryShell({
|
|
|
9479
9645
|
|
|
9480
9646
|
// lib/dom/lib.tsx
|
|
9481
9647
|
import * as React10 from "react";
|
|
9482
|
-
var
|
|
9648
|
+
var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
9483
9649
|
try {
|
|
9484
|
-
if (
|
|
9650
|
+
if (isBrowser2) {
|
|
9485
9651
|
window.__reactRouterVersion = // @ts-expect-error
|
|
9486
|
-
"7.
|
|
9652
|
+
"7.11.0-pre.0";
|
|
9487
9653
|
}
|
|
9488
9654
|
} catch (e) {
|
|
9489
9655
|
}
|
|
@@ -9598,7 +9764,7 @@ function BrowserRouter({
|
|
|
9598
9764
|
location: state.location,
|
|
9599
9765
|
navigationType: state.action,
|
|
9600
9766
|
navigator: history,
|
|
9601
|
-
unstable_useTransitions
|
|
9767
|
+
unstable_useTransitions
|
|
9602
9768
|
}
|
|
9603
9769
|
);
|
|
9604
9770
|
}
|
|
@@ -9636,7 +9802,7 @@ function HashRouter({
|
|
|
9636
9802
|
location: state.location,
|
|
9637
9803
|
navigationType: state.action,
|
|
9638
9804
|
navigator: history,
|
|
9639
|
-
unstable_useTransitions
|
|
9805
|
+
unstable_useTransitions
|
|
9640
9806
|
}
|
|
9641
9807
|
);
|
|
9642
9808
|
}
|
|
@@ -9669,7 +9835,7 @@ function HistoryRouter({
|
|
|
9669
9835
|
location: state.location,
|
|
9670
9836
|
navigationType: state.action,
|
|
9671
9837
|
navigator: history,
|
|
9672
|
-
unstable_useTransitions
|
|
9838
|
+
unstable_useTransitions
|
|
9673
9839
|
}
|
|
9674
9840
|
);
|
|
9675
9841
|
}
|
|
@@ -9688,32 +9854,13 @@ var Link = React10.forwardRef(
|
|
|
9688
9854
|
to,
|
|
9689
9855
|
preventScrollReset,
|
|
9690
9856
|
viewTransition,
|
|
9857
|
+
unstable_defaultShouldRevalidate,
|
|
9691
9858
|
...rest
|
|
9692
9859
|
}, forwardedRef) {
|
|
9693
9860
|
let { basename, unstable_useTransitions } = React10.useContext(NavigationContext);
|
|
9694
9861
|
let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to);
|
|
9695
|
-
let
|
|
9696
|
-
|
|
9697
|
-
if (typeof to === "string" && isAbsolute) {
|
|
9698
|
-
absoluteHref = to;
|
|
9699
|
-
if (isBrowser) {
|
|
9700
|
-
try {
|
|
9701
|
-
let currentUrl = new URL(window.location.href);
|
|
9702
|
-
let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
|
|
9703
|
-
let path = stripBasename(targetUrl.pathname, basename);
|
|
9704
|
-
if (targetUrl.origin === currentUrl.origin && path != null) {
|
|
9705
|
-
to = path + targetUrl.search + targetUrl.hash;
|
|
9706
|
-
} else {
|
|
9707
|
-
isExternal = true;
|
|
9708
|
-
}
|
|
9709
|
-
} catch (e) {
|
|
9710
|
-
warning(
|
|
9711
|
-
false,
|
|
9712
|
-
`<Link to="${to}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`
|
|
9713
|
-
);
|
|
9714
|
-
}
|
|
9715
|
-
}
|
|
9716
|
-
}
|
|
9862
|
+
let parsed = parseToInfo(to, basename);
|
|
9863
|
+
to = parsed.to;
|
|
9717
9864
|
let href = useHref(to, { relative });
|
|
9718
9865
|
let [shouldPrefetch, prefetchRef, prefetchHandlers] = usePrefetchBehavior(
|
|
9719
9866
|
prefetch,
|
|
@@ -9726,6 +9873,7 @@ var Link = React10.forwardRef(
|
|
|
9726
9873
|
preventScrollReset,
|
|
9727
9874
|
relative,
|
|
9728
9875
|
viewTransition,
|
|
9876
|
+
unstable_defaultShouldRevalidate,
|
|
9729
9877
|
unstable_useTransitions
|
|
9730
9878
|
});
|
|
9731
9879
|
function handleClick(event) {
|
|
@@ -9741,8 +9889,8 @@ var Link = React10.forwardRef(
|
|
|
9741
9889
|
{
|
|
9742
9890
|
...rest,
|
|
9743
9891
|
...prefetchHandlers,
|
|
9744
|
-
href:
|
|
9745
|
-
onClick: isExternal || reloadDocument ? onClick : handleClick,
|
|
9892
|
+
href: parsed.absoluteURL || href,
|
|
9893
|
+
onClick: parsed.isExternal || reloadDocument ? onClick : handleClick,
|
|
9746
9894
|
ref: mergeRefs(forwardedRef, prefetchRef),
|
|
9747
9895
|
target,
|
|
9748
9896
|
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
|
|
@@ -9834,6 +9982,7 @@ var Form = React10.forwardRef(
|
|
|
9834
9982
|
relative,
|
|
9835
9983
|
preventScrollReset,
|
|
9836
9984
|
viewTransition,
|
|
9985
|
+
unstable_defaultShouldRevalidate,
|
|
9837
9986
|
...props
|
|
9838
9987
|
}, forwardedRef) => {
|
|
9839
9988
|
let { unstable_useTransitions } = React10.useContext(NavigationContext);
|
|
@@ -9855,7 +10004,8 @@ var Form = React10.forwardRef(
|
|
|
9855
10004
|
state,
|
|
9856
10005
|
relative,
|
|
9857
10006
|
preventScrollReset,
|
|
9858
|
-
viewTransition
|
|
10007
|
+
viewTransition,
|
|
10008
|
+
unstable_defaultShouldRevalidate
|
|
9859
10009
|
});
|
|
9860
10010
|
if (unstable_useTransitions && navigate !== false) {
|
|
9861
10011
|
React10.startTransition(() => doSubmit());
|
|
@@ -9955,6 +10105,7 @@ function useLinkClickHandler(to, {
|
|
|
9955
10105
|
preventScrollReset,
|
|
9956
10106
|
relative,
|
|
9957
10107
|
viewTransition,
|
|
10108
|
+
unstable_defaultShouldRevalidate,
|
|
9958
10109
|
unstable_useTransitions
|
|
9959
10110
|
} = {}) {
|
|
9960
10111
|
let navigate = useNavigate();
|
|
@@ -9970,7 +10121,8 @@ function useLinkClickHandler(to, {
|
|
|
9970
10121
|
state,
|
|
9971
10122
|
preventScrollReset,
|
|
9972
10123
|
relative,
|
|
9973
|
-
viewTransition
|
|
10124
|
+
viewTransition,
|
|
10125
|
+
unstable_defaultShouldRevalidate
|
|
9974
10126
|
});
|
|
9975
10127
|
if (unstable_useTransitions) {
|
|
9976
10128
|
React10.startTransition(() => doNavigate());
|
|
@@ -9990,6 +10142,7 @@ function useLinkClickHandler(to, {
|
|
|
9990
10142
|
preventScrollReset,
|
|
9991
10143
|
relative,
|
|
9992
10144
|
viewTransition,
|
|
10145
|
+
unstable_defaultShouldRevalidate,
|
|
9993
10146
|
unstable_useTransitions
|
|
9994
10147
|
]
|
|
9995
10148
|
);
|
|
@@ -10044,6 +10197,7 @@ function useSubmit() {
|
|
|
10044
10197
|
if (options.navigate === false) {
|
|
10045
10198
|
let key = options.fetcherKey || getUniqueFetcherId();
|
|
10046
10199
|
await routerFetch(key, currentRouteId, options.action || action, {
|
|
10200
|
+
unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
|
|
10047
10201
|
preventScrollReset: options.preventScrollReset,
|
|
10048
10202
|
formData,
|
|
10049
10203
|
body,
|
|
@@ -10053,6 +10207,7 @@ function useSubmit() {
|
|
|
10053
10207
|
});
|
|
10054
10208
|
} else {
|
|
10055
10209
|
await routerNavigate(options.action || action, {
|
|
10210
|
+
unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
|
|
10056
10211
|
preventScrollReset: options.preventScrollReset,
|
|
10057
10212
|
formData,
|
|
10058
10213
|
body,
|
|
@@ -10667,6 +10822,8 @@ export {
|
|
|
10667
10822
|
LocationContext,
|
|
10668
10823
|
RouteContext,
|
|
10669
10824
|
ENABLE_DEV_WARNINGS,
|
|
10825
|
+
decodeRedirectErrorDigest,
|
|
10826
|
+
decodeRouteErrorResponseDigest,
|
|
10670
10827
|
useHref,
|
|
10671
10828
|
useInRouterContext,
|
|
10672
10829
|
useLocation,
|