@tanstack/router-core 1.154.3 → 1.154.4
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/dist/cjs/router.cjs +15 -7
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +5 -0
- package/dist/esm/router.d.ts +5 -0
- package/dist/esm/router.js +15 -7
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +24 -8
package/dist/cjs/router.d.cts
CHANGED
|
@@ -444,6 +444,11 @@ export interface MatchRoutesOpts {
|
|
|
444
444
|
/** Optional match snapshot hint for fast-path (skips path matching) */
|
|
445
445
|
snapshot?: MatchSnapshot;
|
|
446
446
|
}
|
|
447
|
+
export interface MatchRoutesResult {
|
|
448
|
+
matches: Array<AnyRouteMatch>;
|
|
449
|
+
/** Raw string params extracted from path (before parsing) */
|
|
450
|
+
rawParams: Record<string, string>;
|
|
451
|
+
}
|
|
447
452
|
export type InferRouterContext<TRouteTree extends AnyRoute> = TRouteTree['types']['routerContext'];
|
|
448
453
|
export type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext extends InferRouterContext<TRouteTree> ? {
|
|
449
454
|
context?: InferRouterContext<TRouteTree>;
|
package/dist/esm/router.d.ts
CHANGED
|
@@ -444,6 +444,11 @@ export interface MatchRoutesOpts {
|
|
|
444
444
|
/** Optional match snapshot hint for fast-path (skips path matching) */
|
|
445
445
|
snapshot?: MatchSnapshot;
|
|
446
446
|
}
|
|
447
|
+
export interface MatchRoutesResult {
|
|
448
|
+
matches: Array<AnyRouteMatch>;
|
|
449
|
+
/** Raw string params extracted from path (before parsing) */
|
|
450
|
+
rawParams: Record<string, string>;
|
|
451
|
+
}
|
|
447
452
|
export type InferRouterContext<TRouteTree extends AnyRoute> = TRouteTree['types']['routerContext'];
|
|
448
453
|
export type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext extends InferRouterContext<TRouteTree> ? {
|
|
449
454
|
context?: InferRouterContext<TRouteTree>;
|
package/dist/esm/router.js
CHANGED
|
@@ -248,9 +248,9 @@ class RouterCore {
|
|
|
248
248
|
search: locationSearchOrOpts
|
|
249
249
|
},
|
|
250
250
|
opts
|
|
251
|
-
);
|
|
251
|
+
).matches;
|
|
252
252
|
}
|
|
253
|
-
return this.matchRoutesInternal(pathnameOrNext, locationSearchOrOpts);
|
|
253
|
+
return this.matchRoutesInternal(pathnameOrNext, locationSearchOrOpts).matches;
|
|
254
254
|
};
|
|
255
255
|
this.getMatchedRoutes = (pathname) => {
|
|
256
256
|
return getMatchedRoutes({
|
|
@@ -314,9 +314,10 @@ class RouterCore {
|
|
|
314
314
|
path: nextTo,
|
|
315
315
|
params: nextParams
|
|
316
316
|
}).interpolatedPath;
|
|
317
|
-
const destMatches = this.
|
|
318
|
-
|
|
319
|
-
|
|
317
|
+
const { matches: destMatches, rawParams } = this.matchRoutesInternal(
|
|
318
|
+
{ pathname: interpolatedNextTo },
|
|
319
|
+
{ _buildLocation: true }
|
|
320
|
+
);
|
|
320
321
|
const destRoutes = destMatches.map(
|
|
321
322
|
(d) => this.looseRoutesById[d.routeId]
|
|
322
323
|
);
|
|
@@ -371,9 +372,13 @@ class RouterCore {
|
|
|
371
372
|
const hashStr = hash ? `#${hash}` : "";
|
|
372
373
|
let nextState = dest.state === true ? currentLocation.state : dest.state ? functionalUpdate(dest.state, currentLocation.state) : {};
|
|
373
374
|
nextState = replaceEqualDeep(currentLocation.state, nextState);
|
|
375
|
+
const snapshotParams = {
|
|
376
|
+
...rawParams,
|
|
377
|
+
...nextParams
|
|
378
|
+
};
|
|
374
379
|
const matchSnapshot = buildMatchSnapshotFromRoutes({
|
|
375
380
|
routes: destRoutes,
|
|
376
|
-
params:
|
|
381
|
+
params: snapshotParams,
|
|
377
382
|
searchStr,
|
|
378
383
|
globalNotFoundRouteId: globalNotFoundMatch?.routeId
|
|
379
384
|
});
|
|
@@ -1069,17 +1074,20 @@ class RouterCore {
|
|
|
1069
1074
|
const snapshotValid = snapshot && snapshot.routeIds.length > 0 && snapshot.routeIds.every((id) => this.routesById[id]);
|
|
1070
1075
|
let matchedRoutes;
|
|
1071
1076
|
let routeParams;
|
|
1077
|
+
let rawParams;
|
|
1072
1078
|
let globalNotFoundRouteId;
|
|
1073
1079
|
let parsedParams;
|
|
1074
1080
|
if (snapshotValid) {
|
|
1075
1081
|
matchedRoutes = snapshot.routeIds.map((id) => this.routesById[id]);
|
|
1076
1082
|
routeParams = { ...snapshot.params };
|
|
1083
|
+
rawParams = { ...snapshot.params };
|
|
1077
1084
|
globalNotFoundRouteId = snapshot.globalNotFoundRouteId;
|
|
1078
1085
|
parsedParams = snapshot.parsedParams;
|
|
1079
1086
|
} else {
|
|
1080
1087
|
const matchedRoutesResult = this.getMatchedRoutes(next.pathname);
|
|
1081
1088
|
const { foundRoute, routeParams: rp } = matchedRoutesResult;
|
|
1082
1089
|
routeParams = rp;
|
|
1090
|
+
rawParams = { ...rp };
|
|
1083
1091
|
matchedRoutes = matchedRoutesResult.matchedRoutes;
|
|
1084
1092
|
parsedParams = matchedRoutesResult.parsedParams;
|
|
1085
1093
|
let isGlobalNotFound = false;
|
|
@@ -1305,7 +1313,7 @@ class RouterCore {
|
|
|
1305
1313
|
};
|
|
1306
1314
|
}
|
|
1307
1315
|
});
|
|
1308
|
-
return matches;
|
|
1316
|
+
return { matches, rawParams };
|
|
1309
1317
|
}
|
|
1310
1318
|
}
|
|
1311
1319
|
class SearchParamError extends Error {
|