@tanstack/router-core 0.0.1-beta.31 → 0.0.1-beta.34
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/build/cjs/path.js +9 -4
- package/build/cjs/path.js.map +1 -1
- package/build/cjs/router.js +14 -11
- package/build/cjs/router.js.map +1 -1
- package/build/esm/index.js +23 -15
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +132 -132
- package/build/types/index.d.ts +4 -3
- package/build/umd/index.development.js +23 -15
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/path.ts +10 -2
- package/src/router.ts +21 -14
package/build/types/index.d.ts
CHANGED
|
@@ -193,8 +193,9 @@ interface MatchLocation {
|
|
|
193
193
|
fromCurrent?: boolean;
|
|
194
194
|
}
|
|
195
195
|
interface MatchRouteOptions {
|
|
196
|
-
pending
|
|
196
|
+
pending?: boolean;
|
|
197
197
|
caseSensitive?: boolean;
|
|
198
|
+
fuzzy?: boolean;
|
|
198
199
|
}
|
|
199
200
|
interface DehydratedRouterState extends Pick<RouterState, 'status' | 'location' | 'lastUpdated' | 'location'> {
|
|
200
201
|
matches: DehydratedRouteMatch[];
|
|
@@ -618,8 +619,8 @@ declare function trimPath(path: string): string;
|
|
|
618
619
|
declare function resolvePath(basepath: string, base: string, to: string): string;
|
|
619
620
|
declare function parsePathname(pathname?: string): Segment[];
|
|
620
621
|
declare function interpolatePath(path: string | undefined, params: any, leaveWildcard?: boolean): string;
|
|
621
|
-
declare function matchPathname(currentPathname: string, matchLocation: Pick<MatchLocation, 'to' | 'fuzzy' | 'caseSensitive'>): AnyPathParams | undefined;
|
|
622
|
-
declare function matchByPath(from: string, matchLocation: Pick<MatchLocation, 'to' | 'caseSensitive' | 'fuzzy'>): Record<string, string> | undefined;
|
|
622
|
+
declare function matchPathname(basepath: string, currentPathname: string, matchLocation: Pick<MatchLocation, 'to' | 'fuzzy' | 'caseSensitive'>): AnyPathParams | undefined;
|
|
623
|
+
declare function matchByPath(basepath: string, from: string, matchLocation: Pick<MatchLocation, 'to' | 'caseSensitive' | 'fuzzy'>): Record<string, string> | undefined;
|
|
623
624
|
|
|
624
625
|
declare function encode(obj: any, pfx?: string): string;
|
|
625
626
|
declare function decode(str: any): {};
|
|
@@ -1020,8 +1020,8 @@
|
|
|
1020
1020
|
return segment.value;
|
|
1021
1021
|
}));
|
|
1022
1022
|
}
|
|
1023
|
-
function matchPathname(currentPathname, matchLocation) {
|
|
1024
|
-
const pathParams = matchByPath(currentPathname, matchLocation);
|
|
1023
|
+
function matchPathname(basepath, currentPathname, matchLocation) {
|
|
1024
|
+
const pathParams = matchByPath(basepath, currentPathname, matchLocation);
|
|
1025
1025
|
// const searchMatched = matchBySearch(currentLocation.search, matchLocation)
|
|
1026
1026
|
|
|
1027
1027
|
if (matchLocation.to && !pathParams) {
|
|
@@ -1029,10 +1029,15 @@
|
|
|
1029
1029
|
}
|
|
1030
1030
|
return pathParams != null ? pathParams : {};
|
|
1031
1031
|
}
|
|
1032
|
-
function matchByPath(from, matchLocation) {
|
|
1032
|
+
function matchByPath(basepath, from, matchLocation) {
|
|
1033
1033
|
var _matchLocation$to;
|
|
1034
|
+
if (basepath && !from.startsWith(basepath)) {
|
|
1035
|
+
return undefined;
|
|
1036
|
+
}
|
|
1037
|
+
from = from.startsWith(basepath) ? from.substring(basepath.length) : from;
|
|
1034
1038
|
const baseSegments = parsePathname(from);
|
|
1035
|
-
const
|
|
1039
|
+
const to = "" + ((_matchLocation$to = matchLocation.to) != null ? _matchLocation$to : '*');
|
|
1040
|
+
const routeSegments = parsePathname(to);
|
|
1036
1041
|
const params = {};
|
|
1037
1042
|
let isMatch = (() => {
|
|
1038
1043
|
for (let i = 0; i < Math.max(baseSegments.length, routeSegments.length); i++) {
|
|
@@ -1643,7 +1648,7 @@
|
|
|
1643
1648
|
});
|
|
1644
1649
|
},
|
|
1645
1650
|
mount: () => {
|
|
1646
|
-
|
|
1651
|
+
router.__.buildLocation({
|
|
1647
1652
|
to: '.',
|
|
1648
1653
|
search: true,
|
|
1649
1654
|
hash: true
|
|
@@ -1651,9 +1656,10 @@
|
|
|
1651
1656
|
|
|
1652
1657
|
// If the current location isn't updated, trigger a navigation
|
|
1653
1658
|
// to the current location. Otherwise, load the current location.
|
|
1654
|
-
if (next.href !== router.__location.href) {
|
|
1655
|
-
|
|
1656
|
-
}
|
|
1659
|
+
// if (next.href !== router.__location.href) {
|
|
1660
|
+
// router.__.commitLocation(next, true)
|
|
1661
|
+
// }
|
|
1662
|
+
|
|
1657
1663
|
if (!router.state.matches.length) {
|
|
1658
1664
|
router.load();
|
|
1659
1665
|
}
|
|
@@ -1681,6 +1687,7 @@
|
|
|
1681
1687
|
router.load();
|
|
1682
1688
|
},
|
|
1683
1689
|
update: opts => {
|
|
1690
|
+
var _trimPath;
|
|
1684
1691
|
const newHistory = (opts == null ? void 0 : opts.history) !== router.history;
|
|
1685
1692
|
if (!router.__location || newHistory) {
|
|
1686
1693
|
if (opts != null && opts.history) {
|
|
@@ -1694,7 +1701,7 @@
|
|
|
1694
1701
|
basepath,
|
|
1695
1702
|
routeConfig
|
|
1696
1703
|
} = router.options;
|
|
1697
|
-
router.basepath =
|
|
1704
|
+
router.basepath = "/" + ((_trimPath = trimPath(basepath != null ? basepath : '')) != null ? _trimPath : '');
|
|
1698
1705
|
if (routeConfig) {
|
|
1699
1706
|
router.routesById = {};
|
|
1700
1707
|
router.routeTree = router.__.buildRouteTree(routeConfig);
|
|
@@ -1892,7 +1899,7 @@
|
|
|
1892
1899
|
return findMatchInRoutes([...foundRoutes, route], route.childRoutes);
|
|
1893
1900
|
}
|
|
1894
1901
|
const fuzzy = !!(route.routePath !== '/' || (_route$childRoutes2 = route.childRoutes) != null && _route$childRoutes2.length);
|
|
1895
|
-
const matchParams = matchPathname(pathname, {
|
|
1902
|
+
const matchParams = matchPathname(router.basepath, pathname, {
|
|
1896
1903
|
to: route.fullPath,
|
|
1897
1904
|
fuzzy,
|
|
1898
1905
|
caseSensitive: (_route$options$caseSe = route.options.caseSensitive) != null ? _route$options$caseSe : router.options.caseSensitive
|
|
@@ -1943,14 +1950,15 @@
|
|
|
1943
1950
|
},
|
|
1944
1951
|
loadMatches: async (resolvedMatches, loaderOpts) => {
|
|
1945
1952
|
const matchPromises = resolvedMatches.map(async match => {
|
|
1953
|
+
var _search$__data;
|
|
1946
1954
|
// Validate the match (loads search params etc)
|
|
1947
1955
|
match.__.validate();
|
|
1948
|
-
match.load(loaderOpts);
|
|
1949
1956
|
const search = match.search;
|
|
1950
|
-
if (search.__data && search.__data.matchId !== match.matchId) {
|
|
1957
|
+
if ((_search$__data = search.__data) != null && _search$__data.matchId && search.__data.matchId !== match.matchId) {
|
|
1951
1958
|
return;
|
|
1952
1959
|
}
|
|
1953
|
-
|
|
1960
|
+
match.load(loaderOpts);
|
|
1961
|
+
if (match.status !== 'success' && match.__.loadPromise) {
|
|
1954
1962
|
// Wait for the first sign of activity from the match
|
|
1955
1963
|
await match.__.loadPromise;
|
|
1956
1964
|
}
|
|
@@ -2029,11 +2037,11 @@
|
|
|
2029
2037
|
if (!((_router$state$pending7 = router.state.pending) != null && _router$state$pending7.location)) {
|
|
2030
2038
|
return false;
|
|
2031
2039
|
}
|
|
2032
|
-
return !!matchPathname(router.state.pending.location.pathname, _extends({}, opts, {
|
|
2040
|
+
return !!matchPathname(router.basepath, router.state.pending.location.pathname, _extends({}, opts, {
|
|
2033
2041
|
to: next.pathname
|
|
2034
2042
|
}));
|
|
2035
2043
|
}
|
|
2036
|
-
return !!matchPathname(router.state.location.pathname, _extends({}, opts, {
|
|
2044
|
+
return !!matchPathname(router.basepath, router.state.location.pathname, _extends({}, opts, {
|
|
2037
2045
|
to: next.pathname
|
|
2038
2046
|
}));
|
|
2039
2047
|
},
|