@tanstack/react-router 1.31.29 → 1.32.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/Matches.d.cts +6 -9
- package/dist/cjs/RouterProvider.d.cts +6 -6
- package/dist/cjs/awaited.d.cts +1 -1
- package/dist/cjs/defer.d.cts +1 -0
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +38 -79
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +4 -3
- package/dist/cjs/lazyRouteComponent.d.cts +2 -1
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +56 -50
- package/dist/cjs/location.d.cts +3 -2
- package/dist/cjs/not-found.d.cts +2 -2
- package/dist/cjs/path.d.cts +3 -2
- package/dist/cjs/redirects.d.cts +5 -4
- package/dist/cjs/route.cjs +1 -1
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +59 -52
- package/dist/cjs/routeInfo.d.cts +12 -11
- package/dist/cjs/router.cjs +2 -2
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +19 -20
- package/dist/cjs/routerContext.d.cts +1 -1
- package/dist/cjs/scroll-restoration.d.cts +2 -1
- package/dist/cjs/searchParams.d.cts +2 -1
- package/dist/cjs/useBlocker.d.cts +3 -2
- package/dist/cjs/useLocation.cjs +10 -0
- package/dist/cjs/useLocation.cjs.map +1 -0
- package/dist/cjs/useLocation.d.cts +5 -0
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useNavigate.d.cts +5 -4
- package/dist/cjs/useParams.d.cts +5 -5
- package/dist/cjs/useRouteContext.d.cts +5 -4
- package/dist/cjs/useRouter.d.cts +2 -1
- package/dist/cjs/useRouterState.d.cts +2 -1
- package/dist/cjs/useSearch.d.cts +5 -4
- package/dist/esm/Matches.d.ts +6 -9
- package/dist/esm/RouterProvider.d.ts +6 -6
- package/dist/esm/awaited.d.ts +1 -1
- package/dist/esm/defer.d.ts +1 -0
- package/dist/esm/fileRoute.d.ts +38 -79
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/index.d.ts +4 -3
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lazyRouteComponent.d.ts +2 -1
- package/dist/esm/link.d.ts +56 -50
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/location.d.ts +3 -2
- package/dist/esm/not-found.d.ts +2 -2
- package/dist/esm/path.d.ts +3 -2
- package/dist/esm/redirects.d.ts +5 -4
- package/dist/esm/route.d.ts +59 -52
- package/dist/esm/route.js +1 -1
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/routeInfo.d.ts +12 -11
- package/dist/esm/router.d.ts +19 -20
- package/dist/esm/router.js +2 -2
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.d.ts +1 -1
- package/dist/esm/scroll-restoration.d.ts +2 -1
- package/dist/esm/searchParams.d.ts +2 -1
- package/dist/esm/useBlocker.d.ts +3 -2
- package/dist/esm/useLocation.d.ts +5 -0
- package/dist/esm/useLocation.js +10 -0
- package/dist/esm/useLocation.js.map +1 -0
- package/dist/esm/useNavigate.d.ts +5 -4
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.d.ts +5 -5
- package/dist/esm/useRouteContext.d.ts +5 -4
- package/dist/esm/useRouter.d.ts +2 -1
- package/dist/esm/useRouterState.d.ts +2 -1
- package/dist/esm/useSearch.d.ts +5 -4
- package/package.json +2 -10
- package/src/fileRoute.ts +26 -104
- package/src/index.tsx +1 -8
- package/src/link.tsx +205 -156
- package/src/route.ts +121 -106
- package/src/routeInfo.ts +24 -22
- package/src/useLocation.tsx +15 -0
- package/src/useNavigate.tsx +2 -2
package/dist/esm/useRouter.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AnyRouter, RegisteredRouter, RouterState } from './router.js';
|
|
2
|
+
|
|
2
3
|
export declare function useRouterState<TRouter extends AnyRouter = RegisteredRouter, TSelected = RouterState<TRouter['routeTree']>>(opts?: {
|
|
3
4
|
router?: TRouter;
|
|
4
5
|
select: (state: RouterState<RegisteredRouter['routeTree']>) => TSelected;
|
package/dist/esm/useSearch.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { AnyRoute, RootSearchSchema } from './route.js';
|
|
2
|
+
import { FullSearchSchema, RouteById, RouteIds } from './routeInfo.js';
|
|
3
|
+
import { RegisteredRouter } from './router.js';
|
|
4
|
+
import { StrictOrFrom } from './utils.js';
|
|
5
|
+
|
|
5
6
|
export declare function useSearch<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>, TReturnIntersection extends boolean = false, TSearch = TReturnIntersection extends false ? Exclude<RouteById<TRouteTree, TFrom>['types']['fullSearchSchema'], RootSearchSchema> : Partial<Omit<FullSearchSchema<TRouteTree>, keyof RootSearchSchema>>, TSelected = TSearch>(opts: StrictOrFrom<TFrom, TReturnIntersection> & {
|
|
6
7
|
select?: (search: TSearch) => TSelected;
|
|
7
8
|
}): TSelected;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.32.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -66,13 +66,5 @@
|
|
|
66
66
|
"react": ">=16.8",
|
|
67
67
|
"react-dom": ">=16.8"
|
|
68
68
|
},
|
|
69
|
-
"scripts": {
|
|
70
|
-
"clean": "rimraf ./dist && rimraf ./coverage",
|
|
71
|
-
"test:eslint": "eslint --ext .ts,.tsx ./src",
|
|
72
|
-
"test:types": "tsc --noEmit",
|
|
73
|
-
"test:unit": "vitest --typecheck",
|
|
74
|
-
"test:unit:dev": "pnpm run test:unit --watch",
|
|
75
|
-
"test:build": "publint --strict",
|
|
76
|
-
"build": "vite build"
|
|
77
|
-
}
|
|
69
|
+
"scripts": {}
|
|
78
70
|
}
|
package/src/fileRoute.ts
CHANGED
|
@@ -11,10 +11,13 @@ import type {
|
|
|
11
11
|
AnyRoute,
|
|
12
12
|
AnySearchSchema,
|
|
13
13
|
FileBaseRouteOptions,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
ResolveAllContext,
|
|
15
|
+
ResolveAllParamsFromParent,
|
|
16
16
|
ResolveFullSearchSchema,
|
|
17
17
|
ResolveFullSearchSchemaInput,
|
|
18
|
+
ResolveLoaderData,
|
|
19
|
+
ResolveRouteContext,
|
|
20
|
+
ResolveSearchSchemaUsed,
|
|
18
21
|
RootRouteId,
|
|
19
22
|
Route,
|
|
20
23
|
RouteConstraints,
|
|
@@ -36,79 +39,13 @@ export interface FileRoutesByPath {
|
|
|
36
39
|
// }
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
type Replace<
|
|
40
|
-
TValue extends string,
|
|
41
|
-
TFrom extends string,
|
|
42
|
-
TTo extends string,
|
|
43
|
-
TAcc extends string = '',
|
|
44
|
-
> = TValue extends `${infer Start}${TFrom}${infer Rest}`
|
|
45
|
-
? Replace<Rest, TFrom, TTo, `${TAcc}${Start}${TTo}`>
|
|
46
|
-
: `${TAcc}${TValue}`
|
|
47
|
-
|
|
48
|
-
export type TrimLeft<
|
|
49
|
-
TValue extends string,
|
|
50
|
-
TStartsWith extends string,
|
|
51
|
-
> = TValue extends `${TStartsWith}${infer U}` ? U : TValue
|
|
52
|
-
|
|
53
|
-
export type TrimRight<
|
|
54
|
-
TValue extends string,
|
|
55
|
-
TEndsWith extends string,
|
|
56
|
-
> = TValue extends `${infer U}${TEndsWith}` ? U : TValue
|
|
57
|
-
|
|
58
|
-
export type Trim<TValue extends string, TFind extends string> = TrimLeft<
|
|
59
|
-
TrimRight<TValue, TFind>,
|
|
60
|
-
TFind
|
|
61
|
-
>
|
|
62
|
-
|
|
63
|
-
export type RemoveUnderScores<T extends string> = Replace<
|
|
64
|
-
Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>,
|
|
65
|
-
'/_',
|
|
66
|
-
'/'
|
|
67
|
-
>
|
|
68
|
-
|
|
69
|
-
type RemoveRouteGroups<T extends string> =
|
|
70
|
-
T extends `${infer Before}(${string})${infer After}`
|
|
71
|
-
? RemoveRouteGroups<`${Before}${After}`>
|
|
72
|
-
: T
|
|
73
|
-
|
|
74
|
-
type NormalizeSlashes<T extends string> =
|
|
75
|
-
T extends `${infer Before}//${infer After}`
|
|
76
|
-
? NormalizeSlashes<`${Before}/${After}`>
|
|
77
|
-
: T
|
|
78
|
-
|
|
79
|
-
export type ResolveFilePath<
|
|
80
|
-
TParentRoute extends AnyRoute,
|
|
81
|
-
TFilePath extends string,
|
|
82
|
-
> = TParentRoute['id'] extends RootRouteId
|
|
83
|
-
? TrimPathLeft<TFilePath>
|
|
84
|
-
: TFilePath extends `${TParentRoute['types']['customId']}${infer TRest}`
|
|
85
|
-
? TRest
|
|
86
|
-
: TFilePath
|
|
87
|
-
|
|
88
|
-
export type FileRoutePath<
|
|
89
|
-
TParentRoute extends AnyRoute,
|
|
90
|
-
TFilePath extends string,
|
|
91
|
-
TResolvedFilePath = ResolveFilePath<TParentRoute, TFilePath>,
|
|
92
|
-
> = TResolvedFilePath extends `_${string}`
|
|
93
|
-
? ''
|
|
94
|
-
: TResolvedFilePath extends `/_${string}`
|
|
95
|
-
? ''
|
|
96
|
-
: TResolvedFilePath
|
|
97
|
-
|
|
98
42
|
export function createFileRoute<
|
|
99
43
|
TFilePath extends keyof FileRoutesByPath,
|
|
100
44
|
TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],
|
|
101
|
-
TId extends RouteConstraints['TId'] =
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
TParentRoute,
|
|
106
|
-
TFilePath
|
|
107
|
-
>,
|
|
108
|
-
TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<
|
|
109
|
-
TParentRoute,
|
|
110
|
-
NormalizeSlashes<RemoveRouteGroups<RemoveUnderScores<TPath>>>
|
|
111
|
-
>,
|
|
45
|
+
TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],
|
|
46
|
+
TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],
|
|
47
|
+
TFullPath extends
|
|
48
|
+
RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],
|
|
112
49
|
>(path: TFilePath) {
|
|
113
50
|
return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {
|
|
114
51
|
silent: true,
|
|
@@ -122,15 +59,10 @@ export function createFileRoute<
|
|
|
122
59
|
export class FileRoute<
|
|
123
60
|
TFilePath extends keyof FileRoutesByPath,
|
|
124
61
|
TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],
|
|
125
|
-
TId extends RouteConstraints['TId'] = TFilePath,
|
|
126
|
-
TPath extends RouteConstraints['TPath'] =
|
|
127
|
-
|
|
128
|
-
TFilePath
|
|
129
|
-
>,
|
|
130
|
-
TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<
|
|
131
|
-
TParentRoute,
|
|
132
|
-
RemoveUnderScores<TPath>
|
|
133
|
-
>,
|
|
62
|
+
TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],
|
|
63
|
+
TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],
|
|
64
|
+
TFullPath extends
|
|
65
|
+
RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],
|
|
134
66
|
> {
|
|
135
67
|
silent?: boolean
|
|
136
68
|
|
|
@@ -142,37 +74,27 @@ export class FileRoute<
|
|
|
142
74
|
}
|
|
143
75
|
|
|
144
76
|
createRoute = <
|
|
145
|
-
TSearchSchemaInput
|
|
146
|
-
TSearchSchema
|
|
147
|
-
TSearchSchemaUsed =
|
|
148
|
-
|
|
149
|
-
|
|
77
|
+
TSearchSchemaInput = {},
|
|
78
|
+
TSearchSchema = {},
|
|
79
|
+
TSearchSchemaUsed = ResolveSearchSchemaUsed<
|
|
80
|
+
TSearchSchemaInput,
|
|
81
|
+
TSearchSchema
|
|
82
|
+
>,
|
|
150
83
|
TFullSearchSchemaInput = ResolveFullSearchSchemaInput<
|
|
151
84
|
TParentRoute,
|
|
152
85
|
TSearchSchemaUsed
|
|
153
86
|
>,
|
|
154
87
|
TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,
|
|
155
88
|
TParams = Record<ParsePathParams<TPath>, string>,
|
|
156
|
-
TAllParams =
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
>,
|
|
160
|
-
|
|
161
|
-
RouteConstraints['TRouteContext'] = RouteContext,
|
|
162
|
-
TRouteContext = [TRouteContextReturn] extends [never]
|
|
163
|
-
? RouteContext
|
|
164
|
-
: TRouteContextReturn,
|
|
165
|
-
TAllContext = Assign<
|
|
166
|
-
IsAny<TParentRoute['types']['allContext'], {}>,
|
|
167
|
-
TRouteContext
|
|
168
|
-
>,
|
|
169
|
-
TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,
|
|
89
|
+
TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
90
|
+
TRouteContextReturn = RouteContext,
|
|
91
|
+
TRouteContext = ResolveRouteContext<TRouteContextReturn>,
|
|
92
|
+
TAllContext = ResolveAllContext<TParentRoute, TRouteContext>,
|
|
93
|
+
TRouterContext = AnyContext,
|
|
170
94
|
TLoaderDeps extends Record<string, any> = {},
|
|
171
95
|
TLoaderDataReturn = unknown,
|
|
172
|
-
TLoaderData =
|
|
173
|
-
|
|
174
|
-
: TLoaderDataReturn,
|
|
175
|
-
TChildren extends RouteConstraints['TChildren'] = unknown,
|
|
96
|
+
TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
|
|
97
|
+
TChildren = unknown,
|
|
176
98
|
>(
|
|
177
99
|
options?: FileBaseRouteOptions<
|
|
178
100
|
TParentRoute,
|
package/src/index.tsx
CHANGED
|
@@ -28,12 +28,6 @@ export {
|
|
|
28
28
|
createLazyRoute,
|
|
29
29
|
createLazyFileRoute,
|
|
30
30
|
type FileRoutesByPath,
|
|
31
|
-
type Trim,
|
|
32
|
-
type TrimLeft,
|
|
33
|
-
type TrimRight,
|
|
34
|
-
type RemoveUnderScores,
|
|
35
|
-
type ResolveFilePath,
|
|
36
|
-
type FileRoutePath,
|
|
37
31
|
type LazyRouteOptions,
|
|
38
32
|
} from './fileRoute'
|
|
39
33
|
export * from './history'
|
|
@@ -60,7 +54,6 @@ export {
|
|
|
60
54
|
type ToMaskOptions,
|
|
61
55
|
type ToSubOptions,
|
|
62
56
|
type ResolveRoute,
|
|
63
|
-
type ParamOptions,
|
|
64
57
|
type SearchParamOptions,
|
|
65
58
|
type PathParamOptions,
|
|
66
59
|
type ToPathOption,
|
|
@@ -162,7 +155,6 @@ export {
|
|
|
162
155
|
type ResolveFullSearchSchema,
|
|
163
156
|
type ResolveFullSearchSchemaInput,
|
|
164
157
|
type AnyRoute,
|
|
165
|
-
type MergeFromFromParent,
|
|
166
158
|
type ResolveAllParams,
|
|
167
159
|
type RouteConstraints,
|
|
168
160
|
type AnyRootRoute,
|
|
@@ -258,6 +250,7 @@ export {
|
|
|
258
250
|
export { useRouteContext } from './useRouteContext'
|
|
259
251
|
export { useRouter } from './useRouter'
|
|
260
252
|
export { useRouterState } from './useRouterState'
|
|
253
|
+
export { useLocation } from './useLocation'
|
|
261
254
|
export {
|
|
262
255
|
escapeJSON, // SSR
|
|
263
256
|
useLayoutEffect, // SSR
|