@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.
Files changed (140) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/dist/cjs/Matches.cjs +13 -0
  4. package/dist/cjs/Matches.cjs.map +1 -0
  5. package/dist/cjs/Matches.d.cts +28 -0
  6. package/dist/cjs/RouterProvider.d.cts +18 -0
  7. package/dist/cjs/defer.cjs +25 -0
  8. package/dist/cjs/defer.cjs.map +1 -0
  9. package/dist/cjs/defer.d.cts +20 -0
  10. package/dist/cjs/index.cjs +50 -0
  11. package/dist/cjs/index.cjs.map +1 -0
  12. package/dist/cjs/index.d.cts +25 -0
  13. package/dist/cjs/link.cjs +5 -0
  14. package/dist/cjs/link.cjs.map +1 -0
  15. package/dist/cjs/link.d.cts +51 -0
  16. package/dist/cjs/location.d.cts +12 -0
  17. package/dist/cjs/manifest.d.cts +24 -0
  18. package/dist/cjs/path.cjs +289 -0
  19. package/dist/cjs/path.cjs.map +1 -0
  20. package/dist/cjs/path.d.cts +34 -0
  21. package/dist/cjs/qss.cjs +51 -0
  22. package/dist/cjs/qss.cjs.map +1 -0
  23. package/dist/cjs/qss.d.cts +27 -0
  24. package/dist/cjs/root.cjs +5 -0
  25. package/dist/cjs/root.cjs.map +1 -0
  26. package/dist/cjs/root.d.cts +2 -0
  27. package/dist/cjs/route.d.cts +148 -0
  28. package/dist/cjs/router.cjs +19 -0
  29. package/dist/cjs/router.cjs.map +1 -0
  30. package/dist/cjs/router.d.cts +31 -0
  31. package/dist/cjs/searchMiddleware.cjs +42 -0
  32. package/dist/cjs/searchMiddleware.cjs.map +1 -0
  33. package/dist/cjs/searchMiddleware.d.cts +5 -0
  34. package/dist/cjs/searchParams.cjs +61 -0
  35. package/dist/cjs/searchParams.cjs.map +1 -0
  36. package/dist/cjs/searchParams.d.cts +7 -0
  37. package/dist/cjs/serializer.d.cts +15 -0
  38. package/dist/cjs/structuralSharing.d.cts +4 -0
  39. package/dist/cjs/utils.cjs +155 -0
  40. package/dist/cjs/utils.cjs.map +1 -0
  41. package/dist/cjs/utils.d.cts +81 -0
  42. package/dist/cjs/validators.d.cts +51 -0
  43. package/dist/esm/Matches.d.ts +28 -0
  44. package/dist/esm/Matches.js +13 -0
  45. package/dist/esm/Matches.js.map +1 -0
  46. package/dist/esm/RouterProvider.d.ts +18 -0
  47. package/dist/esm/defer.d.ts +20 -0
  48. package/dist/esm/defer.js +25 -0
  49. package/dist/esm/defer.js.map +1 -0
  50. package/dist/esm/index.d.ts +25 -0
  51. package/dist/esm/index.js +50 -0
  52. package/dist/esm/index.js.map +1 -0
  53. package/dist/esm/link.d.ts +51 -0
  54. package/dist/esm/link.js +5 -0
  55. package/dist/esm/link.js.map +1 -0
  56. package/dist/esm/location.d.ts +12 -0
  57. package/dist/esm/manifest.d.ts +24 -0
  58. package/dist/esm/path.d.ts +34 -0
  59. package/dist/esm/path.js +289 -0
  60. package/dist/esm/path.js.map +1 -0
  61. package/dist/esm/qss.d.ts +27 -0
  62. package/dist/esm/qss.js +51 -0
  63. package/dist/esm/qss.js.map +1 -0
  64. package/dist/esm/root.d.ts +2 -0
  65. package/dist/esm/root.js +5 -0
  66. package/dist/esm/root.js.map +1 -0
  67. package/dist/esm/route.d.ts +148 -0
  68. package/dist/esm/router.d.ts +31 -0
  69. package/dist/esm/router.js +19 -0
  70. package/dist/esm/router.js.map +1 -0
  71. package/dist/esm/searchMiddleware.d.ts +5 -0
  72. package/dist/esm/searchMiddleware.js +42 -0
  73. package/dist/esm/searchMiddleware.js.map +1 -0
  74. package/dist/esm/searchParams.d.ts +7 -0
  75. package/dist/esm/searchParams.js +61 -0
  76. package/dist/esm/searchParams.js.map +1 -0
  77. package/dist/esm/serializer.d.ts +15 -0
  78. package/dist/esm/structuralSharing.d.ts +4 -0
  79. package/dist/esm/utils.d.ts +81 -0
  80. package/dist/esm/utils.js +155 -0
  81. package/dist/esm/utils.js.map +1 -0
  82. package/dist/esm/validators.d.ts +51 -0
  83. package/package.json +35 -32
  84. package/src/Matches.ts +94 -0
  85. package/src/RouterProvider.ts +20 -0
  86. package/src/defer.ts +52 -0
  87. package/src/index.ts +206 -19
  88. package/src/link.ts +122 -300
  89. package/src/location.ts +13 -0
  90. package/src/manifest.ts +32 -0
  91. package/src/path.ts +238 -47
  92. package/src/qss.ts +56 -19
  93. package/src/root.ts +2 -0
  94. package/src/route.ts +296 -223
  95. package/src/router.ts +34 -1281
  96. package/src/searchMiddleware.ts +54 -0
  97. package/src/searchParams.ts +43 -20
  98. package/src/serializer.ts +24 -0
  99. package/src/structuralSharing.ts +7 -0
  100. package/src/utils.ts +314 -75
  101. package/src/validators.ts +121 -0
  102. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -33
  103. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  104. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
  105. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
  106. package/build/cjs/node_modules/history/index.js +0 -815
  107. package/build/cjs/node_modules/history/index.js.map +0 -1
  108. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
  109. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
  110. package/build/cjs/packages/router-core/src/index.js +0 -58
  111. package/build/cjs/packages/router-core/src/index.js.map +0 -1
  112. package/build/cjs/packages/router-core/src/path.js +0 -222
  113. package/build/cjs/packages/router-core/src/path.js.map +0 -1
  114. package/build/cjs/packages/router-core/src/qss.js +0 -71
  115. package/build/cjs/packages/router-core/src/qss.js.map +0 -1
  116. package/build/cjs/packages/router-core/src/route.js +0 -150
  117. package/build/cjs/packages/router-core/src/route.js.map +0 -1
  118. package/build/cjs/packages/router-core/src/routeConfig.js +0 -69
  119. package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
  120. package/build/cjs/packages/router-core/src/routeMatch.js +0 -266
  121. package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
  122. package/build/cjs/packages/router-core/src/router.js +0 -822
  123. package/build/cjs/packages/router-core/src/router.js.map +0 -1
  124. package/build/cjs/packages/router-core/src/searchParams.js +0 -70
  125. package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
  126. package/build/cjs/packages/router-core/src/utils.js +0 -125
  127. package/build/cjs/packages/router-core/src/utils.js.map +0 -1
  128. package/build/esm/index.js +0 -2481
  129. package/build/esm/index.js.map +0 -1
  130. package/build/stats-html.html +0 -4034
  131. package/build/stats-react.json +0 -493
  132. package/build/types/index.d.ts +0 -618
  133. package/build/umd/index.development.js +0 -2514
  134. package/build/umd/index.development.js.map +0 -1
  135. package/build/umd/index.production.js +0 -12
  136. package/build/umd/index.production.js.map +0 -1
  137. package/src/frameworks.ts +0 -12
  138. package/src/routeConfig.ts +0 -495
  139. package/src/routeInfo.ts +0 -228
  140. package/src/routeMatch.ts +0 -374
package/src/link.ts CHANGED
@@ -1,319 +1,141 @@
1
- import { AnyPathParams } from './routeConfig'
2
- import {
3
- AnyAllRouteInfo,
4
- DefaultAllRouteInfo,
5
- RouteInfoByPath,
6
- } from './routeInfo'
7
- import { Location } from './router'
8
- import { Expand, NoInfer, PickAsRequired, PickRequired, Updater } from './utils'
9
-
10
- export type LinkInfo =
11
- | {
12
- type: 'external'
13
- href: string
14
- }
15
- | {
16
- type: 'internal'
17
- next: Location
18
- handleFocus: (e: any) => void
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 Split<S, TIncludeTrailingSlash = true> = S extends unknown
39
- ? string extends S
40
- ? string[]
41
- : S extends string
42
- ? CleanPath<S> extends ''
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 ToPathOption<
186
- TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
187
- TFrom extends ValidFromPath<TAllRouteInfo> = '/',
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 ToIdOption<
198
- TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
199
- TFrom extends ValidFromPath<TAllRouteInfo> = '/',
200
- TTo extends string = '.',
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 type LinkOptions<
215
- TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
216
- TFrom extends ValidFromPath<TAllRouteInfo> = '/',
217
- TTo extends string = '.',
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
- // Defaults to `{ exact: false, includeHash: false }`
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
- // If set, will preload the linked route on hover and cache it for this many milliseconds in hopes that the user will eventually navigate there.
224
- preload?: false | 'intent'
225
- // When preloaded, the preloaded result will be considered "fresh" for this duration in milliseconds
226
- preloadMaxAge?: number
227
- // When preloaded and subsequently inactive, the preloaded result will remain in memory for this duration in milliseconds
228
- preloadGcMaxAge?: number
229
- // Delay intent preloading by this many milliseconds. If the intent exits before this delay, the preload will be cancelled.
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
- // If true, will render the link without the href attribute
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
- export type CheckRelativePath<
236
- TAllRouteInfo extends AnyAllRouteInfo,
237
- TFrom,
238
- TTo,
239
- > = TTo extends string
240
- ? TFrom extends string
241
- ? ResolveRelativePath<TFrom, TTo> extends TAllRouteInfo['routePaths']
242
- ? {}
243
- : {
244
- Error: `${TFrom} + ${TTo} resolves to ${ResolveRelativePath<
245
- TFrom,
246
- TTo
247
- >}, which is not a valid route path.`
248
- 'Valid Route Paths': TAllRouteInfo['routePaths']
249
- }
250
- : {}
251
- : {}
252
-
253
- export type CheckPath<
254
- TAllRouteInfo extends AnyAllRouteInfo,
255
- TPath,
256
- TPass,
257
- > = Exclude<TPath, TAllRouteInfo['routePaths']> extends never
258
- ? TPass
259
- : CheckPathError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routePaths']>>
260
-
261
- export type CheckPathError<
262
- TAllRouteInfo extends AnyAllRouteInfo,
263
- TInvalids,
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 ResolveRelativePath<TFrom, TTo = '.'> = TFrom extends string
290
- ? TTo extends string
291
- ? TTo extends '.'
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
- ? Join<[TFrom, '/']>
295
- : TTo extends `./${infer TRest}`
296
- ? ResolveRelativePath<TFrom, TRest>
297
- : TTo extends `/${infer TRest}`
298
- ? TTo
299
- : Split<TTo> extends ['..', ...infer ToRest]
300
- ? Split<TFrom> extends [...infer FromRest, infer FromTail]
301
- ? ToRest extends ['/']
302
- ? Join<[...FromRest, '/']>
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 ValidFromPath<
314
- TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
315
- > =
316
- | undefined
317
- | (string extends TAllRouteInfo['routePaths']
318
- ? string
319
- : TAllRouteInfo['routePaths'])
137
+ export type LinkCurrentTargetElement = {
138
+ preloadTimeout?: null | ReturnType<typeof setTimeout>
139
+ }
140
+
141
+ export const preloadWarning = 'Error preloading route! ☝️'
@@ -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
+ }
@@ -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
+ }