@remix-run/router 1.3.1 → 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 +7 -0
- package/dist/router.cjs.js +19 -29
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +19 -29
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +19 -29
- 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 +21 -29
package/dist/router.umd.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
|
*
|
|
@@ -1478,6 +1478,7 @@
|
|
|
1478
1478
|
reset: undefined,
|
|
1479
1479
|
location: undefined
|
|
1480
1480
|
};
|
|
1481
|
+
const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
1481
1482
|
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
1482
1483
|
const isServer = !isBrowser; //#endregion
|
|
1483
1484
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -1585,10 +1586,7 @@
|
|
|
1585
1586
|
// promise resolves we update loaderData. If a new navigation starts we
|
|
1586
1587
|
// cancel active deferreds for eliminated routes.
|
|
1587
1588
|
|
|
1588
|
-
let activeDeferreds = new Map(); //
|
|
1589
|
-
// any compelling use cases for multi-blocker yet
|
|
1590
|
-
|
|
1591
|
-
let activeBlocker = null; // Store blocker functions in a separate Map outside of router state since
|
|
1589
|
+
let activeDeferreds = new Map(); // Store blocker functions in a separate Map outside of router state since
|
|
1592
1590
|
// we don't need to update UI state if they change
|
|
1593
1591
|
|
|
1594
1592
|
let blockerFunctions = new Map(); // Flag to ignore the next history update, so we can revert the URL change on
|
|
@@ -1615,7 +1613,7 @@
|
|
|
1615
1613
|
return;
|
|
1616
1614
|
}
|
|
1617
1615
|
|
|
1618
|
-
warning(
|
|
1616
|
+
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.");
|
|
1619
1617
|
let blockerKey = shouldBlockNavigation({
|
|
1620
1618
|
currentLocation: state.location,
|
|
1621
1619
|
nextLocation: location,
|
|
@@ -2549,9 +2547,9 @@
|
|
|
2549
2547
|
}, isFetchActionRedirect ? {
|
|
2550
2548
|
_isFetchActionRedirect: true
|
|
2551
2549
|
} : {}));
|
|
2552
|
-
invariant(redirectLocation, "Expected a location on the redirect navigation"); // Check if this an external redirect that goes to a new origin
|
|
2550
|
+
invariant(redirectLocation, "Expected a location on the redirect navigation"); // Check if this an absolute external redirect that goes to a new origin
|
|
2553
2551
|
|
|
2554
|
-
if (isBrowser && typeof ((_window = window) == null ? void 0 : _window.location) !== "undefined") {
|
|
2552
|
+
if (ABSOLUTE_URL_REGEX.test(redirect.location) && isBrowser && typeof ((_window = window) == null ? void 0 : _window.location) !== "undefined") {
|
|
2555
2553
|
let newOrigin = init.history.createURL(redirect.location).origin;
|
|
2556
2554
|
|
|
2557
2555
|
if (window.location.origin !== newOrigin) {
|
|
@@ -2729,13 +2727,6 @@
|
|
|
2729
2727
|
|
|
2730
2728
|
if (blockerFunctions.get(key) !== fn) {
|
|
2731
2729
|
blockerFunctions.set(key, fn);
|
|
2732
|
-
|
|
2733
|
-
if (activeBlocker == null) {
|
|
2734
|
-
// This is now the active blocker
|
|
2735
|
-
activeBlocker = key;
|
|
2736
|
-
} else if (key !== activeBlocker) {
|
|
2737
|
-
warning(false, "A router only supports one blocker at a time");
|
|
2738
|
-
}
|
|
2739
2730
|
}
|
|
2740
2731
|
|
|
2741
2732
|
return blocker;
|
|
@@ -2744,10 +2735,6 @@
|
|
|
2744
2735
|
function deleteBlocker(key) {
|
|
2745
2736
|
state.blockers.delete(key);
|
|
2746
2737
|
blockerFunctions.delete(key);
|
|
2747
|
-
|
|
2748
|
-
if (activeBlocker === key) {
|
|
2749
|
-
activeBlocker = null;
|
|
2750
|
-
}
|
|
2751
2738
|
} // Utility function to update blockers, ensuring valid state transitions
|
|
2752
2739
|
|
|
2753
2740
|
|
|
@@ -2769,15 +2756,19 @@
|
|
|
2769
2756
|
historyAction
|
|
2770
2757
|
} = _ref2;
|
|
2771
2758
|
|
|
2772
|
-
if (
|
|
2759
|
+
if (blockerFunctions.size === 0) {
|
|
2773
2760
|
return;
|
|
2774
|
-
} // We
|
|
2775
|
-
//
|
|
2761
|
+
} // We ony support a single active blocker at the moment since we don't have
|
|
2762
|
+
// any compelling use cases for multi-blocker yet
|
|
2763
|
+
|
|
2776
2764
|
|
|
2765
|
+
if (blockerFunctions.size > 1) {
|
|
2766
|
+
warning(false, "A router only supports one blocker at a time");
|
|
2767
|
+
}
|
|
2777
2768
|
|
|
2778
|
-
let
|
|
2779
|
-
|
|
2780
|
-
let blocker = state.blockers.get(
|
|
2769
|
+
let entries = Array.from(blockerFunctions.entries());
|
|
2770
|
+
let [blockerKey, blockerFunction] = entries[entries.length - 1];
|
|
2771
|
+
let blocker = state.blockers.get(blockerKey);
|
|
2781
2772
|
|
|
2782
2773
|
if (blocker && blocker.state === "proceeding") {
|
|
2783
2774
|
// If the blocker is currently proceeding, we don't need to re-check
|
|
@@ -2792,7 +2783,7 @@
|
|
|
2792
2783
|
nextLocation,
|
|
2793
2784
|
historyAction
|
|
2794
2785
|
})) {
|
|
2795
|
-
return
|
|
2786
|
+
return blockerKey;
|
|
2796
2787
|
}
|
|
2797
2788
|
}
|
|
2798
2789
|
|
|
@@ -3542,10 +3533,9 @@
|
|
|
3542
3533
|
|
|
3543
3534
|
if (redirectStatusCodes.has(status)) {
|
|
3544
3535
|
let location = result.headers.get("Location");
|
|
3545
|
-
invariant(location, "Redirects returned/thrown from loaders/actions must have a Location header");
|
|
3546
|
-
let isAbsolute = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(location); // Support relative routing in internal redirects
|
|
3536
|
+
invariant(location, "Redirects returned/thrown from loaders/actions must have a Location header"); // Support relative routing in internal redirects
|
|
3547
3537
|
|
|
3548
|
-
if (!
|
|
3538
|
+
if (!ABSOLUTE_URL_REGEX.test(location)) {
|
|
3549
3539
|
let activeMatches = matches.slice(0, matches.indexOf(match) + 1);
|
|
3550
3540
|
let routePathnames = getPathContributingMatches(activeMatches).map(match => match.pathnameBase);
|
|
3551
3541
|
let resolvedLocation = resolveTo(location, routePathnames, new URL(request.url).pathname);
|