@remix-run/router 1.9.0-pre.0 → 1.9.0-pre.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 +10 -0
- package/dist/history.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/router.cjs.js +21 -34
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +2 -9
- package/dist/router.js +17 -19
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +21 -34
- 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/dist/utils.d.ts +16 -8
- package/history.ts +5 -2
- package/index.ts +2 -0
- package/package.json +1 -1
- package/router.ts +4 -27
- package/utils.ts +33 -8
package/dist/router.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.9.0-pre.
|
|
2
|
+
* @remix-run/router v1.9.0-pre.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -47,25 +47,23 @@
|
|
|
47
47
|
* The pathname, search, and hash values of a URL.
|
|
48
48
|
*/
|
|
49
49
|
|
|
50
|
+
// TODO: (v7) Change the Location generic default from `any` to `unknown` and
|
|
51
|
+
// remove Remix `useLocation` wrapper.
|
|
50
52
|
/**
|
|
51
53
|
* An entry in a history stack. A location contains information about the
|
|
52
54
|
* URL path, as well as possibly some arbitrary state and a key.
|
|
53
55
|
*/
|
|
54
|
-
|
|
55
56
|
/**
|
|
56
57
|
* A change to the current location.
|
|
57
58
|
*/
|
|
58
|
-
|
|
59
59
|
/**
|
|
60
60
|
* A function that receives notifications about location changes.
|
|
61
61
|
*/
|
|
62
|
-
|
|
63
62
|
/**
|
|
64
63
|
* Describes a location that is the destination of some navigation, either via
|
|
65
64
|
* `history.push` or `history.replace`. May be either a URL or the pieces of a
|
|
66
65
|
* URL path.
|
|
67
66
|
*/
|
|
68
|
-
|
|
69
67
|
/**
|
|
70
68
|
* A history is an interface to the navigation stack. The history serves as the
|
|
71
69
|
* source of truth for the current location, as well as provides a set of
|
|
@@ -74,7 +72,6 @@
|
|
|
74
72
|
* It is similar to the DOM's `window.history` object, but with a smaller, more
|
|
75
73
|
* focused API.
|
|
76
74
|
*/
|
|
77
|
-
|
|
78
75
|
const PopStateEventType = "popstate";
|
|
79
76
|
//#endregion
|
|
80
77
|
|
|
@@ -607,32 +604,28 @@
|
|
|
607
604
|
* this as a private implementation detail in case they diverge in the future.
|
|
608
605
|
*/
|
|
609
606
|
|
|
607
|
+
// TODO: (v7) Change the defaults from any to unknown in and remove Remix wrappers:
|
|
608
|
+
// ActionFunction, ActionFunctionArgs, LoaderFunction, LoaderFunctionArgs
|
|
610
609
|
/**
|
|
611
610
|
* Arguments passed to loader functions
|
|
612
611
|
*/
|
|
613
|
-
|
|
614
612
|
/**
|
|
615
613
|
* Arguments passed to action functions
|
|
616
614
|
*/
|
|
617
|
-
|
|
618
615
|
/**
|
|
619
616
|
* Loaders and actions can return anything except `undefined` (`null` is a
|
|
620
617
|
* valid return value if there is no data to return). Responses are preferred
|
|
621
618
|
* and will ease any future migration to Remix
|
|
622
619
|
*/
|
|
623
|
-
|
|
624
620
|
/**
|
|
625
621
|
* Route loader function signature
|
|
626
622
|
*/
|
|
627
|
-
|
|
628
623
|
/**
|
|
629
624
|
* Route action function signature
|
|
630
625
|
*/
|
|
631
|
-
|
|
632
626
|
/**
|
|
633
627
|
* Arguments passed to shouldRevalidate function
|
|
634
628
|
*/
|
|
635
|
-
|
|
636
629
|
/**
|
|
637
630
|
* Route shouldRevalidate function signature. This runs after any submission
|
|
638
631
|
* (navigation or fetcher), so we flatten the navigation/fetcher submission
|
|
@@ -640,25 +633,21 @@
|
|
|
640
633
|
* or a fetcher, what really matters is the URLs and the formData since loaders
|
|
641
634
|
* have to re-run based on the data models that were potentially mutated.
|
|
642
635
|
*/
|
|
643
|
-
|
|
644
636
|
/**
|
|
645
637
|
* Function provided by the framework-aware layers to set `hasErrorBoundary`
|
|
646
638
|
* from the framework-aware `errorElement` prop
|
|
647
639
|
*
|
|
648
640
|
* @deprecated Use `mapRouteProperties` instead
|
|
649
641
|
*/
|
|
650
|
-
|
|
651
642
|
/**
|
|
652
643
|
* Function provided by the framework-aware layers to set any framework-specific
|
|
653
644
|
* properties from framework-agnostic properties
|
|
654
645
|
*/
|
|
655
|
-
|
|
656
646
|
/**
|
|
657
647
|
* Keys we cannot change from within a lazy() function. We spread all other keys
|
|
658
648
|
* onto the route. Either they're meaningful to the router, or they'll get
|
|
659
649
|
* ignored.
|
|
660
650
|
*/
|
|
661
|
-
|
|
662
651
|
const immutableRouteKeys = new Set(["lazy", "caseSensitive", "path", "id", "index", "children"]);
|
|
663
652
|
|
|
664
653
|
/**
|
|
@@ -775,6 +764,20 @@
|
|
|
775
764
|
}
|
|
776
765
|
return matches;
|
|
777
766
|
}
|
|
767
|
+
function convertRouteMatchToUiMatch(match, loaderData) {
|
|
768
|
+
let {
|
|
769
|
+
route,
|
|
770
|
+
pathname,
|
|
771
|
+
params
|
|
772
|
+
} = match;
|
|
773
|
+
return {
|
|
774
|
+
id: route.id,
|
|
775
|
+
pathname,
|
|
776
|
+
params,
|
|
777
|
+
data: loaderData[route.id],
|
|
778
|
+
handle: route.handle
|
|
779
|
+
};
|
|
780
|
+
}
|
|
778
781
|
function flattenRoutes(routes, branches, parentsMeta, parentPath) {
|
|
779
782
|
if (branches === void 0) {
|
|
780
783
|
branches = [];
|
|
@@ -2974,7 +2977,7 @@
|
|
|
2974
2977
|
}
|
|
2975
2978
|
function getScrollKey(location, matches) {
|
|
2976
2979
|
if (getScrollRestorationKey) {
|
|
2977
|
-
let key = getScrollRestorationKey(location, matches.map(m =>
|
|
2980
|
+
let key = getScrollRestorationKey(location, matches.map(m => convertRouteMatchToUiMatch(m, state.loaderData)));
|
|
2978
2981
|
return key || location.key;
|
|
2979
2982
|
}
|
|
2980
2983
|
return location.key;
|
|
@@ -4379,23 +4382,6 @@
|
|
|
4379
4382
|
function hasNakedIndexQuery(search) {
|
|
4380
4383
|
return new URLSearchParams(search).getAll("index").some(v => v === "");
|
|
4381
4384
|
}
|
|
4382
|
-
|
|
4383
|
-
// Note: This should match the format exported by useMatches, so if you change
|
|
4384
|
-
// this please also change that :) Eventually we'll DRY this up
|
|
4385
|
-
function createUseMatchesMatch(match, loaderData) {
|
|
4386
|
-
let {
|
|
4387
|
-
route,
|
|
4388
|
-
pathname,
|
|
4389
|
-
params
|
|
4390
|
-
} = match;
|
|
4391
|
-
return {
|
|
4392
|
-
id: route.id,
|
|
4393
|
-
pathname,
|
|
4394
|
-
params,
|
|
4395
|
-
data: loaderData[route.id],
|
|
4396
|
-
handle: route.handle
|
|
4397
|
-
};
|
|
4398
|
-
}
|
|
4399
4385
|
function getTargetMatch(matches, location) {
|
|
4400
4386
|
let search = typeof location === "string" ? parsePath(location).search : location.search;
|
|
4401
4387
|
if (matches[matches.length - 1].route.index && hasNakedIndexQuery(search || "")) {
|
|
@@ -4551,6 +4537,7 @@
|
|
|
4551
4537
|
exports.UNSAFE_DEFERRED_SYMBOL = UNSAFE_DEFERRED_SYMBOL;
|
|
4552
4538
|
exports.UNSAFE_DeferredData = DeferredData;
|
|
4553
4539
|
exports.UNSAFE_ErrorResponseImpl = ErrorResponseImpl;
|
|
4540
|
+
exports.UNSAFE_convertRouteMatchToUiMatch = convertRouteMatchToUiMatch;
|
|
4554
4541
|
exports.UNSAFE_convertRoutesToDataRoutes = convertRoutesToDataRoutes;
|
|
4555
4542
|
exports.UNSAFE_getPathContributingMatches = getPathContributingMatches;
|
|
4556
4543
|
exports.UNSAFE_invariant = invariant;
|