@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/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
|
*
|
|
@@ -435,23 +435,17 @@
|
|
|
435
435
|
}
|
|
436
436
|
|
|
437
437
|
function handlePop() {
|
|
438
|
-
|
|
438
|
+
action = exports.Action.Pop;
|
|
439
439
|
let nextIndex = getIndex();
|
|
440
|
+
let delta = nextIndex == null ? null : nextIndex - index;
|
|
441
|
+
index = nextIndex;
|
|
440
442
|
|
|
441
|
-
if (
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
listener({
|
|
448
|
-
action,
|
|
449
|
-
location: history.location,
|
|
450
|
-
delta
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
} else {
|
|
454
|
-
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).");
|
|
443
|
+
if (listener) {
|
|
444
|
+
listener({
|
|
445
|
+
action,
|
|
446
|
+
location: history.location,
|
|
447
|
+
delta
|
|
448
|
+
});
|
|
455
449
|
}
|
|
456
450
|
}
|
|
457
451
|
|
|
@@ -1484,6 +1478,7 @@
|
|
|
1484
1478
|
reset: undefined,
|
|
1485
1479
|
location: undefined
|
|
1486
1480
|
};
|
|
1481
|
+
const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
1487
1482
|
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
1488
1483
|
const isServer = !isBrowser; //#endregion
|
|
1489
1484
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -1591,10 +1586,7 @@
|
|
|
1591
1586
|
// promise resolves we update loaderData. If a new navigation starts we
|
|
1592
1587
|
// cancel active deferreds for eliminated routes.
|
|
1593
1588
|
|
|
1594
|
-
let activeDeferreds = new Map(); //
|
|
1595
|
-
// any compelling use cases for multi-blocker yet
|
|
1596
|
-
|
|
1597
|
-
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
|
|
1598
1590
|
// we don't need to update UI state if they change
|
|
1599
1591
|
|
|
1600
1592
|
let blockerFunctions = new Map(); // Flag to ignore the next history update, so we can revert the URL change on
|
|
@@ -1621,13 +1613,14 @@
|
|
|
1621
1613
|
return;
|
|
1622
1614
|
}
|
|
1623
1615
|
|
|
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.");
|
|
1624
1617
|
let blockerKey = shouldBlockNavigation({
|
|
1625
1618
|
currentLocation: state.location,
|
|
1626
1619
|
nextLocation: location,
|
|
1627
1620
|
historyAction
|
|
1628
1621
|
});
|
|
1629
1622
|
|
|
1630
|
-
if (blockerKey) {
|
|
1623
|
+
if (blockerKey && delta != null) {
|
|
1631
1624
|
// Restore the URL to match the current UI, but don't update router state
|
|
1632
1625
|
ignoreNextHistoryUpdate = true;
|
|
1633
1626
|
init.history.go(delta * -1); // Put the blocker into a blocked state
|
|
@@ -2554,9 +2547,9 @@
|
|
|
2554
2547
|
}, isFetchActionRedirect ? {
|
|
2555
2548
|
_isFetchActionRedirect: true
|
|
2556
2549
|
} : {}));
|
|
2557
|
-
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
|
|
2558
2551
|
|
|
2559
|
-
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") {
|
|
2560
2553
|
let newOrigin = init.history.createURL(redirect.location).origin;
|
|
2561
2554
|
|
|
2562
2555
|
if (window.location.origin !== newOrigin) {
|
|
@@ -2734,13 +2727,6 @@
|
|
|
2734
2727
|
|
|
2735
2728
|
if (blockerFunctions.get(key) !== fn) {
|
|
2736
2729
|
blockerFunctions.set(key, fn);
|
|
2737
|
-
|
|
2738
|
-
if (activeBlocker == null) {
|
|
2739
|
-
// This is now the active blocker
|
|
2740
|
-
activeBlocker = key;
|
|
2741
|
-
} else if (key !== activeBlocker) {
|
|
2742
|
-
warning(false, "A router only supports one blocker at a time");
|
|
2743
|
-
}
|
|
2744
2730
|
}
|
|
2745
2731
|
|
|
2746
2732
|
return blocker;
|
|
@@ -2749,10 +2735,6 @@
|
|
|
2749
2735
|
function deleteBlocker(key) {
|
|
2750
2736
|
state.blockers.delete(key);
|
|
2751
2737
|
blockerFunctions.delete(key);
|
|
2752
|
-
|
|
2753
|
-
if (activeBlocker === key) {
|
|
2754
|
-
activeBlocker = null;
|
|
2755
|
-
}
|
|
2756
2738
|
} // Utility function to update blockers, ensuring valid state transitions
|
|
2757
2739
|
|
|
2758
2740
|
|
|
@@ -2774,15 +2756,19 @@
|
|
|
2774
2756
|
historyAction
|
|
2775
2757
|
} = _ref2;
|
|
2776
2758
|
|
|
2777
|
-
if (
|
|
2759
|
+
if (blockerFunctions.size === 0) {
|
|
2778
2760
|
return;
|
|
2779
|
-
} // We
|
|
2780
|
-
//
|
|
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
|
|
2781
2763
|
|
|
2782
2764
|
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2765
|
+
if (blockerFunctions.size > 1) {
|
|
2766
|
+
warning(false, "A router only supports one blocker at a time");
|
|
2767
|
+
}
|
|
2768
|
+
|
|
2769
|
+
let entries = Array.from(blockerFunctions.entries());
|
|
2770
|
+
let [blockerKey, blockerFunction] = entries[entries.length - 1];
|
|
2771
|
+
let blocker = state.blockers.get(blockerKey);
|
|
2786
2772
|
|
|
2787
2773
|
if (blocker && blocker.state === "proceeding") {
|
|
2788
2774
|
// If the blocker is currently proceeding, we don't need to re-check
|
|
@@ -2797,7 +2783,7 @@
|
|
|
2797
2783
|
nextLocation,
|
|
2798
2784
|
historyAction
|
|
2799
2785
|
})) {
|
|
2800
|
-
return
|
|
2786
|
+
return blockerKey;
|
|
2801
2787
|
}
|
|
2802
2788
|
}
|
|
2803
2789
|
|
|
@@ -3547,10 +3533,9 @@
|
|
|
3547
3533
|
|
|
3548
3534
|
if (redirectStatusCodes.has(status)) {
|
|
3549
3535
|
let location = result.headers.get("Location");
|
|
3550
|
-
invariant(location, "Redirects returned/thrown from loaders/actions must have a Location header");
|
|
3551
|
-
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
|
|
3552
3537
|
|
|
3553
|
-
if (!
|
|
3538
|
+
if (!ABSOLUTE_URL_REGEX.test(location)) {
|
|
3554
3539
|
let activeMatches = matches.slice(0, matches.indexOf(match) + 1);
|
|
3555
3540
|
let routePathnames = getPathContributingMatches(activeMatches).map(match => match.pathnameBase);
|
|
3556
3541
|
let resolvedLocation = resolveTo(location, routePathnames, new URL(request.url).pathname);
|