@remix-run/router 1.3.1-pre.0 → 1.3.2-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 +14 -4
- package/dist/history.d.ts +1 -1
- package/dist/router.cjs.js +29 -44
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +29 -44
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +29 -44
- 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/history.ts +6 -18
- package/package.json +1 -1
- package/router.ts +32 -29
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
# `@remix-run/router`
|
|
2
2
|
|
|
3
|
-
## 1.3.
|
|
3
|
+
## 1.3.2-pre.0
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
7
|
+
- Remove inaccurate console warning for POP navigations ([#10030](https://github.com/remix-run/react-router/pull/10030))
|
|
8
|
+
- Only check for differing origin on absolute URL redirects ([#10033](https://github.com/remix-run/react-router/pull/10033))
|
|
9
|
+
|
|
10
|
+
## 1.3.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Fixes 2 separate issues for revalidating fetcher `shouldRevalidate` calls ([#9948](https://github.com/remix-run/react-router/pull/9948))
|
|
15
|
+
- The `shouldRevalidate` function was only being called for _explicit_ revalidation scenarios (after a mutation, manual `useRevalidator` call, or an `X-Remix-Revalidate` header used for cookie setting in Remix). It was not properly being called on _implicit_ revalidation scenarios that also apply to navigation `loader` revalidation, such as a change in search params or clicking a link for the page we're already on. It's now correctly called in those additional scenarios.
|
|
16
|
+
- The parameters being passed were incorrect and inconsistent with one another since the `current*`/`next*` parameters reflected the static `fetcher.load` URL (and thus were identical). Instead, they should have reflected the the navigation that triggered the revalidation (as the `form*` parameters did). These parameters now correctly reflect the triggering navigation.
|
|
17
|
+
- Respect `preventScrollReset` on `<fetcher.Form>` ([#9963](https://github.com/remix-run/react-router/pull/9963))
|
|
9
18
|
- Do not short circuit on hash change only mutation submissions ([#9944](https://github.com/remix-run/react-router/pull/9944))
|
|
10
19
|
- Remove `instanceof` check from `isRouteErrorResponse` to avoid bundling issues on the server ([#9930](https://github.com/remix-run/react-router/pull/9930))
|
|
11
|
-
-
|
|
20
|
+
- Fix navigation for hash routers on manual URL changes ([#9980](https://github.com/remix-run/react-router/pull/9980))
|
|
21
|
+
- Detect when a `defer` call only contains critical data and remove the `AbortController` ([#9965](https://github.com/remix-run/react-router/pull/9965))
|
|
12
22
|
- Send the name as the value when url-encoding `File` `FormData` entries ([#9867](https://github.com/remix-run/react-router/pull/9867))
|
|
13
23
|
|
|
14
24
|
## 1.3.0
|
package/dist/history.d.ts
CHANGED
package/dist/router.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.3.
|
|
2
|
+
* @remix-run/router v1.3.2-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -433,23 +433,17 @@ function getUrlBasedHistory(getLocation, createHref, validateLocation, options)
|
|
|
433
433
|
}
|
|
434
434
|
|
|
435
435
|
function handlePop() {
|
|
436
|
-
|
|
436
|
+
action = exports.Action.Pop;
|
|
437
437
|
let nextIndex = getIndex();
|
|
438
|
+
let delta = nextIndex == null ? null : nextIndex - index;
|
|
439
|
+
index = nextIndex;
|
|
438
440
|
|
|
439
|
-
if (
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
listener({
|
|
446
|
-
action,
|
|
447
|
-
location: history.location,
|
|
448
|
-
delta
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
} else {
|
|
452
|
-
warning$1(false, "You are trying to perform a POP navigation to a location that was not " + "created by @remix-run/router. This will fail silently in production. " + "You should navigate via the router to avoid this situation (instead of " + "using window.history.pushState/window.location.hash).");
|
|
441
|
+
if (listener) {
|
|
442
|
+
listener({
|
|
443
|
+
action,
|
|
444
|
+
location: history.location,
|
|
445
|
+
delta
|
|
446
|
+
});
|
|
453
447
|
}
|
|
454
448
|
}
|
|
455
449
|
|
|
@@ -1482,6 +1476,7 @@ const IDLE_BLOCKER = {
|
|
|
1482
1476
|
reset: undefined,
|
|
1483
1477
|
location: undefined
|
|
1484
1478
|
};
|
|
1479
|
+
const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
1485
1480
|
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
1486
1481
|
const isServer = !isBrowser; //#endregion
|
|
1487
1482
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -1589,10 +1584,7 @@ function createRouter(init) {
|
|
|
1589
1584
|
// promise resolves we update loaderData. If a new navigation starts we
|
|
1590
1585
|
// cancel active deferreds for eliminated routes.
|
|
1591
1586
|
|
|
1592
|
-
let activeDeferreds = new Map(); //
|
|
1593
|
-
// any compelling use cases for multi-blocker yet
|
|
1594
|
-
|
|
1595
|
-
let activeBlocker = null; // Store blocker functions in a separate Map outside of router state since
|
|
1587
|
+
let activeDeferreds = new Map(); // Store blocker functions in a separate Map outside of router state since
|
|
1596
1588
|
// we don't need to update UI state if they change
|
|
1597
1589
|
|
|
1598
1590
|
let blockerFunctions = new Map(); // Flag to ignore the next history update, so we can revert the URL change on
|
|
@@ -1619,13 +1611,14 @@ function createRouter(init) {
|
|
|
1619
1611
|
return;
|
|
1620
1612
|
}
|
|
1621
1613
|
|
|
1614
|
+
warning(blockerFunctions.size === 0 || delta != null, "You are trying to use a blocker on a POP navigation to a location " + "that was not created by @remix-run/router. This will fail silently in " + "production. This can happen if you are navigating outside the router " + "via `window.history.pushState`/`window.location.hash` instead of using " + "router navigation APIs. This can also happen if you are using " + "createHashRouter and the user manually changes the URL.");
|
|
1622
1615
|
let blockerKey = shouldBlockNavigation({
|
|
1623
1616
|
currentLocation: state.location,
|
|
1624
1617
|
nextLocation: location,
|
|
1625
1618
|
historyAction
|
|
1626
1619
|
});
|
|
1627
1620
|
|
|
1628
|
-
if (blockerKey) {
|
|
1621
|
+
if (blockerKey && delta != null) {
|
|
1629
1622
|
// Restore the URL to match the current UI, but don't update router state
|
|
1630
1623
|
ignoreNextHistoryUpdate = true;
|
|
1631
1624
|
init.history.go(delta * -1); // Put the blocker into a blocked state
|
|
@@ -2552,9 +2545,9 @@ function createRouter(init) {
|
|
|
2552
2545
|
}, isFetchActionRedirect ? {
|
|
2553
2546
|
_isFetchActionRedirect: true
|
|
2554
2547
|
} : {}));
|
|
2555
|
-
invariant(redirectLocation, "Expected a location on the redirect navigation"); // Check if this an external redirect that goes to a new origin
|
|
2548
|
+
invariant(redirectLocation, "Expected a location on the redirect navigation"); // Check if this an absolute external redirect that goes to a new origin
|
|
2556
2549
|
|
|
2557
|
-
if (isBrowser && typeof ((_window = window) == null ? void 0 : _window.location) !== "undefined") {
|
|
2550
|
+
if (ABSOLUTE_URL_REGEX.test(redirect.location) && isBrowser && typeof ((_window = window) == null ? void 0 : _window.location) !== "undefined") {
|
|
2558
2551
|
let newOrigin = init.history.createURL(redirect.location).origin;
|
|
2559
2552
|
|
|
2560
2553
|
if (window.location.origin !== newOrigin) {
|
|
@@ -2732,13 +2725,6 @@ function createRouter(init) {
|
|
|
2732
2725
|
|
|
2733
2726
|
if (blockerFunctions.get(key) !== fn) {
|
|
2734
2727
|
blockerFunctions.set(key, fn);
|
|
2735
|
-
|
|
2736
|
-
if (activeBlocker == null) {
|
|
2737
|
-
// This is now the active blocker
|
|
2738
|
-
activeBlocker = key;
|
|
2739
|
-
} else if (key !== activeBlocker) {
|
|
2740
|
-
warning(false, "A router only supports one blocker at a time");
|
|
2741
|
-
}
|
|
2742
2728
|
}
|
|
2743
2729
|
|
|
2744
2730
|
return blocker;
|
|
@@ -2747,10 +2733,6 @@ function createRouter(init) {
|
|
|
2747
2733
|
function deleteBlocker(key) {
|
|
2748
2734
|
state.blockers.delete(key);
|
|
2749
2735
|
blockerFunctions.delete(key);
|
|
2750
|
-
|
|
2751
|
-
if (activeBlocker === key) {
|
|
2752
|
-
activeBlocker = null;
|
|
2753
|
-
}
|
|
2754
2736
|
} // Utility function to update blockers, ensuring valid state transitions
|
|
2755
2737
|
|
|
2756
2738
|
|
|
@@ -2772,15 +2754,19 @@ function createRouter(init) {
|
|
|
2772
2754
|
historyAction
|
|
2773
2755
|
} = _ref2;
|
|
2774
2756
|
|
|
2775
|
-
if (
|
|
2757
|
+
if (blockerFunctions.size === 0) {
|
|
2776
2758
|
return;
|
|
2777
|
-
} // We
|
|
2778
|
-
//
|
|
2759
|
+
} // We ony support a single active blocker at the moment since we don't have
|
|
2760
|
+
// any compelling use cases for multi-blocker yet
|
|
2779
2761
|
|
|
2780
2762
|
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2763
|
+
if (blockerFunctions.size > 1) {
|
|
2764
|
+
warning(false, "A router only supports one blocker at a time");
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
let entries = Array.from(blockerFunctions.entries());
|
|
2768
|
+
let [blockerKey, blockerFunction] = entries[entries.length - 1];
|
|
2769
|
+
let blocker = state.blockers.get(blockerKey);
|
|
2784
2770
|
|
|
2785
2771
|
if (blocker && blocker.state === "proceeding") {
|
|
2786
2772
|
// If the blocker is currently proceeding, we don't need to re-check
|
|
@@ -2795,7 +2781,7 @@ function createRouter(init) {
|
|
|
2795
2781
|
nextLocation,
|
|
2796
2782
|
historyAction
|
|
2797
2783
|
})) {
|
|
2798
|
-
return
|
|
2784
|
+
return blockerKey;
|
|
2799
2785
|
}
|
|
2800
2786
|
}
|
|
2801
2787
|
|
|
@@ -3545,10 +3531,9 @@ async function callLoaderOrAction(type, request, match, matches, basename, isSta
|
|
|
3545
3531
|
|
|
3546
3532
|
if (redirectStatusCodes.has(status)) {
|
|
3547
3533
|
let location = result.headers.get("Location");
|
|
3548
|
-
invariant(location, "Redirects returned/thrown from loaders/actions must have a Location header");
|
|
3549
|
-
let isAbsolute = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(location); // Support relative routing in internal redirects
|
|
3534
|
+
invariant(location, "Redirects returned/thrown from loaders/actions must have a Location header"); // Support relative routing in internal redirects
|
|
3550
3535
|
|
|
3551
|
-
if (!
|
|
3536
|
+
if (!ABSOLUTE_URL_REGEX.test(location)) {
|
|
3552
3537
|
let activeMatches = matches.slice(0, matches.indexOf(match) + 1);
|
|
3553
3538
|
let routePathnames = getPathContributingMatches(activeMatches).map(match => match.pathnameBase);
|
|
3554
3539
|
let resolvedLocation = resolveTo(location, routePathnames, new URL(request.url).pathname);
|