@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/esm/index.js
CHANGED
|
@@ -203,8 +203,8 @@ function interpolatePath(path, params, leaveWildcard) {
|
|
|
203
203
|
return segment.value;
|
|
204
204
|
}));
|
|
205
205
|
}
|
|
206
|
-
function matchPathname(currentPathname, matchLocation) {
|
|
207
|
-
const pathParams = matchByPath(currentPathname, matchLocation);
|
|
206
|
+
function matchPathname(basepath, currentPathname, matchLocation) {
|
|
207
|
+
const pathParams = matchByPath(basepath, currentPathname, matchLocation);
|
|
208
208
|
// const searchMatched = matchBySearch(currentLocation.search, matchLocation)
|
|
209
209
|
|
|
210
210
|
if (matchLocation.to && !pathParams) {
|
|
@@ -212,10 +212,15 @@ function matchPathname(currentPathname, matchLocation) {
|
|
|
212
212
|
}
|
|
213
213
|
return pathParams != null ? pathParams : {};
|
|
214
214
|
}
|
|
215
|
-
function matchByPath(from, matchLocation) {
|
|
215
|
+
function matchByPath(basepath, from, matchLocation) {
|
|
216
216
|
var _matchLocation$to;
|
|
217
|
+
if (basepath && !from.startsWith(basepath)) {
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
from = from.startsWith(basepath) ? from.substring(basepath.length) : from;
|
|
217
221
|
const baseSegments = parsePathname(from);
|
|
218
|
-
const
|
|
222
|
+
const to = "" + ((_matchLocation$to = matchLocation.to) != null ? _matchLocation$to : '*');
|
|
223
|
+
const routeSegments = parsePathname(to);
|
|
219
224
|
const params = {};
|
|
220
225
|
let isMatch = (() => {
|
|
221
226
|
for (let i = 0; i < Math.max(baseSegments.length, routeSegments.length); i++) {
|
|
@@ -826,7 +831,7 @@ function createRouter(userOptions) {
|
|
|
826
831
|
});
|
|
827
832
|
},
|
|
828
833
|
mount: () => {
|
|
829
|
-
|
|
834
|
+
router.__.buildLocation({
|
|
830
835
|
to: '.',
|
|
831
836
|
search: true,
|
|
832
837
|
hash: true
|
|
@@ -834,9 +839,10 @@ function createRouter(userOptions) {
|
|
|
834
839
|
|
|
835
840
|
// If the current location isn't updated, trigger a navigation
|
|
836
841
|
// to the current location. Otherwise, load the current location.
|
|
837
|
-
if (next.href !== router.__location.href) {
|
|
838
|
-
|
|
839
|
-
}
|
|
842
|
+
// if (next.href !== router.__location.href) {
|
|
843
|
+
// router.__.commitLocation(next, true)
|
|
844
|
+
// }
|
|
845
|
+
|
|
840
846
|
if (!router.state.matches.length) {
|
|
841
847
|
router.load();
|
|
842
848
|
}
|
|
@@ -864,6 +870,7 @@ function createRouter(userOptions) {
|
|
|
864
870
|
router.load();
|
|
865
871
|
},
|
|
866
872
|
update: opts => {
|
|
873
|
+
var _trimPath;
|
|
867
874
|
const newHistory = (opts == null ? void 0 : opts.history) !== router.history;
|
|
868
875
|
if (!router.__location || newHistory) {
|
|
869
876
|
if (opts != null && opts.history) {
|
|
@@ -877,7 +884,7 @@ function createRouter(userOptions) {
|
|
|
877
884
|
basepath,
|
|
878
885
|
routeConfig
|
|
879
886
|
} = router.options;
|
|
880
|
-
router.basepath =
|
|
887
|
+
router.basepath = "/" + ((_trimPath = trimPath(basepath != null ? basepath : '')) != null ? _trimPath : '');
|
|
881
888
|
if (routeConfig) {
|
|
882
889
|
router.routesById = {};
|
|
883
890
|
router.routeTree = router.__.buildRouteTree(routeConfig);
|
|
@@ -1075,7 +1082,7 @@ function createRouter(userOptions) {
|
|
|
1075
1082
|
return findMatchInRoutes([...foundRoutes, route], route.childRoutes);
|
|
1076
1083
|
}
|
|
1077
1084
|
const fuzzy = !!(route.routePath !== '/' || (_route$childRoutes2 = route.childRoutes) != null && _route$childRoutes2.length);
|
|
1078
|
-
const matchParams = matchPathname(pathname, {
|
|
1085
|
+
const matchParams = matchPathname(router.basepath, pathname, {
|
|
1079
1086
|
to: route.fullPath,
|
|
1080
1087
|
fuzzy,
|
|
1081
1088
|
caseSensitive: (_route$options$caseSe = route.options.caseSensitive) != null ? _route$options$caseSe : router.options.caseSensitive
|
|
@@ -1126,14 +1133,15 @@ function createRouter(userOptions) {
|
|
|
1126
1133
|
},
|
|
1127
1134
|
loadMatches: async (resolvedMatches, loaderOpts) => {
|
|
1128
1135
|
const matchPromises = resolvedMatches.map(async match => {
|
|
1136
|
+
var _search$__data;
|
|
1129
1137
|
// Validate the match (loads search params etc)
|
|
1130
1138
|
match.__.validate();
|
|
1131
|
-
match.load(loaderOpts);
|
|
1132
1139
|
const search = match.search;
|
|
1133
|
-
if (search.__data && search.__data.matchId !== match.matchId) {
|
|
1140
|
+
if ((_search$__data = search.__data) != null && _search$__data.matchId && search.__data.matchId !== match.matchId) {
|
|
1134
1141
|
return;
|
|
1135
1142
|
}
|
|
1136
|
-
|
|
1143
|
+
match.load(loaderOpts);
|
|
1144
|
+
if (match.status !== 'success' && match.__.loadPromise) {
|
|
1137
1145
|
// Wait for the first sign of activity from the match
|
|
1138
1146
|
await match.__.loadPromise;
|
|
1139
1147
|
}
|
|
@@ -1212,11 +1220,11 @@ function createRouter(userOptions) {
|
|
|
1212
1220
|
if (!((_router$state$pending7 = router.state.pending) != null && _router$state$pending7.location)) {
|
|
1213
1221
|
return false;
|
|
1214
1222
|
}
|
|
1215
|
-
return !!matchPathname(router.state.pending.location.pathname, _extends({}, opts, {
|
|
1223
|
+
return !!matchPathname(router.basepath, router.state.pending.location.pathname, _extends({}, opts, {
|
|
1216
1224
|
to: next.pathname
|
|
1217
1225
|
}));
|
|
1218
1226
|
}
|
|
1219
|
-
return !!matchPathname(router.state.location.pathname, _extends({}, opts, {
|
|
1227
|
+
return !!matchPathname(router.basepath, router.state.location.pathname, _extends({}, opts, {
|
|
1220
1228
|
to: next.pathname
|
|
1221
1229
|
}));
|
|
1222
1230
|
},
|