react-router 7.9.6 → 7.10.0-pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +75 -10
- package/dist/development/{browser-BbBXFHbO.d.ts → browser-BpxEZgZC.d.ts} +1 -1
- package/dist/development/{browser-C07r42Tt.d.mts → browser-C5z6FZmz.d.mts} +1 -1
- package/dist/development/{chunk-4WY6JWTD.mjs → chunk-GIMUO62I.mjs} +208 -221
- package/dist/development/{chunk-AMVS5XVJ.js → chunk-KQLPIZ7E.js} +201 -258
- package/dist/development/{chunk-PZWDWJAY.js → chunk-RHWHYDYZ.js} +7 -7
- package/dist/development/{chunk-G3INQAYP.mjs → chunk-V5RTLP6E.mjs} +15 -5
- package/dist/development/{chunk-O4JVZSOY.js → chunk-XHWAND4X.js} +167 -123
- package/dist/development/dom-export.d.mts +29 -10
- package/dist/development/dom-export.d.ts +29 -10
- package/dist/development/dom-export.js +158 -103
- package/dist/development/dom-export.mjs +133 -79
- package/dist/{production/index-react-server-client-Da3kmxNd.d.ts → development/index-react-server-client-CCjKYJTH.d.ts} +75 -180
- package/dist/development/{index-react-server-client-rcoGPJhU.d.mts → index-react-server-client-CipGfVBI.d.mts} +75 -180
- 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 +19 -4
- package/dist/development/index-react-server.d.ts +19 -4
- package/dist/development/index-react-server.js +30 -24
- package/dist/development/index-react-server.mjs +30 -24
- package/dist/development/index.d.mts +19 -15
- package/dist/development/index.d.ts +19 -15
- package/dist/development/index.js +92 -82
- package/dist/development/index.mjs +3 -3
- package/dist/{production/instrumentation-Unc20tLk.d.ts → development/instrumentation-BB0wRuqz.d.ts} +93 -11
- 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-QkB3HGjm.d.mts → register-C1RwVJAt.d.mts} +1 -1
- package/dist/development/{register-BpU9rFBJ.d.ts → register-ODDAAYlf.d.ts} +1 -1
- package/dist/development/{router-CAvh_Drx.d.mts → router-CwNp5l9u.d.mts} +93 -11
- package/dist/production/{browser-BbBXFHbO.d.ts → browser-BpxEZgZC.d.ts} +1 -1
- package/dist/production/{browser-C07r42Tt.d.mts → browser-C5z6FZmz.d.mts} +1 -1
- package/dist/production/{chunk-QN64DHI4.js → chunk-3MVZKESN.js} +167 -123
- package/dist/production/{chunk-FUSXQSWG.mjs → chunk-7F5XUDXM.mjs} +208 -221
- package/dist/production/{chunk-EAIF67OW.js → chunk-C7S4I3K5.js} +201 -258
- package/dist/production/{chunk-FDUMZGKM.mjs → chunk-ISOIFGFA.mjs} +15 -5
- package/dist/production/{chunk-G5A35OQU.js → chunk-YU3WNS3T.js} +7 -7
- package/dist/production/dom-export.d.mts +29 -10
- package/dist/production/dom-export.d.ts +29 -10
- package/dist/production/dom-export.js +158 -103
- package/dist/production/dom-export.mjs +133 -79
- package/dist/{development/index-react-server-client-Da3kmxNd.d.ts → production/index-react-server-client-CCjKYJTH.d.ts} +75 -180
- package/dist/production/{index-react-server-client-rcoGPJhU.d.mts → index-react-server-client-CipGfVBI.d.mts} +75 -180
- 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 +19 -4
- package/dist/production/index-react-server.d.ts +19 -4
- package/dist/production/index-react-server.js +30 -24
- package/dist/production/index-react-server.mjs +30 -24
- package/dist/production/index.d.mts +19 -15
- package/dist/production/index.d.ts +19 -15
- package/dist/production/index.js +92 -82
- package/dist/production/index.mjs +3 -3
- package/dist/{development/instrumentation-Unc20tLk.d.ts → production/instrumentation-BB0wRuqz.d.ts} +93 -11
- 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-QkB3HGjm.d.mts → register-C1RwVJAt.d.mts} +1 -1
- package/dist/production/{register-BpU9rFBJ.d.ts → register-ODDAAYlf.d.ts} +1 -1
- package/dist/production/{router-CAvh_Drx.d.mts → router-CwNp5l9u.d.mts} +93 -11
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.
|
|
2
|
+
* react-router v7.10.0-pre.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -973,8 +973,8 @@ var ErrorResponseImpl = class {
|
|
|
973
973
|
function isRouteErrorResponse(error) {
|
|
974
974
|
return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
|
|
975
975
|
}
|
|
976
|
-
function getRoutePattern(
|
|
977
|
-
return
|
|
976
|
+
function getRoutePattern(matches) {
|
|
977
|
+
return matches.map((m) => m.route.path).filter(Boolean).join("/").replace(/\/\/*/g, "/") || "/";
|
|
978
978
|
}
|
|
979
979
|
|
|
980
980
|
// lib/router/instrumentation.ts
|
|
@@ -1411,6 +1411,7 @@ function createRouter(init) {
|
|
|
1411
1411
|
blockers: /* @__PURE__ */ new Map()
|
|
1412
1412
|
};
|
|
1413
1413
|
let pendingAction = "POP" /* Pop */;
|
|
1414
|
+
let pendingPopstateNavigationDfd = null;
|
|
1414
1415
|
let pendingPreventScrollReset = false;
|
|
1415
1416
|
let pendingNavigationController;
|
|
1416
1417
|
let pendingViewTransitionEnabled = false;
|
|
@@ -1470,6 +1471,8 @@ function createRouter(init) {
|
|
|
1470
1471
|
updateState({ blockers });
|
|
1471
1472
|
}
|
|
1472
1473
|
});
|
|
1474
|
+
pendingPopstateNavigationDfd?.resolve();
|
|
1475
|
+
pendingPopstateNavigationDfd = null;
|
|
1473
1476
|
return;
|
|
1474
1477
|
}
|
|
1475
1478
|
return startNavigation(historyAction, location);
|
|
@@ -1541,6 +1544,7 @@ function createRouter(init) {
|
|
|
1541
1544
|
[...subscribers].forEach(
|
|
1542
1545
|
(subscriber) => subscriber(state, {
|
|
1543
1546
|
deletedFetchers: unmountedFetchers,
|
|
1547
|
+
newErrors: newState.errors ?? null,
|
|
1544
1548
|
viewTransitionOpts: opts.viewTransitionOpts,
|
|
1545
1549
|
flushSync: opts.flushSync === true
|
|
1546
1550
|
})
|
|
@@ -1638,13 +1642,21 @@ function createRouter(init) {
|
|
|
1638
1642
|
pendingViewTransitionEnabled = false;
|
|
1639
1643
|
isUninterruptedRevalidation = false;
|
|
1640
1644
|
isRevalidationRequired = false;
|
|
1645
|
+
pendingPopstateNavigationDfd?.resolve();
|
|
1646
|
+
pendingPopstateNavigationDfd = null;
|
|
1641
1647
|
pendingRevalidationDfd?.resolve();
|
|
1642
1648
|
pendingRevalidationDfd = null;
|
|
1643
1649
|
}
|
|
1644
1650
|
async function navigate(to, opts) {
|
|
1651
|
+
pendingPopstateNavigationDfd?.resolve();
|
|
1652
|
+
pendingPopstateNavigationDfd = null;
|
|
1645
1653
|
if (typeof to === "number") {
|
|
1654
|
+
if (!pendingPopstateNavigationDfd) {
|
|
1655
|
+
pendingPopstateNavigationDfd = createDeferred();
|
|
1656
|
+
}
|
|
1657
|
+
let promise = pendingPopstateNavigationDfd.promise;
|
|
1646
1658
|
init.history.go(to);
|
|
1647
|
-
return;
|
|
1659
|
+
return promise;
|
|
1648
1660
|
}
|
|
1649
1661
|
let normalizedPath = normalizeTo(
|
|
1650
1662
|
state.location,
|
|
@@ -2584,6 +2596,10 @@ function createRouter(init) {
|
|
|
2584
2596
|
preventScrollReset,
|
|
2585
2597
|
replace: replace2
|
|
2586
2598
|
} = {}) {
|
|
2599
|
+
if (!isNavigation) {
|
|
2600
|
+
pendingPopstateNavigationDfd?.resolve();
|
|
2601
|
+
pendingPopstateNavigationDfd = null;
|
|
2602
|
+
}
|
|
2587
2603
|
if (redirect2.response.headers.has("X-Remix-Revalidate")) {
|
|
2588
2604
|
isRevalidationRequired = true;
|
|
2589
2605
|
}
|
|
@@ -3192,7 +3208,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3192
3208
|
let response = await runServerMiddlewarePipeline(
|
|
3193
3209
|
{
|
|
3194
3210
|
request,
|
|
3195
|
-
unstable_pattern: getRoutePattern(matches
|
|
3211
|
+
unstable_pattern: getRoutePattern(matches),
|
|
3196
3212
|
matches,
|
|
3197
3213
|
params: matches[0].params,
|
|
3198
3214
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -3338,7 +3354,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3338
3354
|
let response = await runServerMiddlewarePipeline(
|
|
3339
3355
|
{
|
|
3340
3356
|
request,
|
|
3341
|
-
unstable_pattern: getRoutePattern(matches
|
|
3357
|
+
unstable_pattern: getRoutePattern(matches),
|
|
3342
3358
|
matches,
|
|
3343
3359
|
params: matches[0].params,
|
|
3344
3360
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -3614,7 +3630,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3614
3630
|
// Up to but not including the boundary
|
|
3615
3631
|
matches.findIndex((m) => m.route.id === pendingActionResult[0]) - 1
|
|
3616
3632
|
) : void 0;
|
|
3617
|
-
let pattern = getRoutePattern(matches
|
|
3633
|
+
let pattern = getRoutePattern(matches);
|
|
3618
3634
|
dsMatches = matches.map((match, index) => {
|
|
3619
3635
|
if (maxIdx != null && index > maxIdx) {
|
|
3620
3636
|
return getDataStrategyMatch(
|
|
@@ -3913,7 +3929,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
3913
3929
|
actionResult,
|
|
3914
3930
|
actionStatus
|
|
3915
3931
|
};
|
|
3916
|
-
let pattern = getRoutePattern(matches
|
|
3932
|
+
let pattern = getRoutePattern(matches);
|
|
3917
3933
|
let dsMatches = matches.map((match, index) => {
|
|
3918
3934
|
let { route } = match;
|
|
3919
3935
|
let forceShouldLoad = null;
|
|
@@ -4397,7 +4413,7 @@ function runClientMiddlewarePipeline(args, handler) {
|
|
|
4397
4413
|
),
|
|
4398
4414
|
// or the shallowest route that needs to load data
|
|
4399
4415
|
Math.max(
|
|
4400
|
-
matches.findIndex((m) => m.
|
|
4416
|
+
matches.findIndex((m) => m.shouldCallHandler()),
|
|
4401
4417
|
0
|
|
4402
4418
|
)
|
|
4403
4419
|
);
|
|
@@ -4500,7 +4516,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request
|
|
|
4500
4516
|
handler: lazyRoutePromises.lazyHandlerPromise
|
|
4501
4517
|
};
|
|
4502
4518
|
}
|
|
4503
|
-
function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad,
|
|
4519
|
+
function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null) {
|
|
4504
4520
|
let isUsingNewApi = false;
|
|
4505
4521
|
let _lazyPromises = getDataStrategyMatchLazyPromises(
|
|
4506
4522
|
mapRouteProperties2,
|
|
@@ -4513,19 +4529,19 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_p
|
|
|
4513
4529
|
...match,
|
|
4514
4530
|
_lazyPromises,
|
|
4515
4531
|
shouldLoad,
|
|
4516
|
-
|
|
4517
|
-
|
|
4532
|
+
shouldRevalidateArgs,
|
|
4533
|
+
shouldCallHandler(defaultShouldRevalidate) {
|
|
4518
4534
|
isUsingNewApi = true;
|
|
4519
|
-
if (!
|
|
4535
|
+
if (!shouldRevalidateArgs) {
|
|
4520
4536
|
return shouldLoad;
|
|
4521
4537
|
}
|
|
4522
4538
|
if (typeof defaultShouldRevalidate === "boolean") {
|
|
4523
4539
|
return shouldRevalidateLoader(match, {
|
|
4524
|
-
...
|
|
4540
|
+
...shouldRevalidateArgs,
|
|
4525
4541
|
defaultShouldRevalidate
|
|
4526
4542
|
});
|
|
4527
4543
|
}
|
|
4528
|
-
return shouldRevalidateLoader(match,
|
|
4544
|
+
return shouldRevalidateLoader(match, shouldRevalidateArgs);
|
|
4529
4545
|
},
|
|
4530
4546
|
resolve(handlerOverride) {
|
|
4531
4547
|
let { lazy, loader, middleware } = match.route;
|
|
@@ -4552,8 +4568,8 @@ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request,
|
|
|
4552
4568
|
return {
|
|
4553
4569
|
...match,
|
|
4554
4570
|
shouldLoad: false,
|
|
4555
|
-
|
|
4556
|
-
|
|
4571
|
+
shouldRevalidateArgs,
|
|
4572
|
+
shouldCallHandler: () => false,
|
|
4557
4573
|
_lazyPromises: getDataStrategyMatchLazyPromises(
|
|
4558
4574
|
mapRouteProperties2,
|
|
4559
4575
|
manifest,
|
|
@@ -4568,7 +4584,7 @@ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request,
|
|
|
4568
4584
|
mapRouteProperties2,
|
|
4569
4585
|
manifest,
|
|
4570
4586
|
request,
|
|
4571
|
-
getRoutePattern(matches
|
|
4587
|
+
getRoutePattern(matches),
|
|
4572
4588
|
match,
|
|
4573
4589
|
lazyRoutePropertiesToSkip,
|
|
4574
4590
|
scopedContext,
|
|
@@ -4583,7 +4599,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4583
4599
|
}
|
|
4584
4600
|
let dataStrategyArgs = {
|
|
4585
4601
|
request,
|
|
4586
|
-
unstable_pattern: getRoutePattern(matches
|
|
4602
|
+
unstable_pattern: getRoutePattern(matches),
|
|
4587
4603
|
params: matches[0].params,
|
|
4588
4604
|
context: scopedContext,
|
|
4589
4605
|
matches
|
|
@@ -4766,11 +4782,7 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
|
|
|
4766
4782
|
}
|
|
4767
4783
|
return {
|
|
4768
4784
|
type: "error" /* error */,
|
|
4769
|
-
error:
|
|
4770
|
-
result.init?.status || 500,
|
|
4771
|
-
void 0,
|
|
4772
|
-
result.data
|
|
4773
|
-
),
|
|
4785
|
+
error: dataWithResponseInitToErrorResponse(result),
|
|
4774
4786
|
statusCode: isRouteErrorResponse(result) ? result.status : void 0,
|
|
4775
4787
|
headers: result.init?.headers ? new Headers(result.init.headers) : void 0
|
|
4776
4788
|
};
|
|
@@ -5721,6 +5733,7 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, uns
|
|
|
5721
5733
|
unstable_onError(error, {
|
|
5722
5734
|
location: dataRouterState.location,
|
|
5723
5735
|
params: dataRouterState.matches?.[0]?.params ?? {},
|
|
5736
|
+
unstable_pattern: getRoutePattern(dataRouterState.matches),
|
|
5724
5737
|
errorInfo
|
|
5725
5738
|
});
|
|
5726
5739
|
} : void 0;
|
|
@@ -5928,7 +5941,7 @@ function useNavigateStable() {
|
|
|
5928
5941
|
warning(activeRef.current, navigateEffectWarning);
|
|
5929
5942
|
if (!activeRef.current) return;
|
|
5930
5943
|
if (typeof to === "number") {
|
|
5931
|
-
router.navigate(to);
|
|
5944
|
+
await router.navigate(to);
|
|
5932
5945
|
} else {
|
|
5933
5946
|
await router.navigate(to, { fromRouteId: id, ...options });
|
|
5934
5947
|
}
|
|
@@ -5972,6 +5985,15 @@ function warnOnce(condition, message) {
|
|
|
5972
5985
|
}
|
|
5973
5986
|
|
|
5974
5987
|
// lib/components.tsx
|
|
5988
|
+
var USE_OPTIMISTIC = "useOptimistic";
|
|
5989
|
+
var useOptimisticImpl = React3[USE_OPTIMISTIC];
|
|
5990
|
+
function useOptimisticSafe(val) {
|
|
5991
|
+
if (useOptimisticImpl) {
|
|
5992
|
+
return useOptimisticImpl(val);
|
|
5993
|
+
} else {
|
|
5994
|
+
return [val, () => void 0];
|
|
5995
|
+
}
|
|
5996
|
+
}
|
|
5975
5997
|
function mapRouteProperties(route) {
|
|
5976
5998
|
let updates = {
|
|
5977
5999
|
// Note: this check also occurs in createRoutesFromChildren so update
|
|
@@ -6063,125 +6085,14 @@ var Deferred = class {
|
|
|
6063
6085
|
});
|
|
6064
6086
|
}
|
|
6065
6087
|
};
|
|
6066
|
-
function shallowDiff(a, b) {
|
|
6067
|
-
if (a === b) {
|
|
6068
|
-
return false;
|
|
6069
|
-
}
|
|
6070
|
-
let aKeys = Object.keys(a);
|
|
6071
|
-
let bKeys = Object.keys(b);
|
|
6072
|
-
if (aKeys.length !== bKeys.length) {
|
|
6073
|
-
return true;
|
|
6074
|
-
}
|
|
6075
|
-
for (let key of aKeys) {
|
|
6076
|
-
if (a[key] !== b[key]) {
|
|
6077
|
-
return true;
|
|
6078
|
-
}
|
|
6079
|
-
}
|
|
6080
|
-
return false;
|
|
6081
|
-
}
|
|
6082
|
-
function UNSTABLE_TransitionEnabledRouterProvider({
|
|
6083
|
-
router,
|
|
6084
|
-
flushSync: reactDomFlushSyncImpl,
|
|
6085
|
-
unstable_onError
|
|
6086
|
-
}) {
|
|
6087
|
-
let fetcherData = React3.useRef(/* @__PURE__ */ new Map());
|
|
6088
|
-
let [revalidating, startRevalidation] = React3.useTransition();
|
|
6089
|
-
let [state, setState] = React3.useState(router.state);
|
|
6090
|
-
router.__setPendingRerender = (promise) => startRevalidation(
|
|
6091
|
-
// @ts-expect-error - need react 19 types for this to be async
|
|
6092
|
-
async () => {
|
|
6093
|
-
const rerender = await promise;
|
|
6094
|
-
startRevalidation(() => {
|
|
6095
|
-
rerender();
|
|
6096
|
-
});
|
|
6097
|
-
}
|
|
6098
|
-
);
|
|
6099
|
-
let navigator = React3.useMemo(() => {
|
|
6100
|
-
return {
|
|
6101
|
-
createHref: router.createHref,
|
|
6102
|
-
encodeLocation: router.encodeLocation,
|
|
6103
|
-
go: (n) => router.navigate(n),
|
|
6104
|
-
push: (to, state2, opts) => router.navigate(to, {
|
|
6105
|
-
state: state2,
|
|
6106
|
-
preventScrollReset: opts?.preventScrollReset
|
|
6107
|
-
}),
|
|
6108
|
-
replace: (to, state2, opts) => router.navigate(to, {
|
|
6109
|
-
replace: true,
|
|
6110
|
-
state: state2,
|
|
6111
|
-
preventScrollReset: opts?.preventScrollReset
|
|
6112
|
-
})
|
|
6113
|
-
};
|
|
6114
|
-
}, [router]);
|
|
6115
|
-
let basename = router.basename || "/";
|
|
6116
|
-
let dataRouterContext = React3.useMemo(
|
|
6117
|
-
() => ({
|
|
6118
|
-
router,
|
|
6119
|
-
navigator,
|
|
6120
|
-
static: false,
|
|
6121
|
-
basename,
|
|
6122
|
-
unstable_onError
|
|
6123
|
-
}),
|
|
6124
|
-
[router, navigator, basename, unstable_onError]
|
|
6125
|
-
);
|
|
6126
|
-
React3.useLayoutEffect(() => {
|
|
6127
|
-
return router.subscribe(
|
|
6128
|
-
(newState, { deletedFetchers, flushSync, viewTransitionOpts }) => {
|
|
6129
|
-
newState.fetchers.forEach((fetcher, key) => {
|
|
6130
|
-
if (fetcher.data !== void 0) {
|
|
6131
|
-
fetcherData.current.set(key, fetcher.data);
|
|
6132
|
-
}
|
|
6133
|
-
});
|
|
6134
|
-
deletedFetchers.forEach((key) => fetcherData.current.delete(key));
|
|
6135
|
-
const diff = shallowDiff(state, newState);
|
|
6136
|
-
if (!diff) return;
|
|
6137
|
-
if (flushSync) {
|
|
6138
|
-
if (reactDomFlushSyncImpl) {
|
|
6139
|
-
reactDomFlushSyncImpl(() => setState(newState));
|
|
6140
|
-
} else {
|
|
6141
|
-
setState(newState);
|
|
6142
|
-
}
|
|
6143
|
-
} else {
|
|
6144
|
-
React3.startTransition(() => {
|
|
6145
|
-
setState(newState);
|
|
6146
|
-
});
|
|
6147
|
-
}
|
|
6148
|
-
}
|
|
6149
|
-
);
|
|
6150
|
-
}, [router, reactDomFlushSyncImpl, state]);
|
|
6151
|
-
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React3.createElement(
|
|
6152
|
-
DataRouterStateContext.Provider,
|
|
6153
|
-
{
|
|
6154
|
-
value: {
|
|
6155
|
-
...state,
|
|
6156
|
-
revalidation: revalidating ? "loading" : state.revalidation
|
|
6157
|
-
}
|
|
6158
|
-
},
|
|
6159
|
-
/* @__PURE__ */ React3.createElement(FetchersContext.Provider, { value: fetcherData.current }, /* @__PURE__ */ React3.createElement(
|
|
6160
|
-
Router,
|
|
6161
|
-
{
|
|
6162
|
-
basename,
|
|
6163
|
-
location: state.location,
|
|
6164
|
-
navigationType: state.historyAction,
|
|
6165
|
-
navigator
|
|
6166
|
-
},
|
|
6167
|
-
/* @__PURE__ */ React3.createElement(
|
|
6168
|
-
MemoizedDataRoutes,
|
|
6169
|
-
{
|
|
6170
|
-
routes: router.routes,
|
|
6171
|
-
future: router.future,
|
|
6172
|
-
state,
|
|
6173
|
-
unstable_onError
|
|
6174
|
-
}
|
|
6175
|
-
)
|
|
6176
|
-
))
|
|
6177
|
-
)), null);
|
|
6178
|
-
}
|
|
6179
6088
|
function RouterProvider({
|
|
6180
6089
|
router,
|
|
6181
6090
|
flushSync: reactDomFlushSyncImpl,
|
|
6182
|
-
unstable_onError
|
|
6091
|
+
unstable_onError,
|
|
6092
|
+
unstable_useTransitions
|
|
6183
6093
|
}) {
|
|
6184
|
-
let [
|
|
6094
|
+
let [_state, setStateImpl] = React3.useState(router.state);
|
|
6095
|
+
let [state, setOptimisticState] = useOptimisticSafe(_state);
|
|
6185
6096
|
let [pendingState, setPendingState] = React3.useState();
|
|
6186
6097
|
let [vtContext, setVtContext] = React3.useState({
|
|
6187
6098
|
isTransitioning: false
|
|
@@ -6190,26 +6101,17 @@ function RouterProvider({
|
|
|
6190
6101
|
let [transition, setTransition] = React3.useState();
|
|
6191
6102
|
let [interruption, setInterruption] = React3.useState();
|
|
6192
6103
|
let fetcherData = React3.useRef(/* @__PURE__ */ new Map());
|
|
6193
|
-
let logErrorsAndSetState = React3.useCallback(
|
|
6194
|
-
(newState) => {
|
|
6195
|
-
setStateImpl((prevState) => {
|
|
6196
|
-
if (newState.errors && unstable_onError) {
|
|
6197
|
-
Object.entries(newState.errors).forEach(([routeId, error]) => {
|
|
6198
|
-
if (prevState.errors?.[routeId] !== error) {
|
|
6199
|
-
unstable_onError(error, {
|
|
6200
|
-
location: newState.location,
|
|
6201
|
-
params: newState.matches[0]?.params ?? {}
|
|
6202
|
-
});
|
|
6203
|
-
}
|
|
6204
|
-
});
|
|
6205
|
-
}
|
|
6206
|
-
return newState;
|
|
6207
|
-
});
|
|
6208
|
-
},
|
|
6209
|
-
[unstable_onError]
|
|
6210
|
-
);
|
|
6211
6104
|
let setState = React3.useCallback(
|
|
6212
|
-
(newState, { deletedFetchers, flushSync, viewTransitionOpts }) => {
|
|
6105
|
+
(newState, { deletedFetchers, newErrors, flushSync, viewTransitionOpts }) => {
|
|
6106
|
+
if (newErrors && unstable_onError) {
|
|
6107
|
+
Object.values(newErrors).forEach(
|
|
6108
|
+
(error) => unstable_onError(error, {
|
|
6109
|
+
location: newState.location,
|
|
6110
|
+
params: newState.matches[0]?.params ?? {},
|
|
6111
|
+
unstable_pattern: getRoutePattern(newState.matches)
|
|
6112
|
+
})
|
|
6113
|
+
);
|
|
6114
|
+
}
|
|
6213
6115
|
newState.fetchers.forEach((fetcher, key) => {
|
|
6214
6116
|
if (fetcher.data !== void 0) {
|
|
6215
6117
|
fetcherData.current.set(key, fetcher.data);
|
|
@@ -6227,16 +6129,23 @@ function RouterProvider({
|
|
|
6227
6129
|
);
|
|
6228
6130
|
if (!viewTransitionOpts || !isViewTransitionAvailable) {
|
|
6229
6131
|
if (reactDomFlushSyncImpl && flushSync) {
|
|
6230
|
-
reactDomFlushSyncImpl(() =>
|
|
6132
|
+
reactDomFlushSyncImpl(() => setStateImpl(newState));
|
|
6133
|
+
} else if (unstable_useTransitions === false) {
|
|
6134
|
+
setStateImpl(newState);
|
|
6231
6135
|
} else {
|
|
6232
|
-
React3.startTransition(() =>
|
|
6136
|
+
React3.startTransition(() => {
|
|
6137
|
+
if (unstable_useTransitions === true) {
|
|
6138
|
+
setOptimisticState((s) => getOptimisticRouterState(s, newState));
|
|
6139
|
+
}
|
|
6140
|
+
setStateImpl(newState);
|
|
6141
|
+
});
|
|
6233
6142
|
}
|
|
6234
6143
|
return;
|
|
6235
6144
|
}
|
|
6236
6145
|
if (reactDomFlushSyncImpl && flushSync) {
|
|
6237
6146
|
reactDomFlushSyncImpl(() => {
|
|
6238
6147
|
if (transition) {
|
|
6239
|
-
renderDfd
|
|
6148
|
+
renderDfd?.resolve();
|
|
6240
6149
|
transition.skipTransition();
|
|
6241
6150
|
}
|
|
6242
6151
|
setVtContext({
|
|
@@ -6247,7 +6156,7 @@ function RouterProvider({
|
|
|
6247
6156
|
});
|
|
6248
6157
|
});
|
|
6249
6158
|
let t = router.window.document.startViewTransition(() => {
|
|
6250
|
-
reactDomFlushSyncImpl(() =>
|
|
6159
|
+
reactDomFlushSyncImpl(() => setStateImpl(newState));
|
|
6251
6160
|
});
|
|
6252
6161
|
t.finished.finally(() => {
|
|
6253
6162
|
reactDomFlushSyncImpl(() => {
|
|
@@ -6261,7 +6170,7 @@ function RouterProvider({
|
|
|
6261
6170
|
return;
|
|
6262
6171
|
}
|
|
6263
6172
|
if (transition) {
|
|
6264
|
-
renderDfd
|
|
6173
|
+
renderDfd?.resolve();
|
|
6265
6174
|
transition.skipTransition();
|
|
6266
6175
|
setInterruption({
|
|
6267
6176
|
state: newState,
|
|
@@ -6283,7 +6192,9 @@ function RouterProvider({
|
|
|
6283
6192
|
reactDomFlushSyncImpl,
|
|
6284
6193
|
transition,
|
|
6285
6194
|
renderDfd,
|
|
6286
|
-
|
|
6195
|
+
unstable_useTransitions,
|
|
6196
|
+
setOptimisticState,
|
|
6197
|
+
unstable_onError
|
|
6287
6198
|
]
|
|
6288
6199
|
);
|
|
6289
6200
|
React3.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
|
|
@@ -6297,7 +6208,16 @@ function RouterProvider({
|
|
|
6297
6208
|
let newState = pendingState;
|
|
6298
6209
|
let renderPromise = renderDfd.promise;
|
|
6299
6210
|
let transition2 = router.window.document.startViewTransition(async () => {
|
|
6300
|
-
|
|
6211
|
+
if (unstable_useTransitions === false) {
|
|
6212
|
+
setStateImpl(newState);
|
|
6213
|
+
} else {
|
|
6214
|
+
React3.startTransition(() => {
|
|
6215
|
+
if (unstable_useTransitions === true) {
|
|
6216
|
+
setOptimisticState((s) => getOptimisticRouterState(s, newState));
|
|
6217
|
+
}
|
|
6218
|
+
setStateImpl(newState);
|
|
6219
|
+
});
|
|
6220
|
+
}
|
|
6301
6221
|
await renderPromise;
|
|
6302
6222
|
});
|
|
6303
6223
|
transition2.finished.finally(() => {
|
|
@@ -6308,7 +6228,13 @@ function RouterProvider({
|
|
|
6308
6228
|
});
|
|
6309
6229
|
setTransition(transition2);
|
|
6310
6230
|
}
|
|
6311
|
-
}, [
|
|
6231
|
+
}, [
|
|
6232
|
+
pendingState,
|
|
6233
|
+
renderDfd,
|
|
6234
|
+
router.window,
|
|
6235
|
+
unstable_useTransitions,
|
|
6236
|
+
setOptimisticState
|
|
6237
|
+
]);
|
|
6312
6238
|
React3.useEffect(() => {
|
|
6313
6239
|
if (renderDfd && pendingState && state.location.key === pendingState.location.key) {
|
|
6314
6240
|
renderDfd.resolve();
|
|
@@ -6359,7 +6285,8 @@ function RouterProvider({
|
|
|
6359
6285
|
basename,
|
|
6360
6286
|
location: state.location,
|
|
6361
6287
|
navigationType: state.historyAction,
|
|
6362
|
-
navigator
|
|
6288
|
+
navigator,
|
|
6289
|
+
unstable_useTransitions: unstable_useTransitions === true
|
|
6363
6290
|
},
|
|
6364
6291
|
/* @__PURE__ */ React3.createElement(
|
|
6365
6292
|
MemoizedDataRoutes,
|
|
@@ -6372,6 +6299,20 @@ function RouterProvider({
|
|
|
6372
6299
|
)
|
|
6373
6300
|
))))), null);
|
|
6374
6301
|
}
|
|
6302
|
+
function getOptimisticRouterState(currentState, newState) {
|
|
6303
|
+
return {
|
|
6304
|
+
// Don't surface "current location specific" stuff mid-navigation
|
|
6305
|
+
// (historyAction, location, matches, loaderData, errors, initialized,
|
|
6306
|
+
// restoreScroll, preventScrollReset, blockers, etc.)
|
|
6307
|
+
...currentState,
|
|
6308
|
+
// Only surface "pending/in-flight stuff"
|
|
6309
|
+
// (navigation, revalidation, actionData, fetchers, )
|
|
6310
|
+
navigation: newState.navigation.state !== "idle" ? newState.navigation : currentState.navigation,
|
|
6311
|
+
revalidation: newState.revalidation !== "idle" ? newState.revalidation : currentState.revalidation,
|
|
6312
|
+
actionData: newState.navigation.state !== "submitting" ? newState.actionData : currentState.actionData,
|
|
6313
|
+
fetchers: newState.fetchers
|
|
6314
|
+
};
|
|
6315
|
+
}
|
|
6375
6316
|
var MemoizedDataRoutes = React3.memo(DataRoutes);
|
|
6376
6317
|
function DataRoutes({
|
|
6377
6318
|
routes,
|
|
@@ -6385,7 +6326,8 @@ function MemoryRouter({
|
|
|
6385
6326
|
basename,
|
|
6386
6327
|
children,
|
|
6387
6328
|
initialEntries,
|
|
6388
|
-
initialIndex
|
|
6329
|
+
initialIndex,
|
|
6330
|
+
unstable_useTransitions
|
|
6389
6331
|
}) {
|
|
6390
6332
|
let historyRef = React3.useRef();
|
|
6391
6333
|
if (historyRef.current == null) {
|
|
@@ -6402,9 +6344,13 @@ function MemoryRouter({
|
|
|
6402
6344
|
});
|
|
6403
6345
|
let setState = React3.useCallback(
|
|
6404
6346
|
(newState) => {
|
|
6405
|
-
|
|
6347
|
+
if (unstable_useTransitions === false) {
|
|
6348
|
+
setStateImpl(newState);
|
|
6349
|
+
} else {
|
|
6350
|
+
React3.startTransition(() => setStateImpl(newState));
|
|
6351
|
+
}
|
|
6406
6352
|
},
|
|
6407
|
-
[
|
|
6353
|
+
[unstable_useTransitions]
|
|
6408
6354
|
);
|
|
6409
6355
|
React3.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
6410
6356
|
return /* @__PURE__ */ React3.createElement(
|
|
@@ -6414,7 +6360,8 @@ function MemoryRouter({
|
|
|
6414
6360
|
children,
|
|
6415
6361
|
location: state.location,
|
|
6416
6362
|
navigationType: state.action,
|
|
6417
|
-
navigator: history
|
|
6363
|
+
navigator: history,
|
|
6364
|
+
unstable_useTransitions: unstable_useTransitions === true
|
|
6418
6365
|
}
|
|
6419
6366
|
);
|
|
6420
6367
|
}
|
|
@@ -6465,7 +6412,8 @@ function Router({
|
|
|
6465
6412
|
location: locationProp,
|
|
6466
6413
|
navigationType = "POP" /* Pop */,
|
|
6467
6414
|
navigator,
|
|
6468
|
-
static: staticProp = false
|
|
6415
|
+
static: staticProp = false,
|
|
6416
|
+
unstable_useTransitions
|
|
6469
6417
|
}) {
|
|
6470
6418
|
invariant(
|
|
6471
6419
|
!useInRouterContext(),
|
|
@@ -6477,9 +6425,10 @@ function Router({
|
|
|
6477
6425
|
basename,
|
|
6478
6426
|
navigator,
|
|
6479
6427
|
static: staticProp,
|
|
6428
|
+
unstable_useTransitions,
|
|
6480
6429
|
future: {}
|
|
6481
6430
|
}),
|
|
6482
|
-
[basename, navigator, staticProp]
|
|
6431
|
+
[basename, navigator, staticProp, unstable_useTransitions]
|
|
6483
6432
|
);
|
|
6484
6433
|
if (typeof locationProp === "string") {
|
|
6485
6434
|
locationProp = parsePath(locationProp);
|
|
@@ -6534,7 +6483,8 @@ function Await({
|
|
|
6534
6483
|
if (dataRouterContext && dataRouterContext.unstable_onError && dataRouterStateContext) {
|
|
6535
6484
|
dataRouterContext.unstable_onError(error, {
|
|
6536
6485
|
location: dataRouterStateContext.location,
|
|
6537
|
-
params: dataRouterStateContext.matches
|
|
6486
|
+
params: dataRouterStateContext.matches[0]?.params || {},
|
|
6487
|
+
unstable_pattern: getRoutePattern(dataRouterStateContext.matches),
|
|
6538
6488
|
errorInfo
|
|
6539
6489
|
});
|
|
6540
6490
|
}
|
|
@@ -6738,7 +6688,7 @@ function withErrorBoundaryProps(ErrorBoundary) {
|
|
|
6738
6688
|
var defaultMethod = "get";
|
|
6739
6689
|
var defaultEncType = "application/x-www-form-urlencoded";
|
|
6740
6690
|
function isHtmlElement(object) {
|
|
6741
|
-
return
|
|
6691
|
+
return typeof HTMLElement !== "undefined" && object instanceof HTMLElement;
|
|
6742
6692
|
}
|
|
6743
6693
|
function isButtonElement(object) {
|
|
6744
6694
|
return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
|
|
@@ -7672,7 +7622,7 @@ function getSingleFetchDataStrategyImpl(getRouter, getRouteInfo, fetchAndDecode,
|
|
|
7672
7622
|
}
|
|
7673
7623
|
let foundRevalidatingServerLoader = matches.some((m) => {
|
|
7674
7624
|
let { hasLoader, hasClientLoader } = getRouteInfo(m);
|
|
7675
|
-
return m.
|
|
7625
|
+
return m.shouldCallHandler() && hasLoader && !hasClientLoader;
|
|
7676
7626
|
});
|
|
7677
7627
|
if (!ssr && !foundRevalidatingServerLoader) {
|
|
7678
7628
|
return nonSsrStrategy(args, getRouteInfo, fetchAndDecode, basename);
|
|
@@ -7692,7 +7642,7 @@ function getSingleFetchDataStrategyImpl(getRouter, getRouteInfo, fetchAndDecode,
|
|
|
7692
7642
|
};
|
|
7693
7643
|
}
|
|
7694
7644
|
async function singleFetchActionStrategy(args, fetchAndDecode, basename) {
|
|
7695
|
-
let actionMatch = args.matches.find((m) => m.
|
|
7645
|
+
let actionMatch = args.matches.find((m) => m.shouldCallHandler());
|
|
7696
7646
|
invariant2(actionMatch, "No action match found");
|
|
7697
7647
|
let actionStatus = void 0;
|
|
7698
7648
|
let result = await actionMatch.resolve(async (handler) => {
|
|
@@ -7716,9 +7666,7 @@ async function singleFetchActionStrategy(args, fetchAndDecode, basename) {
|
|
|
7716
7666
|
};
|
|
7717
7667
|
}
|
|
7718
7668
|
async function nonSsrStrategy(args, getRouteInfo, fetchAndDecode, basename) {
|
|
7719
|
-
let matchesToLoad = args.matches.filter(
|
|
7720
|
-
(m) => m.unstable_shouldCallHandler()
|
|
7721
|
-
);
|
|
7669
|
+
let matchesToLoad = args.matches.filter((m) => m.shouldCallHandler());
|
|
7722
7670
|
let results = {};
|
|
7723
7671
|
await Promise.all(
|
|
7724
7672
|
matchesToLoad.map(
|
|
@@ -7751,10 +7699,10 @@ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, f
|
|
|
7751
7699
|
routeDfds[i].resolve();
|
|
7752
7700
|
let routeId = m.route.id;
|
|
7753
7701
|
let { hasLoader, hasClientLoader, hasShouldRevalidate } = getRouteInfo(m);
|
|
7754
|
-
let defaultShouldRevalidate = !m.
|
|
7755
|
-
let shouldCall = m.
|
|
7702
|
+
let defaultShouldRevalidate = !m.shouldRevalidateArgs || m.shouldRevalidateArgs.actionStatus == null || m.shouldRevalidateArgs.actionStatus < 400;
|
|
7703
|
+
let shouldCall = m.shouldCallHandler(defaultShouldRevalidate);
|
|
7756
7704
|
if (!shouldCall) {
|
|
7757
|
-
foundOptOutRoute || (foundOptOutRoute = m.
|
|
7705
|
+
foundOptOutRoute || (foundOptOutRoute = m.shouldRevalidateArgs != null && // This is a revalidation,
|
|
7758
7706
|
hasLoader && // for a route with a server loader,
|
|
7759
7707
|
hasShouldRevalidate === true);
|
|
7760
7708
|
return;
|
|
@@ -7843,7 +7791,7 @@ async function bubbleMiddlewareErrors(singleFetchPromise, matches, routesParams,
|
|
|
7843
7791
|
}
|
|
7844
7792
|
}
|
|
7845
7793
|
async function singleFetchLoaderFetcherStrategy(args, fetchAndDecode, basename) {
|
|
7846
|
-
let fetcherMatch = args.matches.find((m) => m.
|
|
7794
|
+
let fetcherMatch = args.matches.find((m) => m.shouldCallHandler());
|
|
7847
7795
|
invariant2(fetcherMatch, "No fetcher match found");
|
|
7848
7796
|
let routeId = fetcherMatch.route.id;
|
|
7849
7797
|
let result = await fetcherMatch.resolve(
|
|
@@ -8662,10 +8610,6 @@ function getShouldRevalidateFunction(path, route, manifestRoute, ssr, needsReval
|
|
|
8662
8610
|
return (opts) => didParamsChange(opts);
|
|
8663
8611
|
}
|
|
8664
8612
|
}
|
|
8665
|
-
if (ssr && route.shouldRevalidate) {
|
|
8666
|
-
let fn = route.shouldRevalidate;
|
|
8667
|
-
return (opts) => fn({ ...opts, defaultShouldRevalidate: true });
|
|
8668
|
-
}
|
|
8669
8613
|
return route.shouldRevalidate;
|
|
8670
8614
|
}
|
|
8671
8615
|
function wrapShouldRevalidateForHdr(routeId, routeShouldRevalidate, needsRevalidation) {
|
|
@@ -9538,7 +9482,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
9538
9482
|
try {
|
|
9539
9483
|
if (isBrowser) {
|
|
9540
9484
|
window.__reactRouterVersion = // @ts-expect-error
|
|
9541
|
-
"7.
|
|
9485
|
+
"7.10.0-pre.1";
|
|
9542
9486
|
}
|
|
9543
9487
|
} catch (e) {
|
|
9544
9488
|
}
|
|
@@ -9622,6 +9566,7 @@ function deserializeErrors(errors) {
|
|
|
9622
9566
|
function BrowserRouter({
|
|
9623
9567
|
basename,
|
|
9624
9568
|
children,
|
|
9569
|
+
unstable_useTransitions,
|
|
9625
9570
|
window: window2
|
|
9626
9571
|
}) {
|
|
9627
9572
|
let historyRef = React10.useRef();
|
|
@@ -9635,9 +9580,13 @@ function BrowserRouter({
|
|
|
9635
9580
|
});
|
|
9636
9581
|
let setState = React10.useCallback(
|
|
9637
9582
|
(newState) => {
|
|
9638
|
-
|
|
9583
|
+
if (unstable_useTransitions === false) {
|
|
9584
|
+
setStateImpl(newState);
|
|
9585
|
+
} else {
|
|
9586
|
+
React10.startTransition(() => setStateImpl(newState));
|
|
9587
|
+
}
|
|
9639
9588
|
},
|
|
9640
|
-
[
|
|
9589
|
+
[unstable_useTransitions]
|
|
9641
9590
|
);
|
|
9642
9591
|
React10.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
9643
9592
|
return /* @__PURE__ */ React10.createElement(
|
|
@@ -9647,11 +9596,17 @@ function BrowserRouter({
|
|
|
9647
9596
|
children,
|
|
9648
9597
|
location: state.location,
|
|
9649
9598
|
navigationType: state.action,
|
|
9650
|
-
navigator: history
|
|
9599
|
+
navigator: history,
|
|
9600
|
+
unstable_useTransitions: unstable_useTransitions === true
|
|
9651
9601
|
}
|
|
9652
9602
|
);
|
|
9653
9603
|
}
|
|
9654
|
-
function HashRouter({
|
|
9604
|
+
function HashRouter({
|
|
9605
|
+
basename,
|
|
9606
|
+
children,
|
|
9607
|
+
unstable_useTransitions,
|
|
9608
|
+
window: window2
|
|
9609
|
+
}) {
|
|
9655
9610
|
let historyRef = React10.useRef();
|
|
9656
9611
|
if (historyRef.current == null) {
|
|
9657
9612
|
historyRef.current = createHashHistory({ window: window2, v5Compat: true });
|
|
@@ -9663,9 +9618,13 @@ function HashRouter({ basename, children, window: window2 }) {
|
|
|
9663
9618
|
});
|
|
9664
9619
|
let setState = React10.useCallback(
|
|
9665
9620
|
(newState) => {
|
|
9666
|
-
|
|
9621
|
+
if (unstable_useTransitions === false) {
|
|
9622
|
+
setStateImpl(newState);
|
|
9623
|
+
} else {
|
|
9624
|
+
React10.startTransition(() => setStateImpl(newState));
|
|
9625
|
+
}
|
|
9667
9626
|
},
|
|
9668
|
-
[
|
|
9627
|
+
[unstable_useTransitions]
|
|
9669
9628
|
);
|
|
9670
9629
|
React10.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
9671
9630
|
return /* @__PURE__ */ React10.createElement(
|
|
@@ -9675,14 +9634,16 @@ function HashRouter({ basename, children, window: window2 }) {
|
|
|
9675
9634
|
children,
|
|
9676
9635
|
location: state.location,
|
|
9677
9636
|
navigationType: state.action,
|
|
9678
|
-
navigator: history
|
|
9637
|
+
navigator: history,
|
|
9638
|
+
unstable_useTransitions: unstable_useTransitions === true
|
|
9679
9639
|
}
|
|
9680
9640
|
);
|
|
9681
9641
|
}
|
|
9682
9642
|
function HistoryRouter({
|
|
9683
9643
|
basename,
|
|
9684
9644
|
children,
|
|
9685
|
-
history
|
|
9645
|
+
history,
|
|
9646
|
+
unstable_useTransitions
|
|
9686
9647
|
}) {
|
|
9687
9648
|
let [state, setStateImpl] = React10.useState({
|
|
9688
9649
|
action: history.action,
|
|
@@ -9690,9 +9651,13 @@ function HistoryRouter({
|
|
|
9690
9651
|
});
|
|
9691
9652
|
let setState = React10.useCallback(
|
|
9692
9653
|
(newState) => {
|
|
9693
|
-
|
|
9654
|
+
if (unstable_useTransitions === false) {
|
|
9655
|
+
setStateImpl(newState);
|
|
9656
|
+
} else {
|
|
9657
|
+
React10.startTransition(() => setStateImpl(newState));
|
|
9658
|
+
}
|
|
9694
9659
|
},
|
|
9695
|
-
[
|
|
9660
|
+
[unstable_useTransitions]
|
|
9696
9661
|
);
|
|
9697
9662
|
React10.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
9698
9663
|
return /* @__PURE__ */ React10.createElement(
|
|
@@ -9702,7 +9667,8 @@ function HistoryRouter({
|
|
|
9702
9667
|
children,
|
|
9703
9668
|
location: state.location,
|
|
9704
9669
|
navigationType: state.action,
|
|
9705
|
-
navigator: history
|
|
9670
|
+
navigator: history,
|
|
9671
|
+
unstable_useTransitions: unstable_useTransitions === true
|
|
9706
9672
|
}
|
|
9707
9673
|
);
|
|
9708
9674
|
}
|
|
@@ -9723,7 +9689,7 @@ var Link = React10.forwardRef(
|
|
|
9723
9689
|
viewTransition,
|
|
9724
9690
|
...rest
|
|
9725
9691
|
}, forwardedRef) {
|
|
9726
|
-
let { basename } = React10.useContext(NavigationContext);
|
|
9692
|
+
let { basename, unstable_useTransitions } = React10.useContext(NavigationContext);
|
|
9727
9693
|
let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to);
|
|
9728
9694
|
let absoluteHref;
|
|
9729
9695
|
let isExternal = false;
|
|
@@ -9758,7 +9724,8 @@ var Link = React10.forwardRef(
|
|
|
9758
9724
|
target,
|
|
9759
9725
|
preventScrollReset,
|
|
9760
9726
|
relative,
|
|
9761
|
-
viewTransition
|
|
9727
|
+
viewTransition,
|
|
9728
|
+
unstable_useTransitions
|
|
9762
9729
|
});
|
|
9763
9730
|
function handleClick(event) {
|
|
9764
9731
|
if (onClick) onClick(event);
|
|
@@ -9868,6 +9835,7 @@ var Form = React10.forwardRef(
|
|
|
9868
9835
|
viewTransition,
|
|
9869
9836
|
...props
|
|
9870
9837
|
}, forwardedRef) => {
|
|
9838
|
+
let { unstable_useTransitions } = React10.useContext(NavigationContext);
|
|
9871
9839
|
let submit = useSubmit();
|
|
9872
9840
|
let formAction = useFormAction(action, { relative });
|
|
9873
9841
|
let formMethod = method.toLowerCase() === "get" ? "get" : "post";
|
|
@@ -9878,7 +9846,7 @@ var Form = React10.forwardRef(
|
|
|
9878
9846
|
event.preventDefault();
|
|
9879
9847
|
let submitter = event.nativeEvent.submitter;
|
|
9880
9848
|
let submitMethod = submitter?.getAttribute("formmethod") || method;
|
|
9881
|
-
submit(submitter || event.currentTarget, {
|
|
9849
|
+
let doSubmit = () => submit(submitter || event.currentTarget, {
|
|
9882
9850
|
fetcherKey,
|
|
9883
9851
|
method: submitMethod,
|
|
9884
9852
|
navigate,
|
|
@@ -9888,6 +9856,11 @@ var Form = React10.forwardRef(
|
|
|
9888
9856
|
preventScrollReset,
|
|
9889
9857
|
viewTransition
|
|
9890
9858
|
});
|
|
9859
|
+
if (unstable_useTransitions && navigate !== false) {
|
|
9860
|
+
React10.startTransition(() => doSubmit());
|
|
9861
|
+
} else {
|
|
9862
|
+
doSubmit();
|
|
9863
|
+
}
|
|
9891
9864
|
};
|
|
9892
9865
|
return /* @__PURE__ */ React10.createElement(
|
|
9893
9866
|
"form",
|
|
@@ -9980,7 +9953,8 @@ function useLinkClickHandler(to, {
|
|
|
9980
9953
|
state,
|
|
9981
9954
|
preventScrollReset,
|
|
9982
9955
|
relative,
|
|
9983
|
-
viewTransition
|
|
9956
|
+
viewTransition,
|
|
9957
|
+
unstable_useTransitions
|
|
9984
9958
|
} = {}) {
|
|
9985
9959
|
let navigate = useNavigate();
|
|
9986
9960
|
let location = useLocation();
|
|
@@ -9990,13 +9964,18 @@ function useLinkClickHandler(to, {
|
|
|
9990
9964
|
if (shouldProcessLinkClick(event, target)) {
|
|
9991
9965
|
event.preventDefault();
|
|
9992
9966
|
let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
|
|
9993
|
-
navigate(to, {
|
|
9967
|
+
let doNavigate = () => navigate(to, {
|
|
9994
9968
|
replace: replace2,
|
|
9995
9969
|
state,
|
|
9996
9970
|
preventScrollReset,
|
|
9997
9971
|
relative,
|
|
9998
9972
|
viewTransition
|
|
9999
9973
|
});
|
|
9974
|
+
if (unstable_useTransitions) {
|
|
9975
|
+
React10.startTransition(() => doNavigate());
|
|
9976
|
+
} else {
|
|
9977
|
+
doNavigate();
|
|
9978
|
+
}
|
|
10000
9979
|
}
|
|
10001
9980
|
},
|
|
10002
9981
|
[
|
|
@@ -10009,7 +9988,8 @@ function useLinkClickHandler(to, {
|
|
|
10009
9988
|
to,
|
|
10010
9989
|
preventScrollReset,
|
|
10011
9990
|
relative,
|
|
10012
|
-
viewTransition
|
|
9991
|
+
viewTransition,
|
|
9992
|
+
unstable_useTransitions
|
|
10013
9993
|
]
|
|
10014
9994
|
);
|
|
10015
9995
|
}
|
|
@@ -10052,6 +10032,8 @@ function useSubmit() {
|
|
|
10052
10032
|
let { router } = useDataRouterContext3("useSubmit" /* UseSubmit */);
|
|
10053
10033
|
let { basename } = React10.useContext(NavigationContext);
|
|
10054
10034
|
let currentRouteId = useRouteId();
|
|
10035
|
+
let routerFetch = router.fetch;
|
|
10036
|
+
let routerNavigate = router.navigate;
|
|
10055
10037
|
return React10.useCallback(
|
|
10056
10038
|
async (target, options = {}) => {
|
|
10057
10039
|
let { action, method, encType, formData, body } = getFormSubmissionInfo(
|
|
@@ -10060,7 +10042,7 @@ function useSubmit() {
|
|
|
10060
10042
|
);
|
|
10061
10043
|
if (options.navigate === false) {
|
|
10062
10044
|
let key = options.fetcherKey || getUniqueFetcherId();
|
|
10063
|
-
await
|
|
10045
|
+
await routerFetch(key, currentRouteId, options.action || action, {
|
|
10064
10046
|
preventScrollReset: options.preventScrollReset,
|
|
10065
10047
|
formData,
|
|
10066
10048
|
body,
|
|
@@ -10069,7 +10051,7 @@ function useSubmit() {
|
|
|
10069
10051
|
flushSync: options.flushSync
|
|
10070
10052
|
});
|
|
10071
10053
|
} else {
|
|
10072
|
-
await
|
|
10054
|
+
await routerNavigate(options.action || action, {
|
|
10073
10055
|
preventScrollReset: options.preventScrollReset,
|
|
10074
10056
|
formData,
|
|
10075
10057
|
body,
|
|
@@ -10083,7 +10065,7 @@ function useSubmit() {
|
|
|
10083
10065
|
});
|
|
10084
10066
|
}
|
|
10085
10067
|
},
|
|
10086
|
-
[
|
|
10068
|
+
[routerFetch, routerNavigate, basename, currentRouteId]
|
|
10087
10069
|
);
|
|
10088
10070
|
}
|
|
10089
10071
|
function useFormAction(action, { relative } = {}) {
|
|
@@ -10132,16 +10114,17 @@ function useFetcher({
|
|
|
10132
10114
|
if (key && key !== fetcherKey) {
|
|
10133
10115
|
setFetcherKey(key);
|
|
10134
10116
|
}
|
|
10117
|
+
let { deleteFetcher, getFetcher, resetFetcher, fetch: routerFetch } = router;
|
|
10135
10118
|
React10.useEffect(() => {
|
|
10136
|
-
|
|
10137
|
-
return () =>
|
|
10138
|
-
}, [
|
|
10119
|
+
getFetcher(fetcherKey);
|
|
10120
|
+
return () => deleteFetcher(fetcherKey);
|
|
10121
|
+
}, [deleteFetcher, getFetcher, fetcherKey]);
|
|
10139
10122
|
let load = React10.useCallback(
|
|
10140
10123
|
async (href, opts) => {
|
|
10141
10124
|
invariant(routeId, "No routeId available for fetcher.load()");
|
|
10142
|
-
await
|
|
10125
|
+
await routerFetch(fetcherKey, routeId, href, opts);
|
|
10143
10126
|
},
|
|
10144
|
-
[fetcherKey, routeId,
|
|
10127
|
+
[fetcherKey, routeId, routerFetch]
|
|
10145
10128
|
);
|
|
10146
10129
|
let submitImpl = useSubmit();
|
|
10147
10130
|
let submit = React10.useCallback(
|
|
@@ -10154,7 +10137,10 @@ function useFetcher({
|
|
|
10154
10137
|
},
|
|
10155
10138
|
[fetcherKey, submitImpl]
|
|
10156
10139
|
);
|
|
10157
|
-
let
|
|
10140
|
+
let reset = React10.useCallback(
|
|
10141
|
+
(opts) => resetFetcher(fetcherKey, opts),
|
|
10142
|
+
[resetFetcher, fetcherKey]
|
|
10143
|
+
);
|
|
10158
10144
|
let FetcherForm = React10.useMemo(() => {
|
|
10159
10145
|
let FetcherForm2 = React10.forwardRef(
|
|
10160
10146
|
(props, ref) => {
|
|
@@ -10171,11 +10157,11 @@ function useFetcher({
|
|
|
10171
10157
|
Form: FetcherForm,
|
|
10172
10158
|
submit,
|
|
10173
10159
|
load,
|
|
10174
|
-
|
|
10160
|
+
reset,
|
|
10175
10161
|
...fetcher,
|
|
10176
10162
|
data: data2
|
|
10177
10163
|
}),
|
|
10178
|
-
[FetcherForm, submit, load,
|
|
10164
|
+
[FetcherForm, submit, load, reset, fetcher, data2]
|
|
10179
10165
|
);
|
|
10180
10166
|
return fetcherWithComponents;
|
|
10181
10167
|
}
|
|
@@ -10385,7 +10371,8 @@ function StaticRouter({
|
|
|
10385
10371
|
location,
|
|
10386
10372
|
navigationType: action,
|
|
10387
10373
|
navigator: staticNavigator,
|
|
10388
|
-
static: true
|
|
10374
|
+
static: true,
|
|
10375
|
+
unstable_useTransitions: false
|
|
10389
10376
|
}
|
|
10390
10377
|
);
|
|
10391
10378
|
}
|
|
@@ -10425,7 +10412,8 @@ function StaticRouterProvider({
|
|
|
10425
10412
|
location: state.location,
|
|
10426
10413
|
navigationType: state.historyAction,
|
|
10427
10414
|
navigator: dataRouterContext.navigator,
|
|
10428
|
-
static: dataRouterContext.static
|
|
10415
|
+
static: dataRouterContext.static,
|
|
10416
|
+
unstable_useTransitions: false
|
|
10429
10417
|
},
|
|
10430
10418
|
/* @__PURE__ */ React11.createElement(
|
|
10431
10419
|
DataRoutes2,
|
|
@@ -10704,7 +10692,6 @@ export {
|
|
|
10704
10692
|
mapRouteProperties,
|
|
10705
10693
|
hydrationRouteProperties,
|
|
10706
10694
|
createMemoryRouter,
|
|
10707
|
-
UNSTABLE_TransitionEnabledRouterProvider,
|
|
10708
10695
|
RouterProvider,
|
|
10709
10696
|
MemoryRouter,
|
|
10710
10697
|
Navigate,
|