@tanstack/solid-router 1.112.10 → 1.112.12
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 -8
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/RouterProvider.d.cts +4 -4
- package/dist/cjs/Transitioner.cjs +1 -1
- package/dist/cjs/Transitioner.cjs.map +1 -1
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +4 -7
- package/dist/cjs/index.d.cts +3 -5
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +1 -2
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/not-found.d.cts +1 -2
- package/dist/cjs/redirects.cjs.map +1 -1
- package/dist/cjs/redirects.d.cts +1 -2
- package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
- package/dist/cjs/renderRouteNotFound.d.cts +1 -2
- package/dist/cjs/route.cjs +15 -23
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +19 -50
- package/dist/cjs/router.cjs +25 -25
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +84 -454
- package/dist/cjs/routerContext.cjs.map +1 -1
- package/dist/cjs/routerContext.d.cts +2 -2
- package/dist/cjs/scroll-restoration.cjs.map +1 -1
- package/dist/cjs/scroll-restoration.d.cts +1 -2
- package/dist/cjs/typePrimitives.d.cts +1 -2
- package/dist/cjs/useBlocker.cjs.map +1 -1
- package/dist/cjs/useBlocker.d.cts +2 -3
- package/dist/cjs/useLoaderData.cjs.map +1 -1
- package/dist/cjs/useLoaderData.d.cts +1 -3
- package/dist/cjs/useLoaderDeps.cjs.map +1 -1
- package/dist/cjs/useLoaderDeps.d.cts +1 -3
- package/dist/cjs/useLocation.cjs.map +1 -1
- package/dist/cjs/useLocation.d.cts +1 -1
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useMatch.d.cts +1 -3
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useNavigate.d.cts +1 -2
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useParams.d.cts +1 -3
- package/dist/cjs/useRouteContext.cjs.map +1 -1
- package/dist/cjs/useRouteContext.d.cts +1 -2
- package/dist/cjs/useRouter.cjs.map +1 -1
- package/dist/cjs/useRouter.d.cts +1 -1
- package/dist/cjs/useRouterState.cjs.map +1 -1
- package/dist/cjs/useRouterState.d.cts +1 -1
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/useSearch.d.cts +1 -3
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +0 -9
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.d.ts +1 -8
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.d.ts +4 -4
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/Transitioner.js +1 -1
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +4 -7
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/index.d.ts +3 -5
- package/dist/esm/link.d.ts +1 -2
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/not-found.d.ts +1 -2
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/redirects.d.ts +1 -2
- package/dist/esm/redirects.js.map +1 -1
- package/dist/esm/renderRouteNotFound.d.ts +1 -2
- package/dist/esm/renderRouteNotFound.js.map +1 -1
- package/dist/esm/route.d.ts +19 -50
- package/dist/esm/route.js +15 -23
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +84 -454
- package/dist/esm/router.js +25 -25
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.d.ts +2 -2
- package/dist/esm/routerContext.js.map +1 -1
- package/dist/esm/scroll-restoration.d.ts +1 -2
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/typePrimitives.d.ts +1 -2
- package/dist/esm/useBlocker.d.ts +2 -3
- package/dist/esm/useBlocker.js.map +1 -1
- package/dist/esm/useLoaderData.d.ts +1 -3
- package/dist/esm/useLoaderData.js.map +1 -1
- package/dist/esm/useLoaderDeps.d.ts +1 -3
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useLocation.d.ts +1 -1
- package/dist/esm/useLocation.js.map +1 -1
- package/dist/esm/useMatch.d.ts +1 -3
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useNavigate.d.ts +1 -2
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.d.ts +1 -3
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouteContext.d.ts +1 -2
- package/dist/esm/useRouteContext.js.map +1 -1
- package/dist/esm/useRouter.d.ts +1 -1
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/esm/useRouterState.d.ts +1 -1
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.d.ts +1 -3
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.d.ts +0 -9
- package/dist/esm/utils.js.map +1 -1
- package/dist/source/Matches.d.ts +1 -8
- package/dist/source/Matches.jsx.map +1 -1
- package/dist/source/RouterProvider.d.ts +4 -4
- package/dist/source/RouterProvider.jsx.map +1 -1
- package/dist/source/Transitioner.jsx +1 -1
- package/dist/source/Transitioner.jsx.map +1 -1
- package/dist/source/fileRoute.d.ts +4 -7
- package/dist/source/fileRoute.js.map +1 -1
- package/dist/source/index.d.ts +3 -5
- package/dist/source/index.jsx.map +1 -1
- package/dist/source/link.d.ts +1 -2
- package/dist/source/link.jsx.map +1 -1
- package/dist/source/not-found.d.ts +1 -2
- package/dist/source/not-found.jsx.map +1 -1
- package/dist/source/redirects.d.ts +1 -2
- package/dist/source/renderRouteNotFound.d.ts +1 -2
- package/dist/source/renderRouteNotFound.jsx.map +1 -1
- package/dist/source/route.d.ts +19 -50
- package/dist/source/route.js +15 -23
- package/dist/source/route.js.map +1 -1
- package/dist/source/router.d.ts +83 -454
- package/dist/source/router.js +33 -22
- package/dist/source/router.js.map +1 -1
- package/dist/source/routerContext.d.ts +2 -2
- package/dist/source/routerContext.jsx.map +1 -1
- package/dist/source/scroll-restoration.d.ts +1 -2
- package/dist/source/scroll-restoration.jsx.map +1 -1
- package/dist/source/typePrimitives.d.ts +1 -2
- package/dist/source/useBlocker.d.ts +2 -3
- package/dist/source/useBlocker.jsx.map +1 -1
- package/dist/source/useLoaderData.d.ts +1 -3
- package/dist/source/useLoaderData.jsx.map +1 -1
- package/dist/source/useLoaderDeps.d.ts +1 -3
- package/dist/source/useLoaderDeps.jsx.map +1 -1
- package/dist/source/useLocation.d.ts +1 -1
- package/dist/source/useLocation.jsx.map +1 -1
- package/dist/source/useMatch.d.ts +1 -3
- package/dist/source/useMatch.jsx.map +1 -1
- package/dist/source/useNavigate.d.ts +1 -2
- package/dist/source/useNavigate.jsx.map +1 -1
- package/dist/source/useParams.d.ts +1 -3
- package/dist/source/useParams.jsx.map +1 -1
- package/dist/source/useRouteContext.d.ts +1 -2
- package/dist/source/useRouter.d.ts +1 -1
- package/dist/source/useRouterState.d.ts +1 -1
- package/dist/source/useRouterState.jsx.map +1 -1
- package/dist/source/useSearch.d.ts +1 -3
- package/dist/source/useSearch.jsx.map +1 -1
- package/dist/source/utils.d.ts +1 -10
- package/dist/source/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/Match.tsx +1 -1
- package/src/Matches.tsx +4 -8
- package/src/RouterProvider.tsx +4 -7
- package/src/Transitioner.tsx +1 -1
- package/src/fileRoute.ts +9 -25
- package/src/index.tsx +22 -28
- package/src/link.tsx +2 -1
- package/src/not-found.tsx +1 -2
- package/src/redirects.ts +1 -1
- package/src/renderRouteNotFound.tsx +1 -2
- package/src/route.ts +93 -222
- package/src/router.ts +154 -596
- package/src/routerContext.tsx +3 -3
- package/src/scroll-restoration.tsx +6 -2
- package/src/typePrimitives.ts +2 -1
- package/src/useBlocker.tsx +7 -3
- package/src/useLoaderData.tsx +3 -2
- package/src/useLoaderDeps.tsx +3 -2
- package/src/useLocation.tsx +5 -1
- package/src/useMatch.tsx +3 -2
- package/src/useNavigate.tsx +2 -1
- package/src/useParams.tsx +3 -2
- package/src/useRouteContext.ts +2 -2
- package/src/useRouter.tsx +1 -1
- package/src/useRouterState.tsx +5 -1
- package/src/useSearch.tsx +3 -2
- package/src/utils.ts +0 -16
package/src/router.ts
CHANGED
|
@@ -30,495 +30,132 @@ import { isRedirect, isResolvedRedirect } from './redirects'
|
|
|
30
30
|
import { isNotFound } from './not-found'
|
|
31
31
|
import { setupScrollRestoration } from './scroll-restoration'
|
|
32
32
|
import type * as Solid from 'solid-js'
|
|
33
|
-
import type {
|
|
34
|
-
HistoryLocation,
|
|
35
|
-
HistoryState,
|
|
36
|
-
ParsedHistoryState,
|
|
37
|
-
RouterHistory,
|
|
38
|
-
} from '@tanstack/history'
|
|
39
|
-
import type { NoInfer } from '@tanstack/solid-store'
|
|
33
|
+
import type { HistoryLocation, RouterHistory } from '@tanstack/history'
|
|
40
34
|
|
|
41
35
|
import type {
|
|
42
|
-
AnyContext,
|
|
43
36
|
AnyRedirect,
|
|
37
|
+
AnyRoute,
|
|
44
38
|
AnyRouteMatch,
|
|
39
|
+
AnyRouter,
|
|
45
40
|
AnySchema,
|
|
46
41
|
AnyValidator,
|
|
47
42
|
BeforeLoadContextOptions,
|
|
48
43
|
BuildLocationFn,
|
|
44
|
+
BuildNextOptions,
|
|
45
|
+
ClearCacheFn,
|
|
46
|
+
CommitLocationFn,
|
|
49
47
|
CommitLocationOptions,
|
|
50
48
|
ControlledPromise,
|
|
49
|
+
Router as CoreRouter,
|
|
50
|
+
EmitFn,
|
|
51
51
|
FullSearchSchema,
|
|
52
|
+
GetMatchFn,
|
|
53
|
+
GetMatchRoutesFn,
|
|
54
|
+
InjectedHtmlEntry,
|
|
55
|
+
InvalidateFn,
|
|
56
|
+
LoadFn,
|
|
52
57
|
LoaderFnContext,
|
|
53
|
-
MakeRemountDepsOptionsUnion,
|
|
54
58
|
MakeRouteMatch,
|
|
55
59
|
MakeRouteMatchUnion,
|
|
56
60
|
Manifest,
|
|
61
|
+
MatchRouteFn,
|
|
62
|
+
MatchRoutesFn,
|
|
63
|
+
MatchRoutesOpts,
|
|
64
|
+
MatchedRoutesResult,
|
|
57
65
|
NavigateFn,
|
|
58
|
-
|
|
59
|
-
NonNullableUpdater,
|
|
66
|
+
ParseLocationFn,
|
|
60
67
|
ParsedLocation,
|
|
61
68
|
PickAsRequired,
|
|
62
|
-
|
|
63
|
-
ResolveRelativePath,
|
|
69
|
+
PreloadRouteFn,
|
|
64
70
|
ResolvedRedirect,
|
|
65
|
-
RouteById,
|
|
66
71
|
RouteContextOptions,
|
|
67
|
-
|
|
72
|
+
RouterConstructorOptions,
|
|
73
|
+
RouterEvent,
|
|
74
|
+
RouterListener,
|
|
75
|
+
RouterOptions,
|
|
76
|
+
RouterState,
|
|
68
77
|
RoutesById,
|
|
69
78
|
RoutesByPath,
|
|
70
79
|
SearchMiddleware,
|
|
71
|
-
SearchParser,
|
|
72
|
-
SearchSerializer,
|
|
73
80
|
StartSerializer,
|
|
74
|
-
|
|
81
|
+
StartTransitionFn,
|
|
82
|
+
SubscribeFn,
|
|
75
83
|
TrailingSlashOption,
|
|
76
|
-
|
|
84
|
+
UpdateFn,
|
|
85
|
+
UpdateMatchFn,
|
|
77
86
|
ViewTransitionOptions,
|
|
78
87
|
} from '@tanstack/router-core'
|
|
79
88
|
import type {
|
|
80
|
-
AnyRoute,
|
|
81
89
|
ErrorRouteComponent,
|
|
82
90
|
NotFoundRouteComponent,
|
|
83
|
-
RootRoute,
|
|
84
91
|
RouteComponent,
|
|
85
|
-
RouteMask,
|
|
86
92
|
} from './route'
|
|
87
|
-
import type { MatchRouteOptions } from './Matches'
|
|
88
|
-
|
|
89
93
|
import type { NotFoundError } from './not-found'
|
|
90
94
|
|
|
91
|
-
declare
|
|
92
|
-
interface
|
|
93
|
-
__TSR_ROUTER__?: AnyRouter
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export type AnyRouter = Router<any, any, any, any, any>
|
|
98
|
-
|
|
99
|
-
export type RegisteredRouter = Register extends {
|
|
100
|
-
router: infer TRouter extends AnyRouter
|
|
101
|
-
}
|
|
102
|
-
? TRouter
|
|
103
|
-
: AnyRouter
|
|
104
|
-
|
|
105
|
-
export type InferRouterContext<TRouteTree extends AnyRoute> =
|
|
106
|
-
TRouteTree extends RootRoute<
|
|
107
|
-
any,
|
|
108
|
-
infer TRouterContext extends AnyContext,
|
|
109
|
-
any,
|
|
110
|
-
any,
|
|
111
|
-
any,
|
|
112
|
-
any,
|
|
113
|
-
any,
|
|
114
|
-
any
|
|
115
|
-
>
|
|
116
|
-
? TRouterContext
|
|
117
|
-
: AnyContext
|
|
118
|
-
|
|
119
|
-
export type ControllablePromise<T = any> = Promise<T> & {
|
|
120
|
-
resolve: (value: T) => void
|
|
121
|
-
reject: (value?: any) => void
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export type RouterContextOptions<TRouteTree extends AnyRoute> =
|
|
125
|
-
AnyContext extends InferRouterContext<TRouteTree>
|
|
126
|
-
? {
|
|
127
|
-
context?: InferRouterContext<TRouteTree>
|
|
128
|
-
}
|
|
129
|
-
: {
|
|
130
|
-
context: InferRouterContext<TRouteTree>
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export type InjectedHtmlEntry = Promise<string>
|
|
134
|
-
|
|
135
|
-
export interface RouterOptions<
|
|
136
|
-
TRouteTree extends AnyRoute,
|
|
137
|
-
TTrailingSlashOption extends TrailingSlashOption,
|
|
138
|
-
TRouterHistory extends RouterHistory = RouterHistory,
|
|
139
|
-
TDehydrated extends Record<string, any> = Record<string, any>,
|
|
140
|
-
> {
|
|
141
|
-
/**
|
|
142
|
-
* The history object that will be used to manage the browser history.
|
|
143
|
-
*
|
|
144
|
-
* If not provided, a new createBrowserHistory instance will be created and used.
|
|
145
|
-
*
|
|
146
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#history-property)
|
|
147
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/history-types)
|
|
148
|
-
*/
|
|
149
|
-
history?: TRouterHistory
|
|
150
|
-
/**
|
|
151
|
-
* A function that will be used to stringify search params when generating links.
|
|
152
|
-
*
|
|
153
|
-
* @default defaultStringifySearch
|
|
154
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#stringifysearch-method)
|
|
155
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)
|
|
156
|
-
*/
|
|
157
|
-
stringifySearch?: SearchSerializer
|
|
158
|
-
/**
|
|
159
|
-
* A function that will be used to parse search params when parsing the current location.
|
|
160
|
-
*
|
|
161
|
-
* @default defaultParseSearch
|
|
162
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#parsesearch-method)
|
|
163
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)
|
|
164
|
-
*/
|
|
165
|
-
parseSearch?: SearchParser
|
|
166
|
-
/**
|
|
167
|
-
* If `false`, routes will not be preloaded by default in any way.
|
|
168
|
-
*
|
|
169
|
-
* If `'intent'`, routes will be preloaded by default when the user hovers over a link or a `touchstart` event is detected on a `<Link>`.
|
|
170
|
-
*
|
|
171
|
-
* If `'viewport'`, routes will be preloaded by default when they are within the viewport.
|
|
172
|
-
*
|
|
173
|
-
* @default false
|
|
174
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreload-property)
|
|
175
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
|
|
176
|
-
*/
|
|
177
|
-
defaultPreload?: false | 'intent' | 'viewport' | 'render'
|
|
178
|
-
/**
|
|
179
|
-
* The delay in milliseconds that a route must be hovered over or touched before it is preloaded.
|
|
180
|
-
*
|
|
181
|
-
* @default 50
|
|
182
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloaddelay-property)
|
|
183
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading#preload-delay)
|
|
184
|
-
*/
|
|
185
|
-
defaultPreloadDelay?: number
|
|
186
|
-
/**
|
|
187
|
-
* The default `component` a route should use if no component is provided.
|
|
188
|
-
*
|
|
189
|
-
* @default Outlet
|
|
190
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultcomponent-property)
|
|
191
|
-
*/
|
|
192
|
-
defaultComponent?: RouteComponent
|
|
193
|
-
/**
|
|
194
|
-
* The default `errorComponent` a route should use if no error component is provided.
|
|
195
|
-
*
|
|
196
|
-
* @default ErrorComponent
|
|
197
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulterrorcomponent-property)
|
|
198
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
|
|
199
|
-
*/
|
|
200
|
-
defaultErrorComponent?: ErrorRouteComponent
|
|
201
|
-
/**
|
|
202
|
-
* The default `pendingComponent` a route should use if no pending component is provided.
|
|
203
|
-
*
|
|
204
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingcomponent-property)
|
|
205
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#showing-a-pending-component)
|
|
206
|
-
*/
|
|
207
|
-
defaultPendingComponent?: RouteComponent
|
|
208
|
-
/**
|
|
209
|
-
* The default `pendingMs` a route should use if no pendingMs is provided.
|
|
210
|
-
*
|
|
211
|
-
* @default 1000
|
|
212
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingms-property)
|
|
213
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)
|
|
214
|
-
*/
|
|
215
|
-
defaultPendingMs?: number
|
|
216
|
-
/**
|
|
217
|
-
* The default `pendingMinMs` a route should use if no pendingMinMs is provided.
|
|
218
|
-
*
|
|
219
|
-
* @default 500
|
|
220
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingminms-property)
|
|
221
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)
|
|
222
|
-
*/
|
|
223
|
-
defaultPendingMinMs?: number
|
|
224
|
-
/**
|
|
225
|
-
* The default `staleTime` a route should use if no staleTime is provided. This is the time in milliseconds that a route will be considered fresh.
|
|
226
|
-
*
|
|
227
|
-
* @default 0
|
|
228
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstaletime-property)
|
|
229
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)
|
|
230
|
-
*/
|
|
231
|
-
defaultStaleTime?: number
|
|
232
|
-
/**
|
|
233
|
-
* The default `preloadStaleTime` a route should use if no preloadStaleTime is provided.
|
|
234
|
-
*
|
|
235
|
-
* @default 30_000 `(30 seconds)`
|
|
236
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadstaletime-property)
|
|
237
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
|
|
238
|
-
*/
|
|
239
|
-
defaultPreloadStaleTime?: number
|
|
240
|
-
/**
|
|
241
|
-
* The default `defaultPreloadGcTime` a route should use if no preloadGcTime is provided.
|
|
242
|
-
*
|
|
243
|
-
* @default 1_800_000 `(30 minutes)`
|
|
244
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadgctime-property)
|
|
245
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
|
|
246
|
-
*/
|
|
247
|
-
defaultPreloadGcTime?: number
|
|
248
|
-
/**
|
|
249
|
-
* The default `onCatch` handler for errors caught by the Router ErrorBoundary
|
|
250
|
-
*
|
|
251
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)
|
|
252
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)
|
|
253
|
-
*/
|
|
254
|
-
defaultOnCatch?: (error: Error) => void
|
|
255
|
-
/**
|
|
256
|
-
* If `true`, route navigations will called using `document.startViewTransition()`.
|
|
257
|
-
*
|
|
258
|
-
* If the browser does not support this api, this option will be ignored.
|
|
259
|
-
*
|
|
260
|
-
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition) for more information on how this function works.
|
|
261
|
-
*
|
|
262
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultviewtransition-property)
|
|
263
|
-
*/
|
|
264
|
-
defaultViewTransition?: boolean | ViewTransitionOptions
|
|
265
|
-
/**
|
|
266
|
-
* The default `hashScrollIntoView` a route should use if no hashScrollIntoView is provided while navigating
|
|
267
|
-
*
|
|
268
|
-
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) for more information on `ScrollIntoViewOptions`.
|
|
269
|
-
*
|
|
270
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulthashscrollintoview-property)
|
|
271
|
-
*/
|
|
272
|
-
defaultHashScrollIntoView?: boolean | ScrollIntoViewOptions
|
|
273
|
-
/**
|
|
274
|
-
* @default 'fuzzy'
|
|
275
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundmode-property)
|
|
276
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#the-notfoundmode-option)
|
|
277
|
-
*/
|
|
278
|
-
notFoundMode?: 'root' | 'fuzzy'
|
|
279
|
-
/**
|
|
280
|
-
* The default `gcTime` a route should use if no gcTime is provided.
|
|
281
|
-
*
|
|
282
|
-
* @default 1_800_000 `(30 minutes)`
|
|
283
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultgctime-property)
|
|
284
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)
|
|
285
|
-
*/
|
|
286
|
-
defaultGcTime?: number
|
|
287
|
-
/**
|
|
288
|
-
* If `true`, all routes will be matched as case-sensitive.
|
|
289
|
-
*
|
|
290
|
-
* @default false
|
|
291
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#casesensitive-property)
|
|
292
|
-
*/
|
|
293
|
-
caseSensitive?: boolean
|
|
294
|
-
/**
|
|
295
|
-
*
|
|
296
|
-
* The route tree that will be used to configure the router instance.
|
|
297
|
-
*
|
|
298
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routetree-property)
|
|
299
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/routing/route-trees)
|
|
300
|
-
*/
|
|
301
|
-
routeTree?: TRouteTree
|
|
302
|
-
/**
|
|
303
|
-
* The basepath for then entire router. This is useful for mounting a router instance at a subpath.
|
|
304
|
-
*
|
|
305
|
-
* @default '/'
|
|
306
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#basepath-property)
|
|
307
|
-
*/
|
|
308
|
-
basepath?: string
|
|
309
|
-
/**
|
|
310
|
-
* The root context that will be provided to all routes in the route tree.
|
|
311
|
-
*
|
|
312
|
-
* This can be used to provide a context to all routes in the tree without having to provide it to each route individually.
|
|
313
|
-
*
|
|
314
|
-
* Optional or required if the root route was created with [`createRootRouteWithContext()`](https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction).
|
|
315
|
-
*
|
|
316
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#context-property)
|
|
317
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/router-context)
|
|
318
|
-
*/
|
|
319
|
-
context?: InferRouterContext<TRouteTree>
|
|
320
|
-
/**
|
|
321
|
-
* A function that will be called when the router is dehydrated.
|
|
322
|
-
*
|
|
323
|
-
* The return value of this function will be serialized and stored in the router's dehydrated state.
|
|
324
|
-
*
|
|
325
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#dehydrate-method)
|
|
326
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
|
|
327
|
-
*/
|
|
328
|
-
dehydrate?: () => TDehydrated
|
|
329
|
-
/**
|
|
330
|
-
* A function that will be called when the router is hydrated.
|
|
331
|
-
*
|
|
332
|
-
* The return value of this function will be serialized and stored in the router's dehydrated state.
|
|
333
|
-
*
|
|
334
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#hydrate-method)
|
|
335
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
|
|
336
|
-
*/
|
|
337
|
-
hydrate?: (dehydrated: TDehydrated) => void
|
|
338
|
-
/**
|
|
339
|
-
* An array of route masks that will be used to mask routes in the route tree.
|
|
340
|
-
*
|
|
341
|
-
* Route masking is when you display a route at a different path than the one it is configured to match, like a modal popup that when shared will unmask to the modal's content instead of the modal's context.
|
|
342
|
-
*
|
|
343
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routemasks-property)
|
|
344
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking)
|
|
345
|
-
*/
|
|
346
|
-
routeMasks?: Array<RouteMask<TRouteTree>>
|
|
347
|
-
/**
|
|
348
|
-
* If `true`, route masks will, by default, be removed when the page is reloaded.
|
|
349
|
-
*
|
|
350
|
-
* This can be overridden on a per-mask basis by setting the `unmaskOnReload` option on the mask, or on a per-navigation basis by setting the `unmaskOnReload` option in the `Navigate` options.
|
|
351
|
-
*
|
|
352
|
-
* @default false
|
|
353
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#unmaskonreload-property)
|
|
354
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking#unmasking-on-page-reload)
|
|
355
|
-
*/
|
|
356
|
-
unmaskOnReload?: boolean
|
|
357
|
-
/**
|
|
358
|
-
* A component that will be used to wrap the entire router.
|
|
359
|
-
*
|
|
360
|
-
* This is useful for providing a context to the entire router.
|
|
361
|
-
*
|
|
362
|
-
* Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
|
|
363
|
-
*
|
|
364
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#wrap-property)
|
|
365
|
-
*/
|
|
366
|
-
Wrap?: (props: { children: any }) => Solid.JSX.Element
|
|
367
|
-
/**
|
|
368
|
-
* A component that will be used to wrap the inner contents of the router.
|
|
369
|
-
*
|
|
370
|
-
* 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.
|
|
371
|
-
*
|
|
372
|
-
* Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
|
|
373
|
-
*
|
|
374
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#innerwrap-property)
|
|
375
|
-
*/
|
|
376
|
-
InnerWrap?: (props: { children: any }) => Solid.JSX.Element
|
|
377
|
-
/**
|
|
378
|
-
* Use `notFoundComponent` instead.
|
|
379
|
-
*
|
|
380
|
-
* @deprecated
|
|
381
|
-
* See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info.
|
|
382
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundroute-property)
|
|
383
|
-
*/
|
|
384
|
-
notFoundRoute?: AnyRoute
|
|
385
|
-
/**
|
|
386
|
-
* The default `notFoundComponent` a route should use if no notFound component is provided.
|
|
387
|
-
*
|
|
388
|
-
* @default NotFound
|
|
389
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultnotfoundcomponent-property)
|
|
390
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#default-router-wide-not-found-handling)
|
|
391
|
-
*/
|
|
392
|
-
defaultNotFoundComponent?: NotFoundRouteComponent
|
|
393
|
-
/**
|
|
394
|
-
* Configures how trailing slashes are treated.
|
|
395
|
-
*
|
|
396
|
-
* - `'always'` will add a trailing slash if not present
|
|
397
|
-
* - `'never'` will remove the trailing slash if present
|
|
398
|
-
* - `'preserve'` will not modify the trailing slash.
|
|
399
|
-
*
|
|
400
|
-
* @default 'never'
|
|
401
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#trailingslash-property)
|
|
402
|
-
*/
|
|
403
|
-
trailingSlash?: TTrailingSlashOption
|
|
404
|
-
/**
|
|
405
|
-
* While usually automatic, sometimes it can be useful to force the router into a server-side state, e.g. when using the router in a non-browser environment that has access to a global.document object.
|
|
406
|
-
*
|
|
407
|
-
* @default typeof document !== 'undefined'
|
|
408
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#isserver-property)
|
|
409
|
-
*/
|
|
410
|
-
isServer?: boolean
|
|
411
|
-
|
|
412
|
-
defaultSsr?: boolean
|
|
413
|
-
|
|
414
|
-
search?: {
|
|
95
|
+
declare module '@tanstack/router-core' {
|
|
96
|
+
export interface RouterOptionsExtensions {
|
|
415
97
|
/**
|
|
416
|
-
*
|
|
98
|
+
* A component that will be used to wrap the entire router.
|
|
99
|
+
*
|
|
100
|
+
* This is useful for providing a context to the entire router.
|
|
417
101
|
*
|
|
418
|
-
*
|
|
419
|
-
*
|
|
102
|
+
* Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
|
|
103
|
+
*
|
|
104
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#wrap-property)
|
|
420
105
|
*/
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
>
|
|
433
|
-
|
|
434
|
-
defaultRemountDeps?: (opts: MakeRemountDepsOptionsUnion<TRouteTree>) => any
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* If `true`, scroll restoration will be enabled
|
|
438
|
-
*
|
|
439
|
-
* @default false
|
|
440
|
-
*/
|
|
441
|
-
scrollRestoration?: boolean
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* A function that will be called to get the key for the scroll restoration cache.
|
|
445
|
-
*
|
|
446
|
-
* @default (location) => location.href
|
|
447
|
-
*/
|
|
448
|
-
getScrollRestorationKey?: (location: ParsedLocation) => string
|
|
449
|
-
/**
|
|
450
|
-
* The default behavior for scroll restoration.
|
|
451
|
-
*
|
|
452
|
-
* @default 'auto'
|
|
453
|
-
*/
|
|
454
|
-
scrollRestorationBehavior?: ScrollBehavior
|
|
455
|
-
/**
|
|
456
|
-
* An array of selectors that will be used to scroll to the top of the page in addition to `window`
|
|
457
|
-
*
|
|
458
|
-
* @default ['window']
|
|
459
|
-
*/
|
|
460
|
-
scrollToTopSelectors?: Array<string>
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
export interface RouterErrorSerializer<TSerializedError> {
|
|
464
|
-
serialize: (err: unknown) => TSerializedError
|
|
465
|
-
deserialize: (err: TSerializedError) => unknown
|
|
466
|
-
}
|
|
106
|
+
Wrap?: (props: { children: any }) => Solid.JSX.Element
|
|
107
|
+
/**
|
|
108
|
+
* A component that will be used to wrap the inner contents of the router.
|
|
109
|
+
*
|
|
110
|
+
* 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.
|
|
111
|
+
*
|
|
112
|
+
* Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
|
|
113
|
+
*
|
|
114
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#innerwrap-property)
|
|
115
|
+
*/
|
|
116
|
+
InnerWrap?: (props: { children: any }) => Solid.JSX.Element
|
|
467
117
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
118
|
+
/**
|
|
119
|
+
* The default `component` a route should use if no component is provided.
|
|
120
|
+
*
|
|
121
|
+
* @default Outlet
|
|
122
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultcomponent-property)
|
|
123
|
+
*/
|
|
124
|
+
defaultComponent?: RouteComponent
|
|
125
|
+
/**
|
|
126
|
+
* The default `errorComponent` a route should use if no error component is provided.
|
|
127
|
+
*
|
|
128
|
+
* @default ErrorComponent
|
|
129
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulterrorcomponent-property)
|
|
130
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
|
|
131
|
+
*/
|
|
132
|
+
defaultErrorComponent?: ErrorRouteComponent
|
|
133
|
+
/**
|
|
134
|
+
* The default `pendingComponent` a route should use if no pending component is provided.
|
|
135
|
+
*
|
|
136
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingcomponent-property)
|
|
137
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#showing-a-pending-component)
|
|
138
|
+
*/
|
|
139
|
+
defaultPendingComponent?: RouteComponent
|
|
140
|
+
/**
|
|
141
|
+
* The default `notFoundComponent` a route should use if no notFound component is provided.
|
|
142
|
+
*
|
|
143
|
+
* @default NotFound
|
|
144
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultnotfoundcomponent-property)
|
|
145
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#default-router-wide-not-found-handling)
|
|
146
|
+
*/
|
|
147
|
+
defaultNotFoundComponent?: NotFoundRouteComponent
|
|
484
148
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>
|
|
493
|
-
mask?: {
|
|
494
|
-
to?: string | number | null
|
|
495
|
-
params?: true | Updater<unknown>
|
|
496
|
-
search?: true | Updater<unknown>
|
|
497
|
-
hash?: true | Updater<string>
|
|
498
|
-
state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>
|
|
499
|
-
unmaskOnReload?: boolean
|
|
149
|
+
/**
|
|
150
|
+
* The default `onCatch` handler for errors caught by the Router ErrorBoundary
|
|
151
|
+
*
|
|
152
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)
|
|
153
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)
|
|
154
|
+
*/
|
|
155
|
+
defaultOnCatch?: (error: Error) => void
|
|
500
156
|
}
|
|
501
|
-
from?: string
|
|
502
|
-
_fromLocation?: ParsedLocation
|
|
503
|
-
href?: string
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
export interface MatchedRoutesResult {
|
|
507
|
-
matchedRoutes: Array<AnyRoute>
|
|
508
|
-
routeParams: Record<string, string>
|
|
509
157
|
}
|
|
510
158
|
|
|
511
|
-
export type RouterConstructorOptions<
|
|
512
|
-
TRouteTree extends AnyRoute,
|
|
513
|
-
TTrailingSlashOption extends TrailingSlashOption,
|
|
514
|
-
TRouterHistory extends RouterHistory,
|
|
515
|
-
TDehydrated extends Record<string, any>,
|
|
516
|
-
> = Omit<
|
|
517
|
-
RouterOptions<TRouteTree, TTrailingSlashOption, TRouterHistory, TDehydrated>,
|
|
518
|
-
'context'
|
|
519
|
-
> &
|
|
520
|
-
RouterContextOptions<TRouteTree>
|
|
521
|
-
|
|
522
159
|
export const componentTypes = [
|
|
523
160
|
'component',
|
|
524
161
|
'errorComponent',
|
|
@@ -563,85 +200,50 @@ function validateSearch(validateSearch: AnyValidator, input: unknown): unknown {
|
|
|
563
200
|
return {}
|
|
564
201
|
}
|
|
565
202
|
|
|
566
|
-
type NavigationEventInfo = {
|
|
567
|
-
fromLocation?: ParsedLocation
|
|
568
|
-
toLocation: ParsedLocation
|
|
569
|
-
pathChanged: boolean
|
|
570
|
-
hrefChanged: boolean
|
|
571
|
-
hashChanged: boolean
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
export type RouterEvents = {
|
|
575
|
-
onBeforeNavigate: {
|
|
576
|
-
type: 'onBeforeNavigate'
|
|
577
|
-
} & NavigationEventInfo
|
|
578
|
-
onBeforeLoad: {
|
|
579
|
-
type: 'onBeforeLoad'
|
|
580
|
-
} & NavigationEventInfo
|
|
581
|
-
onLoad: {
|
|
582
|
-
type: 'onLoad'
|
|
583
|
-
} & NavigationEventInfo
|
|
584
|
-
onResolved: {
|
|
585
|
-
type: 'onResolved'
|
|
586
|
-
} & NavigationEventInfo
|
|
587
|
-
onBeforeRouteMount: {
|
|
588
|
-
type: 'onBeforeRouteMount'
|
|
589
|
-
} & NavigationEventInfo
|
|
590
|
-
onInjectedHtml: {
|
|
591
|
-
type: 'onInjectedHtml'
|
|
592
|
-
promise: Promise<string>
|
|
593
|
-
}
|
|
594
|
-
onRendered: {
|
|
595
|
-
type: 'onRendered'
|
|
596
|
-
} & NavigationEventInfo
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
export type RouterEvent = RouterEvents[keyof RouterEvents]
|
|
600
|
-
|
|
601
|
-
export type RouterListener<TRouterEvent extends RouterEvent> = {
|
|
602
|
-
eventType: TRouterEvent['type']
|
|
603
|
-
fn: ListenerFn<TRouterEvent>
|
|
604
|
-
}
|
|
605
|
-
|
|
606
203
|
export function createRouter<
|
|
607
204
|
TRouteTree extends AnyRoute,
|
|
608
205
|
TTrailingSlashOption extends TrailingSlashOption,
|
|
609
206
|
TRouterHistory extends RouterHistory = RouterHistory,
|
|
610
207
|
TDehydrated extends Record<string, any> = Record<string, any>,
|
|
611
|
-
TSerializedError extends Record<string, any> = Record<string, any>,
|
|
612
208
|
>(
|
|
613
209
|
options: undefined extends number
|
|
614
210
|
? 'strictNullChecks must be enabled in tsconfig.json'
|
|
615
211
|
: RouterConstructorOptions<
|
|
616
212
|
TRouteTree,
|
|
617
213
|
TTrailingSlashOption,
|
|
214
|
+
false,
|
|
618
215
|
TRouterHistory,
|
|
619
216
|
TDehydrated
|
|
620
217
|
>,
|
|
621
|
-
)
|
|
218
|
+
): CoreRouter<
|
|
219
|
+
TRouteTree,
|
|
220
|
+
TTrailingSlashOption,
|
|
221
|
+
false,
|
|
222
|
+
TRouterHistory,
|
|
223
|
+
TDehydrated
|
|
224
|
+
> {
|
|
622
225
|
return new Router<
|
|
623
226
|
TRouteTree,
|
|
624
227
|
TTrailingSlashOption,
|
|
625
228
|
TRouterHistory,
|
|
626
|
-
TDehydrated
|
|
627
|
-
TSerializedError
|
|
229
|
+
TDehydrated
|
|
628
230
|
>(options)
|
|
629
231
|
}
|
|
630
232
|
|
|
631
|
-
type MatchRoutesOpts = {
|
|
632
|
-
preload?: boolean
|
|
633
|
-
throwOnError?: boolean
|
|
634
|
-
_buildLocation?: boolean
|
|
635
|
-
dest?: BuildNextOptions
|
|
636
|
-
}
|
|
637
|
-
|
|
638
233
|
export class Router<
|
|
639
234
|
in out TRouteTree extends AnyRoute,
|
|
640
235
|
in out TTrailingSlashOption extends TrailingSlashOption,
|
|
641
236
|
in out TRouterHistory extends RouterHistory = RouterHistory,
|
|
642
237
|
in out TDehydrated extends Record<string, any> = Record<string, any>,
|
|
643
|
-
|
|
644
|
-
|
|
238
|
+
> implements
|
|
239
|
+
CoreRouter<
|
|
240
|
+
TRouteTree,
|
|
241
|
+
TTrailingSlashOption,
|
|
242
|
+
false,
|
|
243
|
+
TRouterHistory,
|
|
244
|
+
TDehydrated
|
|
245
|
+
>
|
|
246
|
+
{
|
|
645
247
|
// Option-independent properties
|
|
646
248
|
tempLocationKey: string | undefined = `${Math.round(
|
|
647
249
|
Math.random() * 10000000,
|
|
@@ -660,6 +262,7 @@ export class Router<
|
|
|
660
262
|
RouterOptions<
|
|
661
263
|
TRouteTree,
|
|
662
264
|
TTrailingSlashOption,
|
|
265
|
+
false,
|
|
663
266
|
TRouterHistory,
|
|
664
267
|
TDehydrated
|
|
665
268
|
>,
|
|
@@ -682,6 +285,7 @@ export class Router<
|
|
|
682
285
|
options: RouterConstructorOptions<
|
|
683
286
|
TRouteTree,
|
|
684
287
|
TTrailingSlashOption,
|
|
288
|
+
false,
|
|
685
289
|
TRouterHistory,
|
|
686
290
|
TDehydrated
|
|
687
291
|
>,
|
|
@@ -706,16 +310,15 @@ export class Router<
|
|
|
706
310
|
// These are default implementations that can optionally be overridden
|
|
707
311
|
// by the router provider once rendered. We provide these so that the
|
|
708
312
|
// router can be used in a non-react environment if necessary
|
|
709
|
-
|
|
313
|
+
startTransition: StartTransitionFn = (fn) => fn()
|
|
710
314
|
|
|
711
|
-
update
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
) => {
|
|
315
|
+
update: UpdateFn<
|
|
316
|
+
TRouteTree,
|
|
317
|
+
TTrailingSlashOption,
|
|
318
|
+
false,
|
|
319
|
+
TRouterHistory,
|
|
320
|
+
TDehydrated
|
|
321
|
+
> = (newOptions) => {
|
|
719
322
|
if (newOptions.notFoundRoute) {
|
|
720
323
|
console.warn(
|
|
721
324
|
'The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info.',
|
|
@@ -924,10 +527,7 @@ export class Router<
|
|
|
924
527
|
})
|
|
925
528
|
}
|
|
926
529
|
|
|
927
|
-
subscribe =
|
|
928
|
-
eventType: TType,
|
|
929
|
-
fn: ListenerFn<RouterEvents[TType]>,
|
|
930
|
-
) => {
|
|
530
|
+
subscribe: SubscribeFn = (eventType, fn) => {
|
|
931
531
|
const listener: RouterListener<any> = {
|
|
932
532
|
eventType,
|
|
933
533
|
fn,
|
|
@@ -940,7 +540,7 @@ export class Router<
|
|
|
940
540
|
}
|
|
941
541
|
}
|
|
942
542
|
|
|
943
|
-
emit = (routerEvent
|
|
543
|
+
emit: EmitFn = (routerEvent) => {
|
|
944
544
|
this.subscribers.forEach((listener) => {
|
|
945
545
|
if (listener.eventType === routerEvent.type) {
|
|
946
546
|
listener.fn(routerEvent)
|
|
@@ -948,10 +548,10 @@ export class Router<
|
|
|
948
548
|
})
|
|
949
549
|
}
|
|
950
550
|
|
|
951
|
-
parseLocation = (
|
|
952
|
-
previousLocation
|
|
953
|
-
locationToParse
|
|
954
|
-
)
|
|
551
|
+
parseLocation: ParseLocationFn<TRouteTree> = (
|
|
552
|
+
previousLocation,
|
|
553
|
+
locationToParse,
|
|
554
|
+
) => {
|
|
955
555
|
const parse = ({
|
|
956
556
|
pathname,
|
|
957
557
|
search,
|
|
@@ -1015,21 +615,12 @@ export class Router<
|
|
|
1015
615
|
): Array<AnyRouteMatch>;
|
|
1016
616
|
```
|
|
1017
617
|
*/
|
|
1018
|
-
public matchRoutes(
|
|
1019
|
-
pathname: string,
|
|
1020
|
-
locationSearch: AnySchema,
|
|
1021
|
-
opts?: MatchRoutesOpts,
|
|
1022
|
-
): Array<AnyRouteMatch>
|
|
1023
|
-
public matchRoutes(
|
|
1024
|
-
next: ParsedLocation,
|
|
1025
|
-
opts?: MatchRoutesOpts,
|
|
1026
|
-
): Array<AnyRouteMatch>
|
|
1027
618
|
|
|
1028
|
-
public matchRoutes(
|
|
619
|
+
public matchRoutes: MatchRoutesFn = (
|
|
1029
620
|
pathnameOrNext: string | ParsedLocation,
|
|
1030
621
|
locationSearchOrOpts?: AnySchema | MatchRoutesOpts,
|
|
1031
622
|
opts?: MatchRoutesOpts,
|
|
1032
|
-
) {
|
|
623
|
+
) => {
|
|
1033
624
|
if (typeof pathnameOrNext === 'string') {
|
|
1034
625
|
return this.matchRoutesInternal(
|
|
1035
626
|
{
|
|
@@ -1355,7 +946,7 @@ export class Router<
|
|
|
1355
946
|
return matches
|
|
1356
947
|
}
|
|
1357
948
|
|
|
1358
|
-
getMatchedRoutes = (next
|
|
949
|
+
getMatchedRoutes: GetMatchRoutesFn = (next, dest) => {
|
|
1359
950
|
let routeParams: Record<string, string> = {}
|
|
1360
951
|
const trimmedPath = trimPathRight(next.pathname)
|
|
1361
952
|
const getMatchedParams = (route: AnyRoute) => {
|
|
@@ -1719,11 +1310,11 @@ export class Router<
|
|
|
1719
1310
|
|
|
1720
1311
|
commitLocationPromise: undefined | ControlledPromise<void>
|
|
1721
1312
|
|
|
1722
|
-
commitLocation = ({
|
|
1313
|
+
commitLocation: CommitLocationFn = ({
|
|
1723
1314
|
viewTransition,
|
|
1724
1315
|
ignoreBlocker,
|
|
1725
1316
|
...next
|
|
1726
|
-
}
|
|
1317
|
+
}) => {
|
|
1727
1318
|
const isSameState = () => {
|
|
1728
1319
|
// the following props are ignored but may still be provided when navigating,
|
|
1729
1320
|
// temporarily add the previous values to the next state so they don't affect
|
|
@@ -1863,7 +1454,7 @@ export class Router<
|
|
|
1863
1454
|
|
|
1864
1455
|
latestLoadPromise: undefined | Promise<void>
|
|
1865
1456
|
|
|
1866
|
-
load = async (opts
|
|
1457
|
+
load: LoadFn = async (opts) => {
|
|
1867
1458
|
this.latestLocation = this.parseLocation(this.latestLocation)
|
|
1868
1459
|
|
|
1869
1460
|
let redirect: ResolvedRedirect | undefined
|
|
@@ -1873,7 +1464,7 @@ export class Router<
|
|
|
1873
1464
|
|
|
1874
1465
|
// eslint-disable-next-line prefer-const
|
|
1875
1466
|
loadPromise = new Promise<void>((resolve) => {
|
|
1876
|
-
this.
|
|
1467
|
+
this.startTransition(async () => {
|
|
1877
1468
|
try {
|
|
1878
1469
|
const next = this.latestLocation
|
|
1879
1470
|
const prevLocation = this.state.resolvedLocation
|
|
@@ -2077,10 +1668,7 @@ export class Router<
|
|
|
2077
1668
|
}
|
|
2078
1669
|
}
|
|
2079
1670
|
|
|
2080
|
-
updateMatch = (
|
|
2081
|
-
id: string,
|
|
2082
|
-
updater: (match: AnyRouteMatch) => AnyRouteMatch,
|
|
2083
|
-
) => {
|
|
1671
|
+
updateMatch: UpdateMatchFn = (id, updater) => {
|
|
2084
1672
|
let updated!: AnyRouteMatch
|
|
2085
1673
|
const isPending = this.state.pendingMatches?.find((d) => d.id === id)
|
|
2086
1674
|
const isMatched = this.state.matches.find((d) => d.id === id)
|
|
@@ -2106,7 +1694,7 @@ export class Router<
|
|
|
2106
1694
|
return updated
|
|
2107
1695
|
}
|
|
2108
1696
|
|
|
2109
|
-
getMatch = (matchId
|
|
1697
|
+
getMatch: GetMatchFn = (matchId) => {
|
|
2110
1698
|
return [
|
|
2111
1699
|
...this.state.cachedMatches,
|
|
2112
1700
|
...(this.state.pendingMatches ?? []),
|
|
@@ -2287,16 +1875,17 @@ export class Router<
|
|
|
2287
1875
|
if (executeBeforeLoad) {
|
|
2288
1876
|
// If we are not in the middle of a load OR the previous load failed, start it
|
|
2289
1877
|
try {
|
|
2290
|
-
updateMatch(matchId, (prev) =>
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
1878
|
+
updateMatch(matchId, (prev) => {
|
|
1879
|
+
// explicitly capture the previous loadPromise
|
|
1880
|
+
const prevLoadPromise = prev.loadPromise
|
|
1881
|
+
return {
|
|
1882
|
+
...prev,
|
|
1883
|
+
loadPromise: createControlledPromise<void>(() => {
|
|
1884
|
+
prevLoadPromise?.resolve()
|
|
1885
|
+
}),
|
|
1886
|
+
beforeLoadPromise: createControlledPromise<void>(),
|
|
1887
|
+
}
|
|
1888
|
+
})
|
|
2300
1889
|
const abortController = new AbortController()
|
|
2301
1890
|
|
|
2302
1891
|
let pendingTimeout: ReturnType<typeof setTimeout>
|
|
@@ -2669,12 +2258,9 @@ export class Router<
|
|
|
2669
2258
|
return matches
|
|
2670
2259
|
}
|
|
2671
2260
|
|
|
2672
|
-
invalidate
|
|
2673
|
-
filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean
|
|
2674
|
-
sync?: boolean
|
|
2675
|
-
}) => {
|
|
2261
|
+
invalidate: InvalidateFn<this> = (opts) => {
|
|
2676
2262
|
const invalidate = (d: MakeRouteMatch<TRouteTree>) => {
|
|
2677
|
-
if (opts?.filter?.(d as MakeRouteMatchUnion<
|
|
2263
|
+
if (opts?.filter?.(d as MakeRouteMatchUnion<this>) ?? true) {
|
|
2678
2264
|
return {
|
|
2679
2265
|
...d,
|
|
2680
2266
|
invalid: true,
|
|
@@ -2706,16 +2292,14 @@ export class Router<
|
|
|
2706
2292
|
return redirect
|
|
2707
2293
|
}
|
|
2708
2294
|
|
|
2709
|
-
clearCache
|
|
2710
|
-
filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean
|
|
2711
|
-
}) => {
|
|
2295
|
+
clearCache: ClearCacheFn<this> = (opts) => {
|
|
2712
2296
|
const filter = opts?.filter
|
|
2713
2297
|
if (filter !== undefined) {
|
|
2714
2298
|
this.__store.setState((s) => {
|
|
2715
2299
|
return {
|
|
2716
2300
|
...s,
|
|
2717
2301
|
cachedMatches: s.cachedMatches.filter(
|
|
2718
|
-
(m) => !filter(m as MakeRouteMatchUnion<
|
|
2302
|
+
(m) => !filter(m as MakeRouteMatchUnion<this>),
|
|
2719
2303
|
),
|
|
2720
2304
|
}
|
|
2721
2305
|
})
|
|
@@ -2782,26 +2366,12 @@ export class Router<
|
|
|
2782
2366
|
return route._componentsPromise
|
|
2783
2367
|
}
|
|
2784
2368
|
|
|
2785
|
-
preloadRoute
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
>(
|
|
2791
|
-
opts: NavigateOptions<
|
|
2792
|
-
Router<
|
|
2793
|
-
TRouteTree,
|
|
2794
|
-
TTrailingSlashOption,
|
|
2795
|
-
TRouterHistory,
|
|
2796
|
-
TDehydrated,
|
|
2797
|
-
TSerializedError
|
|
2798
|
-
>,
|
|
2799
|
-
TFrom,
|
|
2800
|
-
TTo,
|
|
2801
|
-
TMaskFrom,
|
|
2802
|
-
TMaskTo
|
|
2803
|
-
>,
|
|
2804
|
-
): Promise<Array<AnyRouteMatch> | undefined> => {
|
|
2369
|
+
preloadRoute: PreloadRouteFn<
|
|
2370
|
+
TRouteTree,
|
|
2371
|
+
TTrailingSlashOption,
|
|
2372
|
+
false,
|
|
2373
|
+
TRouterHistory
|
|
2374
|
+
> = async (opts) => {
|
|
2805
2375
|
const next = this.buildLocation(opts as any)
|
|
2806
2376
|
|
|
2807
2377
|
let matches = this.matchRoutes(next, {
|
|
@@ -2867,24 +2437,12 @@ export class Router<
|
|
|
2867
2437
|
}
|
|
2868
2438
|
}
|
|
2869
2439
|
|
|
2870
|
-
matchRoute
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
Router<
|
|
2877
|
-
TRouteTree,
|
|
2878
|
-
TTrailingSlashOption,
|
|
2879
|
-
TRouterHistory,
|
|
2880
|
-
TDehydrated,
|
|
2881
|
-
TSerializedError
|
|
2882
|
-
>,
|
|
2883
|
-
TFrom,
|
|
2884
|
-
TTo
|
|
2885
|
-
>,
|
|
2886
|
-
opts?: MatchRouteOptions,
|
|
2887
|
-
): false | RouteById<TRouteTree, TResolved>['types']['allParams'] => {
|
|
2440
|
+
matchRoute: MatchRouteFn<
|
|
2441
|
+
TRouteTree,
|
|
2442
|
+
TTrailingSlashOption,
|
|
2443
|
+
false,
|
|
2444
|
+
TRouterHistory
|
|
2445
|
+
> = (location, opts) => {
|
|
2888
2446
|
const matchLocation = {
|
|
2889
2447
|
...location,
|
|
2890
2448
|
to: location.to
|