@remix-run/router 1.17.0 → 1.17.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 +7 -0
- package/dist/router.cjs.js +49 -13
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +2 -1
- package/dist/router.js +46 -13
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +49 -13
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +2 -2
- package/dist/router.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/router.ts +66 -19
- package/utils.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# `@remix-run/router`
|
|
2
2
|
|
|
3
|
+
## 1.17.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fog of War (unstable): Trigger a new `router.routes` identity/reflow during route patching ([#11740](https://github.com/remix-run/react-router/pull/11740))
|
|
8
|
+
- Fog of War (unstable): Fix initial matching when a splat route matches ([#11759](https://github.com/remix-run/react-router/pull/11759))
|
|
9
|
+
|
|
3
10
|
## 1.17.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
package/dist/router.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.17.
|
|
2
|
+
* @remix-run/router v1.17.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -1216,7 +1216,7 @@ function getResolveToMatches(matches, v7_relativeSplatPath) {
|
|
|
1216
1216
|
// match so we include splat values for "." links. See:
|
|
1217
1217
|
// https://github.com/remix-run/react-router/issues/11052#issuecomment-1836589329
|
|
1218
1218
|
if (v7_relativeSplatPath) {
|
|
1219
|
-
return pathMatches.map((match, idx) => idx ===
|
|
1219
|
+
return pathMatches.map((match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase);
|
|
1220
1220
|
}
|
|
1221
1221
|
return pathMatches.map(match => match.pathnameBase);
|
|
1222
1222
|
}
|
|
@@ -1729,6 +1729,16 @@ function createRouter(init) {
|
|
|
1729
1729
|
[route.id]: error
|
|
1730
1730
|
};
|
|
1731
1731
|
}
|
|
1732
|
+
|
|
1733
|
+
// If the user provided a patchRoutesOnMiss implementation and our initial
|
|
1734
|
+
// match is a splat route, clear them out so we run through lazy discovery
|
|
1735
|
+
// on hydration in case there's a more accurate lazy route match
|
|
1736
|
+
if (initialMatches && patchRoutesOnMissImpl) {
|
|
1737
|
+
let fogOfWar = checkFogOfWar(initialMatches, dataRoutes, init.history.location.pathname);
|
|
1738
|
+
if (fogOfWar.active) {
|
|
1739
|
+
initialMatches = null;
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1732
1742
|
let initialized;
|
|
1733
1743
|
if (!initialMatches) {
|
|
1734
1744
|
// We need to run patchRoutesOnMiss in initialize()
|
|
@@ -2058,6 +2068,8 @@ function createRouter(init) {
|
|
|
2058
2068
|
// Always respect the user flag. Otherwise don't reset on mutation
|
|
2059
2069
|
// submission navigations unless they redirect
|
|
2060
2070
|
let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && ((_location$state2 = location.state) == null ? void 0 : _location$state2._isRedirect) !== true;
|
|
2071
|
+
|
|
2072
|
+
// Commit any in-flight routes at the end of the HMR revalidation "navigation"
|
|
2061
2073
|
if (inFlightDataRoutes) {
|
|
2062
2074
|
dataRoutes = inFlightDataRoutes;
|
|
2063
2075
|
inFlightDataRoutes = undefined;
|
|
@@ -3503,7 +3515,7 @@ function createRouter(init) {
|
|
|
3503
3515
|
};
|
|
3504
3516
|
} else {
|
|
3505
3517
|
let leafRoute = matches[matches.length - 1].route;
|
|
3506
|
-
if (leafRoute.path === "*") {
|
|
3518
|
+
if (leafRoute.path && (leafRoute.path === "*" || leafRoute.path.endsWith("/*"))) {
|
|
3507
3519
|
// If we matched a splat, it might only be because we haven't yet fetched
|
|
3508
3520
|
// the children that would match with a higher score, so let's fetch
|
|
3509
3521
|
// around and find out
|
|
@@ -3524,21 +3536,32 @@ function createRouter(init) {
|
|
|
3524
3536
|
let partialMatches = matches;
|
|
3525
3537
|
let route = partialMatches.length > 0 ? partialMatches[partialMatches.length - 1].route : null;
|
|
3526
3538
|
while (true) {
|
|
3539
|
+
let isNonHMR = inFlightDataRoutes == null;
|
|
3540
|
+
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
3527
3541
|
try {
|
|
3528
|
-
await loadLazyRouteChildren(patchRoutesOnMissImpl, pathname, partialMatches,
|
|
3542
|
+
await loadLazyRouteChildren(patchRoutesOnMissImpl, pathname, partialMatches, routesToUse, manifest, mapRouteProperties, pendingPatchRoutes, signal);
|
|
3529
3543
|
} catch (e) {
|
|
3530
3544
|
return {
|
|
3531
3545
|
type: "error",
|
|
3532
3546
|
error: e,
|
|
3533
3547
|
partialMatches
|
|
3534
3548
|
};
|
|
3549
|
+
} finally {
|
|
3550
|
+
// If we are not in the middle of an HMR revalidation and we changed the
|
|
3551
|
+
// routes, provide a new identity so when we `updateState` at the end of
|
|
3552
|
+
// this navigation/fetch `router.routes` will be a new identity and
|
|
3553
|
+
// trigger a re-run of memoized `router.routes` dependencies.
|
|
3554
|
+
// HMR will already update the identity and reflow when it lands
|
|
3555
|
+
// `inFlightDataRoutes` in `completeNavigation`
|
|
3556
|
+
if (isNonHMR) {
|
|
3557
|
+
dataRoutes = [...dataRoutes];
|
|
3558
|
+
}
|
|
3535
3559
|
}
|
|
3536
3560
|
if (signal.aborted) {
|
|
3537
3561
|
return {
|
|
3538
3562
|
type: "aborted"
|
|
3539
3563
|
};
|
|
3540
3564
|
}
|
|
3541
|
-
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
3542
3565
|
let newMatches = matchRoutes(routesToUse, pathname, basename);
|
|
3543
3566
|
let matchedSplat = false;
|
|
3544
3567
|
if (newMatches) {
|
|
@@ -3591,6 +3614,21 @@ function createRouter(init) {
|
|
|
3591
3614
|
manifest = {};
|
|
3592
3615
|
inFlightDataRoutes = convertRoutesToDataRoutes(newRoutes, mapRouteProperties, undefined, manifest);
|
|
3593
3616
|
}
|
|
3617
|
+
function patchRoutes(routeId, children) {
|
|
3618
|
+
let isNonHMR = inFlightDataRoutes == null;
|
|
3619
|
+
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
3620
|
+
patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties);
|
|
3621
|
+
|
|
3622
|
+
// If we are not in the middle of an HMR revalidation and we changed the
|
|
3623
|
+
// routes, provide a new identity and trigger a reflow via `updateState`
|
|
3624
|
+
// to re-run memoized `router.routes` dependencies.
|
|
3625
|
+
// HMR will already update the identity and reflow when it lands
|
|
3626
|
+
// `inFlightDataRoutes` in `completeNavigation`
|
|
3627
|
+
if (isNonHMR) {
|
|
3628
|
+
dataRoutes = [...dataRoutes];
|
|
3629
|
+
updateState({});
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3594
3632
|
router = {
|
|
3595
3633
|
get basename() {
|
|
3596
3634
|
return basename;
|
|
@@ -3622,9 +3660,7 @@ function createRouter(init) {
|
|
|
3622
3660
|
dispose,
|
|
3623
3661
|
getBlocker,
|
|
3624
3662
|
deleteBlocker,
|
|
3625
|
-
patchRoutes
|
|
3626
|
-
return patchRoutes(routeId, children, dataRoutes || inFlightDataRoutes, manifest, mapRouteProperties);
|
|
3627
|
-
},
|
|
3663
|
+
patchRoutes,
|
|
3628
3664
|
_internalFetchControllers: fetchControllers,
|
|
3629
3665
|
_internalActiveDeferreds: activeDeferreds,
|
|
3630
3666
|
// TODO: Remove setRoutes, it's temporary to avoid dealing with
|
|
@@ -4442,7 +4478,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
|
|
|
4442
4478
|
}
|
|
4443
4479
|
|
|
4444
4480
|
/**
|
|
4445
|
-
* Idempotent utility to execute
|
|
4481
|
+
* Idempotent utility to execute patchRoutesOnMiss() to lazily load route
|
|
4446
4482
|
* definitions and update the routes/routeManifest
|
|
4447
4483
|
*/
|
|
4448
4484
|
async function loadLazyRouteChildren(patchRoutesOnMissImpl, path, matches, routes, manifest, mapRouteProperties, pendingRouteChildren, signal) {
|
|
@@ -4455,7 +4491,7 @@ async function loadLazyRouteChildren(patchRoutesOnMissImpl, path, matches, route
|
|
|
4455
4491
|
matches,
|
|
4456
4492
|
patch: (routeId, children) => {
|
|
4457
4493
|
if (!signal.aborted) {
|
|
4458
|
-
|
|
4494
|
+
patchRoutesImpl(routeId, children, routes, manifest, mapRouteProperties);
|
|
4459
4495
|
}
|
|
4460
4496
|
}
|
|
4461
4497
|
});
|
|
@@ -4468,7 +4504,7 @@ async function loadLazyRouteChildren(patchRoutesOnMissImpl, path, matches, route
|
|
|
4468
4504
|
pendingRouteChildren.delete(key);
|
|
4469
4505
|
}
|
|
4470
4506
|
}
|
|
4471
|
-
function
|
|
4507
|
+
function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties) {
|
|
4472
4508
|
if (routeId) {
|
|
4473
4509
|
var _route$children;
|
|
4474
4510
|
let route = manifest[routeId];
|
|
@@ -4480,8 +4516,8 @@ function patchRoutes(routeId, children, routes, manifest, mapRouteProperties) {
|
|
|
4480
4516
|
route.children = dataChildren;
|
|
4481
4517
|
}
|
|
4482
4518
|
} else {
|
|
4483
|
-
let dataChildren = convertRoutesToDataRoutes(children, mapRouteProperties, ["patch", String(
|
|
4484
|
-
|
|
4519
|
+
let dataChildren = convertRoutesToDataRoutes(children, mapRouteProperties, ["patch", String(routesToUse.length || "0")], manifest);
|
|
4520
|
+
routesToUse.push(...dataChildren);
|
|
4485
4521
|
}
|
|
4486
4522
|
}
|
|
4487
4523
|
|