@tanstack/router-core 0.0.1-beta.9 → 1.97.24
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/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/cjs/Matches.cjs +13 -0
- package/dist/cjs/Matches.cjs.map +1 -0
- package/dist/cjs/Matches.d.cts +28 -0
- package/dist/cjs/RouterProvider.d.cts +18 -0
- package/dist/cjs/defer.cjs +25 -0
- package/dist/cjs/defer.cjs.map +1 -0
- package/dist/cjs/defer.d.cts +20 -0
- package/dist/cjs/index.cjs +50 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +25 -0
- package/dist/cjs/link.cjs +5 -0
- package/dist/cjs/link.cjs.map +1 -0
- package/dist/cjs/link.d.cts +51 -0
- package/dist/cjs/location.d.cts +12 -0
- package/dist/cjs/manifest.d.cts +24 -0
- package/dist/cjs/path.cjs +289 -0
- package/dist/cjs/path.cjs.map +1 -0
- package/dist/cjs/path.d.cts +34 -0
- package/dist/cjs/qss.cjs +51 -0
- package/dist/cjs/qss.cjs.map +1 -0
- package/dist/cjs/qss.d.cts +27 -0
- package/dist/cjs/root.cjs +5 -0
- package/dist/cjs/root.cjs.map +1 -0
- package/dist/cjs/root.d.cts +2 -0
- package/dist/cjs/route.d.cts +148 -0
- package/dist/cjs/router.cjs +19 -0
- package/dist/cjs/router.cjs.map +1 -0
- package/dist/cjs/router.d.cts +31 -0
- package/dist/cjs/searchMiddleware.cjs +42 -0
- package/dist/cjs/searchMiddleware.cjs.map +1 -0
- package/dist/cjs/searchMiddleware.d.cts +5 -0
- package/dist/cjs/searchParams.cjs +61 -0
- package/dist/cjs/searchParams.cjs.map +1 -0
- package/dist/cjs/searchParams.d.cts +7 -0
- package/dist/cjs/serializer.d.cts +15 -0
- package/dist/cjs/structuralSharing.d.cts +4 -0
- package/dist/cjs/utils.cjs +155 -0
- package/dist/cjs/utils.cjs.map +1 -0
- package/dist/cjs/utils.d.cts +81 -0
- package/dist/cjs/validators.d.cts +51 -0
- package/dist/esm/Matches.d.ts +28 -0
- package/dist/esm/Matches.js +13 -0
- package/dist/esm/Matches.js.map +1 -0
- package/dist/esm/RouterProvider.d.ts +18 -0
- package/dist/esm/defer.d.ts +20 -0
- package/dist/esm/defer.js +25 -0
- package/dist/esm/defer.js.map +1 -0
- package/dist/esm/index.d.ts +25 -0
- package/dist/esm/index.js +50 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/link.d.ts +51 -0
- package/dist/esm/link.js +5 -0
- package/dist/esm/link.js.map +1 -0
- package/dist/esm/location.d.ts +12 -0
- package/dist/esm/manifest.d.ts +24 -0
- package/dist/esm/path.d.ts +34 -0
- package/dist/esm/path.js +289 -0
- package/dist/esm/path.js.map +1 -0
- package/dist/esm/qss.d.ts +27 -0
- package/dist/esm/qss.js +51 -0
- package/dist/esm/qss.js.map +1 -0
- package/dist/esm/root.d.ts +2 -0
- package/dist/esm/root.js +5 -0
- package/dist/esm/root.js.map +1 -0
- package/dist/esm/route.d.ts +148 -0
- package/dist/esm/router.d.ts +31 -0
- package/dist/esm/router.js +19 -0
- package/dist/esm/router.js.map +1 -0
- package/dist/esm/searchMiddleware.d.ts +5 -0
- package/dist/esm/searchMiddleware.js +42 -0
- package/dist/esm/searchMiddleware.js.map +1 -0
- package/dist/esm/searchParams.d.ts +7 -0
- package/dist/esm/searchParams.js +61 -0
- package/dist/esm/searchParams.js.map +1 -0
- package/dist/esm/serializer.d.ts +15 -0
- package/dist/esm/structuralSharing.d.ts +4 -0
- package/dist/esm/utils.d.ts +81 -0
- package/dist/esm/utils.js +155 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/esm/validators.d.ts +51 -0
- package/package.json +35 -32
- package/src/Matches.ts +94 -0
- package/src/RouterProvider.ts +20 -0
- package/src/defer.ts +52 -0
- package/src/index.ts +206 -19
- package/src/link.ts +122 -300
- package/src/location.ts +13 -0
- package/src/manifest.ts +32 -0
- package/src/path.ts +238 -47
- package/src/qss.ts +56 -19
- package/src/root.ts +2 -0
- package/src/route.ts +296 -223
- package/src/router.ts +34 -1281
- package/src/searchMiddleware.ts +54 -0
- package/src/searchParams.ts +43 -20
- package/src/serializer.ts +24 -0
- package/src/structuralSharing.ts +7 -0
- package/src/utils.ts +314 -75
- package/src/validators.ts +121 -0
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -33
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
- package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
- package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
- package/build/cjs/node_modules/history/index.js +0 -815
- package/build/cjs/node_modules/history/index.js.map +0 -1
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
- package/build/cjs/packages/router-core/src/index.js +0 -58
- package/build/cjs/packages/router-core/src/index.js.map +0 -1
- package/build/cjs/packages/router-core/src/path.js +0 -222
- package/build/cjs/packages/router-core/src/path.js.map +0 -1
- package/build/cjs/packages/router-core/src/qss.js +0 -71
- package/build/cjs/packages/router-core/src/qss.js.map +0 -1
- package/build/cjs/packages/router-core/src/route.js +0 -150
- package/build/cjs/packages/router-core/src/route.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeConfig.js +0 -69
- package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeMatch.js +0 -266
- package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
- package/build/cjs/packages/router-core/src/router.js +0 -822
- package/build/cjs/packages/router-core/src/router.js.map +0 -1
- package/build/cjs/packages/router-core/src/searchParams.js +0 -70
- package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
- package/build/cjs/packages/router-core/src/utils.js +0 -125
- package/build/cjs/packages/router-core/src/utils.js.map +0 -1
- package/build/esm/index.js +0 -2481
- package/build/esm/index.js.map +0 -1
- package/build/stats-html.html +0 -4034
- package/build/stats-react.json +0 -493
- package/build/types/index.d.ts +0 -618
- package/build/umd/index.development.js +0 -2514
- package/build/umd/index.development.js.map +0 -1
- package/build/umd/index.production.js +0 -12
- package/build/umd/index.production.js.map +0 -1
- package/src/frameworks.ts +0 -12
- package/src/routeConfig.ts +0 -495
- package/src/routeInfo.ts +0 -228
- package/src/routeMatch.ts +0 -374
package/src/link.ts
CHANGED
|
@@ -1,319 +1,141 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
handleClick: (e: any) => void
|
|
20
|
-
handleEnter: (e: any) => void
|
|
21
|
-
handleLeave: (e: any) => void
|
|
22
|
-
isActive: boolean
|
|
23
|
-
disabled?: boolean
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
type StartsWith<A, B> = A extends `${B extends string ? B : never}${infer _}`
|
|
27
|
-
? true
|
|
28
|
-
: false
|
|
29
|
-
|
|
30
|
-
type CleanPath<T extends string> = T extends `${infer L}//${infer R}`
|
|
31
|
-
? CleanPath<`${CleanPath<L>}/${CleanPath<R>}`>
|
|
32
|
-
: T extends `${infer L}//`
|
|
33
|
-
? `${CleanPath<L>}/`
|
|
34
|
-
: T extends `//${infer L}`
|
|
35
|
-
? `/${CleanPath<L>}`
|
|
1
|
+
export type IsRequiredParams<TParams> =
|
|
2
|
+
Record<never, never> extends TParams ? never : true
|
|
3
|
+
|
|
4
|
+
export type ParsePathParams<T extends string, TAcc = never> = T &
|
|
5
|
+
`${string}$${string}` extends never
|
|
6
|
+
? TAcc
|
|
7
|
+
: T extends `${string}$${infer TPossiblyParam}`
|
|
8
|
+
? TPossiblyParam extends ''
|
|
9
|
+
? TAcc
|
|
10
|
+
: TPossiblyParam & `${string}/${string}` extends never
|
|
11
|
+
? TPossiblyParam | TAcc
|
|
12
|
+
: TPossiblyParam extends `${infer TParam}/${infer TRest}`
|
|
13
|
+
? ParsePathParams<TRest, TParam extends '' ? TAcc : TParam | TAcc>
|
|
14
|
+
: never
|
|
15
|
+
: TAcc
|
|
16
|
+
|
|
17
|
+
export type AddTrailingSlash<T> = T & `${string}/` extends never
|
|
18
|
+
? `${T & string}/`
|
|
36
19
|
: T
|
|
37
20
|
|
|
38
|
-
export type
|
|
39
|
-
?
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
? []
|
|
44
|
-
: TIncludeTrailingSlash extends true
|
|
45
|
-
? CleanPath<S> extends `${infer T}/`
|
|
46
|
-
? [...Split<T>, '/']
|
|
47
|
-
: CleanPath<S> extends `/${infer U}`
|
|
48
|
-
? Split<U>
|
|
49
|
-
: CleanPath<S> extends `${infer T}/${infer U}`
|
|
50
|
-
? [...Split<T>, ...Split<U>]
|
|
51
|
-
: [S]
|
|
52
|
-
: CleanPath<S> extends `${infer T}/${infer U}`
|
|
53
|
-
? [...Split<T>, ...Split<U>]
|
|
54
|
-
: S extends string
|
|
55
|
-
? [S]
|
|
56
|
-
: never
|
|
57
|
-
: never
|
|
58
|
-
: never
|
|
59
|
-
|
|
60
|
-
export type ParsePathParams<T extends string> = Split<T>[number] extends infer U
|
|
61
|
-
? U extends `:${infer V}`
|
|
62
|
-
? V
|
|
63
|
-
: never
|
|
64
|
-
: never
|
|
65
|
-
|
|
66
|
-
type Join<T> = T extends []
|
|
67
|
-
? ''
|
|
68
|
-
: T extends [infer L extends string]
|
|
69
|
-
? L
|
|
70
|
-
: T extends [infer L extends string, ...infer Tail extends [...string[]]]
|
|
71
|
-
? CleanPath<`${L}/${Join<Tail>}`>
|
|
72
|
-
: never
|
|
73
|
-
|
|
74
|
-
export type RelativeToPathAutoComplete<
|
|
75
|
-
AllPaths extends string,
|
|
76
|
-
TFrom extends string,
|
|
77
|
-
TTo extends string,
|
|
78
|
-
SplitPaths extends string[] = Split<AllPaths, false>,
|
|
79
|
-
> = TTo extends `..${infer _}`
|
|
80
|
-
? SplitPaths extends [
|
|
81
|
-
...Split<ResolveRelativePath<TFrom, TTo>, false>,
|
|
82
|
-
...infer TToRest,
|
|
83
|
-
]
|
|
84
|
-
? `${CleanPath<
|
|
85
|
-
Join<
|
|
86
|
-
[
|
|
87
|
-
...Split<TTo, false>,
|
|
88
|
-
...(
|
|
89
|
-
| TToRest
|
|
90
|
-
| (Split<
|
|
91
|
-
ResolveRelativePath<TFrom, TTo>,
|
|
92
|
-
false
|
|
93
|
-
>['length'] extends 1
|
|
94
|
-
? never
|
|
95
|
-
: ['../'])
|
|
96
|
-
),
|
|
97
|
-
]
|
|
98
|
-
>
|
|
99
|
-
>}`
|
|
100
|
-
: never
|
|
101
|
-
: TTo extends `./${infer RestTTo}`
|
|
102
|
-
? SplitPaths extends [
|
|
103
|
-
...Split<TFrom, false>,
|
|
104
|
-
...Split<RestTTo, false>,
|
|
105
|
-
...infer RestPath,
|
|
106
|
-
]
|
|
107
|
-
? `${TTo}${Join<RestPath>}`
|
|
108
|
-
: never
|
|
109
|
-
: './' | '../' | AllPaths
|
|
110
|
-
|
|
111
|
-
export type NavigateOptionsAbsolute<
|
|
112
|
-
TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
|
|
113
|
-
TFrom extends ValidFromPath<TAllRouteInfo> = '/',
|
|
114
|
-
TTo extends string = '.',
|
|
115
|
-
> = ToOptions<TAllRouteInfo, TFrom, TTo> & {
|
|
116
|
-
// Whether to replace the current history stack instead of pushing a new one
|
|
117
|
-
replace?: boolean
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export type ToOptions<
|
|
121
|
-
TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
|
|
122
|
-
TFrom extends ValidFromPath<TAllRouteInfo> = '/',
|
|
123
|
-
TTo extends string = '.',
|
|
124
|
-
TResolvedTo = ResolveRelativePath<TFrom, NoInfer<TTo>>,
|
|
125
|
-
> = {
|
|
126
|
-
to?: ToPathOption<TAllRouteInfo, TFrom, TTo>
|
|
127
|
-
// The new has string or a function to update it
|
|
128
|
-
hash?: Updater<string>
|
|
129
|
-
// The source route path. This is automatically set when using route-level APIs, but for type-safe relative routing on the router itself, this is required
|
|
130
|
-
from?: TFrom
|
|
131
|
-
// // When using relative route paths, this option forces resolution from the current path, instead of the route API's path or `from` path
|
|
132
|
-
// fromCurrent?: boolean
|
|
133
|
-
} & CheckPath<TAllRouteInfo, NoInfer<TResolvedTo>, {}> &
|
|
134
|
-
SearchParamOptions<TAllRouteInfo, TFrom, TResolvedTo> &
|
|
135
|
-
PathParamOptions<TAllRouteInfo, TFrom, TResolvedTo>
|
|
136
|
-
|
|
137
|
-
type SearchParamOptions<
|
|
138
|
-
TAllRouteInfo extends AnyAllRouteInfo,
|
|
139
|
-
TFrom,
|
|
140
|
-
TTo,
|
|
141
|
-
TFromSchema = RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema'],
|
|
142
|
-
TToSchema = RouteInfoByPath<TAllRouteInfo, TTo>['fullSearchSchema'],
|
|
143
|
-
> = StartsWith<TFrom, TTo> extends true // If the next route search extend or cover the from route, params will be optional
|
|
144
|
-
? {
|
|
145
|
-
search?: SearchReducer<TFromSchema, TToSchema>
|
|
146
|
-
}
|
|
147
|
-
: // Optional search params? Allow it
|
|
148
|
-
keyof PickRequired<TToSchema> extends never
|
|
149
|
-
? {
|
|
150
|
-
search?: SearchReducer<TFromSchema, TToSchema>
|
|
151
|
-
}
|
|
152
|
-
: {
|
|
153
|
-
// Must have required search params, enforce it
|
|
154
|
-
search: SearchReducer<TFromSchema, TToSchema>
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
type SearchReducer<TFrom, TTo> =
|
|
158
|
-
| { [TKey in keyof TTo]: TTo[TKey] }
|
|
159
|
-
| ((current: TFrom) => TTo)
|
|
160
|
-
|
|
161
|
-
type PathParamOptions<
|
|
162
|
-
TAllRouteInfo extends AnyAllRouteInfo,
|
|
163
|
-
TFrom,
|
|
164
|
-
TTo,
|
|
165
|
-
TFromParams = RouteInfoByPath<TAllRouteInfo, TFrom>['allParams'],
|
|
166
|
-
TToParams = RouteInfoByPath<TAllRouteInfo, TTo>['allParams'],
|
|
167
|
-
> =
|
|
168
|
-
// If the next routes params extend or cover the from route, params will be optional
|
|
169
|
-
StartsWith<TFrom, TTo> extends true
|
|
170
|
-
? {
|
|
171
|
-
params?: ParamsReducer<TFromParams, TToParams>
|
|
172
|
-
}
|
|
173
|
-
: // If the next route doesn't have params, warn if any have been passed
|
|
174
|
-
AnyPathParams extends TToParams
|
|
175
|
-
? {
|
|
176
|
-
params?: ParamsReducer<TFromParams, Record<string, never>>
|
|
177
|
-
}
|
|
178
|
-
: // If the next route has params, enforce them
|
|
179
|
-
{
|
|
180
|
-
params: ParamsReducer<TFromParams, TToParams>
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
type ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo)
|
|
21
|
+
export type RemoveTrailingSlashes<T> = T & `${string}/` extends never
|
|
22
|
+
? T
|
|
23
|
+
: T extends `${infer R}/`
|
|
24
|
+
? R
|
|
25
|
+
: T
|
|
184
26
|
|
|
185
|
-
export type
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
TTo extends string = '.',
|
|
189
|
-
> =
|
|
190
|
-
| TTo
|
|
191
|
-
| RelativeToPathAutoComplete<
|
|
192
|
-
TAllRouteInfo['routePaths'],
|
|
193
|
-
NoInfer<TFrom> extends string ? NoInfer<TFrom> : '',
|
|
194
|
-
NoInfer<TTo> & string
|
|
195
|
-
>
|
|
27
|
+
export type AddLeadingSlash<T> = T & `/${string}` extends never
|
|
28
|
+
? `/${T & string}`
|
|
29
|
+
: T
|
|
196
30
|
|
|
197
|
-
export type
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
| TTo
|
|
203
|
-
| RelativeToPathAutoComplete<
|
|
204
|
-
TAllRouteInfo['routeIds'],
|
|
205
|
-
NoInfer<TFrom> extends string ? NoInfer<TFrom> : '',
|
|
206
|
-
NoInfer<TTo> & string
|
|
207
|
-
>
|
|
31
|
+
export type RemoveLeadingSlashes<T> = T & `/${string}` extends never
|
|
32
|
+
? T
|
|
33
|
+
: T extends `/${infer R}`
|
|
34
|
+
? R
|
|
35
|
+
: T
|
|
208
36
|
|
|
209
|
-
interface ActiveOptions {
|
|
37
|
+
export interface ActiveOptions {
|
|
210
38
|
exact?: boolean
|
|
211
39
|
includeHash?: boolean
|
|
40
|
+
includeSearch?: boolean
|
|
41
|
+
explicitUndefined?: boolean
|
|
212
42
|
}
|
|
213
43
|
|
|
214
|
-
export
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
> = NavigateOptionsAbsolute<TAllRouteInfo, TFrom, TTo> & {
|
|
219
|
-
// The standard anchor tag target attribute
|
|
44
|
+
export interface LinkOptionsProps {
|
|
45
|
+
/**
|
|
46
|
+
* The standard anchor tag target attribute
|
|
47
|
+
*/
|
|
220
48
|
target?: HTMLAnchorElement['target']
|
|
221
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Configurable options to determine if the link should be considered active or not
|
|
51
|
+
* @default {exact:true,includeHash:true}
|
|
52
|
+
*/
|
|
222
53
|
activeOptions?: ActiveOptions
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
54
|
+
/**
|
|
55
|
+
* The preloading strategy for this link
|
|
56
|
+
* - `false` - No preloading
|
|
57
|
+
* - `'intent'` - Preload the linked route on hover and cache it for this many milliseconds in hopes that the user will eventually navigate there.
|
|
58
|
+
* - `'viewport'` - Preload the linked route when it enters the viewport
|
|
59
|
+
*/
|
|
60
|
+
preload?: false | 'intent' | 'viewport' | 'render'
|
|
61
|
+
/**
|
|
62
|
+
* When a preload strategy is set, this delays the preload by this many milliseconds.
|
|
63
|
+
* If the user exits the link before this delay, the preload will be cancelled.
|
|
64
|
+
*/
|
|
230
65
|
preloadDelay?: number
|
|
231
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Control whether the link should be disabled or not
|
|
68
|
+
* If set to `true`, the link will be rendered without an `href` attribute
|
|
69
|
+
* @default false
|
|
70
|
+
*/
|
|
232
71
|
disabled?: boolean
|
|
233
72
|
}
|
|
234
73
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
>
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
> = Expand<{
|
|
265
|
-
Error: `${TInvalids extends string
|
|
266
|
-
? TInvalids
|
|
267
|
-
: never} is not a valid route path.`
|
|
268
|
-
'Valid Route Paths': TAllRouteInfo['routePaths']
|
|
269
|
-
}>
|
|
270
|
-
|
|
271
|
-
export type CheckId<
|
|
272
|
-
TAllRouteInfo extends AnyAllRouteInfo,
|
|
273
|
-
TPath,
|
|
274
|
-
TPass,
|
|
275
|
-
> = Exclude<TPath, TAllRouteInfo['routeIds']> extends never
|
|
276
|
-
? TPass
|
|
277
|
-
: CheckIdError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routeIds']>>
|
|
278
|
-
|
|
279
|
-
export type CheckIdError<
|
|
280
|
-
TAllRouteInfo extends AnyAllRouteInfo,
|
|
281
|
-
TInvalids,
|
|
282
|
-
> = Expand<{
|
|
283
|
-
Error: `${TInvalids extends string
|
|
284
|
-
? TInvalids
|
|
285
|
-
: never} is not a valid route ID.`
|
|
286
|
-
'Valid Route IDs': TAllRouteInfo['routeIds']
|
|
287
|
-
}>
|
|
74
|
+
type JoinPath<TLeft extends string, TRight extends string> = TRight extends ''
|
|
75
|
+
? TLeft
|
|
76
|
+
: TLeft extends ''
|
|
77
|
+
? TRight
|
|
78
|
+
: `${RemoveTrailingSlashes<TLeft>}/${RemoveLeadingSlashes<TRight>}`
|
|
79
|
+
|
|
80
|
+
type RemoveLastSegment<
|
|
81
|
+
T extends string,
|
|
82
|
+
TAcc extends string = '',
|
|
83
|
+
> = T extends `${infer TSegment}/${infer TRest}`
|
|
84
|
+
? TRest & `${string}/${string}` extends never
|
|
85
|
+
? TRest extends ''
|
|
86
|
+
? TAcc
|
|
87
|
+
: `${TAcc}${TSegment}`
|
|
88
|
+
: RemoveLastSegment<TRest, `${TAcc}${TSegment}/`>
|
|
89
|
+
: TAcc
|
|
90
|
+
|
|
91
|
+
export type ResolveCurrentPath<
|
|
92
|
+
TFrom extends string,
|
|
93
|
+
TTo extends string,
|
|
94
|
+
> = TTo extends '.'
|
|
95
|
+
? TFrom
|
|
96
|
+
: TTo extends './'
|
|
97
|
+
? AddTrailingSlash<TFrom>
|
|
98
|
+
: TTo & `./${string}` extends never
|
|
99
|
+
? never
|
|
100
|
+
: TTo extends `./${infer TRest}`
|
|
101
|
+
? AddLeadingSlash<JoinPath<TFrom, TRest>>
|
|
102
|
+
: never
|
|
288
103
|
|
|
289
|
-
export type
|
|
290
|
-
|
|
291
|
-
|
|
104
|
+
export type ResolveParentPath<
|
|
105
|
+
TFrom extends string,
|
|
106
|
+
TTo extends string,
|
|
107
|
+
> = TTo extends '../' | '..'
|
|
108
|
+
? TFrom extends '' | '/'
|
|
109
|
+
? never
|
|
110
|
+
: AddLeadingSlash<RemoveLastSegment<TFrom>>
|
|
111
|
+
: TTo & `../${string}` extends never
|
|
112
|
+
? AddLeadingSlash<JoinPath<TFrom, TTo>>
|
|
113
|
+
: TFrom extends '' | '/'
|
|
114
|
+
? never
|
|
115
|
+
: TTo extends `../${infer ToRest}`
|
|
116
|
+
? ResolveParentPath<RemoveLastSegment<TFrom>, ToRest>
|
|
117
|
+
: AddLeadingSlash<JoinPath<TFrom, TTo>>
|
|
118
|
+
|
|
119
|
+
export type ResolveRelativePath<TFrom, TTo = '.'> = string extends TFrom
|
|
120
|
+
? TTo
|
|
121
|
+
: string extends TTo
|
|
122
|
+
? TFrom
|
|
123
|
+
: undefined extends TTo
|
|
292
124
|
? TFrom
|
|
293
|
-
: TTo extends
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
: ResolveRelativePath<Join<FromRest>, Join<ToRest>>
|
|
125
|
+
: TTo extends string
|
|
126
|
+
? TFrom extends string
|
|
127
|
+
? TTo extends `/${string}`
|
|
128
|
+
? TTo
|
|
129
|
+
: TTo extends `..${string}`
|
|
130
|
+
? ResolveParentPath<TFrom, TTo>
|
|
131
|
+
: TTo extends `.${string}`
|
|
132
|
+
? ResolveCurrentPath<TFrom, TTo>
|
|
133
|
+
: AddLeadingSlash<JoinPath<TFrom, TTo>>
|
|
134
|
+
: never
|
|
304
135
|
: never
|
|
305
|
-
: Split<TTo> extends ['.', ...infer ToRest]
|
|
306
|
-
? ToRest extends ['/']
|
|
307
|
-
? Join<[TFrom, '/']>
|
|
308
|
-
: ResolveRelativePath<TFrom, Join<ToRest>>
|
|
309
|
-
: CleanPath<Join<['/', ...Split<TFrom>, ...Split<TTo>]>>
|
|
310
|
-
: never
|
|
311
|
-
: never
|
|
312
136
|
|
|
313
|
-
export type
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
? string
|
|
319
|
-
: TAllRouteInfo['routePaths'])
|
|
137
|
+
export type LinkCurrentTargetElement = {
|
|
138
|
+
preloadTimeout?: null | ReturnType<typeof setTimeout>
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export const preloadWarning = 'Error preloading route! ☝️'
|
package/src/location.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ParsedHistoryState } from '@tanstack/history'
|
|
2
|
+
import type { AnySchema } from './validators'
|
|
3
|
+
|
|
4
|
+
export interface ParsedLocation<TSearchObj extends AnySchema = {}> {
|
|
5
|
+
href: string
|
|
6
|
+
pathname: string
|
|
7
|
+
search: TSearchObj
|
|
8
|
+
searchStr: string
|
|
9
|
+
state: ParsedHistoryState
|
|
10
|
+
hash: string
|
|
11
|
+
maskedLocation?: ParsedLocation<TSearchObj>
|
|
12
|
+
unmaskOnReload?: boolean
|
|
13
|
+
}
|
package/src/manifest.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type Manifest = {
|
|
2
|
+
routes: Record<
|
|
3
|
+
string,
|
|
4
|
+
{
|
|
5
|
+
filePath?: string
|
|
6
|
+
preloads?: Array<string>
|
|
7
|
+
assets?: Array<RouterManagedTag>
|
|
8
|
+
}
|
|
9
|
+
>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type RouterManagedTag =
|
|
13
|
+
| {
|
|
14
|
+
tag: 'title'
|
|
15
|
+
attrs?: Record<string, any>
|
|
16
|
+
children: string
|
|
17
|
+
}
|
|
18
|
+
| {
|
|
19
|
+
tag: 'meta' | 'link'
|
|
20
|
+
attrs?: Record<string, any>
|
|
21
|
+
children?: never
|
|
22
|
+
}
|
|
23
|
+
| {
|
|
24
|
+
tag: 'script'
|
|
25
|
+
attrs?: Record<string, any>
|
|
26
|
+
children?: string
|
|
27
|
+
}
|
|
28
|
+
| {
|
|
29
|
+
tag: 'style'
|
|
30
|
+
attrs?: Record<string, any>
|
|
31
|
+
children?: string
|
|
32
|
+
}
|