@tanstack/react-router 1.45.10 → 1.45.13
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/Match.cjs.map +1 -1
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Matches.d.cts +1 -1
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/Transitioner.cjs +0 -3
- package/dist/cjs/Transitioner.cjs.map +1 -1
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +2 -3
- package/dist/cjs/index.d.cts +37 -20
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/not-found.d.cts +1 -1
- package/dist/cjs/path.cjs +5 -1
- package/dist/cjs/path.cjs.map +1 -1
- package/dist/cjs/path.d.cts +1 -1
- package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +0 -1
- package/dist/cjs/router.cjs +2 -2
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +3 -1
- package/dist/cjs/useLoaderData.cjs.map +1 -1
- package/dist/cjs/useLoaderData.d.cts +3 -3
- package/dist/cjs/useLoaderDeps.cjs.map +1 -1
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useNavigate.cjs +0 -2
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useRouter.cjs.map +1 -1
- package/dist/cjs/useRouterState.cjs.map +1 -1
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.d.ts +1 -1
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/Transitioner.js +0 -3
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +2 -3
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/index.d.ts +37 -20
- package/dist/esm/not-found.d.ts +1 -1
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/path.d.ts +1 -1
- package/dist/esm/path.js +5 -1
- package/dist/esm/path.js.map +1 -1
- package/dist/esm/renderRouteNotFound.js.map +1 -1
- package/dist/esm/route.d.ts +0 -1
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +3 -1
- package/dist/esm/router.js +2 -2
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/useLoaderData.d.ts +3 -3
- package/dist/esm/useLoaderData.js.map +1 -1
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useNavigate.js +0 -2
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/Match.tsx +1 -1
- package/src/Matches.tsx +1 -1
- package/src/RouterProvider.tsx +0 -5
- package/src/Transitioner.tsx +1 -1
- package/src/fileRoute.ts +1 -5
- package/src/index.tsx +192 -150
- package/src/not-found.tsx +1 -2
- package/src/path.ts +8 -2
- package/src/renderRouteNotFound.tsx +2 -2
- package/src/route.ts +3 -3
- package/src/routeInfo.ts +1 -1
- package/src/router.ts +8 -10
- package/src/useLoaderData.tsx +13 -6
- package/src/useLoaderDeps.tsx +2 -2
- package/src/useMatch.tsx +2 -2
- package/src/useNavigate.tsx +0 -3
- package/src/useRouter.tsx +1 -1
- package/src/useRouterState.tsx +1 -1
- package/src/utils.ts +1 -1
package/src/index.tsx
CHANGED
|
@@ -3,18 +3,27 @@ export {
|
|
|
3
3
|
createBrowserHistory,
|
|
4
4
|
createHashHistory,
|
|
5
5
|
createMemoryHistory,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
} from '@tanstack/history'
|
|
7
|
+
export type {
|
|
8
|
+
BlockerFn,
|
|
9
|
+
HistoryLocation,
|
|
10
|
+
RouterHistory,
|
|
11
|
+
ParsedPath,
|
|
12
|
+
HistoryState,
|
|
11
13
|
} from '@tanstack/history'
|
|
12
14
|
export { default as invariant } from 'tiny-invariant'
|
|
13
15
|
export { default as warning } from 'tiny-warning'
|
|
14
|
-
|
|
16
|
+
|
|
17
|
+
export { useAwaited, Await } from './awaited'
|
|
18
|
+
export type { AwaitOptions } from './awaited'
|
|
19
|
+
|
|
15
20
|
export { ScriptOnce } from './ScriptOnce'
|
|
16
|
-
|
|
21
|
+
|
|
22
|
+
export { defer } from './defer'
|
|
23
|
+
export type { DeferredPromiseState, DeferredPromise } from './defer'
|
|
24
|
+
|
|
17
25
|
export { CatchBoundary, ErrorComponent } from './CatchBoundary'
|
|
26
|
+
|
|
18
27
|
export {
|
|
19
28
|
FileRoute,
|
|
20
29
|
createFileRoute,
|
|
@@ -22,46 +31,48 @@ export {
|
|
|
22
31
|
LazyRoute,
|
|
23
32
|
createLazyRoute,
|
|
24
33
|
createLazyFileRoute,
|
|
25
|
-
type FileRoutesByPath,
|
|
26
|
-
type LazyRouteOptions,
|
|
27
34
|
} from './fileRoute'
|
|
35
|
+
export type { FileRoutesByPath, LazyRouteOptions } from './fileRoute'
|
|
36
|
+
|
|
28
37
|
export * from './history'
|
|
38
|
+
|
|
29
39
|
export { lazyRouteComponent } from './lazyRouteComponent'
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
type LinkComponent,
|
|
40
|
+
|
|
41
|
+
export { useLinkProps, createLink, Link } from './link'
|
|
42
|
+
export type {
|
|
43
|
+
CleanPath,
|
|
44
|
+
Split,
|
|
45
|
+
ParsePathParams,
|
|
46
|
+
Join,
|
|
47
|
+
Last,
|
|
48
|
+
RemoveTrailingSlashes,
|
|
49
|
+
RemoveLeadingSlashes,
|
|
50
|
+
SearchPaths,
|
|
51
|
+
SearchRelativePathAutoComplete,
|
|
52
|
+
RelativeToParentPathAutoComplete,
|
|
53
|
+
RelativeToCurrentPathAutoComplete,
|
|
54
|
+
AbsolutePathAutoComplete,
|
|
55
|
+
RelativeToPathAutoComplete,
|
|
56
|
+
NavigateOptions,
|
|
57
|
+
ToOptions,
|
|
58
|
+
ToMaskOptions,
|
|
59
|
+
ToSubOptions,
|
|
60
|
+
ResolveRoute,
|
|
61
|
+
SearchParamOptions,
|
|
62
|
+
PathParamOptions,
|
|
63
|
+
ToPathOption,
|
|
64
|
+
ActiveOptions,
|
|
65
|
+
LinkOptions,
|
|
66
|
+
CheckPath,
|
|
67
|
+
ResolveRelativePath,
|
|
68
|
+
UseLinkPropsOptions,
|
|
69
|
+
ActiveLinkOptions,
|
|
70
|
+
LinkProps,
|
|
71
|
+
LinkComponent,
|
|
63
72
|
} from './link'
|
|
64
|
-
|
|
73
|
+
|
|
74
|
+
export type { ParsedLocation } from './location'
|
|
75
|
+
|
|
65
76
|
export {
|
|
66
77
|
Matches,
|
|
67
78
|
useMatchRoute,
|
|
@@ -69,18 +80,27 @@ export {
|
|
|
69
80
|
useMatches,
|
|
70
81
|
useParentMatches,
|
|
71
82
|
useChildMatches,
|
|
72
|
-
type RouteMatch,
|
|
73
|
-
type AnyRouteMatch,
|
|
74
|
-
type MatchRouteOptions,
|
|
75
|
-
type UseMatchRouteOptions,
|
|
76
|
-
type MakeMatchRouteOptions,
|
|
77
83
|
} from './Matches'
|
|
84
|
+
export type {
|
|
85
|
+
RouteMatch,
|
|
86
|
+
AnyRouteMatch,
|
|
87
|
+
MatchRouteOptions,
|
|
88
|
+
UseMatchRouteOptions,
|
|
89
|
+
MakeMatchRouteOptions,
|
|
90
|
+
} from './Matches'
|
|
91
|
+
|
|
78
92
|
export { matchContext } from './matchContext'
|
|
93
|
+
|
|
79
94
|
export { Match, Outlet } from './Match'
|
|
95
|
+
|
|
80
96
|
export { isServerSideError, defaultDeserializeError } from './isServerSideError'
|
|
97
|
+
|
|
81
98
|
export { useMatch } from './useMatch'
|
|
99
|
+
|
|
82
100
|
export { useLoaderDeps } from './useLoaderDeps'
|
|
101
|
+
|
|
83
102
|
export { useLoaderData } from './useLoaderData'
|
|
103
|
+
|
|
84
104
|
export {
|
|
85
105
|
joinPaths,
|
|
86
106
|
cleanPath,
|
|
@@ -93,17 +113,17 @@ export {
|
|
|
93
113
|
matchPathname,
|
|
94
114
|
removeBasepath,
|
|
95
115
|
matchByPath,
|
|
96
|
-
type Segment,
|
|
97
116
|
} from './path'
|
|
117
|
+
export type { Segment } from './path'
|
|
118
|
+
|
|
98
119
|
export { encode, decode } from './qss'
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
export { rootRouteId, type RootRouteId } from './root'
|
|
120
|
+
|
|
121
|
+
export { redirect, isRedirect } from './redirects'
|
|
122
|
+
export type { AnyRedirect, Redirect, ResolvedRedirect } from './redirects'
|
|
123
|
+
|
|
124
|
+
export { rootRouteId } from './root'
|
|
125
|
+
export type { RootRouteId } from './root'
|
|
126
|
+
|
|
107
127
|
export {
|
|
108
128
|
RouteApi,
|
|
109
129
|
getRouteApi,
|
|
@@ -115,65 +135,69 @@ export {
|
|
|
115
135
|
createRootRouteWithContext,
|
|
116
136
|
createRouteMask,
|
|
117
137
|
NotFoundRoute,
|
|
118
|
-
type AnyPathParams,
|
|
119
|
-
type SearchSchemaInput,
|
|
120
|
-
type AnySearchSchema,
|
|
121
|
-
type AnyContext,
|
|
122
|
-
type RouteContext,
|
|
123
|
-
type PreloadableObj,
|
|
124
|
-
type RoutePathOptions,
|
|
125
|
-
type StaticDataRouteOption,
|
|
126
|
-
type RoutePathOptionsIntersection,
|
|
127
|
-
type RouteOptions,
|
|
128
|
-
type FileBaseRouteOptions,
|
|
129
|
-
type BaseRouteOptions,
|
|
130
|
-
type UpdatableRouteOptions,
|
|
131
|
-
type UpdatableStaticRouteOption,
|
|
132
|
-
type MetaDescriptor,
|
|
133
|
-
type RouteLinkEntry,
|
|
134
|
-
type ParseParamsFn,
|
|
135
|
-
type SearchSchemaValidator,
|
|
136
|
-
type SearchSchemaValidatorObj,
|
|
137
|
-
type SearchSchemaValidatorFn,
|
|
138
|
-
type RouteLoaderFn,
|
|
139
|
-
type LoaderFnContext,
|
|
140
|
-
type SearchFilter,
|
|
141
|
-
type ResolveId,
|
|
142
|
-
type InferFullSearchSchema,
|
|
143
|
-
type InferFullSearchSchemaInput,
|
|
144
|
-
type ResolveFullSearchSchema,
|
|
145
|
-
type ResolveFullSearchSchemaInput,
|
|
146
|
-
type AnyRoute,
|
|
147
|
-
type RouteConstraints,
|
|
148
|
-
type AnyRootRoute,
|
|
149
|
-
type ResolveFullPath,
|
|
150
|
-
type RouteMask,
|
|
151
|
-
type ErrorRouteProps,
|
|
152
|
-
type ErrorComponentProps,
|
|
153
|
-
type NotFoundRouteProps,
|
|
154
|
-
type ReactNode,
|
|
155
|
-
type SyncRouteComponent,
|
|
156
|
-
type AsyncRouteComponent,
|
|
157
|
-
type RouteComponent,
|
|
158
|
-
type ErrorRouteComponent,
|
|
159
|
-
type NotFoundRouteComponent,
|
|
160
|
-
type TrimPath,
|
|
161
|
-
type TrimPathLeft,
|
|
162
|
-
type TrimPathRight,
|
|
163
|
-
type RootRouteOptions,
|
|
164
|
-
type AnyRouteWithContext,
|
|
165
138
|
} from './route'
|
|
166
|
-
export {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
139
|
+
export type {
|
|
140
|
+
AnyPathParams,
|
|
141
|
+
SearchSchemaInput,
|
|
142
|
+
AnySearchSchema,
|
|
143
|
+
AnyContext,
|
|
144
|
+
RouteContext,
|
|
145
|
+
PreloadableObj,
|
|
146
|
+
RoutePathOptions,
|
|
147
|
+
StaticDataRouteOption,
|
|
148
|
+
RoutePathOptionsIntersection,
|
|
149
|
+
RouteOptions,
|
|
150
|
+
FileBaseRouteOptions,
|
|
151
|
+
BaseRouteOptions,
|
|
152
|
+
UpdatableRouteOptions,
|
|
153
|
+
UpdatableStaticRouteOption,
|
|
154
|
+
MetaDescriptor,
|
|
155
|
+
RouteLinkEntry,
|
|
156
|
+
ParseParamsFn,
|
|
157
|
+
SearchSchemaValidator,
|
|
158
|
+
SearchSchemaValidatorObj,
|
|
159
|
+
SearchSchemaValidatorFn,
|
|
160
|
+
RouteLoaderFn,
|
|
161
|
+
LoaderFnContext,
|
|
162
|
+
SearchFilter,
|
|
163
|
+
ResolveId,
|
|
164
|
+
InferFullSearchSchema,
|
|
165
|
+
InferFullSearchSchemaInput,
|
|
166
|
+
ResolveFullSearchSchema,
|
|
167
|
+
ResolveFullSearchSchemaInput,
|
|
168
|
+
AnyRoute,
|
|
169
|
+
RouteConstraints,
|
|
170
|
+
AnyRootRoute,
|
|
171
|
+
ResolveFullPath,
|
|
172
|
+
RouteMask,
|
|
173
|
+
ErrorRouteProps,
|
|
174
|
+
ErrorComponentProps,
|
|
175
|
+
NotFoundRouteProps,
|
|
176
|
+
ReactNode,
|
|
177
|
+
SyncRouteComponent,
|
|
178
|
+
AsyncRouteComponent,
|
|
179
|
+
RouteComponent,
|
|
180
|
+
ErrorRouteComponent,
|
|
181
|
+
NotFoundRouteComponent,
|
|
182
|
+
TrimPath,
|
|
183
|
+
TrimPathLeft,
|
|
184
|
+
TrimPathRight,
|
|
185
|
+
RootRouteOptions,
|
|
186
|
+
AnyRouteWithContext,
|
|
187
|
+
} from './route'
|
|
188
|
+
|
|
189
|
+
export type {
|
|
190
|
+
ParseRoute,
|
|
191
|
+
RoutesById,
|
|
192
|
+
RouteById,
|
|
193
|
+
RouteIds,
|
|
194
|
+
RoutesByPath,
|
|
195
|
+
RouteByPath,
|
|
196
|
+
RoutePaths,
|
|
197
|
+
FullSearchSchema,
|
|
198
|
+
AllParams,
|
|
176
199
|
} from './routeInfo'
|
|
200
|
+
|
|
177
201
|
export {
|
|
178
202
|
componentTypes,
|
|
179
203
|
createRouter,
|
|
@@ -183,62 +207,76 @@ export {
|
|
|
183
207
|
PathParamError,
|
|
184
208
|
getInitialRouterState,
|
|
185
209
|
defaultSerializeError,
|
|
186
|
-
type Register,
|
|
187
|
-
type AnyRouter,
|
|
188
|
-
type RegisteredRouter,
|
|
189
|
-
type HydrationCtx,
|
|
190
|
-
type RouterContextOptions,
|
|
191
|
-
type TrailingSlashOption,
|
|
192
|
-
type RouterOptions,
|
|
193
|
-
type RouterTransformer,
|
|
194
|
-
type RouterErrorSerializer,
|
|
195
|
-
type RouterState,
|
|
196
|
-
type ListenerFn,
|
|
197
|
-
type BuildNextOptions,
|
|
198
|
-
type DehydratedRouterState,
|
|
199
|
-
type DehydratedRouteMatch,
|
|
200
|
-
type DehydratedRouter,
|
|
201
|
-
type RouterConstructorOptions,
|
|
202
|
-
type RouterEvents,
|
|
203
|
-
type RouterEvent,
|
|
204
|
-
type RouterListener,
|
|
205
|
-
type AnyRouterWithContext,
|
|
206
210
|
} from './router'
|
|
207
|
-
export {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
211
|
+
export type {
|
|
212
|
+
Register,
|
|
213
|
+
AnyRouter,
|
|
214
|
+
RegisteredRouter,
|
|
215
|
+
HydrationCtx,
|
|
216
|
+
RouterContextOptions,
|
|
217
|
+
TrailingSlashOption,
|
|
218
|
+
RouterOptions,
|
|
219
|
+
RouterTransformer,
|
|
220
|
+
RouterErrorSerializer,
|
|
221
|
+
RouterState,
|
|
222
|
+
ListenerFn,
|
|
223
|
+
BuildNextOptions,
|
|
224
|
+
DehydratedRouterState,
|
|
225
|
+
DehydratedRouteMatch,
|
|
226
|
+
DehydratedRouter,
|
|
227
|
+
RouterConstructorOptions,
|
|
228
|
+
RouterEvents,
|
|
229
|
+
RouterEvent,
|
|
230
|
+
RouterListener,
|
|
231
|
+
AnyRouterWithContext,
|
|
232
|
+
} from './router'
|
|
233
|
+
|
|
234
|
+
export { RouterProvider, RouterContextProvider } from './RouterProvider'
|
|
235
|
+
export type {
|
|
236
|
+
RouterProps,
|
|
237
|
+
CommitLocationOptions,
|
|
238
|
+
MatchLocation,
|
|
239
|
+
NavigateFn,
|
|
240
|
+
BuildLocationFn,
|
|
241
|
+
InjectedHtmlEntry,
|
|
216
242
|
} from './RouterProvider'
|
|
243
|
+
|
|
217
244
|
export {
|
|
218
245
|
useScrollRestoration,
|
|
219
246
|
useElementScrollRestoration,
|
|
220
247
|
ScrollRestoration,
|
|
221
|
-
type ScrollRestorationOptions,
|
|
222
248
|
} from './scroll-restoration'
|
|
249
|
+
export type { ScrollRestorationOptions } from './scroll-restoration'
|
|
250
|
+
|
|
223
251
|
export {
|
|
224
252
|
defaultParseSearch,
|
|
225
253
|
defaultStringifySearch,
|
|
226
254
|
parseSearchWith,
|
|
227
255
|
stringifySearchWith,
|
|
228
|
-
type SearchSerializer,
|
|
229
|
-
type SearchParser,
|
|
230
256
|
} from './searchParams'
|
|
257
|
+
export type { SearchSerializer, SearchParser } from './searchParams'
|
|
258
|
+
|
|
231
259
|
export { useBlocker, Block } from './useBlocker'
|
|
232
|
-
|
|
260
|
+
|
|
261
|
+
export { useNavigate, Navigate } from './useNavigate'
|
|
262
|
+
export type { UseNavigateResult } from './useNavigate'
|
|
263
|
+
|
|
233
264
|
export { useParams } from './useParams'
|
|
265
|
+
|
|
234
266
|
export { useSearch } from './useSearch'
|
|
267
|
+
|
|
235
268
|
export {
|
|
236
269
|
getRouterContext, // SSR
|
|
237
270
|
} from './routerContext'
|
|
271
|
+
|
|
238
272
|
export { useRouteContext } from './useRouteContext'
|
|
273
|
+
|
|
239
274
|
export { useRouter } from './useRouter'
|
|
275
|
+
|
|
240
276
|
export { useRouterState } from './useRouterState'
|
|
277
|
+
|
|
241
278
|
export { useLocation } from './useLocation'
|
|
279
|
+
|
|
242
280
|
export {
|
|
243
281
|
escapeJSON, // SSR
|
|
244
282
|
useLayoutEffect, // SSR
|
|
@@ -251,12 +289,16 @@ export {
|
|
|
251
289
|
useStableCallback,
|
|
252
290
|
shallow,
|
|
253
291
|
} from './utils'
|
|
292
|
+
|
|
254
293
|
export {
|
|
255
294
|
notFound,
|
|
256
295
|
isNotFound,
|
|
257
296
|
CatchNotFound,
|
|
258
297
|
DefaultGlobalNotFound,
|
|
259
|
-
type NotFoundError,
|
|
260
298
|
} from './not-found'
|
|
261
|
-
export
|
|
262
|
-
|
|
299
|
+
export type { NotFoundError } from './not-found'
|
|
300
|
+
|
|
301
|
+
export type { Manifest, RouterManagedTag } from './manifest'
|
|
302
|
+
|
|
303
|
+
export { createControlledPromise } from './utils'
|
|
304
|
+
export type { ControlledPromise } from './utils'
|
package/src/not-found.tsx
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
// eslint-disable-next-line ts/consistent-type-imports
|
|
2
1
|
import * as React from 'react'
|
|
3
2
|
import { CatchBoundary } from './CatchBoundary'
|
|
4
3
|
import { useRouterState } from './useRouterState'
|
|
4
|
+
import type { ErrorInfo } from 'react'
|
|
5
5
|
import type { RegisteredRouter } from './router'
|
|
6
6
|
import type { RouteIds } from './routeInfo'
|
|
7
|
-
import type { ErrorInfo } from 'react'
|
|
8
7
|
|
|
9
8
|
export type NotFoundError = {
|
|
10
9
|
/**
|
package/src/path.ts
CHANGED
|
@@ -8,7 +8,13 @@ export interface Segment {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export function joinPaths(paths: Array<string | undefined>) {
|
|
11
|
-
return cleanPath(
|
|
11
|
+
return cleanPath(
|
|
12
|
+
paths
|
|
13
|
+
.filter((val) => {
|
|
14
|
+
return val !== undefined
|
|
15
|
+
})
|
|
16
|
+
.join('/'),
|
|
17
|
+
)
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
export function cleanPath(path: string) {
|
|
@@ -193,7 +199,7 @@ export function parsePathname(pathname?: string): Array<Segment> {
|
|
|
193
199
|
|
|
194
200
|
interface InterpolatePathOptions {
|
|
195
201
|
path?: string
|
|
196
|
-
params:
|
|
202
|
+
params: Record<string, unknown>
|
|
197
203
|
leaveWildcards?: boolean
|
|
198
204
|
leaveParams?: boolean
|
|
199
205
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import warning from 'tiny-warning'
|
|
3
3
|
import { DefaultGlobalNotFound } from './not-found'
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import type { AnyRouter } from './router'
|
|
5
|
+
import type { AnyRoute } from './route'
|
|
6
6
|
|
|
7
7
|
export function renderRouteNotFound(
|
|
8
8
|
router: AnyRouter,
|
package/src/route.ts
CHANGED
|
@@ -8,15 +8,15 @@ import { useSearch } from './useSearch'
|
|
|
8
8
|
import { notFound } from './not-found'
|
|
9
9
|
import { useNavigate } from './useNavigate'
|
|
10
10
|
import { rootRouteId } from './root'
|
|
11
|
+
import type * as React from 'react'
|
|
11
12
|
import type { RootRouteId } from './root'
|
|
12
13
|
import type { UseNavigateResult } from './useNavigate'
|
|
13
|
-
import type * as React from 'react'
|
|
14
14
|
import type { MakeRouteMatch, RouteMatch } from './Matches'
|
|
15
15
|
import type { NavigateOptions, ParsePathParams, ToSubOptions } from './link'
|
|
16
16
|
import type { ParsedLocation } from './location'
|
|
17
17
|
import type { RouteById, RouteIds, RoutePaths } from './routeInfo'
|
|
18
18
|
import type { AnyRouter, RegisteredRouter, Router } from './router'
|
|
19
|
-
import type { Assign, Expand,
|
|
19
|
+
import type { Assign, Expand, NoInfer, PickRequired } from './utils'
|
|
20
20
|
import type { BuildLocationFn, NavigateFn } from './RouterProvider'
|
|
21
21
|
import type { NotFoundError } from './not-found'
|
|
22
22
|
import type { LazyRoute } from './fileRoute'
|
|
@@ -719,7 +719,7 @@ export class Route<
|
|
|
719
719
|
|
|
720
720
|
const isRoot = !options?.path && !options?.id
|
|
721
721
|
|
|
722
|
-
// eslint-disable-next-line
|
|
722
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
723
723
|
this.parentRoute = this.options?.getParentRoute?.()
|
|
724
724
|
|
|
725
725
|
if (isRoot) {
|
package/src/routeInfo.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AnyRoute } from './route'
|
|
2
2
|
import type { AnyRouter, TrailingSlashOption } from './router'
|
|
3
|
-
import type {
|
|
3
|
+
import type { MergeUnion } from './utils'
|
|
4
4
|
|
|
5
5
|
export type ParseRoute<TRouteTree, TAcc = TRouteTree> = TRouteTree extends {
|
|
6
6
|
types: { children: infer TChildren }
|
package/src/router.ts
CHANGED
|
@@ -26,13 +26,13 @@ import {
|
|
|
26
26
|
import { isRedirect, isResolvedRedirect } from './redirects'
|
|
27
27
|
import { isNotFound } from './not-found'
|
|
28
28
|
import type * as React from 'react'
|
|
29
|
-
import type { Manifest } from './manifest'
|
|
30
29
|
import type {
|
|
31
30
|
HistoryLocation,
|
|
32
31
|
HistoryState,
|
|
33
32
|
RouterHistory,
|
|
34
33
|
} from '@tanstack/history'
|
|
35
|
-
|
|
34
|
+
import type { NoInfer } from '@tanstack/react-store'
|
|
35
|
+
import type { Manifest } from './manifest'
|
|
36
36
|
import type {
|
|
37
37
|
AnyContext,
|
|
38
38
|
AnyRoute,
|
|
@@ -70,13 +70,9 @@ import type {
|
|
|
70
70
|
CommitLocationOptions,
|
|
71
71
|
NavigateFn,
|
|
72
72
|
} from './RouterProvider'
|
|
73
|
-
|
|
74
73
|
import type { AnyRedirect, ResolvedRedirect } from './redirects'
|
|
75
|
-
|
|
76
74
|
import type { NotFoundError } from './not-found'
|
|
77
75
|
import type { NavigateOptions, ResolveRelativePath, ToOptions } from './link'
|
|
78
|
-
import type { NoInfer } from '@tanstack/react-store'
|
|
79
|
-
import type { DeferredPromiseState } from './defer'
|
|
80
76
|
|
|
81
77
|
//
|
|
82
78
|
|
|
@@ -323,12 +319,14 @@ export interface RouterOptions<
|
|
|
323
319
|
/**
|
|
324
320
|
* A component that will be used to wrap the entire router.
|
|
325
321
|
* This is useful for providing a context to the entire router.
|
|
322
|
+
* Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
|
|
326
323
|
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#wrap-property)
|
|
327
324
|
*/
|
|
328
325
|
Wrap?: (props: { children: any }) => React.JSX.Element
|
|
329
326
|
/**
|
|
330
327
|
* A component that will be used to wrap the inner contents of the router.
|
|
331
328
|
* This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.
|
|
329
|
+
* Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
|
|
332
330
|
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#innerwrap-property)
|
|
333
331
|
*/
|
|
334
332
|
InnerWrap?: (props: { children: any }) => React.JSX.Element
|
|
@@ -637,7 +635,7 @@ export class Router<
|
|
|
637
635
|
}
|
|
638
636
|
|
|
639
637
|
if (
|
|
640
|
-
// eslint-disable-next-line
|
|
638
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
641
639
|
!this.history ||
|
|
642
640
|
(this.options.history && this.options.history !== this.history)
|
|
643
641
|
) {
|
|
@@ -656,7 +654,7 @@ export class Router<
|
|
|
656
654
|
this.buildRouteTree()
|
|
657
655
|
}
|
|
658
656
|
|
|
659
|
-
// eslint-disable-next-line
|
|
657
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
660
658
|
if (!this.__store) {
|
|
661
659
|
this.__store = new Store(getInitialRouterState(this.latestLocation), {
|
|
662
660
|
onUpdate: () => {
|
|
@@ -1544,9 +1542,9 @@ export class Router<
|
|
|
1544
1542
|
await this.loadMatches({
|
|
1545
1543
|
matches: pendingMatches,
|
|
1546
1544
|
location: next,
|
|
1547
|
-
// eslint-disable-next-line
|
|
1545
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
1548
1546
|
onReady: async () => {
|
|
1549
|
-
// eslint-disable-next-line
|
|
1547
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
1550
1548
|
this.startViewTransition(async () => {
|
|
1551
1549
|
// this.viewTransitionPromise = createControlledPromise<true>()
|
|
1552
1550
|
|
package/src/useLoaderData.tsx
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { type RegisteredRouter } from './router'
|
|
2
|
-
import { type AnyRoute } from './route'
|
|
3
1
|
import { useMatch } from './useMatch'
|
|
2
|
+
import type { RegisteredRouter } from './router'
|
|
3
|
+
import type { AnyRoute } from './route'
|
|
4
4
|
import type { MakeRouteMatch } from './Matches'
|
|
5
5
|
import type { RouteIds } from './routeInfo'
|
|
6
6
|
import type { StrictOrFrom } from './utils'
|
|
7
7
|
|
|
8
8
|
export type UseLoaderDataOptions<
|
|
9
|
+
TRouteTree extends AnyRoute,
|
|
9
10
|
TFrom,
|
|
10
11
|
TStrict extends boolean,
|
|
11
|
-
TRouteMatch,
|
|
12
|
+
TRouteMatch extends MakeRouteMatch<TRouteTree, TFrom, TStrict>,
|
|
12
13
|
TSelected,
|
|
13
14
|
> = StrictOrFrom<TFrom, TStrict> & {
|
|
14
|
-
select?: (match: TRouteMatch) => TSelected
|
|
15
|
+
select?: (match: Required<TRouteMatch>['loaderData']) => TSelected
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export function useLoaderData<
|
|
@@ -25,13 +26,19 @@ export function useLoaderData<
|
|
|
25
26
|
> = MakeRouteMatch<TRouteTree, TFrom, TStrict>,
|
|
26
27
|
TSelected = Required<TRouteMatch>['loaderData'],
|
|
27
28
|
>(
|
|
28
|
-
opts: UseLoaderDataOptions<
|
|
29
|
+
opts: UseLoaderDataOptions<
|
|
30
|
+
TRouteTree,
|
|
31
|
+
TFrom,
|
|
32
|
+
TStrict,
|
|
33
|
+
TRouteMatch,
|
|
34
|
+
TSelected
|
|
35
|
+
>,
|
|
29
36
|
): TSelected {
|
|
30
37
|
return useMatch<TRouteTree, TFrom, TStrict, TRouteMatch, TSelected>({
|
|
31
38
|
...opts,
|
|
32
39
|
select: (s) => {
|
|
33
40
|
return typeof opts.select === 'function'
|
|
34
|
-
? opts.select(s.loaderData
|
|
41
|
+
? opts.select(s.loaderData)
|
|
35
42
|
: (s.loaderData as TSelected)
|
|
36
43
|
},
|
|
37
44
|
})
|
package/src/useLoaderDeps.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type RegisteredRouter } from './router'
|
|
2
|
-
import { type AnyRoute } from './route'
|
|
3
1
|
import { useMatch } from './useMatch'
|
|
2
|
+
import type { RegisteredRouter } from './router'
|
|
3
|
+
import type { AnyRoute } from './route'
|
|
4
4
|
import type { MakeRouteMatch } from './Matches'
|
|
5
5
|
import type { RouteIds } from './routeInfo'
|
|
6
6
|
import type { StrictOrFrom } from './utils'
|
package/src/useMatch.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import invariant from 'tiny-invariant'
|
|
3
3
|
import { useRouterState } from './useRouterState'
|
|
4
|
-
import { type RegisteredRouter } from './router'
|
|
5
|
-
import { type AnyRoute } from './route'
|
|
6
4
|
import { matchContext } from './matchContext'
|
|
5
|
+
import type { RegisteredRouter } from './router'
|
|
6
|
+
import type { AnyRoute } from './route'
|
|
7
7
|
import type { MakeRouteMatch } from './Matches'
|
|
8
8
|
import type { RouteIds } from './routeInfo'
|
|
9
9
|
import type { StrictOrFrom } from './utils'
|
package/src/useNavigate.tsx
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
|
-
import { useMatch } from './useMatch'
|
|
3
2
|
import { useRouter } from './useRouter'
|
|
4
|
-
|
|
5
3
|
import type { FromPathOption, NavigateOptions } from './link'
|
|
6
4
|
import type { RoutePaths } from './routeInfo'
|
|
7
5
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
@@ -58,7 +56,6 @@ export function Navigate<
|
|
|
58
56
|
TMaskTo extends string = '',
|
|
59
57
|
>(props: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): null {
|
|
60
58
|
const { navigate } = useRouter()
|
|
61
|
-
const match = useMatch({ strict: false })
|
|
62
59
|
|
|
63
60
|
React.useEffect(() => {
|
|
64
61
|
navigate({
|
package/src/useRouter.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import warning from 'tiny-warning'
|
|
3
3
|
import { getRouterContext } from './routerContext'
|
|
4
|
-
import type { AnyRouter, RegisteredRouter
|
|
4
|
+
import type { AnyRouter, RegisteredRouter } from './router'
|
|
5
5
|
|
|
6
6
|
export function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {
|
|
7
7
|
warn?: boolean
|