@tanstack/react-router 1.49.1 → 1.49.2
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 +207 -194
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +18 -5
- package/dist/esm/router.d.ts +18 -5
- package/dist/esm/router.js +208 -195
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +44 -2
package/package.json
CHANGED
package/src/router.ts
CHANGED
|
@@ -42,6 +42,7 @@ import type {
|
|
|
42
42
|
AnyContext,
|
|
43
43
|
AnyRoute,
|
|
44
44
|
AnyRouteWithContext,
|
|
45
|
+
AnySearchSchema,
|
|
45
46
|
BeforeLoadContextOptions,
|
|
46
47
|
ErrorRouteComponent,
|
|
47
48
|
LoaderFnContext,
|
|
@@ -588,6 +589,8 @@ export function createRouter<
|
|
|
588
589
|
>(options)
|
|
589
590
|
}
|
|
590
591
|
|
|
592
|
+
type MatchRoutesOpts = { preload?: boolean; throwOnError?: boolean }
|
|
593
|
+
|
|
591
594
|
export class Router<
|
|
592
595
|
in out TRouteTree extends AnyRoute,
|
|
593
596
|
in out TTrailingSlashOption extends TrailingSlashOption,
|
|
@@ -950,10 +953,49 @@ export class Router<
|
|
|
950
953
|
return this.routesById as Record<string, AnyRoute>
|
|
951
954
|
}
|
|
952
955
|
|
|
953
|
-
|
|
956
|
+
/**
|
|
957
|
+
@deprecated use the following signature instead
|
|
958
|
+
```ts
|
|
959
|
+
matchRoutes (
|
|
960
|
+
next: ParsedLocation,
|
|
961
|
+
opts?: { preload?: boolean; throwOnError?: boolean },
|
|
962
|
+
): Array<AnyRouteMatch>;
|
|
963
|
+
```
|
|
964
|
+
*/
|
|
965
|
+
public matchRoutes(
|
|
966
|
+
pathname: string,
|
|
967
|
+
locationSearch: AnySearchSchema,
|
|
968
|
+
opts?: MatchRoutesOpts,
|
|
969
|
+
): Array<AnyRouteMatch>
|
|
970
|
+
public matchRoutes(
|
|
971
|
+
next: ParsedLocation,
|
|
972
|
+
opts?: MatchRoutesOpts,
|
|
973
|
+
): Array<AnyRouteMatch>
|
|
974
|
+
|
|
975
|
+
public matchRoutes(
|
|
976
|
+
pathnameOrNext: string | ParsedLocation,
|
|
977
|
+
locationSearchOrOpts?:
|
|
978
|
+
| AnySearchSchema
|
|
979
|
+
| { preload?: boolean; throwOnError?: boolean },
|
|
980
|
+
opts?: { preload?: boolean; throwOnError?: boolean },
|
|
981
|
+
) {
|
|
982
|
+
if (typeof pathnameOrNext === 'string') {
|
|
983
|
+
return this.matchRoutesInternal(
|
|
984
|
+
{
|
|
985
|
+
pathname: pathnameOrNext,
|
|
986
|
+
search: locationSearchOrOpts,
|
|
987
|
+
} as ParsedLocation,
|
|
988
|
+
opts,
|
|
989
|
+
)
|
|
990
|
+
} else {
|
|
991
|
+
return this.matchRoutesInternal(pathnameOrNext, locationSearchOrOpts)
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
private matchRoutesInternal(
|
|
954
996
|
next: ParsedLocation,
|
|
955
997
|
opts?: { preload?: boolean; throwOnError?: boolean },
|
|
956
|
-
): Array<AnyRouteMatch>
|
|
998
|
+
): Array<AnyRouteMatch> {
|
|
957
999
|
let routeParams: Record<string, string> = {}
|
|
958
1000
|
|
|
959
1001
|
const foundRoute = this.flatRoutes.find((route) => {
|