@remix-run/router 0.0.0-experimental-c5cae38f3 → 0.0.0-experimental-078ef8de9
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 +9 -0
- package/dist/router.cjs.js +50 -31
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +2 -1
- package/dist/router.js +48 -31
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +50 -31
- 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 +56 -29
- package/utils.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# `@remix-run/router`
|
|
2
2
|
|
|
3
|
+
## 1.17.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add support for Lazy Route Discovery (a.k.a. Fog of War) ([#11626](https://github.com/remix-run/react-router/pull/11626))
|
|
8
|
+
|
|
9
|
+
- RFC: <https://github.com/remix-run/react-router/discussions/11113>
|
|
10
|
+
- `unstable_patchRoutesOnMiss` docs: <https://reactrouter.com/en/main/routers/create-browser-router>
|
|
11
|
+
|
|
3
12
|
## 1.16.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/router.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v0.0.0-experimental-
|
|
2
|
+
* @remix-run/router v0.0.0-experimental-078ef8de9
|
|
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
|
}
|
|
@@ -2058,6 +2058,8 @@ function createRouter(init) {
|
|
|
2058
2058
|
// Always respect the user flag. Otherwise don't reset on mutation
|
|
2059
2059
|
// submission navigations unless they redirect
|
|
2060
2060
|
let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && ((_location$state2 = location.state) == null ? void 0 : _location$state2._isRedirect) !== true;
|
|
2061
|
+
|
|
2062
|
+
// Commit any in-flight routes at the end of the HMR revalidation "navigation"
|
|
2061
2063
|
if (inFlightDataRoutes) {
|
|
2062
2064
|
dataRoutes = inFlightDataRoutes;
|
|
2063
2065
|
inFlightDataRoutes = undefined;
|
|
@@ -3524,21 +3526,32 @@ function createRouter(init) {
|
|
|
3524
3526
|
let partialMatches = matches;
|
|
3525
3527
|
let route = partialMatches.length > 0 ? partialMatches[partialMatches.length - 1].route : null;
|
|
3526
3528
|
while (true) {
|
|
3529
|
+
let isNonHMR = inFlightDataRoutes == null;
|
|
3530
|
+
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
3527
3531
|
try {
|
|
3528
|
-
await loadLazyRouteChildren(patchRoutesOnMissImpl, pathname, partialMatches,
|
|
3529
|
-
if (signal.aborted) {
|
|
3530
|
-
return {
|
|
3531
|
-
type: "aborted"
|
|
3532
|
-
};
|
|
3533
|
-
}
|
|
3532
|
+
await loadLazyRouteChildren(patchRoutesOnMissImpl, pathname, partialMatches, routesToUse, manifest, mapRouteProperties, pendingPatchRoutes, signal);
|
|
3534
3533
|
} catch (e) {
|
|
3535
3534
|
return {
|
|
3536
3535
|
type: "error",
|
|
3537
3536
|
error: e,
|
|
3538
3537
|
partialMatches
|
|
3539
3538
|
};
|
|
3539
|
+
} finally {
|
|
3540
|
+
// If we are not in the middle of an HMR revalidation and we changed the
|
|
3541
|
+
// routes, provide a new identity so when we `updateState` at the end of
|
|
3542
|
+
// this navigation/fetch `router.routes` will be a new identity and
|
|
3543
|
+
// trigger a re-run of memoized `router.routes` dependencies.
|
|
3544
|
+
// HMR will already update the identity and reflow when it lands
|
|
3545
|
+
// `inFlightDataRoutes` in `completeNavigation`
|
|
3546
|
+
if (isNonHMR) {
|
|
3547
|
+
dataRoutes = [...dataRoutes];
|
|
3548
|
+
}
|
|
3549
|
+
}
|
|
3550
|
+
if (signal.aborted) {
|
|
3551
|
+
return {
|
|
3552
|
+
type: "aborted"
|
|
3553
|
+
};
|
|
3540
3554
|
}
|
|
3541
|
-
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
3542
3555
|
let newMatches = matchRoutes(routesToUse, pathname, basename);
|
|
3543
3556
|
let matchedSplat = false;
|
|
3544
3557
|
if (newMatches) {
|
|
@@ -3567,21 +3580,14 @@ function createRouter(init) {
|
|
|
3567
3580
|
}
|
|
3568
3581
|
let newPartialMatches = matchRoutesImpl(routesToUse, pathname, basename, true);
|
|
3569
3582
|
|
|
3570
|
-
//
|
|
3583
|
+
// If we are no longer partially matching anything, this was either a
|
|
3584
|
+
// legit splat match above, or it's a 404. Also avoid loops if the
|
|
3585
|
+
// second pass results in the same partial matches
|
|
3571
3586
|
if (!newPartialMatches || partialMatches.map(m => m.route.id).join("-") === newPartialMatches.map(m => m.route.id).join("-")) {
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
type: "success",
|
|
3577
|
-
matches: newMatches
|
|
3578
|
-
};
|
|
3579
|
-
} else {
|
|
3580
|
-
return {
|
|
3581
|
-
type: "success",
|
|
3582
|
-
matches: null
|
|
3583
|
-
};
|
|
3584
|
-
}
|
|
3587
|
+
return {
|
|
3588
|
+
type: "success",
|
|
3589
|
+
matches: matchedSplat ? newMatches : null
|
|
3590
|
+
};
|
|
3585
3591
|
}
|
|
3586
3592
|
partialMatches = newPartialMatches;
|
|
3587
3593
|
route = partialMatches[partialMatches.length - 1].route;
|
|
@@ -3598,6 +3604,21 @@ function createRouter(init) {
|
|
|
3598
3604
|
manifest = {};
|
|
3599
3605
|
inFlightDataRoutes = convertRoutesToDataRoutes(newRoutes, mapRouteProperties, undefined, manifest);
|
|
3600
3606
|
}
|
|
3607
|
+
function patchRoutes(routeId, children) {
|
|
3608
|
+
let isNonHMR = inFlightDataRoutes == null;
|
|
3609
|
+
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
3610
|
+
patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties);
|
|
3611
|
+
|
|
3612
|
+
// If we are not in the middle of an HMR revalidation and we changed the
|
|
3613
|
+
// routes, provide a new identity and trigger a reflow via `updateState`
|
|
3614
|
+
// to re-run memoized `router.routes` dependencies.
|
|
3615
|
+
// HMR will already update the identity and reflow when it lands
|
|
3616
|
+
// `inFlightDataRoutes` in `completeNavigation`
|
|
3617
|
+
if (isNonHMR) {
|
|
3618
|
+
dataRoutes = [...dataRoutes];
|
|
3619
|
+
updateState({});
|
|
3620
|
+
}
|
|
3621
|
+
}
|
|
3601
3622
|
router = {
|
|
3602
3623
|
get basename() {
|
|
3603
3624
|
return basename;
|
|
@@ -3629,9 +3650,7 @@ function createRouter(init) {
|
|
|
3629
3650
|
dispose,
|
|
3630
3651
|
getBlocker,
|
|
3631
3652
|
deleteBlocker,
|
|
3632
|
-
patchRoutes
|
|
3633
|
-
return patchRoutes(routeId, children, dataRoutes || inFlightDataRoutes, manifest, mapRouteProperties);
|
|
3634
|
-
},
|
|
3653
|
+
patchRoutes,
|
|
3635
3654
|
_internalFetchControllers: fetchControllers,
|
|
3636
3655
|
_internalActiveDeferreds: activeDeferreds,
|
|
3637
3656
|
// TODO: Remove setRoutes, it's temporary to avoid dealing with
|
|
@@ -4449,7 +4468,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
|
|
|
4449
4468
|
}
|
|
4450
4469
|
|
|
4451
4470
|
/**
|
|
4452
|
-
* Idempotent utility to execute
|
|
4471
|
+
* Idempotent utility to execute patchRoutesOnMiss() to lazily load route
|
|
4453
4472
|
* definitions and update the routes/routeManifest
|
|
4454
4473
|
*/
|
|
4455
4474
|
async function loadLazyRouteChildren(patchRoutesOnMissImpl, path, matches, routes, manifest, mapRouteProperties, pendingRouteChildren, signal) {
|
|
@@ -4462,7 +4481,7 @@ async function loadLazyRouteChildren(patchRoutesOnMissImpl, path, matches, route
|
|
|
4462
4481
|
matches,
|
|
4463
4482
|
patch: (routeId, children) => {
|
|
4464
4483
|
if (!signal.aborted) {
|
|
4465
|
-
|
|
4484
|
+
patchRoutesImpl(routeId, children, routes, manifest, mapRouteProperties);
|
|
4466
4485
|
}
|
|
4467
4486
|
}
|
|
4468
4487
|
});
|
|
@@ -4475,7 +4494,7 @@ async function loadLazyRouteChildren(patchRoutesOnMissImpl, path, matches, route
|
|
|
4475
4494
|
pendingRouteChildren.delete(key);
|
|
4476
4495
|
}
|
|
4477
4496
|
}
|
|
4478
|
-
function
|
|
4497
|
+
function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties) {
|
|
4479
4498
|
if (routeId) {
|
|
4480
4499
|
var _route$children;
|
|
4481
4500
|
let route = manifest[routeId];
|
|
@@ -4487,8 +4506,8 @@ function patchRoutes(routeId, children, routes, manifest, mapRouteProperties) {
|
|
|
4487
4506
|
route.children = dataChildren;
|
|
4488
4507
|
}
|
|
4489
4508
|
} else {
|
|
4490
|
-
let dataChildren = convertRoutesToDataRoutes(children, mapRouteProperties, ["patch", String(
|
|
4491
|
-
|
|
4509
|
+
let dataChildren = convertRoutesToDataRoutes(children, mapRouteProperties, ["patch", String(routesToUse.length || "0")], manifest);
|
|
4510
|
+
routesToUse.push(...dataChildren);
|
|
4492
4511
|
}
|
|
4493
4512
|
}
|
|
4494
4513
|
|