@tanstack/router-core 0.0.1-beta.33 → 0.0.1-beta.35
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 +13 -12
- package/build/cjs/router.js.map +1 -1
- package/build/esm/index.js +22 -16
- 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 +2 -2
- package/build/umd/index.development.js +22 -16
- 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 +28 -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 (!from.startsWith(basepath)) {
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
from = 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);
|
|
@@ -928,10 +935,8 @@ function createRouter(userOptions) {
|
|
|
928
935
|
match
|
|
929
936
|
})));
|
|
930
937
|
} catch (err) {
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
}
|
|
934
|
-
throw err;
|
|
938
|
+
console.info(err);
|
|
939
|
+
invariant(false, "A route's beforeLoad middleware failed! \uD83D\uDC46");
|
|
935
940
|
}
|
|
936
941
|
router.notify();
|
|
937
942
|
|
|
@@ -1075,11 +1080,12 @@ function createRouter(userOptions) {
|
|
|
1075
1080
|
return findMatchInRoutes([...foundRoutes, route], route.childRoutes);
|
|
1076
1081
|
}
|
|
1077
1082
|
const fuzzy = !!(route.routePath !== '/' || (_route$childRoutes2 = route.childRoutes) != null && _route$childRoutes2.length);
|
|
1078
|
-
const matchParams = matchPathname(pathname, {
|
|
1083
|
+
const matchParams = matchPathname(router.basepath, pathname, {
|
|
1079
1084
|
to: route.fullPath,
|
|
1080
1085
|
fuzzy,
|
|
1081
1086
|
caseSensitive: (_route$options$caseSe = route.options.caseSensitive) != null ? _route$options$caseSe : router.options.caseSensitive
|
|
1082
1087
|
});
|
|
1088
|
+
console.log(router.basepath, route.fullPath, fuzzy, pathname, matchParams);
|
|
1083
1089
|
if (matchParams) {
|
|
1084
1090
|
let parsedParams;
|
|
1085
1091
|
try {
|
|
@@ -1213,11 +1219,11 @@ function createRouter(userOptions) {
|
|
|
1213
1219
|
if (!((_router$state$pending7 = router.state.pending) != null && _router$state$pending7.location)) {
|
|
1214
1220
|
return false;
|
|
1215
1221
|
}
|
|
1216
|
-
return !!matchPathname(router.state.pending.location.pathname, _extends({}, opts, {
|
|
1222
|
+
return !!matchPathname(router.basepath, router.state.pending.location.pathname, _extends({}, opts, {
|
|
1217
1223
|
to: next.pathname
|
|
1218
1224
|
}));
|
|
1219
1225
|
}
|
|
1220
|
-
return !!matchPathname(router.state.location.pathname, _extends({}, opts, {
|
|
1226
|
+
return !!matchPathname(router.basepath, router.state.location.pathname, _extends({}, opts, {
|
|
1221
1227
|
to: next.pathname
|
|
1222
1228
|
}));
|
|
1223
1229
|
},
|